public MinecraftServerGui(DedicatedServer serverIn) { this.server = serverIn; this.setPreferredSize(new Dimension(854, 480)); this.setLayout(new BorderLayout()); try { this.add(this.getLogComponent(), "Center"); this.add(this.getStatsComponent(), "West"); } catch (Exception exception) { LOGGER.error((String)"Couldn\'t build server GUI", (Throwable)exception); } }
@Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { if (sender instanceof DedicatedServer) return true; EntityPlayerMP player = (EntityPlayerMP) sender; GameProfile profile = player.getGameProfile(); UserListOpsEntry opEntry = (UserListOpsEntry) WorldBorder.SERVER .getPlayerList() .getOppedPlayers() .getEntry(profile); // Level 2 (out of 4) have general access to game-changing commands // TODO: Make this a configuration option return opEntry != null && opEntry.getPermissionLevel() > 2; }
@Override public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; EntityPlayerMP player = (EntityPlayerMP) sender; GameProfile profile = player.getGameProfile(); UserListOpsEntry opEntry = (UserListOpsEntry) WorldBorder.SERVER .getConfigurationManager() .func_152603_m() .func_152683_b(profile); // Level 2 (out of 4) have general access to game-changing commands // TODO: Make this a configuration option return opEntry != null && opEntry.func_152644_a() > 2; }
public MinecraftServerGui(DedicatedServer p_i2362_1_) { this.field_120021_b = p_i2362_1_; this.setPreferredSize(new Dimension(854, 480)); this.setLayout(new BorderLayout()); try { this.add(this.getLogComponent(), "Center"); this.add(this.getStatsComponent(), "West"); } catch (Exception exception) { field_164248_b.error("Couldn\'t build server GUI", exception); } }
public DedicatedPlayerList(DedicatedServer p_i1503_1_) { super(p_i1503_1_); this.field_72423_e = p_i1503_1_.func_71209_f("ops.txt"); this.field_72422_f = p_i1503_1_.func_71209_f("white-list.txt"); this.field_72402_d = p_i1503_1_.func_71327_a("view-distance", 10); this.field_72405_c = p_i1503_1_.func_71327_a("max-players", 20); this.func_72371_a(p_i1503_1_.func_71332_a("white-list", false)); if(!p_i1503_1_.func_71264_H()) { this.func_72390_e().func_73708_a(true); this.func_72363_f().func_73708_a(true); } this.func_72390_e().func_73707_e(); this.func_72390_e().func_73711_f(); this.func_72363_f().func_73707_e(); this.func_72363_f().func_73711_f(); this.func_72417_t(); this.func_72418_v(); this.func_72419_u(); if(!this.field_72422_f.exists()) { this.func_72421_w(); } }
public static void func_120016_a(DedicatedServer p_120016_0_) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception var3) { ; } MinecraftServerGui var1 = new MinecraftServerGui(p_120016_0_); field_120022_a = true; JFrame var2 = new JFrame("Minecraft server"); var2.add(var1); var2.pack(); var2.setLocationRelativeTo((Component)null); var2.setVisible(true); var2.addWindowListener(new MinecraftServerGuiINNER1(p_120016_0_)); }
public static void func_120016_a(DedicatedServer par0DedicatedServer) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { ; } MinecraftServerGui minecraftservergui = new MinecraftServerGui(par0DedicatedServer); field_120022_a = true; JFrame jframe = new JFrame("Minecraft server"); jframe.add(minecraftservergui); jframe.pack(); jframe.setLocationRelativeTo((Component)null); jframe.setVisible(true); jframe.addWindowListener(new MinecraftServerGuiINNER1(par0DedicatedServer)); }
public MinecraftServerGui(DedicatedServer par1DedicatedServer) { this.field_120021_b = par1DedicatedServer; this.setPreferredSize(new Dimension(854, 480)); this.setLayout(new BorderLayout()); try { this.add(this.func_120018_d(), "Center"); this.add(this.func_120019_b(), "West"); } catch (Exception exception) { exception.printStackTrace(); } }
@Override public void resuscitateWatchdog() { DedicatedServer server = (DedicatedServer) instance().getMinecraftServerInstance(); if (server.getMaxTickTime() > 0L) { Thread thread1 = new Thread(new ServerHangWatchdog(server)); thread1.setName("Server Watchdog"); thread1.setDaemon(true); thread1.start(); CreeperHostServer.logger.info("Performing CPR. Server Watchdog is alive again!"); } }
/** * Creates the server GUI and sets it visible for the user. */ public static void createServerGui(final DedicatedServer serverIn) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception var3) { ; } MinecraftServerGui minecraftservergui = new MinecraftServerGui(serverIn); JFrame jframe = new JFrame("Minecraft server"); jframe.add(minecraftservergui); jframe.pack(); jframe.setLocationRelativeTo((Component)null); jframe.setVisible(true); jframe.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent p_windowClosing_1_) { serverIn.initiateShutdown(); while (!serverIn.isServerStopped()) { try { Thread.sleep(100L); } catch (InterruptedException interruptedexception) { interruptedexception.printStackTrace(); } } System.exit(0); } }); }
/** * Sends an automatically translated and formatted message to a command sender * @param sender Target to send message to * @param msg String or language key to broadcast */ public static void chat(ICommandSender sender, String msg, Object... parts) { String translated = translate(msg); // Consoles require ANSI coloring for formatting if (sender instanceof DedicatedServer) Log.info( removeFormatting(translated), parts ); else { translated = String.format(translated, parts); sender.addChatMessage( new TextComponentString(translated) ); } }
@Override public void queryUser(StartupQuery query) throws InterruptedException { if (query.getResult() == null) { FMLLog.warning("%s", query.getText()); query.finish(); } else { String text = query.getText() + "\n\nRun the command /fml confirm or or /fml cancel to proceed." + "\nAlternatively start the server with -Dfml.queryResult=confirm or -Dfml.queryResult=cancel to preselect the answer."; FMLLog.warning("%s", text); if (!query.isSynchronous()) return; // no-op until mc does commands in another thread (if ever) boolean done = false; while (!done && server.isServerRunning()) { if (Thread.interrupted()) throw new InterruptedException(); DedicatedServer dedServer = (DedicatedServer) server; // rudimentary command processing, check for fml confirm/cancel and stop commands synchronized (dedServer.pendingCommandList) { for (Iterator<PendingCommand> it = GenericIterableFactory.newCastingIterable(dedServer.pendingCommandList, PendingCommand.class).iterator(); it.hasNext(); ) { String cmd = it.next().command.trim().toLowerCase(); if (cmd.equals("/fml confirm")) { FMLLog.info("confirmed"); query.setResult(true); done = true; it.remove(); } else if (cmd.equals("/fml cancel")) { FMLLog.info("cancelled"); query.setResult(false); done = true; it.remove(); } else if (cmd.equals("/stop")) { StartupQuery.abort(); } } } Thread.sleep(10L); } query.finish(); } }
@Nonnull private DedicatedServer constructServerInstance(@Nonnull BundleContext ctx) { logger.info("Initializing Minecraft %s", FaucetVersion.API_VERSION); Bootstrap.register(); // apparently this is how the registries work ... don't question it // log some environment information logger.info("Running on Java v%s supplied by %s", System.getProperty("java.version", "Unknown"), System.getProperty("java.vendor")); // TODO: Integrate with plugins here? YggdrasilAuthenticationService var15 = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); MinecraftSessionService var16 = var15.createMinecraftSessionService(); GameProfileRepository var17 = var15.createProfileRepository(); PlayerProfileCache var18 = new PlayerProfileCache(var17, new File(".", "usercache.json")); DedicatedServer server = new DedicatedServer(new File("."), DataFixesManager.createFixer(), var15, var16, var17, var18); // TODO: Re-introduce configuration if (!GraphicsEnvironment.isHeadless()) { logger.info("Server GUI has been disabled or is unavailable in this environment"); // TODO: Custom GUI } else { logger .info("Server GUI has been disabled or is not available within the current environment"); } return server; }
@SuppressWarnings("ThisEscapedInObjectConstruction") SinkServer(@Nonnull BundleContext ctx, @Nonnull DedicatedServer server) { this.ctx = ctx; this.server = server; this.injector = Guice.createInjector(Peaberry.osgiModule(ctx), this); this.injector.injectMembers(this); logger.debug("Faucet services are ready for consumption"); }
/** * Sends an automatically translated and formatted message to a command sender * @param sender Target to send message to * @param msg String or language key to broadcast */ public static void chat(ICommandSender sender, String msg, Object... parts) { String translated = translate(msg); // Consoles require ANSI coloring for formatting if (sender instanceof DedicatedServer) Log.info( removeFormatting(translated), parts ); else { translated = String.format(translated, parts); sender.addChatMessage( new ChatComponentText(translated) ); } }
@Override public <T extends FMLStateEvent> boolean applyStateEventPatch(T e) { FMLServerAboutToStartEvent event = (FMLServerAboutToStartEvent) e; try { Constructor<PlayerList> ctor; if (event.getServer().isDedicatedServer()) ctor = (Constructor<PlayerList>) (Constructor<?>) DedicatedPlayerList.class.getDeclaredConstructor(DedicatedServer.class); else ctor = (Constructor<PlayerList>) (Constructor<?>) IntegratedPlayerList.class.getDeclaredConstructor(IntegratedServer.class); ctor.setAccessible(true); if (event.getServer().isDedicatedServer()) event.getServer().setPlayerList(ctor.newInstance((DedicatedServer) event.getServer())); else event.getServer().setPlayerList(ctor.newInstance((IntegratedServer) event.getServer())); PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true); return true; } catch (Exception ex) { PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, false); return false; } }
private void loadWorld(DedicatedServer server, AnvilSaveConverter saveLoader, String world, long seed, WorldType type, String genSettings) { if (this.loadWorlds != null) { try { server.getPlayerList().saveAllPlayerData(); this.loadWorlds.invoke(server, world, world, seed, type == null ? WorldType.DEFAULT : type, genSettings); server.setFolderName(world); for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { transferPlayer(server, player); } } catch (Exception ex) {ex.printStackTrace(); return;} } }
public void preLoad(DedicatedServer server){ CommandBase.setAdminCommander(null); //Don't spam my log with stupid messages TileEntity.addMapping(TileEntityStatEmitter.class, "Nailed:StatEmitter"); TileEntity.addMapping(OldStatEmitterConverter.class, "nailed.stat"); pluginsDir.mkdir(); NailedPluginManager.instance().loadPlugins(pluginsDir); NailedEventFactory.fireEvent(new RegisterMappacksEvent(NailedMappackRegistry.instance(), NailedMapLoader.instance())); NailedCommandManager.registerPluginCommands(); }
public MinecraftServerGui(DedicatedServer p_i2362_1_) { this.field_120021_b = p_i2362_1_; this.setPreferredSize(new Dimension(854, 480)); this.setLayout(new BorderLayout()); try { this.add(this.func_120018_d(), "Center"); this.add(this.func_120019_b(), "West"); } catch (Exception var3) { var3.printStackTrace(); } }
@Override public boolean needsToBeKilled() { return ((DedicatedServer) instance().getMinecraftServerInstance()).getMaxTickTime() > 0; }
@Override public boolean shouldAllowPlayerLogins() { return DedicatedServer.allowPlayerLogins; }
@Override public void allowLogins() { DedicatedServer.allowPlayerLogins = true; }
public static boolean handleCommands(DedicatedServer server) { final ConsoleReader reader = TerminalConsoleAppender.getReader(); if (reader != null) { TerminalConsoleAppender.setFormatter(new ConsoleFormatter()); reader.addCompleter(new ConsoleCommandCompleter(server)); String line; while (!server.isServerStopped() && server.isServerRunning()) { try { line = reader.readLine("> "); if (line == null) { break; } line = line.trim(); if (!line.isEmpty()) { server.addPendingCommand(line, server); } } catch (IOException e) { logger.error("Exception handling console input", e); } } return true; } else { TerminalConsoleAppender.setFormatter(new Function<String, String>() { @Override public String apply(String text) { return TextFormatting.getTextWithoutFormattingCodes(text); } }); return false; } }
public ConsoleCommandCompleter(DedicatedServer server) { this.server = checkNotNull(server, "server"); }
/** * Creates the server GUI and sets it visible for the user. */ public static void createServerGui(final DedicatedServer serverIn) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception var3) { ; } MinecraftServerGui minecraftservergui = new MinecraftServerGui(serverIn); JFrame jframe = new JFrame("Minecraft server"); jframe.add(minecraftservergui); jframe.pack(); jframe.setLocationRelativeTo((Component)null); jframe.setVisible(true); jframe.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent p_windowClosing_1_) { serverIn.initiateShutdown(); while (!serverIn.isServerStopped()) { try { Thread.sleep(100L); } catch (InterruptedException interruptedexception) { interruptedexception.printStackTrace(); } } System.exit(0); } }); minecraftservergui.latch.countDown(); }
@Override public void queryUser(StartupQuery query) throws InterruptedException { if (query.getResult() == null) { FMLLog.warning("%s", query.getText()); query.finish(); } else { String text = query.getText() + "\n\nRun the command /fml confirm or or /fml cancel to proceed." + "\nAlternatively start the server with -Dfml.queryResult=confirm or -Dfml.queryResult=cancel to preselect the answer."; FMLLog.warning("%s", text); if (!query.isSynchronous()) return; // no-op until mc does commands in another thread (if ever) boolean done = false; while (!done && server.func_71278_l()) { if (Thread.interrupted()) throw new InterruptedException(); DedicatedServer dedServer = (DedicatedServer) server; // rudimentary command processing, check for fml confirm/cancel and stop commands synchronized (dedServer.field_71341_l) { for (Iterator<ServerCommand> it = GenericIterableFactory.newCastingIterable(dedServer.field_71341_l, ServerCommand.class).iterator(); it.hasNext(); ) { String cmd = it.next().field_73702_a.trim().toLowerCase(); if (cmd.equals("/fml confirm")) { FMLLog.info("confirmed"); query.setResult(true); done = true; it.remove(); } else if (cmd.equals("/fml cancel")) { FMLLog.info("cancelled"); query.setResult(false); done = true; it.remove(); } else if (cmd.equals("/stop")) { StartupQuery.abort(); } } } Thread.sleep(10L); } query.finish(); } }
/** * {@inheritDoc} */ @Nonnull @Override public DedicatedServer getHandle() { return server; }
@Override public void queryUser(StartupQuery query) throws InterruptedException { if (query.getResult() == null) { FMLLog.warning("%s", query.getText()); query.finish(); } else { String text = query.getText() + "\n\nRun the command /fml confirm or or /fml cancel to proceed." + "\nAlternatively start the server with -Dfml.queryResult=confirm or -Dfml.queryResult=cancel to preselect the answer."; FMLLog.warning("%s", text); if (!query.isSynchronous()) return; // no-op until mc does commands in another thread (if ever) boolean done = false; while (!done && server.isServerRunning()) { if (Thread.interrupted()) throw new InterruptedException(); DedicatedServer dedServer = (DedicatedServer) server; // rudimentary command processing, check for fml confirm/cancel and stop commands synchronized (dedServer.pendingCommandList) { for (Iterator<ServerCommand> it = GenericIterableFactory.newCastingIterable(dedServer.pendingCommandList, ServerCommand.class).iterator(); it.hasNext(); ) { String cmd = it.next().command.trim().toLowerCase(); if (cmd.equals("/fml confirm")) { FMLLog.info("confirmed"); query.setResult(true); done = true; it.remove(); } else if (cmd.equals("/fml cancel")) { FMLLog.info("cancelled"); query.setResult(false); done = true; it.remove(); } else if (cmd.equals("/stop")) { StartupQuery.abort(); } } } Thread.sleep(10L); } query.finish(); } }
DedicatedPlayerList(DedicatedServer server) { super(server); }