@SideOnly(Side.SERVER) public static void InjectDedicated(MinecraftServer server) { PlayerList playerList = server.getPlayerList(); try { if (playerList instanceof DedicatedPlayerList) { server.setPlayerList(new HookedDedicatedPlayerList((DedicatedPlayerList)playerList)); } else { // uh ho... Util.logger.error("Unable to inject custom PlayerList into server due to unknown type! PlayerList was of type {}.", playerList.getClass().toString()); } } catch (IllegalAccessException | NoSuchFieldException | SecurityException e) { Util.logger.logException("Exception trying to inject custom PlayerList into server!", e); } }
/** * {@inheritDoc} */ @Override public void shutdown(@Nullable String reason) { // TODO Fire shutdown event here, once I add it. :) this.server.logInfo("Server Shutdown: " + reason); DedicatedPlayerList playerList = this.server.getPlayerList(); if (playerList != null) { playerList.getPlayers().forEach((p) -> p.connection.disconnect(reason)); } // de-register all services (this isn't required as our framework should clean up when the // bundle shuts down but we'll do it anyways) // TODO: Move into bundle shutdown callback of sorts this.serverExport.unput(); this.server.stopServer(); }
@SuppressWarnings("unchecked") public HookedDedicatedPlayerList(DedicatedPlayerList oldList) throws IllegalAccessException, NoSuchFieldException, SecurityException { super(oldList.getServerInstance()); InjectionHandler.copyAllFieldsFromEx(this, oldList, DedicatedPlayerList.class); mcServer = InjectionHandler.readFieldOfType(PlayerList.class, this, MinecraftServer.class); gameType = InjectionHandler.readFieldOfType(PlayerList.class, this, GameType.class); playerEntityList = InjectionHandler.readFieldOfType(PlayerList.class, this, List.class); uuidToPlayerMap = InjectionHandler.readFieldOfType(PlayerList.class, this, Map.class); }
public DedicatedPlayerList getHandle() { return playerList; }
public DedicatedPlayerList func_71334_ai() { return (DedicatedPlayerList)super.func_71203_ab(); }