Skip to content

Commit

Permalink
not registering event fix, cancelling event if connection is already …
Browse files Browse the repository at this point in the history
…closing
  • Loading branch information
yooniks committed Feb 4, 2019
1 parent 1ad0bfc commit e6c5dc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public void onEnable() {
final ConnectionCloser connectionCloser = new DefaultConnectionCloser(this);

if (this.getConfig().getBoolean("arm-animation.enabled")) {
this.protocolManager.addPacketListener(new ArmAnimationListener(this,
this.getConfig().getLong("arm-animation.timestamp")));
final ArmAnimationListener armAnimationListener = new ArmAnimationListener(this,
this.getConfig().getLong("arm-animation.timestamp"));
this.protocolManager.addPacketListener(armAnimationListener);
this.getServer().getPluginManager().registerEvents(armAnimationListener, this);
}

this.protocolManager.addPacketListener(new ItemPacketListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public ItemPacketListener(Plugin plugin, ConnectionCloser connectionCloser, List
public void onPacketReceiving(PacketEvent event) {
final Player player = event.getPlayer();
if (player == null || this.connectionCloser.isClosing(player)) {
event.setCancelled(true);
return;
}
final PacketContainer packet = event.getPacket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public boolean isInvalid(ItemStack item) {
return compound.getKeys().stream()
.map(compound::getValue)
.anyMatch(value -> value.getName().length() > 100
|| (value.getValue() instanceof String && ((String) value.getValue()).length() > 100)
//not checking every tag in nbtlist =/ i hope it's not needed, cuz nbt has already some limit
|| (value instanceof NbtList && ((NbtList) value).size() > 55));
}

Expand Down

0 comments on commit e6c5dc3

Please sign in to comment.