/** * Allows validation of the connection state transition. Parameters: from, to (connection state). Typically throws * IllegalStateException or UnsupportedOperationException if validation fails */ public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) { Validate.validState(p_147232_2_ == EnumConnectionState.LOGIN || p_147232_2_ == EnumConnectionState.STATUS, "Unexpected protocol " + p_147232_2_, new Object[0]); switch (NetHandlerHandshakeMemory.SwitchEnumConnectionState.field_151263_a[p_147232_2_.ordinal()]) { case 1: this.field_147384_b.setNetHandler(new NetHandlerLoginServer(this.field_147385_a, this.field_147384_b)); break; case 2: throw new UnsupportedOperationException("NYI"); default: } }
/** * Called from {@link NetHandlerLoginServer#tryAcceptPlayer()} */ public static boolean isBlocked(NetHandlerLoginServer login, GameProfile profile) { if(profile == null) return false; UUID uuid = profile.getId(); if(uuid == null) return false; if(Blocker.isBlocked(uuid)) { login.func_194026_b(new TextComponentString(Blocker.MESSAGE)); return true; } return false; }
/** * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention * must pass a versioncheck or receive a disconnect otherwise */ public void processHandshake(C00Handshake packetIn) { if (!net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerHandshake(packetIn, this.networkManager)) return; this.networkManager.setConnectionState(packetIn.getRequestedState()); this.networkManager.setNetHandler(new NetHandlerLoginServer(this.mcServer, this.networkManager)); }
public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) { Validate.validState(p_147232_2_ == EnumConnectionState.LOGIN || p_147232_2_ == EnumConnectionState.STATUS, "Unexpected protocol " + p_147232_2_, new Object[0]); switch (NetHandlerHandshakeMemory.SwitchEnumConnectionState.field_151263_a[p_147232_2_.ordinal()]) { case 1: this.field_147384_b.setNetHandler(new NetHandlerLoginServer(this.field_147385_a, this.field_147384_b)); break; case 2: throw new UnsupportedOperationException("NYI"); default: } }
/** * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention * must pass a versioncheck or receive a disconnect otherwise */ public void processHandshake(C00Handshake packetIn) { this.networkManager.setConnectionState(packetIn.getRequestedState()); this.networkManager.setNetHandler(new NetHandlerLoginServer(this.mcServer, this.networkManager)); }
public EntityPlayerMP attemptLogin(NetHandlerLoginServer loginlistener, GameProfile gameprofile, String hostname) { // Instead of kicking then returning, we need to store the kick reason // in the event, check with plugins to see if it's ok, and THEN kick // depending on the outcome. SocketAddress socketaddress = loginlistener.field_147333_a.getSocketAddress(); EntityPlayerMP entity = new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), gameprofile, new ItemInWorldManager(this.mcServer.worldServerForDimension(0))); Player player = entity.getBukkitEntity(); PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.field_147333_a.getRawAddress()).getAddress()); // Spigot String s; if (this.bannedPlayers.func_152702_a(gameprofile) && !this.bannedPlayers.func_152683_b(gameprofile).hasBanExpired()) { UserListBansEntry banentry = (UserListBansEntry) this.bannedPlayers.func_152683_b(gameprofile); s = "You are banned from this server!\nReason: " + banentry.getBanReason(); if (banentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(banentry.getBanEndDate()); } // return s; event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); } else if (!this.func_152607_e(gameprofile)) { // return "You are not white-listed on this server!"; event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot } else if (this.bannedIPs.func_152708_a(socketaddress) && !this.bannedPlayers.func_152683_b(gameprofile).hasBanExpired()) { IPBanEntry ipbanentry = this.bannedIPs.func_152709_b(socketaddress); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getBanReason(); if (ipbanentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(ipbanentry.getBanEndDate()); } // return s; event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); } else { // return this.players.size() >= this.maxPlayers ? "The server is full!" : null; if (this.playerEntityList.size() >= this.maxPlayers) { event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot } } this.cserver.getPluginManager().callEvent(event); if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { loginlistener.func_147322_a(event.getKickMessage()); return null; } return entity; // CraftBukkit end }