9
9
import org .bukkit .event .entity .EntitySpawnEvent ;
10
10
import org .bukkit .event .player .PlayerCommandPreprocessEvent ;
11
11
import org .bukkit .plugin .java .JavaPlugin ;
12
+ import org .cloudanarchy .queueplugin .packetwrapper .PacketGameState ;
13
+ import org .cloudanarchy .queueplugin .packetwrapper .PacketPlayerInfo ;
12
14
13
15
import java .util .HashSet ;
14
16
import java .util .Set ;
@@ -35,21 +37,37 @@ public void onPacketReceiving(PacketEvent ev) {
35
37
36
38
@ Override
37
39
public void onPacketSending (PacketEvent ev ) {
40
+
38
41
// these are needed or a notchian client will not join
39
42
if (ev .getPacketType () == PacketType .Play .Server .KEEP_ALIVE ) return ;
40
- if (ev .getPacketType () == PacketType .Play .Server .POSITION ) return ;
41
43
if (ev .getPacketType () == PacketType .Play .Server .LOGIN ) return ;
44
+ if (ev .getPacketType () == PacketType .Play .Server .POSITION ) return ;
45
+
46
+ // for chat notifications
42
47
if (ev .getPacketType () == PacketType .Play .Server .CHAT ) return ;
43
48
44
49
// this keeps the player from falling (flying ability)
45
50
if (ev .getPacketType () == PacketType .Play .Server .ABILITIES ) return ;
46
51
47
- // if we dont send this, player has default skin lol
48
- if (ev .getPacketType () == PacketType .Play .Server .PLAYER_INFO ) return ;
49
-
50
52
// this keeps hacked clients from showing server as lagging
51
53
if (ev .getPacketType () == PacketType .Play .Server .UPDATE_TIME ) return ;
52
54
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
+
53
71
ev .setCancelled (true );
54
72
}
55
73
0 commit comments