99import org .bukkit .event .entity .EntitySpawnEvent ;
1010import org .bukkit .event .player .PlayerCommandPreprocessEvent ;
1111import org .bukkit .plugin .java .JavaPlugin ;
12+ import org .cloudanarchy .queueplugin .packetwrapper .PacketGameState ;
13+ import org .cloudanarchy .queueplugin .packetwrapper .PacketPlayerInfo ;
1214
1315import java .util .HashSet ;
1416import java .util .Set ;
@@ -35,21 +37,37 @@ public void onPacketReceiving(PacketEvent ev) {
3537
3638 @ Override
3739 public void onPacketSending (PacketEvent ev ) {
40+
3841 // these are needed or a notchian client will not join
3942 if (ev .getPacketType () == PacketType .Play .Server .KEEP_ALIVE ) return ;
40- if (ev .getPacketType () == PacketType .Play .Server .POSITION ) return ;
4143 if (ev .getPacketType () == PacketType .Play .Server .LOGIN ) return ;
44+ if (ev .getPacketType () == PacketType .Play .Server .POSITION ) return ;
45+
46+ // for chat notifications
4247 if (ev .getPacketType () == PacketType .Play .Server .CHAT ) return ;
4348
4449 // this keeps the player from falling (flying ability)
4550 if (ev .getPacketType () == PacketType .Play .Server .ABILITIES ) return ;
4651
47- // if we dont send this, player has default skin lol
48- if (ev .getPacketType () == PacketType .Play .Server .PLAYER_INFO ) return ;
49-
5052 // this keeps hacked clients from showing server as lagging
5153 if (ev .getPacketType () == PacketType .Play .Server .UPDATE_TIME ) return ;
5254
55+ // if we dont send this, player has default skin lol
56+ if (ev .getPacketType () == PacketType .Play .Server .PLAYER_INFO ) {
57+ PacketPlayerInfo packet = new PacketPlayerInfo (ev .getPacket ());
58+ // send players only their own data? or dont send this packet at all...
59+ if (packet .getData () != null )
60+ packet .setData (packet .getData ().stream ().filter (data -> data .getProfile ().getUUID ().equals (ev .getPlayer ().getUniqueId ())).collect (Collectors .toList ()));
61+ return ;
62+ }
63+
64+ // this is for fun
65+ if (ev .getPacketType () == PacketType .Play .Server .GAME_STATE_CHANGE ) {
66+ PacketGameState packet = new PacketGameState (ev .getPacket ());
67+ // allow credit screen
68+ if (packet .getReason () == 4 && packet .getValue () == 1 ) return ;
69+ }
70+
5371 ev .setCancelled (true );
5472 }
5573
0 commit comments