From f9f7330d857a5b900adbc9c38108390da3e855bc Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Mon, 12 Aug 2019 14:00:35 -0300 Subject: [PATCH 001/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../adapters/AbilitiesPacketAdapter.java | 4 +- .../adapters/ArmAnimationPacketAdapter.java | 4 +- .../adapters/BlockDigPacketAdapter.java | 4 +- .../adapters/BlockPlacePacketAdapter.java | 4 +- .../adapters/CustomPayloadPacketAdapter.java | 10 ++-- .../adapters/KeepAlivePacketAdapter.java | 4 +- .../adapters/PositionPacketAdapter.java | 4 +- .../adapters/WindowClickPacketAdapter.java | 4 +- .../instanceables/BukkitExploitPlayer.java | 8 +-- .../listeners/InventoryCreativeListener.java | 55 +++++++++++-------- .../listeners/PlayerInteractListener.java | 6 +- .../bukkit/modules/BukkitPacketsModule.java | 24 ++++---- .../instanceables/BungeeExploitPlayer.java | 8 +-- .../listeners/PluginMessageListener.java | 10 ++-- .../instanceables/ExploitPlayer.java | 6 +- .../interfaces/modules/PacketsModule.java | 6 +- .../exploitfixer/shared/enums/Identity.java | 6 ++ 19 files changed, 92 insertions(+), 79 deletions(-) create mode 100644 src/twolovers/exploitfixer/shared/enums/Identity.java diff --git a/src/bungee.yml b/src/bungee.yml index fe3b842..4043f6d 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.1 +version: 0.6.2 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index c9c84ba..38ce0bb 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.1 +version: 0.6.2 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java index 6da192b..b899a8f 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class AbilitiesPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public AbilitiesPacketAdapter(final Plugin plugin, final ModuleManager moduleMan @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.ABILITIES); + packetsModule.checkPacket(event, Identity.ABILITIES); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java index f9db41f..69f9ff8 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class ArmAnimationPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public ArmAnimationPacketAdapter(final Plugin plugin, final ModuleManager module @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.ARM_ANIMATION); + packetsModule.checkPacket(event, Identity.ARM_ANIMATION); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 8ca60f6..8f8e10d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class BlockDigPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public BlockDigPacketAdapter(final Plugin plugin, final ModuleManager moduleMana @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.BLOCK_DIG); + packetsModule.checkPacket(event, Identity.BLOCK_DIG); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 3c0cc87..2a568ff 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class BlockPlacePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleMa @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.BLOCK_PLACE); + packetsModule.checkPacket(event, Identity.BLOCK_PLACE); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java index d0b035c..8e7fdd1 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java @@ -13,7 +13,7 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; import java.util.List; @@ -58,9 +58,9 @@ else if (dataSize > 16384) { exploitPlayer.punish(plugin, customPayloadModule, player); event.setCancelled(true); } else if (tag.equals("MC|BSign") || tag.equals("MC|BEdit") || tag.equals("MC|BOpen")) { - exploitPlayer.addViolation(PacketIdentity.CUSTOM_PAYLOAD); + exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD); - final int violations = exploitPlayer.getViolations(PacketIdentity.CUSTOM_PAYLOAD); + final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD); if (violations == customPayloadModule.getLimit()) { exploitPlayer.punish(plugin, customPayloadModule, player); @@ -78,9 +78,9 @@ else if (dataSize > 16384) { } else if (channels > 256) event.setCancelled(true); } else { - exploitPlayer.addViolation(PacketIdentity.CUSTOM_PAYLOAD_OTHER); + exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD_OTHER); - final int violations = exploitPlayer.getViolations(PacketIdentity.CUSTOM_PAYLOAD_OTHER); + final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD_OTHER); if (violations == customPayloadModule.getOtherLimit()) { exploitPlayer.punish(plugin, customPayloadModule, player); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java index 234aa0e..c3ac0cb 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class KeepAlivePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public KeepAlivePacketAdapter(final Plugin plugin, final ModuleManager moduleMan @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.KEEP_ALIVE); + packetsModule.checkPacket(event, Identity.KEEP_ALIVE); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java index 002c49a..ae6ebeb 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class PositionPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public PositionPacketAdapter(final Plugin plugin, final ModuleManager moduleMana @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.POSITION); + packetsModule.checkPacket(event, Identity.POSITION); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 4a83340..df0e99e 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +18,6 @@ public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, PacketIdentity.WINDOW_CLICK); + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index d43eb94..bd81b13 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -7,7 +7,7 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.*; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -20,7 +20,7 @@ public class BukkitExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private HashMap violations = new HashMap<>(); + final private HashMap violations = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -45,11 +45,11 @@ public void addChannels(final int channels) { this.channels += channels; } - public int getViolations(final PacketIdentity identifier) { + public int getViolations(final Identity identifier) { return violations.getOrDefault(identifier, 0); } - public void addViolation(final PacketIdentity identifier) { + public void addViolation(final Identity identifier) { final double currentTime = System.currentTimeMillis(); if (currentTime - lastViolation >= 1000) { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index 6863bee..9476276 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.listeners; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -8,54 +9,60 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.ItemsModule; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.shared.enums.Identity; public class InventoryCreativeListener implements Listener { private final Plugin plugin; private final ItemsModule itemsModule; - private final NotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; public InventoryCreativeListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.itemsModule = moduleManager.getItemsModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onInventoryCreative(final InventoryCreativeEvent event) { - if (!event.isCancelled() && itemsModule.isEnabled()) { + final HumanEntity whoClicked = event.getWhoClicked(); + + if (itemsModule.isEnabled() && whoClicked instanceof Player) { + final Player player = (Player) event.getWhoClicked(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); final ItemStack itemStack = event.getCursor(); final ItemMeta itemMeta = itemStack.getItemMeta(); - if (itemStack.hasItemMeta() && itemMeta instanceof PotionMeta && !((PotionMeta) itemMeta).getCustomEffects().isEmpty()) - event.setCancelled(true); - - if (!event.isCancelled() && itemMeta != null) { - final Player player = (Player) event.getWhoClicked(); - final int itemMetaLenght = itemMeta.toString().length(); + exploitPlayer.addViolation(Identity.INVENTORY_CREATIVE); - if (itemMetaLenght > 16384) { - event.setCancelled(true); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, itemsModule, player); - } else if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().length() > 32) || (itemMeta.hasLore() && itemMeta.getLore().size() > 16)) { + if (exploitPlayer.getViolations(Identity.INVENTORY_CREATIVE) > 20) + event.setCancelled(true); + else { + if (itemStack.hasItemMeta() && itemMeta instanceof PotionMeta && !((PotionMeta) itemMeta).getCustomEffects().isEmpty()) event.setCancelled(true); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, itemsModule, player); - } - } - if (!event.isCancelled() && !itemStack.getEnchantments().isEmpty()) { - final Player player = (Player) event.getWhoClicked(); + if (!event.isCancelled() && itemMeta != null) { + final int itemMetaLenght = itemMeta.toString().length(); - for (int enchantmentLevel : itemStack.getEnchantments().values()) { - if (enchantmentLevel > 10) { + if (itemMetaLenght > 16384) { + event.setCancelled(true); + exploitPlayer.punish(plugin, itemsModule, player); + } else if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().length() > 32) || (itemMeta.hasLore() && itemMeta.getLore().size() > 16)) { event.setCancelled(true); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, itemsModule, player); - break; + exploitPlayer.punish(plugin, itemsModule, player); + } + } + + if (!event.isCancelled() && !itemStack.getEnchantments().isEmpty()) { + for (int enchantmentLevel : itemStack.getEnchantments().values()) { + if (enchantmentLevel > 10) { + event.setCancelled(true); + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, itemsModule, player); + break; + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java index 01b4c4a..25b3fbc 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java @@ -10,7 +10,7 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class PlayerInteractListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; @@ -34,7 +34,7 @@ public void onPlayerInteract(final PlayerInteractEvent event) { if (material == Material.WRITTEN_BOOK || material == Material.BOOK_AND_QUILL) { final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final PacketIdentity name = PacketIdentity.INTERACT_BOOK; + final Identity name = Identity.INTERACT_BOOK; exploitPlayer.addViolation(name); @@ -44,7 +44,7 @@ public void onPlayerInteract(final PlayerInteractEvent event) { } final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final PacketIdentity identifier = PacketIdentity.INTERACT; + final Identity identifier = Identity.INTERACT; exploitPlayer.addViolation(identifier); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index e61d155..42971ad 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -7,7 +7,7 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; import java.util.HashMap; import java.util.List; @@ -15,7 +15,7 @@ public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; - private final Map limits = new HashMap<>(); + private final Map limits = new HashMap<>(); private boolean enabled; public BukkitPacketsModule(final ModuleManager moduleManager, final Object configYml) { @@ -30,12 +30,12 @@ final public void reload(final Object configYml) { this.enabled = configYml1.getBoolean("packets.enabled"); for (final String packetIdentityName : configurationSection.getKeys(false)) { - for (final PacketIdentity packetIdentity : PacketIdentity.values()) { - if (packetIdentity.name().equalsIgnoreCase(packetIdentityName)) { + for (final Identity identity : Identity.values()) { + if (identity.name().equalsIgnoreCase(packetIdentityName)) { final Object value = configurationSection.get(packetIdentityName); if (value instanceof Integer) - addLimit(packetIdentity, (Integer) value); + addLimit(identity, (Integer) value); break; } @@ -43,11 +43,11 @@ final public void reload(final Object configYml) { } } - private void addLimit(final PacketIdentity packet, final int value) { + private void addLimit(final Identity packet, final int value) { this.limits.put(packet, value); } - final public int getLimit(final PacketIdentity packet) { + final public int getLimit(final Identity packet) { return limits.getOrDefault(packet, 999999); } @@ -55,7 +55,7 @@ public boolean isEnabled() { return enabled; } - public void checkPacket(Object packetEvent, PacketIdentity packetIdentity) { + public void checkPacket(Object packetEvent, Identity identity) { if (packetEvent instanceof PacketEvent) { final PacketEvent event = (PacketEvent) packetEvent; @@ -67,15 +67,15 @@ public void checkPacket(Object packetEvent, PacketIdentity packetIdentity) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().getPlayer(playerName); if (exploitPlayer != null) { - final int limit = getLimit(packetIdentity); + final int limit = getLimit(identity); if (limit > 0) { - exploitPlayer.addViolation(packetIdentity); + exploitPlayer.addViolation(identity); - final int violations = exploitPlayer.getViolations(packetIdentity); + final int violations = exploitPlayer.getViolations(identity); if (violations == limit) - moduleManager.getNotificationsModule().sendNotification(packetIdentity.name(), player); + moduleManager.getNotificationsModule().sendNotification(identity.name(), player); else if (violations > limit) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index 728e61b..9b1f81e 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -8,7 +8,7 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.*; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -21,7 +21,7 @@ public class BungeeExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private HashMap violations = new HashMap<>(); + final private HashMap violations = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -46,11 +46,11 @@ public void addChannels(final int channels) { this.channels += channels; } - public int getViolations(final PacketIdentity identifier) { + public int getViolations(final Identity identifier) { return violations.getOrDefault(identifier, 0); } - public void addViolation(final PacketIdentity identifier) { + public void addViolation(final Identity identifier) { final double currentTime = System.currentTimeMillis(); if (currentTime - lastViolation >= 1000) { diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index a548b0c..71f14f4 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -13,7 +13,7 @@ import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public class PluginMessageListener implements Listener { final private Plugin plugin; @@ -50,9 +50,9 @@ public void onPluginMessage(final PluginMessageEvent event) { exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); event.setCancelled(true); } else if (tag.equals("MC|BSign") || tag.equals("MC|BEdit") || tag.equals("MC|BOpen")) { - exploitPlayer.addViolation(PacketIdentity.CUSTOM_PAYLOAD); + exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD); - final int violations = exploitPlayer.getViolations(PacketIdentity.CUSTOM_PAYLOAD); + final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD); if (violations == customPayloadModule.getLimit()) { exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); @@ -71,9 +71,9 @@ public void onPluginMessage(final PluginMessageEvent event) { event.setCancelled(true); } } else { - exploitPlayer.addViolation(PacketIdentity.CUSTOM_PAYLOAD_OTHER); + exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD_OTHER); - final int violations = exploitPlayer.getViolations(PacketIdentity.CUSTOM_PAYLOAD_OTHER); + final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD_OTHER); if (violations == customPayloadModule.getOtherLimit()) { exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java index a16e145..f736908 100644 --- a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java @@ -1,7 +1,7 @@ package twolovers.exploitfixer.interfaces.instanceables; import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public interface ExploitPlayer { int getChannels(); @@ -10,9 +10,9 @@ public interface ExploitPlayer { void addChannels(final int channels); - int getViolations(final PacketIdentity identifier); + int getViolations(final Identity identifier); - void addViolation(final PacketIdentity identifier); + void addViolation(final Identity identifier); String getOnlineUUID(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 86ef048..88fb025 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -1,13 +1,13 @@ package twolovers.exploitfixer.interfaces.modules; -import twolovers.exploitfixer.shared.enums.PacketIdentity; +import twolovers.exploitfixer.shared.enums.Identity; public interface PacketsModule extends Module { void reload(Object configYml); - int getLimit(final PacketIdentity identity); + int getLimit(final Identity identity); boolean isEnabled(); - void checkPacket(final Object packetEvent, final PacketIdentity packetIdentity); + void checkPacket(final Object packetEvent, final Identity identity); } diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java new file mode 100644 index 0000000..3323b7c --- /dev/null +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -0,0 +1,6 @@ +package twolovers.exploitfixer.shared.enums; + +public enum Identity { + ABILITIES, ARM_ANIMATION, BLOCK_PLACE, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, WINDOW_CLICK, INTERACT, INTERACT_BOOK, BLOCK_DIG, + KEEP_ALIVE, INVENTORY_CREATIVE +} From 830a7ed14565588063e3339d3e94f01c5d89ffa3 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 13 Aug 2019 17:27:35 -0300 Subject: [PATCH 002/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../bukkit/managers/BukkitExploitPlayerManager.java | 8 ++++---- .../bungee/managers/BungeeExploitPlayerManager.java | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 4043f6d..3ee7738 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.2 +version: 0.6.3 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 38ce0bb..b04d353 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.2 +version: 0.6.3 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 16ccc9d..0e269b2 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -1,7 +1,6 @@ package twolovers.exploitfixer.bukkit.managers; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -34,10 +33,11 @@ public void addPlayer(final String playerName) { } public void reload() { - exploitPlayers.clear(); + for (ExploitPlayer exploitPlayer : exploitPlayers) + if (Bukkit.getPlayer(exploitPlayer.getName()) == null) + exploitPlayers.remove(exploitPlayer); - for (final Player player : Bukkit.getOnlinePlayers()) - exploitPlayers.add(new BukkitExploitPlayer(player.getName(), moduleManager)); + punishments = 0; } public Collection getExploitPlayers() { diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index edca5d0..bf7b10e 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -1,7 +1,6 @@ package twolovers.exploitfixer.bungee.managers; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.connection.ProxiedPlayer; import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -34,11 +33,11 @@ public void addPlayer(final String playerName) { } public void reload() { - exploitPlayers.clear(); - punishments = 0; + for (ExploitPlayer exploitPlayer : exploitPlayers) + if (BungeeCord.getInstance().getPlayer(exploitPlayer.getName()) == null) + exploitPlayers.remove(exploitPlayer); - for (final ProxiedPlayer proxiedPlayer : BungeeCord.getInstance().getPlayers()) - exploitPlayers.add(new BungeeExploitPlayer(proxiedPlayer.getName(), moduleManager)); + punishments = 0; } public Collection getExploitPlayers() { From 9649195330a50f82913cadb178e971fdd5d0d345 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 13 Aug 2019 21:21:13 -0300 Subject: [PATCH 003/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../managers/BukkitExploitPlayerManager.java | 14 +++++++++++--- .../managers/BungeeExploitPlayerManager.java | 14 +++++++++++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 3ee7738..6b0a00a 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.3 +version: 0.6.4 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index b04d353..1074c10 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.3 +version: 0.6.4 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 0e269b2..73637cc 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.managers; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -8,6 +9,7 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; @@ -33,9 +35,15 @@ public void addPlayer(final String playerName) { } public void reload() { - for (ExploitPlayer exploitPlayer : exploitPlayers) - if (Bukkit.getPlayer(exploitPlayer.getName()) == null) - exploitPlayers.remove(exploitPlayer); + final Iterator iterator = exploitPlayers.iterator(); + + while (iterator.hasNext()) { + final ExploitPlayer exploitPlayer = iterator.next(); + final Player player = Bukkit.getPlayer(exploitPlayer.getName()); + + if (player == null || !player.isOnline()) + iterator.remove(); + } punishments = 0; } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index bf7b10e..168c91b 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bungee.managers; import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.api.connection.ProxiedPlayer; import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -8,6 +9,7 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; public class BungeeExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; @@ -33,9 +35,15 @@ public void addPlayer(final String playerName) { } public void reload() { - for (ExploitPlayer exploitPlayer : exploitPlayers) - if (BungeeCord.getInstance().getPlayer(exploitPlayer.getName()) == null) - exploitPlayers.remove(exploitPlayer); + final Iterator iterator = exploitPlayers.iterator(); + + while (iterator.hasNext()) { + final ExploitPlayer exploitPlayer = iterator.next(); + final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(exploitPlayer.getName()); + + if (player == null || !player.isConnected()) + iterator.remove(); + } punishments = 0; } From a22d0937ff5e60f5fe05f41ea35bfac07ebf3811 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 20 Aug 2019 14:49:46 -0300 Subject: [PATCH 004/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 2 ++ src/plugin.yml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 6b0a00a..a9ddfd2 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.4 +version: 0.6.5 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 5fc5ea3..308da5f 100644 --- a/src/config.yml +++ b/src/config.yml @@ -80,6 +80,8 @@ packets: BLOCK_PLACE: 80 KEEP_ALIVE: 5 POSITION: 250 + USE_ENTITY: 80 + USE_ITEM: 80 WINDOW_CLICK: 80 # Prevents duplication with Signs/Books. diff --git a/src/plugin.yml b/src/plugin.yml index 1074c10..0b4ea75 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.4 +version: 0.6.5 author: 2LS softdepend: [ProtocolLib] commands: From 2d3d34f850f6a9bb9923e907079bd804c2572759 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Wed, 21 Aug 2019 19:43:32 -0300 Subject: [PATCH 005/336] updated Source --- .../adapters/UseEntityPacketAdapter.java | 23 ++++++++++ .../bukkit/adapters/UseItemPacketAdapter.java | 23 ++++++++++ .../adapters/WindowClickPacketAdapter.java | 18 ++++++++ .../initializers/AdapterInitializer.java | 2 + .../instanceables/BukkitExploitPlayer.java | 3 +- .../listeners/PlayerInteractListener.java | 44 +++++++++++-------- .../managers/BukkitExploitPlayerManager.java | 3 ++ .../bukkit/modules/BukkitPacketsModule.java | 4 +- .../instanceables/BungeeExploitPlayer.java | 3 +- .../modules/BungeeNotificationsModule.java | 11 +++-- .../exploitfixer/shared/enums/Identity.java | 2 +- 11 files changed, 106 insertions(+), 30 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java new file mode 100644 index 0000000..e187907 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class UseEntityPacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public UseEntityPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.USE_ENTITY); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.USE_ENTITY); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java new file mode 100644 index 0000000..2e81495 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class UseItemPacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public UseItemPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.USE_ITEM); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.USE_ITEM); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index df0e99e..46def00 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -3,21 +3,39 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import org.bukkit.inventory.InventoryView; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.ItemsModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; + private final ItemsModule itemsModule; public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.WINDOW_CLICK); this.packetsModule = moduleManager.getPacketsModule(); + this.itemsModule = moduleManager.getItemsModule(); } @Override public void onPacketReceiving(final PacketEvent event) { packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + + if (itemsModule.isEnabled()) { + final StructureModifier integers = event.getPacket().getIntegers(); + final InventoryView inventoryView = event.getPlayer().getOpenInventory(); + + if (inventoryView != null && integers.size() > 0) { + final int slot = integers.read(1); + final int maxSlots = inventoryView.countSlots(); + + if (slot > maxSlots) + event.setCancelled(true); + } + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 95b37e3..166b965 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -18,6 +18,8 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new KeepAlivePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new UseEntityPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new UseItemPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index bd81b13..30b9b15 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -78,7 +78,8 @@ public String getOnlineUUID() { bufferedReader.close(); onlineUUID = response.toString(); - } catch (Exception ignored) { } + } catch (Exception ignored) { + } } return onlineUUID; diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java index 25b3fbc..1087eed 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.listeners; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; @@ -8,48 +9,53 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; +import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class PlayerInteractListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; private final PacketsModule packetsModule; - private final CustomPayloadModule customPayloadModule; + private final NotificationsModule notificationsModule; public PlayerInteractListener(final ModuleManager moduleManager) { this.packetsModule = moduleManager.getPacketsModule(); - this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler public void onPlayerInteract(final PlayerInteractEvent event) { if (!event.isCancelled() && packetsModule.isEnabled()) { - final String playerName = event.getPlayer().getName(); + final Player player = event.getPlayer(); + final String playerName = player.getName(); final ItemStack item = event.getItem(); - if (item != null) { - final Material material = item.getType(); + if (item != null && (item.getType() == Material.WRITTEN_BOOK || item.getType() == Material.BOOK_AND_QUILL)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); + final Identity identifier = Identity.INTERACT_BOOK; - if (material == Material.WRITTEN_BOOK || material == Material.BOOK_AND_QUILL) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity name = Identity.INTERACT_BOOK; + exploitPlayer.addViolation(identifier); - exploitPlayer.addViolation(name); + final int violations = exploitPlayer.getViolations(identifier); - if (exploitPlayer.getViolations(name) > packetsModule.getLimit(name)) - event.setCancelled(true); - } - } + if (violations == packetsModule.getLimit(identifier)) + notificationsModule.sendNotification(identifier.name(), player); + if (exploitPlayer.getViolations(identifier) > packetsModule.getLimit(identifier)) + event.setCancelled(true); + } else { + final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); + final Identity identifier = Identity.INTERACT; - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity identifier = Identity.INTERACT; + exploitPlayer.addViolation(identifier); - exploitPlayer.addViolation(identifier); + final int violations = exploitPlayer.getViolations(identifier); - if (exploitPlayer.getViolations(identifier) > packetsModule.getLimit(identifier)) - event.setCancelled(true); + if (violations == packetsModule.getLimit(identifier)) + notificationsModule.sendNotification(identifier.name(), player); + if (violations > packetsModule.getLimit(identifier)) + event.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 73637cc..e05330f 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -18,6 +18,9 @@ public class BukkitExploitPlayerManager implements ExploitPlayerManager { public BukkitExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; + + for (final Player player : Bukkit.getOnlinePlayers()) + addPlayer(player.getName()); } public ExploitPlayer getPlayer(final String playerName) { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 42971ad..5b9376d 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -56,13 +56,13 @@ public boolean isEnabled() { } public void checkPacket(Object packetEvent, Identity identity) { - if (packetEvent instanceof PacketEvent) { + if (isEnabled() && packetEvent instanceof PacketEvent) { final PacketEvent event = (PacketEvent) packetEvent; if (!event.isCancelled()) { final Player player = event.getPlayer(); - if (isEnabled() && player != null) { + if (player != null) { final String playerName = player.getName(); final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().getPlayer(playerName); diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index 9b1f81e..f3950f7 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -79,7 +79,8 @@ public String getOnlineUUID() { bufferedReader.close(); onlineUUID = response.toString(); - } catch (Exception ignored) { } + } catch (Exception ignored) { + } } return onlineUUID; diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java index 1766c49..7fd36a2 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java @@ -1,8 +1,8 @@ package twolovers.exploitfixer.bungee.modules; +import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.command.ConsoleCommandSender; import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; @@ -32,16 +32,15 @@ public final boolean isNotifications(final Object player) { public void sendNotification(final String check, final Object player) { if (enabled && player != null) { final ProxiedPlayer player1 = (ProxiedPlayer) player; - final ConsoleCommandSender consoleCommandSender = ConsoleCommandSender.getInstance(); - final String notification = message + final TextComponent notification = new TextComponent(message .replace("%player%", player1.getName()) .replace("%check%", check) - .replace("%ping%", String.valueOf(player1.getPing())); + .replace("%ping%", String.valueOf(player1.getPing()))); - consoleCommandSender.sendMessage(notification); + BungeeCord.getInstance().getConsole().sendMessage(notification); for (final Object proxiedPlayer1 : getNotifications()) - ((ProxiedPlayer) proxiedPlayer1).sendMessage(new TextComponent(notification)); + ((ProxiedPlayer) proxiedPlayer1).sendMessage(notification); } } diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index 3323b7c..c9a604a 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -2,5 +2,5 @@ public enum Identity { ABILITIES, ARM_ANIMATION, BLOCK_PLACE, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, WINDOW_CLICK, INTERACT, INTERACT_BOOK, BLOCK_DIG, - KEEP_ALIVE, INVENTORY_CREATIVE + KEEP_ALIVE, INVENTORY_CREATIVE, USE_ITEM, USE_ENTITY, } From b95446a2258d038281de4510e5d498d89fb46f35 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 22 Aug 2019 19:36:20 -0300 Subject: [PATCH 006/336] updated Source --- src/config.yml | 23 ++++---- src/messages.yml | 2 + .../instanceables/BukkitExploitPlayer.java | 54 ++++++++++--------- .../bukkit/modules/BukkitPacketsModule.java | 2 +- .../instanceables/BungeeExploitPlayer.java | 34 ++++++------ 5 files changed, 61 insertions(+), 54 deletions(-) diff --git a/src/config.yml b/src/config.yml index 308da5f..194714b 100644 --- a/src/config.yml +++ b/src/config.yml @@ -72,17 +72,18 @@ packets: enabled: true # Max packets per second. - INTERACT: 80 - INTERACT_BOOKS: 5 - ABILITIES: 250 - ARM_ANIMATION: 80 - BLOCK_DIG: 120 - BLOCK_PLACE: 80 - KEEP_ALIVE: 5 - POSITION: 250 - USE_ENTITY: 80 - USE_ITEM: 80 - WINDOW_CLICK: 80 + limits: + INTERACT: 80 + INTERACT_BOOKS: 5 + ABILITIES: 250 + ARM_ANIMATION: 80 + BLOCK_DIG: 120 + BLOCK_PLACE: 80 + KEEP_ALIVE: 5 + POSITION: 250 + USE_ENTITY: 80 + USE_ITEM: 80 + WINDOW_CLICK: 80 # Prevents duplication with Signs/Books. duplication: diff --git a/src/messages.yml b/src/messages.yml index eb2a519..10f4868 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -30,6 +30,8 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fDuplication exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fPlayers cached: &a%players_cached% diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 30b9b15..fa5edf1 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -86,32 +86,34 @@ public String getOnlineUUID() { } public void punish(final Object plugin, final Module module, final Object player) { - final List punishCommands = module.getPunishCommands(); - final Player player1 = (Player) player; - final String lang = player1.spigot().getLocale().substring(0, 2); - - if (player1.isOnline()) { - final JavaPlugin javaPlugin = (JavaPlugin) plugin; - final Server server = javaPlugin.getServer(); - - exploitPlayerManager.addPunishment(); - - if (punishCommands != null) { - for (final String punishCommand : punishCommands) - if (!punishCommand.equals("")) - server.getScheduler().runTask(javaPlugin, () -> - server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player1.getName())) - ); - } - - notificationsModule.sendNotification(module.getName(), player); - - if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { - final String kickMessage = messagesModule.getKickMessage(module, lang); - - server.getScheduler().runTask(javaPlugin, () -> - player1.kickPlayer(kickMessage) - ); + if (player != null) { + final List punishCommands = module.getPunishCommands(); + final Player player1 = (Player) player; + final String lang = player1.spigot().getLocale().substring(0, 2); + + if (player1.isOnline()) { + final JavaPlugin javaPlugin = (JavaPlugin) plugin; + final Server server = javaPlugin.getServer(); + + exploitPlayerManager.addPunishment(); + + if (punishCommands != null) { + for (final String punishCommand : punishCommands) + if (!punishCommand.equals("")) + server.getScheduler().runTask(javaPlugin, () -> + server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player1.getName())) + ); + } + + notificationsModule.sendNotification(module.getName(), player); + + if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { + final String kickMessage = messagesModule.getKickMessage(module, lang); + + server.getScheduler().runTask(javaPlugin, () -> + player1.kickPlayer(kickMessage) + ); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 5b9376d..f7e9686 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -25,7 +25,7 @@ public BukkitPacketsModule(final ModuleManager moduleManager, final Object confi final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets"); + final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.limits"); this.enabled = configYml1.getBoolean("packets.enabled"); diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index f3950f7..98176fa 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -87,27 +87,29 @@ public String getOnlineUUID() { } public void punish(final Object plugin1, final Module module, final Object player) { - final List punishCommands = module.getPunishCommands(); - final ProxiedPlayer player1 = (ProxiedPlayer) player; - final String lang = player1.getLocale().toString().substring(0, 2); + if (player != null) { + final List punishCommands = module.getPunishCommands(); + final ProxiedPlayer player1 = (ProxiedPlayer) player; + final String lang = player1.getLocale().toString().substring(0, 2); - if (player1.isConnected()) { - exploitPlayerManager.addPunishment(); + if (player1.isConnected()) { + exploitPlayerManager.addPunishment(); - if (punishCommands != null) { - final Plugin plugin = (Plugin) plugin1; - final ProxyServer proxyServer = plugin.getProxy(); + if (punishCommands != null) { + final Plugin plugin = (Plugin) plugin1; + final ProxyServer proxyServer = plugin.getProxy(); - for (final String punishCommand : punishCommands) - if (!punishCommand.equals("")) - proxyServer.getPluginManager().dispatchCommand(proxyServer.getConsole(), punishCommand.replace("%player%", player1.getName())); - } + for (final String punishCommand : punishCommands) + if (!punishCommand.equals("")) + proxyServer.getPluginManager().dispatchCommand(proxyServer.getConsole(), punishCommand.replace("%player%", player1.getName())); + } - notificationsModule.sendNotification(module.getName(), player); + notificationsModule.sendNotification(module.getName(), player); - if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { - final String kickMessage = messagesModule.getKickMessage(module, lang); - player1.disconnect(new TextComponent(kickMessage)); + if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { + final String kickMessage = messagesModule.getKickMessage(module, lang); + player1.disconnect(new TextComponent(kickMessage)); + } } } } From ac769a8022d5151a3a755a50d8475da052937fa5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 22 Aug 2019 19:37:15 -0300 Subject: [PATCH 007/336] updated messages.yml --- src/messages.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/messages.yml b/src/messages.yml index 10f4868..eb2a519 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -30,8 +30,6 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fDuplication exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - packets: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fPlayers cached: &a%players_cached% From 1197c36cd5a52c96f1b769c16d74b1ab781ca28f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 22 Aug 2019 19:43:44 -0300 Subject: [PATCH 008/336] updated plugin.yml --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index a9ddfd2..11ec9de 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.5 +version: 0.6.6 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 0b4ea75..2d1dccf 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.5 +version: 0.6.6 author: 2LS softdepend: [ProtocolLib] commands: From 29a65b1cbaa7dfcfb2205f71ab241369d93692f0 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 24 Aug 2019 14:47:48 -0300 Subject: [PATCH 009/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 10 +++- src/plugin.yml | 2 +- .../adapters/BlockPlacePacketAdapter.java | 26 ++++++++++ .../adapters/WindowClickPacketAdapter.java | 8 +-- .../listeners/InventoryCreativeListener.java | 14 +++--- .../bukkit/managers/BukkitModuleManager.java | 10 ++-- .../modules/BukkitCustomPayloadModule.java | 11 +++-- .../bukkit/modules/BukkitInventoryModule.java | 49 +++++++++++++++++++ .../bukkit/modules/BukkitMessagesModule.java | 2 +- .../bungee/managers/BungeeModuleManager.java | 2 +- .../modules/BungeeCustomPayloadModule.java | 10 ++-- .../bungee/modules/BungeeMessagesModule.java | 2 +- .../interfaces/managers/ModuleManager.java | 2 +- .../modules/CustomPayloadModule.java | 2 + .../interfaces/modules/InventoryModule.java | 15 ++++++ 16 files changed, 135 insertions(+), 32 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java create mode 100644 src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java diff --git a/src/bungee.yml b/src/bungee.yml index 11ec9de..6d7eca7 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.6 +version: 0.6.7 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 194714b..50221d8 100644 --- a/src/config.yml +++ b/src/config.yml @@ -22,6 +22,9 @@ custompayload: # Increase if you have false positives in BungeeCord. other: 400 + # Cancells invalid block_place packets with books. + block_place: true + # Placeholders: %player% punish_commands: - "" @@ -97,14 +100,17 @@ duplication: punish_commands: - "" -# Prevents exploits with hacked creative items. -items: +# Prevents exploits with various inventory exploits. (Prevents hacked creative items) +inventory: # Do you want to enable this module? enabled: true # Kick the player on detection? If you dont it will only cancel. kick: false + # Cancells invalid window_click packets involving inventory slots. + window_click: true + # Placeholders: %player% punish_commands: - "" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 2d1dccf..418475e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.6 +version: 0.6.7 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 2a568ff..87650e6 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -3,21 +3,47 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class BlockPlacePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; + private final CustomPayloadModule customPayloadModule; public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.BLOCK_PLACE); this.packetsModule = moduleManager.getPacketsModule(); + this.customPayloadModule = moduleManager.getCustomPayloadModule(); } @Override public void onPacketReceiving(final PacketEvent event) { packetsModule.checkPacket(event, Identity.BLOCK_PLACE); + + if (customPayloadModule.isEnabled() && customPayloadModule.isBlockPlace()) { + final Player player = event.getPlayer(); + + if (player != null) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); + + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.readSafely(0); + + if (itemUse != null && itemUse.getType() == Material.WRITTEN_BOOK) { + final ItemStack itemOnHand = player.getItemInHand(); + + if (itemOnHand == null || itemOnHand.getType() != Material.WRITTEN_BOOK) + event.setCancelled(true); + } + } + } + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 46def00..699c25f 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -7,25 +7,25 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.ItemsModule; +import twolovers.exploitfixer.interfaces.modules.InventoryModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; - private final ItemsModule itemsModule; + private final InventoryModule inventoryModule; public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.WINDOW_CLICK); this.packetsModule = moduleManager.getPacketsModule(); - this.itemsModule = moduleManager.getItemsModule(); + this.inventoryModule = moduleManager.getInventoryModule(); } @Override public void onPacketReceiving(final PacketEvent event) { packetsModule.checkPacket(event, Identity.WINDOW_CLICK); - if (itemsModule.isEnabled()) { + if (inventoryModule.isEnabled() && inventoryModule.isWindowClick()) { final StructureModifier integers = event.getPacket().getIntegers(); final InventoryView inventoryView = event.getPlayer().getOpenInventory(); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index 9476276..c72d474 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -12,17 +12,17 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.ItemsModule; +import twolovers.exploitfixer.interfaces.modules.InventoryModule; import twolovers.exploitfixer.shared.enums.Identity; public class InventoryCreativeListener implements Listener { private final Plugin plugin; - private final ItemsModule itemsModule; + private final InventoryModule inventoryModule; private final ExploitPlayerManager exploitPlayerManager; public InventoryCreativeListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.itemsModule = moduleManager.getItemsModule(); + this.inventoryModule = moduleManager.getInventoryModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @@ -30,7 +30,7 @@ public InventoryCreativeListener(final Plugin plugin, final ModuleManager module public void onInventoryCreative(final InventoryCreativeEvent event) { final HumanEntity whoClicked = event.getWhoClicked(); - if (itemsModule.isEnabled() && whoClicked instanceof Player) { + if (inventoryModule.isEnabled() && whoClicked instanceof Player) { final Player player = (Player) event.getWhoClicked(); final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); final ItemStack itemStack = event.getCursor(); @@ -49,10 +49,10 @@ public void onInventoryCreative(final InventoryCreativeEvent event) { if (itemMetaLenght > 16384) { event.setCancelled(true); - exploitPlayer.punish(plugin, itemsModule, player); + exploitPlayer.punish(plugin, inventoryModule, player); } else if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().length() > 32) || (itemMeta.hasLore() && itemMeta.getLore().size() > 16)) { event.setCancelled(true); - exploitPlayer.punish(plugin, itemsModule, player); + exploitPlayer.punish(plugin, inventoryModule, player); } } @@ -60,7 +60,7 @@ public void onInventoryCreative(final InventoryCreativeEvent event) { for (int enchantmentLevel : itemStack.getEnchantments().values()) { if (enchantmentLevel > 10) { event.setCancelled(true); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, itemsModule, player); + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, inventoryModule, player); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index fdb929c..2dedee9 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -8,7 +8,7 @@ public class BukkitModuleManager implements ModuleManager { private CommandsModule commandsModule; private CustomPayloadModule customPayloadModule; - private ItemsModule itemsModule; + private InventoryModule inventoryModule; private MessagesModule messagesModule; private NotificationsModule notificationsModule; private UUIDSpoofModule uuidSpoofModule; @@ -19,7 +19,7 @@ public class BukkitModuleManager implements ModuleManager { public BukkitModuleManager(final Object configYml, final Object messagesYml) { commandsModule = new BukkitCommandsModule(configYml); customPayloadModule = new BukkitCustomPayloadModule(configYml); - itemsModule = new BukkitItemsModule(configYml); + inventoryModule = new BukkitInventoryModule(configYml); messagesModule = new BukkitMessagesModule(messagesYml); notificationsModule = new BukkitNotificationsModule(configYml); uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); @@ -31,7 +31,7 @@ public BukkitModuleManager(final Object configYml, final Object messagesYml) { public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { commandsModule.reload(configYml); customPayloadModule.reload(configYml); - itemsModule.reload(configYml); + inventoryModule.reload(configYml); messagesModule.reload(messagesYml); notificationsModule.reload(configYml); uuidSpoofModule.reload(configYml); @@ -48,8 +48,8 @@ public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } - public ItemsModule getItemsModule() { - return itemsModule; + public InventoryModule getInventoryModule() { + return inventoryModule; } public MessagesModule getMessagesModule() { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index b9b1e68..1fe86e6 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -6,10 +6,8 @@ import java.util.List; public class BukkitCustomPayloadModule implements CustomPayloadModule { - private int limit; - private int otherLimit; - private boolean enabled; - private boolean kick; + private boolean enabled, kick, blockPlace; + private int limit, otherLimit; private List punishCommands; public BukkitCustomPayloadModule(final Object configYml) { @@ -37,6 +35,7 @@ public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("custompayload.enabled"); + blockPlace = configYml1.getBoolean("custompayload.block_place"); kick = configYml1.getBoolean("custompayload.kick"); punishCommands = configYml1.getStringList("custompayload.punish_commands"); limit = configYml1.getInt("custompayload.limit.normal"); @@ -50,4 +49,8 @@ public int getLimit() { public int getOtherLimit() { return otherLimit; } + + public boolean isBlockPlace() { + return blockPlace; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java new file mode 100644 index 0000000..00c71c0 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java @@ -0,0 +1,49 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.modules.InventoryModule; + +import java.util.List; + +public class BukkitInventoryModule implements InventoryModule { + private boolean enabled, kick, windowClick; + private String kickMessage; + private List punishCommands; + + public BukkitInventoryModule(final Object configYml) { + reload(configYml); + } + + final public void reload(final Object configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + enabled = configYml1.getBoolean("inventory.enabled"); + windowClick = configYml1.getBoolean("inventory.window_click"); + kick = configYml1.getBoolean("inventory.kick"); + kickMessage = configYml1.getString("inventory.kick_message"); + punishCommands = configYml1.getStringList("inventory.punish_command"); + + if (kickMessage != null) + kickMessage = kickMessage.replace("&", "\u00A7"); + } + + final public Boolean isEnabled() { + return enabled; + } + + final public Boolean isKick() { + return kick; + } + + public Boolean isWindowClick() { + return windowClick; + } + + final public List getPunishCommands() { + return punishCommands; + } + + public String getName() { + return "Items"; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 9511122..bc9e620 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -64,7 +64,7 @@ else if (module instanceof CommandsModule) return getString(locale, ".modules.commands.kick_message"); else if (module instanceof DuplicationModule) return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof ItemsModule) + else if (module instanceof InventoryModule) return getString(locale, ".modules.items.kick_message"); else return ""; diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 5700af3..80931ba 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -39,7 +39,7 @@ public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } - public ItemsModule getItemsModule() { + public InventoryModule getInventoryModule() { return null; } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index f8844ab..5e796be 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -6,10 +6,8 @@ import java.util.List; public class BungeeCustomPayloadModule implements CustomPayloadModule { - private int limit; - private int otherLimit; - private boolean enabled; - private boolean kick; + private int limit, otherLimit; + private boolean enabled, kick; private List punishCommands; public BungeeCustomPayloadModule(final Object configYml) { @@ -50,4 +48,8 @@ public int getLimit() { public int getOtherLimit() { return otherLimit; } + + public boolean isBlockPlace() { + return false; + } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index 603bd1d..f0bb4ea 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -61,7 +61,7 @@ else if (module instanceof CommandsModule) return getString(locale, ".modules.commands.kick_message"); else if (module instanceof DuplicationModule) return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof ItemsModule) + else if (module instanceof InventoryModule) return getString(locale, ".modules.items.kick_message"); else return ""; diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index 04e5165..8be21fa 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -9,7 +9,7 @@ public interface ModuleManager { CustomPayloadModule getCustomPayloadModule(); - ItemsModule getItemsModule(); + InventoryModule getInventoryModule(); MessagesModule getMessagesModule(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index 69d6dd2..5a06027 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -14,4 +14,6 @@ public interface CustomPayloadModule extends Module { int getLimit(); int getOtherLimit(); + + boolean isBlockPlace(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java b/src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java new file mode 100644 index 0000000..266f2e4 --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java @@ -0,0 +1,15 @@ +package twolovers.exploitfixer.interfaces.modules; + +import java.util.List; + +public interface InventoryModule extends Module { + void reload(Object configYml); + + Boolean isEnabled(); + + Boolean isKick(); + + Boolean isWindowClick(); + + List getPunishCommands(); +} From 2c36074c86740acd0fb9af160a5162836dad1dd6 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Mon, 26 Aug 2019 17:52:37 -0300 Subject: [PATCH 010/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 2 +- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 6 +-- .../listeners/PlayerInteractListener.java | 54 ++++++++++--------- .../initializers/ListenerInitializer.java | 2 +- .../managers/BukkitExploitPlayerManager.java | 11 +++- .../bukkit/managers/BukkitModuleManager.java | 3 +- .../exploitfixer/bungee/ExploitFixer.java | 4 +- .../bungee/listeners/ChatListener.java | 3 -- .../bungee/listeners/DisconnectListener.java | 3 -- .../listeners/PluginMessageListener.java | 6 --- .../bungee/listeners/PostLoginListener.java | 4 -- .../managers/BungeeExploitPlayerManager.java | 12 ++++- 14 files changed, 59 insertions(+), 55 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 6d7eca7..7eef545 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.7 +version: 0.6.9 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 50221d8..235b37f 100644 --- a/src/config.yml +++ b/src/config.yml @@ -109,7 +109,7 @@ inventory: kick: false # Cancells invalid window_click packets involving inventory slots. - window_click: true + window_click: false # Placeholders: %player% punish_commands: diff --git a/src/plugin.yml b/src/plugin.yml index 418475e..5e2a339 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.7 +version: 0.6.9 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 48be0bb..1ee2770 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -25,17 +25,15 @@ public void onEnable() { final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); exploitFixer = this; - this.moduleManager = new BukkitModuleManager(configYml, messagesYml); + this.moduleManager = new BukkitModuleManager(this, configYml, messagesYml); reload(); getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - if (!exploitPlayerManager.getExploitPlayers().isEmpty()) { + if (!exploitPlayerManager.getExploitPlayers().isEmpty()) exploitPlayerManager.reload(); - System.out.println("[ExploitFixer] Automatically cleared unused cached players!"); - } }, 9000L, 9000L); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java index 1087eed..e14fe6d 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java @@ -6,6 +6,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -14,11 +15,13 @@ import twolovers.exploitfixer.shared.enums.Identity; public class PlayerInteractListener implements Listener { + private final Plugin plugin; private final ExploitPlayerManager exploitPlayerManager; private final PacketsModule packetsModule; private final NotificationsModule notificationsModule; - public PlayerInteractListener(final ModuleManager moduleManager) { + public PlayerInteractListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; this.packetsModule = moduleManager.getPacketsModule(); this.notificationsModule = moduleManager.getNotificationsModule(); exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -26,36 +29,39 @@ public PlayerInteractListener(final ModuleManager moduleManager) { @EventHandler public void onPlayerInteract(final PlayerInteractEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); - final String playerName = player.getName(); - final ItemStack item = event.getItem(); + plugin.getServer().getScheduler().runTask(plugin, () -> { + if (!event.isCancelled() && packetsModule.isEnabled()) { + final Player player = event.getPlayer(); + final String playerName = player.getName(); + final ItemStack item = event.getItem(); - if (item != null && (item.getType() == Material.WRITTEN_BOOK || item.getType() == Material.BOOK_AND_QUILL)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity identifier = Identity.INTERACT_BOOK; - exploitPlayer.addViolation(identifier); + if (item != null && (item.getType() == Material.WRITTEN_BOOK || item.getType() == Material.BOOK_AND_QUILL)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); + final Identity identifier = Identity.INTERACT_BOOK; - final int violations = exploitPlayer.getViolations(identifier); + exploitPlayer.addViolation(identifier); - if (violations == packetsModule.getLimit(identifier)) - notificationsModule.sendNotification(identifier.name(), player); - if (exploitPlayer.getViolations(identifier) > packetsModule.getLimit(identifier)) - event.setCancelled(true); - } else { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity identifier = Identity.INTERACT; + final int violations = exploitPlayer.getViolations(identifier); - exploitPlayer.addViolation(identifier); + if (violations == packetsModule.getLimit(identifier)) + notificationsModule.sendNotification(identifier.name(), player); + if (exploitPlayer.getViolations(identifier) > packetsModule.getLimit(identifier)) + event.setCancelled(true); + } else { + final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); + final Identity identifier = Identity.INTERACT; - final int violations = exploitPlayer.getViolations(identifier); + exploitPlayer.addViolation(identifier); - if (violations == packetsModule.getLimit(identifier)) - notificationsModule.sendNotification(identifier.name(), player); - if (violations > packetsModule.getLimit(identifier)) - event.setCancelled(true); + final int violations = exploitPlayer.getViolations(identifier); + + if (violations == packetsModule.getLimit(identifier)) + notificationsModule.sendNotification(identifier.name(), player); + if (violations > packetsModule.getLimit(identifier)) + event.setCancelled(true); + } } - } + }); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 1837979..5b8343c 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -14,7 +14,7 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage pluginManager.registerEvents(new InventoryCreativeListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerEditBookListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PlayerInteractListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerInteractListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new SignChangeListener(plugin, moduleManager), plugin); diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index e05330f..2c6a304 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -14,7 +14,7 @@ public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; final private HashSet exploitPlayers = new HashSet<>(); - private int punishments; + private int punishments = 0; public BukkitExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -39,13 +39,20 @@ public void addPlayer(final String playerName) { public void reload() { final Iterator iterator = exploitPlayers.iterator(); + boolean hasRemoved = false; while (iterator.hasNext()) { final ExploitPlayer exploitPlayer = iterator.next(); final Player player = Bukkit.getPlayer(exploitPlayer.getName()); - if (player == null || !player.isOnline()) + if (player == null || !player.isOnline()) { iterator.remove(); + + if (!hasRemoved) { + System.out.println("[ExploitFixer] Cleared unused cached players!"); + hasRemoved = true; + } + } } punishments = 0; diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 2dedee9..e6eb87e 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.managers; +import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.modules.*; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -16,7 +17,7 @@ public class BukkitModuleManager implements ModuleManager { private ExploitPlayerManager exploitPlayerManager; private DuplicationModule duplicationModule; - public BukkitModuleManager(final Object configYml, final Object messagesYml) { + public BukkitModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { commandsModule = new BukkitCommandsModule(configYml); customPayloadModule = new BukkitCustomPayloadModule(configYml); inventoryModule = new BukkitInventoryModule(configYml); diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/twolovers/exploitfixer/bungee/ExploitFixer.java index febacd8..6ba5dcb 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bungee/ExploitFixer.java @@ -36,10 +36,8 @@ public void onEnable() { getProxy().getScheduler().schedule(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - if (!exploitPlayerManager.getExploitPlayers().isEmpty()) { + if (!exploitPlayerManager.getExploitPlayers().isEmpty()) exploitPlayerManager.reload(); - System.out.println("[ExploitFixer] Automatically cleared unused cached players!"); - } }, 5, 5, TimeUnit.MINUTES); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index d2893bc..a3be882 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -9,18 +9,15 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CommandsModule; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; public class ChatListener implements Listener { private final Plugin plugin; private final CommandsModule commandsModule; - private final NotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index 51f59e5..6434bc0 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -7,16 +7,13 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; public class DisconnectListener implements Listener { - private final CustomPayloadModule customPayloadModule; private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; public DisconnectListener(final ModuleManager moduleManager) { - this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.notificationsModule = moduleManager.getNotificationsModule(); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index 71f14f4..d47fcab 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -11,22 +11,16 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import twolovers.exploitfixer.shared.enums.Identity; public class PluginMessageListener implements Listener { final private Plugin plugin; final private CustomPayloadModule customPayloadModule; - final private NotificationsModule notificationsModule; - final private MessagesModule messagesModule; final private ExploitPlayerManager exploitPlayerManager; public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index db87384..6f7ed6b 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -9,7 +9,6 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; @@ -19,21 +18,18 @@ public class PostLoginListener implements Listener { final private Plugin plugin; final private UUIDSpoofModule uuidSpoofModule; final private NotificationsModule notificationsModule; - final private MessagesModule messagesModule; final private ExploitPlayerManager exploitPlayerManager; public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(final PostLoginEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final String lang = "en"; exploitPlayerManager.addPlayer(proxiedPlayer.getName()); diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 168c91b..8a6d476 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -18,6 +18,9 @@ public class BungeeExploitPlayerManager implements ExploitPlayerManager { public BungeeExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; + + for (final ProxiedPlayer proxiedPlayer : BungeeCord.getInstance().getPlayers()) + addPlayer(proxiedPlayer.getName()); } public ExploitPlayer getPlayer(final String playerName) { @@ -36,13 +39,20 @@ public void addPlayer(final String playerName) { public void reload() { final Iterator iterator = exploitPlayers.iterator(); + boolean hasRemoved = false; while (iterator.hasNext()) { final ExploitPlayer exploitPlayer = iterator.next(); final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(exploitPlayer.getName()); - if (player == null || !player.isConnected()) + if (player == null || !player.isConnected()) { iterator.remove(); + + if (!hasRemoved) { + System.out.println("[ExploitFixer] Cleared unused cached players!"); + hasRemoved = true; + } + } } punishments = 0; From 5ed67209ef07521f23d60d0196d29b3d766d0af9 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 27 Aug 2019 23:46:34 -0300 Subject: [PATCH 011/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 13 ++++---- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 4 +-- .../adapters/BlockPlacePacketAdapter.java | 30 +++++++++---------- .../adapters/WindowClickPacketAdapter.java | 23 +++++++------- .../initializers/ListenerInitializer.java | 1 - .../modules/BukkitCustomPayloadModule.java | 7 +---- .../modules/BungeeCustomPayloadModule.java | 4 --- .../modules/CustomPayloadModule.java | 2 -- .../exploitfixer/shared/enums/Identity.java | 4 +-- 11 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 7eef545..0c8f116 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.6.9 +version: 0.7.0 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 235b37f..ee07429 100644 --- a/src/config.yml +++ b/src/config.yml @@ -22,9 +22,6 @@ custompayload: # Increase if you have false positives in BungeeCord. other: 400 - # Cancells invalid block_place packets with books. - block_place: true - # Placeholders: %player% punish_commands: - "" @@ -75,18 +72,21 @@ packets: enabled: true # Max packets per second. + # The ones ending with WRONG are impossible packets. + # WRONG packets are recommended to set to 1 but it can cause issues with laggy players. limits: - INTERACT: 80 - INTERACT_BOOKS: 5 ABILITIES: 250 ARM_ANIMATION: 80 BLOCK_DIG: 120 BLOCK_PLACE: 80 + BLOCK_PLACE_BOOKS: 5 + BLOCK_PLACE_WRONG: 20 KEEP_ALIVE: 5 POSITION: 250 USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 + WINDOW_CLICK_WRONG: 5 # Prevents duplication with Signs/Books. duplication: @@ -108,9 +108,6 @@ inventory: # Kick the player on detection? If you dont it will only cancel. kick: false - # Cancells invalid window_click packets involving inventory slots. - window_click: false - # Placeholders: %player% punish_commands: - "" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 5e2a339..b2e734c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.6.9 +version: 0.7.0 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 1ee2770..3b811b3 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -51,9 +51,9 @@ public void reload() { final PluginManager pluginManager = getServer().getPluginManager(); - if (pluginManager.isPluginEnabled("ProtocolLib")) { + if (pluginManager.isPluginEnabled("ProtocolLib")) new AdapterInitializer(this, moduleManager); - } else + else System.out.println("[ExploitFixer] ProtocolLib not found, enable it for better protection!"); new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 87650e6..1407f04 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -9,40 +9,38 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class BlockPlacePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; - private final CustomPayloadModule customPayloadModule; public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.BLOCK_PLACE); this.packetsModule = moduleManager.getPacketsModule(); - this.customPayloadModule = moduleManager.getCustomPayloadModule(); } @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.BLOCK_PLACE); + final Player player = event.getPlayer(); - if (customPayloadModule.isEnabled() && customPayloadModule.isBlockPlace()) { - final Player player = event.getPlayer(); + if (player != null) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); - if (player != null) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.read(0); - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.readSafely(0); + if (itemUse != null) { + final ItemStack itemOnHand = player.getItemInHand(); - if (itemUse != null && itemUse.getType() == Material.WRITTEN_BOOK) { - final ItemStack itemOnHand = player.getItemInHand(); - - if (itemOnHand == null || itemOnHand.getType() != Material.WRITTEN_BOOK) - event.setCancelled(true); - } + if (itemUse.getType() == Material.WRITTEN_BOOK || itemUse.getType() == Material.BOOK_AND_QUILL) + packetsModule.checkPacket(event, Identity.BLOCK_PLACE_BOOKS); + else if (itemOnHand != null && itemUse.getType() != itemOnHand.getType()) + packetsModule.checkPacket(event, Identity.BLOCK_PLACE_WRONG); + else + packetsModule.checkPacket(event, Identity.BLOCK_PLACE); } + } } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 699c25f..cb400eb 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -23,19 +23,18 @@ public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + final StructureModifier integers = event.getPacket().getIntegers(); + final InventoryView inventoryView = event.getPlayer().getOpenInventory(); - if (inventoryModule.isEnabled() && inventoryModule.isWindowClick()) { - final StructureModifier integers = event.getPacket().getIntegers(); - final InventoryView inventoryView = event.getPlayer().getOpenInventory(); + if (inventoryView != null && integers.size() > 1) { + final int slot = integers.read(1); + final int maxSlots = inventoryView.countSlots(); - if (inventoryView != null && integers.size() > 0) { - final int slot = integers.read(1); - final int maxSlots = inventoryView.countSlots(); - - if (slot > maxSlots) - event.setCancelled(true); - } - } + if (slot > maxSlots) + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + } else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 5b8343c..a138578 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -14,7 +14,6 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage pluginManager.registerEvents(new InventoryCreativeListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerEditBookListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PlayerInteractListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new SignChangeListener(plugin, moduleManager), plugin); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index 1fe86e6..e568f78 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -6,7 +6,7 @@ import java.util.List; public class BukkitCustomPayloadModule implements CustomPayloadModule { - private boolean enabled, kick, blockPlace; + private boolean enabled, kick; private int limit, otherLimit; private List punishCommands; @@ -35,7 +35,6 @@ public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("custompayload.enabled"); - blockPlace = configYml1.getBoolean("custompayload.block_place"); kick = configYml1.getBoolean("custompayload.kick"); punishCommands = configYml1.getStringList("custompayload.punish_commands"); limit = configYml1.getInt("custompayload.limit.normal"); @@ -49,8 +48,4 @@ public int getLimit() { public int getOtherLimit() { return otherLimit; } - - public boolean isBlockPlace() { - return blockPlace; - } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index 5e796be..bab8636 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -48,8 +48,4 @@ public int getLimit() { public int getOtherLimit() { return otherLimit; } - - public boolean isBlockPlace() { - return false; - } } diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index 5a06027..69d6dd2 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -14,6 +14,4 @@ public interface CustomPayloadModule extends Module { int getLimit(); int getOtherLimit(); - - boolean isBlockPlace(); } diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index c9a604a..9d93719 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.shared.enums; public enum Identity { - ABILITIES, ARM_ANIMATION, BLOCK_PLACE, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, WINDOW_CLICK, INTERACT, INTERACT_BOOK, BLOCK_DIG, - KEEP_ALIVE, INVENTORY_CREATIVE, USE_ITEM, USE_ENTITY, + ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, + KEEP_ALIVE, INVENTORY_CREATIVE, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG } From 54e6e7d8105f98809ad76f465b4185f4b865bce5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Wed, 28 Aug 2019 03:16:57 -0300 Subject: [PATCH 012/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 18 ++--- src/plugin.yml | 2 +- .../SetCreativeSlotPacketAdapter.java | 23 +++++++ .../adapters/WindowClickPacketAdapter.java | 3 - .../initializers/AdapterInitializer.java | 1 + .../listeners/InventoryCreativeListener.java | 57 +++------------- .../listeners/PlayerInteractListener.java | 67 ------------------- .../initializers/ListenerInitializer.java | 2 +- .../bukkit/managers/BukkitModuleManager.java | 10 +-- .../bukkit/modules/BukkitInventoryModule.java | 49 -------------- .../bukkit/modules/BukkitItemsFixModule.java | 41 ++++++++++++ .../bukkit/modules/BukkitItemsModule.java | 46 ------------- .../bukkit/modules/BukkitMessagesModule.java | 2 +- .../bungee/managers/BungeeModuleManager.java | 2 +- .../bungee/modules/BungeeMessagesModule.java | 2 +- .../interfaces/managers/ModuleManager.java | 2 +- ...ventoryModule.java => ItemsFixModule.java} | 2 +- .../interfaces/modules/ItemsModule.java | 13 ---- .../exploitfixer/shared/enums/Identity.java | 2 +- .../shared/enums/PacketIdentity.java | 6 -- 21 files changed, 93 insertions(+), 259 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitItemsModule.java rename src/twolovers/exploitfixer/interfaces/modules/{InventoryModule.java => ItemsFixModule.java} (81%) delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/ItemsModule.java delete mode 100644 src/twolovers/exploitfixer/shared/enums/PacketIdentity.java diff --git a/src/bungee.yml b/src/bungee.yml index 0c8f116..9d797d8 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.0 +version: 0.7.1 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index ee07429..e6684d1 100644 --- a/src/config.yml +++ b/src/config.yml @@ -66,6 +66,11 @@ commands: # Bukkit only # ############################## +# Recreates items obtained in creative to remove invalid tags, enchants, etc. +itemsfix: + # Do you want to enable this module? + enabled: true + # Limits packets with ProtocolLib to avoid exploits. packets: # Do you want to enable this module? @@ -83,6 +88,7 @@ packets: BLOCK_PLACE_WRONG: 20 KEEP_ALIVE: 5 POSITION: 250 + SET_CREATIVE_SLOT: 20 USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 @@ -96,18 +102,6 @@ duplication: # Kick the player on detection? If you dont it will only cancel. kick: false - # Placeholders: %player% - punish_commands: - - "" - -# Prevents exploits with various inventory exploits. (Prevents hacked creative items) -inventory: - # Do you want to enable this module? - enabled: true - - # Kick the player on detection? If you dont it will only cancel. - kick: false - # Placeholders: %player% punish_commands: - "" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index b2e734c..cb9d455 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.0 +version: 0.7.1 author: 2LS softdepend: [ProtocolLib] commands: diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java new file mode 100644 index 0000000..8197ad2 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class SetCreativeSlotPacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index cb400eb..872e0b6 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -7,18 +7,15 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.InventoryModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; - private final InventoryModule inventoryModule; public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.WINDOW_CLICK); this.packetsModule = moduleManager.getPacketsModule(); - this.inventoryModule = moduleManager.getInventoryModule(); } @Override diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 166b965..d1a7211 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -18,6 +18,7 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new KeepAlivePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new UseEntityPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new UseItemPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index c72d474..2e3effd 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -3,69 +3,28 @@ import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryCreativeEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.InventoryModule; -import twolovers.exploitfixer.shared.enums.Identity; +import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; public class InventoryCreativeListener implements Listener { - private final Plugin plugin; - private final InventoryModule inventoryModule; - private final ExploitPlayerManager exploitPlayerManager; + private final ItemsFixModule itemsFixModule; - public InventoryCreativeListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.inventoryModule = moduleManager.getInventoryModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + public InventoryCreativeListener(final ModuleManager moduleManager) { + this.itemsFixModule = moduleManager.getItemsFixModule(); } - @EventHandler(ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryCreative(final InventoryCreativeEvent event) { final HumanEntity whoClicked = event.getWhoClicked(); - if (inventoryModule.isEnabled() && whoClicked instanceof Player) { - final Player player = (Player) event.getWhoClicked(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); + if (itemsFixModule.isEnabled() && whoClicked instanceof Player) { final ItemStack itemStack = event.getCursor(); - final ItemMeta itemMeta = itemStack.getItemMeta(); - exploitPlayer.addViolation(Identity.INVENTORY_CREATIVE); - - if (exploitPlayer.getViolations(Identity.INVENTORY_CREATIVE) > 20) - event.setCancelled(true); - else { - if (itemStack.hasItemMeta() && itemMeta instanceof PotionMeta && !((PotionMeta) itemMeta).getCustomEffects().isEmpty()) - event.setCancelled(true); - - if (!event.isCancelled() && itemMeta != null) { - final int itemMetaLenght = itemMeta.toString().length(); - - if (itemMetaLenght > 16384) { - event.setCancelled(true); - exploitPlayer.punish(plugin, inventoryModule, player); - } else if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().length() > 32) || (itemMeta.hasLore() && itemMeta.getLore().size() > 16)) { - event.setCancelled(true); - exploitPlayer.punish(plugin, inventoryModule, player); - } - } - - if (!event.isCancelled() && !itemStack.getEnchantments().isEmpty()) { - for (int enchantmentLevel : itemStack.getEnchantments().values()) { - if (enchantmentLevel > 10) { - event.setCancelled(true); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, inventoryModule, player); - break; - } - } - } - } + event.setCursor(new ItemStack(itemStack.getType(), itemStack.getAmount(), itemStack.getData().getData())); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java deleted file mode 100644 index e14fe6d..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerInteractListener.java +++ /dev/null @@ -1,67 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; - -public class PlayerInteractListener implements Listener { - private final Plugin plugin; - private final ExploitPlayerManager exploitPlayerManager; - private final PacketsModule packetsModule; - private final NotificationsModule notificationsModule; - - public PlayerInteractListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.packetsModule = moduleManager.getPacketsModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler - public void onPlayerInteract(final PlayerInteractEvent event) { - plugin.getServer().getScheduler().runTask(plugin, () -> { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); - final String playerName = player.getName(); - final ItemStack item = event.getItem(); - - - if (item != null && (item.getType() == Material.WRITTEN_BOOK || item.getType() == Material.BOOK_AND_QUILL)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity identifier = Identity.INTERACT_BOOK; - - exploitPlayer.addViolation(identifier); - - final int violations = exploitPlayer.getViolations(identifier); - - if (violations == packetsModule.getLimit(identifier)) - notificationsModule.sendNotification(identifier.name(), player); - if (exploitPlayer.getViolations(identifier) > packetsModule.getLimit(identifier)) - event.setCancelled(true); - } else { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(playerName); - final Identity identifier = Identity.INTERACT; - - exploitPlayer.addViolation(identifier); - - final int violations = exploitPlayer.getViolations(identifier); - - if (violations == packetsModule.getLimit(identifier)) - notificationsModule.sendNotification(identifier.name(), player); - if (violations > packetsModule.getLimit(identifier)) - event.setCancelled(true); - } - } - }); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index a138578..78d7f41 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -11,7 +11,7 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage final PluginManager pluginManager = plugin.getServer().getPluginManager(); HandlerList.unregisterAll(plugin); - pluginManager.registerEvents(new InventoryCreativeListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new InventoryCreativeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerEditBookListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index e6eb87e..fc2680e 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -9,7 +9,7 @@ public class BukkitModuleManager implements ModuleManager { private CommandsModule commandsModule; private CustomPayloadModule customPayloadModule; - private InventoryModule inventoryModule; + private ItemsFixModule itemsFixModule; private MessagesModule messagesModule; private NotificationsModule notificationsModule; private UUIDSpoofModule uuidSpoofModule; @@ -20,7 +20,7 @@ public class BukkitModuleManager implements ModuleManager { public BukkitModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { commandsModule = new BukkitCommandsModule(configYml); customPayloadModule = new BukkitCustomPayloadModule(configYml); - inventoryModule = new BukkitInventoryModule(configYml); + itemsFixModule = new BukkitItemsFixModule(configYml); messagesModule = new BukkitMessagesModule(messagesYml); notificationsModule = new BukkitNotificationsModule(configYml); uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); @@ -32,7 +32,7 @@ public BukkitModuleManager(final Plugin plugin, final Object configYml, final Ob public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { commandsModule.reload(configYml); customPayloadModule.reload(configYml); - inventoryModule.reload(configYml); + itemsFixModule.reload(configYml); messagesModule.reload(messagesYml); notificationsModule.reload(configYml); uuidSpoofModule.reload(configYml); @@ -49,8 +49,8 @@ public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } - public InventoryModule getInventoryModule() { - return inventoryModule; + public ItemsFixModule getItemsFixModule() { + return itemsFixModule; } public MessagesModule getMessagesModule() { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java deleted file mode 100644 index 00c71c0..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitInventoryModule.java +++ /dev/null @@ -1,49 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.modules.InventoryModule; - -import java.util.List; - -public class BukkitInventoryModule implements InventoryModule { - private boolean enabled, kick, windowClick; - private String kickMessage; - private List punishCommands; - - public BukkitInventoryModule(final Object configYml) { - reload(configYml); - } - - final public void reload(final Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - - enabled = configYml1.getBoolean("inventory.enabled"); - windowClick = configYml1.getBoolean("inventory.window_click"); - kick = configYml1.getBoolean("inventory.kick"); - kickMessage = configYml1.getString("inventory.kick_message"); - punishCommands = configYml1.getStringList("inventory.punish_command"); - - if (kickMessage != null) - kickMessage = kickMessage.replace("&", "\u00A7"); - } - - final public Boolean isEnabled() { - return enabled; - } - - final public Boolean isKick() { - return kick; - } - - public Boolean isWindowClick() { - return windowClick; - } - - final public List getPunishCommands() { - return punishCommands; - } - - public String getName() { - return "Items"; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java new file mode 100644 index 0000000..ef531ac --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -0,0 +1,41 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; + +import java.util.ArrayList; +import java.util.List; + +public class BukkitItemsFixModule implements ItemsFixModule { + private boolean enabled; + + public BukkitItemsFixModule(final Object configYml) { + reload(configYml); + } + + final public void reload(final Object configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + enabled = configYml1.getBoolean("itemsfix.enabled"); + } + + final public Boolean isEnabled() { + return enabled; + } + + final public Boolean isKick() { + return false; + } + + public Boolean isWindowClick() { + return false; + } + + final public List getPunishCommands() { + return new ArrayList<>(); + } + + public String getName() { + return "ItemsFix"; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsModule.java deleted file mode 100644 index 3590850..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsModule.java +++ /dev/null @@ -1,46 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.modules.ItemsModule; - -import java.util.List; - -public class BukkitItemsModule implements ItemsModule { - private boolean enabled; - private boolean kick; - private String kickMessage; - private List punishCommands; - - public BukkitItemsModule(final Object configYml) { - reload(configYml); - } - - final public void reload(final Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - - enabled = configYml1.getBoolean("items.enabled"); - kick = configYml1.getBoolean("items.kick"); - kickMessage = configYml1.getString("items.kick_message"); - punishCommands = configYml1.getStringList("items.punish_command"); - - if (kickMessage != null) - kickMessage = kickMessage.replace("&", "\u00A7"); - } - - final public Boolean isEnabled() { - return enabled; - } - - final public Boolean isKick() { - return kick; - } - - final public List getPunishCommands() { - return punishCommands; - } - - @Override - public String getName() { - return "Items"; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index bc9e620..96b6e7e 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -64,7 +64,7 @@ else if (module instanceof CommandsModule) return getString(locale, ".modules.commands.kick_message"); else if (module instanceof DuplicationModule) return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof InventoryModule) + else if (module instanceof ItemsFixModule) return getString(locale, ".modules.items.kick_message"); else return ""; diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 80931ba..491c8c4 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -39,7 +39,7 @@ public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } - public InventoryModule getInventoryModule() { + public ItemsFixModule getItemsFixModule() { return null; } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index f0bb4ea..b0afbb1 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -61,7 +61,7 @@ else if (module instanceof CommandsModule) return getString(locale, ".modules.commands.kick_message"); else if (module instanceof DuplicationModule) return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof InventoryModule) + else if (module instanceof ItemsFixModule) return getString(locale, ".modules.items.kick_message"); else return ""; diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index 8be21fa..986631a 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -9,7 +9,7 @@ public interface ModuleManager { CustomPayloadModule getCustomPayloadModule(); - InventoryModule getInventoryModule(); + ItemsFixModule getItemsFixModule(); MessagesModule getMessagesModule(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java similarity index 81% rename from src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java rename to src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index 266f2e4..9171b38 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/InventoryModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -2,7 +2,7 @@ import java.util.List; -public interface InventoryModule extends Module { +public interface ItemsFixModule extends Module { void reload(Object configYml); Boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsModule.java deleted file mode 100644 index afc1ed6..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsModule.java +++ /dev/null @@ -1,13 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -import java.util.List; - -public interface ItemsModule extends Module { - void reload(Object configYml); - - Boolean isEnabled(); - - Boolean isKick(); - - List getPunishCommands(); -} diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index 9d93719..55a3b10 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -2,5 +2,5 @@ public enum Identity { ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, - KEEP_ALIVE, INVENTORY_CREATIVE, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG + KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG } diff --git a/src/twolovers/exploitfixer/shared/enums/PacketIdentity.java b/src/twolovers/exploitfixer/shared/enums/PacketIdentity.java deleted file mode 100644 index 750fd42..0000000 --- a/src/twolovers/exploitfixer/shared/enums/PacketIdentity.java +++ /dev/null @@ -1,6 +0,0 @@ -package twolovers.exploitfixer.shared.enums; - -public enum PacketIdentity { - ABILITIES, ARM_ANIMATION, BLOCK_PLACE, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, WINDOW_CLICK, INTERACT, INTERACT_BOOK, BLOCK_DIG, - KEEP_ALIVE -} From a4d56f2b4230f346bcd8d4fa36396dcb908f299a Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 7 Sep 2019 16:29:31 -0300 Subject: [PATCH 013/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 89 ++++++++++++++----- src/messages.yml | 2 + src/plugin.yml | 3 +- .../adapters/WindowClickPacketAdapter.java | 2 +- .../instanceables/BukkitExploitPlayer.java | 49 +++++----- .../listeners/InventoryCreativeListener.java | 19 +++- .../managers/BukkitExploitPlayerManager.java | 2 +- .../bukkit/modules/BukkitCommandsModule.java | 23 ++--- .../modules/BukkitCustomPayloadModule.java | 23 ++--- .../modules/BukkitDuplicationModule.java | 22 ++--- .../bukkit/modules/BukkitItemsFixModule.java | 25 +++--- .../modules/BukkitNotificationsModule.java | 6 +- .../bukkit/modules/BukkitPacketsModule.java | 16 ++-- .../bukkit/modules/BukkitUUIDSpoofModule.java | 16 ++-- .../instanceables/BungeeExploitPlayer.java | 41 +++++---- .../managers/BungeeExploitPlayerManager.java | 2 +- .../bungee/modules/BungeeCommandsModule.java | 26 +++--- .../modules/BungeeCustomPayloadModule.java | 26 +++--- .../bungee/modules/BungeeMessagesModule.java | 11 +++ .../modules/BungeeNotificationsModule.java | 11 ++- .../bungee/modules/BungeeUUIDSpoofModule.java | 18 ++-- .../interfaces/modules/CommandsModule.java | 5 -- .../modules/CustomPayloadModule.java | 6 -- .../interfaces/modules/DuplicationModule.java | 6 -- .../interfaces/modules/ItemsFixModule.java | 8 -- .../interfaces/modules/Module.java | 6 +- .../modules/NotificationsModule.java | 4 +- .../interfaces/modules/PacketsModule.java | 2 + .../interfaces/modules/UUIDSpoofModule.java | 4 - .../shared/instanceables/Punishment.java | 32 +++++++ 31 files changed, 296 insertions(+), 211 deletions(-) create mode 100644 src/twolovers/exploitfixer/shared/instanceables/Punishment.java diff --git a/src/bungee.yml b/src/bungee.yml index 9d797d8..1399936 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.1 +version: 0.7.2 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index e6684d1..5eb8e4c 100644 --- a/src/config.yml +++ b/src/config.yml @@ -12,38 +12,50 @@ custompayload: # Do you want to enable this module? enabled: true - # Kick the player on detection? - # Set to false to only cancel. - kick: true - # Maximum custom payload packets that can be sent per second. limit: normal: 6 # Increase if you have false positives in BungeeCord. other: 400 - # Placeholders: %player% - punish_commands: - - "" + # Punishes players that get detected by the check. + punish: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] # Checks if players have a invalid UUID. uuidspoof: # Do you want to enable this module? enabled: true - # Placeholders: %player% - punish_commands: - - "" + # Punishes players that get detected by the check. + punish: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] # Checks if players try to crash/exploit the server with commands. commands: # Do you want to enable this module? enabled: true - # Kick the player on detection? - # Set to false to only cancel. - kick: false - # Commands to detect. commands: - "//calc" @@ -58,9 +70,19 @@ commands: - "/promote" - "/demote" - # Placeholders: %player% - punish_commands: - - "" + # Punishes players that get detected by the check. + punish: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] ############################## # Bukkit only # @@ -88,20 +110,41 @@ packets: BLOCK_PLACE_WRONG: 20 KEEP_ALIVE: 5 POSITION: 250 - SET_CREATIVE_SLOT: 20 + SET_CREATIVE_SLOT: 200 USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 WINDOW_CLICK_WRONG: 5 + # Punishes players that get detected by the check. + punish: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 2s + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] + # Prevents duplication with Signs/Books. duplication: # Do you want to enable this module? enabled: true - # Kick the player on detection? If you dont it will only cancel. - kick: false + # Punishes players that get detected by the check. + punish: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true - # Placeholders: %player% - punish_commands: - - "" \ No newline at end of file + # Placeholders: %player% + commands: [] \ No newline at end of file diff --git a/src/messages.yml b/src/messages.yml index eb2a519..10f4868 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -30,6 +30,8 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fDuplication exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fPlayers cached: &a%players_cached% diff --git a/src/plugin.yml b/src/plugin.yml index cb9d455..b275bf6 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,7 +1,8 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.1 +version: 0.7.2 author: 2LS +api-version: '1.13' softdepend: [ProtocolLib] commands: exploitfixer: diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 872e0b6..32fce51 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -24,7 +24,7 @@ public void onPacketReceiving(final PacketEvent event) { final InventoryView inventoryView = event.getPlayer().getOpenInventory(); if (inventoryView != null && integers.size() > 1) { - final int slot = integers.read(1); + final int slot = integers.read(0) - 3; final int maxSlots = inventoryView.countSlots(); if (slot > maxSlots) diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index fa5edf1..0849d35 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -6,21 +6,25 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.*; +import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; +import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import twolovers.exploitfixer.shared.enums.Identity; +import twolovers.exploitfixer.shared.instanceables.Punishment; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; -import java.util.List; +import java.util.Map; public class BukkitExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private HashMap violations = new HashMap<>(); + final private Map violations = new HashMap<>(); + final private Map thresholds = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -86,33 +90,38 @@ public String getOnlineUUID() { } public void punish(final Object plugin, final Module module, final Object player) { - if (player != null) { - final List punishCommands = module.getPunishCommands(); - final Player player1 = (Player) player; - final String lang = player1.spigot().getLocale().substring(0, 2); + final Punishment punishment = module.getPunishment(); - if (player1.isOnline()) { - final JavaPlugin javaPlugin = (JavaPlugin) plugin; - final Server server = javaPlugin.getServer(); + if (punishment != null && punishment.isEnabled() && player != null) { + thresholds.put(module, thresholds.getOrDefault(module, 0) + 1); - exploitPlayerManager.addPunishment(); + final int threshold = thresholds.getOrDefault(module, 1); - if (punishCommands != null) { - for (final String punishCommand : punishCommands) + if (threshold >= punishment.getThreshold()) { + final Player player1 = (Player) player; + final String lang = player1.spigot().getLocale().substring(0, 2); + + if (player1.isOnline()) { + final JavaPlugin javaPlugin = (JavaPlugin) plugin; + final Server server = javaPlugin.getServer(); + + exploitPlayerManager.addPunishment(); + + for (final String punishCommand : punishment.getCommands()) if (!punishCommand.equals("")) server.getScheduler().runTask(javaPlugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player1.getName())) ); - } - notificationsModule.sendNotification(module.getName(), player); + notificationsModule.sendNotification(module.getName(), player); - if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { - final String kickMessage = messagesModule.getKickMessage(module, lang); + if (punishment.isKick()) { + final String kickMessage = messagesModule.getKickMessage(module, lang); - server.getScheduler().runTask(javaPlugin, () -> - player1.kickPlayer(kickMessage) - ); + server.getScheduler().runTask(javaPlugin, () -> + player1.kickPlayer(kickMessage) + ); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index 2e3effd..372ff18 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -5,8 +5,11 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryCreativeEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.PotionMeta; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; @@ -21,10 +24,22 @@ public InventoryCreativeListener(final ModuleManager moduleManager) { public void onInventoryCreative(final InventoryCreativeEvent event) { final HumanEntity whoClicked = event.getWhoClicked(); - if (itemsFixModule.isEnabled() && whoClicked instanceof Player) { + if (itemsFixModule.isEnabled() && event.getAction() == InventoryAction.PLACE_ALL && whoClicked instanceof Player) { final ItemStack itemStack = event.getCursor(); + final ItemStack itemStackRemake = new ItemStack(itemStack.getType(), itemStack.getAmount(), itemStack.getData().getData()); + final ItemMeta itemMeta = itemStack.getItemMeta(); - event.setCursor(new ItemStack(itemStack.getType(), itemStack.getAmount(), itemStack.getData().getData())); + if (itemMeta != null) { + if (itemMeta instanceof PotionMeta) + ((PotionMeta) itemMeta).clearCustomEffects(); + + itemMeta.setDisplayName(null); + itemMeta.setLore(null); + + itemStackRemake.setItemMeta(itemMeta); + } + + event.setCursor(itemStackRemake); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 2c6a304..f5e67d8 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -13,7 +13,7 @@ public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; - final private HashSet exploitPlayers = new HashSet<>(); + final private Collection exploitPlayers = new HashSet<>(); private int punishments = 0; public BukkitExploitPlayerManager(final ModuleManager moduleManager) { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java index 27245b8..e39c502 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java @@ -2,15 +2,15 @@ import org.bukkit.configuration.file.YamlConfiguration; import twolovers.exploitfixer.interfaces.modules.CommandsModule; +import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.Collection; -import java.util.List; public class BukkitCommandsModule implements CommandsModule { - private List commands; + private Collection commands; private boolean enabled; private boolean kick; - private List punishCommands; + private Punishment punishment; public BukkitCommandsModule(final Object configYml) { reload(configYml); @@ -24,15 +24,16 @@ final public Boolean isKick() { return kick; } - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "Commands"; } + @Override + public Punishment getPunishment() { + return punishment; + } + final public Collection getCommands() { return commands; } @@ -40,9 +41,9 @@ final public Collection getCommands() { public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - enabled = configYml1.getBoolean("commands.enabled"); - kick = configYml1.getBoolean("commands.kick"); - commands = configYml1.getStringList("commands.commands"); - punishCommands = configYml1.getStringList("commands.punish_commands"); + this.punishment = new Punishment(configYml1.getBoolean("commands.punishment.enabled"), configYml1.getBoolean("commands.punishment.kick"), configYml1.getInt("commands.punishment.threshold"), configYml1.getStringList("commands.punishment.commands")); + this.enabled = configYml1.getBoolean("commands.enabled"); + this.kick = configYml1.getBoolean("commands.kick"); + this.commands = configYml1.getStringList("commands.commands"); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index e568f78..3364030 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -2,13 +2,12 @@ import org.bukkit.configuration.file.YamlConfiguration; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; - -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitCustomPayloadModule implements CustomPayloadModule { - private boolean enabled, kick; + private boolean enabled; private int limit, otherLimit; - private List punishCommands; + private Punishment punishment; public BukkitCustomPayloadModule(final Object configYml) { reload(configYml); @@ -18,27 +17,23 @@ final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return kick; - } - - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "CustomPayload"; } + @Override + public Punishment getPunishment() { + return punishment; + } + public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("custompayload.enabled"); - kick = configYml1.getBoolean("custompayload.kick"); - punishCommands = configYml1.getStringList("custompayload.punish_commands"); limit = configYml1.getInt("custompayload.limit.normal"); otherLimit = configYml1.getInt("custompayload.limit.other"); + this.punishment = new Punishment(configYml1.getBoolean("custompayload.punishment.enabled"), configYml1.getBoolean("custompayload.punishment.kick"), configYml1.getInt("custompayload.punishment.threshold"), configYml1.getStringList("custompayload.punishment.commands")); } public int getLimit() { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java index 7660040..8bba9d0 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java @@ -2,13 +2,11 @@ import org.bukkit.configuration.file.YamlConfiguration; import twolovers.exploitfixer.interfaces.modules.DuplicationModule; - -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitDuplicationModule implements DuplicationModule { private boolean enabled; - private boolean kick; - private List punishCommands; + private Punishment punishment; public BukkitDuplicationModule(final Object configYml) { reload(configYml); @@ -18,23 +16,19 @@ final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("duplication.enabled"); - kick = configYml1.getBoolean("duplication.kick"); - punishCommands = configYml1.getStringList("duplication.punish_command"); + this.punishment = new Punishment(configYml1.getBoolean("duplication.punishment.enabled"), configYml1.getBoolean("duplication.punishment.kick"), configYml1.getInt("duplication.punishment.threshold"), configYml1.getStringList("duplication.punishment.commands")); } final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return kick; - } - - final public List getPunishCommands() { - return punishCommands; - } - public String getName() { return "Duplication"; } + + @Override + public Punishment getPunishment() { + return punishment; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index ef531ac..5fa5ed5 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -2,12 +2,11 @@ import org.bukkit.configuration.file.YamlConfiguration; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; - -import java.util.ArrayList; -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitItemsFixModule implements ItemsFixModule { private boolean enabled; + private Punishment punishment; public BukkitItemsFixModule(final Object configYml) { reload(configYml); @@ -17,25 +16,21 @@ final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("itemsfix.enabled"); + this.punishment = new Punishment(configYml1.getBoolean("itemsfix.punishment.enabled"), configYml1.getBoolean("itemsfix.punishment.kick"), configYml1.getInt("itemsfix.punishment.threshold"), configYml1.getStringList("itemsfix.punishment.commands")); } + @Override final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return false; - } - - public Boolean isWindowClick() { - return false; - } - - final public List getPunishCommands() { - return new ArrayList<>(); - } - + @Override public String getName() { return "ItemsFix"; } + + @Override + public Punishment getPunishment() { + return punishment; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java index 0c1ff58..44add06 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java @@ -7,11 +7,11 @@ import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import java.lang.reflect.InvocationTargetException; +import java.util.Collection; import java.util.HashSet; -import java.util.Set; public class BukkitNotificationsModule implements NotificationsModule { - private final HashSet notifications = new HashSet<>(); + private final Collection notifications = new HashSet<>(); private boolean enabled; private String message; @@ -54,7 +54,7 @@ public void sendNotification(final String check, final Object player) { } } - public final Set getNotifications() { + public final Collection getNotifications() { return notifications; } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index f7e9686..dc69628 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -8,14 +8,15 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; import twolovers.exploitfixer.shared.enums.Identity; +import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.HashMap; -import java.util.List; import java.util.Map; public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; private final Map limits = new HashMap<>(); + private Punishment punishment; private boolean enabled; public BukkitPacketsModule(final ModuleManager moduleManager, final Object configYml) { @@ -27,6 +28,7 @@ final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.limits"); + this.punishment = new Punishment(configYml1.getBoolean("packets.punishment.enabled"), configYml1.getBoolean("packets.punishment.kick"), configYml1.getInt("packets.punishment.threshold"), configYml1.getStringList("packets.punishment.commands")); this.enabled = configYml1.getBoolean("packets.enabled"); for (final String packetIdentityName : configurationSection.getKeys(false)) { @@ -43,11 +45,11 @@ final public void reload(final Object configYml) { } } - private void addLimit(final Identity packet, final int value) { + public void addLimit(final Identity packet, final int value) { this.limits.put(packet, value); } - final public int getLimit(final Identity packet) { + public int getLimit(final Identity packet) { return limits.getOrDefault(packet, 999999); } @@ -85,11 +87,11 @@ else if (violations > limit) } } - public List getPunishCommands() { - return null; - } - public String getName() { return "Packets"; } + + public Punishment getPunishment() { + return punishment; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java index ae67f83..d7fe1c4 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java @@ -2,12 +2,11 @@ import org.bukkit.configuration.file.YamlConfiguration; import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; - -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitUUIDSpoofModule implements UUIDSpoofModule { private boolean enabled; - private List punishCommands; + private Punishment punishment; public BukkitUUIDSpoofModule(final Object configYml) { reload(configYml); @@ -17,19 +16,20 @@ final public Boolean isEnabled() { return enabled; } - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "UUIDSpoof"; } + @Override + public Punishment getPunishment() { + return punishment; + } + public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; enabled = configYml1.getBoolean("uuidspoof.enabled"); - punishCommands = configYml1.getStringList("uuidspoof.punish_commands"); + this.punishment = new Punishment(configYml1.getBoolean("uuidspoof.punishment.enabled"), configYml1.getBoolean("uuidspoof.punishment.kick"), configYml1.getInt("uuidspoof.punishment.threshold"), configYml1.getStringList("uuidspoof.punishment.commands")); } } diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index 98176fa..9cf7f39 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -7,21 +7,25 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.*; +import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; +import twolovers.exploitfixer.interfaces.modules.NotificationsModule; import twolovers.exploitfixer.shared.enums.Identity; +import twolovers.exploitfixer.shared.instanceables.Punishment; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; -import java.util.List; +import java.util.Map; public class BungeeExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private HashMap violations = new HashMap<>(); + final private Map violations = new HashMap<>(); + final private Map thresholds = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -87,28 +91,33 @@ public String getOnlineUUID() { } public void punish(final Object plugin1, final Module module, final Object player) { - if (player != null) { - final List punishCommands = module.getPunishCommands(); - final ProxiedPlayer player1 = (ProxiedPlayer) player; - final String lang = player1.getLocale().toString().substring(0, 2); + final Punishment punishment = module.getPunishment(); - if (player1.isConnected()) { - exploitPlayerManager.addPunishment(); + if (punishment != null && punishment.isEnabled() && player != null) { + thresholds.put(module, thresholds.getOrDefault(module, 0) + 1); - if (punishCommands != null) { + final int threshold = thresholds.getOrDefault(module, 1); + + if (threshold >= punishment.getThreshold()) { + final ProxiedPlayer player1 = (ProxiedPlayer) player; + final String lang = player1.getLocale().toString().substring(0, 2); + + if (player1.isConnected()) { final Plugin plugin = (Plugin) plugin1; final ProxyServer proxyServer = plugin.getProxy(); - for (final String punishCommand : punishCommands) + exploitPlayerManager.addPunishment(); + + for (final String punishCommand : punishment.getCommands()) if (!punishCommand.equals("")) proxyServer.getPluginManager().dispatchCommand(proxyServer.getConsole(), punishCommand.replace("%player%", player1.getName())); - } - notificationsModule.sendNotification(module.getName(), player); + notificationsModule.sendNotification(module.getName(), player); - if ((module instanceof CommandsModule && ((CommandsModule) module).isKick()) || (module instanceof CustomPayloadModule && ((CustomPayloadModule) module).isKick())) { - final String kickMessage = messagesModule.getKickMessage(module, lang); - player1.disconnect(new TextComponent(kickMessage)); + if (punishment.isKick()) { + final String kickMessage = messagesModule.getKickMessage(module, lang); + player1.disconnect(new TextComponent(kickMessage)); + } } } } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 8a6d476..763b2e9 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -13,7 +13,7 @@ public class BungeeExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; - final private HashSet exploitPlayers = new HashSet<>(); + final private Collection exploitPlayers = new HashSet<>(); private int punishments = 0; public BungeeExploitPlayerManager(final ModuleManager moduleManager) { diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java index ba9cd24..d87052e 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java @@ -2,47 +2,45 @@ import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.interfaces.modules.CommandsModule; +import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.Collection; -import java.util.List; public class BungeeCommandsModule implements CommandsModule { - private List commands; + private Collection commands; private boolean enabled; - private boolean kick; - private List punishCommands; + private Punishment punishment; public BungeeCommandsModule(final Object configYml) { reload(configYml); } + @Override final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return kick; - } - - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "Commands"; } + @Override + public Punishment getPunishment() { + return punishment; + } + + @Override final public Collection getCommands() { return commands; } + @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; enabled = configYml1.getBoolean("commands.enabled"); - kick = configYml1.getBoolean("commands.kick"); commands = configYml1.getStringList("commands.commands"); - punishCommands = configYml1.getStringList("commands.punish_commands"); + this.punishment = new Punishment(configYml1.getBoolean("commands.punishment.enabled"), configYml1.getBoolean("commands.punishment.kick"), configYml1.getInt("commands.punishment.threshold"), configYml1.getStringList("commands.punishment.commands")); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index bab8636..3757ab6 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -2,49 +2,47 @@ import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; - -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BungeeCustomPayloadModule implements CustomPayloadModule { private int limit, otherLimit; - private boolean enabled, kick; - private List punishCommands; + private boolean enabled; + private Punishment punishment; public BungeeCustomPayloadModule(final Object configYml) { reload(configYml); } + @Override final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return kick; - } - - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "CustomPayload"; } + @Override + public Punishment getPunishment() { + return punishment; + } + public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; enabled = configYml1.getBoolean("custompayload.enabled"); - kick = configYml1.getBoolean("custompayload.kick"); - punishCommands = configYml1.getStringList("custompayload.punish_commands"); + this.punishment = new Punishment(configYml1.getBoolean("custompayload.punishment.enabled"), configYml1.getBoolean("custompayload.punishment.kick"), configYml1.getInt("custompayload.punishment.threshold"), configYml1.getStringList("custompayload.punishment.commands")); limit = configYml1.getInt("custompayload.limit.normal"); otherLimit = configYml1.getInt("custompayload.limit.other"); } + @Override public int getLimit() { return limit; } + @Override public int getOtherLimit() { return otherLimit; } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index b0afbb1..7b353b7 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -10,6 +10,7 @@ public BungeeMessagesModule(final Object messagesYml) { reload(messagesYml); } + @Override public String getString(final String locale, final String path) { String string = ((Configuration) messagesYml).getString(locale + path); @@ -24,34 +25,42 @@ public String getString(final String locale, final String path) { return string; } + @Override public final String getReload(final String locale) { return getString(locale, ".commands.reload"); } + @Override public final String getHelp(final String locale) { return getString(locale, ".commands.help"); } + @Override public final String getUnknown(final String locale) { return getString(locale, ".commands.error.unknown"); } + @Override public final String getPermission(final String locale) { return getString(locale, ".commands.error.permission"); } + @Override public final String getConsole(final String locale) { return getString(locale, ".commands.error.console"); } + @Override public final String getEnable(final String locale) { return getString(locale, ".commands.notifications.enable"); } + @Override public final String getDisable(final String locale) { return getString(locale, ".commands.notifications.disable"); } + @Override public final String getKickMessage(final Module module, final String locale) { if (module instanceof CustomPayloadModule) return getString(locale, ".modules.custompayload.kick_message"); @@ -67,10 +76,12 @@ else if (module instanceof ItemsFixModule) return ""; } + @Override public void reload(Object messagesYml) { this.messagesYml = messagesYml; } + @Override public String getStats(String locale) { return getString(locale, ".modules.stats.message"); } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java index 7fd36a2..923c3ee 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java @@ -6,11 +6,11 @@ import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import java.util.Collection; import java.util.HashSet; -import java.util.Set; public class BungeeNotificationsModule implements NotificationsModule { - private final HashSet notifications = new HashSet<>(); + private final Collection notifications = new HashSet<>(); private boolean enabled; private String message; @@ -18,6 +18,7 @@ public BungeeNotificationsModule(final Object configYml) { reload(configYml); } + @Override public final void setNotifications(final Object player, final boolean input) { if (input) notifications.add(player); @@ -25,10 +26,12 @@ public final void setNotifications(final Object player, final boolean input) { notifications.remove(player); } + @Override public final boolean isNotifications(final Object player) { return notifications.contains(player); } + @Override public void sendNotification(final String check, final Object player) { if (enabled && player != null) { final ProxiedPlayer player1 = (ProxiedPlayer) player; @@ -44,10 +47,12 @@ public void sendNotification(final String check, final Object player) { } } - public final Set getNotifications() { + @Override + public final Collection getNotifications() { return notifications; } + @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java index 666b58a..a58e9ac 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java @@ -2,34 +2,36 @@ import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; - -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public class BungeeUUIDSpoofModule implements UUIDSpoofModule { private boolean enabled; - private List punishCommands; + private Punishment punishment; public BungeeUUIDSpoofModule(final Object configYml) { reload(configYml); } + @Override final public Boolean isEnabled() { return enabled; } - final public List getPunishCommands() { - return punishCommands; - } - @Override public String getName() { return "UUIDSpoof"; } + @Override + public Punishment getPunishment() { + return punishment; + } + + @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; enabled = configYml1.getBoolean("uuidspoof.enabled"); - punishCommands = configYml1.getStringList("uuidspoof.punish_commands"); + this.punishment = new Punishment(configYml1.getBoolean("uuidspoof.punishment.enabled"), configYml1.getBoolean("uuidspoof.punishment.kick"), configYml1.getInt("uuidspoof.punishment.threshold"), configYml1.getStringList("uuidspoof.punishment.commands")); } } diff --git a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java index 8d0ee9d..772fff5 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java @@ -1,15 +1,10 @@ package twolovers.exploitfixer.interfaces.modules; import java.util.Collection; -import java.util.List; public interface CommandsModule extends Module { Boolean isEnabled(); - Boolean isKick(); - - List getPunishCommands(); - Collection getCommands(); void reload(Object configYml); diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index 69d6dd2..bc85bac 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -1,14 +1,8 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.List; - public interface CustomPayloadModule extends Module { Boolean isEnabled(); - Boolean isKick(); - - List getPunishCommands(); - void reload(Object configYml); int getLimit(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java index a05f8d2..e2354f9 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java @@ -1,13 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.List; - public interface DuplicationModule extends Module { void reload(Object configYml); Boolean isEnabled(); - - Boolean isKick(); - - List getPunishCommands(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index 9171b38..4014e85 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -1,15 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.List; - public interface ItemsFixModule extends Module { void reload(Object configYml); Boolean isEnabled(); - - Boolean isKick(); - - Boolean isWindowClick(); - - List getPunishCommands(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/Module.java b/src/twolovers/exploitfixer/interfaces/modules/Module.java index a059d15..d93eaeb 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/Module.java +++ b/src/twolovers/exploitfixer/interfaces/modules/Module.java @@ -1,9 +1,9 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.List; +import twolovers.exploitfixer.shared.instanceables.Punishment; public interface Module { - List getPunishCommands(); - String getName(); + + Punishment getPunishment(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java b/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java index c7cd6f3..828688d 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.Set; +import java.util.Collection; public interface NotificationsModule { void setNotifications(final Object player, final boolean input); @@ -9,7 +9,7 @@ public interface NotificationsModule { void sendNotification(final String check, final Object player); - Set getNotifications(); + Collection getNotifications(); void reload(Object configYml); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 88fb025..f99880e 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -5,6 +5,8 @@ public interface PacketsModule extends Module { void reload(Object configYml); + void addLimit(final Identity packet, final int value); + int getLimit(final Identity identity); boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java b/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java index 7284b38..11232bd 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java @@ -1,11 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; -import java.util.List; - public interface UUIDSpoofModule extends Module { Boolean isEnabled(); - List getPunishCommands(); - void reload(Object configYml); } diff --git a/src/twolovers/exploitfixer/shared/instanceables/Punishment.java b/src/twolovers/exploitfixer/shared/instanceables/Punishment.java new file mode 100644 index 0000000..38d0bb4 --- /dev/null +++ b/src/twolovers/exploitfixer/shared/instanceables/Punishment.java @@ -0,0 +1,32 @@ +package twolovers.exploitfixer.shared.instanceables; + +import java.util.Collection; + +public class Punishment { + private final boolean enabled, kick; + private final int threshold; + private final Collection commands; + + public Punishment(final boolean enabled, final boolean kick, final int threshold, final Collection commands) { + this.enabled = enabled; + this.kick = kick; + this.threshold = threshold; + this.commands = commands; + } + + public boolean isEnabled() { + return enabled; + } + + public boolean isKick() { + return kick; + } + + public int getThreshold() { + return threshold; + } + + public Collection getCommands() { + return commands; + } +} From 4081a95879cbe824197947b9f40f5d71e19de2a4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 8 Sep 2019 18:10:49 -0300 Subject: [PATCH 014/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 12 ++++++------ src/messages.yml | 4 ++++ src/plugin.yml | 2 +- .../bukkit/instanceables/BukkitExploitPlayer.java | 10 +++++----- .../bukkit/listeners/SignChangeListener.java | 2 +- .../bukkit/managers/BukkitModuleManager.java | 2 +- .../bukkit/modules/BukkitMessagesModule.java | 13 +------------ .../bukkit/modules/BukkitPacketsModule.java | 12 ++++++++---- .../bungee/modules/BungeeMessagesModule.java | 13 +------------ 10 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 1399936..7619b48 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.2 +version: 0.7.3 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 5eb8e4c..97fc0bb 100644 --- a/src/config.yml +++ b/src/config.yml @@ -19,7 +19,7 @@ custompayload: other: 400 # Punishes players that get detected by the check. - punish: + punishment: # Do you want to punish player when they get detected? enabled: true @@ -38,7 +38,7 @@ uuidspoof: enabled: true # Punishes players that get detected by the check. - punish: + punishment: # Do you want to punish player when they get detected? enabled: true @@ -71,7 +71,7 @@ commands: - "/demote" # Punishes players that get detected by the check. - punish: + punishment: # Do you want to punish player when they get detected? enabled: true @@ -117,12 +117,12 @@ packets: WINDOW_CLICK_WRONG: 5 # Punishes players that get detected by the check. - punish: + punishment: # Do you want to punish player when they get detected? enabled: true # How many times should a player be detected to be punished - threshold: 2s + threshold: 2 # Kick the player on detection? kick: true @@ -136,7 +136,7 @@ duplication: enabled: true # Punishes players that get detected by the check. - punish: + punishment: # Do you want to punish player when they get detected? enabled: true diff --git a/src/messages.yml b/src/messages.yml index 10f4868..40839b6 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -65,6 +65,8 @@ es: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de duplicacion detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores en cache: &a%players_cached% @@ -98,6 +100,8 @@ pt: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de duplicação detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores em cache: &a%players_cached% diff --git a/src/plugin.yml b/src/plugin.yml index b275bf6..97755bd 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.2 +version: 0.7.3 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 0849d35..8307104 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -2,7 +2,7 @@ import org.bukkit.Server; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -102,14 +102,14 @@ public void punish(final Object plugin, final Module module, final Object player final String lang = player1.spigot().getLocale().substring(0, 2); if (player1.isOnline()) { - final JavaPlugin javaPlugin = (JavaPlugin) plugin; - final Server server = javaPlugin.getServer(); + final Plugin plugin1 = (Plugin) plugin; + final Server server = plugin1.getServer(); exploitPlayerManager.addPunishment(); for (final String punishCommand : punishment.getCommands()) if (!punishCommand.equals("")) - server.getScheduler().runTask(javaPlugin, () -> + server.getScheduler().runTask(plugin1, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player1.getName())) ); @@ -118,7 +118,7 @@ public void punish(final Object plugin, final Module module, final Object player if (punishment.isKick()) { final String kickMessage = messagesModule.getKickMessage(module, lang); - server.getScheduler().runTask(javaPlugin, () -> + server.getScheduler().runTask(plugin1, () -> player1.kickPlayer(kickMessage) ); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 6b1165f..448e84e 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -25,7 +25,7 @@ public SignChangeListener(final Plugin plugin, final ModuleManager variables) { } @EventHandler(priority = EventPriority.LOWEST) - public void onSignChange(SignChangeEvent event) { + public void onSignChange(final SignChangeEvent event) { if (duplicationModule.isEnabled()) { for (String line : event.getLines()) { if (line.length() >= 46 || pattern.matcher(line).find()) { diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index fc2680e..6e8a6d9 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -24,7 +24,7 @@ public BukkitModuleManager(final Plugin plugin, final Object configYml, final Ob messagesModule = new BukkitMessagesModule(messagesYml); notificationsModule = new BukkitNotificationsModule(configYml); uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); - packetsModule = new BukkitPacketsModule(this, configYml); + packetsModule = new BukkitPacketsModule(plugin, this, configYml); exploitPlayerManager = new BukkitExploitPlayerManager(this); duplicationModule = new BukkitDuplicationModule(configYml); } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 96b6e7e..f97dd7d 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -56,18 +56,7 @@ public final String getDisable(final String locale) { } public final String getKickMessage(final Module module, final String locale) { - if (module instanceof CustomPayloadModule) - return getString(locale, ".modules.custompayload.kick_message"); - else if (module instanceof UUIDSpoofModule) - return getString(locale, ".modules.uuidspoof.kick_message"); - else if (module instanceof CommandsModule) - return getString(locale, ".modules.commands.kick_message"); - else if (module instanceof DuplicationModule) - return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof ItemsFixModule) - return getString(locale, ".modules.items.kick_message"); - else - return ""; + return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); } public void reload(Object messagesYml) { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index dc69628..c85e797 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -4,6 +4,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -14,12 +15,14 @@ import java.util.Map; public class BukkitPacketsModule implements PacketsModule { + private final Plugin plugin; private final ModuleManager moduleManager; private final Map limits = new HashMap<>(); private Punishment punishment; private boolean enabled; - public BukkitPacketsModule(final ModuleManager moduleManager, final Object configYml) { + public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { + this.plugin = plugin; this.moduleManager = moduleManager; reload(configYml); } @@ -58,7 +61,7 @@ public boolean isEnabled() { } public void checkPacket(Object packetEvent, Identity identity) { - if (isEnabled() && packetEvent instanceof PacketEvent) { + if (enabled && packetEvent instanceof PacketEvent) { final PacketEvent event = (PacketEvent) packetEvent; if (!event.isCancelled()) { @@ -76,9 +79,10 @@ public void checkPacket(Object packetEvent, Identity identity) { final int violations = exploitPlayer.getViolations(identity); - if (violations == limit) + if (violations == limit) { + exploitPlayer.punish(plugin, this, player); moduleManager.getNotificationsModule().sendNotification(identity.name(), player); - else if (violations > limit) + } else if (violations > limit) event.setCancelled(true); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index 7b353b7..cd1fd0a 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -62,18 +62,7 @@ public final String getDisable(final String locale) { @Override public final String getKickMessage(final Module module, final String locale) { - if (module instanceof CustomPayloadModule) - return getString(locale, ".modules.custompayload.kick_message"); - else if (module instanceof UUIDSpoofModule) - return getString(locale, ".modules.uuidspoof.kick_message"); - else if (module instanceof CommandsModule) - return getString(locale, ".modules.commands.kick_message"); - else if (module instanceof DuplicationModule) - return getString(locale, ".modules.duplication.kick_message"); - else if (module instanceof ItemsFixModule) - return getString(locale, ".modules.items.kick_message"); - else - return ""; + return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); } @Override From 2509b959c966cca54fc565d2764ae36d5514a87e Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Wed, 11 Sep 2019 22:57:05 -0300 Subject: [PATCH 015/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 38 ++++++++++++++++++- src/plugin.yml | 2 +- .../adapters/WindowClickPacketAdapter.java | 5 +-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 7619b48..3c8851e 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.3 +version: 0.7.4 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 97fc0bb..0d81b0e 100644 --- a/src/config.yml +++ b/src/config.yml @@ -130,7 +130,43 @@ packets: # Placeholders: %player% commands: [] -# Prevents duplication with Signs/Books. +# Prevents invalid book creation. +books: + enabled: true + + # Punishes players that get detected by the check. + punishment: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] + +# Prevents invalid sign creation. +signs: + enabled: true + + # Punishes players that get detected by the check. + punishment: + # Do you want to punish player when they get detected? + enabled: true + + # How many times should a player be detected to be punished + threshold: 1 + + # Kick the player on detection? + kick: true + + # Placeholders: %player% + commands: [] + +# Prevents duplication with Signs/Books by removing not english characters. duplication: # Do you want to enable this module? enabled: true diff --git a/src/plugin.yml b/src/plugin.yml index 97755bd..2cfb600 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.3 +version: 0.7.4 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 32fce51..5dc6e45 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -24,14 +24,13 @@ public void onPacketReceiving(final PacketEvent event) { final InventoryView inventoryView = event.getPlayer().getOpenInventory(); if (inventoryView != null && integers.size() > 1) { - final int slot = integers.read(0) - 3; + final int slot = integers.read(1) - 3; final int maxSlots = inventoryView.countSlots(); if (slot > maxSlots) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); else packetsModule.checkPacket(event, Identity.WINDOW_CLICK); - } else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + } } } \ No newline at end of file From 34ce93ade8d63ea3225861b134c4cf254d92f30f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Fri, 13 Sep 2019 16:04:04 -0300 Subject: [PATCH 016/336] updated Source --- src/bungee.yml | 2 +- src/messages.yml | 12 ++++++ src/plugin.yml | 2 +- .../adapters/WindowClickPacketAdapter.java | 24 +++++++----- .../listeners/PlayerEditBookListener.java | 38 +++++++++++++------ .../bukkit/listeners/SignChangeListener.java | 27 +++++++++---- .../bukkit/managers/BukkitModuleManager.java | 14 +++++++ .../bukkit/modules/BukkitBooksModule.java | 37 ++++++++++++++++++ .../bukkit/modules/BukkitSignsModule.java | 37 ++++++++++++++++++ .../bukkit/modules/BukkitUUIDSpoofModule.java | 2 + .../bungee/managers/BungeeModuleManager.java | 10 +++++ .../interfaces/managers/ModuleManager.java | 4 ++ .../interfaces/modules/BooksModule.java | 7 ++++ .../interfaces/modules/SignsModule.java | 7 ++++ 14 files changed, 193 insertions(+), 30 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java create mode 100644 src/twolovers/exploitfixer/interfaces/modules/BooksModule.java create mode 100644 src/twolovers/exploitfixer/interfaces/modules/SignsModule.java diff --git a/src/bungee.yml b/src/bungee.yml index 3c8851e..145da07 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.4 +version: 0.7.5 author: 2LS commands: exploitfixer: diff --git a/src/messages.yml b/src/messages.yml index 40839b6..f584a3d 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -32,6 +32,10 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + books: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fBooks exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + signs: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fSigns exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fPlayers cached: &a%players_cached% @@ -67,6 +71,10 @@ es: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + books: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de books detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + signs: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de signs detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores en cache: &a%players_cached% @@ -102,6 +110,10 @@ pt: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + books: + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de books detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + signs: + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de signs detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores em cache: &a%players_cached% diff --git a/src/plugin.yml b/src/plugin.yml index 2cfb600..0be4709 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.4 +version: 0.7.5 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 5dc6e45..aca1ad0 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -4,6 +4,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; +import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -20,17 +21,22 @@ public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { + final Player player = event.getPlayer(); final StructureModifier integers = event.getPacket().getIntegers(); - final InventoryView inventoryView = event.getPlayer().getOpenInventory(); - if (inventoryView != null && integers.size() > 1) { - final int slot = integers.read(1) - 3; - final int maxSlots = inventoryView.countSlots(); + if (player != null) { + final InventoryView inventoryView = event.getPlayer().getOpenInventory(); - if (slot > maxSlots) - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); - } + if (inventoryView != null && integers.size() > 1) { + final int slot = integers.read(1) - 3; + final int maxSlots = inventoryView.countSlots(); + + if (slot > maxSlots) + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + } + } else + event.setCancelled(true); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java index bcd7b90..7101f5f 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java @@ -9,6 +9,7 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.BooksModule; import twolovers.exploitfixer.interfaces.modules.DuplicationModule; import java.util.regex.Pattern; @@ -16,36 +17,49 @@ public class PlayerEditBookListener implements Listener { private final Plugin plugin; private final DuplicationModule duplicationModule; + private final BooksModule booksModule; private final ExploitPlayerManager exploitPlayerManager; private final Pattern pattern = Pattern.compile("[^üéáíóúñÁÉÍÓÚÜA-Za-z.!@?#\"$%&§:;()Ñ¿¡ *'+,/\\-=\\[\\]^_{|}~`<>\\x00-\\x7F]+"); public PlayerEditBookListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.duplicationModule = moduleManager.getDuplicationModule(); + this.booksModule = moduleManager.getBooksModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST) public void onPlayerEditBook(final PlayerEditBookEvent event) { - if (duplicationModule.isEnabled()) { - final BookMeta bookMeta = event.getNewBookMeta(); + final BookMeta bookMeta = event.getNewBookMeta(); - if (bookMeta == null) + if (booksModule.isEnabled()) + if (bookMeta == null) { event.setCancelled(true); - else if (bookMeta.getEnchants().size() != 0) + } else if (bookMeta.getEnchants().size() != 0) { event.setCancelled(true); - else if (bookMeta.getPageCount() > 50) + } else if (bookMeta.getPageCount() > 50) { event.setCancelled(true); - else + } else for (String page : bookMeta.getPages()) { - if (page.length() > 340 || pattern.matcher(page).find()) { - final Player player = event.getPlayer(); + if (duplicationModule.isEnabled()) { + if (pattern.matcher(page).find()) { + final Player player = event.getPlayer(); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); - break; + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); + event.setCancelled(true); + return; + } + } + + if (booksModule.isEnabled()) { + if (page.length() > 340) { + final Player player = event.getPlayer(); + + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); + event.setCancelled(true); + return; + } } } - } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 448e84e..6f3f2dd 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -9,31 +9,44 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.DuplicationModule; +import twolovers.exploitfixer.interfaces.modules.SignsModule; import java.util.regex.Pattern; public class SignChangeListener implements Listener { private final Plugin plugin; private final DuplicationModule duplicationModule; + private final SignsModule signsModule; private final ExploitPlayerManager exploitPlayerManager; private final Pattern pattern = Pattern.compile("[^üéáíóúñÁÉÍÓÚÜA-Za-z.!@?#\"$%&§:;()Ñ¿¡ *'+,/\\-=\\[\\]^_{|}~`<>\\x00-\\x7F]+"); - public SignChangeListener(final Plugin plugin, final ModuleManager variables) { + public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.duplicationModule = variables.getDuplicationModule(); - this.exploitPlayerManager = variables.getExploitPlayerManager(); + this.duplicationModule = moduleManager.getDuplicationModule(); + this.signsModule = moduleManager.getSignsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST) public void onSignChange(final SignChangeEvent event) { - if (duplicationModule.isEnabled()) { - for (String line : event.getLines()) { - if (line.length() >= 46 || pattern.matcher(line).find()) { + for (String line : event.getLines()) { + if (duplicationModule.isEnabled()) { + if (pattern.matcher(line).find()) { final Player player = event.getPlayer(); exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); event.setCancelled(true); - break; + return; + } + } + + if (signsModule.isEnabled()) { + if (line.length() >= 46) { + final Player player = event.getPlayer(); + + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, signsModule, player); + event.setCancelled(true); + return; } } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 6e8a6d9..bd8ecca 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -16,6 +16,8 @@ public class BukkitModuleManager implements ModuleManager { private PacketsModule packetsModule; private ExploitPlayerManager exploitPlayerManager; private DuplicationModule duplicationModule; + private BooksModule booksModule; + private SignsModule signsModule; public BukkitModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { commandsModule = new BukkitCommandsModule(configYml); @@ -27,6 +29,8 @@ public BukkitModuleManager(final Plugin plugin, final Object configYml, final Ob packetsModule = new BukkitPacketsModule(plugin, this, configYml); exploitPlayerManager = new BukkitExploitPlayerManager(this); duplicationModule = new BukkitDuplicationModule(configYml); + booksModule = new BukkitBooksModule(configYml); + signsModule = new BukkitSignsModule(configYml); } public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { @@ -39,6 +43,8 @@ public void reload(final Object configYml, final Object messagesYml, final Objec packetsModule.reload(configYml); exploitPlayerManager.reload(); duplicationModule.reload(configYml); + booksModule.reload(configYml); + signsModule.reload(configYml); } public CommandsModule getCommandsModule() { @@ -76,4 +82,12 @@ public UUIDSpoofModule getUUIDSpoofModule() { public PacketsModule getPacketsModule() { return packetsModule; } + + public SignsModule getSignsModule() { + return signsModule; + } + + public BooksModule getBooksModule() { + return booksModule; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java new file mode 100644 index 0000000..acf83fb --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java @@ -0,0 +1,37 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.modules.BooksModule; +import twolovers.exploitfixer.shared.instanceables.Punishment; + +public class BukkitBooksModule implements BooksModule { + private boolean enabled; + private Punishment punishment; + + public BukkitBooksModule(final Object configYml) { + reload(configYml); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "Books"; + } + + @Override + public Punishment getPunishment() { + return punishment; + } + + @Override + public void reload(Object configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + this.enabled = configYml1.getBoolean("books.enabled"); + this.punishment = new Punishment(configYml1.getBoolean("books.punishment.enabled"), configYml1.getBoolean("books.punishment.kick"), configYml1.getInt("books.punishment.threshold"), configYml1.getStringList("books.punishment.commands")); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java new file mode 100644 index 0000000..b9f622d --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java @@ -0,0 +1,37 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.modules.SignsModule; +import twolovers.exploitfixer.shared.instanceables.Punishment; + +public class BukkitSignsModule implements SignsModule { + private boolean enabled; + private Punishment punishment; + + public BukkitSignsModule(final Object configYml) { + reload(configYml); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "Signs"; + } + + @Override + public Punishment getPunishment() { + return punishment; + } + + @Override + public void reload(Object configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + this.enabled = configYml1.getBoolean("signs.enabled"); + this.punishment = new Punishment(configYml1.getBoolean("signs.punishment.enabled"), configYml1.getBoolean("signs.punishment.kick"), configYml1.getInt("signs.punishment.threshold"), configYml1.getStringList("signs.punishment.commands")); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java index d7fe1c4..f568d99 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java @@ -12,6 +12,7 @@ public BukkitUUIDSpoofModule(final Object configYml) { reload(configYml); } + @Override final public Boolean isEnabled() { return enabled; } @@ -26,6 +27,7 @@ public Punishment getPunishment() { return punishment; } + @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 491c8c4..18f550b 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -55,6 +55,16 @@ public ExploitPlayerManager getExploitPlayerManager() { return exploitPlayerManager; } + @Override + public BooksModule getBooksModule() { + return null; + } + + @Override + public SignsModule getSignsModule() { + return null; + } + public DuplicationModule getDuplicationModule() { return null; } diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index 986631a..4efff1b 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -22,4 +22,8 @@ public interface ModuleManager { UUIDSpoofModule getUUIDSpoofModule(); ExploitPlayerManager getExploitPlayerManager(); + + BooksModule getBooksModule(); + + SignsModule getSignsModule(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java b/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java new file mode 100644 index 0000000..1552c6f --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java @@ -0,0 +1,7 @@ +package twolovers.exploitfixer.interfaces.modules; + +public interface BooksModule extends Module { + void reload(Object configYml); + + boolean isEnabled(); +} diff --git a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java new file mode 100644 index 0000000..a7a420f --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java @@ -0,0 +1,7 @@ +package twolovers.exploitfixer.interfaces.modules; + +public interface SignsModule extends Module { + void reload(Object configYml); + + boolean isEnabled(); +} From 2b6e61345e477fdcb8c18c3c21bbf99d4eb360e2 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 19 Sep 2019 18:51:52 -0300 Subject: [PATCH 017/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 4 ++++ src/plugin.yml | 2 +- .../adapters/EntityActionPacketAdapter.java | 23 +++++++++++++++++++ .../initializers/AdapterInitializer.java | 1 + .../listeners/InventoryCreativeListener.java | 17 ++++++++++++-- .../bukkit/modules/BukkitPacketsModule.java | 9 +++++++- .../exploitfixer/shared/enums/Identity.java | 2 +- 8 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java diff --git a/src/bungee.yml b/src/bungee.yml index 145da07..fdd11c2 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.5 +version: 0.7.6 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 0d81b0e..626d45d 100644 --- a/src/config.yml +++ b/src/config.yml @@ -98,6 +98,9 @@ packets: # Do you want to enable this module? enabled: true + # If a packet exceds this size it will be cancelled. + max_size: 16384 + # Max packets per second. # The ones ending with WRONG are impossible packets. # WRONG packets are recommended to set to 1 but it can cause issues with laggy players. @@ -108,6 +111,7 @@ packets: BLOCK_PLACE: 80 BLOCK_PLACE_BOOKS: 5 BLOCK_PLACE_WRONG: 20 + ENTITY_ACTION: 60 KEEP_ALIVE: 5 POSITION: 250 SET_CREATIVE_SLOT: 200 diff --git a/src/plugin.yml b/src/plugin.yml index 0be4709..69a7a53 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.5 +version: 0.7.6 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java new file mode 100644 index 0000000..095851d --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class EntityActionPacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public EntityActionPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.ENTITY_ACTION); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.ENTITY_ACTION); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index d1a7211..5637eb3 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -16,6 +16,7 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new EntityActionPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new KeepAlivePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index 372ff18..021ce99 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.listeners; +import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -10,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.Potion; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; @@ -26,13 +28,24 @@ public void onInventoryCreative(final InventoryCreativeEvent event) { if (itemsFixModule.isEnabled() && event.getAction() == InventoryAction.PLACE_ALL && whoClicked instanceof Player) { final ItemStack itemStack = event.getCursor(); - final ItemStack itemStackRemake = new ItemStack(itemStack.getType(), itemStack.getAmount(), itemStack.getData().getData()); + final Material material = itemStack.getType(); + ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); final ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta != null) { - if (itemMeta instanceof PotionMeta) + if (itemMeta instanceof PotionMeta) { ((PotionMeta) itemMeta).clearCustomEffects(); + if (material == Material.POTION) { + final Potion itemStackPotion = Potion.fromItemStack(itemStackRemake); + + if (Potion.fromItemStack(itemStack).isSplash()) + itemStackPotion.setSplash(true); + + itemStackRemake = itemStackPotion.toItemStack(itemStackRemake.getAmount()); + } + } + itemMeta.setDisplayName(null); itemMeta.setLore(null); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index c85e797..da95053 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -20,6 +20,7 @@ public class BukkitPacketsModule implements PacketsModule { private final Map limits = new HashMap<>(); private Punishment punishment; private boolean enabled; + private int maxSize; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -33,6 +34,7 @@ final public void reload(final Object configYml) { this.punishment = new Punishment(configYml1.getBoolean("packets.punishment.enabled"), configYml1.getBoolean("packets.punishment.kick"), configYml1.getInt("packets.punishment.threshold"), configYml1.getStringList("packets.punishment.commands")); this.enabled = configYml1.getBoolean("packets.enabled"); + this.maxSize = configYml1.getInt("packets.max_size"); for (final String packetIdentityName : configurationSection.getKeys(false)) { for (final Identity identity : Identity.values()) { @@ -66,6 +68,7 @@ public void checkPacket(Object packetEvent, Identity identity) { if (!event.isCancelled()) { final Player player = event.getPlayer(); + final int size = event.getPacket().getBytes().toString().length(); if (player != null) { final String playerName = player.getName(); @@ -74,7 +77,11 @@ public void checkPacket(Object packetEvent, Identity identity) { if (exploitPlayer != null) { final int limit = getLimit(identity); - if (limit > 0) { + if (size > maxSize) { + exploitPlayer.punish(plugin, this, player); + moduleManager.getNotificationsModule().sendNotification("PACKET_SIZE", player); + event.setCancelled(true); + } else if (limit > 0) { exploitPlayer.addViolation(identity); final int violations = exploitPlayer.getViolations(identity); diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index 55a3b10..abc4b7d 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -2,5 +2,5 @@ public enum Identity { ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, - KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG + KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, } From d6078f7e6164b5b5d98f8f2004321fd6f21ea1ab Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 13 Oct 2019 20:31:30 -0300 Subject: [PATCH 018/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 1 + src/plugin.yml | 2 +- .../bukkit/adapters/SetCreativeSlotPacketAdapter.java | 4 ++++ .../bukkit/listeners/PlayerEditBookListener.java | 5 +++++ src/twolovers/exploitfixer/shared/enums/Identity.java | 2 +- 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index fdd11c2..683eea5 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.6 +version: 0.7.7 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 626d45d..d3866d8 100644 --- a/src/config.yml +++ b/src/config.yml @@ -115,6 +115,7 @@ packets: KEEP_ALIVE: 5 POSITION: 250 SET_CREATIVE_SLOT: 200 + SET_CREATIVE_SLOT_WRONG: 1 USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 diff --git a/src/plugin.yml b/src/plugin.yml index 69a7a53..addb4f2 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.6 +version: 0.7.7 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 8197ad2..5c5e555 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -3,6 +3,7 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.GameMode; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -19,5 +20,8 @@ public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager mod @Override public void onPacketReceiving(final PacketEvent event) { packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT); + + if (event.getPlayer().getGameMode() == GameMode.SURVIVAL) + packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT_WRONG); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java index 7101f5f..a26ce0a 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java @@ -35,10 +35,13 @@ public void onPlayerEditBook(final PlayerEditBookEvent event) { if (booksModule.isEnabled()) if (bookMeta == null) { event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); } else if (bookMeta.getEnchants().size() != 0) { event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); } else if (bookMeta.getPageCount() > 50) { event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); } else for (String page : bookMeta.getPages()) { if (duplicationModule.isEnabled()) { @@ -47,6 +50,7 @@ public void onPlayerEditBook(final PlayerEditBookEvent event) { exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); return; } } @@ -57,6 +61,7 @@ public void onPlayerEditBook(final PlayerEditBookEvent event) { exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); return; } } diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index abc4b7d..bc520f2 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -2,5 +2,5 @@ public enum Identity { ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, - KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, + KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, SET_CREATIVE_SLOT_WRONG } From 6d6faa77605b34dbdc0725f18e25de74e68a6e35 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Mon, 14 Oct 2019 18:35:10 -0300 Subject: [PATCH 019/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 9 ++++++++- src/plugin.yml | 2 +- .../listeners/PlayerEditBookListener.java | 17 +++++++++-------- .../bukkit/listeners/SignChangeListener.java | 19 +++++++++---------- .../modules/BukkitDuplicationModule.java | 9 ++++++++- .../interfaces/modules/DuplicationModule.java | 2 ++ 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 683eea5..a927597 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.7 +version: 0.7.8 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index d3866d8..397c542 100644 --- a/src/config.yml +++ b/src/config.yml @@ -171,11 +171,18 @@ signs: # Placeholders: %player% commands: [] -# Prevents duplication with Signs/Books by removing not english characters. +# Prevents duplication with Signs/Books by cancelling characters of 3 or more bytes long. duplication: # Do you want to enable this module? enabled: true + # Maximum bytes allowed per character. + # Common keyboard characters are 1 byte long. + # Characters with tildes are 2 bytes long. + # Chinese characters are 3 bytes long. + # Emojis are 4 bytes long. + max_bytes: 2 + # Punishes players that get detected by the check. punishment: # Do you want to punish player when they get detected? diff --git a/src/plugin.yml b/src/plugin.yml index addb4f2..188dfee 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.7 +version: 0.7.8 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java index a26ce0a..d23d9c1 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java @@ -12,14 +12,13 @@ import twolovers.exploitfixer.interfaces.modules.BooksModule; import twolovers.exploitfixer.interfaces.modules.DuplicationModule; -import java.util.regex.Pattern; +import java.nio.charset.StandardCharsets; public class PlayerEditBookListener implements Listener { private final Plugin plugin; private final DuplicationModule duplicationModule; private final BooksModule booksModule; private final ExploitPlayerManager exploitPlayerManager; - private final Pattern pattern = Pattern.compile("[^üéáíóúñÁÉÍÓÚÜA-Za-z.!@?#\"$%&§:;()Ñ¿¡ *'+,/\\-=\\[\\]^_{|}~`<>\\x00-\\x7F]+"); public PlayerEditBookListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; @@ -45,13 +44,15 @@ public void onPlayerEditBook(final PlayerEditBookEvent event) { } else for (String page : bookMeta.getPages()) { if (duplicationModule.isEnabled()) { - if (pattern.matcher(page).find()) { - final Player player = event.getPlayer(); + for (final String word : page.split("")) { + if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { + final Player player = event.getPlayer(); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); - event.setNewBookMeta(event.getPreviousBookMeta()); - return; + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); + event.setCancelled(true); + event.setNewBookMeta(event.getPreviousBookMeta()); + return; + } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 6f3f2dd..3c5ea83 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -11,14 +11,13 @@ import twolovers.exploitfixer.interfaces.modules.DuplicationModule; import twolovers.exploitfixer.interfaces.modules.SignsModule; -import java.util.regex.Pattern; +import java.nio.charset.StandardCharsets; public class SignChangeListener implements Listener { private final Plugin plugin; private final DuplicationModule duplicationModule; private final SignsModule signsModule; private final ExploitPlayerManager exploitPlayerManager; - private final Pattern pattern = Pattern.compile("[^üéáíóúñÁÉÍÓÚÜA-Za-z.!@?#\"$%&§:;()Ñ¿¡ *'+,/\\-=\\[\\]^_{|}~`<>\\x00-\\x7F]+"); public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; @@ -29,21 +28,21 @@ public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager @EventHandler(priority = EventPriority.LOWEST) public void onSignChange(final SignChangeEvent event) { + final Player player = event.getPlayer(); + for (String line : event.getLines()) { if (duplicationModule.isEnabled()) { - if (pattern.matcher(line).find()) { - final Player player = event.getPlayer(); - - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); - return; + for (String word : line.split("")) { + if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { + exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); + event.setCancelled(true); + return; + } } } if (signsModule.isEnabled()) { if (line.length() >= 46) { - final Player player = event.getPlayer(); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, signsModule, player); event.setCancelled(true); return; diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java index 8bba9d0..7e85fcc 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java @@ -6,6 +6,7 @@ public class BukkitDuplicationModule implements DuplicationModule { private boolean enabled; + private int maxBytes; private Punishment punishment; public BukkitDuplicationModule(final Object configYml) { @@ -15,7 +16,8 @@ public BukkitDuplicationModule(final Object configYml) { final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - enabled = configYml1.getBoolean("duplication.enabled"); + this.enabled = configYml1.getBoolean("duplication.enabled"); + this.maxBytes = configYml1.getInt("duplication.max_bytes"); this.punishment = new Punishment(configYml1.getBoolean("duplication.punishment.enabled"), configYml1.getBoolean("duplication.punishment.kick"), configYml1.getInt("duplication.punishment.threshold"), configYml1.getStringList("duplication.punishment.commands")); } @@ -23,6 +25,11 @@ final public Boolean isEnabled() { return enabled; } + @Override + public int getMaxBytes() { + return maxBytes; + } + public String getName() { return "Duplication"; } diff --git a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java index e2354f9..ef7e237 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java @@ -4,4 +4,6 @@ public interface DuplicationModule extends Module { void reload(Object configYml); Boolean isEnabled(); + + int getMaxBytes(); } From 3311c8a5d004ed18c0b6a51258b5802dcbdfc23f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Fri, 18 Oct 2019 14:41:07 -0300 Subject: [PATCH 020/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../adapters/CustomPayloadPacketAdapter.java | 13 +++--- .../SetCreativeSlotPacketAdapter.java | 9 +++- .../adapters/WindowClickPacketAdapter.java | 42 ++++++++++++++----- .../listeners/PlayerCommandListener.java | 8 ++-- .../bukkit/modules/BukkitPacketsModule.java | 17 +++++++- .../bungee/listeners/ChatListener.java | 3 +- 8 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index a927597..d0d7b6c 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.8 +version: 0.7.9 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 188dfee..f2f1ba5 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.8 +version: 0.7.9 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java index 8e7fdd1..595c40f 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java @@ -5,7 +5,6 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import io.netty.buffer.ByteBuf; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -28,7 +27,7 @@ public CustomPayloadPacketAdapter(final Plugin plugin, final ModuleManager modul this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.messagesModule = moduleManager.getMessagesModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.isOneDotSeven = Bukkit.getServer().getVersion().contains("1.7"); + this.isOneDotSeven = plugin.getServer().getVersion().contains("1.7"); } @Override @@ -40,21 +39,21 @@ public void onPacketReceiving(final PacketEvent event) { final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); if (exploitPlayer != null) { - int dataSize = 0; + int size = 0; final List values = packetContainer.getModifier().getValues(); - if (!values.isEmpty()) { + if (values.size() > 1) { tag = String.valueOf(values.get(0)); final Object object = values.get(1); if (!isOneDotSeven && object instanceof ByteBuf) - dataSize = ((ByteBuf) object).capacity(); + size = ((ByteBuf) object).capacity(); } if (tag == null) event.setCancelled(true); - else if (dataSize > 16384) { + else if (size > 16384) { exploitPlayer.punish(plugin, customPayloadModule, player); event.setCancelled(true); } else if (tag.equals("MC|BSign") || tag.equals("MC|BEdit") || tag.equals("MC|BOpen")) { @@ -68,7 +67,7 @@ else if (dataSize > 16384) { } else if (violations > customPayloadModule.getLimit()) event.setCancelled(true); } else if (tag.equals("REGISTER")) { - exploitPlayer.addChannels(dataSize); + exploitPlayer.addChannels(size); final int channels = exploitPlayer.getChannels(); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 5c5e555..06affd0 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -4,6 +4,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.GameMode; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -19,9 +20,13 @@ public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager mod @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT); + final Player player = event.getPlayer(); - if (event.getPlayer().getGameMode() == GameMode.SURVIVAL) + if (player == null) packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT_WRONG); + else if (player.getGameMode() != GameMode.CREATIVE) + packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT_WRONG); + else + packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index aca1ad0..3f9787b 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -2,10 +2,13 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -22,21 +25,40 @@ public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { final Player player = event.getPlayer(); - final StructureModifier integers = event.getPacket().getIntegers(); - if (player != null) { - final InventoryView inventoryView = event.getPlayer().getOpenInventory(); + if (player == null) + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + else { + final PacketContainer packet = event.getPacket(); + final StructureModifier integers = packet.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); - if (inventoryView != null && integers.size() > 1) { - final int slot = integers.read(1) - 3; + if (inventoryView == null) + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + else if (integers.size() > 1) { + final int slot = integers.read(1); final int maxSlots = inventoryView.countSlots(); - if (slot > maxSlots) + if (slot - 2 > maxSlots) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + else { + final StructureModifier structureModifier = packet.getItemModifier(); + + if (structureModifier.size() > 0) { + if (slot > 0) { + final ItemStack itemStack = inventoryView.getItem(slot); + final ItemStack itemStack1 = structureModifier.read(0); + + if (itemStack1 != null && itemStack1.getType() != Material.AIR && !itemStack1.equals(itemStack)) + packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); + else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + } else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + } else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + } } - } else - event.setCancelled(true); + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index a419dfd..5cfabb8 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -24,18 +24,16 @@ public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleMana @EventHandler(priority = EventPriority.LOWEST) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!event.isCancelled() && commandsModule.isEnabled()) { - String message = event.getMessage(); - - for (final String command : commandsModule.getCommands()) { - message = message.replaceAll("[\\w]+:", ""); + final String message = event.getMessage().replaceAll("[\\w]+:", ""); + for (final String command : commandsModule.getCommands()) if (message.startsWith(command + " ") || message.endsWith(command)) { final Player player = event.getPlayer(); exploitPlayerManager.getPlayer(player.getName()).punish(plugin, commandsModule, player); event.setCancelled(true); + break; } - } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index da95053..f323b2f 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.modules; import com.comphenix.protocol.events.PacketEvent; +import io.netty.buffer.ByteBuf; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -12,6 +13,7 @@ import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.HashMap; +import java.util.List; import java.util.Map; public class BukkitPacketsModule implements PacketsModule { @@ -21,11 +23,13 @@ public class BukkitPacketsModule implements PacketsModule { private Punishment punishment; private boolean enabled; private int maxSize; + private final boolean isOneDotSeven; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; this.moduleManager = moduleManager; reload(configYml); + this.isOneDotSeven = plugin.getServer().getVersion().contains("1.7"); } final public void reload(final Object configYml) { @@ -55,7 +59,7 @@ public void addLimit(final Identity packet, final int value) { } public int getLimit(final Identity packet) { - return limits.getOrDefault(packet, 999999); + return limits.getOrDefault(packet, 10000); } public boolean isEnabled() { @@ -68,7 +72,15 @@ public void checkPacket(Object packetEvent, Identity identity) { if (!event.isCancelled()) { final Player player = event.getPlayer(); - final int size = event.getPacket().getBytes().toString().length(); + int size = 1; + final List values = event.getPacket().getModifier().getValues(); + + if (values.size() > 1) { + final Object object = values.get(1); + + if (!isOneDotSeven && object instanceof ByteBuf) + size = ((ByteBuf) object).capacity(); + } if (player != null) { final String playerName = player.getName(); @@ -89,6 +101,7 @@ public void checkPacket(Object packetEvent, Identity identity) { if (violations == limit) { exploitPlayer.punish(plugin, this, player); moduleManager.getNotificationsModule().sendNotification(identity.name(), player); + event.setCancelled(true); } else if (violations > limit) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index a3be882..c292daa 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -24,7 +24,7 @@ public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { @EventHandler(priority = -128) public void onChat(ChatEvent event) { if (!event.isCancelled() && commandsModule.isEnabled()) { - final String message = event.getMessage(); + final String message = event.getMessage().replaceAll("[\\w]+:", ""); for (final String command : commandsModule.getCommands()) if (message.startsWith(command + " ") || message.endsWith(command)) { @@ -34,7 +34,6 @@ public void onChat(ChatEvent event) { final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; exploitPlayerManager.getPlayer(proxiedPlayer.getName()).punish(plugin, commandsModule, proxiedPlayer); - event.setCancelled(true); } From e17f7f0d292698aac7fbbd4b11262551ea190918 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 19 Oct 2019 03:37:33 -0300 Subject: [PATCH 021/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../adapters/WindowClickPacketAdapter.java | 23 +++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index d0d7b6c..c5c38ea 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.7.9 +version: 0.8.0 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index f2f1ba5..42ae629 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.7.9 +version: 0.8.0 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 3f9787b..1d9f125 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -7,6 +7,8 @@ import com.comphenix.protocol.reflect.StructureModifier; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; @@ -36,20 +38,27 @@ public void onPacketReceiving(final PacketEvent event) { if (inventoryView == null) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); else if (integers.size() > 1) { - final int slot = integers.read(1); + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); final int maxSlots = inventoryView.countSlots(); + int slot = integers.read(1); - if (slot - 2 > maxSlots) + if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) + slot = slot - 4; + + if (slot >= maxSlots) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); else { final StructureModifier structureModifier = packet.getItemModifier(); - if (structureModifier.size() > 0) { - if (slot > 0) { - final ItemStack itemStack = inventoryView.getItem(slot); - final ItemStack itemStack1 = structureModifier.read(0); + if (structureModifier.size() > 0 && slot > 0) { + final ItemStack itemStack = inventoryView.getItem(slot); + final ItemStack itemStack1 = structureModifier.read(0); + + if (itemStack1 != null) { + final Material material = itemStack1.getType(); - if (itemStack1 != null && itemStack1.getType() != Material.AIR && !itemStack1.equals(itemStack)) + if ((material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); else packetsModule.checkPacket(event, Identity.WINDOW_CLICK); From 8e8561870c53b4e2793c87a96ce70e5f77eef739 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 26 Oct 2019 03:17:05 -0300 Subject: [PATCH 022/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 2 ++ src/plugin.yml | 2 +- .../adapters/TabCompletePacketAdapter.java | 23 +++++++++++++++++++ .../adapters/UpdateSignPacketAdapter.java | 23 +++++++++++++++++++ .../initializers/AdapterInitializer.java | 2 ++ .../bukkit/listeners/PlayerQuitListener.java | 6 +++-- .../bungee/listeners/DisconnectListener.java | 6 +++-- .../exploitfixer/shared/enums/Identity.java | 3 ++- 9 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java diff --git a/src/bungee.yml b/src/bungee.yml index c5c38ea..929c2fd 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.0 +version: 0.8.1 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 397c542..d32cbb2 100644 --- a/src/config.yml +++ b/src/config.yml @@ -116,6 +116,8 @@ packets: POSITION: 250 SET_CREATIVE_SLOT: 200 SET_CREATIVE_SLOT_WRONG: 1 + TAB_COMPLETE: 50 + UPDATE_SIGN: 8 USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 diff --git a/src/plugin.yml b/src/plugin.yml index 42ae629..ac1ed21 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.0 +version: 0.8.1 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java new file mode 100644 index 0000000..4cd3ca7 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class TabCompletePacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public TabCompletePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.TAB_COMPLETE); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.TAB_COMPLETE); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java new file mode 100644 index 0000000..15b2569 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java @@ -0,0 +1,23 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import twolovers.exploitfixer.shared.enums.Identity; + +public class UpdateSignPacketAdapter extends PacketAdapter { + private final PacketsModule packetsModule; + + public UpdateSignPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.UPDATE_SIGN); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event, Identity.UPDATE_SIGN); + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 5637eb3..9f73bda 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -20,6 +20,8 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.addPacketListener(new KeepAlivePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new TabCompletePacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new UpdateSignPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new UseEntityPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new UseItemPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java index 64b709d..cb30009 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -23,8 +23,10 @@ public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); + if (exploitPlayer != null) { + exploitPlayer.clearChannels(); + exploitPlayer.clearViolations(); + } notificationsModule.setNotifications(player, false); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index 6434bc0..0f44ec9 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -23,8 +23,10 @@ public void onDisconnect(final PlayerDisconnectEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(proxiedPlayer.getName()); - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); + if (exploitPlayer != null) { + exploitPlayer.clearChannels(); + exploitPlayer.clearViolations(); + } notificationsModule.setNotifications(proxiedPlayer, false); } diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java index bc520f2..ab05b2a 100644 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ b/src/twolovers/exploitfixer/shared/enums/Identity.java @@ -2,5 +2,6 @@ public enum Identity { ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, - KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, SET_CREATIVE_SLOT_WRONG + KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, SET_CREATIVE_SLOT_WRONG, TAB_COMPLETE, + UPDATE_SIGN } From c1506f41ff8457b8d680e958e457bf3205916a14 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 29 Oct 2019 12:48:15 -0300 Subject: [PATCH 023/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../managers/BukkitExploitPlayerManager.java | 33 ++++++++---------- .../managers/BungeeExploitPlayerManager.java | 34 +++++++++---------- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 929c2fd..fb30d7f 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.1 +version: 0.8.2 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index ac1ed21..d35aef6 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.1 +version: 0.8.2 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index f5e67d8..1963291 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -7,43 +7,39 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; +import java.util.*; public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; - final private Collection exploitPlayers = new HashSet<>(); + final private Map exploitPlayers = new HashMap<>(); private int punishments = 0; - public BukkitExploitPlayerManager(final ModuleManager moduleManager) { + BukkitExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; for (final Player player : Bukkit.getOnlinePlayers()) addPlayer(player.getName()); } + @Override public ExploitPlayer getPlayer(final String playerName) { - if (playerName != null) - for (final ExploitPlayer exploitPlayer : exploitPlayers) - if (playerName.equals(exploitPlayer.getName())) - return exploitPlayer; - - return null; + return exploitPlayers.getOrDefault(playerName, null); } + @Override public void addPlayer(final String playerName) { if (getPlayer(playerName) == null) - exploitPlayers.add(new BukkitExploitPlayer(playerName, moduleManager)); + exploitPlayers.put(playerName, new BukkitExploitPlayer(playerName, moduleManager)); } + @Override public void reload() { - final Iterator iterator = exploitPlayers.iterator(); + final Iterator iterator = exploitPlayers.keySet().iterator(); boolean hasRemoved = false; while (iterator.hasNext()) { - final ExploitPlayer exploitPlayer = iterator.next(); - final Player player = Bukkit.getPlayer(exploitPlayer.getName()); + final String playerName = iterator.next(); + final Player player = Bukkit.getPlayer(playerName); if (player == null || !player.isOnline()) { iterator.remove(); @@ -58,8 +54,9 @@ public void reload() { punishments = 0; } + @Override public Collection getExploitPlayers() { - return exploitPlayers; + return exploitPlayers.values(); } @Override @@ -73,7 +70,7 @@ public void addPunishment() { } @Override - public void removePlayer(String name) { - exploitPlayers.remove(getPlayer(name)); + public void removePlayer(final String name) { + exploitPlayers.remove(name); } } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 763b2e9..332f64c 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -2,48 +2,47 @@ import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; -import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; +import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import java.util.Collection; -import java.util.HashSet; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; public class BungeeExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; - final private Collection exploitPlayers = new HashSet<>(); + final private Map exploitPlayers = new HashMap<>(); private int punishments = 0; - public BungeeExploitPlayerManager(final ModuleManager moduleManager) { + BungeeExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; for (final ProxiedPlayer proxiedPlayer : BungeeCord.getInstance().getPlayers()) addPlayer(proxiedPlayer.getName()); } + @Override public ExploitPlayer getPlayer(final String playerName) { - if (playerName != null) - for (final ExploitPlayer exploitPlayer : exploitPlayers) - if (playerName.equals(exploitPlayer.getName())) - return exploitPlayer; - - return null; + return exploitPlayers.getOrDefault(playerName, null); } + @Override public void addPlayer(final String playerName) { if (getPlayer(playerName) == null) - exploitPlayers.add(new BungeeExploitPlayer(playerName, moduleManager)); + exploitPlayers.put(playerName, new BukkitExploitPlayer(playerName, moduleManager)); } + @Override public void reload() { - final Iterator iterator = exploitPlayers.iterator(); + final Iterator iterator = exploitPlayers.keySet().iterator(); boolean hasRemoved = false; while (iterator.hasNext()) { - final ExploitPlayer exploitPlayer = iterator.next(); - final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(exploitPlayer.getName()); + final String playerName = iterator.next(); + final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(playerName); if (player == null || !player.isConnected()) { iterator.remove(); @@ -58,8 +57,9 @@ public void reload() { punishments = 0; } + @Override public Collection getExploitPlayers() { - return exploitPlayers; + return exploitPlayers.values(); } @Override @@ -73,7 +73,7 @@ public void addPunishment() { } @Override - public void removePlayer(String name) { - exploitPlayers.remove(getPlayer(name)); + public void removePlayer(final String name) { + exploitPlayers.remove(name); } } From 04de663c3cb8622a38ce6871fa3c41c90e35998a Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Wed, 30 Oct 2019 17:33:12 -0300 Subject: [PATCH 024/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../bukkit/adapters/WindowClickPacketAdapter.java | 4 ++-- .../bungee/managers/BungeeExploitPlayerManager.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index fb30d7f..5266fc3 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.2 +version: 0.8.3 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index d35aef6..193cb38 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.2 +version: 0.8.3 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 1d9f125..8eb9a07 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -40,11 +40,11 @@ public void onPacketReceiving(final PacketEvent event) { else if (integers.size() > 1) { final Inventory topInventory = inventoryView.getTopInventory(); final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int maxSlots = inventoryView.countSlots(); + int maxSlots = inventoryView.countSlots(); int slot = integers.read(1); if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) - slot = slot - 4; + maxSlots += 4; if (slot >= maxSlots) packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 332f64c..643ebee 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -2,7 +2,7 @@ import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; -import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; +import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -32,7 +32,7 @@ public ExploitPlayer getPlayer(final String playerName) { @Override public void addPlayer(final String playerName) { if (getPlayer(playerName) == null) - exploitPlayers.put(playerName, new BukkitExploitPlayer(playerName, moduleManager)); + exploitPlayers.put(playerName, new BungeeExploitPlayer(playerName, moduleManager)); } @Override From f5c67bcd756a2c9c8bc60dd5c52b85d2cccb3c5b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Mon, 4 Nov 2019 14:59:07 -0300 Subject: [PATCH 025/336] updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../exploitfixer/bukkit/listeners/PlayerCommandListener.java | 2 +- .../exploitfixer/bukkit/listeners/PlayerEditBookListener.java | 2 +- .../exploitfixer/bukkit/listeners/PlayerLoginListener.java | 2 +- .../exploitfixer/bukkit/listeners/SignChangeListener.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 5266fc3..f59b3a7 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.3 +version: 0.8.4 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 193cb38..8c7b6dc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.3 +version: 0.8.4 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 5cfabb8..c201136 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -21,7 +21,7 @@ public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleMana this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!event.isCancelled() && commandsModule.isEnabled()) { final String message = event.getMessage().replaceAll("[\\w]+:", ""); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java index d23d9c1..b0ead63 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java @@ -27,7 +27,7 @@ public PlayerEditBookListener(final Plugin plugin, final ModuleManager moduleMan this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerEditBook(final PlayerEditBookEvent event) { final BookMeta bookMeta = event.getNewBookMeta(); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 195b71f..8b6112c 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -30,7 +30,7 @@ public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManage this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); final String lang = player.spigot().getLocale().substring(0, 2); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 3c5ea83..4717999 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -26,7 +26,7 @@ public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onSignChange(final SignChangeEvent event) { final Player player = event.getPlayer(); From 059d89c2c7afd16be8939e6893cc93292b4c92e4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 5 Nov 2019 11:28:04 -0300 Subject: [PATCH 026/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 3 ++- src/plugin.yml | 2 +- .../bukkit/adapters/WindowClickPacketAdapter.java | 7 ++++--- .../bukkit/listeners/PlayerCommandListener.java | 2 +- .../exploitfixer/bungee/commands/ExploitFixerCommand.java | 2 +- .../exploitfixer/bungee/listeners/ChatListener.java | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index f59b3a7..3edce52 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.4 +version: 0.8.5 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index d32cbb2..6e88309 100644 --- a/src/config.yml +++ b/src/config.yml @@ -69,6 +69,7 @@ commands: - "/pex demote" - "/promote" - "/demote" + - "/execute" # Punishes players that get detected by the check. punishment: @@ -121,7 +122,7 @@ packets: USE_ENTITY: 80 USE_ITEM: 80 WINDOW_CLICK: 80 - WINDOW_CLICK_WRONG: 5 + WINDOW_CLICK_WRONG: 15 # Punishes players that get detected by the check. punishment: diff --git a/src/plugin.yml b/src/plugin.yml index 8c7b6dc..faf07cf 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.4 +version: 0.8.5 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 8eb9a07..49dad6c 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -58,16 +58,17 @@ else if (integers.size() > 1) { if (itemStack1 != null) { final Material material = itemStack1.getType(); - if ((material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) + if ((material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) { packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else + } else packetsModule.checkPacket(event, Identity.WINDOW_CLICK); } else packetsModule.checkPacket(event, Identity.WINDOW_CLICK); } else packetsModule.checkPacket(event, Identity.WINDOW_CLICK); } - } + } else + packetsModule.checkPacket(event, Identity.WINDOW_CLICK); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index c201136..798db3c 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -24,7 +24,7 @@ public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleMana @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!event.isCancelled() && commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]+:", ""); + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) if (message.startsWith(command + " ") || message.endsWith(command)) { diff --git a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java index d4b9fbc..bd7d7b7 100644 --- a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -22,7 +22,7 @@ public ExploitFixerCommand(final String string, final ModuleManager moduleManage this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - public void execute(final CommandSender commandSender, String[] args) { + public void execute(final CommandSender commandSender, final String[] args) { String lang = "en"; final int length = args.length; diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index c292daa..09d8476 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -24,7 +24,7 @@ public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { @EventHandler(priority = -128) public void onChat(ChatEvent event) { if (!event.isCancelled() && commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]+:", ""); + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) if (message.startsWith(command + " ") || message.endsWith(command)) { From 2d332e45126a00000152b34a49b22dcf49f6dd02 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 24 Dec 2019 14:57:11 -0300 Subject: [PATCH 027/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 248 +++++++++--------- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 15 +- .../adapters/AbilitiesPacketAdapter.java | 4 +- .../adapters/ArmAnimationPacketAdapter.java | 4 +- .../adapters/BlockDigPacketAdapter.java | 29 +- .../adapters/BlockPlacePacketAdapter.java | 43 +-- .../adapters/CustomPayloadPacketAdapter.java | 71 +---- .../adapters/EntityActionPacketAdapter.java | 4 +- .../adapters/KeepAlivePacketAdapter.java | 23 -- .../adapters/PositionPacketAdapter.java | 4 +- .../SetCreativeSlotPacketAdapter.java | 17 +- .../adapters/TabCompletePacketAdapter.java | 4 +- .../adapters/UpdateSignPacketAdapter.java | 4 +- .../adapters/UseEntityPacketAdapter.java | 4 +- .../bukkit/adapters/UseItemPacketAdapter.java | 4 +- .../adapters/WindowClickPacketAdapter.java | 79 +++--- .../initializers/AdapterInitializer.java | 1 - .../bukkit/commands/ExploitFixerCommand.java | 8 +- .../instanceables/BukkitExploitPlayer.java | 103 +++++--- .../instanceables/BukkitThresholds.java | 34 +++ .../listeners/PlayerCommandListener.java | 3 +- .../listeners/PlayerEditBookListener.java | 17 +- .../bukkit/listeners/PlayerLoginListener.java | 17 +- .../bukkit/listeners/PlayerQuitListener.java | 2 +- .../bukkit/listeners/SignChangeListener.java | 6 +- .../managers/BukkitExploitPlayerManager.java | 56 ++-- .../bukkit/managers/BukkitModuleManager.java | 2 +- .../bukkit/modules/BukkitBooksModule.java | 27 +- .../bukkit/modules/BukkitCommandsModule.java | 36 ++- .../modules/BukkitCustomPayloadModule.java | 100 +++++-- .../modules/BukkitDuplicationModule.java | 27 +- .../bukkit/modules/BukkitItemsFixModule.java | 13 +- .../bukkit/modules/BukkitMessagesModule.java | 9 +- .../bukkit/modules/BukkitPacketsModule.java | 146 +++++------ .../bukkit/modules/BukkitSignsModule.java | 27 +- .../bukkit/modules/BukkitUUIDSpoofModule.java | 27 +- .../bukkit/utils/ConfigurationUtil.java | 6 +- .../bukkit/utils/VersionUtil.java | 20 ++ .../exploitfixer/bungee/ExploitFixer.java | 26 +- .../bungee/commands/ExploitFixerCommand.java | 2 +- .../instanceables/BungeeExploitPlayer.java | 105 +++++--- .../instanceables/BungeeThresholds.java | 35 +++ .../bungee/listeners/ChatListener.java | 3 +- .../bungee/listeners/DisconnectListener.java | 2 +- .../listeners/PluginMessageListener.java | 66 +---- .../bungee/listeners/PostLoginListener.java | 18 +- .../managers/BungeeExploitPlayerManager.java | 74 +++--- .../bungee/managers/BungeeModuleManager.java | 25 +- .../bungee/modules/BungeeCommandsModule.java | 29 +- .../modules/BungeeCustomPayloadModule.java | 85 ++++-- .../bungee/modules/BungeeMessagesModule.java | 3 +- .../bungee/modules/BungeeUUIDSpoofModule.java | 27 +- .../bungee/utils/ConfigurationUtil.java | 6 +- .../instanceables/ExploitPlayer.java | 10 +- .../interfaces/instanceables/Thresholds.java | 9 + .../managers/ExploitPlayerManager.java | 16 +- .../interfaces/managers/ModuleManager.java | 4 +- .../interfaces/modules/BooksModule.java | 2 +- .../interfaces/modules/CancellableModule.java | 11 + .../interfaces/modules/CommandsModule.java | 4 +- .../modules/CustomPayloadModule.java | 10 +- .../interfaces/modules/DuplicationModule.java | 2 +- .../interfaces/modules/ItemsFixModule.java | 2 +- .../interfaces/modules/MessagesModule.java | 2 +- .../interfaces/modules/Module.java | 4 - .../interfaces/modules/PacketsModule.java | 20 +- .../interfaces/modules/ReloadableModule.java | 5 + .../interfaces/modules/SignsModule.java | 2 +- .../interfaces/modules/UUIDSpoofModule.java | 2 +- .../exploitfixer/shared/enums/Identity.java | 7 - .../shared/instanceables/Punishment.java | 32 --- 73 files changed, 1049 insertions(+), 849 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java create mode 100644 src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java create mode 100644 src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java create mode 100644 src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java create mode 100644 src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java create mode 100644 src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java create mode 100644 src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java delete mode 100644 src/twolovers/exploitfixer/shared/enums/Identity.java delete mode 100644 src/twolovers/exploitfixer/shared/instanceables/Punishment.java diff --git a/src/bungee.yml b/src/bungee.yml index 3edce52..8a049d5 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.8.5 +version: 0.9.1 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 6e88309..c847160 100644 --- a/src/config.yml +++ b/src/config.yml @@ -7,55 +7,111 @@ notifications: # %check% gets replaced dynamically by the check. message: "&c&lEF: &e%player% &f| &6%check% &f| &c%ping%ms" -# Prevents exploits with custompayload packets. -custompayload: +# Checks if players have a invalid UUID. +uuidspoof: # Do you want to enable this module? enabled: true - # Maximum custom payload packets that can be sent per second. - limit: - normal: 6 - # Increase if you have false positives in BungeeCord. - other: 400 - - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true + # Amount of violations required to cancel. + cancel_vls: 1 - # How many times should a player be detected to be punished - threshold: 1 + # Amount of violations to reduce per second. + reduce_vls: 1 - # Kick the player on detection? - kick: true + # Placeholders: %player% + thresholds: + 1: + - "kick" + - "notification" - # Placeholders: %player% - commands: [] - -# Checks if players have a invalid UUID. -uuidspoof: +# Limits custom_payload packets to avoid exploits. +custompayload: # Do you want to enable this module? enabled: true - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true + # Max amount of registered channels per player allowed. + max_channels: 256 - # How many times should a player be detected to be punished - threshold: 1 + # Amount of violations required to cancel. + cancel_vls: 400 - # Kick the player on detection? - kick: true + # Amount of violations to reduce per second. + reduce_vls: 500 - # Placeholders: %player% - commands: [] + multipliers: + OTHER: 1.25 + MAX_CHANNELS: 600 + MC|BSign: 50 + MC|BEdit: 50 + MC|BOpen: 50 + + # Placeholders: %player% + thresholds: + 600: + - "kick" + - "notification" + +# Cancels common kinds of invalid packets and limits valid packets. +packets: + # Do you want to enable this module? + enabled: true + + # Cancells packets from offline players. + offline: true + + # Cancells invalid window_click packets. + window_click: true + + # Cancells invalid block_place packets. + block_place: true + + # Cancells invalid block_dig packets. + block_dig: true + + # Cancells invalid set_creative_slot packets. + set_creative_slot: true + + # Amount of violations required to cancel. + cancel_vls: 200 + + # Amount of violations to reduce per second. + reduce_vls: 600 + + # When a valid packet is sent the following amount of violations will be applied. + multipliers: + ABILITIES: 1 + ARM_ANIMATION: 4 + BLOCK_DIG: 4 + BLOCK_PLACE: 4 + BLOCK_PLACE_BOOKS: 50 + ENTITY_ACTION: 6.5 + POSITION: 0.8 + SET_CREATIVE_SLOT: 1 + TAB_COMPLETE: 8 + UPDATE_SIGN: 95 + USE_ENTITY: 6.5 + USE_ITEM: 6.5 + WINDOW_CLICK: 6.5 + + # Placeholders: %player% + thresholds: + 750: + - "notification" + 2500: + - "kick" + - "notification" # Checks if players try to crash/exploit the server with commands. commands: # Do you want to enable this module? enabled: true + # Amount of violations required to cancel. + cancel_vls: 1 + + # Amount of violations to reduce per second. + reduce_vls: 1 + # Commands to detect. commands: - "//calc" @@ -71,114 +127,60 @@ commands: - "/demote" - "/execute" - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true - - # How many times should a player be detected to be punished - threshold: 1 - - # Kick the player on detection? - kick: true - - # Placeholders: %player% - commands: [] - -############################## -# Bukkit only # -############################## + # Placeholders: %player% + thresholds: + 2: + - "kick" + - "notification" # Recreates items obtained in creative to remove invalid tags, enchants, etc. itemsfix: # Do you want to enable this module? enabled: true -# Limits packets with ProtocolLib to avoid exploits. -packets: - # Do you want to enable this module? - enabled: true - - # If a packet exceds this size it will be cancelled. - max_size: 16384 - - # Max packets per second. - # The ones ending with WRONG are impossible packets. - # WRONG packets are recommended to set to 1 but it can cause issues with laggy players. - limits: - ABILITIES: 250 - ARM_ANIMATION: 80 - BLOCK_DIG: 120 - BLOCK_PLACE: 80 - BLOCK_PLACE_BOOKS: 5 - BLOCK_PLACE_WRONG: 20 - ENTITY_ACTION: 60 - KEEP_ALIVE: 5 - POSITION: 250 - SET_CREATIVE_SLOT: 200 - SET_CREATIVE_SLOT_WRONG: 1 - TAB_COMPLETE: 50 - UPDATE_SIGN: 8 - USE_ENTITY: 80 - USE_ITEM: 80 - WINDOW_CLICK: 80 - WINDOW_CLICK_WRONG: 15 - - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true - - # How many times should a player be detected to be punished - threshold: 2 - - # Kick the player on detection? - kick: true - - # Placeholders: %player% - commands: [] - # Prevents invalid book creation. books: enabled: true - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true - - # How many times should a player be detected to be punished - threshold: 1 + # Amount of violations required to cancel. + cancel_vls: 1 - # Kick the player on detection? - kick: true + # Amount of violations to reduce per second. + reduce_vls: 1 - # Placeholders: %player% - commands: [] + # Placeholders: %player% + thresholds: + 2: + - "kick" + - "notification" # Prevents invalid sign creation. signs: enabled: true - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true + # Amount of violations required to cancel. + cancel_vls: 1 - # How many times should a player be detected to be punished - threshold: 1 + # Amount of violations to reduce per second. + reduce_vls: 1 - # Kick the player on detection? - kick: true - - # Placeholders: %player% - commands: [] + # Placeholders: %player% + thresholds: + 2: + - "kick" + - "notification" # Prevents duplication with Signs/Books by cancelling characters of 3 or more bytes long. duplication: # Do you want to enable this module? enabled: true + # Amount of violations required to cancel. + cancel_vls: 1 + + # Amount of violations to reduce per second. + reduce_vls: 1 + # Maximum bytes allowed per character. # Common keyboard characters are 1 byte long. # Characters with tildes are 2 bytes long. @@ -186,16 +188,8 @@ duplication: # Emojis are 4 bytes long. max_bytes: 2 - # Punishes players that get detected by the check. - punishment: - # Do you want to punish player when they get detected? - enabled: true - - # How many times should a player be detected to be punished - threshold: 1 - - # Kick the player on detection? - kick: true - - # Placeholders: %player% - commands: [] \ No newline at end of file + # Placeholders: %player% + thresholds: + 2: + - "kick" + - "notification" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index faf07cf..6a0677a 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.8.5 +version: 0.9.1 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 3b811b3..456ea39 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit; +import org.bukkit.Server; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -8,6 +9,7 @@ import twolovers.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; import twolovers.exploitfixer.bukkit.managers.BukkitModuleManager; import twolovers.exploitfixer.bukkit.utils.ConfigurationUtil; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -16,6 +18,7 @@ public class ExploitFixer extends JavaPlugin { private ModuleManager moduleManager; public void onEnable() { + final Server server = this.getServer(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); @@ -27,17 +30,19 @@ public void onEnable() { exploitFixer = this; this.moduleManager = new BukkitModuleManager(this, configYml, messagesYml); + VersionUtil.init(); + reload(); - getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> { + server.getScheduler().scheduleSyncRepeatingTask(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - if (!exploitPlayerManager.getExploitPlayers().isEmpty()) - exploitPlayerManager.reload(); + exploitPlayerManager.clear(); }, 9000L, 9000L); } public void reload() { + final PluginManager pluginManager = getServer().getPluginManager(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); @@ -49,12 +54,10 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); - final PluginManager pluginManager = getServer().getPluginManager(); - if (pluginManager.isPluginEnabled("ProtocolLib")) new AdapterInitializer(this, moduleManager); else - System.out.println("[ExploitFixer] ProtocolLib not found, enable it for better protection!"); + System.out.println("[ExploitFixer] Please install ProtocolLib or your server will remain unprotected from exploits!"); new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java index b899a8f..c32bb58 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class AbilitiesPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public AbilitiesPacketAdapter(final Plugin plugin, final ModuleManager moduleMan @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.ABILITIES); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "ABILITIES"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java index 69f9ff8..209c114 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class ArmAnimationPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public ArmAnimationPacketAdapter(final Plugin plugin, final ModuleManager module @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.ARM_ANIMATION); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "ARM_ANIMATION"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 8f8e10d..aec70a7 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -3,10 +3,13 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class BlockDigPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +21,28 @@ public BlockDigPacketAdapter(final Plugin plugin, final ModuleManager moduleMana @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.BLOCK_DIG); + if (!event.isCancelled() && packetsModule.isEnabled()) { + final Player player = event.getPlayer(); + + if (player != null) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); + + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.read(0); + + if (itemUse != null) { + final ItemStack itemOnHand = player.getItemInHand(); + + if (packetsModule.isBlockDig() && itemOnHand != null && itemUse.getType() != itemOnHand.getType()) + event.setCancelled(true); + else + packetsModule.checkPacket(event, "BLOCK_DIG"); + } else + packetsModule.checkPacket(event, "BLOCK_DIG"); + } else + packetsModule.checkPacket(event, "BLOCK_DIG"); + } else if (packetsModule.isOffline()) + event.setCancelled(true); + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 1407f04..a7d19ac 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -10,7 +10,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class BlockPlacePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -22,26 +21,28 @@ public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleMa @Override public void onPacketReceiving(final PacketEvent event) { - final Player player = event.getPlayer(); - - if (player != null) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); - - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.read(0); - - if (itemUse != null) { - final ItemStack itemOnHand = player.getItemInHand(); - - if (itemUse.getType() == Material.WRITTEN_BOOK || itemUse.getType() == Material.BOOK_AND_QUILL) - packetsModule.checkPacket(event, Identity.BLOCK_PLACE_BOOKS); - else if (itemOnHand != null && itemUse.getType() != itemOnHand.getType()) - packetsModule.checkPacket(event, Identity.BLOCK_PLACE_WRONG); - else - packetsModule.checkPacket(event, Identity.BLOCK_PLACE); - } - - } + if (!event.isCancelled() && packetsModule.isEnabled()) { + final Player player = event.getPlayer(); + + if (player != null) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); + + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.read(0); + + if (itemUse != null) { + final ItemStack itemOnHand = player.getItemInHand(); + + if (packetsModule.isBlockPlace() && itemOnHand != null && itemUse.getType() != itemOnHand.getType()) + event.setCancelled(true); + else + packetsModule.checkPacket(event, "BLOCK_PLACE"); + } else + packetsModule.checkPacket(event, "BLOCK_PLACE"); + } else + packetsModule.checkPacket(event, "BLOCK_PLACE"); + } else if (packetsModule.isOffline()) + event.setCancelled(true); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java index 595c40f..e65b327 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java @@ -2,92 +2,23 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; -import io.netty.buffer.ByteBuf; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.shared.enums.Identity; - -import java.util.List; public class CustomPayloadPacketAdapter extends PacketAdapter { private final CustomPayloadModule customPayloadModule; - private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; - private final boolean isOneDotSeven; public CustomPayloadPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.CUSTOM_PAYLOAD); this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.messagesModule = moduleManager.getMessagesModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.isOneDotSeven = plugin.getServer().getVersion().contains("1.7"); } @Override public void onPacketReceiving(final PacketEvent event) { if (!event.isCancelled() && customPayloadModule.isEnabled()) { - final PacketContainer packetContainer = event.getPacket(); - String tag = ""; - final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); - - if (exploitPlayer != null) { - int size = 0; - final List values = packetContainer.getModifier().getValues(); - - if (values.size() > 1) { - tag = String.valueOf(values.get(0)); - - final Object object = values.get(1); - - if (!isOneDotSeven && object instanceof ByteBuf) - size = ((ByteBuf) object).capacity(); - } - - if (tag == null) - event.setCancelled(true); - else if (size > 16384) { - exploitPlayer.punish(plugin, customPayloadModule, player); - event.setCancelled(true); - } else if (tag.equals("MC|BSign") || tag.equals("MC|BEdit") || tag.equals("MC|BOpen")) { - exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD); - - final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD); - - if (violations == customPayloadModule.getLimit()) { - exploitPlayer.punish(plugin, customPayloadModule, player); - event.setCancelled(true); - } else if (violations > customPayloadModule.getLimit()) - event.setCancelled(true); - } else if (tag.equals("REGISTER")) { - exploitPlayer.addChannels(size); - - final int channels = exploitPlayer.getChannels(); - - if (channels == 256) { - exploitPlayer.punish(plugin, customPayloadModule, player); - event.setCancelled(true); - } else if (channels > 256) - event.setCancelled(true); - } else { - exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD_OTHER); - - final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD_OTHER); - - if (violations == customPayloadModule.getOtherLimit()) { - exploitPlayer.punish(plugin, customPayloadModule, player); - event.setCancelled(true); - } else if (violations > customPayloadModule.getOtherLimit()) - event.setCancelled(true); - } - } + customPayloadModule.checkPacket(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java index 095851d..0573ef3 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class EntityActionPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public EntityActionPacketAdapter(final Plugin plugin, final ModuleManager module @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.ENTITY_ACTION); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "ENTITY_ACTION"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java deleted file mode 100644 index c3ac0cb..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/KeepAlivePacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; - -public class KeepAlivePacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public KeepAlivePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.KEEP_ALIVE); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.KEEP_ALIVE); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java index ae6ebeb..43c7018 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class PositionPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public PositionPacketAdapter(final Plugin plugin, final ModuleManager moduleMana @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.POSITION); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "POSITION"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 06affd0..07ef5b0 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -8,7 +8,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class SetCreativeSlotPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -20,13 +19,15 @@ public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager mod @Override public void onPacketReceiving(final PacketEvent event) { - final Player player = event.getPlayer(); + if (!event.isCancelled() && packetsModule.isEnabled()) { + final Player player = event.getPlayer(); - if (player == null) - packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT_WRONG); - else if (player.getGameMode() != GameMode.CREATIVE) - packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT_WRONG); - else - packetsModule.checkPacket(event, Identity.SET_CREATIVE_SLOT); + if (packetsModule.isOffline() && player == null) + event.setCancelled(true); + if (packetsModule.isSetCreativeSlot() && player != null && player.getGameMode() != GameMode.CREATIVE) + event.setCancelled(true); + else + packetsModule.checkPacket(event, "SET_CREATIVE_SLOT"); + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java index 4cd3ca7..4dbd59a 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class TabCompletePacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public TabCompletePacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.TAB_COMPLETE); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "TAB_COMPLETE"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java index 15b2569..81eda3d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class UpdateSignPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public UpdateSignPacketAdapter(final Plugin plugin, final ModuleManager moduleMa @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.UPDATE_SIGN); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "UPDATE_SIGN"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java index e187907..5dbfb42 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class UseEntityPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public UseEntityPacketAdapter(final Plugin plugin, final ModuleManager moduleMan @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.USE_ENTITY); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "USE_ENTITY"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java index 2e81495..d238e69 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class UseItemPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -18,6 +17,7 @@ public UseItemPacketAdapter(final Plugin plugin, final ModuleManager moduleManag @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event, Identity.USE_ITEM); + if (!event.isCancelled() && packetsModule.isEnabled()) + packetsModule.checkPacket(event, "USE_ITEM"); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 49dad6c..a67dff8 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -14,7 +14,6 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; @@ -26,49 +25,57 @@ public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleM @Override public void onPacketReceiving(final PacketEvent event) { - final Player player = event.getPlayer(); + if (!event.isCancelled() && packetsModule.isEnabled()) { + final Player player = event.getPlayer(); - if (player == null) - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else { - final PacketContainer packet = event.getPacket(); - final StructureModifier integers = packet.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); + if (player != null) { + final PacketContainer packet = event.getPacket(); + final StructureModifier integers = packet.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); - if (inventoryView == null) - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else if (integers.size() > 1) { - final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - int maxSlots = inventoryView.countSlots(); - int slot = integers.read(1); + if (packetsModule.isWindowClick() && inventoryView == null) + event.setCancelled(true); + else if (integers.size() > 1) { + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); + int maxSlots = inventoryView.countSlots(); + int slot = integers.read(1); - if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) - maxSlots += 4; + if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) + maxSlots += 4; - if (slot >= maxSlots) - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - else { - final StructureModifier structureModifier = packet.getItemModifier(); + if (packetsModule.isWindowClick() && slot >= maxSlots) + event.setCancelled(true); + else { + final StructureModifier structureModifier = packet.getItemModifier(); - if (structureModifier.size() > 0 && slot > 0) { - final ItemStack itemStack = inventoryView.getItem(slot); - final ItemStack itemStack1 = structureModifier.read(0); + if (structureModifier.size() > 0 && slot > 0) { + if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) + maxSlots -= 4; - if (itemStack1 != null) { - final Material material = itemStack1.getType(); + if (slot >= maxSlots) + packetsModule.checkPacket(event, "WINDOW_CLICK"); + else { + final ItemStack itemStack = inventoryView.getItem(slot); + final ItemStack itemStack1 = structureModifier.read(0); - if ((material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) { - packetsModule.checkPacket(event, Identity.WINDOW_CLICK_WRONG); - } else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + if (itemStack1 != null) { + final Material material = itemStack1.getType(); + + if (packetsModule.isWindowClick() && (material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) { + packetsModule.checkPacket(event, "WINDOW_CLICK_WRONG"); + } else + packetsModule.checkPacket(event, "WINDOW_CLICK"); + } else + packetsModule.checkPacket(event, "WINDOW_CLICK"); + } } else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); - } else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); - } - } else - packetsModule.checkPacket(event, Identity.WINDOW_CLICK); + packetsModule.checkPacket(event, "WINDOW_CLICK"); + } + } else + packetsModule.checkPacket(event, "WINDOW_CLICK"); + } else if (packetsModule.isOffline()) + event.setCancelled(true); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 9f73bda..a95f274 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -17,7 +17,6 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new EntityActionPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new KeepAlivePacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new TabCompletePacketAdapter(plugin, moduleManager)); diff --git a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java index fee693b..863003a 100644 --- a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.ExploitFixer; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.MessagesModule; @@ -27,7 +28,10 @@ public boolean onCommand(final CommandSender commandSender, final Command comman String lang = "en"; if (commandSender instanceof Player) - lang = ((Player) commandSender).spigot().getLocale().substring(0, 2); + if (VersionUtil.isOneDotFifteen()) + lang = ((Player) commandSender).getLocale().substring(0, 2); + else + lang = ((Player) commandSender).spigot().getLocale().substring(0, 2); if (length < 1 || args[0].equals("help")) { commandSender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); @@ -41,7 +45,7 @@ else if (args[0].equals("stats")) if (commandSender.hasPermission("exploitfixer.admin")) commandSender.sendMessage(messagesModule.getStats(lang) .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) - .replace("%players_cached%", String.valueOf(exploitPlayerManager.getExploitPlayers().size()))); + .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize()))); else commandSender.sendMessage(messagesModule.getPermission(lang)); else if (args[0].equalsIgnoreCase("notifications")) { diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 8307104..98c9aee 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -2,20 +2,23 @@ import org.bukkit.Server; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CancellableModule; import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.Module; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.shared.enums.Identity; -import twolovers.exploitfixer.shared.instanceables.Punishment; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -23,8 +26,7 @@ public class BukkitExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private Map violations = new HashMap<>(); - final private Map thresholds = new HashMap<>(); + final private Map violations = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -45,23 +47,14 @@ public void clearChannels() { this.channels = 0; } - public void addChannels(final int channels) { - this.channels += channels; + @Override + public int addChannels(final int channels) { + return this.channels += channels; } - public int getViolations(final Identity identifier) { - return violations.getOrDefault(identifier, 0); - } - - public void addViolation(final Identity identifier) { - final double currentTime = System.currentTimeMillis(); - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - violations.clear(); - } - - this.violations.put(identifier, violations.getOrDefault(identifier, 0) + 1); + @Override + public double getViolations(final Module module) { + return violations.getOrDefault(module, 0D); } public String getOnlineUUID() { @@ -89,39 +82,63 @@ public String getOnlineUUID() { return onlineUUID; } - public void punish(final Object plugin, final Module module, final Object player) { - final Punishment punishment = module.getPunishment(); + @Override + public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { + if (playerObject instanceof Player) { + final Thresholds thresholds = module.getThresholds(); - if (punishment != null && punishment.isEnabled() && player != null) { - thresholds.put(module, thresholds.getOrDefault(module, 0) + 1); + if (thresholds != null) { + final Player player = (Player) playerObject; - final int threshold = thresholds.getOrDefault(module, 1); + if (player.isOnline()) { + final Plugin plugin = (Plugin) pluginObject; + final Server server = plugin.getServer(); + final double currentTime = System.currentTimeMillis(); + final String locale; - if (threshold >= punishment.getThreshold()) { - final Player player1 = (Player) player; - final String lang = player1.spigot().getLocale().substring(0, 2); + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); - if (player1.isOnline()) { - final Plugin plugin1 = (Plugin) plugin; - final Server server = plugin1.getServer(); + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; - exploitPlayerManager.addPunishment(); + for (final CancellableModule violationModule : violations.keySet().toArray(new CancellableModule[0])) { + final double vls = violations.get(violationModule) - violationModule.getReduceVls(); - for (final String punishCommand : punishment.getCommands()) - if (!punishCommand.equals("")) - server.getScheduler().runTask(plugin1, () -> - server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player1.getName())) - ); + if (vls <= 0) + violations.remove(violationModule); + else + violations.put(violationModule, vls); + } + } - notificationsModule.sendNotification(module.getName(), player); + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; - if (punishment.isKick()) { - final String kickMessage = messagesModule.getKickMessage(module, lang); + final String kickMessage = messagesModule.getKickMessage(module, locale); - server.getScheduler().runTask(plugin1, () -> - player1.kickPlayer(kickMessage) - ); - } + violations.put(module, newVls); + + for (final int threshold : thresholds.getThresholds()) + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = thresholds.getCommands(threshold); + + if (commands != null && !commands.isEmpty()) + for (final String punishCommand : commands) + if (!punishCommand.isEmpty()) + if (punishCommand.equals("kick")) { + server.getScheduler().runTask(plugin, ()->player.kickPlayer(kickMessage)); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) + notificationsModule.sendNotification(module.getName(), player); + else + server.getScheduler().runTask(plugin, ()->server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + } + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java new file mode 100644 index 0000000..10acf29 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java @@ -0,0 +1,34 @@ +package twolovers.exploitfixer.bukkit.instanceables; + +import org.bukkit.configuration.ConfigurationSection; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class BukkitThresholds implements Thresholds { + private Map> thresholds = null; + + public BukkitThresholds(final ConfigurationSection configuration) { + if (configuration != null) + for (final String key : configuration.getKeys(false)) { + try { + if (this.thresholds == null) + this.thresholds = new HashMap<>(); + + this.thresholds.put(Integer.parseInt(key), configuration.getStringList(key)); + } catch (NumberFormatException ignored) { + } + } + } + + public Collection getCommands(final int violations) { + return thresholds.getOrDefault(violations, null); + } + + @Override + public Collection getThresholds() { + return thresholds.keySet(); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 798db3c..0ec8aa4 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -30,8 +30,7 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (message.startsWith(command + " ") || message.endsWith(command)) { final Player player = event.getPlayer(); - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, commandsModule, player); - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, commandsModule, player, commandsModule, 1); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java index b0ead63..237a07f 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java @@ -30,26 +30,24 @@ public PlayerEditBookListener(final Plugin plugin, final ModuleManager moduleMan @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerEditBook(final PlayerEditBookEvent event) { final BookMeta bookMeta = event.getNewBookMeta(); + final Player player = event.getPlayer(); if (booksModule.isEnabled()) if (bookMeta == null) { - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); event.setNewBookMeta(event.getPreviousBookMeta()); } else if (bookMeta.getEnchants().size() != 0) { - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); event.setNewBookMeta(event.getPreviousBookMeta()); } else if (bookMeta.getPageCount() > 50) { - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); event.setNewBookMeta(event.getPreviousBookMeta()); } else for (String page : bookMeta.getPages()) { if (duplicationModule.isEnabled()) { for (final String word : page.split("")) { if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { - final Player player = event.getPlayer(); - - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); event.setNewBookMeta(event.getPreviousBookMeta()); return; } @@ -58,10 +56,7 @@ public void onPlayerEditBook(final PlayerEditBookEvent event) { if (booksModule.isEnabled()) { if (page.length() > 340) { - final Player player = event.getPlayer(); - - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, booksModule, 1); event.setNewBookMeta(event.getPreviousBookMeta()); return; } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 8b6112c..aa7dda9 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -6,6 +6,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -33,24 +34,30 @@ public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManage @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); - final String lang = player.spigot().getLocale().substring(0, 2); - exploitPlayerManager.addPlayer(player.getName()); + exploitPlayerManager.add(player.getName()); if (uuidSpoofModule.isEnabled()) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { final String playerName = player.getName(); final String originalUUID = player.getUniqueId().toString().replace("-", ""); final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getName()); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID != null && !onlineUUID.contains(originalUUID)) { - event.setKickMessage(messagesModule.getKickMessage(uuidSpoofModule, lang)); + event.setKickMessage(messagesModule.getKickMessage(uuidSpoofModule, locale)); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - exploitPlayer.punish(plugin, uuidSpoofModule, player); + exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); } } }); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java index cb30009..7cc6584 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -21,7 +21,7 @@ public PlayerQuitListener(final ModuleManager variables) { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(player.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getName()); if (exploitPlayer != null) { exploitPlayer.clearChannels(); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 4717999..d3a3c13 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -34,8 +34,7 @@ public void onSignChange(final SignChangeEvent event) { if (duplicationModule.isEnabled()) { for (String word : line.split("")) { if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, duplicationModule, player); - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); return; } } @@ -43,8 +42,7 @@ public void onSignChange(final SignChangeEvent event) { if (signsModule.isEnabled()) { if (line.length() >= 46) { - exploitPlayerManager.getPlayer(player.getName()).punish(plugin, signsModule, player); - event.setCancelled(true); + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, signsModule, 1); return; } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 1963291..d496431 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -7,7 +7,9 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; @@ -17,60 +19,54 @@ public class BukkitExploitPlayerManager implements ExploitPlayerManager { BukkitExploitPlayerManager(final ModuleManager moduleManager) { this.moduleManager = moduleManager; - for (final Player player : Bukkit.getOnlinePlayers()) - addPlayer(player.getName()); + reload(); } @Override - public ExploitPlayer getPlayer(final String playerName) { + public ExploitPlayer get(final String playerName) { return exploitPlayers.getOrDefault(playerName, null); } @Override - public void addPlayer(final String playerName) { - if (getPlayer(playerName) == null) + public void add(final String playerName) { + if (!exploitPlayers.containsKey(playerName)) exploitPlayers.put(playerName, new BukkitExploitPlayer(playerName, moduleManager)); } @Override - public void reload() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean hasRemoved = false; - - while (iterator.hasNext()) { - final String playerName = iterator.next(); - final Player player = Bukkit.getPlayer(playerName); + public void clear() { + boolean cleared = false; - if (player == null || !player.isOnline()) { - iterator.remove(); - - if (!hasRemoved) { - System.out.println("[ExploitFixer] Cleared unused cached players!"); - hasRemoved = true; - } + for (final String name : exploitPlayers.keySet().toArray(new String[0])) + if (Bukkit.getPlayerExact(name) == null) { + exploitPlayers.remove(name); + cleared = true; } - } - punishments = 0; + if (cleared) + Bukkit.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); } @Override - public Collection getExploitPlayers() { - return exploitPlayers.values(); + public void reload() { + exploitPlayers.clear(); + + for (final Player player : Bukkit.getOnlinePlayers()) + add(player.getName()); } @Override - public int getPunishments() { - return punishments; + public int getSize() { + return exploitPlayers.size(); } @Override - public void addPunishment() { - punishments++; + public int getPunishments() { + return punishments; } @Override - public void removePlayer(final String name) { - exploitPlayers.remove(name); + public int addPunishment() { + return ++punishments; } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index bd8ecca..38bd561 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -21,7 +21,7 @@ public class BukkitModuleManager implements ModuleManager { public BukkitModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { commandsModule = new BukkitCommandsModule(configYml); - customPayloadModule = new BukkitCustomPayloadModule(configYml); + customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); itemsFixModule = new BukkitItemsFixModule(configYml); messagesModule = new BukkitMessagesModule(messagesYml); notificationsModule = new BukkitNotificationsModule(configYml); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java index acf83fb..75bd167 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java @@ -1,12 +1,14 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.BooksModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitBooksModule implements BooksModule { + private Thresholds thresholds; + private int cancelVls, reduceVls; private boolean enabled; - private Punishment punishment; public BukkitBooksModule(final Object configYml) { reload(configYml); @@ -23,15 +25,28 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean("books.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("books.punishment.enabled"), configYml1.getBoolean("books.punishment.kick"), configYml1.getInt("books.punishment.threshold"), configYml1.getStringList("books.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java index e39c502..0ac5182 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java @@ -1,49 +1,61 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.CommandsModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.Collection; public class BukkitCommandsModule implements CommandsModule { private Collection commands; + private Thresholds thresholds; + private int cancelVls, reduceVls; private boolean enabled; - private boolean kick; - private Punishment punishment; public BukkitCommandsModule(final Object configYml) { reload(configYml); } + @Override final public Boolean isEnabled() { return enabled; } - final public Boolean isKick() { - return kick; - } - @Override public String getName() { return "Commands"; } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; } + @Override + public Thresholds getThresholds() { + return thresholds; + } + + @Override final public Collection getCommands() { return commands; } + @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - this.punishment = new Punishment(configYml1.getBoolean("commands.punishment.enabled"), configYml1.getBoolean("commands.punishment.kick"), configYml1.getInt("commands.punishment.threshold"), configYml1.getStringList("commands.punishment.commands")); - this.enabled = configYml1.getBoolean("commands.enabled"); - this.kick = configYml1.getBoolean("commands.kick"); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); this.commands = configYml1.getStringList("commands.commands"); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index 3364030..f57c337 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -1,20 +1,52 @@ package twolovers.exploitfixer.bukkit.modules; -import org.bukkit.configuration.file.YamlConfiguration; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.google.common.base.Charsets; +import io.netty.buffer.ByteBuf; +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; + +import java.util.HashMap; +import java.util.Map; public class BukkitCustomPayloadModule implements CustomPayloadModule { + private Map multipliers = new HashMap<>(); + private Plugin plugin; + private ModuleManager moduleManager; + private Thresholds thresholds; + private int maxChannels; + private int cancelVls, reduceVls; private boolean enabled; - private int limit, otherLimit; - private Punishment punishment; - public BukkitCustomPayloadModule(final Object configYml) { + public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { + this.plugin = plugin; + this.moduleManager = moduleManager; + reload(configYml); } - final public Boolean isEnabled() { - return enabled; + @Override + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override @@ -23,24 +55,52 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + final public boolean isEnabled() { + return enabled; } - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + @Override + public void reload(final Object configYml) { + final Configuration configYml1 = (Configuration) configYml; + final ConfigurationSection configurationSection = configYml1.getConfigurationSection("custompayload.multipliers"); + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("custompayload.enabled"); - limit = configYml1.getInt("custompayload.limit.normal"); - otherLimit = configYml1.getInt("custompayload.limit.other"); - this.punishment = new Punishment(configYml1.getBoolean("custompayload.punishment.enabled"), configYml1.getBoolean("custompayload.punishment.kick"), configYml1.getInt("custompayload.punishment.threshold"), configYml1.getStringList("custompayload.punishment.commands")); - } + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + this.maxChannels = configYml1.getInt("custompayload.max_channels"); - public int getLimit() { - return limit; + for (final String key : configurationSection.getKeys(false)) + multipliers.put(key, configurationSection.getDouble(key)); } - public int getOtherLimit() { - return otherLimit; + @Override + public void checkPacket(final Object event) { + if (event instanceof PacketEvent) { + final PacketEvent packetEvent = (PacketEvent) event; + final Player sender = packetEvent.getPlayer(); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(sender.getName()); + + if (exploitPlayer != null && sender.isOnline()) { + final PacketContainer packet = packetEvent.getPacket(); + final String tag = String.valueOf(packet.getModifier().readSafely(0)); + + if (tag != null && tag.toLowerCase().endsWith("register")) { + final ByteBuf buffer = packet.getSpecificModifier(ByteBuf.class).readSafely(0); + final int channels; + + if (VersionUtil.isOneDotSeven()) + channels = 1; + else + channels = buffer.toString(Charsets.UTF_8).split("\000").length; + + if (exploitPlayer.addChannels(channels) > maxChannels) + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", multipliers.getOrDefault("OTHER", 1D))); + } else + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } /*else if (moduleManager.getPacketsModule().isOffline()) + packetEvent.setCancelled(true);*/ // Disabled because of false positives + } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java index 7e85fcc..d3b1e6d 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java @@ -1,13 +1,15 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.DuplicationModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitDuplicationModule implements DuplicationModule { private boolean enabled; private int maxBytes; - private Punishment punishment; + private int cancelVls, reduceVls; + private Thresholds thresholds; public BukkitDuplicationModule(final Object configYml) { reload(configYml); @@ -15,10 +17,13 @@ public BukkitDuplicationModule(final Object configYml) { final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean("duplication.enabled"); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); this.maxBytes = configYml1.getInt("duplication.max_bytes"); - this.punishment = new Punishment(configYml1.getBoolean("duplication.punishment.enabled"), configYml1.getBoolean("duplication.punishment.kick"), configYml1.getInt("duplication.punishment.threshold"), configYml1.getStringList("duplication.punishment.commands")); } final public Boolean isEnabled() { @@ -35,7 +40,17 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index 5fa5ed5..915c33b 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -1,12 +1,12 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitItemsFixModule implements ItemsFixModule { private boolean enabled; - private Punishment punishment; + private Thresholds thresholds; public BukkitItemsFixModule(final Object configYml) { reload(configYml); @@ -14,9 +14,9 @@ public BukkitItemsFixModule(final Object configYml) { final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("itemsfix.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("itemsfix.punishment.enabled"), configYml1.getBoolean("itemsfix.punishment.kick"), configYml1.getInt("itemsfix.punishment.threshold"), configYml1.getStringList("itemsfix.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); } @Override @@ -28,9 +28,4 @@ final public Boolean isEnabled() { public String getName() { return "ItemsFix"; } - - @Override - public Punishment getPunishment() { - return punishment; - } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index f97dd7d..9046e59 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -1,19 +1,22 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.modules.*; +import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; public class BukkitMessagesModule implements MessagesModule { - private Object messagesYml; public BukkitMessagesModule(final Object messagesYml) { reload(messagesYml); } - public String getString(final String locale, final String path) { + public String getString(String locale, final String path) { String string; + if (locale == null) + locale = "en"; + string = ((YamlConfiguration) messagesYml).getString(locale + path); if (string == null || string.isEmpty()) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index f323b2f..f80dc17 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -1,121 +1,117 @@ package twolovers.exploitfixer.bukkit.modules; import com.comphenix.protocol.events.PacketEvent; -import io.netty.buffer.ByteBuf; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import twolovers.exploitfixer.shared.enums.Identity; -import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.HashMap; -import java.util.List; import java.util.Map; public class BukkitPacketsModule implements PacketsModule { private final Plugin plugin; private final ModuleManager moduleManager; - private final Map limits = new HashMap<>(); - private Punishment punishment; - private boolean enabled; - private int maxSize; - private final boolean isOneDotSeven; + private final Map multipliers = new HashMap<>(); + private Thresholds thresholds; + private boolean enabled, windowClick, offline, setCreativeSlot, blockPlace, blockDig; + private int cancelVls, reduceVls; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; this.moduleManager = moduleManager; reload(configYml); - this.isOneDotSeven = plugin.getServer().getVersion().contains("1.7"); } final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.limits"); + final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.multipliers"); + final String name = getName().toLowerCase(); + + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.offline = configYml1.getBoolean(name + ".offline"); + this.windowClick = configYml1.getBoolean(name + ".window_click"); + this.blockPlace = configYml1.getBoolean(name + ".block_place"); + this.blockDig = configYml1.getBoolean(name + ".block_dig"); + this.setCreativeSlot = configYml1.getBoolean(name + ".set_creative_slot"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + + for (final String key : configurationSection.getKeys(false)) + multipliers.put(key, configurationSection.getDouble(key)); + } - this.punishment = new Punishment(configYml1.getBoolean("packets.punishment.enabled"), configYml1.getBoolean("packets.punishment.kick"), configYml1.getInt("packets.punishment.threshold"), configYml1.getStringList("packets.punishment.commands")); - this.enabled = configYml1.getBoolean("packets.enabled"); - this.maxSize = configYml1.getInt("packets.max_size"); + @Override + public double getMultiplier(final String packetName) { + return multipliers.getOrDefault(packetName, 1D); + } - for (final String packetIdentityName : configurationSection.getKeys(false)) { - for (final Identity identity : Identity.values()) { - if (identity.name().equalsIgnoreCase(packetIdentityName)) { - final Object value = configurationSection.get(packetIdentityName); + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void checkPacket(final Object packetEvent, String packetName) { + final PacketEvent event = (PacketEvent) packetEvent; + final Player player = event.getPlayer(); - if (value instanceof Integer) - addLimit(identity, (Integer) value); + if (player != null && player.isOnline()) { + final String playerName = player.getName(); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); - break; - } - } - } + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + } else if (isOffline()) + event.setCancelled(true); } - public void addLimit(final Identity packet, final int value) { - this.limits.put(packet, value); + @Override + public boolean isWindowClick() { + return windowClick; } - public int getLimit(final Identity packet) { - return limits.getOrDefault(packet, 10000); + @Override + public boolean isOffline() { + return offline; } - public boolean isEnabled() { - return enabled; + @Override + public boolean isSetCreativeSlot() { + return setCreativeSlot; + } + + @Override + public boolean isBlockPlace() { + return blockPlace; } - public void checkPacket(Object packetEvent, Identity identity) { - if (enabled && packetEvent instanceof PacketEvent) { - final PacketEvent event = (PacketEvent) packetEvent; - - if (!event.isCancelled()) { - final Player player = event.getPlayer(); - int size = 1; - final List values = event.getPacket().getModifier().getValues(); - - if (values.size() > 1) { - final Object object = values.get(1); - - if (!isOneDotSeven && object instanceof ByteBuf) - size = ((ByteBuf) object).capacity(); - } - - if (player != null) { - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().getPlayer(playerName); - - if (exploitPlayer != null) { - final int limit = getLimit(identity); - - if (size > maxSize) { - exploitPlayer.punish(plugin, this, player); - moduleManager.getNotificationsModule().sendNotification("PACKET_SIZE", player); - event.setCancelled(true); - } else if (limit > 0) { - exploitPlayer.addViolation(identity); - - final int violations = exploitPlayer.getViolations(identity); - - if (violations == limit) { - exploitPlayer.punish(plugin, this, player); - moduleManager.getNotificationsModule().sendNotification(identity.name(), player); - event.setCancelled(true); - } else if (violations > limit) - event.setCancelled(true); - } - } - } - } - } + @Override + public boolean isBlockDig() { + return blockDig; } + @Override public String getName() { return "Packets"; } - public Punishment getPunishment() { - return punishment; + @Override + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + public Thresholds getThresholds() { + return thresholds; } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java index b9f622d..c86c926 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java @@ -1,12 +1,14 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.SignsModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitSignsModule implements SignsModule { private boolean enabled; - private Punishment punishment; + private int cancelVls, reduceVls; + private Thresholds thresholds; public BukkitSignsModule(final Object configYml) { reload(configYml); @@ -23,15 +25,28 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean("signs.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("signs.punishment.enabled"), configYml1.getBoolean("signs.punishment.kick"), configYml1.getInt("signs.punishment.threshold"), configYml1.getStringList("signs.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java index f568d99..b066d11 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java @@ -1,12 +1,14 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BukkitUUIDSpoofModule implements UUIDSpoofModule { private boolean enabled; - private Punishment punishment; + private int cancelVls, reduceVls; + private Thresholds thresholds; public BukkitUUIDSpoofModule(final Object configYml) { reload(configYml); @@ -23,15 +25,28 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("uuidspoof.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("uuidspoof.punishment.enabled"), configYml1.getBoolean("uuidspoof.punishment.kick"), configYml1.getInt("uuidspoof.punishment.threshold"), configYml1.getStringList("uuidspoof.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java index fe2ca1a..d52059c 100644 --- a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -41,11 +41,11 @@ public void createConfiguration(String file) { if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - System.out.print(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); } else configFile.createNewFile(); } } catch (final IOException e) { - System.out.print(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } } @@ -56,7 +56,7 @@ public void saveConfiguration(final YamlConfiguration yamlConfiguration, final S yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); } catch (final IOException e) { - System.out.print(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } }); } diff --git a/src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java b/src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java new file mode 100644 index 0000000..a3566c5 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java @@ -0,0 +1,20 @@ +package twolovers.exploitfixer.bukkit.utils; + +import org.bukkit.Bukkit; + +public class VersionUtil { + private static boolean oneDotFifteen, oneDotSeven; + + public static void init() { + oneDotFifteen = Bukkit.getServer().getVersion().contains("1.15"); + oneDotSeven = Bukkit.getServer().getVersion().contains("1.7"); + } + + public static boolean isOneDotFifteen() { + return oneDotFifteen; + } + + public static boolean isOneDotSeven() { + return oneDotSeven; + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/twolovers/exploitfixer/bungee/ExploitFixer.java index 6ba5dcb..500bd48 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bungee/ExploitFixer.java @@ -20,6 +20,8 @@ public class ExploitFixer extends Plugin { private ModuleManager moduleManager; public void onEnable() { + plugin = this; + final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); @@ -28,16 +30,14 @@ public void onEnable() { final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); - plugin = this; - this.moduleManager = new BungeeModuleManager(configYml, messagesYml); + this.moduleManager = new BungeeModuleManager(this, configYml, messagesYml); reload(); getProxy().getScheduler().schedule(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - if (!exploitPlayerManager.getExploitPlayers().isEmpty()) - exploitPlayerManager.reload(); + exploitPlayerManager.clear(); }, 5, 5, TimeUnit.MINUTES); } @@ -50,17 +50,17 @@ public void reload() { final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); moduleManager.reload(configYml, messagesYml, null); - final PluginManager pluginManager = plugin.getProxy().getPluginManager(); + final PluginManager pluginManager = getProxy().getPluginManager(); - pluginManager.unregisterListeners(plugin); - pluginManager.registerListener(plugin, new ChatListener(plugin, moduleManager)); - pluginManager.registerListener(plugin, new DisconnectListener(moduleManager)); - pluginManager.registerListener(plugin, new PluginMessageListener(plugin, moduleManager)); - pluginManager.registerListener(plugin, new PostLoginListener(plugin, moduleManager)); + pluginManager.unregisterListeners(this); + pluginManager.registerListener(this, new ChatListener(this, moduleManager)); + pluginManager.registerListener(this, new DisconnectListener(moduleManager)); + pluginManager.registerListener(this, new PluginMessageListener(moduleManager)); + pluginManager.registerListener(this, new PostLoginListener(this, moduleManager)); - pluginManager.unregisterCommands(plugin); - pluginManager.registerCommand(plugin, new ExploitFixerCommand("exploitfixer", moduleManager)); - pluginManager.registerCommand(plugin, new ExploitFixerCommand("ef", moduleManager)); + pluginManager.unregisterCommands(this); + pluginManager.registerCommand(this, new ExploitFixerCommand("exploitfixer", moduleManager)); + pluginManager.registerCommand(this, new ExploitFixerCommand("ef", moduleManager)); } public static ExploitFixer getInstance() { diff --git a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java index bd7d7b7..0a78027 100644 --- a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -41,7 +41,7 @@ else if (args[0].equals("stats")) if (commandSender.hasPermission("exploitfixer.admin")) commandSender.sendMessage(new TextComponent(messagesModule.getStats(lang) .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) - .replace("%players_cached%", String.valueOf(exploitPlayerManager.getExploitPlayers().size())))); + .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize())))); else commandSender.sendMessage(new TextComponent(messagesModule.getPermission(lang))); else if (args[0].equalsIgnoreCase("notifications")) { diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index 9cf7f39..b0f89a2 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -1,31 +1,32 @@ package twolovers.exploitfixer.bungee.instanceables; import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; import net.md_5.bungee.api.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CancellableModule; import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.Module; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.shared.enums.Identity; -import twolovers.exploitfixer.shared.instanceables.Punishment; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; +import java.util.Collection; import java.util.HashMap; +import java.util.Locale; import java.util.Map; public class BungeeExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; final private NotificationsModule notificationsModule; - final private Map violations = new HashMap<>(); - final private Map thresholds = new HashMap<>(); + final private Map violations = new HashMap<>(); final private String name; private String onlineUUID = null; private int channels = 0; @@ -38,33 +39,27 @@ public BungeeExploitPlayer(final String name, final ModuleManager moduleManager) this.name = name; } + @Override public int getChannels() { return channels; } + @Override public void clearChannels() { this.channels = 0; } - public void addChannels(final int channels) { - this.channels += channels; + @Override + public int addChannels(final int channels) { + return this.channels += channels; } - public int getViolations(final Identity identifier) { - return violations.getOrDefault(identifier, 0); - } - - public void addViolation(final Identity identifier) { - final double currentTime = System.currentTimeMillis(); - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - violations.clear(); - } - - this.violations.put(identifier, violations.getOrDefault(identifier, 0) + 1); + @Override + public double getViolations(final Module module) { + return violations.getOrDefault(module, 0D); } + @Override public String getOnlineUUID() { if (onlineUUID == null) { try { @@ -90,43 +85,73 @@ public String getOnlineUUID() { return onlineUUID; } - public void punish(final Object plugin1, final Module module, final Object player) { - final Punishment punishment = module.getPunishment(); + @Override + public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { + if (playerObject instanceof ProxiedPlayer) { + final Thresholds thresholds = module.getThresholds(); - if (punishment != null && punishment.isEnabled() && player != null) { - thresholds.put(module, thresholds.getOrDefault(module, 0) + 1); + if (thresholds != null) { + final ProxiedPlayer player = (ProxiedPlayer) playerObject; - final int threshold = thresholds.getOrDefault(module, 1); + if (player.isConnected()) { + final Plugin plugin = (Plugin) pluginObject; + final ProxyServer server = plugin.getProxy(); + final double currentTime = System.currentTimeMillis(); + final Locale locale = player.getLocale(); + String lang = null; - if (threshold >= punishment.getThreshold()) { - final ProxiedPlayer player1 = (ProxiedPlayer) player; - final String lang = player1.getLocale().toString().substring(0, 2); + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; - if (player1.isConnected()) { - final Plugin plugin = (Plugin) plugin1; - final ProxyServer proxyServer = plugin.getProxy(); + for (final CancellableModule violationModule : violations.keySet().toArray(new CancellableModule[0])) { + final double vls = violations.get(violationModule) - violationModule.getReduceVls(); - exploitPlayerManager.addPunishment(); + if (vls <= 0) + violations.remove(violationModule); + else + violations.put(violationModule, vls); + } + } - for (final String punishCommand : punishment.getCommands()) - if (!punishCommand.equals("")) - proxyServer.getPluginManager().dispatchCommand(proxyServer.getConsole(), punishCommand.replace("%player%", player1.getName())); + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; - notificationsModule.sendNotification(module.getName(), player); + if (locale != null) + lang = locale.toString().substring(0, 2); - if (punishment.isKick()) { - final String kickMessage = messagesModule.getKickMessage(module, lang); - player1.disconnect(new TextComponent(kickMessage)); - } + final String kickMessage = messagesModule.getKickMessage(module, lang); + + violations.put(module, newVls); + + for (final int threshold : thresholds.getThresholds()) + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = thresholds.getCommands(threshold); + + if (commands != null && !commands.isEmpty()) + for (final String punishCommand : commands) + if (!punishCommand.isEmpty()) + if (punishCommand.equals("kick")) { + player.disconnect(kickMessage); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) + notificationsModule.sendNotification(module.getName(), player); + else + server.getPluginManager().dispatchCommand(server.getConsole(), punishCommand.replace("%player%", player.getName())); + } + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); } } } } + @Override public String getName() { return name; } + @Override public void clearViolations() { violations.clear(); } diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java new file mode 100644 index 0000000..bc43155 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java @@ -0,0 +1,35 @@ +package twolovers.exploitfixer.bungee.instanceables; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class BungeeThresholds implements Thresholds { + private Map> thresholds = null; + + public BungeeThresholds(final Configuration configuration) { + if (configuration != null) + for (final String key : configuration.getKeys()) { + try { + if (this.thresholds == null) + this.thresholds = new HashMap<>(); + + this.thresholds.put(Integer.parseInt(key), configuration.getStringList(key)); + } catch (NumberFormatException ignored) { + } + } + } + + @Override + public Collection getCommands(final int violations) { + return thresholds.getOrDefault(violations, null); + } + + @Override + public Collection getThresholds() { + return thresholds.keySet(); + } +} diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index 09d8476..d6a52dd 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -33,8 +33,7 @@ public void onChat(ChatEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - exploitPlayerManager.getPlayer(proxiedPlayer.getName()).punish(plugin, commandsModule, proxiedPlayer); - event.setCancelled(true); + exploitPlayerManager.get(proxiedPlayer.getName()).addVls(plugin, event, proxiedPlayer, commandsModule, 1); } break; diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index 0f44ec9..d662cf6 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -21,7 +21,7 @@ public DisconnectListener(final ModuleManager moduleManager) { @EventHandler public void onDisconnect(final PlayerDisconnectEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(proxiedPlayer.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getName()); if (exploitPlayer != null) { exploitPlayer.clearChannels(); diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index d47fcab..8a2afca 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -1,82 +1,22 @@ package twolovers.exploitfixer.bungee.listeners; -import com.google.common.base.Charsets; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.shared.enums.Identity; public class PluginMessageListener implements Listener { - final private Plugin plugin; final private CustomPayloadModule customPayloadModule; - final private ExploitPlayerManager exploitPlayerManager; - public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; + public PluginMessageListener(final ModuleManager moduleManager) { this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = -128) public void onPluginMessage(final PluginMessageEvent event) { - final Connection connection = event.getSender(); - - if (customPayloadModule.isEnabled() && connection instanceof ProxiedPlayer) { - final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - final String proxiedPlayerName = proxiedPlayer.getName(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(proxiedPlayerName); - final String tag = event.getTag(); - final byte[] data = event.getData(); - final String dataString = new String(data, Charsets.UTF_8); - final int dataSize = dataString.split("[\u0001-\u0009]").length; - - if (exploitPlayer != null) { - if (tag == null) { - event.setCancelled(true); - } else if (dataSize > 16384) { - exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); - event.setCancelled(true); - } else if (tag.equals("MC|BSign") || tag.equals("MC|BEdit") || tag.equals("MC|BOpen")) { - exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD); - - final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD); - - if (violations == customPayloadModule.getLimit()) { - exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); - event.setCancelled(true); - } else if (violations > customPayloadModule.getLimit()) - event.setCancelled(true); - } else if (tag.equals("REGISTER")) { - exploitPlayer.addChannels(dataSize); - - final int channels = exploitPlayer.getChannels(); - - if (channels == 256) { - exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); - event.setCancelled(true); - } else if (channels > 256) { - event.setCancelled(true); - } - } else { - exploitPlayer.addViolation(Identity.CUSTOM_PAYLOAD_OTHER); - - final int violations = exploitPlayer.getViolations(Identity.CUSTOM_PAYLOAD_OTHER); - - if (violations == customPayloadModule.getOtherLimit()) { - exploitPlayer.punish(plugin, customPayloadModule, proxiedPlayer); - event.setCancelled(true); - } else if (violations > customPayloadModule.getOtherLimit()) - event.setCancelled(true); - } - } - } + if (!event.isCancelled() && customPayloadModule.isEnabled()) + customPayloadModule.checkPacket(event); } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index 6f7ed6b..efc5995 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -29,27 +29,29 @@ public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(final PostLoginEvent event) { - final ProxiedPlayer proxiedPlayer = event.getPlayer(); + final ProxiedPlayer player = event.getPlayer(); + final String playerName = player.getName(); + final UUID uuid = player.getUniqueId(); - exploitPlayerManager.addPlayer(proxiedPlayer.getName()); + exploitPlayerManager.add(playerName); if (uuidSpoofModule.isEnabled()) { plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final String originalUUID = proxiedPlayer.getUniqueId().toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + proxiedPlayer.getName()).getBytes()).toString().replace("-", ""); + final String originalUUID = uuid.toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.getPlayer(proxiedPlayer.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID != null && !onlineUUID.contains(originalUUID)) - exploitPlayer.punish(plugin, uuidSpoofModule, proxiedPlayer); + exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); } }); } - if (proxiedPlayer.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(proxiedPlayer, true); + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(player, true); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 643ebee..4a8fc42 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -1,79 +1,75 @@ package twolovers.exploitfixer.bungee.managers; import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; +import java.util.logging.Level; public class BungeeExploitPlayerManager implements ExploitPlayerManager { - final private ModuleManager moduleManager; - final private Map exploitPlayers = new HashMap<>(); + private final ModuleManager moduleManager; + private final ProxyServer proxy; + private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; - BungeeExploitPlayerManager(final ModuleManager moduleManager) { + BungeeExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { this.moduleManager = moduleManager; + this.proxy = proxy; - for (final ProxiedPlayer proxiedPlayer : BungeeCord.getInstance().getPlayers()) - addPlayer(proxiedPlayer.getName()); + reload(); } @Override - public ExploitPlayer getPlayer(final String playerName) { - return exploitPlayers.getOrDefault(playerName, null); + public ExploitPlayer get(final String name) { + return exploitPlayers.getOrDefault(name, null); } @Override - public void addPlayer(final String playerName) { - if (getPlayer(playerName) == null) - exploitPlayers.put(playerName, new BungeeExploitPlayer(playerName, moduleManager)); + public int getSize() { + return exploitPlayers.size(); } @Override - public void reload() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean hasRemoved = false; - - while (iterator.hasNext()) { - final String playerName = iterator.next(); - final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(playerName); - - if (player == null || !player.isConnected()) { - iterator.remove(); - - if (!hasRemoved) { - System.out.println("[ExploitFixer] Cleared unused cached players!"); - hasRemoved = true; - } - } - } - - punishments = 0; + public int getPunishments() { + return punishments; } @Override - public Collection getExploitPlayers() { - return exploitPlayers.values(); + public void add(final String name) { + if (!exploitPlayers.containsKey(name)) + exploitPlayers.put(name, new BungeeExploitPlayer(name, moduleManager)); } @Override - public int getPunishments() { - return punishments; + public int addPunishment() { + return ++punishments; } @Override - public void addPunishment() { - punishments++; + public void reload() { + exploitPlayers.clear(); + + for (final ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) + add(player.getName()); } @Override - public void removePlayer(final String name) { - exploitPlayers.remove(name); + public void clear() { + boolean cleared = false; + + for (final String name : exploitPlayers.keySet().toArray(new String[0])) + if (proxy.getPlayer(name) == null) { + exploitPlayers.remove(name); + cleared = true; + } + + if (cleared) + proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); } } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 18f550b..b9b750c 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bungee.managers; +import net.md_5.bungee.api.plugin.Plugin; import twolovers.exploitfixer.bungee.modules.*; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -13,15 +14,16 @@ public class BungeeModuleManager implements ModuleManager { private UUIDSpoofModule uuidSpoofModule; private ExploitPlayerManager exploitPlayerManager; - public BungeeModuleManager(final Object configYml, final Object messagesYml) { + public BungeeModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { commandsModule = new BungeeCommandsModule(configYml); - customPayloadModule = new BungeeCustomPayloadModule(configYml); + customPayloadModule = new BungeeCustomPayloadModule(plugin, this, configYml); messagesModule = new BungeeMessagesModule(messagesYml); notificationsModule = new BungeeNotificationsModule(configYml); uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); - exploitPlayerManager = new BungeeExploitPlayerManager(this); + exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); } + @Override public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { commandsModule.reload(configYml); customPayloadModule.reload(configYml); @@ -31,26 +33,32 @@ public void reload(final Object configYml, final Object messagesYml, final Objec exploitPlayerManager.reload(); } + @Override public CommandsModule getCommandsModule() { return commandsModule; } + @Override public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } + @Override public ItemsFixModule getItemsFixModule() { return null; } + @Override public MessagesModule getMessagesModule() { return messagesModule; } + @Override public NotificationsModule getNotificationsModule() { return notificationsModule; } + @Override public ExploitPlayerManager getExploitPlayerManager() { return exploitPlayerManager; } @@ -65,15 +73,18 @@ public SignsModule getSignsModule() { return null; } + @Override + public PacketsModule getPacketsModule() { + return null; + } + + @Override public DuplicationModule getDuplicationModule() { return null; } + @Override public UUIDSpoofModule getUUIDSpoofModule() { return uuidSpoofModule; } - - public PacketsModule getPacketsModule() { - return null; - } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java index d87052e..e48e1c5 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java @@ -1,15 +1,17 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.CommandsModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; import java.util.Collection; public class BungeeCommandsModule implements CommandsModule { private Collection commands; private boolean enabled; - private Punishment punishment; + private int cancelVls, reduceVls; + private Thresholds thresholds; public BungeeCommandsModule(final Object configYml) { reload(configYml); @@ -26,8 +28,18 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override @@ -38,9 +50,12 @@ final public Collection getCommands() { @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("commands.enabled"); - commands = configYml1.getStringList("commands.commands"); - this.punishment = new Punishment(configYml1.getBoolean("commands.punishment.enabled"), configYml1.getBoolean("commands.punishment.kick"), configYml1.getInt("commands.punishment.threshold"), configYml1.getStringList("commands.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BungeeThresholds(configYml1.getSection(name + ".thresholds")); + this.commands = configYml1.getStringList("commands.commands"); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index 3757ab6..4cdf176 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -1,21 +1,48 @@ package twolovers.exploitfixer.bungee.modules; +import com.google.common.base.Charsets; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; + +import java.util.HashMap; +import java.util.Map; public class BungeeCustomPayloadModule implements CustomPayloadModule { - private int limit, otherLimit; + private Map multipliers = new HashMap<>(); + private Plugin plugin; + private ModuleManager moduleManager; + private Thresholds thresholds; + private int maxChannels, cancelVls, reduceVls; private boolean enabled; - private Punishment punishment; - public BungeeCustomPayloadModule(final Object configYml) { + public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { + this.plugin = plugin; + this.moduleManager = moduleManager; + reload(configYml); } @Override - final public Boolean isEnabled() { - return enabled; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override @@ -24,26 +51,46 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + final public boolean isEnabled() { + return enabled; } - public void reload(Object configYml) { + @Override + public void reload(final Object configYml) { final Configuration configYml1 = (Configuration) configYml; + final Configuration configurationSection = configYml1.getSection("custompayload.multipliers"); + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("custompayload.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("custompayload.punishment.enabled"), configYml1.getBoolean("custompayload.punishment.kick"), configYml1.getInt("custompayload.punishment.threshold"), configYml1.getStringList("custompayload.punishment.commands")); - limit = configYml1.getInt("custompayload.limit.normal"); - otherLimit = configYml1.getInt("custompayload.limit.other"); - } + this.enabled = configYml1.getBoolean("custompayload.enabled"); + this.cancelVls = configYml1.getInt("custompayload.cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BungeeThresholds(configYml1.getSection("custompayload.thresholds")); + this.maxChannels = configYml1.getInt("custompayload.max_channels"); - @Override - public int getLimit() { - return limit; + for (final String key : configurationSection.getKeys()) + multipliers.put(key, configurationSection.getDouble(key)); } @Override - public int getOtherLimit() { - return otherLimit; + public void checkPacket(final Object event) { + if (event instanceof PluginMessageEvent) { + final PluginMessageEvent pluginMessageEvent = (PluginMessageEvent) event; + final Connection sender = pluginMessageEvent.getSender(); + + if (sender instanceof ProxiedPlayer) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getName()); + final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); + final String tag = pluginMessageEvent.getTag(); + + if (tag != null && tag.equals("REGISTER")) { + int channels = content.split("[\u0001-\u0009]").length; + + if (exploitPlayer.addChannels(channels) > maxChannels) + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", 9999D)); + } else { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } + } } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index cd1fd0a..9e71a44 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -1,7 +1,8 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.modules.*; +import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; public class BungeeMessagesModule implements MessagesModule { private Object messagesYml; diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java index a58e9ac..63526bd 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java @@ -1,12 +1,14 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; -import twolovers.exploitfixer.shared.instanceables.Punishment; public class BungeeUUIDSpoofModule implements UUIDSpoofModule { private boolean enabled; - private Punishment punishment; + private int cancelVls, reduceVls; + private Thresholds thresholds; public BungeeUUIDSpoofModule(final Object configYml) { reload(configYml); @@ -23,15 +25,28 @@ public String getName() { } @Override - public Punishment getPunishment() { - return punishment; + public int getCancelVls() { + return cancelVls; + } + + @Override + public int getReduceVls() { + return reduceVls; + } + + @Override + public Thresholds getThresholds() { + return thresholds; } @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; + final String name = getName().toLowerCase(); - enabled = configYml1.getBoolean("uuidspoof.enabled"); - this.punishment = new Punishment(configYml1.getBoolean("uuidspoof.punishment.enabled"), configYml1.getBoolean("uuidspoof.punishment.kick"), configYml1.getInt("uuidspoof.punishment.threshold"), configYml1.getStringList("uuidspoof.punishment.commands")); + this.enabled = configYml1.getBoolean(name + ".enabled"); + this.cancelVls = configYml1.getInt(name + ".cancel_vls"); + this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.thresholds = new BungeeThresholds(configYml1.getSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java b/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java index c5d2414..c845117 100644 --- a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java +++ b/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java @@ -47,11 +47,11 @@ public void createConfiguration(String file) { if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - System.out.print(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); } else configFile.createNewFile(); } } catch (final IOException e) { - System.out.print(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } } @@ -62,7 +62,7 @@ public void saveConfiguration(final Configuration configuration, final String fi ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(file.replace("%datafolder%", dataFolder.toPath().toString()))); } catch (final IOException e) { - System.out.print(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + System.out.println(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } }); } diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java index f736908..7179f18 100644 --- a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java @@ -1,22 +1,20 @@ package twolovers.exploitfixer.interfaces.instanceables; +import twolovers.exploitfixer.interfaces.modules.CancellableModule; import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.shared.enums.Identity; public interface ExploitPlayer { int getChannels(); void clearChannels(); - void addChannels(final int channels); + int addChannels(final int channels); - int getViolations(final Identity identifier); - - void addViolation(final Identity identifier); + double getViolations(final Module module); String getOnlineUUID(); - void punish(final Object plugin, final Module module, final Object player); + void addVls(final Object plugin, final Object event, final Object player, final CancellableModule module, final double amount); String getName(); diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java b/src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java new file mode 100644 index 0000000..b09dc3b --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java @@ -0,0 +1,9 @@ +package twolovers.exploitfixer.interfaces.instanceables; + +import java.util.Collection; + +public interface Thresholds { + Collection getCommands(final int violations); + + Collection getThresholds(); +} diff --git a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java index 7aa632d..18d19b5 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java @@ -2,21 +2,19 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import java.util.Collection; - public interface ExploitPlayerManager { - ExploitPlayer getPlayer(final String playerName); + ExploitPlayer get(final String name); - void addPlayer(final String playerName); + int getSize(); - void reload(); + int getPunishments(); - Collection getExploitPlayers(); + void add(final String name); - int getPunishments(); + int addPunishment(); - void addPunishment(); + void clear(); - void removePlayer(String name); + void reload(); } diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index 4efff1b..ab40dfd 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -15,8 +15,6 @@ public interface ModuleManager { NotificationsModule getNotificationsModule(); - PacketsModule getPacketsModule(); - DuplicationModule getDuplicationModule(); UUIDSpoofModule getUUIDSpoofModule(); @@ -26,4 +24,6 @@ public interface ModuleManager { BooksModule getBooksModule(); SignsModule getSignsModule(); + + PacketsModule getPacketsModule(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java b/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java index 1552c6f..af0401f 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface BooksModule extends Module { +public interface BooksModule extends CancellableModule { void reload(Object configYml); boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java b/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java new file mode 100644 index 0000000..8767e92 --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java @@ -0,0 +1,11 @@ +package twolovers.exploitfixer.interfaces.modules; + +import twolovers.exploitfixer.interfaces.instanceables.Thresholds; + +public interface CancellableModule extends ReloadableModule { + int getCancelVls(); + + int getReduceVls(); + + Thresholds getThresholds(); +} diff --git a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java index 772fff5..a2fe217 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java @@ -2,10 +2,8 @@ import java.util.Collection; -public interface CommandsModule extends Module { +public interface CommandsModule extends CancellableModule { Boolean isEnabled(); Collection getCommands(); - - void reload(Object configYml); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index bc85bac..5ac013a 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -1,11 +1,9 @@ package twolovers.exploitfixer.interfaces.modules; -public interface CustomPayloadModule extends Module { - Boolean isEnabled(); +public interface CustomPayloadModule extends CancellableModule { + boolean isEnabled(); - void reload(Object configYml); + void reload(final Object configYml); - int getLimit(); - - int getOtherLimit(); + void checkPacket(final Object packetEvent); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java index ef7e237..2a404f7 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface DuplicationModule extends Module { +public interface DuplicationModule extends CancellableModule { void reload(Object configYml); Boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index 4014e85..edcf93e 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface ItemsFixModule extends Module { +public interface ItemsFixModule extends ReloadableModule { void reload(Object configYml); Boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java b/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java index ba3d4ac..f6593a5 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java @@ -17,7 +17,7 @@ public interface MessagesModule { String getDisable(final String locale); - String getKickMessage(Module module, String locale); + String getKickMessage(final Module module, String locale); void reload(Object messagesYml); diff --git a/src/twolovers/exploitfixer/interfaces/modules/Module.java b/src/twolovers/exploitfixer/interfaces/modules/Module.java index d93eaeb..cba715f 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/Module.java +++ b/src/twolovers/exploitfixer/interfaces/modules/Module.java @@ -1,9 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; -import twolovers.exploitfixer.shared.instanceables.Punishment; - public interface Module { String getName(); - - Punishment getPunishment(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index f99880e..5d9587c 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -1,15 +1,21 @@ package twolovers.exploitfixer.interfaces.modules; -import twolovers.exploitfixer.shared.enums.Identity; - -public interface PacketsModule extends Module { +public interface PacketsModule extends CancellableModule { void reload(Object configYml); - void addLimit(final Identity packet, final int value); - - int getLimit(final Identity identity); + double getMultiplier(final String packetName); boolean isEnabled(); - void checkPacket(final Object packetEvent, final Identity identity); + void checkPacket(final Object packetEvent, final String packetName); + + boolean isWindowClick(); + + boolean isOffline(); + + boolean isSetCreativeSlot(); + + boolean isBlockPlace(); + + boolean isBlockDig(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java b/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java new file mode 100644 index 0000000..9e38ace --- /dev/null +++ b/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java @@ -0,0 +1,5 @@ +package twolovers.exploitfixer.interfaces.modules; + +public interface ReloadableModule extends Module { + void reload(final Object configYml); +} diff --git a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java index a7a420f..c592dfd 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface SignsModule extends Module { +public interface SignsModule extends CancellableModule { void reload(Object configYml); boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java b/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java index 11232bd..b1aa05c 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface UUIDSpoofModule extends Module { +public interface UUIDSpoofModule extends CancellableModule { Boolean isEnabled(); void reload(Object configYml); diff --git a/src/twolovers/exploitfixer/shared/enums/Identity.java b/src/twolovers/exploitfixer/shared/enums/Identity.java deleted file mode 100644 index ab05b2a..0000000 --- a/src/twolovers/exploitfixer/shared/enums/Identity.java +++ /dev/null @@ -1,7 +0,0 @@ -package twolovers.exploitfixer.shared.enums; - -public enum Identity { - ABILITIES, ARM_ANIMATION, BLOCK_PLACE, BLOCK_PLACE_BOOKS, BLOCK_PLACE_WRONG, CUSTOM_PAYLOAD, CUSTOM_PAYLOAD_OTHER, POSITION, BLOCK_DIG, - KEEP_ALIVE, SET_CREATIVE_SLOT, USE_ITEM, USE_ENTITY, WINDOW_CLICK, WINDOW_CLICK_WRONG, ENTITY_ACTION, SET_CREATIVE_SLOT_WRONG, TAB_COMPLETE, - UPDATE_SIGN -} diff --git a/src/twolovers/exploitfixer/shared/instanceables/Punishment.java b/src/twolovers/exploitfixer/shared/instanceables/Punishment.java deleted file mode 100644 index 38d0bb4..0000000 --- a/src/twolovers/exploitfixer/shared/instanceables/Punishment.java +++ /dev/null @@ -1,32 +0,0 @@ -package twolovers.exploitfixer.shared.instanceables; - -import java.util.Collection; - -public class Punishment { - private final boolean enabled, kick; - private final int threshold; - private final Collection commands; - - public Punishment(final boolean enabled, final boolean kick, final int threshold, final Collection commands) { - this.enabled = enabled; - this.kick = kick; - this.threshold = threshold; - this.commands = commands; - } - - public boolean isEnabled() { - return enabled; - } - - public boolean isKick() { - return kick; - } - - public int getThreshold() { - return threshold; - } - - public Collection getCommands() { - return commands; - } -} From b47cd499a4f0750b3a788778878aa1acac7b9655 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Sat, 28 Dec 2019 21:50:16 -0300 Subject: [PATCH 028/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 13 ++-- src/plugin.yml | 2 +- .../adapters/BlockDigPacketAdapter.java | 19 +++--- .../adapters/BlockPlacePacketAdapter.java | 19 +++--- .../adapters/WindowClickPacketAdapter.java | 33 ++++------ .../instanceables/BukkitExploitPlayer.java | 4 +- .../modules/BukkitCustomPayloadModule.java | 31 +++++----- .../bukkit/modules/BukkitPacketsModule.java | 60 ++++++++++++++++++- .../modules/BungeeCustomPayloadModule.java | 6 +- .../interfaces/modules/PacketsModule.java | 2 + 11 files changed, 124 insertions(+), 67 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 8a049d5..86342ef 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.9.1 +version: 0.9.5 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index c847160..88f3213 100644 --- a/src/config.yml +++ b/src/config.yml @@ -56,6 +56,9 @@ packets: # Do you want to enable this module? enabled: true + # Cancells packets with big data length. + big_data: true + # Cancells packets from offline players. offline: true @@ -84,18 +87,18 @@ packets: BLOCK_DIG: 4 BLOCK_PLACE: 4 BLOCK_PLACE_BOOKS: 50 - ENTITY_ACTION: 6.5 + ENTITY_ACTION: 4 POSITION: 0.8 SET_CREATIVE_SLOT: 1 TAB_COMPLETE: 8 UPDATE_SIGN: 95 - USE_ENTITY: 6.5 - USE_ITEM: 6.5 - WINDOW_CLICK: 6.5 + USE_ENTITY: 4 + USE_ITEM: 4 + WINDOW_CLICK: 4 # Placeholders: %player% thresholds: - 750: + 200: - "notification" 2500: - "kick" diff --git a/src/plugin.yml b/src/plugin.yml index 6a0677a..8928611 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.9.1 +version: 0.9.5 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index aec70a7..3e88d5f 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -31,16 +32,18 @@ public void onPacketReceiving(final PacketEvent event) { final ItemStack itemUse = itemModifier.read(0); if (itemUse != null) { - final ItemStack itemOnHand = player.getItemInHand(); + final PlayerInventory playerInventory = player.getInventory(); + ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - if (packetsModule.isBlockDig() && itemOnHand != null && itemUse.getType() != itemOnHand.getType()) + if (itemOnHand == null) + itemOnHand = new ItemStack(Material.AIR); + + if (packetsModule.isBlockDig() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) event.setCancelled(true); - else - packetsModule.checkPacket(event, "BLOCK_DIG"); - } else - packetsModule.checkPacket(event, "BLOCK_DIG"); - } else - packetsModule.checkPacket(event, "BLOCK_DIG"); + } + } + + packetsModule.checkPacket(event, "BLOCK_DIG"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index a7d19ac..6ff6b25 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -31,16 +32,18 @@ public void onPacketReceiving(final PacketEvent event) { final ItemStack itemUse = itemModifier.read(0); if (itemUse != null) { - final ItemStack itemOnHand = player.getItemInHand(); + final PlayerInventory playerInventory = player.getInventory(); + ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - if (packetsModule.isBlockPlace() && itemOnHand != null && itemUse.getType() != itemOnHand.getType()) + if (itemOnHand == null) + itemOnHand = new ItemStack(Material.AIR); + + if (packetsModule.isBlockPlace() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) event.setCancelled(true); - else - packetsModule.checkPacket(event, "BLOCK_PLACE"); - } else - packetsModule.checkPacket(event, "BLOCK_PLACE"); - } else - packetsModule.checkPacket(event, "BLOCK_PLACE"); + } + } + + packetsModule.checkPacket(event, "BLOCK_PLACE"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index a67dff8..2aa5da6 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -5,7 +5,6 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -38,8 +37,8 @@ public void onPacketReceiving(final PacketEvent event) { else if (integers.size() > 1) { final Inventory topInventory = inventoryView.getTopInventory(); final Inventory bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.readSafely(1); int maxSlots = inventoryView.countSlots(); - int slot = integers.read(1); if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) maxSlots += 4; @@ -50,30 +49,20 @@ else if (integers.size() > 1) { final StructureModifier structureModifier = packet.getItemModifier(); if (structureModifier.size() > 0 && slot > 0) { - if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) - maxSlots -= 4; + final ItemStack itemUse = structureModifier.readSafely(0); - if (slot >= maxSlots) - packetsModule.checkPacket(event, "WINDOW_CLICK"); - else { - final ItemStack itemStack = inventoryView.getItem(slot); - final ItemStack itemStack1 = structureModifier.read(0); + if (itemUse != null) { + final ItemStack itemOnHand = inventoryView.getItem(slot); - if (itemStack1 != null) { - final Material material = itemStack1.getType(); - - if (packetsModule.isWindowClick() && (material != Material.AIR && material != Material.getMaterial("LEGACY_AIR")) && !itemStack1.isSimilar(itemStack)) { - packetsModule.checkPacket(event, "WINDOW_CLICK_WRONG"); - } else - packetsModule.checkPacket(event, "WINDOW_CLICK"); - } else - packetsModule.checkPacket(event, "WINDOW_CLICK"); + if (packetsModule.isWindowClick() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) { + event.setCancelled(true); + } } - } else - packetsModule.checkPacket(event, "WINDOW_CLICK"); + } } - } else - packetsModule.checkPacket(event, "WINDOW_CLICK"); + } + + packetsModule.checkPacket(event, "WINDOW_CLICK"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 98c9aee..a16f157 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -129,12 +129,12 @@ public void addVls(final Object pluginObject, final Object event, final Object p for (final String punishCommand : commands) if (!punishCommand.isEmpty()) if (punishCommand.equals("kick")) { - server.getScheduler().runTask(plugin, ()->player.kickPlayer(kickMessage)); + server.getScheduler().runTask(plugin, () -> player.kickPlayer(kickMessage)); exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) notificationsModule.sendNotification(module.getName(), player); else - server.getScheduler().runTask(plugin, ()->server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); } if (event instanceof Cancellable && module.getCancelVls() <= newVls) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index f57c337..8038cca 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -84,22 +84,21 @@ public void checkPacket(final Object event) { if (exploitPlayer != null && sender.isOnline()) { final PacketContainer packet = packetEvent.getPacket(); - final String tag = String.valueOf(packet.getModifier().readSafely(0)); - - if (tag != null && tag.toLowerCase().endsWith("register")) { - final ByteBuf buffer = packet.getSpecificModifier(ByteBuf.class).readSafely(0); - final int channels; - - if (VersionUtil.isOneDotSeven()) - channels = 1; - else - channels = buffer.toString(Charsets.UTF_8).split("\000").length; - - if (exploitPlayer.addChannels(channels) > maxChannels) - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", multipliers.getOrDefault("OTHER", 1D))); - } else - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } /*else if (moduleManager.getPacketsModule().isOffline()) + final String tag = String.valueOf(packet.getModifier().readSafely(0)); + + if (tag != null && tag.toLowerCase().endsWith("register")) { + final int channels; + + if (VersionUtil.isOneDotSeven()) + channels = 1; + else + channels = packet.getSpecificModifier(ByteBuf.class).readSafely(0).toString(Charsets.UTF_8).split("\000").length; + + if (exploitPlayer.addChannels(channels) > maxChannels) + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", multipliers.getOrDefault("OTHER", 1D))); + } else + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } /*else if (moduleManager.getPacketsModule().isOffline()) packetEvent.setCancelled(true);*/ // Disabled because of false positives } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index f80dc17..2dcca12 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -1,9 +1,13 @@ package twolovers.exploitfixer.bukkit.modules; +import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.WrappedBlockData; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -19,7 +23,7 @@ public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; private final Map multipliers = new HashMap<>(); private Thresholds thresholds; - private boolean enabled, windowClick, offline, setCreativeSlot, blockPlace, blockDig; + private boolean enabled, bigData, offline, windowClick, setCreativeSlot, blockPlace, blockDig; private int cancelVls, reduceVls; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { @@ -36,6 +40,7 @@ final public void reload(final Object configYml) { this.enabled = configYml1.getBoolean(name + ".enabled"); this.cancelVls = configYml1.getInt(name + ".cancel_vls"); this.reduceVls = configYml1.getInt(name + ".reduce_vls"); + this.bigData = configYml1.getBoolean(name + ".big_data"); this.offline = configYml1.getBoolean(name + ".offline"); this.windowClick = configYml1.getBoolean(name + ".window_click"); this.blockPlace = configYml1.getBoolean(name + ".block_place"); @@ -62,11 +67,55 @@ public void checkPacket(final Object packetEvent, String packetName) { final PacketEvent event = (PacketEvent) packetEvent; final Player player = event.getPlayer(); - if (player != null && player.isOnline()) { + if (bigData) { + final PacketContainer packet = event.getPacket(); + final StructureModifier itemModifier = packet.getItemModifier(); + final StructureModifier blockDataModifier = packet.getBlockData(); + final int itemModifierSize = itemModifier.size(); + final int blockDataModifierSize = blockDataModifier.size(); + int packetSize = 0; + + if (itemModifierSize > 75 || blockDataModifierSize > 75) + event.setCancelled(true); + else { + if (itemModifierSize > 0) + for (int i = 0; i < itemModifier.size(); i++) { + final ItemStack itemStack = itemModifier.readSafely(i); + + if (itemStack != null) { + int dataBytes = itemStack.getData().toString().getBytes().length; + + if (itemStack.hasItemMeta()) + dataBytes += itemStack.getItemMeta().toString().getBytes().length; + + packetSize += dataBytes; + } + } + + if (blockDataModifierSize > 0) + for (int i = 0; i < blockDataModifier.size(); i++) { + final WrappedBlockData blockData = blockDataModifier.readSafely(i); + + if (blockData != null) { + int dataBytes = blockData.toString().getBytes().length; + + packetSize += dataBytes; + } + } + + if (packetSize > 20000) + event.setCancelled(true); + } + } + + if (!event.isCancelled() && player != null && player.isOnline()) { final String playerName = player.getName(); final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + else if (isOffline()) + event.setCancelled(true); } else if (isOffline()) event.setCancelled(true); } @@ -76,6 +125,11 @@ public boolean isWindowClick() { return windowClick; } + @Override + public boolean isBigData() { + return bigData; + } + @Override public boolean isOffline() { return offline; diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index 4cdf176..1bd69ab 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -79,7 +79,9 @@ public void checkPacket(final Object event) { if (sender instanceof ProxiedPlayer) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getName()); - final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); + + if (exploitPlayer != null) { + final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); final String tag = pluginMessageEvent.getTag(); if (tag != null && tag.equals("REGISTER")) { @@ -90,6 +92,8 @@ public void checkPacket(final Object event) { } else { exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); } + } else if (moduleManager.getPacketsModule().isOffline()) + ((PluginMessageEvent) event).setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 5d9587c..353181a 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -11,6 +11,8 @@ public interface PacketsModule extends CancellableModule { boolean isWindowClick(); + boolean isBigData(); + boolean isOffline(); boolean isSetCreativeSlot(); From 1627efe9c28e686b543a28cbcc7403e6eaf08699 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Thu, 2 Jan 2020 13:47:22 -0300 Subject: [PATCH 029/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 25 ++++--- src/messages.yml | 2 +- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 4 +- .../adapters/AbilitiesPacketAdapter.java | 23 ------- .../adapters/ArmAnimationPacketAdapter.java | 23 ------- .../adapters/BlockDigPacketAdapter.java | 2 - .../adapters/BlockPlacePacketAdapter.java | 2 - .../adapters/CustomPayloadPacketAdapter.java | 24 ------- .../adapters/EntityActionPacketAdapter.java | 23 ------- .../adapters/PositionPacketAdapter.java | 23 ------- .../SetCreativeSlotPacketAdapter.java | 2 - .../adapters/TabCompletePacketAdapter.java | 23 ------- .../adapters/UpdateSignPacketAdapter.java | 23 ------- .../adapters/UseEntityPacketAdapter.java | 23 ------- .../bukkit/adapters/UseItemPacketAdapter.java | 23 ------- .../adapters/WindowClickPacketAdapter.java | 5 +- .../initializers/AdapterInitializer.java | 29 +++++--- .../instanceables/BukkitExploitPlayer.java | 1 - .../bukkit/listeners/PlayerLoginListener.java | 12 +--- .../bukkit/managers/BukkitModuleManager.java | 5 +- .../bukkit/modules/BukkitItemsFixModule.java | 2 - .../bukkit/modules/BukkitMessagesModule.java | 17 +++-- .../bukkit/modules/BukkitPacketsModule.java | 67 +++++++++++-------- .../bukkit/utils/ConfigurationUtil.java | 7 +- .../bungee/listeners/PostLoginListener.java | 2 +- .../bungee/managers/BungeeModuleManager.java | 5 +- .../bungee/modules/BungeeMessagesModule.java | 14 ++-- .../bungee/utils/ConfigurationUtil.java | 7 +- 30 files changed, 112 insertions(+), 310 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java diff --git a/src/bungee.yml b/src/bungee.yml index 86342ef..01846fb 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.9.5 +version: 0.9.7 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 88f3213..96d6db7 100644 --- a/src/config.yml +++ b/src/config.yml @@ -75,32 +75,35 @@ packets: set_creative_slot: true # Amount of violations required to cancel. - cancel_vls: 200 + cancel_vls: 400 # Amount of violations to reduce per second. - reduce_vls: 600 + reduce_vls: 300 # When a valid packet is sent the following amount of violations will be applied. multipliers: ABILITIES: 1 - ARM_ANIMATION: 4 - BLOCK_DIG: 4 - BLOCK_PLACE: 4 - BLOCK_PLACE_BOOKS: 50 + ARM_ANIMATION: 4.5 + BLOCK_DIG: 4.5 + BLOCK_PLACE: 4.5 + BLOCK_PLACE_BOOKS: 80 ENTITY_ACTION: 4 - POSITION: 0.8 + FLYING: 1 + LOOK: 1.5 + POSITION_LOOK: 1.5 + POSITION: 3 SET_CREATIVE_SLOT: 1 TAB_COMPLETE: 8 - UPDATE_SIGN: 95 + UPDATE_SIGN: 90 USE_ENTITY: 4 USE_ITEM: 4 - WINDOW_CLICK: 4 + WINDOW_CLICK: 5 # Placeholders: %player% thresholds: - 200: + 400: - "notification" - 2500: + 1000: - "kick" - "notification" diff --git a/src/messages.yml b/src/messages.yml index f584a3d..c360a46 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -7,7 +7,7 @@ en: commands: reload: "&aPlugin ExploitFixer reloaded!" help: |- - &aExploitFixer commands: + &aExploitFixer %version% commands: &e/%command% help &7- &bShows available commands! &e/%command% reload &7- &bReloads the plugin! &e/%command% notifications &7- &bToggles notifications of the plugin! diff --git a/src/plugin.yml b/src/plugin.yml index 8928611..de0b627 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.9.5 +version: 0.9.7 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 456ea39..ba7f492 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -13,6 +13,8 @@ import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import java.util.logging.Level; + public class ExploitFixer extends JavaPlugin { private static ExploitFixer exploitFixer; private ModuleManager moduleManager; @@ -57,7 +59,7 @@ public void reload() { if (pluginManager.isPluginEnabled("ProtocolLib")) new AdapterInitializer(this, moduleManager); else - System.out.println("[ExploitFixer] Please install ProtocolLib or your server will remain unprotected from exploits!"); + getLogger().log(Level.INFO, "[ExploitFixer] Please install ProtocolLib or your server will remain unprotected from exploits!"); new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java deleted file mode 100644 index c32bb58..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/AbilitiesPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class AbilitiesPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public AbilitiesPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.ABILITIES); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "ABILITIES"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java deleted file mode 100644 index 209c114..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/ArmAnimationPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class ArmAnimationPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public ArmAnimationPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.ARM_ANIMATION); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "ARM_ANIMATION"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 3e88d5f..852cfcb 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -42,8 +42,6 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } } - - packetsModule.checkPacket(event, "BLOCK_DIG"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 6ff6b25..443256b 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -42,8 +42,6 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } } - - packetsModule.checkPacket(event, "BLOCK_PLACE"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java deleted file mode 100644 index e65b327..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ /dev/null @@ -1,24 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; - -public class CustomPayloadPacketAdapter extends PacketAdapter { - private final CustomPayloadModule customPayloadModule; - - public CustomPayloadPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.CUSTOM_PAYLOAD); - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && customPayloadModule.isEnabled()) { - customPayloadModule.checkPacket(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java deleted file mode 100644 index 0573ef3..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/EntityActionPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class EntityActionPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public EntityActionPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.ENTITY_ACTION); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "ENTITY_ACTION"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java deleted file mode 100644 index 43c7018..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/PositionPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class PositionPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public PositionPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.POSITION); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "POSITION"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 07ef5b0..d33eb80 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -26,8 +26,6 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); if (packetsModule.isSetCreativeSlot() && player != null && player.getGameMode() != GameMode.CREATIVE) event.setCancelled(true); - else - packetsModule.checkPacket(event, "SET_CREATIVE_SLOT"); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java deleted file mode 100644 index 4dbd59a..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/TabCompletePacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class TabCompletePacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public TabCompletePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.TAB_COMPLETE); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "TAB_COMPLETE"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java deleted file mode 100644 index 81eda3d..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/UpdateSignPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class UpdateSignPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public UpdateSignPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.UPDATE_SIGN); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "UPDATE_SIGN"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java deleted file mode 100644 index 5dbfb42..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/UseEntityPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class UseEntityPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public UseEntityPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.USE_ENTITY); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "USE_ENTITY"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java deleted file mode 100644 index d238e69..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/UseItemPacketAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class UseItemPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - - public UseItemPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.USE_ITEM); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, "USE_ITEM"); - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 2aa5da6..34311d5 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -54,15 +54,12 @@ else if (integers.size() > 1) { if (itemUse != null) { final ItemStack itemOnHand = inventoryView.getItem(slot); - if (packetsModule.isWindowClick() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) { + if (packetsModule.isWindowClick() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) event.setCancelled(true); - } } } } } - - packetsModule.checkPacket(event, "WINDOW_CLICK"); } else if (packetsModule.isOffline()) event.setCancelled(true); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index a95f274..6970e7a 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -1,28 +1,37 @@ package twolovers.exploitfixer.bukkit.adapters.initializers; +import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.*; +import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class AdapterInitializer { public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager) { final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); + final PacketsModule packetsModule = moduleManager.getPacketsModule(); protocolManager.removePacketListeners(plugin); - protocolManager.addPacketListener(new AbilitiesPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new ArmAnimationPacketAdapter(plugin, moduleManager)); + + for (final PacketType packetType : PacketType.Play.Client.getInstance()) + protocolManager.addPacketListener(new PacketAdapter(plugin, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { + if (!event.isCancelled()) + packetsModule.checkPacket(event, packetType.name()); + } + }); + protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new EntityActionPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new PositionPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new TabCompletePacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new UpdateSignPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new UseEntityPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new UseItemPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index a16f157..9b108ab 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -116,7 +116,6 @@ public void addVls(final Object pluginObject, final Object event, final Object p final double oldVls = getViolations(module); final double newVls = oldVls + amount; - final String kickMessage = messagesModule.getKickMessage(module, locale); violations.put(module, newVls); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index aa7dda9..d4c8bde 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -6,7 +6,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -38,13 +37,6 @@ public void onPlayerLogin(final PlayerLoginEvent event) { exploitPlayerManager.add(player.getName()); if (uuidSpoofModule.isEnabled()) { - final String locale; - - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { final String playerName = player.getName(); final String originalUUID = player.getUniqueId().toString().replace("-", ""); @@ -54,9 +46,7 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getName()); final String onlineUUID = exploitPlayer.getOnlineUUID(); - if (onlineUUID != null && !onlineUUID.contains(originalUUID)) { - event.setKickMessage(messagesModule.getKickMessage(uuidSpoofModule, locale)); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 38bd561..6eec29d 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.managers; +import org.bukkit.configuration.Configuration; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.modules.*; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -19,11 +20,11 @@ public class BukkitModuleManager implements ModuleManager { private BooksModule booksModule; private SignsModule signsModule; - public BukkitModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { + public BukkitModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { commandsModule = new BukkitCommandsModule(configYml); customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); itemsFixModule = new BukkitItemsFixModule(configYml); - messagesModule = new BukkitMessagesModule(messagesYml); + messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); notificationsModule = new BukkitNotificationsModule(configYml); uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); packetsModule = new BukkitPacketsModule(plugin, this, configYml); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index 915c33b..acea5b0 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -1,12 +1,10 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; public class BukkitItemsFixModule implements ItemsFixModule { private boolean enabled; - private Thresholds thresholds; public BukkitItemsFixModule(final Object configYml) { reload(configYml); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 9046e59..cb23cec 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -1,13 +1,15 @@ package twolovers.exploitfixer.bukkit.modules; -import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.configuration.Configuration; import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.Module; public class BukkitMessagesModule implements MessagesModule { - private Object messagesYml; + private final String version; + private Configuration messagesYml; - public BukkitMessagesModule(final Object messagesYml) { + public BukkitMessagesModule(final String version, final Configuration messagesYml) { + this.version = version; reload(messagesYml); } @@ -17,10 +19,10 @@ public String getString(String locale, final String path) { if (locale == null) locale = "en"; - string = ((YamlConfiguration) messagesYml).getString(locale + path); + string = messagesYml.getString(locale + path); if (string == null || string.isEmpty()) - string = ((YamlConfiguration) messagesYml).getString("en" + path); + string = messagesYml.getString("en" + path); if (string != null) string = string.replace("&", "\u00A7"); @@ -35,7 +37,8 @@ public final String getReload(final String locale) { } public final String getHelp(final String locale) { - return getString(locale, ".commands.help"); + return getString(locale, ".commands.help") + .replace("%version%", version); } public final String getUnknown(final String locale) { @@ -63,7 +66,7 @@ public final String getKickMessage(final Module module, final String locale) { } public void reload(Object messagesYml) { - this.messagesYml = messagesYml; + this.messagesYml = (Configuration) messagesYml; } public String getStats(String locale) { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 2dcca12..d1c7048 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -63,61 +64,69 @@ public boolean isEnabled() { } @Override - public void checkPacket(final Object packetEvent, String packetName) { + public void checkPacket(final Object packetEvent, final String packetName) { final PacketEvent event = (PacketEvent) packetEvent; final Player player = event.getPlayer(); - if (bigData) { + if (!event.isCancelled() && bigData) { final PacketContainer packet = event.getPacket(); final StructureModifier itemModifier = packet.getItemModifier(); final StructureModifier blockDataModifier = packet.getBlockData(); - final int itemModifierSize = itemModifier.size(); - final int blockDataModifierSize = blockDataModifier.size(); + final StructureModifier longs = packet.getLongs(); + final StructureModifier strings = packet.getStrings(); int packetSize = 0; - if (itemModifierSize > 75 || blockDataModifierSize > 75) + if (itemModifier.size() > 75 || blockDataModifier.size() > 75 || longs.size() > 75 || strings.size() > 75) { + System.out.println("TOO BIG ARRAY"); event.setCancelled(true); - else { - if (itemModifierSize > 0) - for (int i = 0; i < itemModifier.size(); i++) { - final ItemStack itemStack = itemModifier.readSafely(i); + } else { + for (final ItemStack itemStack : itemModifier.getValues()) { + if (itemStack != null) { + int dataBytes = itemStack.getData().toString().getBytes().length; + + if (itemStack.hasItemMeta()) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + try { + dataBytes += itemMeta.toString().getBytes().length; + } catch (final NullPointerException e) { + dataBytes += String.valueOf(itemMeta).getBytes().length; + } + } - if (itemStack != null) { - int dataBytes = itemStack.getData().toString().getBytes().length; + packetSize += dataBytes; + } + } - if (itemStack.hasItemMeta()) - dataBytes += itemStack.getItemMeta().toString().getBytes().length; + for (final WrappedBlockData blockData : blockDataModifier.getValues()) { + if (blockData != null) { + int dataBytes = blockData.toString().getBytes().length; - packetSize += dataBytes; - } + packetSize += dataBytes; } + } - if (blockDataModifierSize > 0) - for (int i = 0; i < blockDataModifier.size(); i++) { - final WrappedBlockData blockData = blockDataModifier.readSafely(i); - - if (blockData != null) { - int dataBytes = blockData.toString().getBytes().length; + for (final String string : strings.getValues()) { + if (string != null) { + int dataBytes = string.getBytes().length; - packetSize += dataBytes; - } + packetSize += dataBytes; } + } - if (packetSize > 20000) + if (packetSize > 20000){ + System.out.println("TOO BIG PACKET"); event.setCancelled(true); + } } } - if (!event.isCancelled() && player != null && player.isOnline()) { + if (player != null && player.isOnline()) { final String playerName = player.getName(); final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); - else if (isOffline()) - event.setCancelled(true); - } else if (isOffline()) - event.setCancelled(true); + } } @Override diff --git a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java index d52059c..5dc8bee 100644 --- a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.util.logging.Level; public class ConfigurationUtil { final private Plugin plugin; @@ -41,11 +42,11 @@ public void createConfiguration(String file) { if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - System.out.println(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); } else configFile.createNewFile(); } } catch (final IOException e) { - System.out.println(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } } @@ -56,7 +57,7 @@ public void saveConfiguration(final YamlConfiguration yamlConfiguration, final S yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); } catch (final IOException e) { - System.out.println(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } }); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index efc5995..b95244b 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -44,7 +44,7 @@ public void onPostLogin(final PostLoginEvent event) { final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); final String onlineUUID = exploitPlayer.getOnlineUUID(); - if (onlineUUID != null && !onlineUUID.contains(originalUUID)) + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); } }); diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index b9b750c..f91a16a 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bungee.managers; import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.bungee.modules.*; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -14,10 +15,10 @@ public class BungeeModuleManager implements ModuleManager { private UUIDSpoofModule uuidSpoofModule; private ExploitPlayerManager exploitPlayerManager; - public BungeeModuleManager(final Plugin plugin, final Object configYml, final Object messagesYml) { + public BungeeModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { commandsModule = new BungeeCommandsModule(configYml); customPayloadModule = new BungeeCustomPayloadModule(plugin, this, configYml); - messagesModule = new BungeeMessagesModule(messagesYml); + messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); notificationsModule = new BungeeNotificationsModule(configYml); uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index 9e71a44..3b2414b 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -5,18 +5,19 @@ import twolovers.exploitfixer.interfaces.modules.Module; public class BungeeMessagesModule implements MessagesModule { - private Object messagesYml; + private Configuration messagesYml; + private String version; - public BungeeMessagesModule(final Object messagesYml) { + public BungeeMessagesModule(final String version, final Configuration messagesYml) { reload(messagesYml); } @Override public String getString(final String locale, final String path) { - String string = ((Configuration) messagesYml).getString(locale + path); + String string = messagesYml.getString(locale + path); if (string == null || string.isEmpty()) - string = ((Configuration) messagesYml).getString("en" + path); + string = messagesYml.getString("en" + path); if (string != null) string = string.replace("&", "\u00A7"); @@ -33,7 +34,8 @@ public final String getReload(final String locale) { @Override public final String getHelp(final String locale) { - return getString(locale, ".commands.help"); + return getString(locale, ".commands.help") + .replace("%version%", version); } @Override @@ -68,7 +70,7 @@ public final String getKickMessage(final Module module, final String locale) { @Override public void reload(Object messagesYml) { - this.messagesYml = messagesYml; + this.messagesYml = (Configuration) messagesYml; } @Override diff --git a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java b/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java index c845117..4714238 100644 --- a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java +++ b/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.util.logging.Level; public class ConfigurationUtil { final private Plugin plugin; @@ -47,11 +48,11 @@ public void createConfiguration(String file) { if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - System.out.println(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); } else configFile.createNewFile(); } } catch (final IOException e) { - System.out.println(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } } @@ -62,7 +63,7 @@ public void saveConfiguration(final Configuration configuration, final String fi ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(file.replace("%datafolder%", dataFolder.toPath().toString()))); } catch (final IOException e) { - System.out.println(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); } }); } From 8a6794d4b550b4d99d8e5563f1358f7af24dc22c Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Wed, 8 Jan 2020 15:37:54 -0300 Subject: [PATCH 030/336] updated Source --- src/bungee.yml | 2 +- src/config.yml | 24 ++--- src/plugin.yml | 2 +- .../adapters/BlockDigPacketAdapter.java | 51 ++++++---- .../adapters/BlockPlacePacketAdapter.java | 53 ++++++---- .../adapters/CustomPayloadPacketAdapter.java | 24 +++++ .../SetCreativeSlotPacketAdapter.java | 30 ++++-- .../adapters/WindowClickPacketAdapter.java | 96 ++++++++++++------- .../modules/BukkitCustomPayloadModule.java | 16 ++-- .../bukkit/modules/BukkitPacketsModule.java | 84 +++++++++------- .../modules/BungeeCustomPayloadModule.java | 28 +++--- .../bungee/modules/BungeeMessagesModule.java | 1 + .../interfaces/modules/PacketsModule.java | 16 ++-- 13 files changed, 271 insertions(+), 156 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java diff --git a/src/bungee.yml b/src/bungee.yml index 01846fb..083600c 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 0.9.7 +version: 1.0.0 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 96d6db7..759b5ba 100644 --- a/src/config.yml +++ b/src/config.yml @@ -56,23 +56,23 @@ packets: # Do you want to enable this module? enabled: true - # Cancells packets with big data length. - big_data: true + # Cancells packets with big data length. (Set to 0 to disable) + big_data: 1000 # Cancells packets from offline players. offline: true - # Cancells invalid window_click packets. - window_click: true + # Cancells invalid window_click packets. (Set to 0 to disable) + window_click: 1000 - # Cancells invalid block_place packets. - block_place: true + # Cancells invalid block_place packets. (Set to 0 to disable) + block_place: 1000 - # Cancells invalid block_dig packets. - block_dig: true + # Cancells invalid block_dig packets. (Set to 0 to disable) + block_dig: 1000 - # Cancells invalid set_creative_slot packets. - set_creative_slot: true + # Cancells invalid set_creative_slot packets. (Set to 0 to disable) + set_creative_slot: 1000 # Amount of violations required to cancel. cancel_vls: 400 @@ -101,7 +101,7 @@ packets: # Placeholders: %player% thresholds: - 400: + 500: - "notification" 1000: - "kick" @@ -135,7 +135,7 @@ commands: # Placeholders: %player% thresholds: - 2: + 1: - "kick" - "notification" diff --git a/src/plugin.yml b/src/plugin.yml index de0b627..eb9f7b2 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 0.9.7 +version: 1.0.0 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 852cfcb..b3d9031 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -9,41 +9,56 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class BlockDigPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; + private final ModuleManager moduleManager; public BlockDigPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.BLOCK_DIG); - this.packetsModule = moduleManager.getPacketsModule(); + this.moduleManager = moduleManager; } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); + if (!event.isCancelled()) { + final PacketsModule packetsModule = moduleManager.getPacketsModule(); - if (player != null) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); + if (packetsModule.isEnabled()) { + final int blockDig = packetsModule.getBlockDig(); - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.read(0); + if (blockDig > 0) { + final Player player = event.getPlayer(); - if (itemUse != null) { - final PlayerInventory playerInventory = player.getInventory(); - ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + if (player != null && player.isOnline()) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); - if (itemOnHand == null) - itemOnHand = new ItemStack(Material.AIR); + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.read(0); - if (packetsModule.isBlockDig() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) - event.setCancelled(true); - } + if (itemUse != null) { + final PlayerInventory playerInventory = player.getInventory(); + ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemOnHand == null) + itemOnHand = new ItemStack(Material.AIR); + + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, blockDig); + else + event.setCancelled(true); + } + } + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } - } else if (packetsModule.isOffline()) - event.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 443256b..fe05a68 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -9,41 +9,56 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class BlockPlacePacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; + private final ModuleManager moduleManager; public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.BLOCK_PLACE); - this.packetsModule = moduleManager.getPacketsModule(); + super(plugin, PacketType.Play.Client.BLOCK_DIG); + this.moduleManager = moduleManager; } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); + if (!event.isCancelled()) { + final PacketsModule packetsModule = moduleManager.getPacketsModule(); - if (player != null) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); + if (packetsModule.isEnabled()) { + final int blockPlace = packetsModule.getBlockPlace(); - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.read(0); + if (blockPlace > 0) { + final Player player = event.getPlayer(); - if (itemUse != null) { - final PlayerInventory playerInventory = player.getInventory(); - ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + if (player != null && player.isOnline()) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); - if (itemOnHand == null) - itemOnHand = new ItemStack(Material.AIR); + if (itemModifier != null && itemModifier.size() > 0) { + final ItemStack itemUse = itemModifier.read(0); - if (packetsModule.isBlockPlace() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) - event.setCancelled(true); - } + if (itemUse != null) { + final PlayerInventory playerInventory = player.getInventory(); + ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemOnHand == null) + itemOnHand = new ItemStack(Material.AIR); + + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, blockPlace); + else + event.setCancelled(true); + } + } + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } - } else if (packetsModule.isOffline()) - event.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java new file mode 100644 index 0000000..082a60d --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java @@ -0,0 +1,24 @@ +package twolovers.exploitfixer.bukkit.adapters; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; + +public class CustomPayloadPacketAdapter extends PacketAdapter { + private final CustomPayloadModule customPayloadModule; + + public CustomPayloadPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { + super(plugin, PacketType.Play.Client.CUSTOM_PAYLOAD); + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + if (!event.isCancelled() && customPayloadModule.isEnabled()) { + customPayloadModule.checkPacket(event); + } + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index d33eb80..bd18367 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -6,26 +6,40 @@ import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class SetCreativeSlotPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; + private final ModuleManager moduleManager; public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT); - this.packetsModule = moduleManager.getPacketsModule(); + this.moduleManager = moduleManager; } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); + if (!event.isCancelled()) { + final PacketsModule packetsModule = moduleManager.getPacketsModule(); - if (packetsModule.isOffline() && player == null) - event.setCancelled(true); - if (packetsModule.isSetCreativeSlot() && player != null && player.getGameMode() != GameMode.CREATIVE) - event.setCancelled(true); + if (packetsModule.isEnabled()) { + final Player player = event.getPlayer(); + + if (player != null && player.isOnline()) { + final int setCreativeSlot = packetsModule.getSetCreativeSlot(); + + if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); + else + event.setCancelled(true); + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 34311d5..20b876d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -11,57 +11,87 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class WindowClickPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; + private final ModuleManager moduleManager; public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { super(plugin, PacketType.Play.Client.WINDOW_CLICK); - this.packetsModule = moduleManager.getPacketsModule(); + this.moduleManager = moduleManager; } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Player player = event.getPlayer(); - - if (player != null) { - final PacketContainer packet = event.getPacket(); - final StructureModifier integers = packet.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - - if (packetsModule.isWindowClick() && inventoryView == null) - event.setCancelled(true); - else if (integers.size() > 1) { - final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.readSafely(1); - int maxSlots = inventoryView.countSlots(); - - if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) - maxSlots += 4; - - if (packetsModule.isWindowClick() && slot >= maxSlots) - event.setCancelled(true); - else { - final StructureModifier structureModifier = packet.getItemModifier(); + if (!event.isCancelled()) { + final PacketsModule packetsModule = moduleManager.getPacketsModule(); + + if (packetsModule.isEnabled()) { + final int windowClick = packetsModule.getWindowClick(); + + if (windowClick > 0) { + final Player player = event.getPlayer(); + + if (player != null && player.isOnline()) { + final PacketContainer packet = event.getPacket(); + final StructureModifier integers = packet.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final String playerName = player.getName(); + + if (inventoryView == null) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + else + event.setCancelled(true); + } else if (integers.size() > 1) { + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.readSafely(1); + int maxSlots = inventoryView.countSlots(); - if (structureModifier.size() > 0 && slot > 0) { - final ItemStack itemUse = structureModifier.readSafely(0); + if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) + maxSlots += 4; - if (itemUse != null) { - final ItemStack itemOnHand = inventoryView.getItem(slot); + if (slot >= maxSlots) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); - if (packetsModule.isWindowClick() && (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 256)) + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + else event.setCancelled(true); + } else { + final StructureModifier structureModifier = packet.getItemModifier(); + + if (structureModifier.size() > 0 && slot > 0) { + final ItemStack itemUse = structureModifier.readSafely(0); + + if (itemUse != null) { + try { + final ItemStack itemOnHand = inventoryView.getItem(slot); + + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { + event.setCancelled(true); + } + } catch (final IndexOutOfBoundsException e) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + else + event.setCancelled(true); + } + } + } } } - } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } - } else if (packetsModule.isOffline()) - event.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index 8038cca..23d07b3 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -2,6 +2,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; import com.google.common.base.Charsets; import io.netty.buffer.ByteBuf; import org.bukkit.configuration.Configuration; @@ -84,18 +85,15 @@ public void checkPacket(final Object event) { if (exploitPlayer != null && sender.isOnline()) { final PacketContainer packet = packetEvent.getPacket(); - final String tag = String.valueOf(packet.getModifier().readSafely(0)); + final String tag = String.valueOf(packet.getStrings().readSafely(0)); - if (tag != null && tag.toLowerCase().endsWith("register")) { - final int channels; + if (tag != null && tag.toLowerCase().endsWith("register") && !VersionUtil.isOneDotFifteen()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + final int channels = byteBufModifier.readSafely(0).toString(Charsets.UTF_8).split("\000").length; - if (VersionUtil.isOneDotSeven()) - channels = 1; - else - channels = packet.getSpecificModifier(ByteBuf.class).readSafely(0).toString(Charsets.UTF_8).split("\000").length; - - if (exploitPlayer.addChannels(channels) > maxChannels) + if (exploitPlayer.addChannels(channels) > maxChannels) { exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", multipliers.getOrDefault("OTHER", 1D))); + } } else exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); } /*else if (moduleManager.getPacketsModule().isOffline()) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index d1c7048..24c7b2c 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -4,6 +4,8 @@ import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedBlockData; +import com.comphenix.protocol.wrappers.nbt.NbtBase; +import io.netty.buffer.ByteBuf; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -11,6 +13,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.Thresholds; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -24,8 +27,8 @@ public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; private final Map multipliers = new HashMap<>(); private Thresholds thresholds; - private boolean enabled, bigData, offline, windowClick, setCreativeSlot, blockPlace, blockDig; - private int cancelVls, reduceVls; + private boolean enabled, offline; + private int bigData, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -41,12 +44,12 @@ final public void reload(final Object configYml) { this.enabled = configYml1.getBoolean(name + ".enabled"); this.cancelVls = configYml1.getInt(name + ".cancel_vls"); this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.bigData = configYml1.getBoolean(name + ".big_data"); + this.bigData = configYml1.getInt(name + ".big_data"); this.offline = configYml1.getBoolean(name + ".offline"); - this.windowClick = configYml1.getBoolean(name + ".window_click"); - this.blockPlace = configYml1.getBoolean(name + ".block_place"); - this.blockDig = configYml1.getBoolean(name + ".block_dig"); - this.setCreativeSlot = configYml1.getBoolean(name + ".set_creative_slot"); + this.windowClick = configYml1.getInt(name + ".window_click"); + this.blockPlace = configYml1.getInt(name + ".block_place"); + this.blockDig = configYml1.getInt(name + ".block_dig"); + this.setCreativeSlot = configYml1.getInt(name + ".set_creative_slot"); this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); for (final String key : configurationSection.getKeys(false)) @@ -67,18 +70,29 @@ public boolean isEnabled() { public void checkPacket(final Object packetEvent, final String packetName) { final PacketEvent event = (PacketEvent) packetEvent; final Player player = event.getPlayer(); + ExploitPlayer exploitPlayer = null; - if (!event.isCancelled() && bigData) { + if (player != null && player.isOnline()) { + final String playerName = player.getName(); + exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + } + + if (!event.isCancelled() && bigData > 0) { final PacketContainer packet = event.getPacket(); final StructureModifier itemModifier = packet.getItemModifier(); final StructureModifier blockDataModifier = packet.getBlockData(); final StructureModifier longs = packet.getLongs(); final StructureModifier strings = packet.getStrings(); + final StructureModifier> nbtModifier = packet.getNbtModifier(); int packetSize = 0; - if (itemModifier.size() > 75 || blockDataModifier.size() > 75 || longs.size() > 75 || strings.size() > 75) { - System.out.println("TOO BIG ARRAY"); - event.setCancelled(true); + if (itemModifier.size() > 50 || blockDataModifier.size() > 50 || longs.size() > 50 || strings.size() > 50 || nbtModifier.size() > 50) { + if (exploitPlayer != null) { + exploitPlayer.addVls(plugin, event, player, this, bigData); + } } else { for (final ItemStack itemStack : itemModifier.getValues()) { if (itemStack != null) { @@ -113,50 +127,56 @@ public void checkPacket(final Object packetEvent, final String packetName) { } } - if (packetSize > 20000){ - System.out.println("TOO BIG PACKET"); - event.setCancelled(true); + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + int dataBytes = nbtBase.getValue().toString().length(); + + packetSize += dataBytes; + } } - } - } - if (player != null && player.isOnline()) { - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + if (byteBuf != null) + packetSize += byteBuf.capacity(); + } + } + + if (packetSize > 16000) { + if (exploitPlayer != null) { + exploitPlayer.addVls(plugin, event, player, this, bigData); + } else + event.setCancelled(true); + } + } } } @Override - public boolean isWindowClick() { + public int getWindowClick() { return windowClick; } - @Override - public boolean isBigData() { - return bigData; - } - @Override public boolean isOffline() { return offline; } @Override - public boolean isSetCreativeSlot() { + public int getSetCreativeSlot() { return setCreativeSlot; } @Override - public boolean isBlockPlace() { - return blockPlace; + public int getBlockDig() { + return blockDig; } @Override - public boolean isBlockDig() { - return blockDig; + public int getBlockPlace() { + return blockPlace; } @Override diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index 1bd69ab..31146db 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -77,24 +77,24 @@ public void checkPacket(final Object event) { final PluginMessageEvent pluginMessageEvent = (PluginMessageEvent) event; final Connection sender = pluginMessageEvent.getSender(); - if (sender instanceof ProxiedPlayer) { + if (sender instanceof ProxiedPlayer && sender.isConnected()) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getName()); + final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); + final String tag = pluginMessageEvent.getTag(); - if (exploitPlayer != null) { - final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); - final String tag = pluginMessageEvent.getTag(); + if (tag != null && tag.equals("REGISTER")) { + int channels = content.split("[\u0001-\u0009]").length; - if (tag != null && tag.equals("REGISTER")) { - int channels = content.split("[\u0001-\u0009]").length; - - if (exploitPlayer.addChannels(channels) > maxChannels) - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", 9999D)); - } else { + if (exploitPlayer.addChannels(channels) > maxChannels) + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", 9999D)); + } else { + if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } - } else if (moduleManager.getPacketsModule().isOffline()) - ((PluginMessageEvent) event).setCancelled(true); - } + else if (moduleManager.getPacketsModule().isOffline()) + ((PluginMessageEvent) event).setCancelled(true); + } + } else if (moduleManager.getPacketsModule().isOffline()) + ((PluginMessageEvent) event).setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index 3b2414b..c9972e8 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -10,6 +10,7 @@ public class BungeeMessagesModule implements MessagesModule { public BungeeMessagesModule(final String version, final Configuration messagesYml) { reload(messagesYml); + this.version = version; } @Override diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 353181a..b12e82e 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -3,21 +3,19 @@ public interface PacketsModule extends CancellableModule { void reload(Object configYml); - double getMultiplier(final String packetName); - - boolean isEnabled(); - void checkPacket(final Object packetEvent, final String packetName); - boolean isWindowClick(); + double getMultiplier(final String packetName); + + int getWindowClick(); - boolean isBigData(); + boolean isEnabled(); boolean isOffline(); - boolean isSetCreativeSlot(); + int getSetCreativeSlot(); - boolean isBlockPlace(); + int getBlockPlace(); - boolean isBlockDig(); + int getBlockDig(); } From 9fbc40dc53fb1a2cab35efc5f763ac7c6ef507ab Mon Sep 17 00:00:00 2001 From: Malachiel Date: Fri, 10 Jan 2020 14:11:33 +0100 Subject: [PATCH 031/336] Italian language :) --- src/messages.yml | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/messages.yml b/src/messages.yml index c360a46..55416d1 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -117,4 +117,44 @@ pt: stats: message: |- &fJugadores em cache: &a%players_cached% - &fJogadores punidos: &a%players_punished% \ No newline at end of file + &fJogadores punidos: &a%players_punished% + +# Italian +it: + commands: + reload: "&aPlugin ExploitFixer ricaricato!" + help: |- + &aCommadni di ExploitFixer %version%: + &e/%command% help &7- &bMostra i commandi disponibili! + &e/%command% reload &7- &bRicarica il plugin! + &e/%command% notifications &7- &bCambia le notifiche del plugin! + &e/%command% stats &7- &bMostra le statistiche del plugin! + error: + unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" + permission: "&cNon hai il permesso per questo commando!" + console: "&cQuesto commando non può essere eseguito dalla console!" + notifications: + enable: "&aHai abilitato le notifiche!" + disable: "&cHai disabilitato le notifiche!" + modules: + custompayload: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + uuidspoof: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + commands: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + duplication: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di duplicazione rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + items: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di oggetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + books: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di libri rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + signs: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di cartelli rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + stats: + message: |- + &fGiocatori in cache: &a%players_cached% + &fGiocatori puniti: &a%players_punished% + From 23f73e630f4cfbe694f2b2510cef811d9e45a2b9 Mon Sep 17 00:00:00 2001 From: Malachiel Date: Fri, 10 Jan 2020 14:29:40 +0100 Subject: [PATCH 032/336] Update messages.yml --- src/messages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/messages.yml b/src/messages.yml index 55416d1..f66cf5e 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -153,6 +153,8 @@ it: kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di libri rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" signs: kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di cartelli rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fGiocatori in cache: &a%players_cached% From 6efdecc3c4918ab0ca39477f0e00607661b97efa Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Tue, 28 Jan 2020 19:18:13 -0300 Subject: [PATCH 033/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 166 ++++++------- src/messages.yml | 32 +-- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 2 +- .../adapters/BlockDigPacketAdapter.java | 2 +- .../adapters/BlockPlacePacketAdapter.java | 2 +- .../SetCreativeSlotPacketAdapter.java | 61 ++++- .../adapters/WindowClickPacketAdapter.java | 4 +- .../initializers/AdapterInitializer.java | 11 +- .../bukkit/commands/ExploitFixerCommand.java | 15 +- .../instanceables/BukkitExploitPlayer.java | 32 ++- .../instanceables/BukkitThresholds.java | 34 --- .../instanceables/BukkitViolations.java | 31 +++ .../listeners/InventoryCreativeListener.java | 27 +- .../listeners/PlayerEditBookListener.java | 66 ----- .../bukkit/listeners/PlayerLoginListener.java | 53 ++-- .../listeners/PlayerTabCompleteListener.java | 38 +++ .../bukkit/listeners/SignChangeListener.java | 21 +- .../initializers/ListenerInitializer.java | 2 +- .../bukkit/managers/BukkitModuleManager.java | 34 +-- .../bukkit/modules/BukkitBooksModule.java | 52 ---- .../bukkit/modules/BukkitCommandsModule.java | 24 +- .../modules/BukkitCustomPayloadModule.java | 22 +- .../modules/BukkitDuplicationModule.java | 56 ----- .../bukkit/modules/BukkitItemsFixModule.java | 9 +- .../bukkit/modules/BukkitMessagesModule.java | 21 ++ .../modules/BukkitNotificationsModule.java | 5 +- .../modules/BukkitNullAddressModule.java | 30 +++ .../bukkit/modules/BukkitPacketsModule.java | 231 +++++++++++------- .../bukkit/modules/BukkitSignsModule.java | 29 ++- .../bukkit/modules/BukkitUUIDSpoofModule.java | 28 +-- .../exploitfixer/bungee/ExploitFixer.java | 3 +- .../bungee/commands/ExploitFixerCommand.java | 15 +- .../instanceables/BungeeExploitPlayer.java | 22 +- .../instanceables/BungeeThresholds.java | 35 --- .../instanceables/BungeeViolations.java | 32 +++ .../bungee/listeners/PostLoginListener.java | 66 +++-- .../bungee/managers/BungeeModuleManager.java | 14 +- .../bungee/modules/BungeeCommandsModule.java | 24 +- .../modules/BungeeCustomPayloadModule.java | 28 +-- .../bungee/modules/BungeeMessagesModule.java | 10 + .../modules/BungeeNotificationsModule.java | 8 +- .../modules/BungeeNullAddressModule.java | 30 +++ .../bungee/modules/BungeeUUIDSpoofModule.java | 28 +-- .../{Thresholds.java => Violations.java} | 4 +- .../interfaces/managers/ModuleManager.java | 8 +- .../interfaces/modules/BooksModule.java | 7 - .../interfaces/modules/CancellableModule.java | 8 +- .../interfaces/modules/CommandsModule.java | 2 - .../modules/CustomPayloadModule.java | 4 - .../interfaces/modules/DuplicationModule.java | 9 - .../interfaces/modules/ItemsFixModule.java | 4 +- .../interfaces/modules/MessagesModule.java | 4 +- .../interfaces/modules/Module.java | 2 + .../modules/NotificationsModule.java | 2 +- .../interfaces/modules/PacketsModule.java | 14 +- .../interfaces/modules/ReloadableModule.java | 2 +- .../interfaces/modules/SignsModule.java | 4 +- .../interfaces/modules/UUIDSpoofModule.java | 7 - 60 files changed, 782 insertions(+), 758 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java create mode 100644 src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java create mode 100644 src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java delete mode 100644 src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java create mode 100644 src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java create mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java rename src/twolovers/exploitfixer/interfaces/instanceables/{Thresholds.java => Violations.java} (68%) delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/BooksModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java diff --git a/src/bungee.yml b/src/bungee.yml index 083600c..089da3c 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.0.0 +version: 1.0.5 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 759b5ba..443f442 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,28 +1,34 @@ -# Shows notifications on detection. +# ExploitFixer developed by LinsaFTW. +# +# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands check works on BungeeCord. +# The other checks require to be installed in Spigot with ProtocolLib. +# It is recommended to install the plugin on BungeeCord and all Spigot servers. +# The plugin will increase the performance by limiting and cancelling invalid packets. + notifications: - # Do you want to enable notifications? enabled: true - # Placeholders: %player% %ping% - # %check% gets replaced dynamically by the check. - message: "&c&lEF: &e%player% &f| &6%check% &f| &c%ping%ms" + # Placeholders: %player% %ping% %check% %vls% + message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" + +# Prevents null addresses from fake bungee IP-Forward to bypass IPWhitelist. +# WARNING: This is not a real fix, to fix this you need to host your network on a dedicated/vps machine +# and properly setup a firewall/airgap technique to prevent direct connections to your server. +# Follow this guide: https://www.spigotmc.org/wiki/firewall-guide/ +nulladdress: + enabled: true -# Checks if players have a invalid UUID. +# Checks if players have a invalid UUID. (Works with premium and no premium servers) uuidspoof: # Do you want to enable this module? enabled: true - # Amount of violations required to cancel. - cancel_vls: 1 - - # Amount of violations to reduce per second. - reduce_vls: 1 +# Removes some ItemMeta from items to fix invalid tags, enchants, effects, etc... +itemsfix: + enabled: true - # Placeholders: %player% - thresholds: - 1: - - "kick" - - "notification" + # Maximum enchant level obtainable with creative packets. (Set to 0 to disable custom enchants) + enchant_limit: 0 # Limits custom_payload packets to avoid exploits. custompayload: @@ -46,52 +52,67 @@ custompayload: MC|BOpen: 50 # Placeholders: %player% - thresholds: + violations: 600: - "kick" - "notification" -# Cancels common kinds of invalid packets and limits valid packets. packets: - # Do you want to enable this module? enabled: true - # Cancells packets with big data length. (Set to 0 to disable) - big_data: 1000 + # Amount of vls required to start cancelling packets. + cancel_vls: 400 - # Cancells packets from offline players. - offline: true + # Amount of vls to reduce per second. + reduce_vls: 300 - # Cancells invalid window_click packets. (Set to 0 to disable) - window_click: 1000 + # Blocks different types of invalid packets. + invalid: + # Cancells packets if the player sending it is offline. + offline: true - # Cancells invalid block_place packets. (Set to 0 to disable) - block_place: 1000 + # TIP: Dont disable this and instead increase max_bytes if you have false positives. + big_data: + # Vls to add when too big packets are sent. (Set to 0 to disable) + vls: 1000 - # Cancells invalid block_dig packets. (Set to 0 to disable) - block_dig: 1000 + # Maximum amount of bytes per packet. + max_bytes: 16000 - # Cancells invalid set_creative_slot packets. (Set to 0 to disable) - set_creative_slot: 1000 + # big_data is required to enable this check. (Checks page quantity and bytes) + books: + # Vls to add when invalid book packets are sent. (Set to 0 to disable) + vls: 1000 - # Amount of violations required to cancel. - cancel_vls: 400 + # Maximum amount of bytes per page. (Prevents duplication and crashes) + max_bytes: 256 - # Amount of violations to reduce per second. - reduce_vls: 300 + # Vls to add when invalid window_click packets are sent. (Set to 0 to disable) + # Vls added by null inventoryview is the tenth part of the window_click vls. + window_click: 1000 - # When a valid packet is sent the following amount of violations will be applied. + # Vls to add when invalid block_place packets are sent. (Set to 0 to disable) + block_place: 1000 + + # Vls to add when invalid block_dig packets are sent. (Set to 0 to disable) + block_dig: 1000 + + # Vls to add when invalid set_creative_slot packets are sent. (Set to 0 to disable) + set_creative_slot: 1000 + + # When a valid packet is sent the following amount of vls will be applied. multipliers: ABILITIES: 1 - ARM_ANIMATION: 4.5 - BLOCK_DIG: 4.5 - BLOCK_PLACE: 4.5 + ARM_ANIMATION: 4.25 + BLOCK_DIG: 4.25 + BLOCK_PLACE: 4.25 BLOCK_PLACE_BOOKS: 80 + CUSTOM_PAYLOAD: 0.5 ENTITY_ACTION: 4 - FLYING: 1 - LOOK: 1.5 - POSITION_LOOK: 1.5 - POSITION: 3 + FLYING: 0.5 + LOOK: 1.25 + POSITION_LOOK: 1.25 + POSITION: 2 SET_CREATIVE_SLOT: 1 TAB_COMPLETE: 8 UPDATE_SIGN: 90 @@ -100,7 +121,8 @@ packets: WINDOW_CLICK: 5 # Placeholders: %player% - thresholds: + # Commands to execute when a players reachs a violation level. + violations: 500: - "notification" 1000: @@ -109,14 +131,13 @@ packets: # Checks if players try to crash/exploit the server with commands. commands: - # Do you want to enable this module? enabled: true # Amount of violations required to cancel. cancel_vls: 1 # Amount of violations to reduce per second. - reduce_vls: 1 + reduce_vls: 0 # Commands to detect. commands: @@ -134,32 +155,11 @@ commands: - "/execute" # Placeholders: %player% - thresholds: + violations: 1: - "kick" - "notification" -# Recreates items obtained in creative to remove invalid tags, enchants, etc. -itemsfix: - # Do you want to enable this module? - enabled: true - -# Prevents invalid book creation. -books: - enabled: true - - # Amount of violations required to cancel. - cancel_vls: 1 - - # Amount of violations to reduce per second. - reduce_vls: 1 - - # Placeholders: %player% - thresholds: - 2: - - "kick" - - "notification" - # Prevents invalid sign creation. signs: enabled: true @@ -168,34 +168,12 @@ signs: cancel_vls: 1 # Amount of violations to reduce per second. - reduce_vls: 1 + reduce_vls: 0 - # Placeholders: %player% - thresholds: - 2: - - "kick" - - "notification" - -# Prevents duplication with Signs/Books by cancelling characters of 3 or more bytes long. -duplication: - # Do you want to enable this module? - enabled: true - - # Amount of violations required to cancel. - cancel_vls: 1 - - # Amount of violations to reduce per second. - reduce_vls: 1 - - # Maximum bytes allowed per character. - # Common keyboard characters are 1 byte long. - # Characters with tildes are 2 bytes long. - # Chinese characters are 3 bytes long. - # Emojis are 4 bytes long. - max_bytes: 2 + max_bytes: 34 # Placeholders: %player% - thresholds: - 2: + violations: + 1: - "kick" - "notification" \ No newline at end of file diff --git a/src/messages.yml b/src/messages.yml index c360a46..cbfcd57 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -32,10 +32,10 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - books: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fBooks exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" signs: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fSigns exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fPlayers cached: &a%players_cached% @@ -64,17 +64,17 @@ es: uuidspoof: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" commands: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" duplication: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de duplicacion detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Duplicacion detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - books: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de books detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" signs: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de signs detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Carteles detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores en cache: &a%players_cached% @@ -103,17 +103,17 @@ pt: uuidspoof: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" commands: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" duplication: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de duplicação detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Duplicação detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" items: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - books: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de books detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" signs: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de signs detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Cartazes detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores em cache: &a%players_cached% diff --git a/src/plugin.yml b/src/plugin.yml index eb9f7b2..078c4ee 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.0.0 +version: 1.0.5 author: 2LS api-version: '1.13' softdepend: [ProtocolLib] diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index ba7f492..4b8e69d 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -59,7 +59,7 @@ public void reload() { if (pluginManager.isPluginEnabled("ProtocolLib")) new AdapterInitializer(this, moduleManager); else - getLogger().log(Level.INFO, "[ExploitFixer] Please install ProtocolLib or your server will remain unprotected from exploits!"); + getLogger().log(Level.SEVERE, "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index b3d9031..4f01917 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -27,7 +27,7 @@ public void onPacketReceiving(final PacketEvent event) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); if (packetsModule.isEnabled()) { - final int blockDig = packetsModule.getBlockDig(); + final double blockDig = packetsModule.getBlockDig(); if (blockDig > 0) { final Player player = event.getPlayer(); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index fe05a68..bcc3d79 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -27,7 +27,7 @@ public void onPacketReceiving(final PacketEvent event) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); if (packetsModule.isEnabled()) { - final int blockPlace = packetsModule.getBlockPlace(); + final double blockPlace = packetsModule.getBlockPlace(); if (blockPlace > 0) { final Player player = event.getPlayer(); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index bd18367..e591636 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -3,13 +3,23 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.util.List; +import java.util.Map; + public class SetCreativeSlotPacketAdapter extends PacketAdapter { private final ModuleManager moduleManager; @@ -27,7 +37,8 @@ public void onPacketReceiving(final PacketEvent event) { final Player player = event.getPlayer(); if (player != null && player.isOnline()) { - final int setCreativeSlot = packetsModule.getSetCreativeSlot(); + final ItemsFixModule itemsFixModule = moduleManager.getItemsFixModule(); + final double setCreativeSlot = packetsModule.getSetCreativeSlot(); if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); @@ -36,6 +47,54 @@ public void onPacketReceiving(final PacketEvent event) { exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); else event.setCancelled(true); + } else if (itemsFixModule.isEnabled()) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); + final ItemStack itemStack = itemModifier.readSafely(0); + + if (itemStack != null) { + final Material material = itemStack.getType(); + final ItemMeta itemMeta = itemStack.getItemMeta(); + final int enchantLimit = itemsFixModule.getEnchantLimit(); + final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); + + if (enchantLimit > 0) { + final Map enchantments = itemStackRemake.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + if (enchantments.get(enchantment) > enchantLimit) + itemStackRemake.removeEnchantment(enchantment); + } else { + final Map enchantments = itemStackRemake.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + itemStackRemake.removeEnchantment(enchantment); + } + + if (itemStack.hasItemMeta()) { + final String displayName = itemMeta.getDisplayName(); + final List lore = itemMeta.getLore(); + final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + + if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + final BookMeta newBookMeta = (BookMeta) newItemMeta; + + newBookMeta.setTitle(bookMeta.getTitle()); + newBookMeta.setAuthor(bookMeta.getAuthor()); + newBookMeta.setPages(bookMeta.getPages()); + } + + if (displayName != null && displayName.getBytes().length < 128) + newItemMeta.setDisplayName(displayName); + + if (lore != null && lore.toString().getBytes().length < 1024) + newItemMeta.setLore(lore); + + itemStackRemake.setItemMeta(newItemMeta); + } + + itemModifier.write(0, itemStack); + } } } else if (packetsModule.isOffline()) event.setCancelled(true); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 20b876d..12a7195 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -29,7 +29,7 @@ public void onPacketReceiving(final PacketEvent event) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); if (packetsModule.isEnabled()) { - final int windowClick = packetsModule.getWindowClick(); + final double windowClick = packetsModule.getWindowClick(); if (windowClick > 0) { final Player player = event.getPlayer(); @@ -44,7 +44,7 @@ public void onPacketReceiving(final PacketEvent event) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 10); // Divide by 10 because of false positives else event.setCancelled(true); } else if (integers.size() > 1) { diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 6970e7a..2d115f3 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -6,10 +6,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.*; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; @@ -20,17 +17,19 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.removePacketListeners(plugin); - for (final PacketType packetType : PacketType.Play.Client.getInstance()) + for (final PacketType packetType : PacketType.Play.Client.getInstance()) { protocolManager.addPacketListener(new PacketAdapter(plugin, packetType) { @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) + if (!event.isCancelled() && packetsModule.isEnabled()) packetsModule.checkPacket(event, packetType.name()); } }); + } protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); } diff --git a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 863003a..d269348 100644 --- a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -28,10 +28,17 @@ public boolean onCommand(final CommandSender commandSender, final Command comman String lang = "en"; if (commandSender instanceof Player) - if (VersionUtil.isOneDotFifteen()) - lang = ((Player) commandSender).getLocale().substring(0, 2); - else - lang = ((Player) commandSender).spigot().getLocale().substring(0, 2); + if (VersionUtil.isOneDotFifteen()) { + final String locale = ((Player) commandSender).getLocale(); + + if (locale != null) + lang = locale.substring(0, 2); + } else { + final String locale = ((Player) commandSender).spigot().getLocale(); + + if (locale != null) + lang = locale.substring(0, 2); + } if (length < 1 || args[0].equals("help")) { commandSender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 9b108ab..a4e9b5d 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -1,12 +1,13 @@ package twolovers.exploitfixer.bukkit.instanceables; +import com.comphenix.protocol.events.PacketEvent; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CancellableModule; @@ -85,9 +86,9 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof Player) { - final Thresholds thresholds = module.getThresholds(); + final Violations violations = module.getViolations(); - if (thresholds != null) { + if (violations != null) { final Player player = (Player) playerObject; if (player.isOnline()) { @@ -104,13 +105,13 @@ public void addVls(final Object pluginObject, final Object event, final Object p if (currentTime - lastViolation >= 1000) { lastViolation = currentTime; - for (final CancellableModule violationModule : violations.keySet().toArray(new CancellableModule[0])) { - final double vls = violations.get(violationModule) - violationModule.getReduceVls(); + for (final CancellableModule violationModule : this.violations.keySet().toArray(new CancellableModule[0])) { + final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); if (vls <= 0) - violations.remove(violationModule); + this.violations.remove(violationModule); else - violations.put(violationModule, vls); + this.violations.put(violationModule, vls); } } @@ -118,11 +119,11 @@ public void addVls(final Object pluginObject, final Object event, final Object p final double newVls = oldVls + amount; final String kickMessage = messagesModule.getKickMessage(module, locale); - violations.put(module, newVls); + this.violations.put(module, newVls); - for (final int threshold : thresholds.getThresholds()) + for (final int threshold : violations.getViolations()) { if (threshold > oldVls && threshold <= newVls) { - final Collection commands = thresholds.getCommands(threshold); + final Collection commands = violations.getCommands(threshold); if (commands != null && !commands.isEmpty()) for (final String punishCommand : commands) @@ -131,14 +132,19 @@ public void addVls(final Object pluginObject, final Object event, final Object p server.getScheduler().runTask(plugin, () -> player.kickPlayer(kickMessage)); exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) - notificationsModule.sendNotification(module.getName(), player); + if (event instanceof PacketEvent) + notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); + else + notificationsModule.sendNotification(module.getName(), player, (int) newVls); else server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); } + } - if (event instanceof Cancellable && module.getCancelVls() <= newVls) + if (module.getCancelVls() <= newVls && event instanceof Cancellable) ((Cancellable) event).setCancelled(true); - } + } else if (event instanceof Cancellable) + ((Cancellable) event).setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java deleted file mode 100644 index 10acf29..0000000 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitThresholds.java +++ /dev/null @@ -1,34 +0,0 @@ -package twolovers.exploitfixer.bukkit.instanceables; - -import org.bukkit.configuration.ConfigurationSection; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class BukkitThresholds implements Thresholds { - private Map> thresholds = null; - - public BukkitThresholds(final ConfigurationSection configuration) { - if (configuration != null) - for (final String key : configuration.getKeys(false)) { - try { - if (this.thresholds == null) - this.thresholds = new HashMap<>(); - - this.thresholds.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (NumberFormatException ignored) { - } - } - } - - public Collection getCommands(final int violations) { - return thresholds.getOrDefault(violations, null); - } - - @Override - public Collection getThresholds() { - return thresholds.keySet(); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java new file mode 100644 index 0000000..5e001ed --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java @@ -0,0 +1,31 @@ +package twolovers.exploitfixer.bukkit.instanceables; + +import org.bukkit.configuration.ConfigurationSection; +import twolovers.exploitfixer.interfaces.instanceables.Violations; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class BukkitViolations implements Violations { + private Map> violations = new HashMap<>(); + + public BukkitViolations(final ConfigurationSection configuration) { + if (configuration != null) + for (final String key : configuration.getKeys(false)) { + try { + this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); + } catch (NumberFormatException ignored) { + } + } + } + + public Collection getCommands(final int violations) { + return this.violations.getOrDefault(violations, null); + } + + @Override + public Collection getViolations() { + return violations.keySet(); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java index 021ce99..c5e3cdb 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java @@ -1,17 +1,9 @@ package twolovers.exploitfixer.bukkit.listeners; -import org.bukkit.Material; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryCreativeEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.Potion; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; @@ -24,13 +16,27 @@ public InventoryCreativeListener(final ModuleManager moduleManager) { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryCreative(final InventoryCreativeEvent event) { - final HumanEntity whoClicked = event.getWhoClicked(); + /*final HumanEntity whoClicked = event.getWhoClicked(); if (itemsFixModule.isEnabled() && event.getAction() == InventoryAction.PLACE_ALL && whoClicked instanceof Player) { final ItemStack itemStack = event.getCursor(); final Material material = itemStack.getType(); - ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); final ItemMeta itemMeta = itemStack.getItemMeta(); + final int enchantLimit = itemsFixModule.getEnchantLimit(); + ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); + + if (enchantLimit > 0) { + final Map enchantments = itemStackRemake.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + if (enchantments.get(enchantment) > enchantLimit) + itemStackRemake.removeEnchantment(enchantment); + } else { + final Map enchantments = itemStackRemake.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + itemStackRemake.removeEnchantment(enchantment); + } if (itemMeta != null) { if (itemMeta instanceof PotionMeta) { @@ -54,5 +60,6 @@ public void onInventoryCreative(final InventoryCreativeEvent event) { event.setCursor(itemStackRemake); } + */ } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java deleted file mode 100644 index 237a07f..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerEditBookListener.java +++ /dev/null @@ -1,66 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerEditBookEvent; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.BooksModule; -import twolovers.exploitfixer.interfaces.modules.DuplicationModule; - -import java.nio.charset.StandardCharsets; - -public class PlayerEditBookListener implements Listener { - private final Plugin plugin; - private final DuplicationModule duplicationModule; - private final BooksModule booksModule; - private final ExploitPlayerManager exploitPlayerManager; - - public PlayerEditBookListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.duplicationModule = moduleManager.getDuplicationModule(); - this.booksModule = moduleManager.getBooksModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerEditBook(final PlayerEditBookEvent event) { - final BookMeta bookMeta = event.getNewBookMeta(); - final Player player = event.getPlayer(); - - if (booksModule.isEnabled()) - if (bookMeta == null) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); - event.setNewBookMeta(event.getPreviousBookMeta()); - } else if (bookMeta.getEnchants().size() != 0) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); - event.setNewBookMeta(event.getPreviousBookMeta()); - } else if (bookMeta.getPageCount() > 50) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); - event.setNewBookMeta(event.getPreviousBookMeta()); - } else - for (String page : bookMeta.getPages()) { - if (duplicationModule.isEnabled()) { - for (final String word : page.split("")) { - if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); - event.setNewBookMeta(event.getPreviousBookMeta()); - return; - } - } - } - - if (booksModule.isEnabled()) { - if (page.length() > 340) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, booksModule, 1); - event.setNewBookMeta(event.getPreviousBookMeta()); - return; - } - } - } - } -} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index d4c8bde..cbb18a7 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -6,20 +6,22 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; +import java.net.InetAddress; import java.util.UUID; public class PlayerLoginListener implements Listener { private final Plugin plugin; - private final UUIDSpoofModule uuidSpoofModule; private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; + private final Module uuidSpoofModule, nullAddressModule; private final ExploitPlayerManager exploitPlayerManager; public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { @@ -27,34 +29,49 @@ public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManage this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); + this.nullAddressModule = moduleManager.getNullAddressModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); + final InetAddress address = event.getAddress(); + final String locale; - exploitPlayerManager.add(player.getName()); + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); - if (uuidSpoofModule.isEnabled()) { - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - final String playerName = player.getName(); - final String originalUUID = player.getUniqueId().toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + if (nullAddressModule.isEnabled() && address == null) { + event.setKickMessage(messagesModule.getKickMessage(nullAddressModule, locale)); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + } else { + final String playerName = player.getName(); - if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getName()); - final String onlineUUID = exploitPlayer.getOnlineUUID(); + exploitPlayerManager.add(playerName); - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); + if (uuidSpoofModule.isEnabled()) { + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { + final String originalUUID = player.getUniqueId().toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + + if (!originalUUID.contains(offlineUUID)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); + final String onlineUUID = exploitPlayer.getOnlineUUID(); + + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + event.setKickMessage(messagesModule.getKickMessage(uuidSpoofModule, locale)); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + } } - } - }); - } + }); + } - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(player, true); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java new file mode 100644 index 0000000..991337d --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java @@ -0,0 +1,38 @@ +package twolovers.exploitfixer.bukkit.listeners; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.server.TabCompleteEvent; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; +import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CommandsModule; + +public class PlayerTabCompleteListener implements Listener { + private final Plugin plugin; + private final CommandsModule commandsModule; + private final ExploitPlayerManager exploitPlayerManager; + + public PlayerTabCompleteListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.commandsModule = moduleManager.getCommandsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerCommand(final TabCompleteEvent event) { + if (commandsModule.isEnabled() && event.getSender() instanceof Player) { + final String message = event.getBuffer().replaceAll("[\\w]+:", "").toLowerCase(); + + for (final String command : commandsModule.getCommands()) + if (message.startsWith(command + " ") || message.endsWith(command)) { + final Player player = (Player) event.getSender(); + + exploitPlayerManager.get(player.getName()).addVls(plugin, commandsModule, player, commandsModule, 1); + break; + } + } + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index d3a3c13..1b1751a 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -8,42 +8,33 @@ import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.DuplicationModule; import twolovers.exploitfixer.interfaces.modules.SignsModule; import java.nio.charset.StandardCharsets; public class SignChangeListener implements Listener { private final Plugin plugin; - private final DuplicationModule duplicationModule; private final SignsModule signsModule; private final ExploitPlayerManager exploitPlayerManager; public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.duplicationModule = moduleManager.getDuplicationModule(); this.signsModule = moduleManager.getSignsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onSignChange(final SignChangeEvent event) { - final Player player = event.getPlayer(); + if (signsModule.isEnabled()) { + final Player player = event.getPlayer(); - for (String line : event.getLines()) { - if (duplicationModule.isEnabled()) { - for (String word : line.split("")) { - if (word.getBytes(StandardCharsets.UTF_8).length > duplicationModule.getMaxBytes()) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, duplicationModule, 1); - return; - } - } - } - - if (signsModule.isEnabled()) { + for (String line : event.getLines()) { if (line.length() >= 46) { exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, signsModule, 1); return; + } else if (line.getBytes(StandardCharsets.UTF_8).length > signsModule.getMaxBytes()) { + exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, signsModule, 1); + return; } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 78d7f41..5913813 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -13,9 +13,9 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage HandlerList.unregisterAll(plugin); pluginManager.registerEvents(new InventoryCreativeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PlayerEditBookListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerTabCompleteListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new SignChangeListener(plugin, moduleManager), plugin); } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 6eec29d..9772df9 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -13,12 +13,10 @@ public class BukkitModuleManager implements ModuleManager { private ItemsFixModule itemsFixModule; private MessagesModule messagesModule; private NotificationsModule notificationsModule; - private UUIDSpoofModule uuidSpoofModule; private PacketsModule packetsModule; private ExploitPlayerManager exploitPlayerManager; - private DuplicationModule duplicationModule; - private BooksModule booksModule; private SignsModule signsModule; + private ReloadableModule uuidSpoofModule, nullAddressModule; public BukkitModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { commandsModule = new BukkitCommandsModule(configYml); @@ -29,9 +27,8 @@ public BukkitModuleManager(final Plugin plugin, final Configuration configYml, f uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); packetsModule = new BukkitPacketsModule(plugin, this, configYml); exploitPlayerManager = new BukkitExploitPlayerManager(this); - duplicationModule = new BukkitDuplicationModule(configYml); - booksModule = new BukkitBooksModule(configYml); signsModule = new BukkitSignsModule(configYml); + nullAddressModule = new BukkitNullAddressModule(configYml); } public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { @@ -43,52 +40,57 @@ public void reload(final Object configYml, final Object messagesYml, final Objec uuidSpoofModule.reload(configYml); packetsModule.reload(configYml); exploitPlayerManager.reload(); - duplicationModule.reload(configYml); - booksModule.reload(configYml); signsModule.reload(configYml); + nullAddressModule.reload(configYml); } + @Override public CommandsModule getCommandsModule() { return commandsModule; } + @Override public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } + @Override public ItemsFixModule getItemsFixModule() { return itemsFixModule; } + @Override public MessagesModule getMessagesModule() { return messagesModule; } + @Override public NotificationsModule getNotificationsModule() { return notificationsModule; } + @Override public ExploitPlayerManager getExploitPlayerManager() { return exploitPlayerManager; } - public DuplicationModule getDuplicationModule() { - return duplicationModule; - } - - public UUIDSpoofModule getUUIDSpoofModule() { + @Override + public ReloadableModule getUUIDSpoofModule() { return uuidSpoofModule; } + @Override public PacketsModule getPacketsModule() { return packetsModule; } - public SignsModule getSignsModule() { - return signsModule; + @Override + public ReloadableModule getNullAddressModule() { + return nullAddressModule; } - public BooksModule getBooksModule() { - return booksModule; + @Override + public SignsModule getSignsModule() { + return signsModule; } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java deleted file mode 100644 index 75bd167..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitBooksModule.java +++ /dev/null @@ -1,52 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; -import twolovers.exploitfixer.interfaces.modules.BooksModule; - -public class BukkitBooksModule implements BooksModule { - private Thresholds thresholds; - private int cancelVls, reduceVls; - private boolean enabled; - - public BukkitBooksModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "Books"; - } - - @Override - public int getCancelVls() { - return cancelVls; - } - - @Override - public int getReduceVls() { - return reduceVls; - } - - @Override - public Thresholds getThresholds() { - return thresholds; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java index 0ac5182..489b294 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java @@ -1,16 +1,16 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.modules.CommandsModule; import java.util.Collection; public class BukkitCommandsModule implements CommandsModule { private Collection commands; - private Thresholds thresholds; - private int cancelVls, reduceVls; + private Violations violations; + private double cancelVls, reduceVls; private boolean enabled; public BukkitCommandsModule(final Object configYml) { @@ -18,7 +18,7 @@ public BukkitCommandsModule(final Object configYml) { } @Override - final public Boolean isEnabled() { + final public boolean isEnabled() { return enabled; } @@ -28,18 +28,18 @@ public String getName() { } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } @Override - public Thresholds getThresholds() { - return thresholds; + public Violations getViolations() { + return violations; } @Override @@ -53,9 +53,9 @@ public void reload(Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); this.commands = configYml1.getStringList("commands.commands"); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index 23d07b3..b5410df 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -9,10 +9,10 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; @@ -23,9 +23,9 @@ public class BukkitCustomPayloadModule implements CustomPayloadModule { private Map multipliers = new HashMap<>(); private Plugin plugin; private ModuleManager moduleManager; - private Thresholds thresholds; + private Violations violations; private int maxChannels; - private int cancelVls, reduceVls; + private double cancelVls, reduceVls; private boolean enabled; public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { @@ -36,18 +36,18 @@ public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager module } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } @Override - public Thresholds getThresholds() { - return thresholds; + public Violations getViolations() { + return violations; } @Override @@ -67,9 +67,9 @@ public void reload(final Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); this.maxChannels = configYml1.getInt("custompayload.max_channels"); for (final String key : configurationSection.getKeys(false)) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java deleted file mode 100644 index d3b1e6d..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitDuplicationModule.java +++ /dev/null @@ -1,56 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; -import twolovers.exploitfixer.interfaces.modules.DuplicationModule; - -public class BukkitDuplicationModule implements DuplicationModule { - private boolean enabled; - private int maxBytes; - private int cancelVls, reduceVls; - private Thresholds thresholds; - - public BukkitDuplicationModule(final Object configYml) { - reload(configYml); - } - - final public void reload(final Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); - this.maxBytes = configYml1.getInt("duplication.max_bytes"); - } - - final public Boolean isEnabled() { - return enabled; - } - - @Override - public int getMaxBytes() { - return maxBytes; - } - - public String getName() { - return "Duplication"; - } - - @Override - public int getCancelVls() { - return cancelVls; - } - - @Override - public int getReduceVls() { - return reduceVls; - } - - @Override - public Thresholds getThresholds() { - return thresholds; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index acea5b0..85f2714 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -5,6 +5,7 @@ public class BukkitItemsFixModule implements ItemsFixModule { private boolean enabled; + private int enchantLimit; public BukkitItemsFixModule(final Object configYml) { reload(configYml); @@ -15,10 +16,11 @@ final public void reload(final Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); + this.enchantLimit = configYml1.getInt(name + ".enchant_limit"); } @Override - final public Boolean isEnabled() { + final public boolean isEnabled() { return enabled; } @@ -26,4 +28,9 @@ final public Boolean isEnabled() { public String getName() { return "ItemsFix"; } + + @Override + public int getEnchantLimit() { + return enchantLimit; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java index cb23cec..6b758f8 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -13,6 +13,7 @@ public BukkitMessagesModule(final String version, final Configuration messagesYm reload(messagesYml); } + @Override public String getString(String locale, final String path) { String string; @@ -32,44 +33,64 @@ public String getString(String locale, final String path) { return string; } + @Override public final String getReload(final String locale) { return getString(locale, ".commands.reload"); } + @Override public final String getHelp(final String locale) { return getString(locale, ".commands.help") .replace("%version%", version); } + @Override public final String getUnknown(final String locale) { return getString(locale, ".commands.error.unknown"); } + @Override public final String getPermission(final String locale) { return getString(locale, ".commands.error.permission"); } + @Override public final String getConsole(final String locale) { return getString(locale, ".commands.error.console"); } + @Override public final String getEnable(final String locale) { return getString(locale, ".commands.notifications.enable"); } + @Override public final String getDisable(final String locale) { return getString(locale, ".commands.notifications.disable"); } + @Override public final String getKickMessage(final Module module, final String locale) { return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); } + @Override public void reload(Object messagesYml) { this.messagesYml = (Configuration) messagesYml; } + @Override public String getStats(String locale) { return getString(locale, ".modules.stats.message"); } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return "Messages"; + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java index 44add06..91aee96 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java @@ -30,7 +30,7 @@ public final boolean isNotifications(final Object player) { return notifications.contains(player); } - public void sendNotification(final String check, final Object player) { + public void sendNotification(final String check, final Object player, final int violations) { if (enabled && player != null) { final Player player1 = (Player) player; final ConsoleCommandSender consoleCommandSender = Bukkit.getConsoleSender(); @@ -45,7 +45,8 @@ public void sendNotification(final String check, final Object player) { final String notification = message .replace("%player%", player1.getName()) .replace("%check%", check) - .replace("%ping%", String.valueOf(ping)); + .replace("%ping%", String.valueOf(ping)) + .replace("%vls%", String.valueOf(violations)); consoleCommandSender.sendMessage(notification); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java new file mode 100644 index 0000000..eebb0e8 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java @@ -0,0 +1,30 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.interfaces.modules.ReloadableModule; + +public class BukkitNullAddressModule implements ReloadableModule { + private boolean enabled; + + public BukkitNullAddressModule(final Object configYml) { + reload(configYml); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "NullAddress"; + } + + @Override + public void reload(Object configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final String name = getName().toLowerCase(); + + this.enabled = configYml1.getBoolean(name + ".enabled"); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 24c7b2c..0497bc9 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -6,29 +6,36 @@ import com.comphenix.protocol.wrappers.WrappedBlockData; import com.comphenix.protocol.wrappers.nbt.NbtBase; import io.netty.buffer.ByteBuf; +import org.bukkit.block.BlockState; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; +import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; public class BukkitPacketsModule implements PacketsModule { private final Plugin plugin; private final ModuleManager moduleManager; private final Map multipliers = new HashMap<>(); - private Thresholds thresholds; + private Violations violations; + private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls, booksVls; + private int booksMaxBytes; private boolean enabled, offline; - private int bigData, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -42,15 +49,18 @@ final public void reload(final Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.bigData = configYml1.getInt(name + ".big_data"); - this.offline = configYml1.getBoolean(name + ".offline"); - this.windowClick = configYml1.getInt(name + ".window_click"); - this.blockPlace = configYml1.getInt(name + ".block_place"); - this.blockDig = configYml1.getInt(name + ".block_dig"); - this.setCreativeSlot = configYml1.getInt(name + ".set_creative_slot"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.offline = configYml1.getBoolean(name + ".invalid.offline"); + this.booksVls = configYml1.getDouble(name + ".invalid.books.vls"); + this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); + this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); + this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes"); + this.windowClick = configYml1.getDouble(name + ".invalid.window_click"); + this.blockPlace = configYml1.getDouble(name + ".invalid.block_place"); + this.blockDig = configYml1.getDouble(name + ".invalid.block_dig"); + this.setCreativeSlot = configYml1.getDouble(name + ".invalid.set_creative_slot"); + this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); for (final String key : configurationSection.getKeys(false)) multipliers.put(key, configurationSection.getDouble(key)); @@ -70,112 +80,102 @@ public boolean isEnabled() { public void checkPacket(final Object packetEvent, final String packetName) { final PacketEvent event = (PacketEvent) packetEvent; final Player player = event.getPlayer(); - ExploitPlayer exploitPlayer = null; if (player != null && player.isOnline()) { final String playerName = player.getName(); - exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + + if (bigDataVls > 0) { + final PacketContainer packet = event.getPacket(); + final StructureModifier itemModifier = packet.getItemModifier(); + final StructureModifier blockDataModifier = packet.getBlockData(); + final StructureModifier longs = packet.getLongs(); + final StructureModifier strings = packet.getStrings(); + final StructureModifier> nbtModifier = packet.getNbtModifier(); + final AtomicInteger packetSize = new AtomicInteger(0); + + if (itemModifier.size() > 50 || blockDataModifier.size() > 50 || longs.size() > 50 || strings.size() > 50 || nbtModifier.size() > 50) { + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + else + event.setCancelled(true); + } else { + for (final ItemStack itemStack : itemModifier.getValues()) { + if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) + break; + } - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); - } + if (!event.isCancelled()) { + for (final WrappedBlockData blockData : blockDataModifier.getValues()) { + if (blockData != null) { + int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; - if (!event.isCancelled() && bigData > 0) { - final PacketContainer packet = event.getPacket(); - final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier blockDataModifier = packet.getBlockData(); - final StructureModifier longs = packet.getLongs(); - final StructureModifier strings = packet.getStrings(); - final StructureModifier> nbtModifier = packet.getNbtModifier(); - int packetSize = 0; - - if (itemModifier.size() > 50 || blockDataModifier.size() > 50 || longs.size() > 50 || strings.size() > 50 || nbtModifier.size() > 50) { - if (exploitPlayer != null) { - exploitPlayer.addVls(plugin, event, player, this, bigData); - } - } else { - for (final ItemStack itemStack : itemModifier.getValues()) { - if (itemStack != null) { - int dataBytes = itemStack.getData().toString().getBytes().length; - - if (itemStack.hasItemMeta()) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - try { - dataBytes += itemMeta.toString().getBytes().length; - } catch (final NullPointerException e) { - dataBytes += String.valueOf(itemMeta).getBytes().length; + packetSize.addAndGet(dataBytes); } } - packetSize += dataBytes; - } - } + for (final String string : strings.getValues()) { + if (string != null) { + int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - for (final WrappedBlockData blockData : blockDataModifier.getValues()) { - if (blockData != null) { - int dataBytes = blockData.toString().getBytes().length; - - packetSize += dataBytes; - } - } - - for (final String string : strings.getValues()) { - if (string != null) { - int dataBytes = string.getBytes().length; + packetSize.addAndGet(dataBytes); + } + } - packetSize += dataBytes; - } - } + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + int dataBytes = nbtBase.getValue().toString().length(); - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - int dataBytes = nbtBase.getValue().toString().length(); + packetSize.addAndGet(dataBytes); + } + } - packetSize += dataBytes; - } - } + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + if (byteBuf != null) + packetSize.addAndGet(byteBuf.capacity()); + } + } - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - if (byteBuf != null) - packetSize += byteBuf.capacity(); + if (packetSize.get() > bigDataMaxBytes) { + if (exploitPlayer != null) { + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + } else + event.setCancelled(true); + } } } - - if (packetSize > 16000) { - if (exploitPlayer != null) { - exploitPlayer.addVls(plugin, event, player, this, bigData); - } else - event.setCancelled(true); - } } + + if (!event.isCancelled() && exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); } } @Override - public int getWindowClick() { - return windowClick; + public boolean isOffline() { + return offline; } @Override - public boolean isOffline() { - return offline; + public double getWindowClick() { + return windowClick; } @Override - public int getSetCreativeSlot() { + public double getSetCreativeSlot() { return setCreativeSlot; } @Override - public int getBlockDig() { + public double getBlockDig() { return blockDig; } @Override - public int getBlockPlace() { + public double getBlockPlace() { return blockPlace; } @@ -185,16 +185,71 @@ public String getName() { } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } - public Thresholds getThresholds() { - return thresholds; + @Override + public Violations getViolations() { + return violations; + } + + public boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, final Player player, final AtomicInteger packetSize) { + if (itemStack != null && !event.isCancelled()) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + + if (itemMeta != null) { + try { + dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) + checkItem(itemStack1, event, exploitPlayer, player, packetSize); + } + } + } else if (booksVls > 0 && itemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + + if (bookMeta.getPageCount() > 50) { + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, booksVls); + else + event.setCancelled(true); + } else { + for (String page : bookMeta.getPages()) { + + if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, this, booksVls); + else + event.setCancelled(true); + } + } + } + } + } + + packetSize.addAndGet(dataBytes); + + return false; + } else + return true; } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java index c86c926..8abc4c6 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java @@ -1,14 +1,15 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.modules.SignsModule; public class BukkitSignsModule implements SignsModule { private boolean enabled; - private int cancelVls, reduceVls; - private Thresholds thresholds; + private double cancelVls, reduceVls; + private int maxBytes; + private Violations violations; public BukkitSignsModule(final Object configYml) { reload(configYml); @@ -25,18 +26,18 @@ public String getName() { } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } @Override - public Thresholds getThresholds() { - return thresholds; + public Violations getViolations() { + return violations; } @Override @@ -45,8 +46,14 @@ public void reload(Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); + this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.maxBytes = configYml1.getInt(name + ".max_bytes"); + this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); + } + + @Override + public int getMaxBytes() { + return maxBytes; } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java index b066d11..f2d11f4 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java @@ -1,21 +1,17 @@ package twolovers.exploitfixer.bukkit.modules; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; -import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; +import twolovers.exploitfixer.interfaces.modules.ReloadableModule; -public class BukkitUUIDSpoofModule implements UUIDSpoofModule { +public class BukkitUUIDSpoofModule implements ReloadableModule { private boolean enabled; - private int cancelVls, reduceVls; - private Thresholds thresholds; public BukkitUUIDSpoofModule(final Object configYml) { reload(configYml); } @Override - final public Boolean isEnabled() { + final public boolean isEnabled() { return enabled; } @@ -24,29 +20,11 @@ public String getName() { return "UUIDSpoof"; } - @Override - public int getCancelVls() { - return cancelVls; - } - - @Override - public int getReduceVls() { - return reduceVls; - } - - @Override - public Thresholds getThresholds() { - return thresholds; - } - @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BukkitThresholds(configYml1.getConfigurationSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/twolovers/exploitfixer/bungee/ExploitFixer.java index 500bd48..e6b7b4e 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bungee/ExploitFixer.java @@ -59,8 +59,7 @@ public void reload() { pluginManager.registerListener(this, new PostLoginListener(this, moduleManager)); pluginManager.unregisterCommands(this); - pluginManager.registerCommand(this, new ExploitFixerCommand("exploitfixer", moduleManager)); - pluginManager.registerCommand(this, new ExploitFixerCommand("ef", moduleManager)); + pluginManager.registerCommand(this, new ExploitFixerCommand("exploitfixer", new String[]{"ef"}, moduleManager)); } public static ExploitFixer getInstance() { diff --git a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java index 0a78027..9a54fc9 100644 --- a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -10,24 +10,31 @@ import twolovers.exploitfixer.interfaces.modules.MessagesModule; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import java.util.Locale; + public class ExploitFixerCommand extends Command { private MessagesModule messagesModule; private NotificationsModule notificationsVariables; private ExploitPlayerManager exploitPlayerManager; - public ExploitFixerCommand(final String string, final ModuleManager moduleManager) { - super(string); + public ExploitFixerCommand(final String string, final String[] aliases, final ModuleManager moduleManager) { + super(string, null, aliases); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsVariables = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } + @Override public void execute(final CommandSender commandSender, final String[] args) { String lang = "en"; final int length = args.length; - if (commandSender instanceof ProxiedPlayer) - lang = ((ProxiedPlayer) commandSender).getLocale().toLanguageTag().substring(0, 2); + if (commandSender instanceof ProxiedPlayer) { + final Locale locale = ((ProxiedPlayer) commandSender).getLocale(); + + if (locale != null) + lang = locale.toLanguageTag().substring(0, 2); + } if (length < 1 || args[0].equals("help")) { commandSender.sendMessage(new TextComponent(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index b0f89a2..9b6b1ad 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -5,7 +5,7 @@ import net.md_5.bungee.api.plugin.Cancellable; import net.md_5.bungee.api.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CancellableModule; @@ -88,9 +88,9 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof ProxiedPlayer) { - final Thresholds thresholds = module.getThresholds(); + final Violations violations = module.getViolations(); - if (thresholds != null) { + if (violations != null) { final ProxiedPlayer player = (ProxiedPlayer) playerObject; if (player.isConnected()) { @@ -103,13 +103,13 @@ public void addVls(final Object pluginObject, final Object event, final Object p if (currentTime - lastViolation >= 1000) { lastViolation = currentTime; - for (final CancellableModule violationModule : violations.keySet().toArray(new CancellableModule[0])) { - final double vls = violations.get(violationModule) - violationModule.getReduceVls(); + for (final CancellableModule violationModule : this.violations.keySet().toArray(new CancellableModule[0])) { + final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); if (vls <= 0) - violations.remove(violationModule); + this.violations.remove(violationModule); else - violations.put(violationModule, vls); + this.violations.put(violationModule, vls); } } @@ -121,11 +121,11 @@ public void addVls(final Object pluginObject, final Object event, final Object p final String kickMessage = messagesModule.getKickMessage(module, lang); - violations.put(module, newVls); + this.violations.put(module, newVls); - for (final int threshold : thresholds.getThresholds()) + for (final int threshold : violations.getViolations()) if (threshold > oldVls && threshold <= newVls) { - final Collection commands = thresholds.getCommands(threshold); + final Collection commands = violations.getCommands(threshold); if (commands != null && !commands.isEmpty()) for (final String punishCommand : commands) @@ -134,7 +134,7 @@ public void addVls(final Object pluginObject, final Object event, final Object p player.disconnect(kickMessage); exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) - notificationsModule.sendNotification(module.getName(), player); + notificationsModule.sendNotification(module.getName(), player, (int) newVls); else server.getPluginManager().dispatchCommand(server.getConsole(), punishCommand.replace("%player%", player.getName())); } diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java deleted file mode 100644 index bc43155..0000000 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeThresholds.java +++ /dev/null @@ -1,35 +0,0 @@ -package twolovers.exploitfixer.bungee.instanceables; - -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class BungeeThresholds implements Thresholds { - private Map> thresholds = null; - - public BungeeThresholds(final Configuration configuration) { - if (configuration != null) - for (final String key : configuration.getKeys()) { - try { - if (this.thresholds == null) - this.thresholds = new HashMap<>(); - - this.thresholds.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (NumberFormatException ignored) { - } - } - } - - @Override - public Collection getCommands(final int violations) { - return thresholds.getOrDefault(violations, null); - } - - @Override - public Collection getThresholds() { - return thresholds.keySet(); - } -} diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java new file mode 100644 index 0000000..fefa3d6 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java @@ -0,0 +1,32 @@ +package twolovers.exploitfixer.bungee.instanceables; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.interfaces.instanceables.Violations; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class BungeeViolations implements Violations { + private Map> violations = new HashMap<>(); + + public BungeeViolations(final Configuration configuration) { + if (configuration != null) + for (final String key : configuration.getKeys()) { + try { + this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); + } catch (NumberFormatException ignored) { + } + } + } + + @Override + public Collection getCommands(final int violations) { + return this.violations.getOrDefault(violations, null); + } + + @Override + public Collection getViolations() { + return violations.keySet(); + } +} diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index b95244b..d05f650 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bungee.listeners; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.plugin.Listener; @@ -9,49 +10,68 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.MessagesModule; +import twolovers.exploitfixer.interfaces.modules.Module; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; +import java.net.InetSocketAddress; +import java.util.Locale; import java.util.UUID; public class PostLoginListener implements Listener { - final private Plugin plugin; - final private UUIDSpoofModule uuidSpoofModule; - final private NotificationsModule notificationsModule; - final private ExploitPlayerManager exploitPlayerManager; + private final Plugin plugin; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + private final Module uuidSpoofModule, nullAddressModule; + private final ExploitPlayerManager exploitPlayerManager; public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); + this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); + this.nullAddressModule = moduleManager.getNullAddressModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(final PostLoginEvent event) { final ProxiedPlayer player = event.getPlayer(); - final String playerName = player.getName(); - final UUID uuid = player.getUniqueId(); + final InetSocketAddress address = player.getAddress(); + final Locale locale = player.getLocale(); + final String lang; - exploitPlayerManager.add(playerName); + if (locale != null) + lang = locale.toLanguageTag().substring(0, 2); + else + lang = "en"; - if (uuidSpoofModule.isEnabled()) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + if (nullAddressModule.isEnabled() && address == null) { + player.disconnect(new TextComponent(messagesModule.getKickMessage(nullAddressModule, lang))); + } else { + final String playerName = player.getName(); - if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); - final String onlineUUID = exploitPlayer.getOnlineUUID(); + exploitPlayerManager.add(playerName); - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) - exploitPlayer.addVls(plugin, event, player, uuidSpoofModule, 1); - } - }); - } + if (uuidSpoofModule.isEnabled()) { + plugin.getProxy().getScheduler().runAsync(plugin, () -> { + final String originalUUID = player.getUniqueId().toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + + if (!originalUUID.contains(offlineUUID)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); + final String onlineUUID = exploitPlayer.getOnlineUUID(); + + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + player.disconnect(new TextComponent(messagesModule.getKickMessage(uuidSpoofModule, lang))); + } + } + }); + } - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(player, true); + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index f91a16a..86946f2 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -12,7 +12,7 @@ public class BungeeModuleManager implements ModuleManager { private CustomPayloadModule customPayloadModule; private MessagesModule messagesModule; private NotificationsModule notificationsModule; - private UUIDSpoofModule uuidSpoofModule; + private ReloadableModule uuidSpoofModule, nullAddressModule; private ExploitPlayerManager exploitPlayerManager; public BungeeModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { @@ -21,6 +21,7 @@ public BungeeModuleManager(final Plugin plugin, final Configuration configYml, f messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); notificationsModule = new BungeeNotificationsModule(configYml); uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); + nullAddressModule = new BungeeNullAddressModule(configYml); exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); } @@ -64,11 +65,6 @@ public ExploitPlayerManager getExploitPlayerManager() { return exploitPlayerManager; } - @Override - public BooksModule getBooksModule() { - return null; - } - @Override public SignsModule getSignsModule() { return null; @@ -80,12 +76,12 @@ public PacketsModule getPacketsModule() { } @Override - public DuplicationModule getDuplicationModule() { - return null; + public ReloadableModule getNullAddressModule() { + return nullAddressModule; } @Override - public UUIDSpoofModule getUUIDSpoofModule() { + public ReloadableModule getUUIDSpoofModule() { return uuidSpoofModule; } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java index e48e1c5..b0f4cf7 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java @@ -1,8 +1,8 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.bungee.instanceables.BungeeViolations; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.modules.CommandsModule; import java.util.Collection; @@ -10,15 +10,15 @@ public class BungeeCommandsModule implements CommandsModule { private Collection commands; private boolean enabled; - private int cancelVls, reduceVls; - private Thresholds thresholds; + private double cancelVls, reduceVls; + private Violations violations; public BungeeCommandsModule(final Object configYml) { reload(configYml); } @Override - final public Boolean isEnabled() { + final public boolean isEnabled() { return enabled; } @@ -28,18 +28,18 @@ public String getName() { } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } @Override - public Thresholds getThresholds() { - return thresholds; + public Violations getViolations() { + return violations; } @Override @@ -53,9 +53,9 @@ public void reload(Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BungeeThresholds(configYml1.getSection(name + ".thresholds")); + this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.violations = new BungeeViolations(configYml1.getSection(name + ".violations")); this.commands = configYml1.getStringList("commands.commands"); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index 31146db..d3ff7b4 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -6,9 +6,9 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; +import twolovers.exploitfixer.bungee.instanceables.BungeeViolations; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; @@ -19,8 +19,9 @@ public class BungeeCustomPayloadModule implements CustomPayloadModule { private Map multipliers = new HashMap<>(); private Plugin plugin; private ModuleManager moduleManager; - private Thresholds thresholds; - private int maxChannels, cancelVls, reduceVls; + private Violations violations; + private double cancelVls, reduceVls; + private int maxChannels; private boolean enabled; public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { @@ -31,18 +32,18 @@ public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager module } @Override - public int getCancelVls() { + public double getCancelVls() { return cancelVls; } @Override - public int getReduceVls() { + public double getReduceVls() { return reduceVls; } @Override - public Thresholds getThresholds() { - return thresholds; + public Violations getViolations() { + return violations; } @Override @@ -62,9 +63,9 @@ public void reload(final Object configYml) { final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean("custompayload.enabled"); - this.cancelVls = configYml1.getInt("custompayload.cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BungeeThresholds(configYml1.getSection("custompayload.thresholds")); + this.cancelVls = configYml1.getDouble("custompayload.cancel_vls"); + this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.violations = new BungeeViolations(configYml1.getSection("custompayload.violations")); this.maxChannels = configYml1.getInt("custompayload.max_channels"); for (final String key : configurationSection.getKeys()) @@ -90,11 +91,8 @@ public void checkPacket(final Object event) { } else { if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - else if (moduleManager.getPacketsModule().isOffline()) - ((PluginMessageEvent) event).setCancelled(true); } - } else if (moduleManager.getPacketsModule().isOffline()) - ((PluginMessageEvent) event).setCancelled(true); + } } } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java index c9972e8..d651eed 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -78,4 +78,14 @@ public void reload(Object messagesYml) { public String getStats(String locale) { return getString(locale, ".modules.stats.message"); } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return "Messages"; + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java index 923c3ee..3e804c8 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.config.Configuration; @@ -32,13 +33,14 @@ public final boolean isNotifications(final Object player) { } @Override - public void sendNotification(final String check, final Object player) { + public void sendNotification(final String check, final Object player, final int violations) { if (enabled && player != null) { final ProxiedPlayer player1 = (ProxiedPlayer) player; final TextComponent notification = new TextComponent(message .replace("%player%", player1.getName()) .replace("%check%", check) - .replace("%ping%", String.valueOf(player1.getPing()))); + .replace("%ping%", String.valueOf(player1.getPing())) + .replace("%vls%", String.valueOf(violations))); BungeeCord.getInstance().getConsole().sendMessage(notification); @@ -57,6 +59,6 @@ public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; enabled = configYml1.getBoolean("notifications.enabled"); - message = configYml1.getString("notifications.message").replace("&", "\u00A7"); + message = ChatColor.translateAlternateColorCodes('&', configYml1.getString("notifications.message")); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java new file mode 100644 index 0000000..6cfb720 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java @@ -0,0 +1,30 @@ +package twolovers.exploitfixer.bungee.modules; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.interfaces.modules.ReloadableModule; + +public class BungeeNullAddressModule implements ReloadableModule { + private boolean enabled; + + public BungeeNullAddressModule(final Object configYml) { + reload(configYml); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "NullAddress"; + } + + @Override + public void reload(Object configYml) { + final Configuration configYml1 = (Configuration) configYml; + final String name = getName().toLowerCase(); + + this.enabled = configYml1.getBoolean(name + ".enabled"); + } +} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java index 63526bd..8629f58 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java @@ -1,21 +1,17 @@ package twolovers.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.BungeeThresholds; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; -import twolovers.exploitfixer.interfaces.modules.UUIDSpoofModule; +import twolovers.exploitfixer.interfaces.modules.ReloadableModule; -public class BungeeUUIDSpoofModule implements UUIDSpoofModule { +public class BungeeUUIDSpoofModule implements ReloadableModule { private boolean enabled; - private int cancelVls, reduceVls; - private Thresholds thresholds; public BungeeUUIDSpoofModule(final Object configYml) { reload(configYml); } @Override - final public Boolean isEnabled() { + final public boolean isEnabled() { return enabled; } @@ -24,29 +20,11 @@ public String getName() { return "UUIDSpoof"; } - @Override - public int getCancelVls() { - return cancelVls; - } - - @Override - public int getReduceVls() { - return reduceVls; - } - - @Override - public Thresholds getThresholds() { - return thresholds; - } - @Override public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getInt(name + ".cancel_vls"); - this.reduceVls = configYml1.getInt(name + ".reduce_vls"); - this.thresholds = new BungeeThresholds(configYml1.getSection(name + ".thresholds")); } } diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java b/src/twolovers/exploitfixer/interfaces/instanceables/Violations.java similarity index 68% rename from src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java rename to src/twolovers/exploitfixer/interfaces/instanceables/Violations.java index b09dc3b..96800d6 100644 --- a/src/twolovers/exploitfixer/interfaces/instanceables/Thresholds.java +++ b/src/twolovers/exploitfixer/interfaces/instanceables/Violations.java @@ -2,8 +2,8 @@ import java.util.Collection; -public interface Thresholds { +public interface Violations { Collection getCommands(final int violations); - Collection getThresholds(); + Collection getViolations(); } diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index ab40dfd..33444f8 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -15,15 +15,13 @@ public interface ModuleManager { NotificationsModule getNotificationsModule(); - DuplicationModule getDuplicationModule(); - - UUIDSpoofModule getUUIDSpoofModule(); + ReloadableModule getUUIDSpoofModule(); ExploitPlayerManager getExploitPlayerManager(); - BooksModule getBooksModule(); - SignsModule getSignsModule(); PacketsModule getPacketsModule(); + + ReloadableModule getNullAddressModule(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java b/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java deleted file mode 100644 index af0401f..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/BooksModule.java +++ /dev/null @@ -1,7 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface BooksModule extends CancellableModule { - void reload(Object configYml); - - boolean isEnabled(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java b/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java index 8767e92..27d8b58 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java @@ -1,11 +1,11 @@ package twolovers.exploitfixer.interfaces.modules; -import twolovers.exploitfixer.interfaces.instanceables.Thresholds; +import twolovers.exploitfixer.interfaces.instanceables.Violations; public interface CancellableModule extends ReloadableModule { - int getCancelVls(); + double getCancelVls(); - int getReduceVls(); + double getReduceVls(); - Thresholds getThresholds(); + Violations getViolations(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java index a2fe217..00012e8 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java @@ -3,7 +3,5 @@ import java.util.Collection; public interface CommandsModule extends CancellableModule { - Boolean isEnabled(); - Collection getCommands(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index 5ac013a..ddf735b 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -1,9 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; public interface CustomPayloadModule extends CancellableModule { - boolean isEnabled(); - - void reload(final Object configYml); - void checkPacket(final Object packetEvent); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java b/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java deleted file mode 100644 index 2a404f7..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/DuplicationModule.java +++ /dev/null @@ -1,9 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface DuplicationModule extends CancellableModule { - void reload(Object configYml); - - Boolean isEnabled(); - - int getMaxBytes(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index edcf93e..2b67520 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -1,7 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; public interface ItemsFixModule extends ReloadableModule { - void reload(Object configYml); - - Boolean isEnabled(); + int getEnchantLimit(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java b/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java index f6593a5..82821ef 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java @@ -1,6 +1,6 @@ package twolovers.exploitfixer.interfaces.modules; -public interface MessagesModule { +public interface MessagesModule extends ReloadableModule { String getString(final String locale, final String path); String getReload(final String locale); @@ -19,7 +19,5 @@ public interface MessagesModule { String getKickMessage(final Module module, String locale); - void reload(Object messagesYml); - String getStats(String lang); } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/interfaces/modules/Module.java b/src/twolovers/exploitfixer/interfaces/modules/Module.java index cba715f..5f00a7a 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/Module.java +++ b/src/twolovers/exploitfixer/interfaces/modules/Module.java @@ -1,5 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; public interface Module { + boolean isEnabled(); + String getName(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java b/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java index 828688d..97bb63f 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java @@ -7,7 +7,7 @@ public interface NotificationsModule { boolean isNotifications(final Object player); - void sendNotification(final String check, final Object player); + void sendNotification(final String check, final Object player, final int vls); Collection getNotifications(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index b12e82e..71f33b7 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -1,21 +1,17 @@ package twolovers.exploitfixer.interfaces.modules; public interface PacketsModule extends CancellableModule { - void reload(Object configYml); - void checkPacket(final Object packetEvent, final String packetName); double getMultiplier(final String packetName); - int getWindowClick(); - - boolean isEnabled(); + double getWindowClick(); - boolean isOffline(); + double getSetCreativeSlot(); - int getSetCreativeSlot(); + double getBlockPlace(); - int getBlockPlace(); + double getBlockDig(); - int getBlockDig(); + boolean isOffline(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java b/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java index 9e38ace..446ff8b 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java @@ -1,5 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; public interface ReloadableModule extends Module { - void reload(final Object configYml); + void reload(Object configYml); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java index c592dfd..201d644 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java @@ -1,7 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; public interface SignsModule extends CancellableModule { - void reload(Object configYml); - - boolean isEnabled(); + int getMaxBytes(); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java b/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java deleted file mode 100644 index b1aa05c..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/UUIDSpoofModule.java +++ /dev/null @@ -1,7 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface UUIDSpoofModule extends CancellableModule { - Boolean isEnabled(); - - void reload(Object configYml); -} From 8ccd2d32da36c836069691a373dab5e114e6918a Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Tue, 28 Jan 2020 19:20:07 -0300 Subject: [PATCH 034/336] Updated Source --- src/messages.yml | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/src/messages.yml b/src/messages.yml index 07d86cb..cbfcd57 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -117,46 +117,4 @@ pt: stats: message: |- &fJugadores em cache: &a%players_cached% - &fJogadores punidos: &a%players_punished% - -# Italian -it: - commands: - reload: "&aPlugin ExploitFixer ricaricato!" - help: |- - &aCommadni di ExploitFixer %version%: - &e/%command% help &7- &bMostra i commandi disponibili! - &e/%command% reload &7- &bRicarica il plugin! - &e/%command% notifications &7- &bCambia le notifiche del plugin! - &e/%command% stats &7- &bMostra le statistiche del plugin! - error: - unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" - permission: "&cNon hai il permesso per questo commando!" - console: "&cQuesto commando non può essere eseguito dalla console!" - notifications: - enable: "&aHai abilitato le notifiche!" - disable: "&cHai disabilitato le notifiche!" - modules: - custompayload: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - uuidspoof: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - commands: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - duplication: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di duplicazione rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - items: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di oggetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - packets: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - books: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di libri rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - signs: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di cartelli rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - nulladdress: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - stats: - message: |- - &fGiocatori in cache: &a%players_cached% - &fGiocatori puniti: &a%players_punished% - + &fJogadores punidos: &a%players_punished% \ No newline at end of file From 9ffdf34cd9923466eb8a0d6adb5524503a648996 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Mon, 10 Feb 2020 18:48:08 -0300 Subject: [PATCH 035/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 56 ++++-- src/plugin.yml | 6 +- .../exploitfixer/bukkit/ExploitFixer.java | 16 +- .../adapters/BlockDigPacketAdapter.java | 12 +- .../adapters/BlockPlacePacketAdapter.java | 14 +- .../adapters/CustomPayloadPacketAdapter.java | 19 +- .../SetCreativeSlotPacketAdapter.java | 12 +- .../adapters/WindowClickPacketAdapter.java | 109 ++++++----- .../initializers/AdapterInitializer.java | 25 +-- .../instanceables/BukkitExploitPlayer.java | 132 ++++++++------ .../instanceables/BukkitViolations.java | 2 +- .../listeners/InventoryCreativeListener.java | 65 ------- .../listeners/PlayerCommandListener.java | 2 +- .../bukkit/listeners/PlayerLoginListener.java | 8 +- .../bukkit/listeners/PlayerQuitListener.java | 2 +- .../listeners/PlayerTabCompleteListener.java | 2 +- .../bukkit/listeners/SignChangeListener.java | 6 +- .../initializers/ListenerInitializer.java | 1 - .../managers/BukkitExploitPlayerManager.java | 41 +++-- .../bukkit/managers/BukkitModuleManager.java | 53 +++--- .../modules/BukkitCustomPayloadModule.java | 57 +++--- .../bukkit/modules/BukkitItemsFixModule.java | 1 + .../modules/BukkitNotificationsModule.java | 5 + .../bukkit/modules/BukkitPacketsModule.java | 169 ++++++++++-------- .../exploitfixer/bukkit/nms/NMSManager.java | 26 +++ .../instanceables/BungeeExploitPlayer.java | 42 ++--- .../bungee/listeners/ChatListener.java | 2 +- .../bungee/listeners/DisconnectListener.java | 2 +- .../bungee/listeners/PostLoginListener.java | 9 +- .../managers/BungeeExploitPlayerManager.java | 42 +++-- .../modules/BungeeCustomPayloadModule.java | 42 +++-- .../instanceables/ExploitPlayer.java | 2 - .../managers/ExploitPlayerManager.java | 6 +- .../interfaces/modules/PacketsModule.java | 2 +- 35 files changed, 546 insertions(+), 446 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java create mode 100644 src/twolovers/exploitfixer/bukkit/nms/NMSManager.java diff --git a/src/bungee.yml b/src/bungee.yml index 089da3c..3941461 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.0.5 +version: 1.1.4 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 443f442..f0848bc 100644 --- a/src/config.yml +++ b/src/config.yml @@ -35,24 +35,43 @@ custompayload: # Do you want to enable this module? enabled: true - # Max amount of registered channels per player allowed. - max_channels: 256 + # Blocks different types of invalid packets. + invalid: + # Cancells packets with null/empty tags or content. + empty: true + + # Limits the amount of channels registered per player. + max_channels: + # Vls to add when max channels are exceed. (Set to 0 to disable) + vls: 1000 + + # Maximum amounts of channels allowed per player. + amount: 512 + + # Never disable this and instead increase max_bytes if you have false positives. + big_data: + # Vls to add when too big packets are sent. (Set to 0 to disable) + vls: 1000 + + # Maximum amount of bytes per packet. + max_bytes: 16000 # Amount of violations required to cancel. cancel_vls: 400 # Amount of violations to reduce per second. - reduce_vls: 500 + reduce_vls: 400 multipliers: - OTHER: 1.25 - MAX_CHANNELS: 600 + OTHER: 0.1 MC|BSign: 50 MC|BEdit: 50 MC|BOpen: 50 # Placeholders: %player% violations: + 400: + - "notification" 600: - "kick" - "notification" @@ -71,7 +90,8 @@ packets: # Cancells packets if the player sending it is offline. offline: true - # TIP: Dont disable this and instead increase max_bytes if you have false positives. + # Never disable this and instead increase max_bytes if you have false positives. + # This will check if integers, floats, doubles and packets have a invalid size. big_data: # Vls to add when too big packets are sent. (Set to 0 to disable) vls: 1000 @@ -79,16 +99,23 @@ packets: # Maximum amount of bytes per packet. max_bytes: 16000 + # Maximum amount of items per StructureModifier. + max_structure: 25 + # big_data is required to enable this check. (Checks page quantity and bytes) books: - # Vls to add when invalid book packets are sent. (Set to 0 to disable) - vls: 1000 + vls: + # Vls to add when invalid book packets are sent. (Set to 0 to disable) + invalid: 1000 + + # Vls to add when normal book packets are sent. (Set to 0 to disable) + normal: 20 # Maximum amount of bytes per page. (Prevents duplication and crashes) max_bytes: 256 # Vls to add when invalid window_click packets are sent. (Set to 0 to disable) - # Vls added by null inventoryview is the tenth part of the window_click vls. + # Vls added by null InventoryView is the tenth part of the window_click vls. window_click: 1000 # Vls to add when invalid block_place packets are sent. (Set to 0 to disable) @@ -106,14 +133,13 @@ packets: ARM_ANIMATION: 4.25 BLOCK_DIG: 4.25 BLOCK_PLACE: 4.25 - BLOCK_PLACE_BOOKS: 80 - CUSTOM_PAYLOAD: 0.5 + CUSTOM_PAYLOAD: 0.1 ENTITY_ACTION: 4 FLYING: 0.5 - LOOK: 1.25 - POSITION_LOOK: 1.25 - POSITION: 2 - SET_CREATIVE_SLOT: 1 + LOOK: 0.75 + POSITION_LOOK: 0.75 + POSITION: 3.5 + SET_CREATIVE_SLOT: 0.5 TAB_COMPLETE: 8 UPDATE_SIGN: 90 USE_ENTITY: 4 diff --git a/src/plugin.yml b/src/plugin.yml index 078c4ee..3efd625 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,9 +1,11 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.0.5 +version: 1.1.4 author: 2LS api-version: '1.13' -softdepend: [ProtocolLib] +load: STARTUP +depend: [ProtocolLib] +loadbefore: [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaPotions, ProtocolSupport] commands: exploitfixer: description: The main ExploitFixer command diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 4b8e69d..41a0632 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -23,6 +23,7 @@ public void onEnable() { final Server server = this.getServer(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); + server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); configurationUtil.createConfiguration("%datafolder%/config.yml"); configurationUtil.createConfiguration("%datafolder%/messages.yml"); @@ -30,23 +31,26 @@ public void onEnable() { final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); exploitFixer = this; - this.moduleManager = new BukkitModuleManager(this, configYml, messagesYml); - + moduleManager = new BukkitModuleManager(this, configYml, messagesYml); VersionUtil.init(); - reload(); - - server.getScheduler().scheduleSyncRepeatingTask(this, () -> { + server.getScheduler().runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); exploitPlayerManager.clear(); }, 9000L, 9000L); } + public void onDisable() { + this.getServer().getScheduler().cancelTasks(this); + } + public void reload() { - final PluginManager pluginManager = getServer().getPluginManager(); + final Server server = getServer(); + final PluginManager pluginManager = server.getPluginManager(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); + server.getMessenger().unregisterIncomingPluginChannel(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); configurationUtil.createConfiguration("%datafolder%/messages.yml"); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 4f01917..949f4a7 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.adapters; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; @@ -14,10 +15,12 @@ import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class BlockDigPacketAdapter extends PacketAdapter { + private final PacketType packetType; private final ModuleManager moduleManager; - public BlockDigPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.BLOCK_DIG); + public BlockDigPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + super(plugin, listenerPriority, packetType); + this.packetType = packetType; this.moduleManager = moduleManager; } @@ -46,7 +49,7 @@ public void onPacketReceiving(final PacketEvent event) { itemOnHand = new ItemStack(Material.AIR); if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockDig); @@ -58,6 +61,9 @@ public void onPacketReceiving(final PacketEvent event) { } else if (packetsModule.isOffline()) event.setCancelled(true); } + + if (!event.isCancelled()) + packetsModule.checkPacket(event); } } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index bcc3d79..03197e1 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.adapters; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; @@ -14,10 +15,12 @@ import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class BlockPlacePacketAdapter extends PacketAdapter { + private final PacketType packetType; private final ModuleManager moduleManager; - public BlockPlacePacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.BLOCK_DIG); + public BlockPlacePacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + super(plugin, listenerPriority, packetType); + this.packetType = packetType; this.moduleManager = moduleManager; } @@ -36,7 +39,7 @@ public void onPacketReceiving(final PacketEvent event) { final StructureModifier itemModifier = event.getPacket().getItemModifier(); if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.read(0); + final ItemStack itemUse = itemModifier.readSafely(0); if (itemUse != null) { final PlayerInventory playerInventory = player.getInventory(); @@ -46,7 +49,7 @@ public void onPacketReceiving(final PacketEvent event) { itemOnHand = new ItemStack(Material.AIR); if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockPlace); @@ -59,6 +62,9 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } } + + if (!event.isCancelled()) + packetsModule.checkPacket(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java index 082a60d..43bd2dc 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java @@ -1,24 +1,35 @@ package twolovers.exploitfixer.bukkit.adapters; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; +import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class CustomPayloadPacketAdapter extends PacketAdapter { + private final PacketType packetType; private final CustomPayloadModule customPayloadModule; + private final PacketsModule packetsModule; - public CustomPayloadPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.CUSTOM_PAYLOAD); + public CustomPayloadPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + super(plugin, listenerPriority, packetType); + this.packetType = packetType; this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.packetsModule = moduleManager.getPacketsModule(); } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && customPayloadModule.isEnabled()) { - customPayloadModule.checkPacket(event); + if (!event.isCancelled()) { + if (customPayloadModule.isEnabled()) { + customPayloadModule.checkPacket(event); + } + + if (!event.isCancelled()) + packetsModule.checkPacket(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index e591636..4bd6a9e 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.adapters; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; @@ -21,10 +22,12 @@ import java.util.Map; public class SetCreativeSlotPacketAdapter extends PacketAdapter { + private final PacketType packetType; private final ModuleManager moduleManager; - public SetCreativeSlotPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT); + public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + super(plugin, listenerPriority, packetType); + this.packetType = packetType; this.moduleManager = moduleManager; } @@ -41,7 +44,7 @@ public void onPacketReceiving(final PacketEvent event) { final double setCreativeSlot = packetsModule.getSetCreativeSlot(); if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getName()); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); @@ -99,6 +102,9 @@ public void onPacketReceiving(final PacketEvent event) { } else if (packetsModule.isOffline()) event.setCancelled(true); } + + if (!event.isCancelled()) + packetsModule.checkPacket(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 12a7195..72d25f1 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -1,97 +1,92 @@ package twolovers.exploitfixer.bukkit.adapters; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class WindowClickPacketAdapter extends PacketAdapter { - private final ModuleManager moduleManager; - - public WindowClickPacketAdapter(final Plugin plugin, final ModuleManager moduleManager) { - super(plugin, PacketType.Play.Client.WINDOW_CLICK); - this.moduleManager = moduleManager; + private final PacketType packetType; + private final PacketsModule packetsModule; + private final ExploitPlayerManager exploitPlayerManager; + + public WindowClickPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + super(plugin, listenerPriority, packetType); + this.packetType = packetType; + this.packetsModule = moduleManager.getPacketsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - final PacketsModule packetsModule = moduleManager.getPacketsModule(); + if (!event.isCancelled() && packetsModule.isEnabled()) { + final double windowClick = packetsModule.getWindowClick(); + + if (windowClick > 0) { + final Player player = event.getPlayer(); - if (packetsModule.isEnabled()) { - final double windowClick = packetsModule.getWindowClick(); + if (player != null && player.isOnline()) { + final PacketContainer packet = event.getPacket(); + final StructureModifier integers = packet.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); - if (windowClick > 0) { - final Player player = event.getPlayer(); + if (inventoryView == null) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); - if (player != null && player.isOnline()) { - final PacketContainer packet = event.getPacket(); - final StructureModifier integers = packet.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final String playerName = player.getName(); + // Divide by 10 because of false positives. + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 10); + else + event.setCancelled(true); + } else if (integers.size() > 1) { + final int slot = inventoryView.convertSlot(integers.readSafely(1)); + final int maxSlots = inventoryView.countSlots(); - if (inventoryView == null) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + if (slot >= maxSlots) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 10); // Divide by 10 because of false positives + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); else event.setCancelled(true); - } else if (integers.size() > 1) { - final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.readSafely(1); - int maxSlots = inventoryView.countSlots(); - - if (topInventory.getType() == InventoryType.CRAFTING && bottomInventory.getType() == InventoryType.PLAYER) - maxSlots += 4; + } else { + final StructureModifier structureModifier = packet.getItemModifier(); - if (slot >= maxSlots) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); + if (structureModifier.size() > 0 && slot > 0) { + final ItemStack itemUse = structureModifier.readSafely(0); - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - else - event.setCancelled(true); - } else { - final StructureModifier structureModifier = packet.getItemModifier(); + if (itemUse != null) { + final ItemStack itemOnHand = inventoryView.getItem(slot); - if (structureModifier.size() > 0 && slot > 0) { - final ItemStack itemUse = structureModifier.readSafely(0); + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); - if (itemUse != null) { - try { - final ItemStack itemOnHand = inventoryView.getItem(slot); - - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - event.setCancelled(true); - } - } catch (final IndexOutOfBoundsException e) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); - - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - else - event.setCancelled(true); - } + // Divide by 12 because of false positives. + if (exploitPlayer != null) + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 12); + else + event.setCancelled(true); } } } } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - } + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } + + if (!event.isCancelled()) + packetsModule.checkPacket(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 2d115f3..06f1242 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -3,6 +3,7 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; @@ -18,19 +19,19 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.removePacketListeners(plugin); for (final PacketType packetType : PacketType.Play.Client.getInstance()) { - protocolManager.addPacketListener(new PacketAdapter(plugin, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.checkPacket(event, packetType.name()); - } - }); + if (packetsModule.isEnabled()) + protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.checkPacket(event); + } + }); } - protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, moduleManager)); - protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, moduleManager)); + protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_DIG, moduleManager)); + protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_PLACE, moduleManager)); + protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.CUSTOM_PAYLOAD, moduleManager)); + protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); + protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.WINDOW_CLICK, moduleManager)); } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index a4e9b5d..cc81bdf 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.nms.NMSManager; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.Violations; @@ -21,6 +22,7 @@ import java.net.URLConnection; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; public class BukkitExploitPlayer implements ExploitPlayer { @@ -55,7 +57,10 @@ public int addChannels(final int channels) { @Override public double getViolations(final Module module) { - return violations.getOrDefault(module, 0D); + if (module instanceof CancellableModule) + return violations.getOrDefault(module, 0D); + else + return 0D; } public String getOnlineUUID() { @@ -76,7 +81,7 @@ public String getOnlineUUID() { bufferedReader.close(); onlineUUID = response.toString(); - } catch (Exception ignored) { + } catch (final Exception ignored) { } } @@ -86,71 +91,82 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof Player) { - final Violations violations = module.getViolations(); - - if (violations != null) { final Player player = (Player) playerObject; if (player.isOnline()) { - final Plugin plugin = (Plugin) pluginObject; - final Server server = plugin.getServer(); - final double currentTime = System.currentTimeMillis(); - final String locale; - - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - - for (final CancellableModule violationModule : this.violations.keySet().toArray(new CancellableModule[0])) { - final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - - if (vls <= 0) - this.violations.remove(violationModule); - else - this.violations.put(violationModule, vls); + final Violations violations = module.getViolations(); + + if (violations != null) { + final Plugin plugin = (Plugin) pluginObject; + final Server server = plugin.getServer(); + final double currentTime = System.currentTimeMillis(); + + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; + + for (final CancellableModule cancellableModule : new HashSet<>(this.violations.keySet())) { + final double vls = this.violations.get(cancellableModule) - cancellableModule.getReduceVls(); + + if (vls <= 0) + this.violations.remove(cancellableModule); + else + this.violations.put(cancellableModule, vls); + } } - } - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; - final String kickMessage = messagesModule.getKickMessage(module, locale); - - this.violations.put(module, newVls); - - for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); - - if (commands != null && !commands.isEmpty()) - for (final String punishCommand : commands) - if (!punishCommand.isEmpty()) - if (punishCommand.equals("kick")) { - server.getScheduler().runTask(plugin, () -> player.kickPlayer(kickMessage)); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) - if (event instanceof PacketEvent) - notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; + + this.violations.put(module, newVls); + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); + + for (final int threshold : violations.getViolations()) { + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); + + server.getScheduler().scheduleAsyncDelayedTask(plugin, ()-> { + if (commands != null && !commands.isEmpty()) + for (final String punishCommand : commands) + if (!punishCommand.isEmpty()) + if (punishCommand.equals("kick")) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); + + final String kickMessage = messagesModule.getKickMessage(module, locale); + final Thread thread = Thread.currentThread(); + + server.getScheduler().scheduleSyncDelayedTask(plugin, () -> { + player.kickPlayer(kickMessage); + thread.interrupt(); + }, 0L); + + try { + Thread.sleep(1000); + } catch (final InterruptedException ignored) {} + + NMSManager.closeChannel(player); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) + if (event instanceof PacketEvent) + notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); + else + notificationsModule.sendNotification(module.getName(), player, (int) newVls); else - notificationsModule.sendNotification(module.getName(), player, (int) newVls); - else - server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + server.getScheduler().scheduleSyncDelayedTask(plugin, () ->server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName())), 0L); + }, 0L); + } } } - - if (module.getCancelVls() <= newVls && event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); - } else if (event instanceof Cancellable) + } else if (event instanceof Cancellable) ((Cancellable) event).setCancelled(true); - } - } - } - - public String getName() { - return name; + } else if (event instanceof Cancellable) + ((Cancellable) event).setCancelled(true); } public void clearViolations() { diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java index 5e001ed..df041b9 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java @@ -15,7 +15,7 @@ public BukkitViolations(final ConfigurationSection configuration) { for (final String key : configuration.getKeys(false)) { try { this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (NumberFormatException ignored) { + } catch (final NumberFormatException ignored) { } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java deleted file mode 100644 index c5e3cdb..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/InventoryCreativeListener.java +++ /dev/null @@ -1,65 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryCreativeEvent; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; - -public class InventoryCreativeListener implements Listener { - private final ItemsFixModule itemsFixModule; - - public InventoryCreativeListener(final ModuleManager moduleManager) { - this.itemsFixModule = moduleManager.getItemsFixModule(); - } - - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onInventoryCreative(final InventoryCreativeEvent event) { - /*final HumanEntity whoClicked = event.getWhoClicked(); - - if (itemsFixModule.isEnabled() && event.getAction() == InventoryAction.PLACE_ALL && whoClicked instanceof Player) { - final ItemStack itemStack = event.getCursor(); - final Material material = itemStack.getType(); - final ItemMeta itemMeta = itemStack.getItemMeta(); - final int enchantLimit = itemsFixModule.getEnchantLimit(); - ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); - - if (enchantLimit > 0) { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - if (enchantments.get(enchantment) > enchantLimit) - itemStackRemake.removeEnchantment(enchantment); - } else { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - itemStackRemake.removeEnchantment(enchantment); - } - - if (itemMeta != null) { - if (itemMeta instanceof PotionMeta) { - ((PotionMeta) itemMeta).clearCustomEffects(); - - if (material == Material.POTION) { - final Potion itemStackPotion = Potion.fromItemStack(itemStackRemake); - - if (Potion.fromItemStack(itemStack).isSplash()) - itemStackPotion.setSplash(true); - - itemStackRemake = itemStackPotion.toItemStack(itemStackRemake.getAmount()); - } - } - - itemMeta.setDisplayName(null); - itemMeta.setLore(null); - - itemStackRemake.setItemMeta(itemMeta); - } - - event.setCursor(itemStackRemake); - } - */ - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 0ec8aa4..3965c03 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -30,7 +30,7 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (message.startsWith(command + " ") || message.endsWith(command)) { final Player player = event.getPlayer(); - exploitPlayerManager.get(player.getName()).addVls(plugin, commandsModule, player, commandsModule, 1); + exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, commandsModule, player, commandsModule, 1); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index cbb18a7..471dd5a 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -48,17 +48,15 @@ public void onPlayerLogin(final PlayerLoginEvent event) { event.setKickMessage(messagesModule.getKickMessage(nullAddressModule, locale)); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); } else { - final String playerName = player.getName(); - - exploitPlayerManager.add(playerName); - if (uuidSpoofModule.isEnabled()) { + final String playerName = player.getName(); + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { final String originalUUID = player.getUniqueId().toString().replace("-", ""); final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java index 7cc6584..62e8861 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -21,7 +21,7 @@ public PlayerQuitListener(final ModuleManager variables) { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); if (exploitPlayer != null) { exploitPlayer.clearChannels(); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java index 991337d..06f6ecf 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java @@ -30,7 +30,7 @@ public void onPlayerCommand(final TabCompleteEvent event) { if (message.startsWith(command + " ") || message.endsWith(command)) { final Player player = (Player) event.getSender(); - exploitPlayerManager.get(player.getName()).addVls(plugin, commandsModule, player, commandsModule, 1); + exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, commandsModule, player, commandsModule, 1); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index 1b1751a..e98601f 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -28,12 +28,12 @@ public void onSignChange(final SignChangeEvent event) { if (signsModule.isEnabled()) { final Player player = event.getPlayer(); - for (String line : event.getLines()) { + for (final String line : event.getLines()) { if (line.length() >= 46) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, signsModule, 1); + exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, event, player, signsModule, 1); return; } else if (line.getBytes(StandardCharsets.UTF_8).length > signsModule.getMaxBytes()) { - exploitPlayerManager.get(player.getName()).addVls(plugin, event, player, signsModule, 1); + exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, event, player, signsModule, 1); return; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 5913813..102b274 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -11,7 +11,6 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage final PluginManager pluginManager = plugin.getServer().getPluginManager(); HandlerList.unregisterAll(plugin); - pluginManager.registerEvents(new InventoryCreativeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index d496431..40fae72 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bukkit.managers; import org.bukkit.Bukkit; +import org.bukkit.Server; import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -8,12 +9,14 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.UUID; import java.util.logging.Level; public class BukkitExploitPlayerManager implements ExploitPlayerManager { final private ModuleManager moduleManager; - final private Map exploitPlayers = new HashMap<>(); + final private Map exploitPlayers = new HashMap<>(); private int punishments = 0; BukkitExploitPlayerManager(final ModuleManager moduleManager) { @@ -23,36 +26,42 @@ public class BukkitExploitPlayerManager implements ExploitPlayerManager { } @Override - public ExploitPlayer get(final String playerName) { - return exploitPlayers.getOrDefault(playerName, null); - } + public ExploitPlayer get(final UUID uuid) { + ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); - @Override - public void add(final String playerName) { - if (!exploitPlayers.containsKey(playerName)) - exploitPlayers.put(playerName, new BukkitExploitPlayer(playerName, moduleManager)); + if (exploitPlayer == null) { + final Player player = Bukkit.getPlayer(uuid); + + exploitPlayer = new BukkitExploitPlayer(player.getName(), moduleManager); + exploitPlayers.put(uuid, exploitPlayer); + } + + return exploitPlayer; } @Override public void clear() { + final Server server = Bukkit.getServer(); + final Iterator iterator = exploitPlayers.keySet().iterator(); boolean cleared = false; - for (final String name : exploitPlayers.keySet().toArray(new String[0])) - if (Bukkit.getPlayerExact(name) == null) { - exploitPlayers.remove(name); + while (iterator.hasNext()) { + final UUID uuid = iterator.next(); + + if (server.getPlayer(uuid) == null) { + iterator.remove(); cleared = true; } + } - if (cleared) - Bukkit.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + if (cleared) { + server.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + } } @Override public void reload() { exploitPlayers.clear(); - - for (final Player player : Bukkit.getOnlinePlayers()) - add(player.getName()); } @Override diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 9772df9..848ad74 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.managers; +import org.bukkit.Server; import org.bukkit.configuration.Configuration; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.modules.*; @@ -7,7 +8,10 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.*; +import java.util.logging.Level; + public class BukkitModuleManager implements ModuleManager { + private Plugin plugin; private CommandsModule commandsModule; private CustomPayloadModule customPayloadModule; private ItemsFixModule itemsFixModule; @@ -19,29 +23,38 @@ public class BukkitModuleManager implements ModuleManager { private ReloadableModule uuidSpoofModule, nullAddressModule; public BukkitModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { - commandsModule = new BukkitCommandsModule(configYml); - customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); - itemsFixModule = new BukkitItemsFixModule(configYml); - messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); - notificationsModule = new BukkitNotificationsModule(configYml); - uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); - packetsModule = new BukkitPacketsModule(plugin, this, configYml); - exploitPlayerManager = new BukkitExploitPlayerManager(this); - signsModule = new BukkitSignsModule(configYml); - nullAddressModule = new BukkitNullAddressModule(configYml); + this.plugin = plugin; + this.commandsModule = new BukkitCommandsModule(configYml); + this.customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); + this.itemsFixModule = new BukkitItemsFixModule(configYml); + this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new BukkitNotificationsModule(configYml); + this.uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); + this.packetsModule = new BukkitPacketsModule(plugin, this, configYml); + this.exploitPlayerManager = new BukkitExploitPlayerManager(this); + this.signsModule = new BukkitSignsModule(configYml); + this.nullAddressModule = new BukkitNullAddressModule(configYml); } + @Override public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { - commandsModule.reload(configYml); - customPayloadModule.reload(configYml); - itemsFixModule.reload(configYml); - messagesModule.reload(messagesYml); - notificationsModule.reload(configYml); - uuidSpoofModule.reload(configYml); - packetsModule.reload(configYml); - exploitPlayerManager.reload(); - signsModule.reload(configYml); - nullAddressModule.reload(configYml); + try { + this.commandsModule.reload(configYml); + this.customPayloadModule.reload(configYml); + this.itemsFixModule.reload(configYml); + this.messagesModule.reload(messagesYml); + this.notificationsModule.reload(configYml); + this.uuidSpoofModule.reload(configYml); + this.packetsModule.reload(configYml); + this.exploitPlayerManager.reload(); + this.signsModule.reload(configYml); + this.nullAddressModule.reload(configYml); + } catch (final NullPointerException e) { + final Server server = plugin.getServer(); + + server.getLogger().log(Level.SEVERE, "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); + server.getPluginManager().disablePlugin(plugin); + } } @Override diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index b5410df..ed731cf 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -24,9 +23,9 @@ public class BukkitCustomPayloadModule implements CustomPayloadModule { private Plugin plugin; private ModuleManager moduleManager; private Violations violations; - private int maxChannels; - private double cancelVls, reduceVls; - private boolean enabled; + private int maxChannelsAmount, bigDataMaxBytes; + private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; + private boolean enabled, empty; public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -70,7 +69,11 @@ public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - this.maxChannels = configYml1.getInt("custompayload.max_channels"); + this.empty = configYml1.getBoolean(name + ".invalid.empty"); + this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); + this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); + this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); + this.bigDataMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes"); for (final String key : configurationSection.getKeys(false)) multipliers.put(key, configurationSection.getDouble(key)); @@ -81,23 +84,33 @@ public void checkPacket(final Object event) { if (event instanceof PacketEvent) { final PacketEvent packetEvent = (PacketEvent) event; final Player sender = packetEvent.getPlayer(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(sender.getName()); - - if (exploitPlayer != null && sender.isOnline()) { - final PacketContainer packet = packetEvent.getPacket(); - final String tag = String.valueOf(packet.getStrings().readSafely(0)); - - if (tag != null && tag.toLowerCase().endsWith("register") && !VersionUtil.isOneDotFifteen()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - final int channels = byteBufModifier.readSafely(0).toString(Charsets.UTF_8).split("\000").length; - - if (exploitPlayer.addChannels(channels) > maxChannels) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", multipliers.getOrDefault("OTHER", 1D))); - } - } else - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } /*else if (moduleManager.getPacketsModule().isOffline()) - packetEvent.setCancelled(true);*/ // Disabled because of false positives + + if (sender != null && sender.isOnline()) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(sender.getUniqueId()); + + if (exploitPlayer != null) { + final PacketContainer packet = packetEvent.getPacket(); + final StructureModifier stringStructureModifier = packet.getStrings(); + final String tag = stringStructureModifier.readSafely(0); + + if (tag != null && !tag.isEmpty()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + final String content = byteBufModifier.readSafely(0).toString(Charsets.UTF_8); + + if (content != null && !content.isEmpty()) { + if (tag.toLowerCase().endsWith("register") && content.split("\000").length > maxChannelsAmount) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + } else if (content.length() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); + } else { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } else if (empty) + packetEvent.setCancelled(true); + } else if (empty) + packetEvent.setCancelled(true); + } + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index 85f2714..623c505 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -11,6 +11,7 @@ public BukkitItemsFixModule(final Object configYml) { reload(configYml); } + @Override final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final String name = getName().toLowerCase(); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java index 91aee96..d02d036 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java @@ -19,6 +19,7 @@ public BukkitNotificationsModule(final Object configYml) { reload(configYml); } + @Override public final void setNotifications(final Object player, final boolean input) { if (input) notifications.add(player); @@ -26,10 +27,12 @@ public final void setNotifications(final Object player, final boolean input) { notifications.remove(player); } + @Override public final boolean isNotifications(final Object player) { return notifications.contains(player); } + @Override public void sendNotification(final String check, final Object player, final int violations) { if (enabled && player != null) { final Player player1 = (Player) player; @@ -55,10 +58,12 @@ public void sendNotification(final String check, final Object player, final int } } + @Override public final Collection getNotifications() { return notifications; } + @Override public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 0497bc9..47955d5 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.modules; +import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; @@ -33,7 +34,8 @@ public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; private final Map multipliers = new HashMap<>(); private Violations violations; - private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls, booksVls; + private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls, + booksVlsInvalid, booksVlsNormal, bigDataMaxStructure; private int booksMaxBytes; private boolean enabled, offline; @@ -43,6 +45,7 @@ public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManage reload(configYml); } + @Override final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.multipliers"); @@ -52,10 +55,12 @@ final public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.offline = configYml1.getBoolean(name + ".invalid.offline"); - this.booksVls = configYml1.getDouble(name + ".invalid.books.vls"); + this.booksVlsInvalid = configYml1.getDouble(name + ".invalid.books.vls.invalid"); + this.booksVlsNormal = configYml1.getDouble(name + ".invalid.books.vls.normal"); this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes"); + this.bigDataMaxStructure = configYml1.getDouble(name + ".invalid.big_data.max_structure"); this.windowClick = configYml1.getDouble(name + ".invalid.window_click"); this.blockPlace = configYml1.getDouble(name + ".invalid.block_place"); this.blockDig = configYml1.getDouble(name + ".invalid.block_dig"); @@ -77,80 +82,84 @@ public boolean isEnabled() { } @Override - public void checkPacket(final Object packetEvent, final String packetName) { - final PacketEvent event = (PacketEvent) packetEvent; - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(playerName); - - if (bigDataVls > 0) { - final PacketContainer packet = event.getPacket(); - final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier blockDataModifier = packet.getBlockData(); - final StructureModifier longs = packet.getLongs(); - final StructureModifier strings = packet.getStrings(); - final StructureModifier> nbtModifier = packet.getNbtModifier(); - final AtomicInteger packetSize = new AtomicInteger(0); - - if (itemModifier.size() > 50 || blockDataModifier.size() > 50 || longs.size() > 50 || strings.size() > 50 || nbtModifier.size() > 50) { - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - else - event.setCancelled(true); - } else { - for (final ItemStack itemStack : itemModifier.getValues()) { - if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) - break; - } + public void checkPacket(final Object packetEvent) { + if (enabled) { + final PacketEvent event = (PacketEvent) packetEvent; + + if (!event.isCancelled()) { + final Player player = event.getPlayer(); + + if (player != null && player.isOnline()) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); + + if (bigDataVls > 0) { + final PacketContainer packet = event.getPacket(); + final StructureModifier itemModifier = packet.getItemModifier(); + final StructureModifier blockDataModifier = packet.getBlockData(); + final StructureModifier integers = packet.getIntegers(); + final StructureModifier longs = packet.getLongs(); + final StructureModifier floats = packet.getFloat(); + final StructureModifier doubles = packet.getDoubles(); + final StructureModifier strings = packet.getStrings(); + final StructureModifier> nbtModifier = packet.getNbtModifier(); + final AtomicInteger packetSize = new AtomicInteger(0); + + if (itemModifier.size() > bigDataMaxStructure || blockDataModifier.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + } else { + if (!event.isCancelled()) { + for (final ItemStack itemStack : itemModifier.getValues()) { + if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) + break; + } + } - if (!event.isCancelled()) { - for (final WrappedBlockData blockData : blockDataModifier.getValues()) { - if (blockData != null) { - int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; + if (!event.isCancelled()) { + for (final WrappedBlockData blockData : blockDataModifier.getValues()) { + if (blockData != null) { + int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } - } + packetSize.addAndGet(dataBytes); + } + } - for (final String string : strings.getValues()) { - if (string != null) { - int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; + for (final String string : strings.getValues()) { + if (string != null) { + int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } - } + packetSize.addAndGet(dataBytes); + } + } - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - int dataBytes = nbtBase.getValue().toString().length(); + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + int dataBytes = nbtBase.getValue().toString().getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } - } + packetSize.addAndGet(dataBytes); + } + } - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - if (byteBuf != null) - packetSize.addAndGet(byteBuf.capacity()); - } - } + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + if (byteBuf != null) + packetSize.addAndGet(byteBuf.capacity()); + } + } - if (packetSize.get() > bigDataMaxBytes) { - if (exploitPlayer != null) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } else - event.setCancelled(true); + if (packetSize.get() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + } + } } } - } - } - if (!event.isCancelled() && exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetName)); + if (!event.isCancelled()) + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(event.getPacketType().name())); + } else if (offline && event.getPacketType() != PacketType.Play.Client.CUSTOM_PAYLOAD) + event.setCancelled(true); + } } } @@ -199,7 +208,7 @@ public Violations getViolations() { return violations; } - public boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, final Player player, final AtomicInteger packetSize) { + private boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, final Player player, final AtomicInteger packetSize) { if (itemStack != null && !event.isCancelled()) { final ItemMeta itemMeta = itemStack.getItemMeta(); int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; @@ -221,27 +230,29 @@ public boolean checkItem(final ItemStack itemStack, final PacketEvent event, fin final InventoryHolder inventoryHolder = (InventoryHolder) blockState; for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) - checkItem(itemStack1, event, exploitPlayer, player, packetSize); + if (checkItem(itemStack1, event, exploitPlayer, player, packetSize)) + break; } } - } else if (booksVls > 0 && itemMeta instanceof BookMeta) { + } else if (booksVlsInvalid > 0 && itemMeta instanceof BookMeta) { final BookMeta bookMeta = (BookMeta) itemMeta; - if (bookMeta.getPageCount() > 50) { - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, booksVls); - else - event.setCancelled(true); + if (exploitPlayer == null) + event.setCancelled(true); + else if (bookMeta.getPageCount() > 50) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); } else { - for (String page : bookMeta.getPages()) { - - if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, this, booksVls); - else - event.setCancelled(true); + for (final String page : bookMeta.getPages()) { + if (event.isCancelled()) { + break; + } else if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); } } + + if (!event.isCancelled()) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsNormal); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java b/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java new file mode 100644 index 0000000..82d3235 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java @@ -0,0 +1,26 @@ +package twolovers.exploitfixer.bukkit.nms; + +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class NMSManager { + public static void closeChannel(final Player player) { + try { + final Method getHandle = player.getClass().getMethod("getHandle"); + final Object nmsPlayer = getHandle.invoke(player); + final Field conField = nmsPlayer.getClass().getField("playerConnection"); + final Object con = conField.get(nmsPlayer); + final Field netField = con.getClass().getField("networkManager"); + final Object net = netField.get(con); + final Field chanField = net.getClass().getField("channel"); + final Object chan = chanField.get(net); + final Method method = chan.getClass().getMethod("closeFuture"); + + method.invoke(chan); + } catch (final Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index 9b6b1ad..dfc2934 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bungee.instanceables; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Cancellable; import net.md_5.bungee.api.plugin.Plugin; @@ -17,10 +18,7 @@ import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; +import java.util.*; public class BungeeExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; @@ -56,7 +54,10 @@ public int addChannels(final int channels) { @Override public double getViolations(final Module module) { - return violations.getOrDefault(module, 0D); + if (module instanceof CancellableModule) + return violations.getOrDefault(module, 0D); + else + return 0D; } @Override @@ -88,12 +89,13 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof ProxiedPlayer) { - final Violations violations = module.getViolations(); - - if (violations != null) { final ProxiedPlayer player = (ProxiedPlayer) playerObject; if (player.isConnected()) { + final Violations violations = module.getViolations(); + + if (violations != null) { + final Plugin plugin = (Plugin) pluginObject; final ProxyServer server = plugin.getProxy(); final double currentTime = System.currentTimeMillis(); @@ -103,7 +105,7 @@ public void addVls(final Object pluginObject, final Object event, final Object p if (currentTime - lastViolation >= 1000) { lastViolation = currentTime; - for (final CancellableModule violationModule : this.violations.keySet().toArray(new CancellableModule[0])) { + for (final CancellableModule violationModule : new HashSet<>(this.violations.keySet())) { final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); if (vls <= 0) @@ -123,7 +125,10 @@ public void addVls(final Object pluginObject, final Object event, final Object p this.violations.put(module, newVls); - for (final int threshold : violations.getViolations()) + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); + + for (final int threshold : violations.getViolations()) { if (threshold > oldVls && threshold <= newVls) { final Collection commands = violations.getCommands(threshold); @@ -131,24 +136,19 @@ public void addVls(final Object pluginObject, final Object event, final Object p for (final String punishCommand : commands) if (!punishCommand.isEmpty()) if (punishCommand.equals("kick")) { - player.disconnect(kickMessage); + player.disconnect(new TextComponent(kickMessage)); exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) notificationsModule.sendNotification(module.getName(), player, (int) newVls); else server.getPluginManager().dispatchCommand(server.getConsole(), punishCommand.replace("%player%", player.getName())); } - - if (event instanceof Cancellable && module.getCancelVls() <= newVls) - ((Cancellable) event).setCancelled(true); + } } - } - } - } - - @Override - public String getName() { - return name; + } else if (event instanceof Cancellable) + ((Cancellable) event).setCancelled(true); + } else if (event instanceof Cancellable) + ((Cancellable) event).setCancelled(true); } @Override diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index d6a52dd..aef5a1d 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -33,7 +33,7 @@ public void onChat(ChatEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - exploitPlayerManager.get(proxiedPlayer.getName()).addVls(plugin, event, proxiedPlayer, commandsModule, 1); + exploitPlayerManager.get(proxiedPlayer.getUniqueId()).addVls(plugin, event, proxiedPlayer, commandsModule, 1); } break; diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index d662cf6..0343899 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -21,7 +21,7 @@ public DisconnectListener(final ModuleManager moduleManager) { @EventHandler public void onDisconnect(final PlayerDisconnectEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getName()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId()); if (exploitPlayer != null) { exploitPlayer.clearChannels(); diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index d05f650..d974477 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -46,20 +46,19 @@ public void onPostLogin(final PostLoginEvent event) { else lang = "en"; - if (nullAddressModule.isEnabled() && address == null) { + if (nullAddressModule.isEnabled() && (address == null || address.isUnresolved())) { player.disconnect(new TextComponent(messagesModule.getKickMessage(nullAddressModule, lang))); } else { final String playerName = player.getName(); - exploitPlayerManager.add(playerName); - if (uuidSpoofModule.isEnabled()) { plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final String originalUUID = player.getUniqueId().toString().replace("-", ""); + final UUID uuid = player.getUniqueId(); + final String originalUUID = uuid.toString().replace("-", ""); final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(playerName); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index 4a8fc42..b7859c8 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -9,13 +9,15 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.UUID; import java.util.logging.Level; public class BungeeExploitPlayerManager implements ExploitPlayerManager { private final ModuleManager moduleManager; private final ProxyServer proxy; - private final Map exploitPlayers = new HashMap<>(); + private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; BungeeExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { @@ -25,11 +27,6 @@ public class BungeeExploitPlayerManager implements ExploitPlayerManager { reload(); } - @Override - public ExploitPlayer get(final String name) { - return exploitPlayers.getOrDefault(name, null); - } - @Override public int getSize() { return exploitPlayers.size(); @@ -41,9 +38,17 @@ public int getPunishments() { } @Override - public void add(final String name) { - if (!exploitPlayers.containsKey(name)) - exploitPlayers.put(name, new BungeeExploitPlayer(name, moduleManager)); + public ExploitPlayer get(final UUID uuid) { + ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + + if (exploitPlayer == null) { + final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(uuid); + + exploitPlayer = new BungeeExploitPlayer(player.getName(), moduleManager); + exploitPlayers.put(uuid, exploitPlayer); + } + + return exploitPlayer; } @Override @@ -54,22 +59,25 @@ public int addPunishment() { @Override public void reload() { exploitPlayers.clear(); - - for (final ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) - add(player.getName()); } @Override public void clear() { + final BungeeCord bungeeCord = BungeeCord.getInstance(); + final Iterator iterator = exploitPlayers.keySet().iterator(); boolean cleared = false; - for (final String name : exploitPlayers.keySet().toArray(new String[0])) - if (proxy.getPlayer(name) == null) { - exploitPlayers.remove(name); + while (iterator.hasNext()) { + final UUID uuid = iterator.next(); + + if (bungeeCord.getPlayer(uuid) == null) { + iterator.remove(); cleared = true; } + } - if (cleared) - proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + if (cleared) { + bungeeCord.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + } } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index d3ff7b4..d1139a9 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -20,9 +20,9 @@ public class BungeeCustomPayloadModule implements CustomPayloadModule { private Plugin plugin; private ModuleManager moduleManager; private Violations violations; - private double cancelVls, reduceVls; - private int maxChannels; - private boolean enabled; + private int maxChannelsAmount, bigDataMaxBytes; + private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; + private boolean enabled, empty; public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -66,7 +66,11 @@ public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble("custompayload.cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.violations = new BungeeViolations(configYml1.getSection("custompayload.violations")); - this.maxChannels = configYml1.getInt("custompayload.max_channels"); + this.empty = configYml1.getBoolean(name + ".invalid.empty"); + this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); + this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); + this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); + this.bigDataMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes"); for (final String key : configurationSection.getKeys()) multipliers.put(key, configurationSection.getDouble(key)); @@ -79,19 +83,27 @@ public void checkPacket(final Object event) { final Connection sender = pluginMessageEvent.getSender(); if (sender instanceof ProxiedPlayer && sender.isConnected()) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getName()); - final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); final String tag = pluginMessageEvent.getTag(); - if (tag != null && tag.equals("REGISTER")) { - int channels = content.split("[\u0001-\u0009]").length; - - if (exploitPlayer.addChannels(channels) > maxChannels) - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", 9999D)); - } else { - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } + if (tag != null && !tag.isEmpty()) { + final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); + + if (!content.isEmpty()) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getUniqueId()); + + if (exploitPlayer != null) { + if (tag.toLowerCase().endsWith("register") && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + } else if (content.length() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); + } else { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } + } else if (empty) + pluginMessageEvent.setCancelled(true); + } else if (empty) + pluginMessageEvent.setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java index 7179f18..815a7cb 100644 --- a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java @@ -16,7 +16,5 @@ public interface ExploitPlayer { void addVls(final Object plugin, final Object event, final Object player, final CancellableModule module, final double amount); - String getName(); - void clearViolations(); } diff --git a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java index 18d19b5..82b6d63 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java @@ -2,16 +2,16 @@ import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; +import java.util.UUID; + public interface ExploitPlayerManager { - ExploitPlayer get(final String name); + ExploitPlayer get(final UUID uuid); int getSize(); int getPunishments(); - void add(final String name); - int addPunishment(); void clear(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 71f33b7..6d097e7 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -1,7 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; public interface PacketsModule extends CancellableModule { - void checkPacket(final Object packetEvent, final String packetName); + void checkPacket(final Object packetEvent); double getMultiplier(final String packetName); From de70d799ce7c20e37d892031c2b8bb351b6e6b24 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Thu, 13 Feb 2020 14:36:51 -0300 Subject: [PATCH 036/336] Updated source --- src/bungee.yml | 2 +- src/config.yml | 47 ++++--- src/plugin.yml | 4 +- .../adapters/BlockDigPacketAdapter.java | 28 +++-- .../adapters/BlockPlacePacketAdapter.java | 24 ++-- .../adapters/CustomPayloadPacketAdapter.java | 35 ------ .../SetCreativeSlotPacketAdapter.java | 105 ++++++++-------- .../adapters/WindowClickPacketAdapter.java | 61 +++++---- .../initializers/AdapterInitializer.java | 33 +++-- .../instanceables/BukkitExploitPlayer.java | 76 ++++++----- .../listeners/PlayerCommandListener.java | 12 +- .../bukkit/listeners/PlayerLoginListener.java | 27 ++-- .../bukkit/listeners/PlayerQuitListener.java | 3 +- .../listeners/PlayerTabCompleteListener.java | 2 +- .../bukkit/listeners/SignChangeListener.java | 24 ++-- .../managers/BukkitExploitPlayerManager.java | 16 ++- .../bukkit/managers/BukkitModuleManager.java | 2 +- .../modules/BukkitCustomPayloadModule.java | 40 +++--- .../modules/BukkitNullAddressModule.java | 2 +- .../bukkit/modules/BukkitPacketsModule.java | 119 +++++++++--------- .../bukkit/modules/BukkitUUIDSpoofModule.java | 2 +- .../instanceables/BungeeExploitPlayer.java | 26 ++-- .../bungee/listeners/ChatListener.java | 35 +++--- .../bungee/listeners/DisconnectListener.java | 2 +- .../listeners/PluginMessageListener.java | 2 +- .../bungee/listeners/PostLoginListener.java | 40 +++--- .../managers/BungeeExploitPlayerManager.java | 16 +-- .../bungee/managers/BungeeModuleManager.java | 27 ++-- .../modules/BungeeCustomPayloadModule.java | 34 +++-- .../modules/BungeeNullAddressModule.java | 2 +- .../bungee/modules/BungeeUUIDSpoofModule.java | 2 +- .../instanceables/ExploitPlayer.java | 6 +- .../managers/ExploitPlayerManager.java | 2 +- .../modules/CustomPayloadModule.java | 2 +- .../interfaces/modules/PacketsModule.java | 2 +- 35 files changed, 449 insertions(+), 413 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java diff --git a/src/bungee.yml b/src/bungee.yml index 3941461..3a7bcd4 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.1.4 +version: 1.1.6 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index f0848bc..9e8ff56 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,45 +1,41 @@ # ExploitFixer developed by LinsaFTW. # -# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands check works on BungeeCord. +# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands checks works on BungeeCord. +# This is because the other checks doesn't do anything on BungeeCord. # The other checks require to be installed in Spigot with ProtocolLib. -# It is recommended to install the plugin on BungeeCord and all Spigot servers. -# The plugin will increase the performance by limiting and cancelling invalid packets. +# You need to install the plugin on BungeeCord and all Spigot servers. +# Shows notifications to players with permissions. notifications: enabled: true # Placeholders: %player% %ping% %check% %vls% message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" -# Prevents null addresses from fake bungee IP-Forward to bypass IPWhitelist. -# WARNING: This is not a real fix, to fix this you need to host your network on a dedicated/vps machine -# and properly setup a firewall/airgap technique to prevent direct connections to your server. -# Follow this guide: https://www.spigotmc.org/wiki/firewall-guide/ -nulladdress: - enabled: true +# Prevents a variety of exploits that occur on connection establish. +# Players wont be able to type commands until the connection is secured. (You wont notice this) +connection: + # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. + # NullAddress only affects non-firewalled servers using IP Whitelist. + nulladdress: true -# Checks if players have a invalid UUID. (Works with premium and no premium servers) -uuidspoof: - # Do you want to enable this module? - enabled: true + # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. + # UUIDSpoof only affects non-firewalled servers with BungeeCord: true. + uuidspoof: true -# Removes some ItemMeta from items to fix invalid tags, enchants, effects, etc... +# Fixes ItemMeta from items to remove invalid tags, enchants, effects, etc... itemsfix: enabled: true # Maximum enchant level obtainable with creative packets. (Set to 0 to disable custom enchants) enchant_limit: 0 -# Limits custom_payload packets to avoid exploits. +# Prevents the use of CustomPayload packets to exploit the server. custompayload: - # Do you want to enable this module? enabled: true # Blocks different types of invalid packets. invalid: - # Cancells packets with null/empty tags or content. - empty: true - # Limits the amount of channels registered per player. max_channels: # Vls to add when max channels are exceed. (Set to 0 to disable) @@ -62,6 +58,7 @@ custompayload: # Amount of violations to reduce per second. reduce_vls: 400 + # When a valid packet is sent the following amount of vls will be applied. multipliers: OTHER: 0.1 MC|BSign: 50 @@ -69,13 +66,15 @@ custompayload: MC|BOpen: 50 # Placeholders: %player% + # Commands to execute when a players reachs a violation level. violations: 400: - "notification" 600: - - "kick" - "notification" + - "kick" +# Prevents the use of packets to exploit the server. packets: enabled: true @@ -152,8 +151,8 @@ packets: 500: - "notification" 1000: - - "kick" - "notification" + - "kick" # Checks if players try to crash/exploit the server with commands. commands: @@ -183,8 +182,8 @@ commands: # Placeholders: %player% violations: 1: - - "kick" - "notification" + - "kick" # Prevents invalid sign creation. signs: @@ -201,5 +200,5 @@ signs: # Placeholders: %player% violations: 1: - - "kick" - - "notification" \ No newline at end of file + - "notification" + - "kick" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 3efd625..9fb7b94 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,11 +1,11 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.1.4 +version: 1.1.6 author: 2LS api-version: '1.13' load: STARTUP depend: [ProtocolLib] -loadbefore: [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaPotions, ProtocolSupport] +loadbefore: [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaRewindPotions, ProtocolSupport] commands: exploitfixer: description: The main ExploitFixer command diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 949f4a7..0863a14 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -14,6 +14,8 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.util.UUID; + public class BlockDigPacketAdapter extends PacketAdapter { private final PacketType packetType; private final ModuleManager moduleManager; @@ -28,14 +30,14 @@ public BlockDigPacketAdapter(final Plugin plugin, final ListenerPriority listene public void onPacketReceiving(final PacketEvent event) { if (!event.isCancelled()) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); + final double blockDig = packetsModule.getBlockDig(); - if (packetsModule.isEnabled()) { - final double blockDig = packetsModule.getBlockDig(); - - if (blockDig > 0) { - final Player player = event.getPlayer(); + if (blockDig > 0) { + final Player player = event.getPlayer(); - if (player != null && player.isOnline()) { + if (player != null && player.isOnline()) { + try { + final UUID uuid = player.getUniqueId(); final StructureModifier itemModifier = event.getPacket().getItemModifier(); if (itemModifier != null && itemModifier.size() > 0) { @@ -49,7 +51,7 @@ public void onPacketReceiving(final PacketEvent event) { itemOnHand = new ItemStack(Material.AIR); if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockDig); @@ -58,13 +60,15 @@ public void onPacketReceiving(final PacketEvent event) { } } } - } else if (packetsModule.isOffline()) + } catch (final UnsupportedOperationException ignored) { event.setCancelled(true); - } - - if (!event.isCancelled()) - packetsModule.checkPacket(event); + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } + + if (!event.isCancelled()) + packetsModule.check(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 03197e1..375b888 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -14,6 +14,8 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.util.UUID; + public class BlockPlacePacketAdapter extends PacketAdapter { private final PacketType packetType; private final ModuleManager moduleManager; @@ -28,14 +30,14 @@ public BlockPlacePacketAdapter(final Plugin plugin, final ListenerPriority liste public void onPacketReceiving(final PacketEvent event) { if (!event.isCancelled()) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); + final double blockPlace = packetsModule.getBlockPlace(); - if (packetsModule.isEnabled()) { - final double blockPlace = packetsModule.getBlockPlace(); - - if (blockPlace > 0) { - final Player player = event.getPlayer(); + if (blockPlace > 0) { + final Player player = event.getPlayer(); - if (player != null && player.isOnline()) { + if (player != null && player.isOnline()) { + try { + final UUID uuid = player.getUniqueId(); final StructureModifier itemModifier = event.getPacket().getItemModifier(); if (itemModifier != null && itemModifier.size() > 0) { @@ -49,7 +51,7 @@ public void onPacketReceiving(final PacketEvent event) { itemOnHand = new ItemStack(Material.AIR); if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockPlace); @@ -58,13 +60,15 @@ public void onPacketReceiving(final PacketEvent event) { } } } - } else if (packetsModule.isOffline()) + } catch (final UnsupportedOperationException ignored) { event.setCancelled(true); - } + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); } if (!event.isCancelled()) - packetsModule.checkPacket(event); + packetsModule.check(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java deleted file mode 100644 index 43bd2dc..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/CustomPayloadPacketAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class CustomPayloadPacketAdapter extends PacketAdapter { - private final PacketType packetType; - private final CustomPayloadModule customPayloadModule; - private final PacketsModule packetsModule; - - public CustomPayloadPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { - super(plugin, listenerPriority, packetType); - this.packetType = packetType; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - if (customPayloadModule.isEnabled()) { - customPayloadModule.checkPacket(event); - } - - if (!event.isCancelled()) - packetsModule.checkPacket(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 4bd6a9e..69eb4d9 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -22,12 +22,10 @@ import java.util.Map; public class SetCreativeSlotPacketAdapter extends PacketAdapter { - private final PacketType packetType; private final ModuleManager moduleManager; public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); - this.packetType = packetType; this.moduleManager = moduleManager; } @@ -35,76 +33,77 @@ public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority public void onPacketReceiving(final PacketEvent event) { if (!event.isCancelled()) { final PacketsModule packetsModule = moduleManager.getPacketsModule(); + final Player player = event.getPlayer(); - if (packetsModule.isEnabled()) { - final Player player = event.getPlayer(); + if (player != null && player.isOnline()) { + final ItemsFixModule itemsFixModule = moduleManager.getItemsFixModule(); + final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - if (player != null && player.isOnline()) { - final ItemsFixModule itemsFixModule = moduleManager.getItemsFixModule(); - final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - - if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); + if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { + try { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId(), player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); else event.setCancelled(true); - } else if (itemsFixModule.isEnabled()) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); - final ItemStack itemStack = itemModifier.readSafely(0); - - if (itemStack != null) { - final Material material = itemStack.getType(); - final ItemMeta itemMeta = itemStack.getItemMeta(); - final int enchantLimit = itemsFixModule.getEnchantLimit(); - final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); - - if (enchantLimit > 0) { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - if (enchantments.get(enchantment) > enchantLimit) - itemStackRemake.removeEnchantment(enchantment); - } else { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - itemStackRemake.removeEnchantment(enchantment); - } + } catch (final UnsupportedOperationException ignored) { + event.setCancelled(true); + } + } else if (itemsFixModule.isEnabled()) { + final StructureModifier itemModifier = event.getPacket().getItemModifier(); + final ItemStack itemStack = itemModifier.readSafely(0); + + if (itemStack != null) { + final Material material = itemStack.getType(); + final ItemMeta itemMeta = itemStack.getItemMeta(); + final int enchantLimit = itemsFixModule.getEnchantLimit(); + final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); - if (itemStack.hasItemMeta()) { - final String displayName = itemMeta.getDisplayName(); - final List lore = itemMeta.getLore(); - final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + if (enchantLimit > 0) { + final Map enchantments = itemStackRemake.getEnchantments(); - if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; - final BookMeta newBookMeta = (BookMeta) newItemMeta; + for (final Enchantment enchantment : enchantments.keySet()) + if (enchantments.get(enchantment) > enchantLimit) + itemStackRemake.removeEnchantment(enchantment); + } else { + final Map enchantments = itemStackRemake.getEnchantments(); - newBookMeta.setTitle(bookMeta.getTitle()); - newBookMeta.setAuthor(bookMeta.getAuthor()); - newBookMeta.setPages(bookMeta.getPages()); - } + for (final Enchantment enchantment : enchantments.keySet()) + itemStackRemake.removeEnchantment(enchantment); + } - if (displayName != null && displayName.getBytes().length < 128) - newItemMeta.setDisplayName(displayName); + if (itemStack.hasItemMeta()) { + final String displayName = itemMeta.getDisplayName(); + final List lore = itemMeta.getLore(); + final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - if (lore != null && lore.toString().getBytes().length < 1024) - newItemMeta.setLore(lore); + if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + final BookMeta newBookMeta = (BookMeta) newItemMeta; - itemStackRemake.setItemMeta(newItemMeta); + newBookMeta.setTitle(bookMeta.getTitle()); + newBookMeta.setAuthor(bookMeta.getAuthor()); + newBookMeta.setPages(bookMeta.getPages()); } - itemModifier.write(0, itemStack); + if (displayName != null && displayName.getBytes().length < 128) + newItemMeta.setDisplayName(displayName); + + if (lore != null && lore.toString().getBytes().length < 1024) + newItemMeta.setLore(lore); + + itemStackRemake.setItemMeta(newItemMeta); } + + itemModifier.write(0, itemStack); } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - } + } + } else if (packetsModule.isOffline()) + event.setCancelled(true); if (!event.isCancelled()) - packetsModule.checkPacket(event); + packetsModule.check(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 72d25f1..5dc1880 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -15,78 +15,73 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.util.UUID; + public class WindowClickPacketAdapter extends PacketAdapter { - private final PacketType packetType; private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; public WindowClickPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); - this.packetType = packetType; this.packetsModule = moduleManager.getPacketsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @Override public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { + if (!event.isCancelled()) { final double windowClick = packetsModule.getWindowClick(); if (windowClick > 0) { final Player player = event.getPlayer(); if (player != null && player.isOnline()) { - final PacketContainer packet = event.getPacket(); - final StructureModifier integers = packet.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); + try { + final UUID uuid = player.getUniqueId(); + final PacketContainer packet = event.getPacket(); + final StructureModifier integers = packet.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); - if (inventoryView == null) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); + if (inventoryView == null) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - // Divide by 10 because of false positives. - if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 10); - else - event.setCancelled(true); - } else if (integers.size() > 1) { - final int slot = inventoryView.convertSlot(integers.readSafely(1)); - final int maxSlots = inventoryView.countSlots(); + } else if (integers.size() > 1) { + final int slot = inventoryView.convertSlot(integers.readSafely(1)); + final int maxSlots = inventoryView.countSlots(); - if (slot >= maxSlots) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); + if (slot >= maxSlots) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - else - event.setCancelled(true); - } else { - final StructureModifier structureModifier = packet.getItemModifier(); + } else { + final StructureModifier structureModifier = packet.getItemModifier(); - if (structureModifier.size() > 0 && slot > 0) { - final ItemStack itemUse = structureModifier.readSafely(0); + if (structureModifier.size() > 0 && slot > 0) { + final ItemStack itemUse = structureModifier.readSafely(0); - if (itemUse != null) { - final ItemStack itemOnHand = inventoryView.getItem(slot); + if (itemUse != null) { + final ItemStack itemOnHand = inventoryView.getItem(slot); - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - // Divide by 12 because of false positives. - if (exploitPlayer != null) + // Divide by 12 because of false positives. exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 12); - else - event.setCancelled(true); + } } } } } + } catch (final UnsupportedOperationException ignored) { + event.setCancelled(true); } } else if (packetsModule.isOffline()) event.setCancelled(true); } if (!event.isCancelled()) - packetsModule.checkPacket(event); + packetsModule.check(event); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 06f1242..6e6475d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -7,31 +7,48 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.*; +import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; public class AdapterInitializer { public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager) { final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); final PacketsModule packetsModule = moduleManager.getPacketsModule(); + final CustomPayloadModule customPayloadModule = moduleManager.getCustomPayloadModule(); protocolManager.removePacketListeners(plugin); for (final PacketType packetType : PacketType.Play.Client.getInstance()) { - if (packetsModule.isEnabled()) + if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD && customPayloadModule.isEnabled()) { protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { @Override public void onPacketReceiving(final PacketEvent event) { - packetsModule.checkPacket(event); + customPayloadModule.check(event); + + if (packetsModule.isEnabled()) + packetsModule.check(event); } }); + } else if (packetsModule.isEnabled()) { + protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { + packetsModule.check(event); + } + }); + } } - protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_DIG, moduleManager)); - protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_PLACE, moduleManager)); - protocolManager.addPacketListener(new CustomPayloadPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.CUSTOM_PAYLOAD, moduleManager)); - protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); - protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.WINDOW_CLICK, moduleManager)); + if (packetsModule.isEnabled()) { + protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_DIG, moduleManager)); + protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_PLACE, moduleManager)); + protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); + protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.WINDOW_CLICK, moduleManager)); + } } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index cc81bdf..be9c6c2 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; import twolovers.exploitfixer.bukkit.nms.NMSManager; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -32,6 +33,7 @@ public class BukkitExploitPlayer implements ExploitPlayer { final private Map violations = new HashMap<>(); final private String name; private String onlineUUID = null; + private boolean logged = false; private int channels = 0; private double lastViolation = 0; @@ -91,42 +93,42 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof Player) { - final Player player = (Player) playerObject; + final Player player = (Player) playerObject; - if (player.isOnline()) { - final Violations violations = module.getViolations(); + if (player.isOnline()) { + final Violations violations = module.getViolations(); - if (violations != null) { - final Plugin plugin = (Plugin) pluginObject; - final Server server = plugin.getServer(); - final double currentTime = System.currentTimeMillis(); + if (violations != null) { + final Plugin plugin = (Plugin) pluginObject; + final Server server = plugin.getServer(); + final double currentTime = System.currentTimeMillis(); - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; - for (final CancellableModule cancellableModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(cancellableModule) - cancellableModule.getReduceVls(); + for (final CancellableModule cancellableModule : new HashSet<>(this.violations.keySet())) { + final double vls = this.violations.get(cancellableModule) - cancellableModule.getReduceVls(); - if (vls <= 0) - this.violations.remove(cancellableModule); - else - this.violations.put(cancellableModule, vls); - } + if (vls <= 0) + this.violations.remove(cancellableModule); + else + this.violations.put(cancellableModule, vls); } + } - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; - this.violations.put(module, newVls); + this.violations.put(module, newVls); - if (event instanceof Cancellable && module.getCancelVls() <= newVls) - ((Cancellable) event).setCancelled(true); + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); - for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); + for (final int threshold : violations.getViolations()) { + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); + final BukkitScheduler scheduler = server.getScheduler(); - server.getScheduler().scheduleAsyncDelayedTask(plugin, ()-> { if (commands != null && !commands.isEmpty()) for (final String punishCommand : commands) if (!punishCommand.isEmpty()) @@ -141,14 +143,15 @@ public void addVls(final Object pluginObject, final Object event, final Object p final String kickMessage = messagesModule.getKickMessage(module, locale); final Thread thread = Thread.currentThread(); - server.getScheduler().scheduleSyncDelayedTask(plugin, () -> { + scheduler.runTask(plugin, () -> { player.kickPlayer(kickMessage); thread.interrupt(); - }, 0L); + }); try { Thread.sleep(1000); - } catch (final InterruptedException ignored) {} + } catch (final InterruptedException ignored) { + } NMSManager.closeChannel(player); exploitPlayerManager.addPunishment(); @@ -158,13 +161,12 @@ public void addVls(final Object pluginObject, final Object event, final Object p else notificationsModule.sendNotification(module.getName(), player, (int) newVls); else - server.getScheduler().scheduleSyncDelayedTask(plugin, () ->server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName())), 0L); - }, 0L); - } + server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); } } + } } else if (event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); + ((Cancellable) event).setCancelled(true); } else if (event instanceof Cancellable) ((Cancellable) event).setCancelled(true); } @@ -172,4 +174,14 @@ public void addVls(final Object pluginObject, final Object event, final Object p public void clearViolations() { violations.clear(); } + + @Override + public void setLogged(final boolean logged) { + this.logged = logged; + } + + @Override + public boolean isLogged() { + return logged; + } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 3965c03..642829f 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -6,6 +6,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CommandsModule; @@ -23,14 +24,17 @@ public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleMana @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { - if (!event.isCancelled() && commandsModule.isEnabled()) { + final Player player = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (!exploitPlayer.isLogged()) { + event.setCancelled(true); + } else if (commandsModule.isEnabled()) { final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) if (message.startsWith(command + " ") || message.endsWith(command)) { - final Player player = event.getPlayer(); - - exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, commandsModule, player, commandsModule, 1); + exploitPlayer.addVls(plugin, commandsModule, player, commandsModule, 1); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 471dd5a..9985393 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -6,6 +6,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; @@ -45,31 +46,41 @@ public void onPlayerLogin(final PlayerLoginEvent event) { locale = player.spigot().getLocale().substring(0, 2); if (nullAddressModule.isEnabled() && address == null) { - event.setKickMessage(messagesModule.getKickMessage(nullAddressModule, locale)); + final String nullAddressKickMessage = messagesModule.getKickMessage(nullAddressModule, locale); + + event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + player.kickPlayer(nullAddressKickMessage); } else { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + if (uuidSpoofModule.isEnabled()) { + final BukkitScheduler scheduler = plugin.getServer().getScheduler(); final String playerName = player.getName(); - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - final String originalUUID = player.getUniqueId().toString().replace("-", ""); + scheduler.runTaskAsynchronously(plugin, () -> { + final String originalUUID = uuid.toString().replace("-", ""); final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - event.setKickMessage(messagesModule.getKickMessage(uuidSpoofModule, locale)); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + final String uuidSpoofKickMessage = messagesModule.getKickMessage(uuidSpoofModule, locale); + + scheduler.runTaskLater(plugin, () -> player.kickPlayer(uuidSpoofKickMessage), 1L); } } + + exploitPlayer.setLogged(true); }); - } + } else + exploitPlayer.setLogged(true); + } if (player.hasPermission("exploitfixer.notifications")) { notificationsModule.setNotifications(player, true); } - } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java index 62e8861..3e97fb7 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -21,11 +21,12 @@ public PlayerQuitListener(final ModuleManager variables) { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); if (exploitPlayer != null) { exploitPlayer.clearChannels(); exploitPlayer.clearViolations(); + exploitPlayer.setLogged(false); } notificationsModule.setNotifications(player, false); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java index 06f6ecf..45d608e 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java @@ -30,7 +30,7 @@ public void onPlayerCommand(final TabCompleteEvent event) { if (message.startsWith(command + " ") || message.endsWith(command)) { final Player player = (Player) event.getSender(); - exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, commandsModule, player, commandsModule, 1); + exploitPlayerManager.get(player.getUniqueId(), player).addVls(plugin, commandsModule, player, commandsModule, 1); break; } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java index e98601f..d03aea8 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java @@ -6,11 +6,13 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.SignsModule; import java.nio.charset.StandardCharsets; +import java.util.UUID; public class SignChangeListener implements Listener { private final Plugin plugin; @@ -28,15 +30,21 @@ public void onSignChange(final SignChangeEvent event) { if (signsModule.isEnabled()) { final Player player = event.getPlayer(); - for (final String line : event.getLines()) { - if (line.length() >= 46) { - exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, event, player, signsModule, 1); - return; - } else if (line.getBytes(StandardCharsets.UTF_8).length > signsModule.getMaxBytes()) { - exploitPlayerManager.get(player.getUniqueId()).addVls(plugin, event, player, signsModule, 1); - return; + if (player != null) { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + + for (final String line : event.getLines()) { + if (line.length() >= 46) { + exploitPlayer.addVls(plugin, event, player, signsModule, 1); + break; + } else if (line.getBytes(StandardCharsets.UTF_8).length > signsModule.getMaxBytes()) { + exploitPlayer.addVls(plugin, event, player, signsModule, 1); + break; + } } - } + } else + event.setCancelled(true); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 40fae72..18a5b55 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -1,6 +1,5 @@ package twolovers.exploitfixer.bukkit.managers; -import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; @@ -15,24 +14,24 @@ import java.util.logging.Level; public class BukkitExploitPlayerManager implements ExploitPlayerManager { - final private ModuleManager moduleManager; - final private Map exploitPlayers = new HashMap<>(); + private final Server server; + private final ModuleManager moduleManager; + private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; - BukkitExploitPlayerManager(final ModuleManager moduleManager) { + BukkitExploitPlayerManager(final Server server, final ModuleManager moduleManager) { + this.server = server; this.moduleManager = moduleManager; reload(); } @Override - public ExploitPlayer get(final UUID uuid) { + public ExploitPlayer get(final UUID uuid, final Object playerObject) { ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); if (exploitPlayer == null) { - final Player player = Bukkit.getPlayer(uuid); - - exploitPlayer = new BukkitExploitPlayer(player.getName(), moduleManager); + exploitPlayer = new BukkitExploitPlayer(((Player) playerObject).getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -41,7 +40,6 @@ public ExploitPlayer get(final UUID uuid) { @Override public void clear() { - final Server server = Bukkit.getServer(); final Iterator iterator = exploitPlayers.keySet().iterator(); boolean cleared = false; diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 848ad74..17ceb67 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -31,7 +31,7 @@ public BukkitModuleManager(final Plugin plugin, final Configuration configYml, f this.notificationsModule = new BukkitNotificationsModule(configYml); this.uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); this.packetsModule = new BukkitPacketsModule(plugin, this, configYml); - this.exploitPlayerManager = new BukkitExploitPlayerManager(this); + this.exploitPlayerManager = new BukkitExploitPlayerManager(plugin.getServer(), this); this.signsModule = new BukkitSignsModule(configYml); this.nullAddressModule = new BukkitNullAddressModule(configYml); } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index ed731cf..f0bf70e 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.UUID; public class BukkitCustomPayloadModule implements CustomPayloadModule { private Map multipliers = new HashMap<>(); @@ -25,7 +26,7 @@ public class BukkitCustomPayloadModule implements CustomPayloadModule { private Violations violations; private int maxChannelsAmount, bigDataMaxBytes; private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; - private boolean enabled, empty; + private boolean enabled; public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -69,7 +70,6 @@ public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - this.empty = configYml1.getBoolean(name + ".invalid.empty"); this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); @@ -80,34 +80,40 @@ public void reload(final Object configYml) { } @Override - public void checkPacket(final Object event) { + public void check(final Object event) { if (event instanceof PacketEvent) { final PacketEvent packetEvent = (PacketEvent) event; - final Player sender = packetEvent.getPlayer(); - if (sender != null && sender.isOnline()) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(sender.getUniqueId()); + if (!packetEvent.isCancelled()) { + final Player player = packetEvent.getPlayer(); - if (exploitPlayer != null) { + if (player != null && player.isOnline()) { final PacketContainer packet = packetEvent.getPacket(); final StructureModifier stringStructureModifier = packet.getStrings(); final String tag = stringStructureModifier.readSafely(0); - if (tag != null && !tag.isEmpty()) { + if (tag != null) { final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); final String content = byteBufModifier.readSafely(0).toString(Charsets.UTF_8); - if (content != null && !content.isEmpty()) { - if (tag.toLowerCase().endsWith("register") && content.split("\000").length > maxChannelsAmount) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); - } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); - } else { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + if (content != null) { + try { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + + if (tag.toLowerCase().endsWith("register") && content.split("\000").length > maxChannelsAmount) { + exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + } else if (content.length() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault(tag, bigDataVls)); + } else { + exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } catch (final UnsupportedOperationException e) { + ((PacketEvent) event).setCancelled(true); } - } else if (empty) + } else packetEvent.setCancelled(true); - } else if (empty) + } else packetEvent.setCancelled(true); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java index eebb0e8..c4ba594 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java @@ -25,6 +25,6 @@ public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled"); + this.enabled = configYml1.getBoolean("connection." + name); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 47955d5..8bcad58 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; public class BukkitPacketsModule implements PacketsModule { @@ -82,83 +83,89 @@ public boolean isEnabled() { } @Override - public void checkPacket(final Object packetEvent) { - if (enabled) { - final PacketEvent event = (PacketEvent) packetEvent; + public void check(final Object event) { + if (event instanceof PacketEvent) { + final PacketEvent packetEvent = (PacketEvent) event; - if (!event.isCancelled()) { - final Player player = event.getPlayer(); + if (!packetEvent.isCancelled()) { + final Player player = packetEvent.getPlayer(); + final PacketType packetType = packetEvent.getPacketType(); if (player != null && player.isOnline()) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId()); - - if (bigDataVls > 0) { - final PacketContainer packet = event.getPacket(); - final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier blockDataModifier = packet.getBlockData(); - final StructureModifier integers = packet.getIntegers(); - final StructureModifier longs = packet.getLongs(); - final StructureModifier floats = packet.getFloat(); - final StructureModifier doubles = packet.getDoubles(); - final StructureModifier strings = packet.getStrings(); - final StructureModifier> nbtModifier = packet.getNbtModifier(); - final AtomicInteger packetSize = new AtomicInteger(0); - - if (itemModifier.size() > bigDataMaxStructure || blockDataModifier.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } else { - if (!event.isCancelled()) { - for (final ItemStack itemStack : itemModifier.getValues()) { - if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) - break; + try { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + + if (bigDataVls > 0) { + final PacketContainer packet = packetEvent.getPacket(); + final StructureModifier itemModifier = packet.getItemModifier(); + final StructureModifier blockDataModifier = packet.getBlockData(); + final StructureModifier integers = packet.getIntegers(); + final StructureModifier longs = packet.getLongs(); + final StructureModifier floats = packet.getFloat(); + final StructureModifier doubles = packet.getDoubles(); + final StructureModifier strings = packet.getStrings(); + final StructureModifier> nbtModifier = packet.getNbtModifier(); + final AtomicInteger packetSize = new AtomicInteger(0); + + if (itemModifier.size() > bigDataMaxStructure || blockDataModifier.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { + exploitPlayer.addVls(plugin, packetEvent, player, this, bigDataVls); + } else { + if (!packetEvent.isCancelled()) { + for (final ItemStack itemStack : itemModifier.getValues()) { + if (checkItem(itemStack, packetEvent, exploitPlayer, player, packetSize)) + break; + } } - } - if (!event.isCancelled()) { - for (final WrappedBlockData blockData : blockDataModifier.getValues()) { - if (blockData != null) { - int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; + if (!packetEvent.isCancelled()) { + for (final WrappedBlockData blockData : blockDataModifier.getValues()) { + if (blockData != null) { + int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); + packetSize.addAndGet(dataBytes); + } } - } - for (final String string : strings.getValues()) { - if (string != null) { - int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; + for (final String string : strings.getValues()) { + if (string != null) { + int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); + packetSize.addAndGet(dataBytes); + } } - } - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - int dataBytes = nbtBase.getValue().toString().getBytes(StandardCharsets.UTF_8).length; + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + int dataBytes = nbtBase.getValue().toString().getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); + packetSize.addAndGet(dataBytes); + } } - } - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - if (byteBuf != null) - packetSize.addAndGet(byteBuf.capacity()); + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + if (byteBuf != null) + packetSize.addAndGet(byteBuf.capacity()); + } } - } - if (packetSize.get() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + if (packetSize.get() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, packetEvent, player, this, bigDataVls); + } } } } - } - if (!event.isCancelled()) - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(event.getPacketType().name())); - } else if (offline && event.getPacketType() != PacketType.Play.Client.CUSTOM_PAYLOAD) - event.setCancelled(true); + if (!packetEvent.isCancelled()) + exploitPlayer.addVls(plugin, packetEvent, player, this, getMultiplier(packetEvent.getPacketType().name())); + } catch (final UnsupportedOperationException ignored) { + packetEvent.setCancelled(true); + } + } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD) + packetEvent.setCancelled(true); } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java index f2d11f4..68600b0 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java @@ -25,6 +25,6 @@ public void reload(Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled"); + this.enabled = configYml1.getBoolean("connection." + name); } } diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java index dfc2934..03a93ab 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java @@ -27,6 +27,7 @@ public class BungeeExploitPlayer implements ExploitPlayer { final private Map violations = new HashMap<>(); final private String name; private String onlineUUID = null; + private boolean logged = false; private int channels = 0; private double lastViolation = 0; @@ -37,11 +38,6 @@ public BungeeExploitPlayer(final String name, final ModuleManager moduleManager) this.name = name; } - @Override - public int getChannels() { - return channels; - } - @Override public void clearChannels() { this.channels = 0; @@ -89,12 +85,12 @@ public String getOnlineUUID() { @Override public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { if (playerObject instanceof ProxiedPlayer) { - final ProxiedPlayer player = (ProxiedPlayer) playerObject; + final ProxiedPlayer player = (ProxiedPlayer) playerObject; - if (player.isConnected()) { - final Violations violations = module.getViolations(); + if (player.isConnected()) { + final Violations violations = module.getViolations(); - if (violations != null) { + if (violations != null) { final Plugin plugin = (Plugin) pluginObject; final ProxyServer server = plugin.getProxy(); @@ -146,7 +142,7 @@ public void addVls(final Object pluginObject, final Object event, final Object p } } } else if (event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); + ((Cancellable) event).setCancelled(true); } else if (event instanceof Cancellable) ((Cancellable) event).setCancelled(true); } @@ -155,4 +151,14 @@ public void addVls(final Object pluginObject, final Object event, final Object p public void clearViolations() { violations.clear(); } + + @Override + public void setLogged(final boolean logged) { + this.logged = logged; + } + + @Override + public boolean isLogged() { + return logged; + } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index aef5a1d..16d64a2 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -6,6 +6,7 @@ import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; +import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CommandsModule; @@ -22,22 +23,26 @@ public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { } @EventHandler(priority = -128) - public void onChat(ChatEvent event) { - if (!event.isCancelled() && commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - - for (final String command : commandsModule.getCommands()) - if (message.startsWith(command + " ") || message.endsWith(command)) { - final Connection connection = event.getSender(); - - if (connection instanceof ProxiedPlayer) { - final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - - exploitPlayerManager.get(proxiedPlayer.getUniqueId()).addVls(plugin, event, proxiedPlayer, commandsModule, 1); + public void onChat(final ChatEvent event) { + if (!event.isCancelled()) { + final Connection connection = event.getSender(); + + if (connection instanceof ProxiedPlayer) { + final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); + + if (!exploitPlayer.isLogged()) { + event.setCancelled(true); + } else if (commandsModule.isEnabled()) { + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + + for (final String command : commandsModule.getCommands()) + if (message.startsWith(command + " ") || message.endsWith(command)) { + exploitPlayer.addVls(plugin, event, proxiedPlayer, commandsModule, 1); + break; + } } - - break; - } + } } } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index 0343899..54e4bf4 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -21,7 +21,7 @@ public DisconnectListener(final ModuleManager moduleManager) { @EventHandler public void onDisconnect(final PlayerDisconnectEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId()); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); if (exploitPlayer != null) { exploitPlayer.clearChannels(); diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index 8a2afca..aa0dfbb 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -16,7 +16,7 @@ public PluginMessageListener(final ModuleManager moduleManager) { @EventHandler(priority = -128) public void onPluginMessage(final PluginMessageEvent event) { if (!event.isCancelled() && customPayloadModule.isEnabled()) - customPayloadModule.checkPacket(event); + customPayloadModule.check(event); } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index d974477..7351d1f 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -5,6 +5,7 @@ import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -36,41 +37,44 @@ public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(final PostLoginEvent event) { - final ProxiedPlayer player = event.getPlayer(); - final InetSocketAddress address = player.getAddress(); - final Locale locale = player.getLocale(); - final String lang; + final ProxiedPlayer proxiedPlayer = event.getPlayer(); + final InetSocketAddress address = proxiedPlayer.getAddress(); + final Locale playerLocale = proxiedPlayer.getLocale(); + final String locale; - if (locale != null) - lang = locale.toLanguageTag().substring(0, 2); + if (playerLocale != null) + locale = playerLocale.toLanguageTag().substring(0, 2); else - lang = "en"; + locale = "en"; if (nullAddressModule.isEnabled() && (address == null || address.isUnresolved())) { - player.disconnect(new TextComponent(messagesModule.getKickMessage(nullAddressModule, lang))); + proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage(nullAddressModule, locale))); } else { - final String playerName = player.getName(); + final UUID uuid = proxiedPlayer.getUniqueId(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); if (uuidSpoofModule.isEnabled()) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final UUID uuid = player.getUniqueId(); + final TaskScheduler scheduler = plugin.getProxy().getScheduler(); + final String playerName = proxiedPlayer.getName(); + + scheduler.runAsync(plugin, () -> { final String originalUUID = uuid.toString().replace("-", ""); final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid); final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - player.disconnect(new TextComponent(messagesModule.getKickMessage(uuidSpoofModule, lang))); + final String uuidSpoofKickMessage = messagesModule.getKickMessage(uuidSpoofModule, locale); + + proxiedPlayer.disconnect(new TextComponent(uuidSpoofKickMessage)); } } - }); - } - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); - } + exploitPlayer.setLogged(true); + }); + } else + exploitPlayer.setLogged(true); } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index b7859c8..db0bb8b 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -1,6 +1,5 @@ package twolovers.exploitfixer.bungee.managers; -import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; @@ -15,14 +14,14 @@ import java.util.logging.Level; public class BungeeExploitPlayerManager implements ExploitPlayerManager { - private final ModuleManager moduleManager; private final ProxyServer proxy; + private final ModuleManager moduleManager; private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; BungeeExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { - this.moduleManager = moduleManager; this.proxy = proxy; + this.moduleManager = moduleManager; reload(); } @@ -38,13 +37,11 @@ public int getPunishments() { } @Override - public ExploitPlayer get(final UUID uuid) { + public ExploitPlayer get(final UUID uuid, final Object playerObject) { ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); if (exploitPlayer == null) { - final ProxiedPlayer player = BungeeCord.getInstance().getPlayer(uuid); - - exploitPlayer = new BungeeExploitPlayer(player.getName(), moduleManager); + exploitPlayer = new BungeeExploitPlayer(((ProxiedPlayer) playerObject).getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -63,21 +60,20 @@ public void reload() { @Override public void clear() { - final BungeeCord bungeeCord = BungeeCord.getInstance(); final Iterator iterator = exploitPlayers.keySet().iterator(); boolean cleared = false; while (iterator.hasNext()) { final UUID uuid = iterator.next(); - if (bungeeCord.getPlayer(uuid) == null) { + if (proxy.getPlayer(uuid) == null) { iterator.remove(); cleared = true; } } if (cleared) { - bungeeCord.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); } } } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 86946f2..8ec6fff 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -12,27 +12,26 @@ public class BungeeModuleManager implements ModuleManager { private CustomPayloadModule customPayloadModule; private MessagesModule messagesModule; private NotificationsModule notificationsModule; - private ReloadableModule uuidSpoofModule, nullAddressModule; + private ReloadableModule nullAddressModule, uuidSpoofModule; private ExploitPlayerManager exploitPlayerManager; public BungeeModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { - commandsModule = new BungeeCommandsModule(configYml); - customPayloadModule = new BungeeCustomPayloadModule(plugin, this, configYml); - messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); - notificationsModule = new BungeeNotificationsModule(configYml); - uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); - nullAddressModule = new BungeeNullAddressModule(configYml); - exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); + this.commandsModule = new BungeeCommandsModule(configYml); + this.customPayloadModule = new BungeeCustomPayloadModule(plugin, this, configYml); + this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new BungeeNotificationsModule(configYml); + this.nullAddressModule = new BungeeNullAddressModule(configYml); + this.uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); + this.exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); } @Override public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { - commandsModule.reload(configYml); - customPayloadModule.reload(configYml); - messagesModule.reload(messagesYml); - notificationsModule.reload(configYml); - uuidSpoofModule.reload(configYml); - exploitPlayerManager.reload(); + this.commandsModule.reload(configYml); + this.customPayloadModule.reload(configYml); + this.messagesModule.reload(messagesYml); + this.notificationsModule.reload(configYml); + this.exploitPlayerManager.reload(); } @Override diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index d1139a9..a89ae5f 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -22,7 +22,7 @@ public class BungeeCustomPayloadModule implements CustomPayloadModule { private Violations violations; private int maxChannelsAmount, bigDataMaxBytes; private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; - private boolean enabled, empty; + private boolean enabled; public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { this.plugin = plugin; @@ -66,7 +66,6 @@ public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble("custompayload.cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.violations = new BungeeViolations(configYml1.getSection("custompayload.violations")); - this.empty = configYml1.getBoolean(name + ".invalid.empty"); this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); @@ -77,7 +76,7 @@ public void reload(final Object configYml) { } @Override - public void checkPacket(final Object event) { + public void check(final Object event) { if (event instanceof PluginMessageEvent) { final PluginMessageEvent pluginMessageEvent = (PluginMessageEvent) event; final Connection sender = pluginMessageEvent.getSender(); @@ -85,24 +84,19 @@ public void checkPacket(final Object event) { if (sender instanceof ProxiedPlayer && sender.isConnected()) { final String tag = pluginMessageEvent.getTag(); - if (tag != null && !tag.isEmpty()) { + if (tag != null) { final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); - - if (!content.isEmpty()) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(((ProxiedPlayer) sender).getUniqueId()); - - if (exploitPlayer != null) { - if (tag.toLowerCase().endsWith("register") && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); - } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); - } else { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } - } - } else if (empty) - pluginMessageEvent.setCancelled(true); - } else if (empty) + final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender; + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(proxiedPlayer.getUniqueId(), proxiedPlayer); + + if (tag.toLowerCase().endsWith("register") && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + } else if (content.length() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); + } else { + exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } else pluginMessageEvent.setCancelled(true); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java index 6cfb720..17501f7 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java @@ -25,6 +25,6 @@ public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled"); + this.enabled = configYml1.getBoolean("connection." + name); } } diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java index 8629f58..2dbf60b 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java @@ -25,6 +25,6 @@ public void reload(Object configYml) { final Configuration configYml1 = (Configuration) configYml; final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled"); + this.enabled = configYml1.getBoolean("connection." + name); } } diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java index 815a7cb..f04684f 100644 --- a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java @@ -4,8 +4,6 @@ import twolovers.exploitfixer.interfaces.modules.Module; public interface ExploitPlayer { - int getChannels(); - void clearChannels(); int addChannels(final int channels); @@ -17,4 +15,8 @@ public interface ExploitPlayer { void addVls(final Object plugin, final Object event, final Object player, final CancellableModule module, final double amount); void clearViolations(); + + void setLogged(final boolean logged); + + boolean isLogged(); } diff --git a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java index 82b6d63..5dc601f 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java @@ -6,7 +6,7 @@ public interface ExploitPlayerManager { - ExploitPlayer get(final UUID uuid); + ExploitPlayer get(final UUID uuid, final Object playerObject); int getSize(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java index ddf735b..4b71ea1 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java @@ -1,5 +1,5 @@ package twolovers.exploitfixer.interfaces.modules; public interface CustomPayloadModule extends CancellableModule { - void checkPacket(final Object packetEvent); + void check(final Object packetEvent); } diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java index 6d097e7..6813777 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java @@ -1,7 +1,7 @@ package twolovers.exploitfixer.interfaces.modules; public interface PacketsModule extends CancellableModule { - void checkPacket(final Object packetEvent); + void check(final Object packetEvent); double getMultiplier(final String packetName); From 13521da22b1b79c1d8ae5e9b30b19b25cee02235 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Fri, 14 Feb 2020 10:42:41 -0300 Subject: [PATCH 037/336] Updated Source --- src/twolovers/exploitfixer/bukkit/ExploitFixer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 41a0632..9a14710 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -23,7 +23,6 @@ public void onEnable() { final Server server = this.getServer(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); configurationUtil.createConfiguration("%datafolder%/config.yml"); configurationUtil.createConfiguration("%datafolder%/messages.yml"); @@ -32,8 +31,10 @@ public void onEnable() { exploitFixer = this; moduleManager = new BukkitModuleManager(this, configYml, messagesYml); + VersionUtil.init(); reload(); + server.getScheduler().runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); From 06f74a27780018810c9065cb0286fee5e3eca2a4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Fri, 14 Feb 2020 10:48:36 -0300 Subject: [PATCH 038/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 4 ++-- src/plugin.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 3a7bcd4..7a3a220 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.1.6 +version: 1.1.7 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 9e8ff56..ac8db01 100644 --- a/src/config.yml +++ b/src/config.yml @@ -129,8 +129,8 @@ packets: # When a valid packet is sent the following amount of vls will be applied. multipliers: ABILITIES: 1 - ARM_ANIMATION: 4.25 - BLOCK_DIG: 4.25 + ARM_ANIMATION: 3 + BLOCK_DIG: 3 BLOCK_PLACE: 4.25 CUSTOM_PAYLOAD: 0.1 ENTITY_ACTION: 4 diff --git a/src/plugin.yml b/src/plugin.yml index 9fb7b94..3ffb1df 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.1.6 +version: 1.1.7 author: 2LS api-version: '1.13' load: STARTUP From 375b1740fc34bb497385b9dfe2b2ba796ebf0476 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Sat, 15 Feb 2020 10:33:04 -0300 Subject: [PATCH 039/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 26 ++----- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 16 ++-- .../adapters/WindowClickPacketAdapter.java | 21 ++++- .../initializers/AdapterInitializer.java | 5 +- .../instanceables/BukkitExploitPlayer.java | 58 ++++++++------ .../bukkit/listeners/SignChangeListener.java | 50 ------------ .../initializers/ListenerInitializer.java | 8 +- .../bukkit/managers/BukkitModuleManager.java | 10 +-- .../bukkit/modules/BukkitPacketsModule.java | 78 ++++++++++++------- .../bukkit/modules/BukkitSignsModule.java | 59 -------------- .../bukkit/nms/CraftPlayerReflector.java | 55 +++++++++++++ .../exploitfixer/bukkit/nms/NMSManager.java | 26 ------- .../bungee/managers/BungeeModuleManager.java | 5 -- .../interfaces/managers/ModuleManager.java | 2 - .../interfaces/modules/SignsModule.java | 5 -- 17 files changed, 183 insertions(+), 245 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java delete mode 100644 src/twolovers/exploitfixer/bukkit/nms/NMSManager.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/SignsModule.java diff --git a/src/bungee.yml b/src/bungee.yml index 7a3a220..59130c8 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.1.7 +version: 1.1.8 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index ac8db01..558aac1 100644 --- a/src/config.yml +++ b/src/config.yml @@ -113,6 +113,14 @@ packets: # Maximum amount of bytes per page. (Prevents duplication and crashes) max_bytes: 256 + # Prevents invalid signs used to crash your server. (Checks if exceeds bytes) + signs: + # Vls to add when invalid sign packets are sent. (Set to 0 to disable) + vls: 1000 + + # Maximum amount of bytes per sign line. + max_bytes: 47 + # Vls to add when invalid window_click packets are sent. (Set to 0 to disable) # Vls added by null InventoryView is the tenth part of the window_click vls. window_click: 1000 @@ -179,24 +187,6 @@ commands: - "/demote" - "/execute" - # Placeholders: %player% - violations: - 1: - - "notification" - - "kick" - -# Prevents invalid sign creation. -signs: - enabled: true - - # Amount of violations required to cancel. - cancel_vls: 1 - - # Amount of violations to reduce per second. - reduce_vls: 0 - - max_bytes: 34 - # Placeholders: %player% violations: 1: diff --git a/src/plugin.yml b/src/plugin.yml index 3ffb1df..d234fc1 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.1.7 +version: 1.1.8 author: 2LS api-version: '1.13' load: STARTUP diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 9a14710..b320618 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -2,6 +2,7 @@ import org.bukkit.Server; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import twolovers.exploitfixer.bukkit.adapters.initializers.AdapterInitializer; @@ -44,6 +45,7 @@ public void onEnable() { public void onDisable() { this.getServer().getScheduler().cancelTasks(this); + HandlerList.unregisterAll(this); } public void reload() { @@ -61,14 +63,16 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); - if (pluginManager.isPluginEnabled("ProtocolLib")) - new AdapterInitializer(this, moduleManager); - else - getLogger().log(Level.SEVERE, "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); + if (isEnabled()) { + if (pluginManager.isPluginEnabled("ProtocolLib")) + new AdapterInitializer(this, moduleManager); + else + getLogger().log(Level.SEVERE, "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); - new ListenerInitializer(this, moduleManager); + new ListenerInitializer(this, moduleManager); - getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); + getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); + } } public static ExploitFixer getInstance() { diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 5dc1880..329b223 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -9,12 +9,14 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.nio.charset.StandardCharsets; import java.util.UUID; public class WindowClickPacketAdapter extends PacketAdapter { @@ -63,11 +65,22 @@ public void onPacketReceiving(final PacketEvent event) { if (itemUse != null) { final ItemStack itemOnHand = inventoryView.getItem(slot); - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + if (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta()) { + final ItemMeta itemMeta = itemUse.getItemMeta(); + int dataBytes = 0; - // Divide by 12 because of false positives. - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 12); + try { + dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + + if (dataBytes > 512){ + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + + // Divide by 12 because of false positives. + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 12); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 6e6475d..c35a37d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -7,10 +7,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.*; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index be9c6c2..35b76e1 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -6,7 +6,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; -import twolovers.exploitfixer.bukkit.nms.NMSManager; +import twolovers.exploitfixer.bukkit.nms.CraftPlayerReflector; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.Violations; @@ -127,41 +127,49 @@ public void addVls(final Object pluginObject, final Object event, final Object p for (final int threshold : violations.getViolations()) { if (threshold > oldVls && threshold <= newVls) { final Collection commands = violations.getCommands(threshold); - final BukkitScheduler scheduler = server.getScheduler(); - if (commands != null && !commands.isEmpty()) - for (final String punishCommand : commands) - if (!punishCommand.isEmpty()) - if (punishCommand.equals("kick")) { - final String locale; + if (commands != null && !commands.isEmpty()) { + final BukkitScheduler scheduler = server.getScheduler(); - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); + for (final String punishCommand : commands) + if (!punishCommand.isEmpty()) + if (punishCommand.equals("kick")) { + final CraftPlayerReflector craftPlayer = new CraftPlayerReflector(player); + final String locale; - final String kickMessage = messagesModule.getKickMessage(module, locale); - final Thread thread = Thread.currentThread(); + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); + + final String kickMessage = messagesModule.getKickMessage(module, locale); + + // This is made to sync the current thread with main thread so it doesnt crash. + if (!server.isPrimaryThread()) { + final Thread currentThread = Thread.currentThread(); scheduler.runTask(plugin, () -> { - player.kickPlayer(kickMessage); - thread.interrupt(); + craftPlayer.disconnectChannel(kickMessage); + currentThread.interrupt(); }); try { - Thread.sleep(1000); + Thread.sleep(200); } catch (final InterruptedException ignored) { } - - NMSManager.closeChannel(player); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) - if (event instanceof PacketEvent) - notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); - else - notificationsModule.sendNotification(module.getName(), player, (int) newVls); + } else + craftPlayer.disconnectChannel(kickMessage); + + craftPlayer.closeChannel(); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) { + if (event instanceof PacketEvent) + notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); else - server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + notificationsModule.sendNotification(module.getName(), player, (int) newVls); + } else + server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java deleted file mode 100644 index d03aea8..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/SignChangeListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.SignsModule; - -import java.nio.charset.StandardCharsets; -import java.util.UUID; - -public class SignChangeListener implements Listener { - private final Plugin plugin; - private final SignsModule signsModule; - private final ExploitPlayerManager exploitPlayerManager; - - public SignChangeListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.signsModule = moduleManager.getSignsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onSignChange(final SignChangeEvent event) { - if (signsModule.isEnabled()) { - final Player player = event.getPlayer(); - - if (player != null) { - final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - - for (final String line : event.getLines()) { - if (line.length() >= 46) { - exploitPlayer.addVls(plugin, event, player, signsModule, 1); - break; - } else if (line.getBytes(StandardCharsets.UTF_8).length > signsModule.getMaxBytes()) { - exploitPlayer.addVls(plugin, event, player, signsModule, 1); - break; - } - } - } else - event.setCancelled(true); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 102b274..7c13765 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -1,20 +1,20 @@ package twolovers.exploitfixer.bukkit.listeners.initializers; -import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import twolovers.exploitfixer.bukkit.listeners.*; +import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; +import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; +import twolovers.exploitfixer.bukkit.listeners.PlayerQuitListener; +import twolovers.exploitfixer.bukkit.listeners.PlayerTabCompleteListener; import twolovers.exploitfixer.interfaces.managers.ModuleManager; public class ListenerInitializer { public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { final PluginManager pluginManager = plugin.getServer().getPluginManager(); - HandlerList.unregisterAll(plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerTabCompleteListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new SignChangeListener(plugin, moduleManager), plugin); } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 17ceb67..713daa9 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -19,7 +19,6 @@ public class BukkitModuleManager implements ModuleManager { private NotificationsModule notificationsModule; private PacketsModule packetsModule; private ExploitPlayerManager exploitPlayerManager; - private SignsModule signsModule; private ReloadableModule uuidSpoofModule, nullAddressModule; public BukkitModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { @@ -32,7 +31,6 @@ public BukkitModuleManager(final Plugin plugin, final Configuration configYml, f this.uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); this.packetsModule = new BukkitPacketsModule(plugin, this, configYml); this.exploitPlayerManager = new BukkitExploitPlayerManager(plugin.getServer(), this); - this.signsModule = new BukkitSignsModule(configYml); this.nullAddressModule = new BukkitNullAddressModule(configYml); } @@ -47,13 +45,14 @@ public void reload(final Object configYml, final Object messagesYml, final Objec this.uuidSpoofModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); - this.signsModule.reload(configYml); this.nullAddressModule.reload(configYml); } catch (final NullPointerException e) { final Server server = plugin.getServer(); server.getLogger().log(Level.SEVERE, "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); server.getPluginManager().disablePlugin(plugin); + + e.printStackTrace(); } } @@ -101,9 +100,4 @@ public PacketsModule getPacketsModule() { public ReloadableModule getNullAddressModule() { return nullAddressModule; } - - @Override - public SignsModule getSignsModule() { - return signsModule; - } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 8bcad58..e9b3b5e 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -5,6 +5,7 @@ import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedBlockData; +import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.nbt.NbtBase; import io.netty.buffer.ByteBuf; import org.bukkit.block.BlockState; @@ -36,8 +37,8 @@ public class BukkitPacketsModule implements PacketsModule { private final Map multipliers = new HashMap<>(); private Violations violations; private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls, - booksVlsInvalid, booksVlsNormal, bigDataMaxStructure; - private int booksMaxBytes; + booksVlsInvalid, booksVlsNormal, signsVls, bigDataMaxStructure; + private int booksMaxBytes, signsMaxBytes; private boolean enabled, offline; public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { @@ -59,6 +60,8 @@ final public void reload(final Object configYml) { this.booksVlsInvalid = configYml1.getDouble(name + ".invalid.books.vls.invalid"); this.booksVlsNormal = configYml1.getDouble(name + ".invalid.books.vls.normal"); this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); + this.signsVls = configYml1.getDouble(name + ".invalid.signs.vls", 1000); + this.signsMaxBytes = configYml1.getInt(name + ".invalid.signs.max_bytes", 47); this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes"); this.bigDataMaxStructure = configYml1.getDouble(name + ".invalid.big_data.max_structure"); @@ -83,23 +86,28 @@ public boolean isEnabled() { } @Override - public void check(final Object event) { - if (event instanceof PacketEvent) { - final PacketEvent packetEvent = (PacketEvent) event; + public void check(final Object eventObject) { + if (eventObject instanceof PacketEvent) { + final PacketEvent event = (PacketEvent) eventObject; - if (!packetEvent.isCancelled()) { - final Player player = packetEvent.getPlayer(); - final PacketType packetType = packetEvent.getPacketType(); + if (!event.isCancelled()) { + final Player player = event.getPlayer(); + final PacketType packetType = event.getPacketType(); if (player != null && player.isOnline()) { try { final UUID uuid = player.getUniqueId(); final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + final PacketContainer packet = event.getPacket(); + final StructureModifier chatComponentArrays = packet.getChatComponentArrays(); - if (bigDataVls > 0) { - final PacketContainer packet = packetEvent.getPacket(); + if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN && checkSign(chatComponentArrays.readSafely(0))) { + exploitPlayer.addVls(plugin, event, player, this, signsVls); + } + + if (!event.isCancelled() && bigDataVls > 0) { final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier blockDataModifier = packet.getBlockData(); + final StructureModifier blockData = packet.getBlockData(); final StructureModifier integers = packet.getIntegers(); final StructureModifier longs = packet.getLongs(); final StructureModifier floats = packet.getFloat(); @@ -108,20 +116,20 @@ public void check(final Object event) { final StructureModifier> nbtModifier = packet.getNbtModifier(); final AtomicInteger packetSize = new AtomicInteger(0); - if (itemModifier.size() > bigDataMaxStructure || blockDataModifier.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { - exploitPlayer.addVls(plugin, packetEvent, player, this, bigDataVls); - } else { - if (!packetEvent.isCancelled()) { + if (itemModifier.size() > bigDataMaxStructure || blockData.size() > bigDataMaxStructure || chatComponentArrays.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); + } + + if (!event.isCancelled()) { for (final ItemStack itemStack : itemModifier.getValues()) { - if (checkItem(itemStack, packetEvent, exploitPlayer, player, packetSize)) + if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) break; } - } - if (!packetEvent.isCancelled()) { - for (final WrappedBlockData blockData : blockDataModifier.getValues()) { - if (blockData != null) { - int dataBytes = blockData.toString().getBytes(StandardCharsets.UTF_8).length; + if (!event.isCancelled()) { + for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { + if (wrappedBlockData != null) { + int dataBytes = wrappedBlockData.toString().getBytes(StandardCharsets.UTF_8).length; packetSize.addAndGet(dataBytes); } @@ -153,19 +161,21 @@ public void check(final Object event) { } if (packetSize.get() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, packetEvent, player, this, bigDataVls); + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } } } } - if (!packetEvent.isCancelled()) - exploitPlayer.addVls(plugin, packetEvent, player, this, getMultiplier(packetEvent.getPacketType().name())); + if (!event.isCancelled()) { + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetType.name())); + } } catch (final UnsupportedOperationException ignored) { - packetEvent.setCancelled(true); + event.setCancelled(true); } - } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD) - packetEvent.setCancelled(true); + } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD && packetType != PacketType.Play.Client.SETTINGS) { + event.setCancelled(true); + } } } } @@ -270,4 +280,18 @@ else if (bookMeta.getPageCount() > 50) { } else return true; } + + private boolean checkSign(final WrappedChatComponent[] lines) { + if (lines == null || lines.length > 4) { + return true; + } else { + for (final WrappedChatComponent line : lines) { + if (line.getJson().getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { + return true; + } + } + } + + return false; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java deleted file mode 100644 index 8abc4c6..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitSignsModule.java +++ /dev/null @@ -1,59 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.modules.SignsModule; - -public class BukkitSignsModule implements SignsModule { - private boolean enabled; - private double cancelVls, reduceVls; - private int maxBytes; - private Violations violations; - - public BukkitSignsModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "Signs"; - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.maxBytes = configYml1.getInt(name + ".max_bytes"); - this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - } - - @Override - public int getMaxBytes() { - return maxBytes; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java new file mode 100644 index 0000000..ccad7ea --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java @@ -0,0 +1,55 @@ +package twolovers.exploitfixer.bukkit.nms; + +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class CraftPlayerReflector { + private final Player player; + private Object playerConnection = null; + + public CraftPlayerReflector(final Player player) { + this.player = player; + } + + private Object getPlayerConnection() { + if (playerConnection == null) + try { + final Method getHandle = player.getClass().getMethod("getHandle"); + final Object nmsPlayer = getHandle.invoke(player); + final Field conField = nmsPlayer.getClass().getField("playerConnection"); + playerConnection = conField.get(nmsPlayer); + } catch (final Exception e) { + e.printStackTrace(); + } + + return playerConnection; + } + + public void closeChannel() { + try { + final Object playerConnection = getPlayerConnection(); + final Field netField = playerConnection.getClass().getField("networkManager"); + final Object net = netField.get(playerConnection); + final Field chanField = net.getClass().getField("channel"); + final Object chan = chanField.get(net); + final Method method = chan.getClass().getMethod("closeFuture"); + + method.invoke(chan); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + public void disconnectChannel(final String kickMessage) { + try { + final Object playerConnection = getPlayerConnection(); + final Method method = playerConnection.getClass().getMethod("disconnect", String.class); + + method.invoke(playerConnection, kickMessage); + } catch (final Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java b/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java deleted file mode 100644 index 82d3235..0000000 --- a/src/twolovers/exploitfixer/bukkit/nms/NMSManager.java +++ /dev/null @@ -1,26 +0,0 @@ -package twolovers.exploitfixer.bukkit.nms; - -import org.bukkit.entity.Player; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class NMSManager { - public static void closeChannel(final Player player) { - try { - final Method getHandle = player.getClass().getMethod("getHandle"); - final Object nmsPlayer = getHandle.invoke(player); - final Field conField = nmsPlayer.getClass().getField("playerConnection"); - final Object con = conField.get(nmsPlayer); - final Field netField = con.getClass().getField("networkManager"); - final Object net = netField.get(con); - final Field chanField = net.getClass().getField("channel"); - final Object chan = chanField.get(net); - final Method method = chan.getClass().getMethod("closeFuture"); - - method.invoke(chan); - } catch (final Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java index 8ec6fff..b9f561d 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java @@ -64,11 +64,6 @@ public ExploitPlayerManager getExploitPlayerManager() { return exploitPlayerManager; } - @Override - public SignsModule getSignsModule() { - return null; - } - @Override public PacketsModule getPacketsModule() { return null; diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java index 33444f8..27adfbb 100644 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java @@ -19,8 +19,6 @@ public interface ModuleManager { ExploitPlayerManager getExploitPlayerManager(); - SignsModule getSignsModule(); - PacketsModule getPacketsModule(); ReloadableModule getNullAddressModule(); diff --git a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java b/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java deleted file mode 100644 index 201d644..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/SignsModule.java +++ /dev/null @@ -1,5 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface SignsModule extends CancellableModule { - int getMaxBytes(); -} From 2243e3669294af8c89765373b1d4edb82d970232 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Sun, 16 Feb 2020 10:10:12 -0300 Subject: [PATCH 040/336] Updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../adapters/WindowClickPacketAdapter.java | 2 +- .../initializers/AdapterInitializer.java | 5 ++- .../instanceables/BukkitExploitPlayer.java | 6 +-- .../bukkit/listeners/PlayerLoginListener.java | 6 +-- .../managers/BukkitExploitPlayerManager.java | 6 +++ .../modules/BukkitCustomPayloadModule.java | 30 +++++++------- .../bukkit/modules/BukkitPacketsModule.java | 41 ++++++++++++------- .../bukkit/nms/CraftPlayerReflector.java | 10 ++--- .../bungee/listeners/ChatListener.java | 14 +++---- .../managers/BungeeExploitPlayerManager.java | 6 +++ 12 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 59130c8..97b19a3 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.1.8 +version: 1.1.9 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index d234fc1..d6535b9 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.1.8 +version: 1.1.9 author: 2LS api-version: '1.13' load: STARTUP diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index 329b223..d8f4db3 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -75,7 +75,7 @@ public void onPacketReceiving(final PacketEvent event) { dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; } - if (dataBytes > 512){ + if (dataBytes > 512) { final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); // Divide by 12 because of false positives. diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index c35a37d..6e6475d 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -7,7 +7,10 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.*; +import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; +import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 35b76e1..5a7a2bc 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -173,10 +173,10 @@ public void addVls(final Object pluginObject, final Object event, final Object p } } } - } else if (event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); - } else if (event instanceof Cancellable) + } + } else if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(true); + } } public void clearViolations() { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 9985393..1d08cde 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -79,8 +79,8 @@ public void onPlayerLogin(final PlayerLoginEvent event) { exploitPlayer.setLogged(true); } - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); - } + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(player, true); + } } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java index 18a5b55..26a2cf2 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java @@ -60,6 +60,12 @@ public void clear() { @Override public void reload() { exploitPlayers.clear(); + + for (final Player player : server.getOnlinePlayers()) { + final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + + exploitPlayer.setLogged(true); + } } @Override diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index f0bf70e..916288c 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -80,15 +80,15 @@ public void reload(final Object configYml) { } @Override - public void check(final Object event) { - if (event instanceof PacketEvent) { - final PacketEvent packetEvent = (PacketEvent) event; + public void check(final Object eventObject) { + if (eventObject instanceof PacketEvent) { + final PacketEvent event = (PacketEvent) eventObject; - if (!packetEvent.isCancelled()) { - final Player player = packetEvent.getPlayer(); + if (!event.isCancelled()) { + final Player player = event.getPlayer(); if (player != null && player.isOnline()) { - final PacketContainer packet = packetEvent.getPacket(); + final PacketContainer packet = event.getPacket(); final StructureModifier stringStructureModifier = packet.getStrings(); final String tag = stringStructureModifier.readSafely(0); @@ -102,19 +102,21 @@ public void check(final Object event) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); if (tag.toLowerCase().endsWith("register") && content.split("\000").length > maxChannelsAmount) { - exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault(tag, bigDataVls)); + exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault(tag, bigDataVls)); } else { - exploitPlayer.addVls(plugin, event, player, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); } } catch (final UnsupportedOperationException e) { - ((PacketEvent) event).setCancelled(true); + event.setCancelled(true); } - } else - packetEvent.setCancelled(true); - } else - packetEvent.setCancelled(true); + } else { + event.setCancelled(true); + } + } else { + event.setCancelled(true); + } } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index e9b3b5e..ccbd382 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -100,8 +100,9 @@ public void check(final Object eventObject) { final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); final PacketContainer packet = event.getPacket(); final StructureModifier chatComponentArrays = packet.getChatComponentArrays(); + final StructureModifier stringArrays = packet.getStringArrays(); - if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN && checkSign(chatComponentArrays.readSafely(0))) { + if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN && checkSign(chatComponentArrays.readSafely(0), stringArrays.readSafely(0))) { exploitPlayer.addVls(plugin, event, player, this, signsVls); } @@ -116,15 +117,15 @@ public void check(final Object eventObject) { final StructureModifier> nbtModifier = packet.getNbtModifier(); final AtomicInteger packetSize = new AtomicInteger(0); - if (itemModifier.size() > bigDataMaxStructure || blockData.size() > bigDataMaxStructure || chatComponentArrays.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { + if (itemModifier.size() > bigDataMaxStructure || stringArrays.size() > bigDataMaxStructure || blockData.size() > bigDataMaxStructure || chatComponentArrays.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } if (!event.isCancelled()) { - for (final ItemStack itemStack : itemModifier.getValues()) { - if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) - break; - } + for (final ItemStack itemStack : itemModifier.getValues()) { + if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) + break; + } if (!event.isCancelled()) { for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { @@ -281,15 +282,27 @@ else if (bookMeta.getPageCount() > 50) { return true; } - private boolean checkSign(final WrappedChatComponent[] lines) { - if (lines == null || lines.length > 4) { - return true; - } else { - for (final WrappedChatComponent line : lines) { - if (line.getJson().getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { - return true; + private boolean checkSign(final WrappedChatComponent[] linesChatComponent, final String[] linesString) { + if (linesChatComponent != null) { + if (linesChatComponent.length > 4) { + return true; + } else + for (final WrappedChatComponent line : linesChatComponent) { + if (line.getJson().getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { + return true; + } + } + } + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { + return true; + } } - } } return false; diff --git a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java index ccad7ea..2f4a417 100644 --- a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java +++ b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java @@ -16,15 +16,15 @@ public CraftPlayerReflector(final Player player) { private Object getPlayerConnection() { if (playerConnection == null) try { - final Method getHandle = player.getClass().getMethod("getHandle"); - final Object nmsPlayer = getHandle.invoke(player); - final Field conField = nmsPlayer.getClass().getField("playerConnection"); - playerConnection = conField.get(nmsPlayer); + final Method getHandle = player.getClass().getMethod("getHandle"); + final Object nmsPlayer = getHandle.invoke(player); + final Field conField = nmsPlayer.getClass().getField("playerConnection"); + playerConnection = conField.get(nmsPlayer); } catch (final Exception e) { e.printStackTrace(); } - return playerConnection; + return playerConnection; } public void closeChannel() { diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index 16d64a2..0a8e8a9 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -34,14 +34,14 @@ public void onChat(final ChatEvent event) { if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - for (final String command : commandsModule.getCommands()) - if (message.startsWith(command + " ") || message.endsWith(command)) { - exploitPlayer.addVls(plugin, event, proxiedPlayer, commandsModule, 1); - break; - } - } + for (final String command : commandsModule.getCommands()) + if (message.startsWith(command + " ") || message.endsWith(command)) { + exploitPlayer.addVls(plugin, event, proxiedPlayer, commandsModule, 1); + break; + } + } } } } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java index db0bb8b..5114240 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java @@ -56,6 +56,12 @@ public int addPunishment() { @Override public void reload() { exploitPlayers.clear(); + + for (final ProxiedPlayer player : proxy.getPlayers()) { + final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + + exploitPlayer.setLogged(true); + } } @Override From 934d1aa384dfd222c21f28bcdd1413989c29d863 Mon Sep 17 00:00:00 2001 From: LinsaFTW <> Date: Fri, 28 Feb 2020 14:50:17 -0300 Subject: [PATCH 041/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 12 ++- src/messages.yml | 83 +++++++++++-------- src/plugin.yml | 2 +- .../adapters/BlockDigPacketAdapter.java | 19 +++-- .../adapters/BlockPlacePacketAdapter.java | 13 +-- .../SetCreativeSlotPacketAdapter.java | 14 +++- .../adapters/WindowClickPacketAdapter.java | 18 ++-- .../initializers/AdapterInitializer.java | 47 ++++++----- .../modules/BukkitCustomPayloadModule.java | 21 +++-- .../bukkit/modules/BukkitItemsFixModule.java | 8 +- .../bukkit/modules/BukkitPacketsModule.java | 63 ++++++++++---- .../bungee/listeners/PostLoginListener.java | 7 +- .../interfaces/modules/ItemsFixModule.java | 2 + 14 files changed, 205 insertions(+), 106 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 97b19a3..94dc63d 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.1.9 +version: 1.2.0 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 558aac1..6a2a542 100644 --- a/src/config.yml +++ b/src/config.yml @@ -23,10 +23,13 @@ connection: # UUIDSpoof only affects non-firewalled servers with BungeeCord: true. uuidspoof: true -# Fixes ItemMeta from items to remove invalid tags, enchants, effects, etc... +# Fixes items to remove invalid tags, enchants, effects, etc... itemsfix: enabled: true + # Maximum stack size obtainable with creative packets. (Set to 0 to allow everything) + max_stack_size: 64 + # Maximum enchant level obtainable with creative packets. (Set to 0 to disable custom enchants) enchant_limit: 0 @@ -61,6 +64,7 @@ custompayload: # When a valid packet is sent the following amount of vls will be applied. multipliers: OTHER: 0.1 + SETTINGS: 25 MC|BSign: 50 MC|BEdit: 50 MC|BOpen: 50 @@ -147,6 +151,7 @@ packets: POSITION_LOOK: 0.75 POSITION: 3.5 SET_CREATIVE_SLOT: 0.5 + SETTINGS: 25 TAB_COMPLETE: 8 UPDATE_SIGN: 90 USE_ENTITY: 4 @@ -180,6 +185,9 @@ commands: - "//evaluate" - "//solve" - "/hd readtext" + - "/holo readtext" + - "/hologram readtext" + - "/holograms readtext" - "/holographicdisplays readtext" - "/pex promote" - "/pex demote" @@ -191,4 +199,4 @@ commands: violations: 1: - "notification" - - "kick" \ No newline at end of file + - "kick" diff --git a/src/messages.yml b/src/messages.yml index cbfcd57..a0cebff 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -7,11 +7,11 @@ en: commands: reload: "&aPlugin ExploitFixer reloaded!" help: |- - &aExploitFixer %version% commands: - &e/%command% help &7- &bShows available commands! - &e/%command% reload &7- &bReloads the plugin! - &e/%command% notifications &7- &bToggles notifications of the plugin! - &e/%command% stats &7- &bWatch the stats of the plugin! + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bShows available commands. + &e /%command% reload &7> &bReloads the plugin. + &e /%command% notifications &7> &bToggles notifications of the plugin. + &e /%command% stats &7> &bWatch the stats of the plugin. error: unknown: "&cUnknown command. Use /exploitfixer help to see available commands!" permission: "&cYou dont have permission to use this command!" @@ -26,14 +26,8 @@ en: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" commands: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - duplication: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fDuplication exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - items: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fItem exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - signs: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fSigns exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" nulladdress: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: @@ -46,11 +40,11 @@ es: commands: reload: "&aPlugin ExploitFixer recargado!" help: |- - &aComandos de ExploitFixer: - &e/%command% help &7- &bMuestra los comandos disponibles! - &e/%command% reload &7- &bRecarga el plugin! - &e/%command% notifications &7- &bAlterna las notificaciones del plugin! - &e/%command% stats &7- &bMira las estadisticas del plugin! + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bMuestra los comandos disponibles. + &e /%command% reload &7> &bRecarga el plugin. + &e /%command% notifications &7> &bAlterna las notificaciones del plugin. + &e /%command% stats &7> &bMira las estadisticas del plugin. error: unknown: "&cComando desconocido. Usa /exploitfixer help para ver comandos disponibles!" permission: "&cNo tienes permiso para usar ese comando!" @@ -65,14 +59,8 @@ es: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" commands: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - duplication: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Duplicacion detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - items: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - signs: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Carteles detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" nulladdress: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: @@ -85,11 +73,11 @@ pt: commands: reload: "&aPlugin ExploitFixer recarregado!" help: |- - &aExploitFixer comandos: - &e/%command% help &7- &bComandos disponiveis! - &e/%command% reload &7- &bReload plugin! - &e/%command% notifications &7- &bAtivar as notificações do plugin! - &e/%command% stats &7- &bVer statisticas do plugin! + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bComandos disponiveis. + &e /%command% reload &7> &bReload plugin. + &e /%command% notifications &7> &bAtivar as notificações do plugin. + &e /%command% stats &7> &bVer statisticas do plugin. error: unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" permission: "&cSem permissao para usar este comando!" @@ -104,17 +92,44 @@ pt: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" commands: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - duplication: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Duplicação detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - items: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Items detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" packets: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" - signs: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Cartazes detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" nulladdress: kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" stats: message: |- &fJugadores em cache: &a%players_cached% - &fJogadores punidos: &a%players_punished% \ No newline at end of file + &fJogadores punidos: &a%players_punished% + +# Italian +it: + commands: + reload: "&aPlugin ExploitFixer ricaricato!" + help: |- + &aExploitFixer &b%version%&a da parte di &bLinsaFTW&a. + &e /%command% help &7> &bMostra i commandi disponibili. + &e /%command% reload &7> &bRicarica il plugin. + &e /%command% notifications &7> &bCambia le notifiche del plugin. + &e /%command% stats &7> &bMostra le statistiche del plugin. + error: + unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" + permission: "&cNon hai il permesso per questo commando!" + console: "&cQuesto commando non può essere eseguito dalla console!" + notifications: + enable: "&aHai abilitato le notifiche!" + disable: "&cHai disabilitato le notifiche!" + modules: + custompayload: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + uuidspoof: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + commands: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + stats: + message: |- + &fGiocatori in cache: &a%players_cached% + &fGiocatori puniti: &a%players_punished% diff --git a/src/plugin.yml b/src/plugin.yml index d6535b9..501debc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.1.9 +version: 1.2.0 author: 2LS api-version: '1.13' load: STARTUP diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java index 0863a14..a297e72 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java @@ -1,28 +1,29 @@ package twolovers.exploitfixer.bukkit.adapters; +import java.util.UUID; + import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; + import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import java.util.UUID; - public class BlockDigPacketAdapter extends PacketAdapter { - private final PacketType packetType; private final ModuleManager moduleManager; - public BlockDigPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + public BlockDigPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, + final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); - this.packetType = packetType; this.moduleManager = moduleManager; } @@ -50,8 +51,10 @@ public void onPacketReceiving(final PacketEvent event) { if (itemOnHand == null) itemOnHand = new ItemStack(Material.AIR); - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() + && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() + .get(uuid, player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockDig); @@ -67,7 +70,7 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } - if (!event.isCancelled()) + if (!event.isCancelled() && packetsModule.isEnabled()) packetsModule.check(event); } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java index 375b888..6348f96 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java @@ -17,12 +17,11 @@ import java.util.UUID; public class BlockPlacePacketAdapter extends PacketAdapter { - private final PacketType packetType; private final ModuleManager moduleManager; - public BlockPlacePacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + public BlockPlacePacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, + final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); - this.packetType = packetType; this.moduleManager = moduleManager; } @@ -50,8 +49,10 @@ public void onPacketReceiving(final PacketEvent event) { if (itemOnHand == null) itemOnHand = new ItemStack(Material.AIR); - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() + && itemUse.getItemMeta().toString().length() > 512)) { + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() + .get(uuid, player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, blockPlace); @@ -67,7 +68,7 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } - if (!event.isCancelled()) + if (!event.isCancelled() && packetsModule.isEnabled()) packetsModule.check(event); } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 69eb4d9..2098853 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -24,7 +24,8 @@ public class SetCreativeSlotPacketAdapter extends PacketAdapter { private final ModuleManager moduleManager; - public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, + final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); this.moduleManager = moduleManager; } @@ -41,7 +42,8 @@ public void onPacketReceiving(final PacketEvent event) { if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { try { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(player.getUniqueId(), player); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() + .get(player.getUniqueId(), player); if (exploitPlayer != null) exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); @@ -58,7 +60,7 @@ public void onPacketReceiving(final PacketEvent event) { final Material material = itemStack.getType(); final ItemMeta itemMeta = itemStack.getItemMeta(); final int enchantLimit = itemsFixModule.getEnchantLimit(); - final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount(), itemStack.getData().getData()); + final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount()); if (enchantLimit > 0) { final Map enchantments = itemStackRemake.getEnchantments(); @@ -77,6 +79,7 @@ public void onPacketReceiving(final PacketEvent event) { final String displayName = itemMeta.getDisplayName(); final List lore = itemMeta.getLore(); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + final int maxStackSize = itemsFixModule.getMaxStackSize(); if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { final BookMeta bookMeta = (BookMeta) itemMeta; @@ -87,6 +90,9 @@ public void onPacketReceiving(final PacketEvent event) { newBookMeta.setPages(bookMeta.getPages()); } + if (maxStackSize != 0 && itemStackRemake.getAmount() > maxStackSize) + itemStackRemake.setAmount(maxStackSize); + if (displayName != null && displayName.getBytes().length < 128) newItemMeta.setDisplayName(displayName); @@ -102,7 +108,7 @@ public void onPacketReceiving(final PacketEvent event) { } else if (packetsModule.isOffline()) event.setCancelled(true); - if (!event.isCancelled()) + if (!event.isCancelled() && packetsModule.isEnabled()) packetsModule.check(event); } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java index d8f4db3..40d5ad4 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java @@ -23,7 +23,8 @@ public class WindowClickPacketAdapter extends PacketAdapter { private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; - public WindowClickPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, final PacketType packetType, final ModuleManager moduleManager) { + public WindowClickPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, + final PacketType packetType, final ModuleManager moduleManager) { super(plugin, listenerPriority, packetType); this.packetsModule = moduleManager.getPacketsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -70,16 +71,21 @@ public void onPacketReceiving(final PacketEvent event) { int dataBytes = 0; try { - dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + dataBytes += itemMeta.toString() + .getBytes(StandardCharsets.UTF_8).length; } catch (final NullPointerException e) { - dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + dataBytes += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())) + .getBytes(StandardCharsets.UTF_8).length; } if (dataBytes > 512) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, + player); // Divide by 12 because of false positives. - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 12); + exploitPlayer.addVls(plugin, event, player, packetsModule, + windowClick / 12); } } } @@ -93,7 +99,7 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } - if (!event.isCancelled()) + if (!event.isCancelled() && packetsModule.isEnabled()) packetsModule.check(event); } } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 6e6475d..2a06be7 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -24,31 +24,40 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager protocolManager.removePacketListeners(plugin); for (final PacketType packetType : PacketType.Play.Client.getInstance()) { - if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD && customPayloadModule.isEnabled()) { - protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - customPayloadModule.check(event); + if (packetType.isSupported() && packetType != PacketType.Play.Client.BLOCK_DIG + && packetType != PacketType.Play.Client.BLOCK_PLACE + && packetType != PacketType.Play.Client.SET_CREATIVE_SLOT + && packetType != PacketType.Play.Client.WINDOW_CLICK) { + if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD && customPayloadModule.isEnabled()) { + protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { + customPayloadModule.check(event); - if (packetsModule.isEnabled()) + if (packetsModule.isEnabled()) + packetsModule.check(event); + } + }); + } else if (packetsModule.isEnabled()) { + protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { packetsModule.check(event); - } - }); - } else if (packetsModule.isEnabled()) { - protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - packetsModule.check(event); - } - }); + } + }); + } } } if (packetsModule.isEnabled()) { - protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_DIG, moduleManager)); - protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_PLACE, moduleManager)); - protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); - protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.WINDOW_CLICK, moduleManager)); + protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, + PacketType.Play.Client.BLOCK_DIG, moduleManager)); + protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, + PacketType.Play.Client.BLOCK_PLACE, moduleManager)); + protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, + PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); + protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, + PacketType.Play.Client.WINDOW_CLICK, moduleManager)); } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index 916288c..bf42a43 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.instanceables.Violations; import twolovers.exploitfixer.interfaces.managers.ModuleManager; @@ -63,7 +64,8 @@ final public boolean isEnabled() { @Override public void reload(final Object configYml) { final Configuration configYml1 = (Configuration) configYml; - final ConfigurationSection configurationSection = configYml1.getConfigurationSection("custompayload.multipliers"); + final ConfigurationSection configurationSection = configYml1 + .getConfigurationSection("custompayload.multipliers"); final String name = getName().toLowerCase(); this.enabled = configYml1.getBoolean(name + ".enabled"); @@ -92,21 +94,26 @@ public void check(final Object eventObject) { final StructureModifier stringStructureModifier = packet.getStrings(); final String tag = stringStructureModifier.readSafely(0); - if (tag != null) { + if (tag != null && !VersionUtil.isOneDotSeven()) { final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); final String content = byteBufModifier.readSafely(0).toString(Charsets.UTF_8); if (content != null) { try { final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, + player); - if (tag.toLowerCase().endsWith("register") && content.split("\000").length > maxChannelsAmount) { - exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + if (tag.toLowerCase().endsWith("register") + && content.split("\000").length > maxChannelsAmount) { + exploitPlayer.addVls(plugin, eventObject, player, this, + multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault(tag, bigDataVls)); + exploitPlayer.addVls(plugin, eventObject, player, this, + multipliers.getOrDefault(tag, bigDataVls)); } else { - exploitPlayer.addVls(plugin, eventObject, player, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + exploitPlayer.addVls(plugin, eventObject, player, this, + multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); } } catch (final UnsupportedOperationException e) { event.setCancelled(true); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index 623c505..cd6890c 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -5,7 +5,7 @@ public class BukkitItemsFixModule implements ItemsFixModule { private boolean enabled; - private int enchantLimit; + private int enchantLimit, maxStackSize; public BukkitItemsFixModule(final Object configYml) { reload(configYml); @@ -18,6 +18,7 @@ final public void reload(final Object configYml) { this.enabled = configYml1.getBoolean(name + ".enabled"); this.enchantLimit = configYml1.getInt(name + ".enchant_limit"); + this.maxStackSize = configYml1.getInt(name + ".max_stack_size"); } @Override @@ -34,4 +35,9 @@ public String getName() { public int getEnchantLimit() { return enchantLimit; } + + @Override + public int getMaxStackSize() { + return maxStackSize; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index ccbd382..aa76dc0 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -36,8 +36,8 @@ public class BukkitPacketsModule implements PacketsModule { private final ModuleManager moduleManager; private final Map multipliers = new HashMap<>(); private Violations violations; - private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, reduceVls, - booksVlsInvalid, booksVlsNormal, signsVls, bigDataMaxStructure; + private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, + reduceVls, booksVlsInvalid, booksVlsNormal, signsVls, bigDataMaxStructure; private int booksMaxBytes, signsMaxBytes; private boolean enabled, offline; @@ -99,16 +99,26 @@ public void check(final Object eventObject) { final UUID uuid = player.getUniqueId(); final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); final PacketContainer packet = event.getPacket(); - final StructureModifier chatComponentArrays = packet.getChatComponentArrays(); + final StructureModifier chatComponentArrays; final StructureModifier stringArrays = packet.getStringArrays(); + final WrappedChatComponent[] chatComponentArrays0; + + if (!VersionUtil.isOneDotSeven()) { + chatComponentArrays = packet.getChatComponentArrays(); + chatComponentArrays0 = chatComponentArrays.readSafely(0); + } else { + chatComponentArrays = null; + chatComponentArrays0 = null; + } - if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN && checkSign(chatComponentArrays.readSafely(0), stringArrays.readSafely(0))) { + if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN + && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { exploitPlayer.addVls(plugin, event, player, this, signsVls); } if (!event.isCancelled() && bigDataVls > 0) { final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier blockData = packet.getBlockData(); + final StructureModifier blockData; final StructureModifier integers = packet.getIntegers(); final StructureModifier longs = packet.getLongs(); final StructureModifier floats = packet.getFloat(); @@ -117,7 +127,20 @@ public void check(final Object eventObject) { final StructureModifier> nbtModifier = packet.getNbtModifier(); final AtomicInteger packetSize = new AtomicInteger(0); - if (itemModifier.size() > bigDataMaxStructure || stringArrays.size() > bigDataMaxStructure || blockData.size() > bigDataMaxStructure || chatComponentArrays.size() > bigDataMaxStructure || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure || strings.size() > bigDataMaxStructure || nbtModifier.size() > bigDataMaxStructure) { + if (!VersionUtil.isOneDotSeven()) { + blockData = packet.getBlockData(); + } else { + blockData = null; + } + + if ((chatComponentArrays != null && chatComponentArrays.size() > bigDataMaxStructure) + || itemModifier.size() > bigDataMaxStructure + || stringArrays.size() > bigDataMaxStructure + || (blockData != null && blockData.size() > bigDataMaxStructure) + || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure + || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure + || strings.size() > bigDataMaxStructure + || nbtModifier.size() > bigDataMaxStructure) { exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } @@ -128,11 +151,14 @@ public void check(final Object eventObject) { } if (!event.isCancelled()) { - for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { - if (wrappedBlockData != null) { - int dataBytes = wrappedBlockData.toString().getBytes(StandardCharsets.UTF_8).length; - - packetSize.addAndGet(dataBytes); + if (blockData != null) { + for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { + if (wrappedBlockData != null) { + int dataBytes = wrappedBlockData.toString() + .getBytes(StandardCharsets.UTF_8).length; + + packetSize.addAndGet(dataBytes); + } } } @@ -146,14 +172,16 @@ public void check(final Object eventObject) { for (final NbtBase nbtBase : nbtModifier.getValues()) { if (nbtBase != null) { - int dataBytes = nbtBase.getValue().toString().getBytes(StandardCharsets.UTF_8).length; + int dataBytes = nbtBase.getValue().toString() + .getBytes(StandardCharsets.UTF_8).length; packetSize.addAndGet(dataBytes); } } if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); + final StructureModifier byteBufModifier = packet + .getSpecificModifier(ByteBuf.class); for (final ByteBuf byteBuf : byteBufModifier.getValues()) { if (byteBuf != null) @@ -174,7 +202,8 @@ public void check(final Object eventObject) { } catch (final UnsupportedOperationException ignored) { event.setCancelled(true); } - } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD && packetType != PacketType.Play.Client.SETTINGS) { + } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD + && packetType != PacketType.Play.Client.SETTINGS) { event.setCancelled(true); } } @@ -226,7 +255,8 @@ public Violations getViolations() { return violations; } - private boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, final Player player, final AtomicInteger packetSize) { + private boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, + final Player player, final AtomicInteger packetSize) { if (itemStack != null && !event.isCancelled()) { final ItemMeta itemMeta = itemStack.getItemMeta(); int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; @@ -235,7 +265,8 @@ private boolean checkItem(final ItemStack itemStack, final PacketEvent event, fi try { dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; } catch (final NullPointerException e) { - dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())) + .getBytes(StandardCharsets.UTF_8).length; } if (itemMeta instanceof BlockStateMeta) { diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index 7351d1f..2d48a25 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -59,7 +59,8 @@ public void onPostLogin(final PostLoginEvent event) { scheduler.runAsync(plugin, () -> { final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) + .toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { final String onlineUUID = exploitPlayer.getOnlineUUID(); @@ -76,5 +77,9 @@ public void onPostLogin(final PostLoginEvent event) { } else exploitPlayer.setLogged(true); } + + if (proxiedPlayer.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(proxiedPlayer, true); + } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index 2b67520..72769f2 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -2,4 +2,6 @@ public interface ItemsFixModule extends ReloadableModule { int getEnchantLimit(); + + int getMaxStackSize(); } From e2d6c5e1eb8511a4dce2a30fd2e69d226c4eaba0 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 1 Mar 2020 17:34:01 -0300 Subject: [PATCH 042/336] Updated Source --- src/bungee.yml | 4 +- src/config.yml | 16 +- src/plugin.yml | 10 +- .../exploitfixer/bukkit/ExploitFixer.java | 10 +- .../initializers/AdapterInitializer.java | 5 - .../instanceables/BukkitExploitPlayer.java | 26 +++- .../modules/BukkitCustomPayloadModule.java | 104 +++++++++---- .../bukkit/modules/BukkitPacketsModule.java | 139 +++++++++++------- .../bungee/listeners/ChatListener.java | 3 +- .../modules/BungeeCustomPayloadModule.java | 15 +- 10 files changed, 217 insertions(+), 115 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 94dc63d..2650ebd 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,9 +1,9 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.0 +version: 1.2.1 author: 2LS commands: exploitfixer: description: The main ExploitFixer command usage: /exploitfixer - aliases: [ef] \ No newline at end of file + aliases: [ef] diff --git a/src/config.yml b/src/config.yml index 6a2a542..5e93af6 100644 --- a/src/config.yml +++ b/src/config.yml @@ -55,6 +55,14 @@ custompayload: # Maximum amount of bytes per packet. max_bytes: 16000 + # Checks CustomPayload books for invalid data. + books: + # Vls to add when too big packets are sent. (Set to 0 to disable) + vls: 1000 + + # Maximum amount of bytes per page. + max_bytes: 258 + # Amount of violations required to cancel. cancel_vls: 400 @@ -64,7 +72,7 @@ custompayload: # When a valid packet is sent the following amount of vls will be applied. multipliers: OTHER: 0.1 - SETTINGS: 25 + SETTINGS: 5 MC|BSign: 50 MC|BEdit: 50 MC|BOpen: 50 @@ -114,8 +122,8 @@ packets: # Vls to add when normal book packets are sent. (Set to 0 to disable) normal: 20 - # Maximum amount of bytes per page. (Prevents duplication and crashes) - max_bytes: 256 + # Maximum amount of bytes per page. + max_bytes: 258 # Prevents invalid signs used to crash your server. (Checks if exceeds bytes) signs: @@ -151,7 +159,7 @@ packets: POSITION_LOOK: 0.75 POSITION: 3.5 SET_CREATIVE_SLOT: 0.5 - SETTINGS: 25 + SETTINGS: 5 TAB_COMPLETE: 8 UPDATE_SIGN: 90 USE_ENTITY: 4 diff --git a/src/plugin.yml b/src/plugin.yml index 501debc..c96d9fe 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,13 +1,15 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.0 +version: 1.2.1 author: 2LS -api-version: '1.13' +api: "1.13" +api-version: "1.13" load: STARTUP depend: [ProtocolLib] -loadbefore: [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaRewindPotions, ProtocolSupport] +loadbefore: + [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaRewindPotions, ProtocolSupport] commands: exploitfixer: description: The main ExploitFixer command usage: /exploitfixer - aliases: [ef] \ No newline at end of file + aliases: [ef] diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index b320618..4c6f3c0 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -2,7 +2,6 @@ import org.bukkit.Server; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.event.HandlerList; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import twolovers.exploitfixer.bukkit.adapters.initializers.AdapterInitializer; @@ -20,6 +19,7 @@ public class ExploitFixer extends JavaPlugin { private static ExploitFixer exploitFixer; private ModuleManager moduleManager; + @Override public void onEnable() { final Server server = this.getServer(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); @@ -43,11 +43,6 @@ public void onEnable() { }, 9000L, 9000L); } - public void onDisable() { - this.getServer().getScheduler().cancelTasks(this); - HandlerList.unregisterAll(this); - } - public void reload() { final Server server = getServer(); final PluginManager pluginManager = server.getPluginManager(); @@ -67,7 +62,8 @@ public void reload() { if (pluginManager.isPluginEnabled("ProtocolLib")) new AdapterInitializer(this, moduleManager); else - getLogger().log(Level.SEVERE, "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); + getLogger().log(Level.SEVERE, + "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 2a06be7..2ac5113 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -21,8 +21,6 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager final PacketsModule packetsModule = moduleManager.getPacketsModule(); final CustomPayloadModule customPayloadModule = moduleManager.getCustomPayloadModule(); - protocolManager.removePacketListeners(plugin); - for (final PacketType packetType : PacketType.Play.Client.getInstance()) { if (packetType.isSupported() && packetType != PacketType.Play.Client.BLOCK_DIG && packetType != PacketType.Play.Client.BLOCK_PLACE @@ -33,9 +31,6 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager @Override public void onPacketReceiving(final PacketEvent event) { customPayloadModule.check(event); - - if (packetsModule.isEnabled()) - packetsModule.check(event); } }); } else if (packetsModule.isEnabled()) { diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 5a7a2bc..62ac31e 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -68,12 +68,14 @@ public double getViolations(final Module module) { public String getOnlineUUID() { if (onlineUUID == null) { try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openConnection(); + final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) + .openConnection(); connection.setDoOutput(true); connection.connect(); - final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + final BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(connection.getInputStream())); final StringBuilder response = new StringBuilder(); String inputLine; @@ -91,7 +93,8 @@ public String getOnlineUUID() { } @Override - public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { + public void addVls(final Object pluginObject, final Object event, final Object playerObject, + final CancellableModule module, final double amount) { if (playerObject instanceof Player) { final Player player = (Player) playerObject; @@ -107,7 +110,8 @@ public void addVls(final Object pluginObject, final Object event, final Object p lastViolation = currentTime; for (final CancellableModule cancellableModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(cancellableModule) - cancellableModule.getReduceVls(); + final double vls = this.violations.get(cancellableModule) + - cancellableModule.getReduceVls(); if (vls <= 0) this.violations.remove(cancellableModule); @@ -121,8 +125,9 @@ public void addVls(final Object pluginObject, final Object event, final Object p this.violations.put(module, newVls); - if (event instanceof Cancellable && module.getCancelVls() <= newVls) + if (event instanceof Cancellable && module.getCancelVls() <= newVls) { ((Cancellable) event).setCancelled(true); + } for (final int threshold : violations.getViolations()) { if (threshold > oldVls && threshold <= newVls) { @@ -164,11 +169,16 @@ public void addVls(final Object pluginObject, final Object event, final Object p exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) { if (event instanceof PacketEvent) - notificationsModule.sendNotification(((PacketEvent) event).getPacketType().name(), player, (int) newVls); + notificationsModule.sendNotification( + ((PacketEvent) event).getPacketType().name(), player, + (int) newVls); else - notificationsModule.sendNotification(module.getName(), player, (int) newVls); + notificationsModule.sendNotification(module.getName(), player, + (int) newVls); } else - server.getScheduler().runTask(plugin, () -> server.dispatchCommand(server.getConsoleSender(), punishCommand.replace("%player%", player.getName()))); + server.getScheduler().runTask(plugin, + () -> server.dispatchCommand(server.getConsoleSender(), + punishCommand.replace("%player%", player.getName()))); } } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index bf42a43..f048219 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -5,9 +5,14 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.google.common.base.Charsets; import io.netty.buffer.ByteBuf; + +import org.bukkit.Material; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; import twolovers.exploitfixer.bukkit.utils.VersionUtil; @@ -16,6 +21,7 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -26,7 +32,7 @@ public class BukkitCustomPayloadModule implements CustomPayloadModule { private ModuleManager moduleManager; private Violations violations; private int maxChannelsAmount, bigDataMaxBytes; - private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; + private double cancelVls, reduceVls, booksVls, booksMaxBytes, maxChannelsVls, bigDataVls; private boolean enabled; public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { @@ -71,6 +77,8 @@ public void reload(final Object configYml) { this.enabled = configYml1.getBoolean(name + ".enabled"); this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); + this.booksVls = configYml1.getDouble(name + ".invalid.books.vls"); + this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); @@ -91,41 +99,83 @@ public void check(final Object eventObject) { if (player != null && player.isOnline()) { final PacketContainer packet = event.getPacket(); - final StructureModifier stringStructureModifier = packet.getStrings(); - final String tag = stringStructureModifier.readSafely(0); - - if (tag != null && !VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet.getSpecificModifier(ByteBuf.class); - final String content = byteBufModifier.readSafely(0).toString(Charsets.UTF_8); - - if (content != null) { - try { - final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, - player); - - if (tag.toLowerCase().endsWith("register") - && content.split("\000").length > maxChannelsAmount) { - exploitPlayer.addVls(plugin, eventObject, player, this, - multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); - } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, eventObject, player, this, - multipliers.getOrDefault(tag, bigDataVls)); + final StructureModifier packetStrings = packet.getStrings(); + final String tag = packetStrings.readSafely(0); + + if (tag != null) { + if (tag.endsWith("BEdit") || tag.endsWith("BOpen") || tag.endsWith("BSign")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack heldItem = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (heldItem != null) { + final Material heldItemType = heldItem.getType(); + + if (heldItemType != Material.BOOK_AND_QUILL && heldItemType != Material.WRITTEN_BOOK) { + event.setCancelled(true); + } + } + } + + if (!event.isCancelled()) { + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet + .getSpecificModifier(ByteBuf.class); + final ByteBuf byteBufModifier0 = byteBufModifier.readSafely(0); + final String content = byteBufModifier0.toString(Charsets.UTF_8); + + if (content != null) { + try { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() + .get(uuid, player); + final String[] pages = content.split("\000"); + + if ((tag.endsWith("BEdit") || tag.endsWith("BSign") || tag.endsWith("BOpen")) + && checkPages(event, exploitPlayer, player, pages)) { + exploitPlayer.addVls(plugin, eventObject, player, this, booksVls); + } else if (tag.endsWith("Register") && pages.length > maxChannelsAmount) { + exploitPlayer.addVls(plugin, eventObject, player, this, maxChannelsVls); + } + + if (!event.isCancelled()) { + if (content.length() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, eventObject, player, this, + multipliers.getOrDefault(tag, bigDataVls)); + } else { + exploitPlayer.addVls(plugin, eventObject, player, this, multipliers + .getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + } + } + } catch (final UnsupportedOperationException e) { + event.setCancelled(true); + } } else { - exploitPlayer.addVls(plugin, eventObject, player, this, - multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + event.setCancelled(true); } - } catch (final UnsupportedOperationException e) { - event.setCancelled(true); } } else { event.setCancelled(true); } - } else { - event.setCancelled(true); } } } } } + + private boolean checkPages(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, + final String[] pages) { + + System.out.println(pages.length - 9 > 50); + + if (pages.length - 9 > 50) { + return true; + } else + for (final String page : pages) { + if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { + return true; + } + } + + return false; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index aa76dc0..25dbae1 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -4,14 +4,17 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.utility.StreamSerializer; import com.comphenix.protocol.wrappers.WrappedBlockData; import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.nbt.NbtBase; import io.netty.buffer.ByteBuf; + import org.bukkit.block.BlockState; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; @@ -25,8 +28,11 @@ import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.PacketsModule; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; @@ -118,6 +124,8 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { if (!event.isCancelled() && bigDataVls > 0) { final StructureModifier itemModifier = packet.getItemModifier(); + final StructureModifier> itemListModifier = packet.getItemListModifier(); + final StructureModifier itemArrayModifier = packet.getItemArrayModifier(); final StructureModifier blockData; final StructureModifier integers = packet.getIntegers(); final StructureModifier longs = packet.getLongs(); @@ -146,58 +154,80 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { if (!event.isCancelled()) { for (final ItemStack itemStack : itemModifier.getValues()) { - if (checkItem(itemStack, event, exploitPlayer, player, packetSize)) - break; + checkItem(itemStack, event, exploitPlayer, player, packetSize); } - if (!event.isCancelled()) { - if (blockData != null) { - for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { - if (wrappedBlockData != null) { - int dataBytes = wrappedBlockData.toString() - .getBytes(StandardCharsets.UTF_8).length; + for (final List itemList : itemListModifier.getValues()) + for (final ItemStack itemStack : itemList) { + checkItem(itemStack, event, exploitPlayer, player, packetSize); + } - packetSize.addAndGet(dataBytes); - } - } + for (final ItemStack[] itemList : itemArrayModifier.getValues()) + for (final ItemStack itemStack : itemList) { + checkItem(itemStack, event, exploitPlayer, player, packetSize); } - for (final String string : strings.getValues()) { - if (string != null) { - int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; + if (blockData != null) { + for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { + if (wrappedBlockData != null) { + final int dataBytes = wrappedBlockData.toString() + .getBytes(StandardCharsets.UTF_8).length; packetSize.addAndGet(dataBytes); } } + } - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - int dataBytes = nbtBase.getValue().toString() - .getBytes(StandardCharsets.UTF_8).length; + for (final String string : strings.getValues()) { + if (string != null) { + final int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } + packetSize.addAndGet(dataBytes); + } + } + + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + final int dataBytes = nbtBase.getValue().toString() + .getBytes(StandardCharsets.UTF_8).length; + + packetSize.addAndGet(dataBytes); } + } + + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet + .getSpecificModifier(ByteBuf.class); - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet - .getSpecificModifier(ByteBuf.class); + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + try { + if (byteBuf != null) { + final byte[] bytes = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(bytes); + final DataInputStream inputStream = new DataInputStream( + new ByteArrayInputStream(bytes)); - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - if (byteBuf != null) - packetSize.addAndGet(byteBuf.capacity()); + checkItem( + StreamSerializer.getDefault().deserializeItemStack(inputStream), + event, exploitPlayer, player, packetSize); + + inputStream.close(); + packetSize.addAndGet(((ByteBuf) byteBuf).capacity()); + } + } catch (final Exception ignored) { } } if (packetSize.get() > bigDataMaxBytes) { exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } + } } - } - if (!event.isCancelled()) { - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetType.name())); + if (!event.isCancelled()) { + exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetType.name())); + } } } catch (final UnsupportedOperationException ignored) { event.setCancelled(true); @@ -279,31 +309,11 @@ private boolean checkItem(final ItemStack itemStack, final PacketEvent event, fi final InventoryHolder inventoryHolder = (InventoryHolder) blockState; for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) - if (checkItem(itemStack1, event, exploitPlayer, player, packetSize)) - break; - } - } - } else if (booksVlsInvalid > 0 && itemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; - - if (exploitPlayer == null) - event.setCancelled(true); - else if (bookMeta.getPageCount() > 50) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); - } else { - for (final String page : bookMeta.getPages()) { - if (event.isCancelled()) { - break; - } else if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); - } - } - - if (!event.isCancelled()) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsNormal); + checkItem(itemStack1, event, exploitPlayer, player, packetSize); } } - } + } else + checkBook(event, exploitPlayer, player, itemMeta); } packetSize.addAndGet(dataBytes); @@ -313,6 +323,31 @@ else if (bookMeta.getPageCount() > 50) { return true; } + private void checkBook(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, + final ItemMeta itemMeta) { + if (booksVlsInvalid > 0 && itemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + + if (exploitPlayer == null) { + event.setCancelled(true); + } else if (bookMeta.getPageCount() > 50) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); + } else { + for (final String page : bookMeta.getPages()) { + if (event.isCancelled()) { + break; + } else if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); + } + } + + if (!event.isCancelled()) { + exploitPlayer.addVls(plugin, event, player, this, booksVlsNormal); + } + } + } + } + private boolean checkSign(final WrappedChatComponent[] linesChatComponent, final String[] linesString) { if (linesChatComponent != null) { if (linesChatComponent.length > 4) { diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index 0a8e8a9..5a0af12 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -29,7 +29,8 @@ public void onChat(final ChatEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), + proxiedPlayer); if (!exploitPlayer.isLogged()) { event.setCancelled(true); diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java index a89ae5f..b38f01e 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java @@ -87,17 +87,22 @@ public void check(final Object event) { if (tag != null) { final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender; - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(proxiedPlayer.getUniqueId(), proxiedPlayer); + final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() + .get(proxiedPlayer.getUniqueId(), proxiedPlayer); - if (tag.toLowerCase().endsWith("register") && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); + if (tag.toLowerCase().endsWith("register") + && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { + exploitPlayer.addVls(plugin, event, sender, this, + multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); } else if (content.length() > bigDataMaxBytes) { exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); } else { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); + exploitPlayer.addVls(plugin, event, sender, this, + multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); } - } else + } else { pluginMessageEvent.setCancelled(true); + } } } } From 417d97c6e2e1f95343e907f0e432d31537f1403b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 1 Mar 2020 17:43:15 -0300 Subject: [PATCH 043/336] Updated Source --- .../exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java index f048219..990ac8d 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java @@ -165,8 +165,6 @@ && checkPages(event, exploitPlayer, player, pages)) { private boolean checkPages(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, final String[] pages) { - System.out.println(pages.length - 9 > 50); - if (pages.length - 9 > 50) { return true; } else From 92fc6e7323b53070f604138b5c4a27dc484e0065 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 15 Mar 2020 00:49:58 -0300 Subject: [PATCH 044/336] Updated Source --- src/config.yml | 2 +- .../SetCreativeSlotPacketAdapter.java | 60 ++--------------- .../initializers/ListenerInitializer.java | 1 + .../bukkit/managers/BukkitModuleManager.java | 5 +- .../bukkit/modules/BukkitItemsFixModule.java | 66 ++++++++++++++++++- .../bukkit/modules/BukkitPacketsModule.java | 55 +++++++++------- .../interfaces/modules/ItemsFixModule.java | 4 ++ 7 files changed, 110 insertions(+), 83 deletions(-) diff --git a/src/config.yml b/src/config.yml index 5e93af6..0c35249 100644 --- a/src/config.yml +++ b/src/config.yml @@ -91,7 +91,7 @@ packets: enabled: true # Amount of vls required to start cancelling packets. - cancel_vls: 400 + cancel_vls: 500 # Amount of vls to reduce per second. reduce_vls: 300 diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java index 2098853..f013d37 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java @@ -3,24 +3,20 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; + import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; + import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; import twolovers.exploitfixer.interfaces.managers.ModuleManager; import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; import twolovers.exploitfixer.interfaces.modules.PacketsModule; -import java.util.List; -import java.util.Map; - public class SetCreativeSlotPacketAdapter extends PacketAdapter { private final ModuleManager moduleManager; @@ -53,56 +49,12 @@ public void onPacketReceiving(final PacketEvent event) { event.setCancelled(true); } } else if (itemsFixModule.isEnabled()) { - final StructureModifier itemModifier = event.getPacket().getItemModifier(); + final PacketContainer packet = event.getPacket(); + final StructureModifier itemModifier = packet.getItemModifier(); final ItemStack itemStack = itemModifier.readSafely(0); if (itemStack != null) { - final Material material = itemStack.getType(); - final ItemMeta itemMeta = itemStack.getItemMeta(); - final int enchantLimit = itemsFixModule.getEnchantLimit(); - final ItemStack itemStackRemake = new ItemStack(material, itemStack.getAmount()); - - if (enchantLimit > 0) { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - if (enchantments.get(enchantment) > enchantLimit) - itemStackRemake.removeEnchantment(enchantment); - } else { - final Map enchantments = itemStackRemake.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - itemStackRemake.removeEnchantment(enchantment); - } - - if (itemStack.hasItemMeta()) { - final String displayName = itemMeta.getDisplayName(); - final List lore = itemMeta.getLore(); - final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final int maxStackSize = itemsFixModule.getMaxStackSize(); - - if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; - final BookMeta newBookMeta = (BookMeta) newItemMeta; - - newBookMeta.setTitle(bookMeta.getTitle()); - newBookMeta.setAuthor(bookMeta.getAuthor()); - newBookMeta.setPages(bookMeta.getPages()); - } - - if (maxStackSize != 0 && itemStackRemake.getAmount() > maxStackSize) - itemStackRemake.setAmount(maxStackSize); - - if (displayName != null && displayName.getBytes().length < 128) - newItemMeta.setDisplayName(displayName); - - if (lore != null && lore.toString().getBytes().length < 1024) - newItemMeta.setLore(lore); - - itemStackRemake.setItemMeta(newItemMeta); - } - - itemModifier.write(0, itemStack); + itemModifier.write(0, itemsFixModule.fixItemStack(itemStack)); } } } else if (packetsModule.isOffline()) diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 7c13765..500bcae 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -2,6 +2,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; + import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; import twolovers.exploitfixer.bukkit.listeners.PlayerQuitListener; diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java index 713daa9..c24af39 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java @@ -25,7 +25,7 @@ public BukkitModuleManager(final Plugin plugin, final Configuration configYml, f this.plugin = plugin; this.commandsModule = new BukkitCommandsModule(configYml); this.customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); - this.itemsFixModule = new BukkitItemsFixModule(configYml); + this.itemsFixModule = new BukkitItemsFixModule(plugin, configYml); this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); this.notificationsModule = new BukkitNotificationsModule(configYml); this.uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); @@ -49,7 +49,8 @@ public void reload(final Object configYml, final Object messagesYml, final Objec } catch (final NullPointerException e) { final Server server = plugin.getServer(); - server.getLogger().log(Level.SEVERE, "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); + server.getLogger().log(Level.SEVERE, + "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); server.getPluginManager().disablePlugin(plugin); e.printStackTrace(); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index cd6890c..d6f42d4 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -1,13 +1,25 @@ package twolovers.exploitfixer.bukkit.modules; +import java.util.List; +import java.util.Map; + +import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; public class BukkitItemsFixModule implements ItemsFixModule { + private final Plugin plugin; private boolean enabled; private int enchantLimit, maxStackSize; - public BukkitItemsFixModule(final Object configYml) { + public BukkitItemsFixModule(final Plugin plugin, final Object configYml) { + this.plugin = plugin; reload(configYml); } @@ -40,4 +52,56 @@ public int getEnchantLimit() { public int getMaxStackSize() { return maxStackSize; } + + @Override + public ItemStack fixItemStack(final ItemStack itemStack) { + if (itemStack != null) { + final Material material = Material.getMaterial(itemStack.getType().name()); + final ItemMeta itemMeta = itemStack.getItemMeta(); + final int enchantLimit = getEnchantLimit(); + final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + + if (enchantLimit > 0) { + final Map enchantments = itemStack.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + if (enchantments.get(enchantment) > enchantLimit) + itemStack.removeEnchantment(enchantment); + } else { + final Map enchantments = itemStack.getEnchantments(); + + for (final Enchantment enchantment : enchantments.keySet()) + itemStack.removeEnchantment(enchantment); + } + + if (itemStack.hasItemMeta()) { + final String displayName = itemMeta.getDisplayName(); + final List lore = itemMeta.getLore(); + final int maxStackSize = getMaxStackSize(); + + if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + final BookMeta newBookMeta = (BookMeta) newItemMeta; + + newBookMeta.setTitle(bookMeta.getTitle()); + newBookMeta.setAuthor(bookMeta.getAuthor()); + newBookMeta.setPages(bookMeta.getPages()); + } + + if (maxStackSize != 0 && itemStack.getAmount() > maxStackSize) + itemStack.setAmount(maxStackSize); + + if (displayName != null && displayName.getBytes().length < 128) + newItemMeta.setDisplayName(displayName); + + if (lore != null && lore.toString().getBytes().length < 1024) + newItemMeta.setLore(lore); + } + + itemStack.setType(material); + itemStack.setItemMeta(newItemMeta); + } + + return itemStack; + } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 25dbae1..c9f3ec5 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; @@ -214,7 +215,7 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { inputStream.close(); packetSize.addAndGet(((ByteBuf) byteBuf).capacity()); } - } catch (final Exception ignored) { + } catch (final IOException ignored) { } } @@ -288,37 +289,41 @@ public Violations getViolations() { private boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, final Player player, final AtomicInteger packetSize) { if (itemStack != null && !event.isCancelled()) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - - if (itemMeta != null) { - try { - dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())) - .getBytes(StandardCharsets.UTF_8).length; - } + try { + final ItemMeta itemMeta = itemStack.getItemMeta(); + int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + if (itemMeta != null) { + try { + dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())) + .getBytes(StandardCharsets.UTF_8).length; + } - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) - checkItem(itemStack1, event, exploitPlayer, player, packetSize); + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) + checkItem(itemStack1, event, exploitPlayer, player, packetSize); + } } - } - } else - checkBook(event, exploitPlayer, player, itemMeta); - } + } else + checkBook(event, exploitPlayer, player, itemMeta); + } - packetSize.addAndGet(dataBytes); + packetSize.addAndGet(dataBytes); - return false; + return false; + } catch (final Exception exception) { + return true; + } } else return true; } diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java index 72769f2..506cd80 100644 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java @@ -1,7 +1,11 @@ package twolovers.exploitfixer.interfaces.modules; +import org.bukkit.inventory.ItemStack; + public interface ItemsFixModule extends ReloadableModule { int getEnchantLimit(); int getMaxStackSize(); + + ItemStack fixItemStack(final ItemStack itemStack); } From da8576907cf85fdbe1fbb836681476235434fc34 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 15 Mar 2020 00:55:12 -0300 Subject: [PATCH 045/336] Updated plugin.yml --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index c96d9fe..f78ac31 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.1 +version: 1.2.2 author: 2LS api: "1.13" api-version: "1.13" From 72c72254e0048a47bbb621350b2bc364e3cdf057 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 17 Mar 2020 16:53:47 -0300 Subject: [PATCH 046/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 78 +++++++++---------- src/plugin.yml | 5 +- .../initializers/AdapterInitializer.java | 20 +++-- .../instanceables/BukkitExploitPlayer.java | 1 + .../bukkit/listeners/PlayerLoginListener.java | 3 +- .../bukkit/modules/BukkitItemsFixModule.java | 8 +- .../bukkit/modules/BukkitPacketsModule.java | 45 +++-------- 8 files changed, 68 insertions(+), 94 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 2650ebd..2d495f3 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.1 +version: 1.2.3 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 0c35249..b75e079 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,11 +1,19 @@ -# ExploitFixer developed by LinsaFTW. +# ExploitFixer by LinsaFTW +# Please help by donating, we require funds to continue with the development. +# https://paypal.me/LinsaFTW # -# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands checks works on BungeeCord. -# This is because the other checks doesn't do anything on BungeeCord. -# The other checks require to be installed in Spigot with ProtocolLib. + +# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands modules work on BungeeCord. +# This is because the other modules cant do anything on BungeeCord. +# The other modules require ExploitFixer to be installed in Spigot with ProtocolLib. # You need to install the plugin on BungeeCord and all Spigot servers. +# -# Shows notifications to players with permissions. +# Checks works with VLs, this a counter to execute different commands on +# different levels of violations to allow customization of the modules. +# + +# Shows notifications to console and players with permissions. notifications: enabled: true @@ -13,7 +21,7 @@ notifications: message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" # Prevents a variety of exploits that occur on connection establish. -# Players wont be able to type commands until the connection is secured. (You wont notice this) +# Players wont be able to type messages/commands until the connection is secured. (You wont notice this) connection: # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. # NullAddress only affects non-firewalled servers using IP Whitelist. @@ -30,8 +38,8 @@ itemsfix: # Maximum stack size obtainable with creative packets. (Set to 0 to allow everything) max_stack_size: 64 - # Maximum enchant level obtainable with creative packets. (Set to 0 to disable custom enchants) - enchant_limit: 0 + # Maximum enchant level obtainable with creative packets. (Set to 0 to remove all enchants, -1 to disable) + enchant_limit: 10 # Prevents the use of CustomPayload packets to exploit the server. custompayload: @@ -72,7 +80,7 @@ custompayload: # When a valid packet is sent the following amount of vls will be applied. multipliers: OTHER: 0.1 - SETTINGS: 5 + SETTINGS: 0.5 MC|BSign: 50 MC|BEdit: 50 MC|BOpen: 50 @@ -87,6 +95,7 @@ custompayload: - "kick" # Prevents the use of packets to exploit the server. +# This prevents almost every exploit available for Bukkit. packets: enabled: true @@ -96,57 +105,40 @@ packets: # Amount of vls to reduce per second. reduce_vls: 300 - # Blocks different types of invalid packets. + # Blocks packets when they arent meant to be sent or if they sent invalid data. invalid: - # Cancells packets if the player sending it is offline. + # Cancells packets if the player sending them is offline. offline: true # Never disable this and instead increase max_bytes if you have false positives. # This will check if integers, floats, doubles and packets have a invalid size. big_data: - # Vls to add when too big packets are sent. (Set to 0 to disable) + # Vls to add when too big packets are sent. (Set to -1 to disable) vls: 1000 - # Maximum amount of bytes per packet. - max_bytes: 16000 + # Maximum amount of bytes allowed per packet. (Increase to 80000 to allow Shulker Box) + max_bytes: 20000 - # Maximum amount of items per StructureModifier. - max_structure: 25 + # Maximum amount of bytes allowed per book page. + max_bytes_book: 268 - # big_data is required to enable this check. (Checks page quantity and bytes) - books: - vls: - # Vls to add when invalid book packets are sent. (Set to 0 to disable) - invalid: 1000 + # Maximum amount of bytes allowed per sign line. + max_bytes_sign: 47 - # Vls to add when normal book packets are sent. (Set to 0 to disable) - normal: 20 - - # Maximum amount of bytes per page. - max_bytes: 258 - - # Prevents invalid signs used to crash your server. (Checks if exceeds bytes) - signs: - # Vls to add when invalid sign packets are sent. (Set to 0 to disable) - vls: 1000 - - # Maximum amount of bytes per sign line. - max_bytes: 47 - - # Vls to add when invalid window_click packets are sent. (Set to 0 to disable) - # Vls added by null InventoryView is the tenth part of the window_click vls. + # Checks if players send WINDOW_CLICK packets with another item in cursor. (Set to -1 to disable) window_click: 1000 - # Vls to add when invalid block_place packets are sent. (Set to 0 to disable) + # Checks if players send BLOCK_PLACE packets with another item in hand. (Set to -1 to disable) block_place: 1000 - # Vls to add when invalid block_dig packets are sent. (Set to 0 to disable) + # Checks if players send BLOCK_DIG packets with another item in hand. (Set to -1 to disable) block_dig: 1000 - # Vls to add when invalid set_creative_slot packets are sent. (Set to 0 to disable) + # Checks if players send SET_CREATIVE_SLOT packets without creative. (Set to -1 to disable) set_creative_slot: 1000 - # When a valid packet is sent the following amount of vls will be applied. + # When a valid packet is sent the following amount of vls will be applied to the player. + # This is made to prevent packet spamming. multipliers: ABILITIES: 1 ARM_ANIMATION: 3 @@ -159,8 +151,8 @@ packets: POSITION_LOOK: 0.75 POSITION: 3.5 SET_CREATIVE_SLOT: 0.5 - SETTINGS: 5 - TAB_COMPLETE: 8 + SETTINGS: 0.5 + TAB_COMPLETE: 2 UPDATE_SIGN: 90 USE_ENTITY: 4 USE_ITEM: 4 diff --git a/src/plugin.yml b/src/plugin.yml index f78ac31..31ec3e3 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,13 +1,12 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.2 +version: 1.2.3 author: 2LS api: "1.13" api-version: "1.13" load: STARTUP depend: [ProtocolLib] -loadbefore: - [AAC, ViaVersion, ViaBackwards, ViaRewind, ViaRewindPotions, ProtocolSupport] +loadbefore: [ProtocolLib, AAC, ViaVersion, ProtocolSupport] commands: exploitfixer: description: The main ExploitFixer command diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index 2ac5113..dd95720 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -25,14 +25,18 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager if (packetType.isSupported() && packetType != PacketType.Play.Client.BLOCK_DIG && packetType != PacketType.Play.Client.BLOCK_PLACE && packetType != PacketType.Play.Client.SET_CREATIVE_SLOT - && packetType != PacketType.Play.Client.WINDOW_CLICK) { - if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD && customPayloadModule.isEnabled()) { - protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - customPayloadModule.check(event); - } - }); + && packetType != PacketType.Play.Client.WINDOW_CLICK + && packetType != PacketType.Play.Client.KEEP_ALIVE) { + if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD) { + if (customPayloadModule.isEnabled()) { + protocolManager + .addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { + @Override + public void onPacketReceiving(final PacketEvent event) { + customPayloadModule.check(event); + } + }); + } } else if (packetsModule.isEnabled()) { protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { @Override diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 62ac31e..34cda61 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -65,6 +65,7 @@ public double getViolations(final Module module) { return 0D; } + @Override public String getOnlineUUID() { if (onlineUUID == null) { try { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 1d08cde..e9cd2ba 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -61,7 +61,8 @@ public void onPlayerLogin(final PlayerLoginEvent event) { scheduler.runTaskAsynchronously(plugin, () -> { final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()).toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) + .toString().replace("-", ""); if (!originalUUID.contains(offlineUUID)) { final String onlineUUID = exploitPlayer.getOnlineUUID(); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index d6f42d4..8b9d4c0 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -28,9 +28,9 @@ final public void reload(final Object configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.enchantLimit = configYml1.getInt(name + ".enchant_limit"); - this.maxStackSize = configYml1.getInt(name + ".max_stack_size"); + this.enabled = configYml1.getBoolean(name + ".enabled", true); + this.enchantLimit = configYml1.getInt(name + ".enchant_limit", 10); + this.maxStackSize = configYml1.getInt(name + ".max_stack_size", 64); } @Override @@ -67,7 +67,7 @@ public ItemStack fixItemStack(final ItemStack itemStack) { for (final Enchantment enchantment : enchantments.keySet()) if (enchantments.get(enchantment) > enchantLimit) itemStack.removeEnchantment(enchantment); - } else { + } else if (enchantLimit == 0) { final Map enchantments = itemStack.getEnchantments(); for (final Enchantment enchantment : enchantments.keySet()) diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index c9f3ec5..0a6cab6 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -44,7 +44,7 @@ public class BukkitPacketsModule implements PacketsModule { private final Map multipliers = new HashMap<>(); private Violations violations; private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, - reduceVls, booksVlsInvalid, booksVlsNormal, signsVls, bigDataMaxStructure; + reduceVls; private int booksMaxBytes, signsMaxBytes; private boolean enabled, offline; @@ -64,14 +64,10 @@ final public void reload(final Object configYml) { this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); this.offline = configYml1.getBoolean(name + ".invalid.offline"); - this.booksVlsInvalid = configYml1.getDouble(name + ".invalid.books.vls.invalid"); - this.booksVlsNormal = configYml1.getDouble(name + ".invalid.books.vls.normal"); - this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); - this.signsVls = configYml1.getDouble(name + ".invalid.signs.vls", 1000); - this.signsMaxBytes = configYml1.getInt(name + ".invalid.signs.max_bytes", 47); this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); - this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes"); - this.bigDataMaxStructure = configYml1.getDouble(name + ".invalid.big_data.max_structure"); + this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes", 24000); + this.booksMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes_book", 268); + this.signsMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes_sign", 47); this.windowClick = configYml1.getDouble(name + ".invalid.window_click"); this.blockPlace = configYml1.getDouble(name + ".invalid.block_place"); this.blockDig = configYml1.getDouble(name + ".invalid.block_dig"); @@ -118,9 +114,9 @@ public void check(final Object eventObject) { chatComponentArrays0 = null; } - if (signsVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN + if (bigDataVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { - exploitPlayer.addVls(plugin, event, player, this, signsVls); + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } if (!event.isCancelled() && bigDataVls > 0) { @@ -128,10 +124,6 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { final StructureModifier> itemListModifier = packet.getItemListModifier(); final StructureModifier itemArrayModifier = packet.getItemArrayModifier(); final StructureModifier blockData; - final StructureModifier integers = packet.getIntegers(); - final StructureModifier longs = packet.getLongs(); - final StructureModifier floats = packet.getFloat(); - final StructureModifier doubles = packet.getDoubles(); final StructureModifier strings = packet.getStrings(); final StructureModifier> nbtModifier = packet.getNbtModifier(); final AtomicInteger packetSize = new AtomicInteger(0); @@ -142,17 +134,6 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { blockData = null; } - if ((chatComponentArrays != null && chatComponentArrays.size() > bigDataMaxStructure) - || itemModifier.size() > bigDataMaxStructure - || stringArrays.size() > bigDataMaxStructure - || (blockData != null && blockData.size() > bigDataMaxStructure) - || integers.size() > bigDataMaxStructure || longs.size() > bigDataMaxStructure - || floats.size() > bigDataMaxStructure || doubles.size() > bigDataMaxStructure - || strings.size() > bigDataMaxStructure - || nbtModifier.size() > bigDataMaxStructure) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } - if (!event.isCancelled()) { for (final ItemStack itemStack : itemModifier.getValues()) { checkItem(itemStack, event, exploitPlayer, player, packetSize); @@ -222,7 +203,6 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { if (packetSize.get() > bigDataMaxBytes) { exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } - } } @@ -314,8 +294,9 @@ private boolean checkItem(final ItemStack itemStack, final PacketEvent event, fi checkItem(itemStack1, event, exploitPlayer, player, packetSize); } } - } else + } else if (itemMeta instanceof BookMeta) { checkBook(event, exploitPlayer, player, itemMeta); + } } packetSize.addAndGet(dataBytes); @@ -330,25 +311,21 @@ private boolean checkItem(final ItemStack itemStack, final PacketEvent event, fi private void checkBook(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, final ItemMeta itemMeta) { - if (booksVlsInvalid > 0 && itemMeta instanceof BookMeta) { + if (bigDataVls > 0 && itemMeta instanceof BookMeta) { final BookMeta bookMeta = (BookMeta) itemMeta; if (exploitPlayer == null) { event.setCancelled(true); } else if (bookMeta.getPageCount() > 50) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } else { for (final String page : bookMeta.getPages()) { if (event.isCancelled()) { break; } else if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsInvalid); + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } } - - if (!event.isCancelled()) { - exploitPlayer.addVls(plugin, event, player, this, booksVlsNormal); - } } } } From 219b45c57e6899c64be5b11f25cf48de90b5616f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 19 Mar 2020 17:11:45 -0300 Subject: [PATCH 047/336] Updated Source --- src/config.yml | 2 +- .../bukkit/modules/BukkitItemsFixModule.java | 16 +-- .../bukkit/modules/BukkitPacketsModule.java | 104 ++++++++---------- 3 files changed, 53 insertions(+), 69 deletions(-) diff --git a/src/config.yml b/src/config.yml index b75e079..1365cba 100644 --- a/src/config.yml +++ b/src/config.yml @@ -39,7 +39,7 @@ itemsfix: max_stack_size: 64 # Maximum enchant level obtainable with creative packets. (Set to 0 to remove all enchants, -1 to disable) - enchant_limit: 10 + enchant_limit: 11 # Prevents the use of CustomPayload packets to exploit the server. custompayload: diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index 8b9d4c0..ed2293f 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -58,20 +58,14 @@ public ItemStack fixItemStack(final ItemStack itemStack) { if (itemStack != null) { final Material material = Material.getMaterial(itemStack.getType().name()); final ItemMeta itemMeta = itemStack.getItemMeta(); - final int enchantLimit = getEnchantLimit(); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + final Map enchantments = itemStack.getEnchantments(); - if (enchantLimit > 0) { - final Map enchantments = itemStack.getEnchantments(); + for (final Enchantment enchantment : enchantments.keySet()) { + final int level = enchantments.get(enchantment); - for (final Enchantment enchantment : enchantments.keySet()) - if (enchantments.get(enchantment) > enchantLimit) - itemStack.removeEnchantment(enchantment); - } else if (enchantLimit == 0) { - final Map enchantments = itemStack.getEnchantments(); - - for (final Enchantment enchantment : enchantments.keySet()) - itemStack.removeEnchantment(enchantment); + if (enchantLimit < 0 || enchantments.get(enchantment) < enchantLimit) + newItemMeta.addEnchant(enchantment, level, true); } if (itemStack.hasItemMeta()) { diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index 0a6cab6..daa404f 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -121,88 +121,78 @@ && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { if (!event.isCancelled() && bigDataVls > 0) { final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier> itemListModifier = packet.getItemListModifier(); final StructureModifier itemArrayModifier = packet.getItemArrayModifier(); - final StructureModifier blockData; final StructureModifier strings = packet.getStrings(); final StructureModifier> nbtModifier = packet.getNbtModifier(); final AtomicInteger packetSize = new AtomicInteger(0); if (!VersionUtil.isOneDotSeven()) { - blockData = packet.getBlockData(); - } else { - blockData = null; - } - - if (!event.isCancelled()) { - for (final ItemStack itemStack : itemModifier.getValues()) { - checkItem(itemStack, event, exploitPlayer, player, packetSize); - } + for (final WrappedBlockData wrappedBlockData : packet.getBlockData().getValues()) { + if (wrappedBlockData != null) { + final int dataBytes = wrappedBlockData.toString() + .getBytes(StandardCharsets.UTF_8).length; - for (final List itemList : itemListModifier.getValues()) - for (final ItemStack itemStack : itemList) { - checkItem(itemStack, event, exploitPlayer, player, packetSize); + packetSize.addAndGet(dataBytes); } + } - for (final ItemStack[] itemList : itemArrayModifier.getValues()) + for (final List itemList : packet.getItemListModifier().getValues()) { for (final ItemStack itemStack : itemList) { checkItem(itemStack, event, exploitPlayer, player, packetSize); } + } + } - if (blockData != null) { - for (final WrappedBlockData wrappedBlockData : blockData.getValues()) { - if (wrappedBlockData != null) { - final int dataBytes = wrappedBlockData.toString() - .getBytes(StandardCharsets.UTF_8).length; + for (final ItemStack itemStack : itemModifier.getValues()) { + checkItem(itemStack, event, exploitPlayer, player, packetSize); + } - packetSize.addAndGet(dataBytes); - } - } + for (final ItemStack[] itemList : itemArrayModifier.getValues()) + for (final ItemStack itemStack : itemList) { + checkItem(itemStack, event, exploitPlayer, player, packetSize); } - for (final String string : strings.getValues()) { - if (string != null) { - final int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; + for (final String string : strings.getValues()) { + if (string != null) { + final int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } + packetSize.addAndGet(dataBytes); } + } - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - final int dataBytes = nbtBase.getValue().toString() - .getBytes(StandardCharsets.UTF_8).length; + for (final NbtBase nbtBase : nbtModifier.getValues()) { + if (nbtBase != null) { + final int dataBytes = nbtBase.getValue().toString() + .getBytes(StandardCharsets.UTF_8).length; - packetSize.addAndGet(dataBytes); - } + packetSize.addAndGet(dataBytes); } + } - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet - .getSpecificModifier(ByteBuf.class); - - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - try { - if (byteBuf != null) { - final byte[] bytes = new byte[byteBuf.readableBytes()]; - byteBuf.readBytes(bytes); - final DataInputStream inputStream = new DataInputStream( - new ByteArrayInputStream(bytes)); - - checkItem( - StreamSerializer.getDefault().deserializeItemStack(inputStream), - event, exploitPlayer, player, packetSize); - - inputStream.close(); - packetSize.addAndGet(((ByteBuf) byteBuf).capacity()); - } - } catch (final IOException ignored) { + if (!VersionUtil.isOneDotSeven()) { + final StructureModifier byteBufModifier = packet + .getSpecificModifier(ByteBuf.class); + + for (final ByteBuf byteBuf : byteBufModifier.getValues()) { + try { + if (byteBuf != null) { + final byte[] bytes = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(bytes); + final DataInputStream inputStream = new DataInputStream( + new ByteArrayInputStream(bytes)); + + checkItem(StreamSerializer.getDefault().deserializeItemStack(inputStream), + event, exploitPlayer, player, packetSize); + + inputStream.close(); + packetSize.addAndGet(((ByteBuf) byteBuf).capacity()); } + } catch (final IOException ignored) { } + } - if (packetSize.get() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } + if (packetSize.get() > bigDataMaxBytes) { + exploitPlayer.addVls(plugin, event, player, this, bigDataVls); } } From 6e2f1d9d6e20657366e0d464b471c9cf055a4f1f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Thu, 19 Mar 2020 17:13:17 -0300 Subject: [PATCH 048/336] Updated Source --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index 31ec3e3..7729bcf 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.3 +version: 1.2.4 author: 2LS api: "1.13" api-version: "1.13" From 259fb175a6c400ef7cfdb028df85c98ef0daf9c5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 21 Mar 2020 18:35:00 -0300 Subject: [PATCH 049/336] Updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../exploitfixer/bukkit/modules/BukkitPacketsModule.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 2d495f3..31f00bd 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.3 +version: 1.2.5 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 7729bcf..f81a560 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.4 +version: 1.2.5 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java index daa404f..126aa88 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java @@ -271,7 +271,7 @@ private boolean checkItem(final ItemStack itemStack, final PacketEvent event, fi .getBytes(StandardCharsets.UTF_8).length; } - if (itemMeta instanceof BlockStateMeta) { + if (!VersionUtil.isOneDotSeven() && itemMeta instanceof BlockStateMeta) { final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; if (blockStateMeta.hasBlockState()) { From 5fda36f94ca92a6c445ee95fd01b9f3e44d9a21d Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Sat, 28 Mar 2020 00:57:06 -0300 Subject: [PATCH 050/336] Updated Source --- src/bungee.yml | 2 +- src/messages.yml | 38 ++++++++++++++++++- src/plugin.yml | 2 +- .../instanceables/BukkitExploitPlayer.java | 26 +++++++------ .../bukkit/modules/BukkitItemsFixModule.java | 2 + .../bukkit/nms/CraftPlayerReflector.java | 4 +- 6 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 31f00bd..35242a4 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.5 +version: 1.2.6 author: 2LS commands: exploitfixer: diff --git a/src/messages.yml b/src/messages.yml index a0cebff..bbe1e01 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -1,6 +1,7 @@ # You can create as many locales as you want, -# The language will change depending on the player locale. -# If the locale of the player doesnt exist in this file, english will be used. +# because the language will change depending on the player locale. +# If the locale of the player doesnt exist in this file, english will be used by default. +# Use replace method of your text editor to quickly replace the Discord link in the messages. # English en: @@ -133,3 +134,36 @@ it: message: |- &fGiocatori in cache: &a%players_cached% &fGiocatori puniti: &a%players_punished% + +# French - Credits: HaVroz +fr: + commands: + reload: "&aPlugin Exploitfixer rechargé!" + help: |- + &aExploitFixer &b%version%&a par &bLinsaFTW&a. + &e /%command% help &7> &bAfficher les commandes disponibles. + &e /%command% reload &7> &bRecharger le plugin. + &e /%command% notifications &7> &bActiver/Désactiver les notifications du plugin. + &e /%command% stats &7> &bVoir les statistiques du plugin. + error: + unknown: "&cCommande inconnue. Utilisez /exploitfixer help pour voir les commandes disponibles!" + permission: "&cVous n’avez pas la permission d’utiliser cette commande!" + console: "&cCette commande ne peut pas être exécutée depuis la console!" + notifications: + enable: "&aVous avez activé les notifications!" + disable: "&cVous avez désactivé les notifications!" + modules: + custompayload: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + uuidspoof: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + commands: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + packets: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + nulladdress: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + stats: + message: |- + &fJoueurs caché: &a%players_cached% + &fJoueurs sanctionné: &a%players_punished% diff --git a/src/plugin.yml b/src/plugin.yml index f81a560..07e54f5 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.5 +version: 1.2.6 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 34cda61..9f3f43d 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -135,8 +135,6 @@ public void addVls(final Object pluginObject, final Object event, final Object p final Collection commands = violations.getCommands(threshold); if (commands != null && !commands.isEmpty()) { - final BukkitScheduler scheduler = server.getScheduler(); - for (final String punishCommand : commands) if (!punishCommand.isEmpty()) if (punishCommand.equals("kick")) { @@ -150,21 +148,22 @@ public void addVls(final Object pluginObject, final Object event, final Object p final String kickMessage = messagesModule.getKickMessage(module, locale); - // This is made to sync the current thread with main thread so it doesnt crash. + // This is made to sync the current thread with main thread so it doesnt + // crash. if (!server.isPrimaryThread()) { final Thread currentThread = Thread.currentThread(); - scheduler.runTask(plugin, () -> { - craftPlayer.disconnectChannel(kickMessage); + server.getScheduler().runTask(plugin, () -> { + craftPlayer.disconnect(kickMessage); currentThread.interrupt(); }); try { - Thread.sleep(200); - } catch (final InterruptedException ignored) { + Thread.sleep(500L); + } catch (final InterruptedException e) { } } else - craftPlayer.disconnectChannel(kickMessage); + craftPlayer.disconnect(kickMessage); craftPlayer.closeChannel(); exploitPlayerManager.addPunishment(); @@ -177,15 +176,18 @@ public void addVls(final Object pluginObject, final Object event, final Object p notificationsModule.sendNotification(module.getName(), player, (int) newVls); } else - server.getScheduler().runTask(plugin, - () -> server.dispatchCommand(server.getConsoleSender(), - punishCommand.replace("%player%", player.getName()))); + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishCommand.replace("%player%", player.getName())); + }); } } } } } - } else if (event instanceof Cancellable) { + } else if (event instanceof Cancellable) + + { ((Cancellable) event).setCancelled(true); } } diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java index ed2293f..ab59406 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java @@ -60,6 +60,7 @@ public ItemStack fixItemStack(final ItemStack itemStack) { final ItemMeta itemMeta = itemStack.getItemMeta(); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); final Map enchantments = itemStack.getEnchantments(); + final short durability = itemStack.getDurability(); for (final Enchantment enchantment : enchantments.keySet()) { final int level = enchantments.get(enchantment); @@ -94,6 +95,7 @@ public ItemStack fixItemStack(final ItemStack itemStack) { itemStack.setType(material); itemStack.setItemMeta(newItemMeta); + itemStack.setDurability(durability); } return itemStack; diff --git a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java index 2f4a417..775fe49 100644 --- a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java +++ b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java @@ -38,11 +38,11 @@ public void closeChannel() { method.invoke(chan); } catch (final Exception e) { - e.printStackTrace(); + // Ignore because some version throw exceptions. } } - public void disconnectChannel(final String kickMessage) { + public void disconnect(final String kickMessage) { try { final Object playerConnection = getPlayerConnection(); final Method method = playerConnection.getClass().getMethod("disconnect", String.class); From 57b274d781fb69075aa86f273608bb5d0af226c3 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Sat, 28 Mar 2020 01:04:47 -0300 Subject: [PATCH 051/336] Fixed some Stuff --- .../bukkit/instanceables/BukkitExploitPlayer.java | 9 ++++++--- .../exploitfixer/bukkit/nms/CraftPlayerReflector.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 9f3f43d..30f1014 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -166,6 +166,11 @@ public void addVls(final Object pluginObject, final Object event, final Object p craftPlayer.disconnect(kickMessage); craftPlayer.closeChannel(); + + if (player.isOnline()) { + player.kickPlayer(kickMessage); + } + exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) { if (event instanceof PacketEvent) @@ -185,9 +190,7 @@ public void addVls(final Object pluginObject, final Object event, final Object p } } } - } else if (event instanceof Cancellable) - - { + } else if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(true); } } diff --git a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java index 775fe49..397df45 100644 --- a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java +++ b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java @@ -38,7 +38,7 @@ public void closeChannel() { method.invoke(chan); } catch (final Exception e) { - // Ignore because some version throw exceptions. + // Ignore because some versions throw exceptions. } } From d6c8276a4a51fcb21a3efa87d220791389a79656 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 7 Apr 2020 07:37:02 -0300 Subject: [PATCH 052/336] Fixed a bunch of Bugs --- .../exploitfixer/bukkit/ExploitFixer.java | 11 ++++++--- .../initializers/AdapterInitializer.java | 2 ++ .../instanceables/BukkitExploitPlayer.java | 24 ++++++++++--------- .../initializers/ListenerInitializer.java | 2 ++ .../exploitfixer/bungee/ExploitFixer.java | 11 ++++++--- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 4c6f3c0..ab172ff 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -4,6 +4,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitScheduler; + import twolovers.exploitfixer.bukkit.adapters.initializers.AdapterInitializer; import twolovers.exploitfixer.bukkit.commands.ExploitFixerCommand; import twolovers.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; @@ -22,6 +24,7 @@ public class ExploitFixer extends JavaPlugin { @Override public void onEnable() { final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); @@ -36,7 +39,8 @@ public void onEnable() { VersionUtil.init(); reload(); - server.getScheduler().runTaskTimerAsynchronously(this, () -> { + scheduler.cancelTasks(this); + scheduler.runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); exploitPlayerManager.clear(); @@ -59,11 +63,12 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); if (isEnabled()) { - if (pluginManager.isPluginEnabled("ProtocolLib")) + if (pluginManager.isPluginEnabled("ProtocolLib")) { new AdapterInitializer(this, moduleManager); - else + } else { getLogger().log(Level.SEVERE, "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); + } new ListenerInitializer(this, moduleManager); diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java index dd95720..6076509 100644 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java @@ -21,6 +21,8 @@ public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager final PacketsModule packetsModule = moduleManager.getPacketsModule(); final CustomPayloadModule customPayloadModule = moduleManager.getCustomPayloadModule(); + protocolManager.removePacketListeners(plugin); + for (final PacketType packetType : PacketType.Play.Client.getInstance()) { if (packetType.isSupported() && packetType != PacketType.Play.Client.BLOCK_DIG && packetType != PacketType.Play.Client.BLOCK_PLACE diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 30f1014..515e483 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -1,11 +1,21 @@ package twolovers.exploitfixer.bukkit.instanceables; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + import com.comphenix.protocol.events.PacketEvent; + import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitScheduler; + import twolovers.exploitfixer.bukkit.nms.CraftPlayerReflector; import twolovers.exploitfixer.bukkit.utils.VersionUtil; import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; @@ -17,15 +27,6 @@ import twolovers.exploitfixer.interfaces.modules.Module; import twolovers.exploitfixer.interfaces.modules.NotificationsModule; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - public class BukkitExploitPlayer implements ExploitPlayer { final private ExploitPlayerManager exploitPlayerManager; final private MessagesModule messagesModule; @@ -162,8 +163,9 @@ public void addVls(final Object pluginObject, final Object event, final Object p Thread.sleep(500L); } catch (final InterruptedException e) { } - } else + } else { craftPlayer.disconnect(kickMessage); + } craftPlayer.closeChannel(); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 500bcae..5cfa684 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -1,5 +1,6 @@ package twolovers.exploitfixer.bukkit.listeners.initializers; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -13,6 +14,7 @@ public class ListenerInitializer { public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { final PluginManager pluginManager = plugin.getServer().getPluginManager(); + HandlerList.unregisterAll(plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/twolovers/exploitfixer/bungee/ExploitFixer.java index e6b7b4e..52ca5ec 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bungee/ExploitFixer.java @@ -2,6 +2,7 @@ import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; +import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.config.Configuration; import twolovers.exploitfixer.bungee.commands.ExploitFixerCommand; import twolovers.exploitfixer.bungee.listeners.ChatListener; @@ -20,6 +21,8 @@ public class ExploitFixer extends Plugin { private ModuleManager moduleManager; public void onEnable() { + final TaskScheduler scheduler = getProxy().getScheduler(); + plugin = this; final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); @@ -34,7 +37,8 @@ public void onEnable() { reload(); - getProxy().getScheduler().schedule(this, () -> { + scheduler.cancel(this); + scheduler.schedule(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); exploitPlayerManager.clear(); @@ -42,6 +46,7 @@ public void onEnable() { } public void reload() { + final PluginManager pluginManager = getProxy().getPluginManager(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); configurationUtil.createConfiguration("%datafolder%/config.yml"); @@ -50,7 +55,6 @@ public void reload() { final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); moduleManager.reload(configYml, messagesYml, null); - final PluginManager pluginManager = getProxy().getPluginManager(); pluginManager.unregisterListeners(this); pluginManager.registerListener(this, new ChatListener(this, moduleManager)); @@ -59,7 +63,8 @@ public void reload() { pluginManager.registerListener(this, new PostLoginListener(this, moduleManager)); pluginManager.unregisterCommands(this); - pluginManager.registerCommand(this, new ExploitFixerCommand("exploitfixer", new String[]{"ef"}, moduleManager)); + pluginManager.registerCommand(this, + new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, moduleManager)); } public static ExploitFixer getInstance() { From 74ad8cd2d8e3e11fbe514fe6cb1b5f007f9fdaa8 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 7 Apr 2020 08:05:36 -0300 Subject: [PATCH 053/336] Updated version number --- src/bungee.yml | 2 +- src/plugin.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 35242a4..a8f63cd 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.6 +version: 1.2.7 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 07e54f5..2a280b8 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,12 +1,11 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.6 +version: 1.2.7 author: 2LS api: "1.13" api-version: "1.13" load: STARTUP depend: [ProtocolLib] -loadbefore: [ProtocolLib, AAC, ViaVersion, ProtocolSupport] commands: exploitfixer: description: The main ExploitFixer command From 54a91cf500b96a6ea724af557844db4d2be09396 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Apr 2020 19:23:37 -0300 Subject: [PATCH 054/336] Updated Source --- src/messages.yml | 50 +++++++++---------- .../instanceables/BukkitExploitPlayer.java | 4 -- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/messages.yml b/src/messages.yml index bbe1e01..977d871 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -22,15 +22,15 @@ en: disable: "&cYou have disabled notifications!" modules: custompayload: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- &fPlayers cached: &a%players_cached% @@ -55,15 +55,15 @@ es: disable: "&cDeshabilitaste las notificaciones!" modules: custompayload: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- &fJugadores en cache: &a%players_cached% @@ -88,15 +88,15 @@ pt: disable: "&cVoce desativou as notificações!" modules: custompayload: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- &fJugadores em cache: &a%players_cached% @@ -121,15 +121,15 @@ it: disable: "&cHai disabilitato le notifiche!" modules: custompayload: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- &fGiocatori in cache: &a%players_cached% @@ -154,15 +154,15 @@ fr: disable: "&cVous avez désactivé les notifications!" modules: custompayload: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&nhttps://discord.gg/cjt9bPA&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- &fJoueurs caché: &a%players_cached% diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java index 515e483..4c499a9 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java @@ -169,10 +169,6 @@ public void addVls(final Object pluginObject, final Object event, final Object p craftPlayer.closeChannel(); - if (player.isOnline()) { - player.kickPlayer(kickMessage); - } - exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) { if (event instanceof PacketEvent) From 964ba4caf3d73659a1a34e2916e067b40aae4e8e Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sat, 11 Apr 2020 16:21:01 -0300 Subject: [PATCH 055/336] Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3df6a91 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://paypal.me/LinsaFTW'] From dcf1132630c6fb44067876bb1acc72d73fc17088 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 May 2020 22:52:36 -0300 Subject: [PATCH 056/336] Updated source --- src/bungee.yml | 2 +- src/config.yml | 226 ++++++------ src/messages.yml | 32 ++ src/plugin.yml | 5 +- .../exploitfixer/bukkit/ExploitFixer.java | 54 ++- .../adapters/BlockDigPacketAdapter.java | 77 ---- .../adapters/BlockPlacePacketAdapter.java | 75 ---- .../SetCreativeSlotPacketAdapter.java | 67 ---- .../adapters/WindowClickPacketAdapter.java | 106 ------ .../initializers/AdapterInitializer.java | 64 ---- .../bukkit/commands/ExploitFixerCommand.java | 14 +- .../instanceables/BukkitExploitPlayer.java | 209 ----------- .../bukkit/instanceables/ExploitPlayer.java | 185 ++++++++++ ...{BukkitViolations.java => Violations.java} | 6 +- .../listeners/ExploitFixerDecodeListener.java | 339 +++++++++++++++++ .../listeners/PlayerCommandListener.java | 21 +- .../bukkit/listeners/PlayerLoginListener.java | 45 ++- .../bukkit/listeners/PlayerQuitListener.java | 8 +- .../listeners/PlayerTabCompleteListener.java | 38 -- .../listeners/PlayerTeleportListener.java | 35 ++ .../initializers/ListenerInitializer.java | 44 ++- .../bukkit/managers/BukkitModuleManager.java | 104 ------ ...Manager.java => ExploitPlayerManager.java} | 158 ++++---- .../bukkit/managers/ModuleManager.java | 85 +++++ .../bukkit/modules/BukkitCommandsModule.java | 61 --- .../modules/BukkitCustomPayloadModule.java | 179 --------- .../modules/BukkitNotificationsModule.java | 76 ---- .../modules/BukkitNullAddressModule.java | 30 -- .../bukkit/modules/BukkitPacketsModule.java | 348 ------------------ .../bukkit/modules/BukkitUUIDSpoofModule.java | 30 -- .../bukkit/modules/CommandsModule.java | 45 +++ .../bukkit/modules/ConnectionModule.java | 50 +++ .../bukkit/modules/CustomPayloadModule.java | 103 ++++++ ...temsFixModule.java => ItemsFixModule.java} | 59 +-- ...essagesModule.java => MessagesModule.java} | 182 +++++---- .../bukkit/modules/NotificationsModule.java | 83 +++++ .../bukkit/modules/PacketsModule.java | 118 ++++++ .../bukkit/nms/CraftPlayerReflector.java | 55 --- .../bukkit/utils/ConfigurationUtil.java | 27 +- .../exploitfixer/bungee/ExploitFixer.java | 9 +- .../bungee/commands/ExploitFixerCommand.java | 14 +- .../instanceables/BungeeExploitPlayer.java | 164 --------- .../bungee/instanceables/ExploitPlayer.java | 158 ++++++++ ...{BungeeViolations.java => Violations.java} | 16 +- .../bungee/listeners/ChatListener.java | 26 +- .../bungee/listeners/DisconnectListener.java | 8 +- .../listeners/PluginMessageListener.java | 73 +++- .../bungee/listeners/PostLoginListener.java | 25 +- .../bungee/managers/BungeeModuleManager.java | 81 ---- ...Manager.java => ExploitPlayerManager.java} | 161 ++++---- .../bungee/managers/ModuleManager.java | 57 +++ .../bungee/modules/BungeeCommandsModule.java | 61 --- .../modules/BungeeCustomPayloadModule.java | 109 ------ .../modules/BungeeNotificationsModule.java | 64 ---- .../modules/BungeeNullAddressModule.java | 30 -- .../bungee/modules/BungeeUUIDSpoofModule.java | 30 -- .../bungee/modules/CommandsModule.java | 41 +++ .../bungee/modules/ConnectionModule.java | 47 +++ .../bungee/modules/CustomPayloadModule.java | 100 +++++ ...essagesModule.java => MessagesModule.java} | 165 ++++----- .../bungee/modules/NotificationsModule.java | 73 ++++ .../instanceables/ExploitPlayer.java | 22 -- .../interfaces/instanceables/Violations.java | 9 - .../managers/ExploitPlayerManager.java | 20 - .../interfaces/managers/ModuleManager.java | 25 -- .../interfaces/modules/CancellableModule.java | 11 - .../interfaces/modules/CommandsModule.java | 7 - .../modules/CustomPayloadModule.java | 5 - .../interfaces/modules/ItemsFixModule.java | 11 - .../interfaces/modules/MessagesModule.java | 23 -- .../interfaces/modules/Module.java | 7 - .../modules/NotificationsModule.java | 15 - .../interfaces/modules/PacketsModule.java | 17 - .../interfaces/modules/ReloadableModule.java | 5 - .../shared/interfaces/Module.java | 7 + .../shared/interfaces/PunishmentModule.java | 7 + .../shared/interfaces/ViolationModule.java | 9 + 77 files changed, 2294 insertions(+), 2863 deletions(-) delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java delete mode 100644 src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java delete mode 100644 src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java create mode 100644 src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java rename src/twolovers/exploitfixer/bukkit/instanceables/{BukkitViolations.java => Violations.java} (78%) create mode 100644 src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java create mode 100644 src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java rename src/twolovers/exploitfixer/bukkit/managers/{BukkitExploitPlayerManager.java => ExploitPlayerManager.java} (57%) create mode 100644 src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java rename src/twolovers/exploitfixer/bukkit/modules/{BukkitItemsFixModule.java => ItemsFixModule.java} (57%) rename src/twolovers/exploitfixer/bukkit/modules/{BukkitMessagesModule.java => MessagesModule.java} (76%) create mode 100644 src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java create mode 100644 src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java delete mode 100644 src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java delete mode 100644 src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java create mode 100644 src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java rename src/twolovers/exploitfixer/bungee/instanceables/{BungeeViolations.java => Violations.java} (68%) delete mode 100644 src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java rename src/twolovers/exploitfixer/bungee/managers/{BungeeExploitPlayerManager.java => ExploitPlayerManager.java} (66%) create mode 100644 src/twolovers/exploitfixer/bungee/managers/ModuleManager.java delete mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java delete mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java delete mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java delete mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java delete mode 100644 src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java create mode 100644 src/twolovers/exploitfixer/bungee/modules/CommandsModule.java create mode 100644 src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java create mode 100644 src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java rename src/twolovers/exploitfixer/bungee/modules/{BungeeMessagesModule.java => MessagesModule.java} (69%) create mode 100644 src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java delete mode 100644 src/twolovers/exploitfixer/interfaces/instanceables/Violations.java delete mode 100644 src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java delete mode 100644 src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/Module.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java delete mode 100644 src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java create mode 100644 src/twolovers/exploitfixer/shared/interfaces/Module.java create mode 100644 src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java create mode 100644 src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java diff --git a/src/bungee.yml b/src/bungee.yml index a8f63cd..d4e36b2 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.7 +version: 1.2.8 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 1365cba..ac5387e 100644 --- a/src/config.yml +++ b/src/config.yml @@ -2,95 +2,105 @@ # Please help by donating, we require funds to continue with the development. # https://paypal.me/LinsaFTW # - -# WARNING: Only NullAddress, UUIDSpoof, CustomPayload and Commands modules work on BungeeCord. -# This is because the other modules cant do anything on BungeeCord. -# The other modules require ExploitFixer to be installed in Spigot with ProtocolLib. -# You need to install the plugin on BungeeCord and all Spigot servers. +# WARNING: Only Notifications, Connection, CustomPayload and Commands modules work on BungeeCord. # - -# Checks works with VLs, this a counter to execute different commands on -# different levels of violations to allow customization of the modules. +# This is because the other modules can't be executed on BungeeCord. +# The other modules require ExploitFixer to be installed on Spigot with HamsterAPI. (No performance impact) +# +# INSTALL THE PLUGIN ON BUNGEECORD AND ALL SPIGOT SERVERS! +# +# Most of the check use Violations (vls), this a counter to execute different +# actions on diverse levels to allow high customization of the modules. # # Shows notifications to console and players with permissions. notifications: enabled: true + # This shows extra information about packets blocked. + # Useful to identify false positives and reporting errors. + debug: false + # Placeholders: %player% %ping% %check% %vls% message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" -# Prevents a variety of exploits that occur on connection establish. +# Prevents a variety of exploits that occur on player connection. # Players wont be able to type messages/commands until the connection is secured. (You wont notice this) connection: + # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. + # UUIDSpoof only affects non-firewalled servers with BungeeCord: true. + uuidspoof: true + # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. # NullAddress only affects non-firewalled servers using IP Whitelist. nulladdress: true - # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. - # UUIDSpoof only affects non-firewalled servers with BungeeCord: true. - uuidspoof: true + # Commands to run when a player is detected. + punishments: + - "" -# Fixes items to remove invalid tags, enchants, effects, etc... +# Removes custom NBT tags from creative items to prevent harm to your server. itemsfix: enabled: true - # Maximum stack size obtainable with creative packets. (Set to 0 to allow everything) + # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) max_stack_size: 64 - # Maximum enchant level obtainable with creative packets. (Set to 0 to remove all enchants, -1 to disable) - enchant_limit: 11 + # Maximum enchant level obtainable with creative packets. (-1 to disable) + enchant_limit: 10 # Prevents the use of CustomPayload packets to exploit the server. custompayload: enabled: true - # Blocks different types of invalid packets. - invalid: - # Limits the amount of channels registered per player. - max_channels: - # Vls to add when max channels are exceed. (Set to 0 to disable) - vls: 1000 + # Amount of violations required to cancel. + cancel_vls: 40 - # Maximum amounts of channels allowed per player. - amount: 512 + # Amount of violations to reduce per second. + reduce_vls: 40 - # Never disable this and instead increase max_bytes if you have false positives. - big_data: - # Vls to add when too big packets are sent. (Set to 0 to disable) - vls: 1000 + # Limits the amount of channels a player can register. + channel: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 - # Maximum amount of bytes per packet. - max_bytes: 16000 + # Maximum amounts of channels allowed per player. + amount: 512 - # Checks CustomPayload books for invalid data. - books: - # Vls to add when too big packets are sent. (Set to 0 to disable) - vls: 1000 + # Limits the amount of bytes a custompayload packet can handle. + data: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 - # Maximum amount of bytes per page. - max_bytes: 258 + # Maximum amount of bytes per packet. + bytes: 16000 - # Amount of violations required to cancel. - cancel_vls: 400 + # Checks CustomPayload books for invalid data. + book: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 - # Amount of violations to reduce per second. - reduce_vls: 400 + # Maximum amount of bytes per page. + bytes: 300 + + # Checks if a tag of a CustomPayload packet is invalid. + tag: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 # When a valid packet is sent the following amount of vls will be applied. multipliers: - OTHER: 0.1 - SETTINGS: 0.5 - MC|BSign: 50 - MC|BEdit: 50 - MC|BOpen: 50 + OTHER: 0.01 + SETTINGS: 0.05 + MC|BSign: 10 + MC|BEdit: 10 + MC|BOpen: 10 - # Placeholders: %player% - # Commands to execute when a players reachs a violation level. + # Commands to run when a player reachs certain violation level. violations: - 400: + 50: - "notification" - 600: + 100: - "notification" - "kick" @@ -100,70 +110,79 @@ packets: enabled: true # Amount of vls required to start cancelling packets. - cancel_vls: 500 + cancel_vls: 100 # Amount of vls to reduce per second. - reduce_vls: 300 + reduce_vls: 60 - # Blocks packets when they arent meant to be sent or if they sent invalid data. - invalid: - # Cancells packets if the player sending them is offline. - offline: true + # Cancells packets if the player sending them is offline. + offline: true - # Never disable this and instead increase max_bytes if you have false positives. - # This will check if integers, floats, doubles and packets have a invalid size. - big_data: - # Vls to add when too big packets are sent. (Set to -1 to disable) - vls: 1000 + # Never disable this and instead increase max_bytes if you have false positives. + # This will check if integers, floats, doubles and packets have a invalid size. + data: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 600 - # Maximum amount of bytes allowed per packet. (Increase to 80000 to allow Shulker Box) - max_bytes: 20000 + # Maximum amount of bytes allowed per packet. (Set to -1 to disable) + bytes: 16000 - # Maximum amount of bytes allowed per book page. - max_bytes_book: 268 + # Maximum amount of bytes allowed per book page. (Set to -1 to disable) + bytes_book: 300 - # Maximum amount of bytes allowed per sign line. - max_bytes_sign: 47 + # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) + bytes_sign: 47 - # Checks if players send WINDOW_CLICK packets with another item in cursor. (Set to -1 to disable) - window_click: 1000 + # Packets will add their amount of bytes divided by this number to vl count. + # This is made so big packets add more vls when received. + bytes_divider: 1000 - # Checks if players send BLOCK_PLACE packets with another item in hand. (Set to -1 to disable) - block_place: 1000 + # Checks if players send PacketPlayInWindowClick packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + window_click: 300 - # Checks if players send BLOCK_DIG packets with another item in hand. (Set to -1 to disable) - block_dig: 1000 + # Checks if players send PacketPlayInBlockPlace packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_place: 300 - # Checks if players send SET_CREATIVE_SLOT packets without creative. (Set to -1 to disable) - set_creative_slot: 1000 + # Checks if players send PacketPlayInBlockDig packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_dig: 600 - # When a valid packet is sent the following amount of vls will be applied to the player. - # This is made to prevent packet spamming. + # Checks if players send PacketPlayInCreativeSlot packets without creative. + # Vls to add when a packet fails the check. (Set to -1 to disable) + set_creative_slot: 600 + + # Vls to add when a normal packet is sent by a player. + # This option is made to work as a packet limiter feature. + # Unlisted packets are considered as "PacketPlayInOther" by default. + # Remember to take a look at bytes_divider option. multipliers: - ABILITIES: 1 - ARM_ANIMATION: 3 - BLOCK_DIG: 3 - BLOCK_PLACE: 4.25 - CUSTOM_PAYLOAD: 0.1 - ENTITY_ACTION: 4 - FLYING: 0.5 - LOOK: 0.75 - POSITION_LOOK: 0.75 - POSITION: 3.5 - SET_CREATIVE_SLOT: 0.5 - SETTINGS: 0.5 - TAB_COMPLETE: 2 - UPDATE_SIGN: 90 - USE_ENTITY: 4 - USE_ITEM: 4 - WINDOW_CLICK: 5 + PacketPlayInOther: 0.1 + PacketPlayInAbilities: 0.1 + PacketPlayInArmAnimation: 0.3 + PacketPlayInBlockDig: 0.3 + PacketPlayInBlockPlace: 0.4 + PacketPlayInCustomPayload: 0.01 + PacketPlayInEntityAction: 0.4 + PacketPlayInFlying: 0.05 + PacketPlayInLook: 0.1 + PacketPlayInPositionLook: 0.1 + PacketPlayInPosition: 0.35 + PacketPlayInSetCreativeSlot: 0.1 + PacketPlayInSettings: 0.5 + PacketPlayInTabComplete: 0.2 + PacketPlayInUpdateSign: 10 + PacketPlayInUseEntity: 0.4 + PacketPlayInUseItem: 0.4 + PacketPlayInWindowClick: 0.5 # Placeholders: %player% - # Commands to execute when a players reachs a violation level. + # Commands to run when a player reachs certain violation level. violations: - 500: + 350: - "notification" - 1000: + 600: - "notification" - "kick" @@ -171,13 +190,7 @@ packets: commands: enabled: true - # Amount of violations required to cancel. - cancel_vls: 1 - - # Amount of violations to reduce per second. - reduce_vls: 0 - - # Commands to detect. + # Commands that are excempt from this server. commands: - "//calc" - "//calculate" @@ -196,7 +209,6 @@ commands: - "/execute" # Placeholders: %player% - violations: - 1: - - "notification" - - "kick" + punishments: + - "notification" + - "kick" diff --git a/src/messages.yml b/src/messages.yml index 977d871..97eb460 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -167,3 +167,35 @@ fr: message: |- &fJoueurs caché: &a%players_cached% &fJoueurs sanctionné: &a%players_punished% + +tr: + commands: + reload: "&aPlugin ExploitFixer yeniden yüklendi!" + help: |- + &aExploitFixer &b%version% &a &bLinsaFTW &a. + &e /%command% help &7> &bMevcut komutları gösterir. + &e /%command% reload &7> &bEklentiyi yükler. + &e /%command% notifications &7> &bEklentinin bildirimlerini deÄŸiÅŸtirir. + &e /%command% stats &7> &bEklentinin istatistiklerini izleyin. + error: + unknown: "&cBilinmeyen komut. Kullanılabilir komutları görmek için / exploitfixer yardımını kullanın!" + permission: "&cBu komutu kullanma izniniz yok!" + console: "&cBu komut konsoldan yürütülemez!" + notifications: + enable: "&aBildirimleri etkinleÅŸtirdiniz!" + disable: "&cBildirimleri devre dışı bıraktınız!" + modules: + custompayload: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + uuidspoof: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + commands: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + packets: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + nulladdress: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + stats: + message: |- + &fPlayers önbelleÄŸe alındı: &a%players_cached% + &fPlayers cezalandırıldı: &a%players_punished% \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 2a280b8..5376cb6 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,11 +1,10 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.2.7 +version: 1.3.0 author: 2LS api: "1.13" api-version: "1.13" -load: STARTUP -depend: [ProtocolLib] +soft-depend: [HamsterAPI] commands: exploitfixer: description: The main ExploitFixer command diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index ab172ff..14f37b1 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -2,24 +2,20 @@ import org.bukkit.Server; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; -import twolovers.exploitfixer.bukkit.adapters.initializers.AdapterInitializer; import twolovers.exploitfixer.bukkit.commands.ExploitFixerCommand; import twolovers.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; -import twolovers.exploitfixer.bukkit.managers.BukkitModuleManager; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; import twolovers.exploitfixer.bukkit.utils.ConfigurationUtil; import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; - -import java.util.logging.Level; public class ExploitFixer extends JavaPlugin { private static ExploitFixer exploitFixer; private ModuleManager moduleManager; + private ListenerInitializer listenerInitializer; @Override public void onEnable() { @@ -34,12 +30,13 @@ public void onEnable() { final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); exploitFixer = this; - moduleManager = new BukkitModuleManager(this, configYml, messagesYml); + this.moduleManager = new ModuleManager(this, configYml, messagesYml); + this.listenerInitializer = new ListenerInitializer(this, moduleManager); + server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); VersionUtil.init(); reload(); - scheduler.cancelTasks(this); scheduler.runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -47,30 +44,31 @@ public void onEnable() { }, 9000L, 9000L); } + @Override + public void onDisable() { + final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); + + scheduler.cancelTasks(this); + this.listenerInitializer.stop(); + } + public void reload() { - final Server server = getServer(); - final PluginManager pluginManager = server.getPluginManager(); - final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); + if (isEnabled()) { + final Server server = getServer(); + final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - server.getMessenger().unregisterIncomingPluginChannel(this); - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); + server.getMessenger().unregisterIncomingPluginChannel(this); + configurationUtil.createConfiguration("%datafolder%/config.yml"); + configurationUtil.createConfiguration("%datafolder%/messages.yml"); - final YamlConfiguration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); - final YamlConfiguration spigotYml = configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); + final YamlConfiguration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); + final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final YamlConfiguration spigotYml = configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); - moduleManager.reload(configYml, messagesYml, spigotYml); + moduleManager.reload(configYml, messagesYml, spigotYml); - if (isEnabled()) { - if (pluginManager.isPluginEnabled("ProtocolLib")) { - new AdapterInitializer(this, moduleManager); - } else { - getLogger().log(Level.SEVERE, - "[ExploitFixer] This plugin requires ProtocolLib to protect agaisnt exploits!"); - } - - new ListenerInitializer(this, moduleManager); + this.listenerInitializer.start(); getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); } diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java deleted file mode 100644 index a297e72..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockDigPacketAdapter.java +++ /dev/null @@ -1,77 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import java.util.UUID; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.plugin.Plugin; - -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class BlockDigPacketAdapter extends PacketAdapter { - private final ModuleManager moduleManager; - - public BlockDigPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, - final PacketType packetType, final ModuleManager moduleManager) { - super(plugin, listenerPriority, packetType); - this.moduleManager = moduleManager; - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - final PacketsModule packetsModule = moduleManager.getPacketsModule(); - final double blockDig = packetsModule.getBlockDig(); - - if (blockDig > 0) { - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - try { - final UUID uuid = player.getUniqueId(); - final StructureModifier itemModifier = event.getPacket().getItemModifier(); - - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.read(0); - - if (itemUse != null) { - final PlayerInventory playerInventory = player.getInventory(); - ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (itemOnHand == null) - itemOnHand = new ItemStack(Material.AIR); - - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() - && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() - .get(uuid, player); - - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, blockDig); - else - event.setCancelled(true); - } - } - } - } catch (final UnsupportedOperationException ignored) { - event.setCancelled(true); - } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - } - - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.check(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java deleted file mode 100644 index 6348f96..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/BlockPlacePacketAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -import java.util.UUID; - -public class BlockPlacePacketAdapter extends PacketAdapter { - private final ModuleManager moduleManager; - - public BlockPlacePacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, - final PacketType packetType, final ModuleManager moduleManager) { - super(plugin, listenerPriority, packetType); - this.moduleManager = moduleManager; - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - final PacketsModule packetsModule = moduleManager.getPacketsModule(); - final double blockPlace = packetsModule.getBlockPlace(); - - if (blockPlace > 0) { - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - try { - final UUID uuid = player.getUniqueId(); - final StructureModifier itemModifier = event.getPacket().getItemModifier(); - - if (itemModifier != null && itemModifier.size() > 0) { - final ItemStack itemUse = itemModifier.readSafely(0); - - if (itemUse != null) { - final PlayerInventory playerInventory = player.getInventory(); - ItemStack itemOnHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (itemOnHand == null) - itemOnHand = new ItemStack(Material.AIR); - - if ((!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta() - && itemUse.getItemMeta().toString().length() > 512)) { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() - .get(uuid, player); - - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, blockPlace); - else - event.setCancelled(true); - } - } - } - } catch (final UnsupportedOperationException ignored) { - event.setCancelled(true); - } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - } - - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.check(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java deleted file mode 100644 index f013d37..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/SetCreativeSlotPacketAdapter.java +++ /dev/null @@ -1,67 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; - -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; - -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class SetCreativeSlotPacketAdapter extends PacketAdapter { - private final ModuleManager moduleManager; - - public SetCreativeSlotPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, - final PacketType packetType, final ModuleManager moduleManager) { - super(plugin, listenerPriority, packetType); - this.moduleManager = moduleManager; - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - final PacketsModule packetsModule = moduleManager.getPacketsModule(); - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - final ItemsFixModule itemsFixModule = moduleManager.getItemsFixModule(); - final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - - if (setCreativeSlot > 0 && player.getGameMode() != GameMode.CREATIVE) { - try { - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() - .get(player.getUniqueId(), player); - - if (exploitPlayer != null) - exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); - else - event.setCancelled(true); - } catch (final UnsupportedOperationException ignored) { - event.setCancelled(true); - } - } else if (itemsFixModule.isEnabled()) { - final PacketContainer packet = event.getPacket(); - final StructureModifier itemModifier = packet.getItemModifier(); - final ItemStack itemStack = itemModifier.readSafely(0); - - if (itemStack != null) { - itemModifier.write(0, itemsFixModule.fixItemStack(itemStack)); - } - } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.check(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java b/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java deleted file mode 100644 index 40d5ad4..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/WindowClickPacketAdapter.java +++ /dev/null @@ -1,106 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import org.bukkit.entity.Player; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -import java.nio.charset.StandardCharsets; -import java.util.UUID; - -public class WindowClickPacketAdapter extends PacketAdapter { - private final PacketsModule packetsModule; - private final ExploitPlayerManager exploitPlayerManager; - - public WindowClickPacketAdapter(final Plugin plugin, final ListenerPriority listenerPriority, - final PacketType packetType, final ModuleManager moduleManager) { - super(plugin, listenerPriority, packetType); - this.packetsModule = moduleManager.getPacketsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - if (!event.isCancelled()) { - final double windowClick = packetsModule.getWindowClick(); - - if (windowClick > 0) { - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - try { - final UUID uuid = player.getUniqueId(); - final PacketContainer packet = event.getPacket(); - final StructureModifier integers = packet.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - - if (inventoryView == null) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick / 10); - } else if (integers.size() > 1) { - final int slot = inventoryView.convertSlot(integers.readSafely(1)); - final int maxSlots = inventoryView.countSlots(); - - if (slot >= maxSlots) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - } else { - final StructureModifier structureModifier = packet.getItemModifier(); - - if (structureModifier.size() > 0 && slot > 0) { - final ItemStack itemUse = structureModifier.readSafely(0); - - if (itemUse != null) { - final ItemStack itemOnHand = inventoryView.getItem(slot); - - if (!itemUse.isSimilar(itemOnHand) && itemUse.hasItemMeta()) { - final ItemMeta itemMeta = itemUse.getItemMeta(); - int dataBytes = 0; - - try { - dataBytes += itemMeta.toString() - .getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - dataBytes += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())) - .getBytes(StandardCharsets.UTF_8).length; - } - - if (dataBytes > 512) { - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, - player); - - // Divide by 12 because of false positives. - exploitPlayer.addVls(plugin, event, player, packetsModule, - windowClick / 12); - } - } - } - } - } - } - } catch (final UnsupportedOperationException ignored) { - event.setCancelled(true); - } - } else if (packetsModule.isOffline()) - event.setCancelled(true); - } - - if (!event.isCancelled() && packetsModule.isEnabled()) - packetsModule.check(event); - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java b/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java deleted file mode 100644 index 6076509..0000000 --- a/src/twolovers/exploitfixer/bukkit/adapters/initializers/AdapterInitializer.java +++ /dev/null @@ -1,64 +0,0 @@ -package twolovers.exploitfixer.bukkit.adapters.initializers; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.adapters.BlockDigPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.BlockPlacePacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.SetCreativeSlotPacketAdapter; -import twolovers.exploitfixer.bukkit.adapters.WindowClickPacketAdapter; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -public class AdapterInitializer { - public AdapterInitializer(final Plugin plugin, final ModuleManager moduleManager) { - final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); - final PacketsModule packetsModule = moduleManager.getPacketsModule(); - final CustomPayloadModule customPayloadModule = moduleManager.getCustomPayloadModule(); - - protocolManager.removePacketListeners(plugin); - - for (final PacketType packetType : PacketType.Play.Client.getInstance()) { - if (packetType.isSupported() && packetType != PacketType.Play.Client.BLOCK_DIG - && packetType != PacketType.Play.Client.BLOCK_PLACE - && packetType != PacketType.Play.Client.SET_CREATIVE_SLOT - && packetType != PacketType.Play.Client.WINDOW_CLICK - && packetType != PacketType.Play.Client.KEEP_ALIVE) { - if (packetType == PacketType.Play.Client.CUSTOM_PAYLOAD) { - if (customPayloadModule.isEnabled()) { - protocolManager - .addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - customPayloadModule.check(event); - } - }); - } - } else if (packetsModule.isEnabled()) { - protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.LOWEST, packetType) { - @Override - public void onPacketReceiving(final PacketEvent event) { - packetsModule.check(event); - } - }); - } - } - } - - if (packetsModule.isEnabled()) { - protocolManager.addPacketListener(new BlockDigPacketAdapter(plugin, ListenerPriority.LOWEST, - PacketType.Play.Client.BLOCK_DIG, moduleManager)); - protocolManager.addPacketListener(new BlockPlacePacketAdapter(plugin, ListenerPriority.LOWEST, - PacketType.Play.Client.BLOCK_PLACE, moduleManager)); - protocolManager.addPacketListener(new SetCreativeSlotPacketAdapter(plugin, ListenerPriority.LOWEST, - PacketType.Play.Client.SET_CREATIVE_SLOT, moduleManager)); - protocolManager.addPacketListener(new WindowClickPacketAdapter(plugin, ListenerPriority.LOWEST, - PacketType.Play.Client.WINDOW_CLICK, moduleManager)); - } - } -} diff --git a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java index d269348..27d435d 100644 --- a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -6,10 +6,10 @@ import org.bukkit.entity.Player; import twolovers.exploitfixer.bukkit.ExploitFixer; import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.MessagesModule; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; public class ExploitFixerCommand implements CommandExecutor { private MessagesModule messagesModule; @@ -23,7 +23,8 @@ public ExploitFixerCommand(final ModuleManager moduleManager) { } @Override - public boolean onCommand(final CommandSender commandSender, final Command command, final String label, final String[] args) { + public boolean onCommand(final CommandSender commandSender, final Command command, final String label, + final String[] args) { final int length = args.length; String lang = "en"; @@ -57,7 +58,8 @@ else if (args[0].equals("stats")) commandSender.sendMessage(messagesModule.getPermission(lang)); else if (args[0].equalsIgnoreCase("notifications")) { if (commandSender instanceof Player) { - if (commandSender.hasPermission("exploitfixer.admin") || commandSender.hasPermission("exploitfixer.notifications")) { + if (commandSender.hasPermission("exploitfixer.admin") + || commandSender.hasPermission("exploitfixer.notifications")) { final Player player = (Player) commandSender; if (!notificationsModule.isNotifications(player)) { diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java deleted file mode 100644 index 4c499a9..0000000 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitExploitPlayer.java +++ /dev/null @@ -1,209 +0,0 @@ -package twolovers.exploitfixer.bukkit.instanceables; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import com.comphenix.protocol.events.PacketEvent; - -import org.bukkit.Server; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.plugin.Plugin; - -import twolovers.exploitfixer.bukkit.nms.CraftPlayerReflector; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CancellableModule; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; - -public class BukkitExploitPlayer implements ExploitPlayer { - final private ExploitPlayerManager exploitPlayerManager; - final private MessagesModule messagesModule; - final private NotificationsModule notificationsModule; - final private Map violations = new HashMap<>(); - final private String name; - private String onlineUUID = null; - private boolean logged = false; - private int channels = 0; - private double lastViolation = 0; - - public BukkitExploitPlayer(final String name, final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.messagesModule = moduleManager.getMessagesModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.name = name; - } - - public int getChannels() { - return channels; - } - - public void clearChannels() { - this.channels = 0; - } - - @Override - public int addChannels(final int channels) { - return this.channels += channels; - } - - @Override - public double getViolations(final Module module) { - if (module instanceof CancellableModule) - return violations.getOrDefault(module, 0D); - else - return 0D; - } - - @Override - public String getOnlineUUID() { - if (onlineUUID == null) { - try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) - .openConnection(); - - connection.setDoOutput(true); - connection.connect(); - - final BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(connection.getInputStream())); - final StringBuilder response = new StringBuilder(); - - String inputLine; - - while ((inputLine = bufferedReader.readLine()) != null) - response.append(inputLine).append("\n"); - - bufferedReader.close(); - onlineUUID = response.toString(); - } catch (final Exception ignored) { - } - } - - return onlineUUID; - } - - @Override - public void addVls(final Object pluginObject, final Object event, final Object playerObject, - final CancellableModule module, final double amount) { - if (playerObject instanceof Player) { - final Player player = (Player) playerObject; - - if (player.isOnline()) { - final Violations violations = module.getViolations(); - - if (violations != null) { - final Plugin plugin = (Plugin) pluginObject; - final Server server = plugin.getServer(); - final double currentTime = System.currentTimeMillis(); - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - - for (final CancellableModule cancellableModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(cancellableModule) - - cancellableModule.getReduceVls(); - - if (vls <= 0) - this.violations.remove(cancellableModule); - else - this.violations.put(cancellableModule, vls); - } - } - - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; - - this.violations.put(module, newVls); - - if (event instanceof Cancellable && module.getCancelVls() <= newVls) { - ((Cancellable) event).setCancelled(true); - } - - for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); - - if (commands != null && !commands.isEmpty()) { - for (final String punishCommand : commands) - if (!punishCommand.isEmpty()) - if (punishCommand.equals("kick")) { - final CraftPlayerReflector craftPlayer = new CraftPlayerReflector(player); - final String locale; - - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); - - final String kickMessage = messagesModule.getKickMessage(module, locale); - - // This is made to sync the current thread with main thread so it doesnt - // crash. - if (!server.isPrimaryThread()) { - final Thread currentThread = Thread.currentThread(); - - server.getScheduler().runTask(plugin, () -> { - craftPlayer.disconnect(kickMessage); - currentThread.interrupt(); - }); - - try { - Thread.sleep(500L); - } catch (final InterruptedException e) { - } - } else { - craftPlayer.disconnect(kickMessage); - } - - craftPlayer.closeChannel(); - - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) { - if (event instanceof PacketEvent) - notificationsModule.sendNotification( - ((PacketEvent) event).getPacketType().name(), player, - (int) newVls); - else - notificationsModule.sendNotification(module.getName(), player, - (int) newVls); - } else - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishCommand.replace("%player%", player.getName())); - }); - } - } - } - } - } - } else if (event instanceof Cancellable) { - ((Cancellable) event).setCancelled(true); - } - } - - public void clearViolations() { - violations.clear(); - } - - @Override - public void setLogged(final boolean logged) { - this.logged = logged; - } - - @Override - public boolean isLogged() { - return logged; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java new file mode 100644 index 0000000..9234e6b --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -0,0 +1,185 @@ +package twolovers.exploitfixer.bukkit.instanceables; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import org.bukkit.Server; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.plugin.Plugin; + +import hamsterapi.adapters.HamsterPlayer; +import hamsterapi.wrappers.EventWrapper; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.MessagesModule; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; +import twolovers.exploitfixer.shared.interfaces.ViolationModule; + +public class ExploitPlayer { + private final ExploitPlayerManager exploitPlayerManager; + private final MessagesModule messagesModule; + private final NotificationsModule notificationsModule; + private final Map violations = new HashMap<>(); + private final String name; + private String onlineUUID = null; + private double lastViolation = 0; + private long teleportTimeMillis = System.currentTimeMillis(); + private int channels = 0; + private boolean logged = false; + + public ExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.messagesModule = moduleManager.getMessagesModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.name = name; + } + + public int getChannels() { + return channels; + } + + public void clearChannels() { + this.channels = 0; + } + + public int addChannels(final int channels) { + return this.channels += channels; + } + + public double getViolations(final ViolationModule module) { + return violations.getOrDefault(module, 0D); + } + + public String getOnlineUUID() { + if (onlineUUID == null) { + try { + final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) + .openConnection(); + + connection.setDoOutput(true); + connection.connect(); + + final BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(connection.getInputStream())); + final StringBuilder response = new StringBuilder(); + + String inputLine; + + while ((inputLine = bufferedReader.readLine()) != null) + response.append(inputLine).append("\n"); + + bufferedReader.close(); + onlineUUID = response.toString(); + } catch (final Exception ignored) { + } + } + + return onlineUUID; + } + + public void addVls(final Plugin plugin, final Object event, final Player player, final ViolationModule module, + final double amount) { + if (player.isOnline()) { + final Violations violations = (Violations) module.getViolations(); + + if (violations != null) { + final Server server = plugin.getServer(); + final double currentTime = System.currentTimeMillis(); + + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; + + for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { + final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); + + if (vls <= 0) + this.violations.remove(violationModule); + else + this.violations.put(violationModule, vls); + } + } + + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; + + this.violations.put(module, newVls); + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) { + ((Cancellable) event).setCancelled(true); + } + + for (final int threshold : violations.getViolations()) { + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); + + if (commands != null && !commands.isEmpty()) { + for (final String punishCommand : commands) { + if (!punishCommand.isEmpty()) { + if (punishCommand.equals("kick")) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); + + final String kickMessage = messagesModule.getKickMessage(module, locale); + final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + + hamsterPlayer.kickPlayer(kickMessage); + hamsterPlayer.abort(); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) { + if (event instanceof EventWrapper) { + notificationsModule.sendNotification( + ((EventWrapper) event).getPacket().getType().toString(), player, + (int) newVls); + } else { + notificationsModule.sendNotification(module.getName(), player, + (int) newVls); + } + } else { + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishCommand.replace("%player%", player.getName())); + }); + } + } + } + } + } + } + } + } else if (event instanceof Cancellable) { + ((Cancellable) event).setCancelled(true); + } + } + + public void clearViolations() { + violations.clear(); + } + + public void setLogged(final boolean logged) { + this.logged = logged; + } + + public boolean isLogged() { + return logged; + } + + public void updateTeleportTimeMillis() { + this.teleportTimeMillis = System.currentTimeMillis(); + } + + public long getTeleportTimeMillis() { + return this.teleportTimeMillis; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java b/src/twolovers/exploitfixer/bukkit/instanceables/Violations.java similarity index 78% rename from src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java rename to src/twolovers/exploitfixer/bukkit/instanceables/Violations.java index df041b9..97cf2cf 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/BukkitViolations.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/Violations.java @@ -1,16 +1,15 @@ package twolovers.exploitfixer.bukkit.instanceables; import org.bukkit.configuration.ConfigurationSection; -import twolovers.exploitfixer.interfaces.instanceables.Violations; import java.util.Collection; import java.util.HashMap; import java.util.Map; -public class BukkitViolations implements Violations { +public class Violations { private Map> violations = new HashMap<>(); - public BukkitViolations(final ConfigurationSection configuration) { + public Violations(final ConfigurationSection configuration) { if (configuration != null) for (final String key : configuration.getKeys(false)) { try { @@ -24,7 +23,6 @@ public Collection getCommands(final int violations) { return this.violations.getOrDefault(violations, null); } - @Override public Collection getViolations() { return violations.keySet(); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java new file mode 100644 index 0000000..0b51fc1 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java @@ -0,0 +1,339 @@ +package twolovers.exploitfixer.bukkit.listeners; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Map; +import java.util.logging.Logger; + +import org.bukkit.GameMode; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import hamsterapi.enums.PacketType; +import hamsterapi.interfaces.DecodeListener; +import hamsterapi.wrappers.EventWrapper; +import hamsterapi.wrappers.PacketWrapper; +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.CustomPayloadModule; +import twolovers.exploitfixer.bukkit.modules.ItemsFixModule; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.modules.PacketsModule; + +public class ExploitFixerDecodeListener implements DecodeListener { + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + private final ItemsFixModule itemsFixModule; + + public ExploitFixerDecodeListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + this.itemsFixModule = moduleManager.getItemsFixModule(); + } + + @Override + public void onPacketDecode(final EventWrapper event) { + if (!event.isCancelled()) { + final PacketWrapper packetWrapper = event.getPacket(); + final PacketType packetType = packetWrapper.getType(); + final Player player = event.getPlayer(); + + if (packetType != PacketType.PacketPlayInKeepAlive) { + final Logger logger = plugin.getLogger(); + + if (player != null && player.isOnline()) { + final String playerName = player.getName(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (exploitPlayer != null) { + final Map strings = packetWrapper.getStrings(); + final String packetName = packetWrapper.getName(); + + if (packetsModule.isEnabled()) { + final Map integers = packetWrapper.getIntegers(); + final Map items = packetWrapper.getItems(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(), + setCreativeSlot = packetsModule.getSetCreativeSlot(), + dataVls = packetsModule.getDataVls(); + final int dataBytes = packetsModule.getDataBytes(), + dataBytesSigns = packetsModule.getDataBytesSign(); + + if (integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(), + bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " has a slot less than 0 (" + slot + ")"); + } + + event.setCancelled(true); + return; + } else if (slot >= maxSlots) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " exceeded max available slots (" + slot + "/" + + maxSlots + ") on " + packetName + "! Added vls: " + windowClick); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { + if (player.getGameMode() != GameMode.CREATIVE) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + + setCreativeSlot); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); + return; + } else if (items.containsKey("b")) { + final ItemStack itemStack = itemsFixModule.fixItem(items.get("b")); + + packetWrapper.write("b", itemStack); + + if (notificationsModule.isDebug()) { + logger.info(playerName + " had a creative item fixed by ExploiFixer!"); + } + } + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += checkItem((ItemStack) object, exploitPlayer, player); + } else { + packetSize += String.valueOf(object) + .getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "] Sent by " + playerName + + " got cancelled because its " + packetSize + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && checkSign(strings.values().toArray(new String[0]))) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " has sent a too big sign packet! Added vls: " + + dataVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, player, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { + final String tag = strings.get("a"); + final double tagVls = customPayloadModule.getTagVls(), + bookVls = customPayloadModule.getBookVls(); + + if (tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + return; + } else { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory + .getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " tried to send a " + tag + + " custompayload packet without a book in hand!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, bookVls); + return; + } /* + * else if (byteLength > customPayloadModule.getBookBytes()) { + * logger.info(playerName + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } + } else { + event.setCancelled(true); + event.abort(); + } + } else { + event.setCancelled(true); + event.abort(); + } + } + } + } + + private int checkItem(final ItemStack itemStack, final ExploitPlayer exploitPlayer, final Player player) { + final Logger logger = plugin.getLogger(); + int itemBytesLength = 0; + + if (itemStack != null) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + + try { + itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final Exception exception) { + if (notificationsModule.isDebug()) { + logger.info("There was an exception when processing itemStack data to String!"); + } + } + + if (itemStack.hasItemMeta() && itemMeta != null) { + try { + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { + itemBytesLength += checkItem(itemStack1, exploitPlayer, player); + } + } + } + } else { + throw new Exception(); + } + } catch (final Exception exception) { + if (itemMeta instanceof BookMeta) { + itemBytesLength += checkBook(exploitPlayer, player, itemMeta); + } else { + try { + itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + itemBytesLength += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + } + } + } + } + + return itemBytesLength; + } + + private int checkBook(final ExploitPlayer exploitPlayer, final Player player, final ItemMeta itemMeta) { + final Logger logger = plugin.getLogger(); + final BookMeta bookMeta = (BookMeta) itemMeta; + final double dataVls = packetsModule.getDataVls(); + final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); + int bookTotalBytes = 0; + + if (pageCount > 50) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" + + 50 + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); + } else { + for (final String page : bookMeta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + bookTotalBytes += pageBytes; + + if (pageBytes > dataBytesBook) { + if (notificationsModule.isDebug()) { + logger.info( + player.getName() + " has sent a packet with a book with too many characters per page! (" + + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); + break; + } + } + + return bookTotalBytes; + } + + return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } + + private boolean checkSign(final String[] linesString) { + final int dataBytesSign = packetsModule.getDataBytesSign(); + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else { + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { + return true; + } + } + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 642829f..357b2fe 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -1,15 +1,17 @@ package twolovers.exploitfixer.bukkit.listeners; +import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CommandsModule; + +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.CommandsModule; public class PlayerCommandListener implements Listener { private final Plugin plugin; @@ -30,13 +32,20 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { + final Server server = plugin.getServer(); final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String playerName = player.getName(); - for (final String command : commandsModule.getCommands()) + for (final String command : commandsModule.getCommands()) { if (message.startsWith(command + " ") || message.endsWith(command)) { - exploitPlayer.addVls(plugin, commandsModule, player, commandsModule, 1); + for (final String punishment : commandsModule.getPunishments()) { + server.dispatchCommand(server.getConsoleSender(), punishment.replace("%player%", playerName)); + } + + event.setCancelled(true); break; } + } } } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java index e9cd2ba..70816ba 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -7,13 +7,15 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; + +import hamsterapi.adapters.HamsterPlayer; import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.ConnectionModule; +import twolovers.exploitfixer.bukkit.modules.MessagesModule; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; import java.net.InetAddress; import java.util.UUID; @@ -22,15 +24,14 @@ public class PlayerLoginListener implements Listener { private final Plugin plugin; private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; - private final Module uuidSpoofModule, nullAddressModule; + private final ConnectionModule connectionModule; private final ExploitPlayerManager exploitPlayerManager; public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); + this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); - this.nullAddressModule = moduleManager.getNullAddressModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @@ -40,24 +41,25 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final InetAddress address = event.getAddress(); final String locale; - if (VersionUtil.isOneDotFifteen()) + if (VersionUtil.isOneDotFifteen()) { locale = player.getLocale().substring(0, 2); - else + } else { locale = player.spigot().getLocale().substring(0, 2); + } - if (nullAddressModule.isEnabled() && address == null) { - final String nullAddressKickMessage = messagesModule.getKickMessage(nullAddressModule, locale); + if (connectionModule.isNullAddressEnabled() && address == null) { + final String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - player.kickPlayer(nullAddressKickMessage); + new HamsterPlayer(player).kickPlayer(nullAddressKickMessage); } else { final UUID uuid = player.getUniqueId(); + final String playerName = player.getName(); final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - if (uuidSpoofModule.isEnabled()) { + if (connectionModule.isUUIDSpoofEnabled()) { final BukkitScheduler scheduler = plugin.getServer().getScheduler(); - final String playerName = player.getName(); scheduler.runTaskAsynchronously(plugin, () -> { final String originalUUID = uuid.toString().replace("-", ""); @@ -68,16 +70,21 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage(uuidSpoofModule, locale); + final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - scheduler.runTaskLater(plugin, () -> player.kickPlayer(uuidSpoofKickMessage), 1L); + event.setKickMessage(uuidSpoofKickMessage); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + new HamsterPlayer(player).kickPlayer(uuidSpoofKickMessage); } } exploitPlayer.setLogged(true); + exploitPlayer.updateTeleportTimeMillis(); }); - } else + } else { exploitPlayer.setLogged(true); + exploitPlayer.updateTeleportTimeMillis(); + } } if (player.hasPermission("exploitfixer.notifications")) { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java index 3e97fb7..30c787e 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -4,10 +4,10 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java deleted file mode 100644 index 45d608e..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTabCompleteListener.java +++ /dev/null @@ -1,38 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.server.TabCompleteEvent; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CommandsModule; - -public class PlayerTabCompleteListener implements Listener { - private final Plugin plugin; - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; - - public PlayerTabCompleteListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.commandsModule = moduleManager.getCommandsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final TabCompleteEvent event) { - if (commandsModule.isEnabled() && event.getSender() instanceof Player) { - final String message = event.getBuffer().replaceAll("[\\w]+:", "").toLowerCase(); - - for (final String command : commandsModule.getCommands()) - if (message.startsWith(command + " ") || message.endsWith(command)) { - final Player player = (Player) event.getSender(); - - exploitPlayerManager.get(player.getUniqueId(), player).addVls(plugin, commandsModule, player, commandsModule, 1); - break; - } - } - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java new file mode 100644 index 0000000..b547a54 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java @@ -0,0 +1,35 @@ +package twolovers.exploitfixer.bukkit.listeners; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; + +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; + +public class PlayerTeleportListener implements Listener { + private final ExploitPlayerManager exploitPlayerManager; + + public PlayerTeleportListener(final ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerTeleport(final PlayerTeleportEvent event) { + final Location from = event.getFrom(); + final Location to = event.getTo(); + + if (from.getWorld() != to.getWorld()) { + final Player player = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (exploitPlayer != null) { + exploitPlayer.updateTeleportTimeMillis(); + } + } + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 5cfa684..1d46f6d 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -1,23 +1,57 @@ package twolovers.exploitfixer.bukkit.listeners.initializers; +import java.util.logging.Logger; + +import org.bukkit.Server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import hamsterapi.HamsterAPI; +import hamsterapi.handlers.DecodeEventHandler; +import twolovers.exploitfixer.bukkit.listeners.ExploitFixerDecodeListener; import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; import twolovers.exploitfixer.bukkit.listeners.PlayerQuitListener; -import twolovers.exploitfixer.bukkit.listeners.PlayerTabCompleteListener; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.bukkit.listeners.PlayerTeleportListener; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; public class ListenerInitializer { + private final Plugin plugin; + private final ModuleManager moduleManager; + private final ExploitFixerDecodeListener exploitFixerDecodeListener; + public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { - final PluginManager pluginManager = plugin.getServer().getPluginManager(); + this.plugin = plugin; + this.moduleManager = moduleManager; + this.exploitFixerDecodeListener = new ExploitFixerDecodeListener(plugin, moduleManager); + } + + public void start() { + final Logger logger = this.plugin.getLogger(); + final Server server = this.plugin.getServer(); + final PluginManager pluginManager = server.getPluginManager(); + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + + if (pluginManager.isPluginEnabled("HamsterAPI")) { + decodeEventHandler.addListener(exploitFixerDecodeListener); + logger.info("Successfully hooked with HamsterAPI!"); + } else { + for (int i = 0; i < 10; i++) { + logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); + } + } - HandlerList.unregisterAll(plugin); pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); - pluginManager.registerEvents(new PlayerTabCompleteListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); + } + + public void stop() { + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + + decodeEventHandler.removeListener(exploitFixerDecodeListener); + HandlerList.unregisterAll(plugin); } } diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java deleted file mode 100644 index c24af39..0000000 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitModuleManager.java +++ /dev/null @@ -1,104 +0,0 @@ -package twolovers.exploitfixer.bukkit.managers; - -import org.bukkit.Server; -import org.bukkit.configuration.Configuration; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.modules.*; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.*; - -import java.util.logging.Level; - -public class BukkitModuleManager implements ModuleManager { - private Plugin plugin; - private CommandsModule commandsModule; - private CustomPayloadModule customPayloadModule; - private ItemsFixModule itemsFixModule; - private MessagesModule messagesModule; - private NotificationsModule notificationsModule; - private PacketsModule packetsModule; - private ExploitPlayerManager exploitPlayerManager; - private ReloadableModule uuidSpoofModule, nullAddressModule; - - public BukkitModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { - this.plugin = plugin; - this.commandsModule = new BukkitCommandsModule(configYml); - this.customPayloadModule = new BukkitCustomPayloadModule(plugin, this, configYml); - this.itemsFixModule = new BukkitItemsFixModule(plugin, configYml); - this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new BukkitNotificationsModule(configYml); - this.uuidSpoofModule = new BukkitUUIDSpoofModule(configYml); - this.packetsModule = new BukkitPacketsModule(plugin, this, configYml); - this.exploitPlayerManager = new BukkitExploitPlayerManager(plugin.getServer(), this); - this.nullAddressModule = new BukkitNullAddressModule(configYml); - } - - @Override - public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { - try { - this.commandsModule.reload(configYml); - this.customPayloadModule.reload(configYml); - this.itemsFixModule.reload(configYml); - this.messagesModule.reload(messagesYml); - this.notificationsModule.reload(configYml); - this.uuidSpoofModule.reload(configYml); - this.packetsModule.reload(configYml); - this.exploitPlayerManager.reload(); - this.nullAddressModule.reload(configYml); - } catch (final NullPointerException e) { - final Server server = plugin.getServer(); - - server.getLogger().log(Level.SEVERE, - "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); - server.getPluginManager().disablePlugin(plugin); - - e.printStackTrace(); - } - } - - @Override - public CommandsModule getCommandsModule() { - return commandsModule; - } - - @Override - public CustomPayloadModule getCustomPayloadModule() { - return customPayloadModule; - } - - @Override - public ItemsFixModule getItemsFixModule() { - return itemsFixModule; - } - - @Override - public MessagesModule getMessagesModule() { - return messagesModule; - } - - @Override - public NotificationsModule getNotificationsModule() { - return notificationsModule; - } - - @Override - public ExploitPlayerManager getExploitPlayerManager() { - return exploitPlayerManager; - } - - @Override - public ReloadableModule getUUIDSpoofModule() { - return uuidSpoofModule; - } - - @Override - public PacketsModule getPacketsModule() { - return packetsModule; - } - - @Override - public ReloadableModule getNullAddressModule() { - return nullAddressModule; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java b/src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java similarity index 57% rename from src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java rename to src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 26a2cf2..86d43df 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/BukkitExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -1,85 +1,73 @@ -package twolovers.exploitfixer.bukkit.managers; - -import org.bukkit.Server; -import org.bukkit.entity.Player; -import twolovers.exploitfixer.bukkit.instanceables.BukkitExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import java.util.logging.Level; - -public class BukkitExploitPlayerManager implements ExploitPlayerManager { - private final Server server; - private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); - private int punishments = 0; - - BukkitExploitPlayerManager(final Server server, final ModuleManager moduleManager) { - this.server = server; - this.moduleManager = moduleManager; - - reload(); - } - - @Override - public ExploitPlayer get(final UUID uuid, final Object playerObject) { - ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); - - if (exploitPlayer == null) { - exploitPlayer = new BukkitExploitPlayer(((Player) playerObject).getName(), moduleManager); - exploitPlayers.put(uuid, exploitPlayer); - } - - return exploitPlayer; - } - - @Override - public void clear() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean cleared = false; - - while (iterator.hasNext()) { - final UUID uuid = iterator.next(); - - if (server.getPlayer(uuid) == null) { - iterator.remove(); - cleared = true; - } - } - - if (cleared) { - server.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); - } - } - - @Override - public void reload() { - exploitPlayers.clear(); - - for (final Player player : server.getOnlinePlayers()) { - final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); - - exploitPlayer.setLogged(true); - } - } - - @Override - public int getSize() { - return exploitPlayers.size(); - } - - @Override - public int getPunishments() { - return punishments; - } - - @Override - public int addPunishment() { - return ++punishments; - } -} +package twolovers.exploitfixer.bukkit.managers; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Server; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; + +public class ExploitPlayerManager { + private final Plugin plugin; + private final Server server; + private final ModuleManager moduleManager; + private final Map exploitPlayers = new HashMap<>(); + private int punishments = 0; + + ExploitPlayerManager(final Plugin plugin, final Server server, final ModuleManager moduleManager) { + this.plugin = plugin; + this.server = server; + this.moduleManager = moduleManager; + + reload(); + } + + public ExploitPlayer get(final UUID uuid, final Player player) { + ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + + if (exploitPlayer == null) { + exploitPlayer = new ExploitPlayer(this.plugin, player.getName(), moduleManager); + exploitPlayers.put(uuid, exploitPlayer); + } + + return exploitPlayer; + } + + public void clear() { + final Iterator iterator = exploitPlayers.keySet().iterator(); + + while (iterator.hasNext()) { + final UUID uuid = iterator.next(); + + if (server.getPlayer(uuid) == null) { + iterator.remove(); + } + } + } + + public void reload() { + exploitPlayers.clear(); + + for (final Player player : server.getOnlinePlayers()) { + final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + + exploitPlayer.setLogged(true); + } + } + + public int getSize() { + return exploitPlayers.size(); + } + + public int getPunishments() { + return punishments; + } + + public int addPunishment() { + return ++punishments; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java b/src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java new file mode 100644 index 0000000..2a30e35 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java @@ -0,0 +1,85 @@ +package twolovers.exploitfixer.bukkit.managers; + +import org.bukkit.Server; +import org.bukkit.configuration.Configuration; +import org.bukkit.plugin.Plugin; +import twolovers.exploitfixer.bukkit.modules.*; + +import java.util.logging.Level; + +public class ModuleManager { + private Plugin plugin; + private final CommandsModule commandsModule; + private final ConnectionModule connectionModule; + private final CustomPayloadModule customPayloadModule; + private final ItemsFixModule itemsFixModule; + private final MessagesModule messagesModule; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + private final ExploitPlayerManager exploitPlayerManager; + + public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { + this.plugin = plugin; + this.commandsModule = new CommandsModule(configYml); + this.connectionModule = new ConnectionModule(configYml); + this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); + this.itemsFixModule = new ItemsFixModule(plugin, configYml); + this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), configYml); + this.packetsModule = new PacketsModule(plugin, this, configYml); + this.exploitPlayerManager = new ExploitPlayerManager(plugin, plugin.getServer(), this); + } + + public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) { + try { + this.commandsModule.reload(configYml); + this.connectionModule.reload(configYml); + this.customPayloadModule.reload(configYml); + this.itemsFixModule.reload(configYml); + this.messagesModule.reload(messagesYml); + this.notificationsModule.reload(configYml); + this.packetsModule.reload(configYml); + this.exploitPlayerManager.reload(); + } catch (final NullPointerException e) { + final Server server = plugin.getServer(); + + server.getLogger().log(Level.SEVERE, + "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); + server.getPluginManager().disablePlugin(plugin); + + e.printStackTrace(); + } + } + + public CommandsModule getCommandsModule() { + return commandsModule; + } + + public ConnectionModule getConnectionModule() { + return connectionModule; + } + + public CustomPayloadModule getCustomPayloadModule() { + return customPayloadModule; + } + + public ItemsFixModule getItemsFixModule() { + return itemsFixModule; + } + + public MessagesModule getMessagesModule() { + return messagesModule; + } + + public NotificationsModule getNotificationsModule() { + return notificationsModule; + } + + public ExploitPlayerManager getExploitPlayerManager() { + return exploitPlayerManager; + } + + public PacketsModule getPacketsModule() { + return packetsModule; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java deleted file mode 100644 index 489b294..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCommandsModule.java +++ /dev/null @@ -1,61 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.modules.CommandsModule; - -import java.util.Collection; - -public class BukkitCommandsModule implements CommandsModule { - private Collection commands; - private Violations violations; - private double cancelVls, reduceVls; - private boolean enabled; - - public BukkitCommandsModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "Commands"; - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - final public Collection getCommands() { - return commands; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - this.commands = configYml1.getStringList("commands.commands"); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java deleted file mode 100644 index 990ac8d..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitCustomPayloadModule.java +++ /dev/null @@ -1,179 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import com.google.common.base.Charsets; -import io.netty.buffer.ByteBuf; - -import org.bukkit.Material; -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; - -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class BukkitCustomPayloadModule implements CustomPayloadModule { - private Map multipliers = new HashMap<>(); - private Plugin plugin; - private ModuleManager moduleManager; - private Violations violations; - private int maxChannelsAmount, bigDataMaxBytes; - private double cancelVls, reduceVls, booksVls, booksMaxBytes, maxChannelsVls, bigDataVls; - private boolean enabled; - - public BukkitCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { - this.plugin = plugin; - this.moduleManager = moduleManager; - - reload(configYml); - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - public String getName() { - return "CustomPayload"; - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public void reload(final Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - final ConfigurationSection configurationSection = configYml1 - .getConfigurationSection("custompayload.multipliers"); - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.booksVls = configYml1.getDouble(name + ".invalid.books.vls"); - this.booksMaxBytes = configYml1.getInt(name + ".invalid.books.max_bytes"); - this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); - this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); - this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); - this.bigDataMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes"); - - for (final String key : configurationSection.getKeys(false)) - multipliers.put(key, configurationSection.getDouble(key)); - } - - @Override - public void check(final Object eventObject) { - if (eventObject instanceof PacketEvent) { - final PacketEvent event = (PacketEvent) eventObject; - - if (!event.isCancelled()) { - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - final PacketContainer packet = event.getPacket(); - final StructureModifier packetStrings = packet.getStrings(); - final String tag = packetStrings.readSafely(0); - - if (tag != null) { - if (tag.endsWith("BEdit") || tag.endsWith("BOpen") || tag.endsWith("BSign")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack heldItem = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (heldItem != null) { - final Material heldItemType = heldItem.getType(); - - if (heldItemType != Material.BOOK_AND_QUILL && heldItemType != Material.WRITTEN_BOOK) { - event.setCancelled(true); - } - } - } - - if (!event.isCancelled()) { - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet - .getSpecificModifier(ByteBuf.class); - final ByteBuf byteBufModifier0 = byteBufModifier.readSafely(0); - final String content = byteBufModifier0.toString(Charsets.UTF_8); - - if (content != null) { - try { - final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() - .get(uuid, player); - final String[] pages = content.split("\000"); - - if ((tag.endsWith("BEdit") || tag.endsWith("BSign") || tag.endsWith("BOpen")) - && checkPages(event, exploitPlayer, player, pages)) { - exploitPlayer.addVls(plugin, eventObject, player, this, booksVls); - } else if (tag.endsWith("Register") && pages.length > maxChannelsAmount) { - exploitPlayer.addVls(plugin, eventObject, player, this, maxChannelsVls); - } - - if (!event.isCancelled()) { - if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, eventObject, player, this, - multipliers.getOrDefault(tag, bigDataVls)); - } else { - exploitPlayer.addVls(plugin, eventObject, player, this, multipliers - .getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } - } - } catch (final UnsupportedOperationException e) { - event.setCancelled(true); - } - } else { - event.setCancelled(true); - } - } - } else { - event.setCancelled(true); - } - } - } - } - } - } - - private boolean checkPages(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, - final String[] pages) { - - if (pages.length - 9 > 50) { - return true; - } else - for (final String page : pages) { - if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { - return true; - } - } - - return false; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java deleted file mode 100644 index d02d036..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ /dev/null @@ -1,76 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.Bukkit; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.HashSet; - -public class BukkitNotificationsModule implements NotificationsModule { - private final Collection notifications = new HashSet<>(); - private boolean enabled; - private String message; - - public BukkitNotificationsModule(final Object configYml) { - reload(configYml); - } - - @Override - public final void setNotifications(final Object player, final boolean input) { - if (input) - notifications.add(player); - else - notifications.remove(player); - } - - @Override - public final boolean isNotifications(final Object player) { - return notifications.contains(player); - } - - @Override - public void sendNotification(final String check, final Object player, final int violations) { - if (enabled && player != null) { - final Player player1 = (Player) player; - final ConsoleCommandSender consoleCommandSender = Bukkit.getConsoleSender(); - int ping = 0; - - try { - final Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); - ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer); - } catch (IllegalAccessException | NoSuchFieldException | InvocationTargetException | NoSuchMethodException ignored) { - } - - final String notification = message - .replace("%player%", player1.getName()) - .replace("%check%", check) - .replace("%ping%", String.valueOf(ping)) - .replace("%vls%", String.valueOf(violations)); - - consoleCommandSender.sendMessage(notification); - - for (final Object player2 : getNotifications()) - ((Player) player2).sendMessage(notification); - } - } - - @Override - public final Collection getNotifications() { - return notifications; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - - enabled = configYml1.getBoolean("notifications.enabled"); - message = configYml1.getString("notifications.message"); - - if (message != null) - message = message.replace("&", "\u00A7"); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java deleted file mode 100644 index c4ba594..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitNullAddressModule.java +++ /dev/null @@ -1,30 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.modules.ReloadableModule; - -public class BukkitNullAddressModule implements ReloadableModule { - private boolean enabled; - - public BukkitNullAddressModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "NullAddress"; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean("connection." + name); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java deleted file mode 100644 index 126aa88..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitPacketsModule.java +++ /dev/null @@ -1,348 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.utility.StreamSerializer; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.comphenix.protocol.wrappers.nbt.NbtBase; -import io.netty.buffer.ByteBuf; - -import org.bukkit.block.BlockState; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.BukkitViolations; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.PacketsModule; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; - -public class BukkitPacketsModule implements PacketsModule { - private final Plugin plugin; - private final ModuleManager moduleManager; - private final Map multipliers = new HashMap<>(); - private Violations violations; - private double bigDataVls, bigDataMaxBytes, blockDig, blockPlace, setCreativeSlot, windowClick, cancelVls, - reduceVls; - private int booksMaxBytes, signsMaxBytes; - private boolean enabled, offline; - - public BukkitPacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { - this.plugin = plugin; - this.moduleManager = moduleManager; - reload(configYml); - } - - @Override - final public void reload(final Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final ConfigurationSection configurationSection = configYml1.getConfigurationSection("packets.multipliers"); - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.offline = configYml1.getBoolean(name + ".invalid.offline"); - this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); - this.bigDataMaxBytes = configYml1.getDouble(name + ".invalid.big_data.max_bytes", 24000); - this.booksMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes_book", 268); - this.signsMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes_sign", 47); - this.windowClick = configYml1.getDouble(name + ".invalid.window_click"); - this.blockPlace = configYml1.getDouble(name + ".invalid.block_place"); - this.blockDig = configYml1.getDouble(name + ".invalid.block_dig"); - this.setCreativeSlot = configYml1.getDouble(name + ".invalid.set_creative_slot"); - this.violations = new BukkitViolations(configYml1.getConfigurationSection(name + ".violations")); - - for (final String key : configurationSection.getKeys(false)) - multipliers.put(key, configurationSection.getDouble(key)); - } - - @Override - public double getMultiplier(final String packetName) { - return multipliers.getOrDefault(packetName, 1D); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void check(final Object eventObject) { - if (eventObject instanceof PacketEvent) { - final PacketEvent event = (PacketEvent) eventObject; - - if (!event.isCancelled()) { - final Player player = event.getPlayer(); - final PacketType packetType = event.getPacketType(); - - if (player != null && player.isOnline()) { - try { - final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager().get(uuid, player); - final PacketContainer packet = event.getPacket(); - final StructureModifier chatComponentArrays; - final StructureModifier stringArrays = packet.getStringArrays(); - final WrappedChatComponent[] chatComponentArrays0; - - if (!VersionUtil.isOneDotSeven()) { - chatComponentArrays = packet.getChatComponentArrays(); - chatComponentArrays0 = chatComponentArrays.readSafely(0); - } else { - chatComponentArrays = null; - chatComponentArrays0 = null; - } - - if (bigDataVls > 0 && packet.getType() == PacketType.Play.Client.UPDATE_SIGN - && checkSign(chatComponentArrays0, stringArrays.readSafely(0))) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } - - if (!event.isCancelled() && bigDataVls > 0) { - final StructureModifier itemModifier = packet.getItemModifier(); - final StructureModifier itemArrayModifier = packet.getItemArrayModifier(); - final StructureModifier strings = packet.getStrings(); - final StructureModifier> nbtModifier = packet.getNbtModifier(); - final AtomicInteger packetSize = new AtomicInteger(0); - - if (!VersionUtil.isOneDotSeven()) { - for (final WrappedBlockData wrappedBlockData : packet.getBlockData().getValues()) { - if (wrappedBlockData != null) { - final int dataBytes = wrappedBlockData.toString() - .getBytes(StandardCharsets.UTF_8).length; - - packetSize.addAndGet(dataBytes); - } - } - - for (final List itemList : packet.getItemListModifier().getValues()) { - for (final ItemStack itemStack : itemList) { - checkItem(itemStack, event, exploitPlayer, player, packetSize); - } - } - } - - for (final ItemStack itemStack : itemModifier.getValues()) { - checkItem(itemStack, event, exploitPlayer, player, packetSize); - } - - for (final ItemStack[] itemList : itemArrayModifier.getValues()) - for (final ItemStack itemStack : itemList) { - checkItem(itemStack, event, exploitPlayer, player, packetSize); - } - - for (final String string : strings.getValues()) { - if (string != null) { - final int dataBytes = string.getBytes(StandardCharsets.UTF_8).length; - - packetSize.addAndGet(dataBytes); - } - } - - for (final NbtBase nbtBase : nbtModifier.getValues()) { - if (nbtBase != null) { - final int dataBytes = nbtBase.getValue().toString() - .getBytes(StandardCharsets.UTF_8).length; - - packetSize.addAndGet(dataBytes); - } - } - - if (!VersionUtil.isOneDotSeven()) { - final StructureModifier byteBufModifier = packet - .getSpecificModifier(ByteBuf.class); - - for (final ByteBuf byteBuf : byteBufModifier.getValues()) { - try { - if (byteBuf != null) { - final byte[] bytes = new byte[byteBuf.readableBytes()]; - byteBuf.readBytes(bytes); - final DataInputStream inputStream = new DataInputStream( - new ByteArrayInputStream(bytes)); - - checkItem(StreamSerializer.getDefault().deserializeItemStack(inputStream), - event, exploitPlayer, player, packetSize); - - inputStream.close(); - packetSize.addAndGet(((ByteBuf) byteBuf).capacity()); - } - } catch (final IOException ignored) { - } - } - - if (packetSize.get() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } - } - - if (!event.isCancelled()) { - exploitPlayer.addVls(plugin, event, player, this, getMultiplier(packetType.name())); - } - } - } catch (final UnsupportedOperationException ignored) { - event.setCancelled(true); - } - } else if (this.offline && packetType != PacketType.Play.Client.CUSTOM_PAYLOAD - && packetType != PacketType.Play.Client.SETTINGS) { - event.setCancelled(true); - } - } - } - } - - @Override - public boolean isOffline() { - return offline; - } - - @Override - public double getWindowClick() { - return windowClick; - } - - @Override - public double getSetCreativeSlot() { - return setCreativeSlot; - } - - @Override - public double getBlockDig() { - return blockDig; - } - - @Override - public double getBlockPlace() { - return blockPlace; - } - - @Override - public String getName() { - return "Packets"; - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - private boolean checkItem(final ItemStack itemStack, final PacketEvent event, final ExploitPlayer exploitPlayer, - final Player player, final AtomicInteger packetSize) { - if (itemStack != null && !event.isCancelled()) { - try { - final ItemMeta itemMeta = itemStack.getItemMeta(); - int dataBytes = itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - - if (itemMeta != null) { - try { - dataBytes += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - dataBytes += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())) - .getBytes(StandardCharsets.UTF_8).length; - } - - if (!VersionUtil.isOneDotSeven() && itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) - checkItem(itemStack1, event, exploitPlayer, player, packetSize); - } - } - } else if (itemMeta instanceof BookMeta) { - checkBook(event, exploitPlayer, player, itemMeta); - } - } - - packetSize.addAndGet(dataBytes); - - return false; - } catch (final Exception exception) { - return true; - } - } else - return true; - } - - private void checkBook(final Cancellable event, final ExploitPlayer exploitPlayer, final Player player, - final ItemMeta itemMeta) { - if (bigDataVls > 0 && itemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; - - if (exploitPlayer == null) { - event.setCancelled(true); - } else if (bookMeta.getPageCount() > 50) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } else { - for (final String page : bookMeta.getPages()) { - if (event.isCancelled()) { - break; - } else if (page.getBytes(StandardCharsets.UTF_8).length > booksMaxBytes) { - exploitPlayer.addVls(plugin, event, player, this, bigDataVls); - } - } - } - } - } - - private boolean checkSign(final WrappedChatComponent[] linesChatComponent, final String[] linesString) { - if (linesChatComponent != null) { - if (linesChatComponent.length > 4) { - return true; - } else - for (final WrappedChatComponent line : linesChatComponent) { - if (line.getJson().getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { - return true; - } - } - } - - if (linesString != null) { - if (linesString.length > 4) { - return true; - } else - for (final String line : linesString) { - if (line.getBytes(StandardCharsets.UTF_8).length > signsMaxBytes) { - return true; - } - } - } - - return false; - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java b/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java deleted file mode 100644 index 68600b0..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitUUIDSpoofModule.java +++ /dev/null @@ -1,30 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.interfaces.modules.ReloadableModule; - -public class BukkitUUIDSpoofModule implements ReloadableModule { - private boolean enabled; - - public BukkitUUIDSpoofModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "UUIDSpoof"; - } - - @Override - public void reload(Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean("connection." + name); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java b/src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java new file mode 100644 index 0000000..0775426 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java @@ -0,0 +1,45 @@ +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.bukkit.modules.CommandsModule; +import twolovers.exploitfixer.shared.interfaces.PunishmentModule; + +import java.util.Collection; + +public class CommandsModule implements PunishmentModule { + private Collection commands, punishments; + private String name; + private boolean enabled; + + public CommandsModule(final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + this.name = "Commands"; + this.enabled = configYml1.getBoolean("commands.enabled"); + this.commands = configYml1.getStringList("commands.commands"); + this.punishments = configYml1.getStringList("commands.punishments"); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return this.name; + } + + public final Collection getCommands() { + return commands; + } + + public final Collection getPunishments() { + return punishments; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java b/src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java new file mode 100644 index 0000000..d3e5dfa --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java @@ -0,0 +1,50 @@ +package twolovers.exploitfixer.bukkit.modules; + +import java.util.Collection; +import java.util.HashSet; + +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.file.YamlConfiguration; +import twolovers.exploitfixer.shared.interfaces.PunishmentModule; + +public class ConnectionModule implements PunishmentModule { + private boolean uuidSpoofEnabled, nullAddressEnabled; + private String name; + private Collection punishments; + + public ConnectionModule(final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + + this.uuidSpoofEnabled = configYml1.getBoolean("connection.uuidspoof"); + this.nullAddressEnabled = configYml1.getBoolean("connection.nulladdress"); + this.name = "UUID-Spoof"; + this.punishments = new HashSet<>(configYml1.getStringList("connection.punishments")); + } + + public boolean isUUIDSpoofEnabled() { + return uuidSpoofEnabled; + } + + public boolean isNullAddressEnabled() { + return nullAddressEnabled; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public Collection getPunishments() { + return this.punishments; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java new file mode 100644 index 0000000..0130d35 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java @@ -0,0 +1,103 @@ +package twolovers.exploitfixer.bukkit.modules; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.plugin.Plugin; + +import twolovers.exploitfixer.bukkit.instanceables.Violations; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.shared.interfaces.ViolationModule; + +public class CustomPayloadModule implements ViolationModule { + private Map multipliers = new HashMap<>(); + private Violations violations; + private int channelAmount, dataBytes, bookBytes; + private double cancelVls, reduceVls, bookVls, channelVls, dataVls, tagVls; + private boolean enabled; + + public CustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + final ConfigurationSection configurationSection = configYml + .getConfigurationSection("custompayload.multipliers"); + final String name = getName().toLowerCase(); + + this.enabled = configYml.getBoolean(name + ".enabled"); + this.cancelVls = configYml.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml.getDouble(name + ".reduce_vls"); + this.bookVls = configYml.getDouble(name + ".book.vls"); + this.bookBytes = configYml.getInt(name + ".book.bytes"); + this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); + this.channelVls = configYml.getDouble(name + ".channel.vls"); + this.channelAmount = configYml.getInt(name + ".channel.amount"); + this.dataVls = configYml.getDouble(name + ".data.vls"); + this.dataBytes = configYml.getInt(name + ".data.bytes"); + this.tagVls = configYml.getDouble(name + ".tag.vls"); + + for (final String key : configurationSection.getKeys(false)) { + multipliers.put(key, configurationSection.getDouble(key)); + } + } + + @Override + public double getCancelVls() { + return cancelVls; + } + + @Override + public double getReduceVls() { + return reduceVls; + } + + @Override + public Violations getViolations() { + return violations; + } + + @Override + public String getName() { + return "CustomPayload"; + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + public double getMultiplier(final String packetName) { + return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); + } + + public double getTagVls() { + return this.tagVls; + } + + public double getBookVls() { + return this.bookVls; + } + + public double getChannelVls() { + return this.channelVls; + } + + public double getDataVls() { + return this.dataVls; + } + + public int getBookBytes() { + return this.bookBytes; + } + + public int getDataBytes() { + return this.dataBytes; + } + + public int getChannelAmount() { + return this.channelAmount; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java similarity index 57% rename from src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java rename to src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java index ab59406..5eab8c1 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitItemsFixModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -4,33 +4,32 @@ import java.util.Map; import org.bukkit.Material; -import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.configuration.Configuration; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.interfaces.modules.ItemsFixModule; +import twolovers.exploitfixer.bukkit.modules.ItemsFixModule; +import twolovers.exploitfixer.shared.interfaces.Module; -public class BukkitItemsFixModule implements ItemsFixModule { +public class ItemsFixModule implements Module { private final Plugin plugin; private boolean enabled; private int enchantLimit, maxStackSize; - public BukkitItemsFixModule(final Plugin plugin, final Object configYml) { + public ItemsFixModule(final Plugin plugin, final Configuration configYml) { this.plugin = plugin; reload(configYml); } - @Override - final public void reload(final Object configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; + final public void reload(final Configuration configYml) { final String name = getName().toLowerCase(); - this.enabled = configYml1.getBoolean(name + ".enabled", true); - this.enchantLimit = configYml1.getInt(name + ".enchant_limit", 10); - this.maxStackSize = configYml1.getInt(name + ".max_stack_size", 64); + this.enabled = configYml.getBoolean(name + ".enabled", true); + this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); + this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); } @Override @@ -43,36 +42,36 @@ public String getName() { return "ItemsFix"; } - @Override public int getEnchantLimit() { return enchantLimit; } - @Override public int getMaxStackSize() { return maxStackSize; } - @Override - public ItemStack fixItemStack(final ItemStack itemStack) { + public ItemStack fixItem(final ItemStack itemStack) { if (itemStack != null) { final Material material = Material.getMaterial(itemStack.getType().name()); - final ItemMeta itemMeta = itemStack.getItemMeta(); - final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final Map enchantments = itemStack.getEnchantments(); + final ItemMeta itemMeta = itemStack.getItemMeta(), + newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + final int maxStackSize = getMaxStackSize(); final short durability = itemStack.getDurability(); - for (final Enchantment enchantment : enchantments.keySet()) { - final int level = enchantments.get(enchantment); - - if (enchantLimit < 0 || enchantments.get(enchantment) < enchantLimit) - newItemMeta.addEnchant(enchantment, level, true); - } - if (itemStack.hasItemMeta()) { + final Map enchantments = itemStack.getEnchantments(); final String displayName = itemMeta.getDisplayName(); final List lore = itemMeta.getLore(); - final int maxStackSize = getMaxStackSize(); + + if (enchantLimit > -1) { + for (final Enchantment enchantment : enchantments.keySet()) { + final int level = enchantments.get(enchantment); + + if (level <= enchantLimit && level > -1) { + newItemMeta.addEnchant(enchantment, level, true); + } + } + } if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { final BookMeta bookMeta = (BookMeta) itemMeta; @@ -83,14 +82,16 @@ public ItemStack fixItemStack(final ItemStack itemStack) { newBookMeta.setPages(bookMeta.getPages()); } - if (maxStackSize != 0 && itemStack.getAmount() > maxStackSize) - itemStack.setAmount(maxStackSize); - if (displayName != null && displayName.getBytes().length < 128) newItemMeta.setDisplayName(displayName); - if (lore != null && lore.toString().getBytes().length < 1024) + if (lore != null && lore.toString().getBytes().length < 1024) { newItemMeta.setLore(lore); + } + } + + if (maxStackSize > 0 && itemStack.getAmount() > maxStackSize) { + itemStack.setAmount(maxStackSize); } itemStack.setType(material); diff --git a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java similarity index 76% rename from src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java rename to src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java index 6b758f8..31d1fa9 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java @@ -1,96 +1,88 @@ -package twolovers.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.Configuration; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; - -public class BukkitMessagesModule implements MessagesModule { - private final String version; - private Configuration messagesYml; - - public BukkitMessagesModule(final String version, final Configuration messagesYml) { - this.version = version; - reload(messagesYml); - } - - @Override - public String getString(String locale, final String path) { - String string; - - if (locale == null) - locale = "en"; - - string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) - string = messagesYml.getString("en" + path); - - if (string != null) - string = string.replace("&", "\u00A7"); - else - string = ""; - - return string; - } - - @Override - public final String getReload(final String locale) { - return getString(locale, ".commands.reload"); - } - - @Override - public final String getHelp(final String locale) { - return getString(locale, ".commands.help") - .replace("%version%", version); - } - - @Override - public final String getUnknown(final String locale) { - return getString(locale, ".commands.error.unknown"); - } - - @Override - public final String getPermission(final String locale) { - return getString(locale, ".commands.error.permission"); - } - - @Override - public final String getConsole(final String locale) { - return getString(locale, ".commands.error.console"); - } - - @Override - public final String getEnable(final String locale) { - return getString(locale, ".commands.notifications.enable"); - } - - @Override - public final String getDisable(final String locale) { - return getString(locale, ".commands.notifications.disable"); - } - - @Override - public final String getKickMessage(final Module module, final String locale) { - return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); - } - - @Override - public void reload(Object messagesYml) { - this.messagesYml = (Configuration) messagesYml; - } - - @Override - public String getStats(String locale) { - return getString(locale, ".modules.stats.message"); - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getName() { - return "Messages"; - } +package twolovers.exploitfixer.bukkit.modules; + +import org.bukkit.configuration.Configuration; + +import twolovers.exploitfixer.shared.interfaces.Module; + +public class MessagesModule implements Module { + private final String version; + private Configuration messagesYml; + + public MessagesModule(final String version, final Configuration messagesYml) { + this.version = version; + reload(messagesYml); + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return "Messages"; + } + + public String getString(String locale, final String path) { + String string; + + if (locale == null) + locale = "en"; + + string = messagesYml.getString(locale + path); + + if (string == null || string.isEmpty()) + string = messagesYml.getString("en" + path); + + if (string != null) + string = string.replace("&", "\u00A7"); + else + string = ""; + + return string; + } + + public final String getReload(final String locale) { + return getString(locale, ".commands.reload"); + } + + public final String getHelp(final String locale) { + return getString(locale, ".commands.help").replace("%version%", version); + } + + public final String getUnknown(final String locale) { + return getString(locale, ".commands.error.unknown"); + } + + public final String getPermission(final String locale) { + return getString(locale, ".commands.error.permission"); + } + + public final String getConsole(final String locale) { + return getString(locale, ".commands.error.console"); + } + + public final String getEnable(final String locale) { + return getString(locale, ".commands.notifications.enable"); + } + + public final String getDisable(final String locale) { + return getString(locale, ".commands.notifications.disable"); + } + + public final String getKickMessage(final Module module, final String locale) { + return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); + } + + public final String getKickMessage(final String module, final String locale) { + return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); + } + + public void reload(Object messagesYml) { + this.messagesYml = (Configuration) messagesYml; + } + + public String getStats(String locale) { + return getString(locale, ".modules.stats.message"); + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java b/src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java new file mode 100644 index 0000000..1f530b0 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java @@ -0,0 +1,83 @@ +package twolovers.exploitfixer.bukkit.modules; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; +import java.util.HashSet; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.Configuration; +import org.bukkit.entity.Player; + +import twolovers.exploitfixer.shared.interfaces.Module; + +public class NotificationsModule implements Module { + private final CommandSender console; + private final Collection notifications = new HashSet<>(); + private boolean enabled, debug; + private String message; + + public NotificationsModule(final CommandSender console, final Configuration configYml) { + this.console = console; + reload(configYml); + } + + @Override + public boolean isEnabled() { + return this.enabled; + } + + public boolean isDebug() { + return this.debug; + } + + public final void setNotifications(final Player player, final boolean input) { + if (input) { + notifications.add(player); + } else { + notifications.remove(player); + } + } + + public final boolean isNotifications(final Player player) { + return notifications.contains(player); + } + + public void sendNotification(final String check, final Player player, final int violations) { + if (enabled && player != null) { + final Player player1 = (Player) player; + int ping = 0; + + try { + final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + ping = (int) playerHandle.getClass().getField("ping").get(playerHandle); + } catch (IllegalAccessException | NoSuchFieldException | InvocationTargetException + | NoSuchMethodException ignored) { + } + + final String notification = message.replace("%player%", player1.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); + + console.sendMessage(notification); + + for (final Player player2 : getNotifications()) { + player2.sendMessage(notification); + } + } + } + + public final Collection getNotifications() { + return notifications; + } + + public void reload(final Configuration configYml) { + this.enabled = configYml.getBoolean("notifications.enabled"); + this.debug = configYml.getBoolean("notifications.debug"); + this.message = ChatColor.translateAlternateColorCodes('&', configYml.getString("notifications.message")); + } + + @Override + public String getName() { + return "Notifications"; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java b/src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java new file mode 100644 index 0000000..144cf33 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java @@ -0,0 +1,118 @@ +package twolovers.exploitfixer.bukkit.modules; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.plugin.Plugin; + +import twolovers.exploitfixer.bukkit.instanceables.Violations; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import twolovers.exploitfixer.shared.interfaces.ViolationModule; + +public class PacketsModule implements ViolationModule { + private final Map multipliers = new HashMap<>(); + private Violations violations; + private String name; + private double dataVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, reduceVls; + private int dataBytesBook, dataBytesSign, dataBytes, dataBytesDivider; + private boolean enabled, offline; + + public PacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { + reload(configYml); + } + + final public void reload(final Configuration configYml) { + final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers"); + final String name = "packets"; + + this.name = "Packets"; + this.enabled = configYml.getBoolean(name + ".enabled"); + this.cancelVls = configYml.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml.getDouble(name + ".reduce_vls"); + this.offline = configYml.getBoolean(name + ".offline"); + this.dataVls = configYml.getDouble(name + ".data.vls"); + this.dataBytes = configYml.getInt(name + ".data.bytes", 24000); + this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268); + this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47); + this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200); + this.windowClick = configYml.getDouble(name + ".window_click"); + this.blockPlaceVls = configYml.getDouble(name + ".block_place"); + this.blockDigVls = configYml.getDouble(name + ".block_dig"); + this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); + this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); + + for (final String key : configurationSection.getKeys(false)) + multipliers.put(key, configurationSection.getDouble(key)); + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public double getCancelVls() { + return cancelVls; + } + + @Override + public double getReduceVls() { + return reduceVls; + } + + @Override + public Violations getViolations() { + return this.violations; + } + + public double getMultiplier(final String packetName) { + return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); + } + + public double getWindowClick() { + return this.windowClick; + } + + public double getSetCreativeSlot() { + return this.setCreativeSlot; + } + + public double getBlockDigVls() { + return this.blockDigVls; + } + + public double getBlockPlaceVls() { + return this.blockPlaceVls; + } + + public double getDataVls() { + return this.dataVls; + } + + public int getDataBytes() { + return this.dataBytes; + } + + public int getDataBytesBook() { + return this.dataBytesBook; + } + + public int getDataBytesSign() { + return this.dataBytesSign; + } + + public boolean isOffline() { + return this.offline; + } + + public int getDataBytesDivider() { + return this.dataBytesDivider; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java b/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java deleted file mode 100644 index 397df45..0000000 --- a/src/twolovers/exploitfixer/bukkit/nms/CraftPlayerReflector.java +++ /dev/null @@ -1,55 +0,0 @@ -package twolovers.exploitfixer.bukkit.nms; - -import org.bukkit.entity.Player; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class CraftPlayerReflector { - private final Player player; - private Object playerConnection = null; - - public CraftPlayerReflector(final Player player) { - this.player = player; - } - - private Object getPlayerConnection() { - if (playerConnection == null) - try { - final Method getHandle = player.getClass().getMethod("getHandle"); - final Object nmsPlayer = getHandle.invoke(player); - final Field conField = nmsPlayer.getClass().getField("playerConnection"); - playerConnection = conField.get(nmsPlayer); - } catch (final Exception e) { - e.printStackTrace(); - } - - return playerConnection; - } - - public void closeChannel() { - try { - final Object playerConnection = getPlayerConnection(); - final Field netField = playerConnection.getClass().getField("networkManager"); - final Object net = netField.get(playerConnection); - final Field chanField = net.getClass().getField("channel"); - final Object chan = chanField.get(net); - final Method method = chan.getClass().getMethod("closeFuture"); - - method.invoke(chan); - } catch (final Exception e) { - // Ignore because some versions throw exceptions. - } - } - - public void disconnect(final String kickMessage) { - try { - final Object playerConnection = getPlayerConnection(); - final Method method = playerConnection.getClass().getMethod("disconnect", String.class); - - method.invoke(playerConnection, kickMessage); - } catch (final Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java index 5dc8bee..db17121 100644 --- a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.util.logging.Level; +import java.util.logging.Logger; public class ConfigurationUtil { final private Plugin plugin; @@ -22,10 +23,13 @@ public YamlConfiguration getConfiguration(String filePath) { if (file.exists()) return YamlConfiguration.loadConfiguration(file); - else return new YamlConfiguration(); + else + return new YamlConfiguration(); } public void createConfiguration(String file) { + final Logger logger = plugin.getLogger(); + try { final File dataFolder = plugin.getDataFolder(); @@ -35,18 +39,23 @@ public void createConfiguration(String file) { if (!configFile.exists()) { final String[] files = file.split("/"); - final InputStream inputStream = plugin.getClass().getClassLoader().getResourceAsStream(files[files.length - 1]); + final InputStream inputStream = plugin.getClass().getClassLoader() + .getResourceAsStream(files[files.length - 1]); final File parentFile = configFile.getParentFile(); - if (parentFile != null) parentFile.mkdirs(); + if (parentFile != null) + parentFile.mkdirs(); if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); - } else configFile.createNewFile(); + logger.log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") + .replace("%pluginname%", plugin.getDescription().getName())); + } else + configFile.createNewFile(); } } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + logger.log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", + plugin.getDescription().getName())); } } @@ -57,7 +66,8 @@ public void saveConfiguration(final YamlConfiguration yamlConfiguration, final S yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") + .replace("%pluginname%", plugin.getDescription().getName())); } }); } @@ -66,7 +76,8 @@ public void deleteConfiguration(final String file) { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { final File file1 = new File(file); - if (file1.exists()) file1.delete(); + if (file1.exists()) + file1.delete(); }); } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/twolovers/exploitfixer/bungee/ExploitFixer.java index 52ca5ec..da1b790 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bungee/ExploitFixer.java @@ -9,10 +9,9 @@ import twolovers.exploitfixer.bungee.listeners.DisconnectListener; import twolovers.exploitfixer.bungee.listeners.PluginMessageListener; import twolovers.exploitfixer.bungee.listeners.PostLoginListener; -import twolovers.exploitfixer.bungee.managers.BungeeModuleManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; import twolovers.exploitfixer.bungee.utils.ConfigurationUtil; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; import java.util.concurrent.TimeUnit; @@ -33,7 +32,7 @@ public void onEnable() { final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); - this.moduleManager = new BungeeModuleManager(this, configYml, messagesYml); + this.moduleManager = new ModuleManager(this, configYml, messagesYml); reload(); @@ -59,7 +58,7 @@ public void reload() { pluginManager.unregisterListeners(this); pluginManager.registerListener(this, new ChatListener(this, moduleManager)); pluginManager.registerListener(this, new DisconnectListener(moduleManager)); - pluginManager.registerListener(this, new PluginMessageListener(moduleManager)); + pluginManager.registerListener(this, new PluginMessageListener(this, moduleManager)); pluginManager.registerListener(this, new PostLoginListener(this, moduleManager)); pluginManager.unregisterCommands(this); diff --git a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java index 9a54fc9..79652de 100644 --- a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -5,10 +5,10 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import twolovers.exploitfixer.bungee.ExploitFixer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.MessagesModule; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; import java.util.Locale; @@ -37,7 +37,8 @@ public void execute(final CommandSender commandSender, final String[] args) { } if (length < 1 || args[0].equals("help")) { - commandSender.sendMessage(new TextComponent(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); + commandSender + .sendMessage(new TextComponent(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); } else if (args[0].equals("reload")) if (commandSender.hasPermission("exploitfixer.admin")) { ExploitFixer.getInstance().reload(); @@ -53,7 +54,8 @@ else if (args[0].equals("stats")) commandSender.sendMessage(new TextComponent(messagesModule.getPermission(lang))); else if (args[0].equalsIgnoreCase("notifications")) { if (commandSender instanceof ProxiedPlayer) { - if (commandSender.hasPermission("exploitfixer.admin") || commandSender.hasPermission("exploitfixer.notifications")) { + if (commandSender.hasPermission("exploitfixer.admin") + || commandSender.hasPermission("exploitfixer.notifications")) { final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) commandSender; if (!notificationsVariables.isNotifications(proxiedPlayer)) { diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java deleted file mode 100644 index 03a93ab..0000000 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeExploitPlayer.java +++ /dev/null @@ -1,164 +0,0 @@ -package twolovers.exploitfixer.bungee.instanceables; - -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Cancellable; -import net.md_5.bungee.api.plugin.Plugin; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CancellableModule; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.*; - -public class BungeeExploitPlayer implements ExploitPlayer { - final private ExploitPlayerManager exploitPlayerManager; - final private MessagesModule messagesModule; - final private NotificationsModule notificationsModule; - final private Map violations = new HashMap<>(); - final private String name; - private String onlineUUID = null; - private boolean logged = false; - private int channels = 0; - private double lastViolation = 0; - - public BungeeExploitPlayer(final String name, final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.messagesModule = moduleManager.getMessagesModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.name = name; - } - - @Override - public void clearChannels() { - this.channels = 0; - } - - @Override - public int addChannels(final int channels) { - return this.channels += channels; - } - - @Override - public double getViolations(final Module module) { - if (module instanceof CancellableModule) - return violations.getOrDefault(module, 0D); - else - return 0D; - } - - @Override - public String getOnlineUUID() { - if (onlineUUID == null) { - try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openConnection(); - - connection.setDoOutput(true); - connection.connect(); - - final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - final StringBuilder response = new StringBuilder(); - - String inputLine; - - while ((inputLine = bufferedReader.readLine()) != null) - response.append(inputLine).append("\n"); - - bufferedReader.close(); - onlineUUID = response.toString(); - } catch (Exception ignored) { - } - } - - return onlineUUID; - } - - @Override - public void addVls(final Object pluginObject, final Object event, final Object playerObject, final CancellableModule module, final double amount) { - if (playerObject instanceof ProxiedPlayer) { - final ProxiedPlayer player = (ProxiedPlayer) playerObject; - - if (player.isConnected()) { - final Violations violations = module.getViolations(); - - if (violations != null) { - - final Plugin plugin = (Plugin) pluginObject; - final ProxyServer server = plugin.getProxy(); - final double currentTime = System.currentTimeMillis(); - final Locale locale = player.getLocale(); - String lang = null; - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - - for (final CancellableModule violationModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - - if (vls <= 0) - this.violations.remove(violationModule); - else - this.violations.put(violationModule, vls); - } - } - - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; - - if (locale != null) - lang = locale.toString().substring(0, 2); - - final String kickMessage = messagesModule.getKickMessage(module, lang); - - this.violations.put(module, newVls); - - if (event instanceof Cancellable && module.getCancelVls() <= newVls) - ((Cancellable) event).setCancelled(true); - - for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); - - if (commands != null && !commands.isEmpty()) - for (final String punishCommand : commands) - if (!punishCommand.isEmpty()) - if (punishCommand.equals("kick")) { - player.disconnect(new TextComponent(kickMessage)); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) - notificationsModule.sendNotification(module.getName(), player, (int) newVls); - else - server.getPluginManager().dispatchCommand(server.getConsole(), punishCommand.replace("%player%", player.getName())); - } - } - } - } else if (event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); - } else if (event instanceof Cancellable) - ((Cancellable) event).setCancelled(true); - } - - @Override - public void clearViolations() { - violations.clear(); - } - - @Override - public void setLogged(final boolean logged) { - this.logged = logged; - } - - @Override - public boolean isLogged() { - return logged; - } -} diff --git a/src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java new file mode 100644 index 0000000..69b55f6 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java @@ -0,0 +1,158 @@ +package twolovers.exploitfixer.bungee.instanceables; + +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; +import net.md_5.bungee.api.plugin.Plugin; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.MessagesModule; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; +import twolovers.exploitfixer.shared.interfaces.Module; +import twolovers.exploitfixer.shared.interfaces.ViolationModule; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; + +public class ExploitPlayer { + final private ExploitPlayerManager exploitPlayerManager; + final private MessagesModule messagesModule; + final private NotificationsModule notificationsModule; + final private Map violations = new HashMap<>(); + final private String name; + private String onlineUUID = null; + private boolean logged = false; + private int channels = 0; + private double lastViolation = 0; + + public ExploitPlayer(final String name, final ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.messagesModule = moduleManager.getMessagesModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.name = name; + } + + public void clearChannels() { + this.channels = 0; + } + + public int addChannels(final int channels) { + return this.channels += channels; + } + + public double getViolations(final Module module) { + if (module instanceof ViolationModule) { + return violations.getOrDefault(module, 0D); + } else { + return 0D; + } + } + + public String getOnlineUUID() { + if (onlineUUID == null) { + try { + final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) + .openConnection(); + + connection.setDoOutput(true); + connection.connect(); + + final BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(connection.getInputStream())); + final StringBuilder response = new StringBuilder(); + + String inputLine; + + while ((inputLine = bufferedReader.readLine()) != null) + response.append(inputLine).append("\n"); + + bufferedReader.close(); + onlineUUID = response.toString(); + } catch (Exception ignored) { + } + } + + return onlineUUID; + } + + public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer player, + final ViolationModule module, final double amount) { + if (player.isConnected()) { + final Violations violations = (Violations) module.getViolations(); + + if (violations != null) { + final ProxyServer server = plugin.getProxy(); + final double currentTime = System.currentTimeMillis(); + final Locale locale = player.getLocale(); + String lang = null; + + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; + + for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { + final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); + + if (vls <= 0) + this.violations.remove(violationModule); + else + this.violations.put(violationModule, vls); + } + } + + final double oldVls = getViolations(module); + final double newVls = oldVls + amount; + + if (locale != null) + lang = locale.toString().substring(0, 2); + + final String kickMessage = messagesModule.getKickMessage(module, lang); + + this.violations.put(module, newVls); + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) + ((Cancellable) event).setCancelled(true); + + for (final int threshold : violations.getViolations()) { + if (threshold > oldVls && threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); + + if (commands != null && !commands.isEmpty()) { + for (final String punishCommand : commands) { + if (!punishCommand.isEmpty()) { + if (punishCommand.equals("kick")) { + player.disconnect(new TextComponent(kickMessage)); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) { + notificationsModule.sendNotification(module.getName(), player, (int) newVls); + } else { + server.getPluginManager().dispatchCommand(server.getConsole(), + punishCommand.replace("%player%", player.getName())); + } + } + } + } + } + } + } + } else if (event instanceof Cancellable) { + ((Cancellable) event).setCancelled(true); + } + } + + public void clearViolations() { + violations.clear(); + } + + public void setLogged(final boolean logged) { + this.logged = logged; + } + + public boolean isLogged() { + return logged; + } +} diff --git a/src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java b/src/twolovers/exploitfixer/bungee/instanceables/Violations.java similarity index 68% rename from src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java rename to src/twolovers/exploitfixer/bungee/instanceables/Violations.java index fefa3d6..58f5421 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/BungeeViolations.java +++ b/src/twolovers/exploitfixer/bungee/instanceables/Violations.java @@ -1,31 +1,29 @@ package twolovers.exploitfixer.bungee.instanceables; -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.instanceables.Violations; - import java.util.Collection; import java.util.HashMap; import java.util.Map; -public class BungeeViolations implements Violations { +import net.md_5.bungee.config.Configuration; + +public class Violations { private Map> violations = new HashMap<>(); - public BungeeViolations(final Configuration configuration) { - if (configuration != null) + public Violations(final Configuration configuration) { + if (configuration != null) { for (final String key : configuration.getKeys()) { try { this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (NumberFormatException ignored) { + } catch (final NumberFormatException ignored) { } } + } } - @Override public Collection getCommands(final int violations) { return this.violations.getOrDefault(violations, null); } - @Override public Collection getViolations() { return violations.keySet(); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index 5a0af12..094ef8e 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -1,15 +1,16 @@ package twolovers.exploitfixer.bungee.listeners; +import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CommandsModule; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.CommandsModule; public class ChatListener implements Listener { private final Plugin plugin; @@ -28,20 +29,27 @@ public void onChat(final ChatEvent event) { final Connection connection = event.getSender(); if (connection instanceof ProxiedPlayer) { - final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), - proxiedPlayer); + final ProxiedPlayer player = (ProxiedPlayer) connection; + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { + final ProxyServer server = plugin.getProxy(); final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String playerName = player.getName(); - for (final String command : commandsModule.getCommands()) + for (final String command : commandsModule.getCommands()) { if (message.startsWith(command + " ") || message.endsWith(command)) { - exploitPlayer.addVls(plugin, event, proxiedPlayer, commandsModule, 1); + for (final String punishment : commandsModule.getPunishments()) { + server.getPluginManager().dispatchCommand(server.getConsole(), + punishment.replace("%player%", playerName)); + } + + event.setCancelled(true); break; } + } } } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java index 54e4bf4..87ad7f8 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java @@ -4,10 +4,10 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; public class DisconnectListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index aa0dfbb..3718dbd 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -1,22 +1,81 @@ package twolovers.exploitfixer.bungee.listeners; +import java.util.logging.Logger; + +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.CustomPayloadModule; public class PluginMessageListener implements Listener { - final private CustomPayloadModule customPayloadModule; + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; - public PluginMessageListener(final ModuleManager moduleManager) { + public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); } @EventHandler(priority = -128) public void onPluginMessage(final PluginMessageEvent event) { - if (!event.isCancelled() && customPayloadModule.isEnabled()) - customPayloadModule.check(event); + if (!event.isCancelled() && customPayloadModule.isEnabled()) { + final Connection connection = event.getSender(); + + if (connection instanceof ProxiedPlayer) { + final Logger logger = plugin.getLogger(); + final ProxiedPlayer player = (ProxiedPlayer) connection; + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final String tag = event.getTag(), playerName = player.getName(); + + if (tag == null || tag.isEmpty()) { + final double tagVls = customPayloadModule.getTagVls(); + + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + return; + } else { + final byte[] data = event.getData(); + final int byteLength = data.length; + + if (byteLength > customPayloadModule.getDataBytes()) { + if (notificationsModule.isDebug()) { + logger.info("[PacketPlayInCustomPayload] Sent by " + playerName + + " got cancelled because its " + byteLength + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getDataVls()); + return; + } else if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + /* + * if (byteLength > customPayloadModule.getBookBytes()) { logger.info(playerName + * + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } + } } } - diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java index 2d48a25..8bd8620 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java @@ -8,12 +8,12 @@ import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; +import twolovers.exploitfixer.bungee.modules.ConnectionModule; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.bungee.modules.MessagesModule; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; import java.net.InetSocketAddress; import java.util.Locale; @@ -21,17 +21,16 @@ public class PostLoginListener implements Listener { private final Plugin plugin; + private final ConnectionModule connectionModule; private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; - private final Module uuidSpoofModule, nullAddressModule; private final ExploitPlayerManager exploitPlayerManager; public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; + this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); - this.uuidSpoofModule = moduleManager.getUUIDSpoofModule(); - this.nullAddressModule = moduleManager.getNullAddressModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @@ -47,13 +46,13 @@ public void onPostLogin(final PostLoginEvent event) { else locale = "en"; - if (nullAddressModule.isEnabled() && (address == null || address.isUnresolved())) { - proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage(nullAddressModule, locale))); + if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { + proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage("nulladdress", locale))); } else { final UUID uuid = proxiedPlayer.getUniqueId(); final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); - if (uuidSpoofModule.isEnabled()) { + if (connectionModule.isUUIDSpoofEnabled()) { final TaskScheduler scheduler = plugin.getProxy().getScheduler(); final String playerName = proxiedPlayer.getName(); @@ -66,7 +65,7 @@ public void onPostLogin(final PostLoginEvent event) { final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage(uuidSpoofModule, locale); + final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); proxiedPlayer.disconnect(new TextComponent(uuidSpoofKickMessage)); } diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java deleted file mode 100644 index b9f561d..0000000 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeModuleManager.java +++ /dev/null @@ -1,81 +0,0 @@ -package twolovers.exploitfixer.bungee.managers; - -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.modules.*; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.*; - -public class BungeeModuleManager implements ModuleManager { - private CommandsModule commandsModule; - private CustomPayloadModule customPayloadModule; - private MessagesModule messagesModule; - private NotificationsModule notificationsModule; - private ReloadableModule nullAddressModule, uuidSpoofModule; - private ExploitPlayerManager exploitPlayerManager; - - public BungeeModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { - this.commandsModule = new BungeeCommandsModule(configYml); - this.customPayloadModule = new BungeeCustomPayloadModule(plugin, this, configYml); - this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new BungeeNotificationsModule(configYml); - this.nullAddressModule = new BungeeNullAddressModule(configYml); - this.uuidSpoofModule = new BungeeUUIDSpoofModule(configYml); - this.exploitPlayerManager = new BungeeExploitPlayerManager(plugin.getProxy(), this); - } - - @Override - public void reload(final Object configYml, final Object messagesYml, final Object spigotYml) { - this.commandsModule.reload(configYml); - this.customPayloadModule.reload(configYml); - this.messagesModule.reload(messagesYml); - this.notificationsModule.reload(configYml); - this.exploitPlayerManager.reload(); - } - - @Override - public CommandsModule getCommandsModule() { - return commandsModule; - } - - @Override - public CustomPayloadModule getCustomPayloadModule() { - return customPayloadModule; - } - - @Override - public ItemsFixModule getItemsFixModule() { - return null; - } - - @Override - public MessagesModule getMessagesModule() { - return messagesModule; - } - - @Override - public NotificationsModule getNotificationsModule() { - return notificationsModule; - } - - @Override - public ExploitPlayerManager getExploitPlayerManager() { - return exploitPlayerManager; - } - - @Override - public PacketsModule getPacketsModule() { - return null; - } - - @Override - public ReloadableModule getNullAddressModule() { - return nullAddressModule; - } - - @Override - public ReloadableModule getUUIDSpoofModule() { - return uuidSpoofModule; - } -} diff --git a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java b/src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java similarity index 66% rename from src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java rename to src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java index 5114240..aa81dc6 100644 --- a/src/twolovers/exploitfixer/bungee/managers/BungeeExploitPlayerManager.java +++ b/src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -1,85 +1,76 @@ -package twolovers.exploitfixer.bungee.managers; - -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import twolovers.exploitfixer.bungee.instanceables.BungeeExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.managers.ExploitPlayerManager; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import java.util.logging.Level; - -public class BungeeExploitPlayerManager implements ExploitPlayerManager { - private final ProxyServer proxy; - private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); - private int punishments = 0; - - BungeeExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { - this.proxy = proxy; - this.moduleManager = moduleManager; - - reload(); - } - - @Override - public int getSize() { - return exploitPlayers.size(); - } - - @Override - public int getPunishments() { - return punishments; - } - - @Override - public ExploitPlayer get(final UUID uuid, final Object playerObject) { - ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); - - if (exploitPlayer == null) { - exploitPlayer = new BungeeExploitPlayer(((ProxiedPlayer) playerObject).getName(), moduleManager); - exploitPlayers.put(uuid, exploitPlayer); - } - - return exploitPlayer; - } - - @Override - public int addPunishment() { - return ++punishments; - } - - @Override - public void reload() { - exploitPlayers.clear(); - - for (final ProxiedPlayer player : proxy.getPlayers()) { - final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); - - exploitPlayer.setLogged(true); - } - } - - @Override - public void clear() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean cleared = false; - - while (iterator.hasNext()) { - final UUID uuid = iterator.next(); - - if (proxy.getPlayer(uuid) == null) { - iterator.remove(); - cleared = true; - } - } - - if (cleared) { - proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); - } - } -} +package twolovers.exploitfixer.bungee.managers; + +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; +import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.logging.Level; + +public class ExploitPlayerManager { + private final ProxyServer proxy; + private final ModuleManager moduleManager; + private final Map exploitPlayers = new HashMap<>(); + private int punishments = 0; + + ExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { + this.proxy = proxy; + this.moduleManager = moduleManager; + + reload(); + } + + public int getSize() { + return exploitPlayers.size(); + } + + public int getPunishments() { + return punishments; + } + + public ExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { + ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + + if (exploitPlayer == null) { + exploitPlayer = new ExploitPlayer(player.getName(), moduleManager); + exploitPlayers.put(uuid, exploitPlayer); + } + + return exploitPlayer; + } + + public int addPunishment() { + return ++punishments; + } + + public void reload() { + exploitPlayers.clear(); + + for (final ProxiedPlayer player : proxy.getPlayers()) { + final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + + exploitPlayer.setLogged(true); + } + } + + public void clear() { + final Iterator iterator = exploitPlayers.keySet().iterator(); + boolean cleared = false; + + while (iterator.hasNext()) { + final UUID uuid = iterator.next(); + + if (proxy.getPlayer(uuid) == null) { + iterator.remove(); + cleared = true; + } + } + + if (cleared) { + proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + } + } +} diff --git a/src/twolovers/exploitfixer/bungee/managers/ModuleManager.java b/src/twolovers/exploitfixer/bungee/managers/ModuleManager.java new file mode 100644 index 0000000..c012635 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/managers/ModuleManager.java @@ -0,0 +1,57 @@ +package twolovers.exploitfixer.bungee.managers; + +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.bungee.modules.*; +import twolovers.exploitfixer.bungee.managers.ModuleManager; + +public class ModuleManager { + private CommandsModule commandsModule; + private final ConnectionModule connectionModule; + private CustomPayloadModule customPayloadModule; + private MessagesModule messagesModule; + private NotificationsModule notificationsModule; + private ExploitPlayerManager exploitPlayerManager; + + public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { + this.commandsModule = new CommandsModule(configYml); + this.connectionModule = new ConnectionModule(configYml); + this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); + this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new NotificationsModule(plugin.getProxy().getConsole(), configYml); + this.exploitPlayerManager = new ExploitPlayerManager(plugin.getProxy(), this); + } + + public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) { + this.commandsModule.reload(configYml); + this.connectionModule.reload(configYml); + this.customPayloadModule.reload(configYml); + this.messagesModule.reload(messagesYml); + this.notificationsModule.reload(configYml); + this.exploitPlayerManager.reload(); + } + + public CommandsModule getCommandsModule() { + return commandsModule; + } + + public ConnectionModule getConnectionModule() { + return connectionModule; + } + + public CustomPayloadModule getCustomPayloadModule() { + return customPayloadModule; + } + + public MessagesModule getMessagesModule() { + return messagesModule; + } + + public NotificationsModule getNotificationsModule() { + return notificationsModule; + } + + public ExploitPlayerManager getExploitPlayerManager() { + return exploitPlayerManager; + } +} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java deleted file mode 100644 index b0f4cf7..0000000 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCommandsModule.java +++ /dev/null @@ -1,61 +0,0 @@ -package twolovers.exploitfixer.bungee.modules; - -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.BungeeViolations; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.modules.CommandsModule; - -import java.util.Collection; - -public class BungeeCommandsModule implements CommandsModule { - private Collection commands; - private boolean enabled; - private double cancelVls, reduceVls; - private Violations violations; - - public BungeeCommandsModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "Commands"; - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - final public Collection getCommands() { - return commands; - } - - @Override - public void reload(Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean(name + ".enabled"); - this.cancelVls = configYml1.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.violations = new BungeeViolations(configYml1.getSection(name + ".violations")); - this.commands = configYml1.getStringList("commands.commands"); - } -} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java deleted file mode 100644 index b38f01e..0000000 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeCustomPayloadModule.java +++ /dev/null @@ -1,109 +0,0 @@ -package twolovers.exploitfixer.bungee.modules; - -import com.google.common.base.Charsets; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PluginMessageEvent; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.BungeeViolations; -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; -import twolovers.exploitfixer.interfaces.instanceables.Violations; -import twolovers.exploitfixer.interfaces.managers.ModuleManager; -import twolovers.exploitfixer.interfaces.modules.CustomPayloadModule; - -import java.util.HashMap; -import java.util.Map; - -public class BungeeCustomPayloadModule implements CustomPayloadModule { - private Map multipliers = new HashMap<>(); - private Plugin plugin; - private ModuleManager moduleManager; - private Violations violations; - private int maxChannelsAmount, bigDataMaxBytes; - private double cancelVls, reduceVls, maxChannelsVls, bigDataVls; - private boolean enabled; - - public BungeeCustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Object configYml) { - this.plugin = plugin; - this.moduleManager = moduleManager; - - reload(configYml); - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - public String getName() { - return "CustomPayload"; - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public void reload(final Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - final Configuration configurationSection = configYml1.getSection("custompayload.multipliers"); - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean("custompayload.enabled"); - this.cancelVls = configYml1.getDouble("custompayload.cancel_vls"); - this.reduceVls = configYml1.getDouble(name + ".reduce_vls"); - this.violations = new BungeeViolations(configYml1.getSection("custompayload.violations")); - this.maxChannelsVls = configYml1.getDouble(name + ".invalid.max_channels.vls"); - this.maxChannelsAmount = configYml1.getInt(name + ".invalid.max_channels.amount"); - this.bigDataVls = configYml1.getDouble(name + ".invalid.big_data.vls"); - this.bigDataMaxBytes = configYml1.getInt(name + ".invalid.big_data.max_bytes"); - - for (final String key : configurationSection.getKeys()) - multipliers.put(key, configurationSection.getDouble(key)); - } - - @Override - public void check(final Object event) { - if (event instanceof PluginMessageEvent) { - final PluginMessageEvent pluginMessageEvent = (PluginMessageEvent) event; - final Connection sender = pluginMessageEvent.getSender(); - - if (sender instanceof ProxiedPlayer && sender.isConnected()) { - final String tag = pluginMessageEvent.getTag(); - - if (tag != null) { - final String content = new String(pluginMessageEvent.getData(), Charsets.UTF_8); - final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender; - final ExploitPlayer exploitPlayer = moduleManager.getExploitPlayerManager() - .get(proxiedPlayer.getUniqueId(), proxiedPlayer); - - if (tag.toLowerCase().endsWith("register") - && exploitPlayer.addChannels(content.split("[\u0001-\u0009]").length) > maxChannelsAmount) { - exploitPlayer.addVls(plugin, event, sender, this, - multipliers.getOrDefault("MAX_CHANNELS", maxChannelsVls)); - } else if (content.length() > bigDataMaxBytes) { - exploitPlayer.addVls(plugin, event, sender, this, multipliers.getOrDefault(tag, bigDataVls)); - } else { - exploitPlayer.addVls(plugin, event, sender, this, - multipliers.getOrDefault(tag, multipliers.getOrDefault("OTHER", 1D))); - } - } else { - pluginMessageEvent.setCancelled(true); - } - } - } - } -} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java deleted file mode 100644 index 3e804c8..0000000 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNotificationsModule.java +++ /dev/null @@ -1,64 +0,0 @@ -package twolovers.exploitfixer.bungee.modules; - -import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.modules.NotificationsModule; - -import java.util.Collection; -import java.util.HashSet; - -public class BungeeNotificationsModule implements NotificationsModule { - private final Collection notifications = new HashSet<>(); - private boolean enabled; - private String message; - - public BungeeNotificationsModule(final Object configYml) { - reload(configYml); - } - - @Override - public final void setNotifications(final Object player, final boolean input) { - if (input) - notifications.add(player); - else - notifications.remove(player); - } - - @Override - public final boolean isNotifications(final Object player) { - return notifications.contains(player); - } - - @Override - public void sendNotification(final String check, final Object player, final int violations) { - if (enabled && player != null) { - final ProxiedPlayer player1 = (ProxiedPlayer) player; - final TextComponent notification = new TextComponent(message - .replace("%player%", player1.getName()) - .replace("%check%", check) - .replace("%ping%", String.valueOf(player1.getPing())) - .replace("%vls%", String.valueOf(violations))); - - BungeeCord.getInstance().getConsole().sendMessage(notification); - - for (final Object proxiedPlayer1 : getNotifications()) - ((ProxiedPlayer) proxiedPlayer1).sendMessage(notification); - } - } - - @Override - public final Collection getNotifications() { - return notifications; - } - - @Override - public void reload(Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - - enabled = configYml1.getBoolean("notifications.enabled"); - message = ChatColor.translateAlternateColorCodes('&', configYml1.getString("notifications.message")); - } -} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java deleted file mode 100644 index 17501f7..0000000 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeNullAddressModule.java +++ /dev/null @@ -1,30 +0,0 @@ -package twolovers.exploitfixer.bungee.modules; - -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.modules.ReloadableModule; - -public class BungeeNullAddressModule implements ReloadableModule { - private boolean enabled; - - public BungeeNullAddressModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "NullAddress"; - } - - @Override - public void reload(Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean("connection." + name); - } -} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java b/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java deleted file mode 100644 index 2dbf60b..0000000 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeUUIDSpoofModule.java +++ /dev/null @@ -1,30 +0,0 @@ -package twolovers.exploitfixer.bungee.modules; - -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.modules.ReloadableModule; - -public class BungeeUUIDSpoofModule implements ReloadableModule { - private boolean enabled; - - public BungeeUUIDSpoofModule(final Object configYml) { - reload(configYml); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "UUIDSpoof"; - } - - @Override - public void reload(Object configYml) { - final Configuration configYml1 = (Configuration) configYml; - final String name = getName().toLowerCase(); - - this.enabled = configYml1.getBoolean("connection." + name); - } -} diff --git a/src/twolovers/exploitfixer/bungee/modules/CommandsModule.java b/src/twolovers/exploitfixer/bungee/modules/CommandsModule.java new file mode 100644 index 0000000..4842985 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/modules/CommandsModule.java @@ -0,0 +1,41 @@ +package twolovers.exploitfixer.bungee.modules; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.shared.interfaces.PunishmentModule; + +import java.util.Collection; + +public class CommandsModule implements PunishmentModule { + private Collection commands, punishments; + private String name; + private boolean enabled; + + public CommandsModule(final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + this.name = "Commands"; + this.enabled = configYml.getBoolean("commands.enabled"); + this.commands = configYml.getStringList("commands.commands"); + this.punishments = configYml.getStringList("commands.punishments"); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return this.name; + } + + public final Collection getCommands() { + return commands; + } + + public final Collection getPunishments() { + return punishments; + } +} diff --git a/src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java b/src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java new file mode 100644 index 0000000..0f8dfb2 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java @@ -0,0 +1,47 @@ +package twolovers.exploitfixer.bungee.modules; + +import java.util.Collection; +import java.util.HashSet; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.shared.interfaces.PunishmentModule; + +public class ConnectionModule implements PunishmentModule { + private boolean uuidSpoofEnabled, nullAddressEnabled; + private String name; + private Collection punishments; + + public ConnectionModule(final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof"); + this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress"); + this.name = "UUID-Spoof"; + this.punishments = new HashSet<>(configYml.getStringList("connection.punishments")); + } + + public boolean isUUIDSpoofEnabled() { + return uuidSpoofEnabled; + } + + public boolean isNullAddressEnabled() { + return nullAddressEnabled; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public Collection getPunishments() { + return this.punishments; + } +} diff --git a/src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java new file mode 100644 index 0000000..141afce --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java @@ -0,0 +1,100 @@ +package twolovers.exploitfixer.bungee.modules; + +import java.util.HashMap; +import java.util.Map; + +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.bungee.instanceables.Violations; +import twolovers.exploitfixer.bungee.managers.ModuleManager; +import twolovers.exploitfixer.shared.interfaces.ViolationModule; + +public class CustomPayloadModule implements ViolationModule { + private Map multipliers = new HashMap<>(); + private Violations violations; + private int channelAmount, dataBytes, bookBytes; + private double cancelVls, reduceVls, bookVls, channelVls, dataVls, tagVls; + private boolean enabled; + + public CustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { + reload(configYml); + } + + public void reload(final Configuration configYml) { + final Configuration configurationSection = configYml.getSection("custompayload.multipliers"); + final String name = getName().toLowerCase(); + + this.enabled = configYml.getBoolean(name + ".enabled"); + this.cancelVls = configYml.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml.getDouble(name + ".reduce_vls"); + this.bookVls = configYml.getDouble(name + ".book.vls"); + this.bookBytes = configYml.getInt(name + ".book.bytes"); + this.violations = new Violations(configYml.getSection(name + ".violations")); + this.channelVls = configYml.getDouble(name + ".channel.vls"); + this.channelAmount = configYml.getInt(name + ".channel.amount"); + this.dataVls = configYml.getDouble(name + ".data.vls"); + this.dataBytes = configYml.getInt(name + ".data.bytes"); + this.tagVls = configYml.getDouble(name + ".tag.vls"); + + for (final String key : configurationSection.getKeys()) { + multipliers.put(key, configurationSection.getDouble(key)); + } + } + + @Override + public double getCancelVls() { + return cancelVls; + } + + @Override + public double getReduceVls() { + return reduceVls; + } + + @Override + public Violations getViolations() { + return violations; + } + + @Override + public String getName() { + return "CustomPayload"; + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + public double getMultiplier(final String packetName) { + return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); + } + + public double getTagVls() { + return this.tagVls; + } + + public double getBookVls() { + return this.bookVls; + } + + public double getChannelVls() { + return this.channelVls; + } + + public double getDataVls() { + return this.dataVls; + } + + public int getBookBytes() { + return this.bookBytes; + } + + public int getDataBytes() { + return this.dataBytes; + } + + public int getChannelAmount() { + return this.channelAmount; + } +} diff --git a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/twolovers/exploitfixer/bungee/modules/MessagesModule.java similarity index 69% rename from src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java rename to src/twolovers/exploitfixer/bungee/modules/MessagesModule.java index d651eed..744c3b8 100644 --- a/src/twolovers/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/twolovers/exploitfixer/bungee/modules/MessagesModule.java @@ -1,91 +1,76 @@ -package twolovers.exploitfixer.bungee.modules; - -import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.interfaces.modules.MessagesModule; -import twolovers.exploitfixer.interfaces.modules.Module; - -public class BungeeMessagesModule implements MessagesModule { - private Configuration messagesYml; - private String version; - - public BungeeMessagesModule(final String version, final Configuration messagesYml) { - reload(messagesYml); - this.version = version; - } - - @Override - public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) - string = messagesYml.getString("en" + path); - - if (string != null) - string = string.replace("&", "\u00A7"); - else - string = ""; - - return string; - } - - @Override - public final String getReload(final String locale) { - return getString(locale, ".commands.reload"); - } - - @Override - public final String getHelp(final String locale) { - return getString(locale, ".commands.help") - .replace("%version%", version); - } - - @Override - public final String getUnknown(final String locale) { - return getString(locale, ".commands.error.unknown"); - } - - @Override - public final String getPermission(final String locale) { - return getString(locale, ".commands.error.permission"); - } - - @Override - public final String getConsole(final String locale) { - return getString(locale, ".commands.error.console"); - } - - @Override - public final String getEnable(final String locale) { - return getString(locale, ".commands.notifications.enable"); - } - - @Override - public final String getDisable(final String locale) { - return getString(locale, ".commands.notifications.disable"); - } - - @Override - public final String getKickMessage(final Module module, final String locale) { - return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); - } - - @Override - public void reload(Object messagesYml) { - this.messagesYml = (Configuration) messagesYml; - } - - @Override - public String getStats(String locale) { - return getString(locale, ".modules.stats.message"); - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getName() { - return "Messages"; - } +package twolovers.exploitfixer.bungee.modules; + +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.shared.interfaces.Module; + +public class MessagesModule { + private Configuration messagesYml; + private String version; + + public MessagesModule(final String version, final Configuration messagesYml) { + reload(messagesYml); + this.version = version; + } + + public String getString(final String locale, final String path) { + String string = messagesYml.getString(locale + path); + + if (string == null || string.isEmpty()) + string = messagesYml.getString("en" + path); + + if (string != null) + string = string.replace("&", "\u00A7"); + else + string = ""; + + return string; + } + + public final String getReload(final String locale) { + return getString(locale, ".commands.reload"); + } + + public final String getHelp(final String locale) { + return getString(locale, ".commands.help").replace("%version%", version); + } + + public final String getUnknown(final String locale) { + return getString(locale, ".commands.error.unknown"); + } + + public final String getPermission(final String locale) { + return getString(locale, ".commands.error.permission"); + } + + public final String getConsole(final String locale) { + return getString(locale, ".commands.error.console"); + } + + public final String getEnable(final String locale) { + return getString(locale, ".commands.notifications.enable"); + } + + public final String getDisable(final String locale) { + return getString(locale, ".commands.notifications.disable"); + } + + public final String getKickMessage(final Module module, final String locale) { + return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); + } + + public final String getKickMessage(final String module, final String locale) { + return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); + } + + public void reload(final Configuration messagesYml) { + this.messagesYml = messagesYml; + } + + public String getStats(String locale) { + return getString(locale, ".modules.stats.message"); + } + + public String getName() { + return "Messages"; + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java b/src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java new file mode 100644 index 0000000..dfd99a2 --- /dev/null +++ b/src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java @@ -0,0 +1,73 @@ +package twolovers.exploitfixer.bungee.modules; + +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.config.Configuration; +import twolovers.exploitfixer.shared.interfaces.Module; + +import java.util.Collection; +import java.util.HashSet; + +public class NotificationsModule implements Module { + private final CommandSender console; + private final Collection notifications = new HashSet<>(); + private boolean enabled, debug; + private String message; + + public NotificationsModule(final CommandSender console, final Configuration configYml) { + this.console = console; + reload(configYml); + } + + @Override + public boolean isEnabled() { + return this.enabled; + } + + public boolean isDebug() { + return this.debug; + } + + public final void setNotifications(final ProxiedPlayer player, final boolean input) { + if (input) { + notifications.add(player); + } else { + notifications.remove(player); + } + } + + public final boolean isNotifications(final ProxiedPlayer player) { + return notifications.contains(player); + } + + public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { + if (enabled && player != null) { + final TextComponent notification = new TextComponent(message.replace("%player%", player.getName()) + .replace("%check%", check).replace("%ping%", String.valueOf(player.getPing())) + .replace("%vls%", String.valueOf(violations))); + + console.sendMessage(notification); + + for (final ProxiedPlayer player1 : getNotifications()) { + player1.sendMessage(notification); + } + } + } + + public final Collection getNotifications() { + return notifications; + } + + public void reload(final Configuration configYml) { + this.enabled = configYml.getBoolean("notifications.enabled"); + this.debug = configYml.getBoolean("notifications.debug"); + this.message = ChatColor.translateAlternateColorCodes('&', configYml.getString("notifications.message")); + } + + @Override + public String getName() { + return "Notifications"; + } +} diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java deleted file mode 100644 index f04684f..0000000 --- a/src/twolovers/exploitfixer/interfaces/instanceables/ExploitPlayer.java +++ /dev/null @@ -1,22 +0,0 @@ -package twolovers.exploitfixer.interfaces.instanceables; - -import twolovers.exploitfixer.interfaces.modules.CancellableModule; -import twolovers.exploitfixer.interfaces.modules.Module; - -public interface ExploitPlayer { - void clearChannels(); - - int addChannels(final int channels); - - double getViolations(final Module module); - - String getOnlineUUID(); - - void addVls(final Object plugin, final Object event, final Object player, final CancellableModule module, final double amount); - - void clearViolations(); - - void setLogged(final boolean logged); - - boolean isLogged(); -} diff --git a/src/twolovers/exploitfixer/interfaces/instanceables/Violations.java b/src/twolovers/exploitfixer/interfaces/instanceables/Violations.java deleted file mode 100644 index 96800d6..0000000 --- a/src/twolovers/exploitfixer/interfaces/instanceables/Violations.java +++ /dev/null @@ -1,9 +0,0 @@ -package twolovers.exploitfixer.interfaces.instanceables; - -import java.util.Collection; - -public interface Violations { - Collection getCommands(final int violations); - - Collection getViolations(); -} diff --git a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java b/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java deleted file mode 100644 index 5dc601f..0000000 --- a/src/twolovers/exploitfixer/interfaces/managers/ExploitPlayerManager.java +++ /dev/null @@ -1,20 +0,0 @@ -package twolovers.exploitfixer.interfaces.managers; - -import twolovers.exploitfixer.interfaces.instanceables.ExploitPlayer; - -import java.util.UUID; - -public interface ExploitPlayerManager { - - ExploitPlayer get(final UUID uuid, final Object playerObject); - - int getSize(); - - int getPunishments(); - - int addPunishment(); - - void clear(); - - void reload(); -} diff --git a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java b/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java deleted file mode 100644 index 27adfbb..0000000 --- a/src/twolovers/exploitfixer/interfaces/managers/ModuleManager.java +++ /dev/null @@ -1,25 +0,0 @@ -package twolovers.exploitfixer.interfaces.managers; - -import twolovers.exploitfixer.interfaces.modules.*; - -public interface ModuleManager { - void reload(final Object configYml, final Object messagesYml, final Object spigotYml); - - CommandsModule getCommandsModule(); - - CustomPayloadModule getCustomPayloadModule(); - - ItemsFixModule getItemsFixModule(); - - MessagesModule getMessagesModule(); - - NotificationsModule getNotificationsModule(); - - ReloadableModule getUUIDSpoofModule(); - - ExploitPlayerManager getExploitPlayerManager(); - - PacketsModule getPacketsModule(); - - ReloadableModule getNullAddressModule(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java b/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java deleted file mode 100644 index 27d8b58..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/CancellableModule.java +++ /dev/null @@ -1,11 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -import twolovers.exploitfixer.interfaces.instanceables.Violations; - -public interface CancellableModule extends ReloadableModule { - double getCancelVls(); - - double getReduceVls(); - - Violations getViolations(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java b/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java deleted file mode 100644 index 00012e8..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/CommandsModule.java +++ /dev/null @@ -1,7 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -import java.util.Collection; - -public interface CommandsModule extends CancellableModule { - Collection getCommands(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java b/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java deleted file mode 100644 index 4b71ea1..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/CustomPayloadModule.java +++ /dev/null @@ -1,5 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface CustomPayloadModule extends CancellableModule { - void check(final Object packetEvent); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java deleted file mode 100644 index 506cd80..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/ItemsFixModule.java +++ /dev/null @@ -1,11 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -import org.bukkit.inventory.ItemStack; - -public interface ItemsFixModule extends ReloadableModule { - int getEnchantLimit(); - - int getMaxStackSize(); - - ItemStack fixItemStack(final ItemStack itemStack); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java b/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java deleted file mode 100644 index 82821ef..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/MessagesModule.java +++ /dev/null @@ -1,23 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface MessagesModule extends ReloadableModule { - String getString(final String locale, final String path); - - String getReload(final String locale); - - String getHelp(final String locale); - - String getUnknown(final String locale); - - String getPermission(final String locale); - - String getConsole(final String locale); - - String getEnable(final String locale); - - String getDisable(final String locale); - - String getKickMessage(final Module module, String locale); - - String getStats(String lang); -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/interfaces/modules/Module.java b/src/twolovers/exploitfixer/interfaces/modules/Module.java deleted file mode 100644 index 5f00a7a..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/Module.java +++ /dev/null @@ -1,7 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface Module { - boolean isEnabled(); - - String getName(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java b/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java deleted file mode 100644 index 97bb63f..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/NotificationsModule.java +++ /dev/null @@ -1,15 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -import java.util.Collection; - -public interface NotificationsModule { - void setNotifications(final Object player, final boolean input); - - boolean isNotifications(final Object player); - - void sendNotification(final String check, final Object player, final int vls); - - Collection getNotifications(); - - void reload(Object configYml); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java b/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java deleted file mode 100644 index 6813777..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/PacketsModule.java +++ /dev/null @@ -1,17 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface PacketsModule extends CancellableModule { - void check(final Object packetEvent); - - double getMultiplier(final String packetName); - - double getWindowClick(); - - double getSetCreativeSlot(); - - double getBlockPlace(); - - double getBlockDig(); - - boolean isOffline(); -} diff --git a/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java b/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java deleted file mode 100644 index 446ff8b..0000000 --- a/src/twolovers/exploitfixer/interfaces/modules/ReloadableModule.java +++ /dev/null @@ -1,5 +0,0 @@ -package twolovers.exploitfixer.interfaces.modules; - -public interface ReloadableModule extends Module { - void reload(Object configYml); -} diff --git a/src/twolovers/exploitfixer/shared/interfaces/Module.java b/src/twolovers/exploitfixer/shared/interfaces/Module.java new file mode 100644 index 0000000..ad54c8c --- /dev/null +++ b/src/twolovers/exploitfixer/shared/interfaces/Module.java @@ -0,0 +1,7 @@ +package twolovers.exploitfixer.shared.interfaces; + +public interface Module { + public boolean isEnabled(); + + public String getName(); +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java b/src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java new file mode 100644 index 0000000..8626cf8 --- /dev/null +++ b/src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java @@ -0,0 +1,7 @@ +package twolovers.exploitfixer.shared.interfaces; + +import java.util.Collection; + +public interface PunishmentModule extends Module { + public Collection getPunishments(); +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java b/src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java new file mode 100644 index 0000000..212b64d --- /dev/null +++ b/src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java @@ -0,0 +1,9 @@ +package twolovers.exploitfixer.shared.interfaces; + +public interface ViolationModule extends Module { + public double getCancelVls(); + + public double getReduceVls(); + + public Object getViolations(); +} \ No newline at end of file From f0f102711dc738165ebfd9e273e49ec503a403ae Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 May 2020 23:21:47 -0300 Subject: [PATCH 057/336] Updated source --- src/bungee.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bungee.yml b/src/bungee.yml index d4e36b2..27bf495 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.2.8 +version: 1.3.0 author: 2LS commands: exploitfixer: From aea4cd9fcc1cc4b935d213595ed6516ef475a24c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 May 2020 00:10:41 -0300 Subject: [PATCH 058/336] Updated source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../bukkit/instanceables/ExploitPlayer.java | 19 +++-- .../listeners/ExploitFixerDecodeListener.java | 75 ++++++++++--------- .../initializers/ListenerInitializer.java | 13 +++- .../listeners/PluginMessageListener.java | 5 +- 6 files changed, 68 insertions(+), 48 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 27bf495..4a175d7 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.3.0 +version: 1.3.1 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 5376cb6..7b16313 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.3.0 +version: 1.3.1 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 9234e6b..6c03360 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -15,6 +15,7 @@ import org.bukkit.plugin.Plugin; import hamsterapi.adapters.HamsterPlayer; +import hamsterapi.enums.PacketType; import hamsterapi.wrappers.EventWrapper; import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; import twolovers.exploitfixer.bukkit.managers.ModuleManager; @@ -138,13 +139,21 @@ public void addVls(final Plugin plugin, final Object event, final Player player, hamsterPlayer.abort(); exploitPlayerManager.addPunishment(); } else if (punishCommand.equals("notification")) { + final String moduleName = module.getName(); + if (event instanceof EventWrapper) { - notificationsModule.sendNotification( - ((EventWrapper) event).getPacket().getType().toString(), player, - (int) newVls); + final PacketType packetType = ((EventWrapper) event).getPacket().getType(); + final String name; + + if (packetType != null) { + name = packetType.toString(); + } else { + name = moduleName; + } + + notificationsModule.sendNotification(name, player, (int) newVls); } else { - notificationsModule.sendNotification(module.getName(), player, - (int) newVls); + notificationsModule.sendNotification(moduleName, player, (int) newVls); } } else { server.getScheduler().runTask(plugin, () -> { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java index 0b51fc1..b148ab1 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java @@ -117,7 +117,7 @@ public void onPacketDecode(final EventWrapper event) { event.setCancelled(true); exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); return; - } else if (items.containsKey("b")) { + } else if (itemsFixModule.isEnabled() && items.containsKey("b")) { final ItemStack itemStack = itemsFixModule.fixItem(items.get("b")); packetWrapper.write("b", itemStack); @@ -177,44 +177,49 @@ && checkSign(strings.values().toArray(new String[0]))) { } if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { - final String tag = strings.get("a"); - final double tagVls = customPayloadModule.getTagVls(), - bookVls = customPayloadModule.getBookVls(); + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = customPayloadModule.getTagVls(), + bookVls = customPayloadModule.getBookVls(); - if (tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } + if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info( + playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); - return; - } else { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory - .getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " tried to send a " + tag - + " custompayload packet without a book in hand!"); - } + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + return; + } else { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory + .getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " tried to send a " + tag + + " custompayload packet without a book in hand!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, bookVls); + return; + } /* + * else if (byteLength > customPayloadModule.getBookBytes()) { + * logger.info(playerName + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, bookVls); - return; - } /* - * else if (byteLength > customPayloadModule.getBookBytes()) { - * logger.info(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getMultiplier(tag)); } - - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getMultiplier(tag)); + } else { + event.setCancelled(true); } } } else { diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index 1d46f6d..b279aaa 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -31,9 +31,10 @@ public void start() { final Logger logger = this.plugin.getLogger(); final Server server = this.plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); if (pluginManager.isPluginEnabled("HamsterAPI")) { + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + decodeEventHandler.addListener(exploitFixerDecodeListener); logger.info("Successfully hooked with HamsterAPI!"); } else { @@ -49,9 +50,15 @@ public void start() { } public void stop() { - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + final Server server = this.plugin.getServer(); + final PluginManager pluginManager = server.getPluginManager(); + + if (pluginManager.isPluginEnabled("HamsterAPI")) { + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + + decodeEventHandler.removeListener(exploitFixerDecodeListener); + } - decodeEventHandler.removeListener(exploitFixerDecodeListener); HandlerList.unregisterAll(plugin); } } diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java index 3718dbd..5806969 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -37,10 +37,9 @@ public void onPluginMessage(final PluginMessageEvent event) { final ProxiedPlayer player = (ProxiedPlayer) connection; final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); final String tag = event.getTag(), playerName = player.getName(); + final double tagVls = customPayloadModule.getTagVls(); - if (tag == null || tag.isEmpty()) { - final double tagVls = customPayloadModule.getTagVls(); - + if (tagVls > 0 && tag == null || tag.isEmpty()) { if (notificationsModule.isDebug()) { logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); } From 4dc40779bdf1b97ec7cc3cfa7e89cce17b18f8bd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 May 2020 00:45:42 -0300 Subject: [PATCH 059/336] Updated Source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../listeners/ExploitFixerDecodeListener.java | 9 ++++++ .../listeners/PlayerCommandListener.java | 32 ++++++++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 4a175d7..695de97 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.3.1 +version: 1.3.2 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 7b16313..0a8b228 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.3.1 +version: 1.3.2 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java index b148ab1..2cbdf41 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java @@ -219,14 +219,23 @@ && checkSign(strings.values().toArray(new String[0]))) { customPayloadModule.getMultiplier(tag)); } } else { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent a empty CustomPayload packet!"); + } + event.setCancelled(true); } } } else { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent a packet while offline!"); + } + event.setCancelled(true); event.abort(); } } else { + logger.info("OFFLINEPLAYER sent a packet while offline!"); event.setCancelled(true); event.abort(); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 357b2fe..3f9cad4 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -8,20 +8,28 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.Plugin; +import hamsterapi.adapters.HamsterPlayer; import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; import twolovers.exploitfixer.bukkit.managers.ModuleManager; import twolovers.exploitfixer.bukkit.modules.CommandsModule; +import twolovers.exploitfixer.bukkit.modules.MessagesModule; +import twolovers.exploitfixer.bukkit.modules.NotificationsModule; +import twolovers.exploitfixer.bukkit.utils.VersionUtil; public class PlayerCommandListener implements Listener { private final Plugin plugin; private final CommandsModule commandsModule; private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @@ -39,7 +47,29 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { for (final String command : commandsModule.getCommands()) { if (message.startsWith(command + " ") || message.endsWith(command)) { for (final String punishment : commandsModule.getPunishments()) { - server.dispatchCommand(server.getConsoleSender(), punishment.replace("%player%", playerName)); + if (command.equals("kick")) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) { + locale = player.getLocale().substring(0, 2); + } else { + locale = player.spigot().getLocale().substring(0, 2); + } + + final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); + final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + + hamsterPlayer.kickPlayer(kickMessage); + hamsterPlayer.abort(); + exploitPlayerManager.addPunishment(); + } else if (command.equals("notification")) { + final String moduleName = commandsModule.getName(); + + notificationsModule.sendNotification(moduleName, player, 1); + } else { + server.dispatchCommand(server.getConsoleSender(), + punishment.replace("%player%", playerName)); + } } event.setCancelled(true); From c196a3ad25c373c497bd76b883b81baf22c2e93e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 May 2020 14:22:41 -0300 Subject: [PATCH 060/336] Updated source --- src/bungee.yml | 2 +- src/plugin.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 28 +++++++- .../bukkit/instanceables/ExploitPlayer.java | 66 +++++++++---------- .../listeners/ExploitFixerDecodeListener.java | 5 +- .../listeners/PlayerCommandListener.java | 11 +++- .../initializers/ListenerInitializer.java | 10 +-- .../bungee/listeners/ChatListener.java | 24 ++++++- 8 files changed, 99 insertions(+), 49 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 695de97..f1f6d05 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.3.2 +version: 1.3.3 author: 2LS commands: exploitfixer: diff --git a/src/plugin.yml b/src/plugin.yml index 0a8b228..03f903e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.3.2 +version: 1.3.3 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 14f37b1..00f5d02 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -1,5 +1,7 @@ package twolovers.exploitfixer.bukkit; +import java.util.logging.Logger; + import org.bukkit.Server; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; @@ -31,7 +33,11 @@ public void onEnable() { exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); - this.listenerInitializer = new ListenerInitializer(this, moduleManager); + + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { + this.listenerInitializer = new ListenerInitializer(this, moduleManager); + } + server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); VersionUtil.init(); @@ -50,12 +56,22 @@ public void onDisable() { final BukkitScheduler scheduler = server.getScheduler(); scheduler.cancelTasks(this); - this.listenerInitializer.stop(); + + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { + this.listenerInitializer.stop(); + } else { + final Logger logger = this.getLogger(); + + for (int i = 0; i < 10; i++) { + logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); + } + } } public void reload() { if (isEnabled()) { final Server server = getServer(); + final Logger logger = server.getLogger(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); server.getMessenger().unregisterIncomingPluginChannel(this); @@ -68,7 +84,13 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); - this.listenerInitializer.start(); + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { + this.listenerInitializer.start(); + } else { + for (int i = 0; i < 10; i++) { + logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); + } + } getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 6c03360..63ade88 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -123,44 +123,42 @@ public void addVls(final Plugin plugin, final Object event, final Player player, if (commands != null && !commands.isEmpty()) { for (final String punishCommand : commands) { - if (!punishCommand.isEmpty()) { - if (punishCommand.equals("kick")) { - final String locale; - - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); - - final String kickMessage = messagesModule.getKickMessage(module, locale); - final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); - - hamsterPlayer.kickPlayer(kickMessage); - hamsterPlayer.abort(); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) { - final String moduleName = module.getName(); - - if (event instanceof EventWrapper) { - final PacketType packetType = ((EventWrapper) event).getPacket().getType(); - final String name; - - if (packetType != null) { - name = packetType.toString(); - } else { - name = moduleName; - } - - notificationsModule.sendNotification(name, player, (int) newVls); + if (punishCommand.equals("kick")) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) + locale = player.getLocale().substring(0, 2); + else + locale = player.spigot().getLocale().substring(0, 2); + + final String kickMessage = messagesModule.getKickMessage(module, locale); + final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + + hamsterPlayer.kickPlayer(kickMessage); + hamsterPlayer.abort(); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) { + final String moduleName = module.getName(); + + if (event instanceof EventWrapper) { + final PacketType packetType = ((EventWrapper) event).getPacket().getType(); + final String name; + + if (packetType != null) { + name = packetType.toString(); } else { - notificationsModule.sendNotification(moduleName, player, (int) newVls); + name = moduleName; } + + notificationsModule.sendNotification(name, player, (int) newVls); } else { - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishCommand.replace("%player%", player.getName())); - }); + notificationsModule.sendNotification(moduleName, player, (int) newVls); } + } else { + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishCommand.replace("%player%", player.getName())); + }); } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java index 2cbdf41..59f83fc 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java @@ -235,7 +235,10 @@ && checkSign(strings.values().toArray(new String[0]))) { event.abort(); } } else { - logger.info("OFFLINEPLAYER sent a packet while offline!"); + if (notificationsModule.isDebug()) { + logger.info("OFFLINEPLAYER sent a packet while offline!"); + } + event.setCancelled(true); event.abort(); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 3f9cad4..f9374bf 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -67,8 +67,15 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { notificationsModule.sendNotification(moduleName, player, 1); } else { - server.dispatchCommand(server.getConsoleSender(), - punishment.replace("%player%", playerName)); + if (server.isPrimaryThread()) { + server.dispatchCommand(server.getConsoleSender(), + punishment.replace("%player%", playerName)); + } else { + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishment.replace("%player%", playerName)); + }); + } } } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index b279aaa..dc90299 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -7,8 +7,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import hamsterapi.HamsterAPI; -import hamsterapi.handlers.DecodeEventHandler; import twolovers.exploitfixer.bukkit.listeners.ExploitFixerDecodeListener; import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; @@ -33,7 +31,9 @@ public void start() { final PluginManager pluginManager = server.getPluginManager(); if (pluginManager.isPluginEnabled("HamsterAPI")) { - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + System.out.println("TEST"); + final hamsterapi.handlers.DecodeEventHandler decodeEventHandler = hamsterapi.HamsterAPI + .getDecodeEventHandler(); decodeEventHandler.addListener(exploitFixerDecodeListener); logger.info("Successfully hooked with HamsterAPI!"); @@ -54,7 +54,9 @@ public void stop() { final PluginManager pluginManager = server.getPluginManager(); if (pluginManager.isPluginEnabled("HamsterAPI")) { - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + // Inline import to prevent errors if HamsterAPI is disabled. + final hamsterapi.handlers.DecodeEventHandler decodeEventHandler = hamsterapi.HamsterAPI + .getDecodeEventHandler(); decodeEventHandler.removeListener(exploitFixerDecodeListener); } diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java index 094ef8e..30aceb2 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java @@ -1,6 +1,7 @@ package twolovers.exploitfixer.bungee.listeners; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -11,16 +12,22 @@ import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; import twolovers.exploitfixer.bungee.managers.ModuleManager; import twolovers.exploitfixer.bungee.modules.CommandsModule; +import twolovers.exploitfixer.bungee.modules.MessagesModule; +import twolovers.exploitfixer.bungee.modules.NotificationsModule; public class ChatListener implements Listener { private final Plugin plugin; private final CommandsModule commandsModule; private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); } @EventHandler(priority = -128) @@ -37,13 +44,24 @@ public void onChat(final ChatEvent event) { } else if (commandsModule.isEnabled()) { final ProxyServer server = plugin.getProxy(); final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - final String playerName = player.getName(); for (final String command : commandsModule.getCommands()) { if (message.startsWith(command + " ") || message.endsWith(command)) { for (final String punishment : commandsModule.getPunishments()) { - server.getPluginManager().dispatchCommand(server.getConsole(), - punishment.replace("%player%", playerName)); + if (punishment.equals("kick")) { + final String locale = player.getLocale().toString().substring(0, 2); + final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); + + player.disconnect(TextComponent.fromLegacyText(kickMessage)); + exploitPlayerManager.addPunishment(); + } else if (punishment.equals("notification")) { + final String moduleName = commandsModule.getName(); + + notificationsModule.sendNotification(moduleName, player, (int) 1); + } else { + server.getPluginManager().dispatchCommand(server.getConsole(), + punishment.replace("%player%", player.getName())); + } } event.setCancelled(true); From 4d4cd3d55e0822d938f57d0f2551e637ba9a2b91 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 May 2020 19:35:48 -0300 Subject: [PATCH 061/336] Updated source --- .../exploitfixer/bukkit/ExploitFixer.java | 23 +++++++++-- .../listeners/ExploitFixerDecodeListener.java | 4 +- .../ExploitFixerPreProcessListener.java | 16 ++++++++ .../HamsterAPIListenerInitializer.java | 40 +++++++++++++++++++ .../initializers/ListenerInitializer.java | 30 -------------- 5 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java create mode 100644 src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java index 00f5d02..4a77622 100644 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java @@ -8,6 +8,7 @@ import org.bukkit.scheduler.BukkitScheduler; import twolovers.exploitfixer.bukkit.commands.ExploitFixerCommand; +import twolovers.exploitfixer.bukkit.listeners.initializers.HamsterAPIListenerInitializer; import twolovers.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; import twolovers.exploitfixer.bukkit.managers.ModuleManager; @@ -18,6 +19,7 @@ public class ExploitFixer extends JavaPlugin { private static ExploitFixer exploitFixer; private ModuleManager moduleManager; private ListenerInitializer listenerInitializer; + private HamsterAPIListenerInitializer hamsterAPIListenerInitializer; @Override public void onEnable() { @@ -33,9 +35,20 @@ public void onEnable() { exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); + this.listenerInitializer = new ListenerInitializer(this, moduleManager); if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.listenerInitializer = new ListenerInitializer(this, moduleManager); + final Logger logger = this.getLogger(); + + this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); + + logger.info("Successfully hooked with HamsterAPI!"); + } else { + final Logger logger = this.getLogger(); + + for (int i = 0; i < 10; i++) { + logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); + } } server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); @@ -57,8 +70,10 @@ public void onDisable() { scheduler.cancelTasks(this); + this.listenerInitializer.stop(); + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.listenerInitializer.stop(); + this.hamsterAPIListenerInitializer.stop(); } else { final Logger logger = this.getLogger(); @@ -84,8 +99,10 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); + this.listenerInitializer.start(); + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.listenerInitializer.start(); + this.hamsterAPIListenerInitializer.start(); } else { for (int i = 0; i < 10; i++) { logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java index 59f83fc..1433d80 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java @@ -226,7 +226,7 @@ && checkSign(strings.values().toArray(new String[0]))) { event.setCancelled(true); } } - } else { + } else if (packetsModule.isOffline()) { if (notificationsModule.isDebug()) { logger.info(playerName + " sent a packet while offline!"); } @@ -234,7 +234,7 @@ && checkSign(strings.values().toArray(new String[0]))) { event.setCancelled(true); event.abort(); } - } else { + } else if (packetsModule.isOffline()) { if (notificationsModule.isDebug()) { logger.info("OFFLINEPLAYER sent a packet while offline!"); } diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java new file mode 100644 index 0000000..e89c89c --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java @@ -0,0 +1,16 @@ +package twolovers.exploitfixer.bukkit.listeners; + +import org.bukkit.plugin.Plugin; + +import hamsterapi.interfaces.PreProcessListener; +import hamsterapi.wrappers.EventWrapper; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; + +public class ExploitFixerPreProcessListener implements PreProcessListener { + public ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { + } + + @Override + public void onPacketPreProcess(final EventWrapper event) { + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java new file mode 100644 index 0000000..a40a859 --- /dev/null +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java @@ -0,0 +1,40 @@ +package twolovers.exploitfixer.bukkit.listeners.initializers; + +import org.bukkit.plugin.Plugin; + +import hamsterapi.HamsterAPI; +import hamsterapi.handlers.DecodeEventHandler; +import hamsterapi.handlers.PreProcessEventHandler; +import twolovers.exploitfixer.bukkit.listeners.ExploitFixerDecodeListener; +import twolovers.exploitfixer.bukkit.listeners.ExploitFixerPreProcessListener; +import twolovers.exploitfixer.bukkit.managers.ModuleManager; + +public class HamsterAPIListenerInitializer { + private final Plugin plugin; + private final ModuleManager moduleManager; + private ExploitFixerPreProcessListener exploitFixerPreProcessListener; + private ExploitFixerDecodeListener exploitFixerDecodeListener; + + public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.moduleManager = moduleManager; + } + + public void start() { + final PreProcessEventHandler preProcessEventHandler = HamsterAPI.getPreProcessEventHandler(); + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + + // preProcessEventHandler.addListener(this.exploitFixerPreProcessListener = new + // ExploitFixerPreProcessListener(plugin, moduleManager)); + decodeEventHandler + .addListener(this.exploitFixerDecodeListener = new ExploitFixerDecodeListener(plugin, moduleManager)); + } + + public void stop() { + final PreProcessEventHandler preProcessEventHandler = HamsterAPI.getPreProcessEventHandler(); + final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); + + // preProcessEventHandler.removeListener(exploitFixerPreProcessListener); + decodeEventHandler.removeListener(exploitFixerDecodeListener); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index dc90299..c9983b0 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -1,13 +1,10 @@ package twolovers.exploitfixer.bukkit.listeners.initializers; -import java.util.logging.Logger; - import org.bukkit.Server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import twolovers.exploitfixer.bukkit.listeners.ExploitFixerDecodeListener; import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; import twolovers.exploitfixer.bukkit.listeners.PlayerQuitListener; @@ -17,32 +14,16 @@ public class ListenerInitializer { private final Plugin plugin; private final ModuleManager moduleManager; - private final ExploitFixerDecodeListener exploitFixerDecodeListener; public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.moduleManager = moduleManager; - this.exploitFixerDecodeListener = new ExploitFixerDecodeListener(plugin, moduleManager); } public void start() { - final Logger logger = this.plugin.getLogger(); final Server server = this.plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); - if (pluginManager.isPluginEnabled("HamsterAPI")) { - System.out.println("TEST"); - final hamsterapi.handlers.DecodeEventHandler decodeEventHandler = hamsterapi.HamsterAPI - .getDecodeEventHandler(); - - decodeEventHandler.addListener(exploitFixerDecodeListener); - logger.info("Successfully hooked with HamsterAPI!"); - } else { - for (int i = 0; i < 10; i++) { - logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); - } - } - pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); @@ -50,17 +31,6 @@ public void start() { } public void stop() { - final Server server = this.plugin.getServer(); - final PluginManager pluginManager = server.getPluginManager(); - - if (pluginManager.isPluginEnabled("HamsterAPI")) { - // Inline import to prevent errors if HamsterAPI is disabled. - final hamsterapi.handlers.DecodeEventHandler decodeEventHandler = hamsterapi.HamsterAPI - .getDecodeEventHandler(); - - decodeEventHandler.removeListener(exploitFixerDecodeListener); - } - HandlerList.unregisterAll(plugin); } } From 55afb9c520ce217e807174303a70c2da125bc6ff Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 May 2020 03:19:44 -0300 Subject: [PATCH 062/336] Updated source --- src/bungee.yml | 4 +- src/config.yml | 9 +- .../exploitfixer/bukkit/ExploitFixer.java | 132 ++++++ .../bukkit/commands/ExploitFixerCommand.java | 27 +- .../bukkit/instanceables/ExploitPlayer.java | 38 +- .../bukkit/instanceables/Violations.java | 2 +- .../ExploitFixerPostProcessListener.java | 76 ++++ .../ExploitFixerPreProcessListener.java | 377 ++++++++++++++++++ .../listeners/PlayerCommandListener.java | 174 ++++---- .../bukkit/listeners/PlayerLoginListener.java | 188 ++++----- .../bukkit/listeners/PlayerQuitListener.java | 66 +-- .../listeners/PlayerTeleportListener.java | 8 +- .../HamsterAPIListenerInitializer.java | 42 ++ .../initializers/ListenerInitializer.java | 72 ++-- .../bukkit/managers/ExploitPlayerManager.java | 4 +- .../bukkit/managers/ModuleManager.java | 4 +- .../bukkit/modules/CommandsModule.java | 6 +- .../bukkit/modules/ConnectionModule.java | 4 +- .../bukkit/modules/CustomPayloadModule.java | 8 +- .../bukkit/modules/ItemsFixModule.java | 110 +++++ .../bukkit/modules/MessagesModule.java | 4 +- .../bukkit/modules/NotificationsModule.java | 4 +- .../bukkit/modules/PacketsModule.java | 8 +- .../bukkit/utils/ConfigurationUtil.java | 164 ++++---- .../bukkit/utils/VersionUtil.java | 2 +- .../exploitfixer/bungee/ExploitFixer.java | 18 +- .../bungee/commands/ExploitFixerCommand.java | 12 +- .../bungee/instanceables/ExploitPlayer.java | 16 +- .../bungee/instanceables/Violations.java | 2 +- .../bungee/listeners/ChatListener.java | 150 +++---- .../bungee/listeners/DisconnectListener.java | 66 +-- .../listeners/PluginMessageListener.java | 160 ++++---- .../bungee/listeners/PostLoginListener.java | 166 ++++---- .../bungee/managers/ExploitPlayerManager.java | 6 +- .../bungee/managers/ModuleManager.java | 6 +- .../bungee/modules/CommandsModule.java | 4 +- .../bungee/modules/ConnectionModule.java | 4 +- .../bungee/modules/CustomPayloadModule.java | 8 +- .../bungee/modules/MessagesModule.java | 4 +- .../bungee/modules/NotificationsModule.java | 4 +- .../bungee/utils/ConfigurationUtil.java | 162 ++++---- .../shared/interfaces/Module.java | 2 +- .../shared/interfaces/PunishmentModule.java | 2 +- .../shared/interfaces/ViolationModule.java | 2 +- src/messages.yml | 28 +- src/plugin.yml | 4 +- .../exploitfixer/bukkit/ExploitFixer.java | 119 ------ .../listeners/ExploitFixerDecodeListener.java | 356 ----------------- .../ExploitFixerPreProcessListener.java | 16 - .../HamsterAPIListenerInitializer.java | 40 -- .../bukkit/modules/ItemsFixModule.java | 104 ----- 51 files changed, 1563 insertions(+), 1431 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/commands/ExploitFixerCommand.java (76%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/instanceables/ExploitPlayer.java (81%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/instanceables/Violations.java (92%) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/listeners/PlayerCommandListener.java (82%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/listeners/PlayerLoginListener.java (83%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/listeners/PlayerQuitListener.java (73%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/listeners/PlayerTeleportListener.java (80%) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java (68%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/managers/ExploitPlayerManager.java (92%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/managers/ModuleManager.java (96%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/CommandsModule.java (84%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/ConnectionModule.java (90%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/CustomPayloadModule.java (91%) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/MessagesModule.java (95%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/NotificationsModule.java (95%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/modules/PacketsModule.java (92%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/utils/ConfigurationUtil.java (95%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bukkit/utils/VersionUtil.java (89%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/ExploitFixer.java (79%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/commands/ExploitFixerCommand.java (88%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/instanceables/ExploitPlayer.java (89%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/instanceables/Violations.java (92%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/listeners/ChatListener.java (83%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/listeners/DisconnectListener.java (74%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/listeners/PluginMessageListener.java (86%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/listeners/PostLoginListener.java (85%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/managers/ExploitPlayerManager.java (89%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/managers/ModuleManager.java (91%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/modules/CommandsModule.java (87%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/modules/ConnectionModule.java (89%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/modules/CustomPayloadModule.java (90%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/modules/MessagesModule.java (94%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/modules/NotificationsModule.java (94%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/bungee/utils/ConfigurationUtil.java (75%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/shared/interfaces/Module.java (62%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/shared/interfaces/PunishmentModule.java (70%) rename src/{twolovers => dev/_2lstudios}/exploitfixer/shared/interfaces/ViolationModule.java (74%) delete mode 100644 src/twolovers/exploitfixer/bukkit/ExploitFixer.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java delete mode 100644 src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java delete mode 100644 src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java diff --git a/src/bungee.yml b/src/bungee.yml index f1f6d05..ec6e933 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer -main: twolovers.exploitfixer.bungee.ExploitFixer -version: 1.3.3 +main: dev._2lstudios.exploitfixer.bungee.ExploitFixer +version: 1.3.4 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index ac5387e..6344b05 100644 --- a/src/config.yml +++ b/src/config.yml @@ -5,7 +5,7 @@ # WARNING: Only Notifications, Connection, CustomPayload and Commands modules work on BungeeCord. # # This is because the other modules can't be executed on BungeeCord. -# The other modules require ExploitFixer to be installed on Spigot with HamsterAPI. (No performance impact) +# The other modules require ExploitFixer to be installed on Spigot with dev._2lstudios.hamsterapi. (No performance impact) # # INSTALL THE PLUGIN ON BUNGEECORD AND ALL SPIGOT SERVERS! # @@ -49,6 +49,13 @@ itemsfix: # Maximum enchant level obtainable with creative packets. (-1 to disable) enchant_limit: 10 + # List of materials that are unobtainable from Creative. + blacklist: + - "BARRIER" + - "END_PORTAL" + - "NETHER_PORTAL" + - "COMMAND_BLOCK" + # Prevents the use of CustomPayload packets to exploit the server. custompayload: enabled: true diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java new file mode 100644 index 0000000..6f65606 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -0,0 +1,132 @@ +package dev._2lstudios.exploitfixer.bukkit; + +import java.util.logging.Logger; + +import org.bukkit.Server; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitScheduler; + +import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.bukkit.listeners.initializers.HamsterAPIListenerInitializer; +import dev._2lstudios.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.utils.ConfigurationUtil; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; + +public class ExploitFixer extends JavaPlugin { + private static ExploitFixer exploitFixer; + private ConfigurationUtil configurationUtil; + private ModuleManager moduleManager; + private ListenerInitializer listenerInitializer; + private HamsterAPIListenerInitializer hamsterAPIListenerInitializer; + + @Override + public void onEnable() { + final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); + + this.configurationUtil = new ConfigurationUtil(this); + + createConfigurations(); + + final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); + final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); + + VersionUtil.init(); + + exploitFixer = this; + this.moduleManager = new ModuleManager(this, configYml, messagesYml); + this.listenerInitializer = new ListenerInitializer(this, moduleManager); + + registerCommands(); + + if (checkHamsterAPI()) { + server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + + registerHamsterApi(); + + scheduler.runTaskTimerAsynchronously(this, () -> { + final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); + + exploitPlayerManager.clear(); + }, 9000L, 9000L); + } else { + scheduler.runTaskTimer(this, () -> this.getLogger().severe( + "ExploitFixer requires HamsterAPI 0.0.6 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), + 20L, 20L); + } + } + + @Override + public void onDisable() { + final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); + + scheduler.cancelTasks(this); + + this.listenerInitializer.stop(); + + if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { + this.hamsterAPIListenerInitializer.stop(); + } + } + + public void reload() { + final Server server = getServer(); + + server.getMessenger().unregisterIncomingPluginChannel(this); + + createConfigurations(); + + final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); + final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final YamlConfiguration spigotYml = this.configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); + + moduleManager.reload(configYml, messagesYml, spigotYml); + + this.listenerInitializer.start(); + + if (checkHamsterAPI()) { + this.hamsterAPIListenerInitializer.start(); + } + + registerCommands(); + } + + private boolean checkHamsterAPI() { + final Server server = this.getServer(); + final PluginManager pluginManager = server.getPluginManager(); + + if (pluginManager.isPluginEnabled("HamsterAPI")) { + return (Integer + .valueOf(pluginManager.getPlugin("HamsterAPI").getDescription().getVersion().replace(".", "")) > 5); + } else { + return false; + } + } + + private void createConfigurations() { + this.configurationUtil.createConfiguration("%datafolder%/config.yml"); + this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); + } + + private void registerHamsterApi() { + final Logger logger = this.getLogger(); + + this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); + this.hamsterAPIListenerInitializer.start(); + + logger.info("Successfully hooked with HamsterAPI!"); + } + + private void registerCommands() { + getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager, checkHamsterAPI())); + } + + public static ExploitFixer getInstance() { + return exploitFixer; + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java similarity index 76% rename from src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java rename to src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 27d435d..2484797 100644 --- a/src/twolovers/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -1,25 +1,28 @@ -package twolovers.exploitfixer.bukkit.commands; +package dev._2lstudios.exploitfixer.bukkit.commands; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import twolovers.exploitfixer.bukkit.ExploitFixer; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.MessagesModule; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.ExploitFixer; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; public class ExploitFixerCommand implements CommandExecutor { private MessagesModule messagesModule; private NotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; + private final boolean hamsterApiEnabled; - public ExploitFixerCommand(final ModuleManager moduleManager) { + public ExploitFixerCommand(final ModuleManager moduleManager, final boolean hamsterApiEnabled) { this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.hamsterApiEnabled = hamsterApiEnabled; } @Override @@ -28,7 +31,7 @@ public boolean onCommand(final CommandSender commandSender, final Command comman final int length = args.length; String lang = "en"; - if (commandSender instanceof Player) + if (commandSender instanceof Player) { if (VersionUtil.isOneDotFifteen()) { final String locale = ((Player) commandSender).getLocale(); @@ -40,6 +43,7 @@ public boolean onCommand(final CommandSender commandSender, final Command comman if (locale != null) lang = locale.substring(0, 2); } + } if (length < 1 || args[0].equals("help")) { commandSender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); @@ -76,6 +80,11 @@ else if (args[0].equalsIgnoreCase("notifications")) { } else commandSender.sendMessage(messagesModule.getUnknown(lang)); + if (!hamsterApiEnabled) { + commandSender + .sendMessage(ChatColor.RED + "HamsterAPI is not installed! ExploitFixer will not behave properly!"); + } + return true; } } diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java similarity index 81% rename from src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java rename to src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 63ade88..961b9c8 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.instanceables; +package dev._2lstudios.exploitfixer.bukkit.instanceables; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -14,15 +14,15 @@ import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; -import hamsterapi.adapters.HamsterPlayer; -import hamsterapi.enums.PacketType; -import hamsterapi.wrappers.EventWrapper; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.MessagesModule; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class ExploitPlayer { private final ExploitPlayerManager exploitPlayerManager; @@ -56,7 +56,7 @@ public int addChannels(final int channels) { } public double getViolations(final ViolationModule module) { - return violations.getOrDefault(module, 0D); + return this.violations.getOrDefault(module, 0D); } public String getOnlineUUID() { @@ -86,8 +86,13 @@ public String getOnlineUUID() { return onlineUUID; } - public void addVls(final Plugin plugin, final Object event, final Player player, final ViolationModule module, + public void addVls(final Plugin plugin, final Cancellable event, final Player player, final ViolationModule module, final double amount) { + addVls(plugin, event, null, player, module, amount); + } + + public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, final Player player, + final ViolationModule module, final double amount) { if (player.isOnline()) { final Violations violations = (Violations) module.getViolations(); @@ -101,10 +106,11 @@ public void addVls(final Plugin plugin, final Object event, final Player player, for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - if (vls <= 0) + if (vls <= 0) { this.violations.remove(violationModule); - else + } else { this.violations.put(violationModule, vls); + } } } @@ -140,8 +146,8 @@ public void addVls(final Plugin plugin, final Object event, final Player player, } else if (punishCommand.equals("notification")) { final String moduleName = module.getName(); - if (event instanceof EventWrapper) { - final PacketType packetType = ((EventWrapper) event).getPacket().getType(); + if (packet != null) { + final PacketType packetType = packet.getType(); final String name; if (packetType != null) { diff --git a/src/twolovers/exploitfixer/bukkit/instanceables/Violations.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java similarity index 92% rename from src/twolovers/exploitfixer/bukkit/instanceables/Violations.java rename to src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java index 97cf2cf..e1239c5 100644 --- a/src/twolovers/exploitfixer/bukkit/instanceables/Violations.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.instanceables; +package dev._2lstudios.exploitfixer.bukkit.instanceables; import org.bukkit.configuration.ConfigurationSection; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java new file mode 100644 index 0000000..6187e57 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java @@ -0,0 +1,76 @@ +package dev._2lstudios.exploitfixer.bukkit.listeners; + +import java.util.Map; +import java.util.logging.Logger; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.hamsterapi.interfaces.PostProcessListener; +import dev._2lstudios.hamsterapi.wrappers.EventWrapper; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; + +public class ExploitFixerPostProcessListener implements PostProcessListener { + private final Plugin plugin; + private final NotificationsModule notificationsModule; + private final ItemsFixModule itemsFixModule; + + public ExploitFixerPostProcessListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.notificationsModule = moduleManager.getNotificationsModule(); + this.itemsFixModule = moduleManager.getItemsFixModule(); + } + + @Override + public void onPacketReceive(final EventWrapper event) { + if (!event.isCancelled()) { + final PacketWrapper packetWrapper = event.getPacket(); + final Map items = packetWrapper.getItems(); + + if (itemsFixModule.isEnabled() && items.containsKey("b")) { + final ItemStack itemStack = items.get("b"); + + if (itemStack != null) { + final String materialName = itemStack.getType().toString(); + String blocked = null; + + for (final String blockedMaterial : itemsFixModule.getBlacklist()) { + if (materialName.equals(blockedMaterial)) { + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + blocked = materialName; + break; + } + } + + final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); + + packetWrapper.write("b", fixedItemStack); + + if (notificationsModule.isDebug()) { + final Player player = event.getPlayer(); + final Logger logger = plugin.getLogger(); + + if (player != null) { + if (blocked != null) { + logger.info(player.getName() + " had a creative item blocked by ExploiFixer! (" + + blocked + ")"); + } else { + logger.info(player.getName() + " had a creative item fixed by ExploiFixer!"); + } + } + } + } + } + } + } + + @Override + public void onPacketSend(final EventWrapper event) { + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java new file mode 100644 index 0000000..5bccd4b --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java @@ -0,0 +1,377 @@ +package dev._2lstudios.exploitfixer.bukkit.listeners; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Map; +import java.util.logging.Logger; + +import org.bukkit.GameMode; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.interfaces.PreProcessListener; +import dev._2lstudios.hamsterapi.utils.BufferIO; +import dev._2lstudios.hamsterapi.wrappers.EventWrapper; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; +import io.netty.buffer.ByteBuf; + +public class ExploitFixerPreProcessListener implements PreProcessListener { + private final HamsterAPI hamsterAPI; + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + + public ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { + this.hamsterAPI = HamsterAPI.getInstance(); + this.plugin = plugin; + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @Override + public void onPacketDecode(final EventWrapper event) { + if (!event.isCancelled()) { + final Logger logger = plugin.getLogger(); + final Player player = event.getPlayer(); + + if (player != null && player.isOnline()) { + final BufferIO bufferIO = hamsterAPI.getBufferIO(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final int dataBytes = packetsModule.getDataBytes(); + final double dataVls = packetsModule.getDataVls(); + final String playerName = player.getName(); + + try { + final ByteBuf buf = bufferIO.decompress(event.getByteBuf().copy(), 256); + + if (buf != null) { + final PacketWrapper packetWrapper = bufferIO.decode(event.getChannelHandlerContext(), buf, + dataBytes); + + if (packetWrapper != null) { + final PacketType packetType = packetWrapper.getType(); + + if (packetType != PacketType.PacketPlayInKeepAlive) { + final Map strings = packetWrapper.getStrings(); + final String packetName = packetWrapper.getName(); + + if (packetsModule.isEnabled()) { + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(), + setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(), + bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " has a slot less than 0 (" + slot + ")"); + } + + event.setCancelled(true); + return; + } else if (slot >= maxSlots) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " exceeded max available slots (" + slot + "/" + + maxSlots + ") on " + packetName + "! Added vls: " + + windowClick); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { + if (player.getGameMode() != GameMode.CREATIVE) { + if (notificationsModule.isDebug()) { + logger.info(playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + + setCreativeSlot); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); + return; + } + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += getItemLength((ItemStack) object, exploitPlayer, + player); + } else { + packetSize += String.valueOf(object) + .getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "] Sent by " + playerName + + " got blocked because its " + packetSize + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && checkSign(strings.values().toArray(new String[0]))) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " has sent a too big sign packet! Added vls: " + + dataVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize + / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, player, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + if (customPayloadModule.isEnabled() + && packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = customPayloadModule.getTagVls(), + bookVls = customPayloadModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + return; + } else { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") + || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory + .getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null + && !itemInHand.getType().toString().contains("BOOK")) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " tried to send a " + tag + + " custompayload packet without a book in hand!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + bookVls); + return; + } /* + * else if (byteLength > customPayloadModule.getBookBytes()) { + * logger.info(playerName + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); + * event.setCancelled(true); exploitPlayer.addVls(plugin, event, + * player, customPayloadModule, customPayloadModule.getBookVls()); + * return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } else { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent a empty CustomPayload packet!"); + } + + event.setCancelled(true); + } + } + } + } + } + } catch (final Exception exception) { + if (!(exception instanceof NullPointerException)) { + if (notificationsModule.isDebug()) { + logger.info("[Decoder - " + exception.toString() + "] " + playerName + + " sent a packet that exceeds size limit! Max: " + dataBytes); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, dataVls); + return; + } else { + exception.printStackTrace(); + } + } + } else if (packetsModule.isOffline()) { + if (notificationsModule.isDebug()) { + if (player == null) { + logger.info("OFFLINEPLAYER sent a packet while offline!"); + } else { + logger.info(player.getName() + " sent a packet while offline!"); + } + } + + event.setCancelled(true); + event.abort(); + } + } + } + + private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, final Player player) { + final Logger logger = plugin.getLogger(); + int itemBytesLength = 0; + + if (itemStack != null) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + + try { + itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final Exception exception) { + if (notificationsModule.isDebug()) { + logger.info("There was an exception when processing itemStack data to String!"); + } + } + + if (itemStack.hasItemMeta() && itemMeta != null) { + try { + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { + itemBytesLength += getItemLength(itemStack1, exploitPlayer, player); + } + } + } + } else { + throw new Exception(); + } + } catch (final Exception exception) { + if (itemMeta instanceof BookMeta) { + itemBytesLength += getBookLength(exploitPlayer, player, itemMeta); + } else { + try { + itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + itemBytesLength += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + } + } + } + } + + return itemBytesLength; + } + + private int getBookLength(final ExploitPlayer exploitPlayer, final Player player, final ItemMeta itemMeta) { + final Logger logger = plugin.getLogger(); + final BookMeta bookMeta = (BookMeta) itemMeta; + final double dataVls = packetsModule.getDataVls(); + final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); + int bookTotalBytes = 0; + + if (pageCount > 50) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" + + 50 + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); + } else { + for (final String page : bookMeta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + bookTotalBytes += pageBytes; + + if (pageBytes > dataBytesBook) { + if (notificationsModule.isDebug()) { + logger.info( + player.getName() + " has sent a packet with a book with too many characters per page! (" + + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); + break; + } + } + + return bookTotalBytes; + } + + return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } + + private boolean checkSign(final String[] linesString) { + final int dataBytesSign = packetsModule.getDataBytesSign(); + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else { + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { + return true; + } + } + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java similarity index 82% rename from src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java index f9374bf..46b0498 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -1,88 +1,88 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.Server; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.plugin.Plugin; - -import hamsterapi.adapters.HamsterPlayer; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.CommandsModule; -import twolovers.exploitfixer.bukkit.modules.MessagesModule; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; - -public class PlayerCommandListener implements Listener { - private final Plugin plugin; - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - - public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.commandsModule = moduleManager.getCommandsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { - final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - - if (!exploitPlayer.isLogged()) { - event.setCancelled(true); - } else if (commandsModule.isEnabled()) { - final Server server = plugin.getServer(); - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - final String playerName = player.getName(); - - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ") || message.endsWith(command)) { - for (final String punishment : commandsModule.getPunishments()) { - if (command.equals("kick")) { - final String locale; - - if (VersionUtil.isOneDotFifteen()) { - locale = player.getLocale().substring(0, 2); - } else { - locale = player.spigot().getLocale().substring(0, 2); - } - - final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); - final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); - - hamsterPlayer.kickPlayer(kickMessage); - hamsterPlayer.abort(); - exploitPlayerManager.addPunishment(); - } else if (command.equals("notification")) { - final String moduleName = commandsModule.getName(); - - notificationsModule.sendNotification(moduleName, player, 1); - } else { - if (server.isPrimaryThread()) { - server.dispatchCommand(server.getConsoleSender(), - punishment.replace("%player%", playerName)); - } else { - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishment.replace("%player%", playerName)); - }); - } - } - } - - event.setCancelled(true); - break; - } - } - } - } +package dev._2lstudios.exploitfixer.bukkit.listeners; + +import org.bukkit.Server; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; + +public class PlayerCommandListener implements Listener { + private final Plugin plugin; + private final CommandsModule commandsModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + + public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.commandsModule = moduleManager.getCommandsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { + final Player player = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (!exploitPlayer.isLogged()) { + event.setCancelled(true); + } else if (commandsModule.isEnabled()) { + final Server server = plugin.getServer(); + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String playerName = player.getName(); + + for (final String command : commandsModule.getCommands()) { + if (message.startsWith(command + " ") || message.endsWith(command)) { + for (final String punishment : commandsModule.getPunishments()) { + if (command.equals("kick")) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) { + locale = player.getLocale().substring(0, 2); + } else { + locale = player.spigot().getLocale().substring(0, 2); + } + + final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); + final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + + hamsterPlayer.kickPlayer(kickMessage); + hamsterPlayer.abort(); + exploitPlayerManager.addPunishment(); + } else if (command.equals("notification")) { + final String moduleName = commandsModule.getName(); + + notificationsModule.sendNotification(moduleName, player, 1); + } else { + if (server.isPrimaryThread()) { + server.dispatchCommand(server.getConsoleSender(), + punishment.replace("%player%", playerName)); + } else { + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishment.replace("%player%", playerName)); + }); + } + } + } + + event.setCancelled(true); + break; + } + } + } + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java similarity index 83% rename from src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 70816ba..11f6109 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -1,94 +1,94 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitScheduler; - -import hamsterapi.adapters.HamsterPlayer; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.ConnectionModule; -import twolovers.exploitfixer.bukkit.modules.MessagesModule; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; - -import java.net.InetAddress; -import java.util.UUID; - -public class PlayerLoginListener implements Listener { - private final Plugin plugin; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - private final ConnectionModule connectionModule; - private final ExploitPlayerManager exploitPlayerManager; - - public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.connectionModule = moduleManager.getConnectionModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerLogin(final PlayerLoginEvent event) { - final Player player = event.getPlayer(); - final InetAddress address = event.getAddress(); - final String locale; - - if (VersionUtil.isOneDotFifteen()) { - locale = player.getLocale().substring(0, 2); - } else { - locale = player.spigot().getLocale().substring(0, 2); - } - - if (connectionModule.isNullAddressEnabled() && address == null) { - final String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); - - event.setKickMessage(nullAddressKickMessage); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - new HamsterPlayer(player).kickPlayer(nullAddressKickMessage); - } else { - final UUID uuid = player.getUniqueId(); - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); - - if (connectionModule.isUUIDSpoofEnabled()) { - final BukkitScheduler scheduler = plugin.getServer().getScheduler(); - - scheduler.runTaskAsynchronously(plugin, () -> { - final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) - .toString().replace("-", ""); - - if (!originalUUID.contains(offlineUUID)) { - final String onlineUUID = exploitPlayer.getOnlineUUID(); - - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - - event.setKickMessage(uuidSpoofKickMessage); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - new HamsterPlayer(player).kickPlayer(uuidSpoofKickMessage); - } - } - - exploitPlayer.setLogged(true); - exploitPlayer.updateTeleportTimeMillis(); - }); - } else { - exploitPlayer.setLogged(true); - exploitPlayer.updateTeleportTimeMillis(); - } - } - - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); - } - } -} +package dev._2lstudios.exploitfixer.bukkit.listeners; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; + +import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; + +import java.net.InetAddress; +import java.util.UUID; + +public class PlayerLoginListener implements Listener { + private final Plugin plugin; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + private final ConnectionModule connectionModule; + private final ExploitPlayerManager exploitPlayerManager; + + public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.connectionModule = moduleManager.getConnectionModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerLogin(final PlayerLoginEvent event) { + final Player player = event.getPlayer(); + final InetAddress address = event.getAddress(); + final String locale; + + if (VersionUtil.isOneDotFifteen()) { + locale = player.getLocale().substring(0, 2); + } else { + locale = player.spigot().getLocale().substring(0, 2); + } + + if (connectionModule.isNullAddressEnabled() && address == null) { + final String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); + + event.setKickMessage(nullAddressKickMessage); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + new HamsterPlayer(player).kickPlayer(nullAddressKickMessage); + } else { + final UUID uuid = player.getUniqueId(); + final String playerName = player.getName(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + + if (connectionModule.isUUIDSpoofEnabled()) { + final BukkitScheduler scheduler = plugin.getServer().getScheduler(); + + scheduler.runTaskAsynchronously(plugin, () -> { + final String originalUUID = uuid.toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) + .toString().replace("-", ""); + + if (!originalUUID.contains(offlineUUID)) { + final String onlineUUID = exploitPlayer.getOnlineUUID(); + + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); + + event.setKickMessage(uuidSpoofKickMessage); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + new HamsterPlayer(player).kickPlayer(uuidSpoofKickMessage); + } + } + + exploitPlayer.setLogged(true); + exploitPlayer.updateTeleportTimeMillis(); + }); + } else { + exploitPlayer.setLogged(true); + exploitPlayer.updateTeleportTimeMillis(); + } + } + + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(player, true); + } + } +} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java similarity index 73% rename from src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java index 30c787e..afe7832 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -1,34 +1,34 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; - -public class PlayerQuitListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - - public PlayerQuitListener(final ModuleManager variables) { - this.exploitPlayerManager = variables.getExploitPlayerManager(); - this.notificationsModule = variables.getNotificationsModule(); - } - - @EventHandler - public void onPlayerQuit(final PlayerQuitEvent event) { - final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - - if (exploitPlayer != null) { - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); - exploitPlayer.setLogged(false); - } - - notificationsModule.setNotifications(player, false); - } +package dev._2lstudios.exploitfixer.bukkit.listeners; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; + +public class PlayerQuitListener implements Listener { + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + + public PlayerQuitListener(final ModuleManager variables) { + this.exploitPlayerManager = variables.getExploitPlayerManager(); + this.notificationsModule = variables.getNotificationsModule(); + } + + @EventHandler + public void onPlayerQuit(final PlayerQuitEvent event) { + final Player player = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (exploitPlayer != null) { + exploitPlayer.clearChannels(); + exploitPlayer.clearViolations(); + exploitPlayer.setLogged(false); + } + + notificationsModule.setNotifications(player, false); + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java similarity index 80% rename from src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java index b547a54..8ec2b36 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/PlayerTeleportListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listeners; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -7,9 +7,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerTeleportEvent; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; public class PlayerTeleportListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java new file mode 100644 index 0000000..cbde13b --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java @@ -0,0 +1,42 @@ +package dev._2lstudios.exploitfixer.bukkit.listeners.initializers; + +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.listeners.ExploitFixerPostProcessListener; +import dev._2lstudios.exploitfixer.bukkit.listeners.ExploitFixerPreProcessListener; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.handlers.PostProcessEventHandler; +import dev._2lstudios.hamsterapi.handlers.PreProcessEventHandler; + +public class HamsterAPIListenerInitializer { + private final HamsterAPI hamsterAPI; + private final Plugin plugin; + private final ModuleManager moduleManager; + private ExploitFixerPreProcessListener exploitFixerPreProcessListener; + private ExploitFixerPostProcessListener exploitFixerPostProcessListener; + + public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { + this.hamsterAPI = HamsterAPI.getInstance(); + this.plugin = plugin; + this.moduleManager = moduleManager; + } + + public void start() { + final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); + final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); + + preProcessEventHandler.addListener( + this.exploitFixerPreProcessListener = new ExploitFixerPreProcessListener(plugin, moduleManager), 0); + postProcessEventHandler.addListener( + this.exploitFixerPostProcessListener = new ExploitFixerPostProcessListener(plugin, moduleManager), 0); + } + + public void stop() { + final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); + final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); + + preProcessEventHandler.removeListener(exploitFixerPreProcessListener); + postProcessEventHandler.removeListener(exploitFixerPostProcessListener); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java similarity index 68% rename from src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index c9983b0..c31fa52 100644 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -1,36 +1,36 @@ -package twolovers.exploitfixer.bukkit.listeners.initializers; - -import org.bukkit.Server; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; - -import twolovers.exploitfixer.bukkit.listeners.PlayerCommandListener; -import twolovers.exploitfixer.bukkit.listeners.PlayerLoginListener; -import twolovers.exploitfixer.bukkit.listeners.PlayerQuitListener; -import twolovers.exploitfixer.bukkit.listeners.PlayerTeleportListener; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; - -public class ListenerInitializer { - private final Plugin plugin; - private final ModuleManager moduleManager; - - public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.moduleManager = moduleManager; - } - - public void start() { - final Server server = this.plugin.getServer(); - final PluginManager pluginManager = server.getPluginManager(); - - pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); - pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); - } - - public void stop() { - HandlerList.unregisterAll(plugin); - } -} +package dev._2lstudios.exploitfixer.bukkit.listeners.initializers; + +import org.bukkit.Server; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; + +import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerCommandListener; +import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerLoginListener; +import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerQuitListener; +import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerTeleportListener; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; + +public class ListenerInitializer { + private final Plugin plugin; + private final ModuleManager moduleManager; + + public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.moduleManager = moduleManager; + } + + public void start() { + final Server server = this.plugin.getServer(); + final PluginManager pluginManager = server.getPluginManager(); + + pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); + } + + public void stop() { + HandlerList.unregisterAll(plugin); + } +} diff --git a/src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java similarity index 92% rename from src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java rename to src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 86d43df..168337c 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.managers; +package dev._2lstudios.exploitfixer.bukkit.managers; import java.util.HashMap; import java.util.Iterator; @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; public class ExploitPlayerManager { private final Plugin plugin; diff --git a/src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java similarity index 96% rename from src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java rename to src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index 2a30e35..ec7ae88 100644 --- a/src/twolovers/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -1,9 +1,9 @@ -package twolovers.exploitfixer.bukkit.managers; +package dev._2lstudios.exploitfixer.bukkit.managers; import org.bukkit.Server; import org.bukkit.configuration.Configuration; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.modules.*; +import dev._2lstudios.exploitfixer.bukkit.modules.*; import java.util.logging.Level; diff --git a/src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java similarity index 84% rename from src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java index 0775426..407174a 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java @@ -1,9 +1,9 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.bukkit.modules.CommandsModule; -import twolovers.exploitfixer.shared.interfaces.PunishmentModule; +import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; +import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; import java.util.Collection; diff --git a/src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java similarity index 90% rename from src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java index d3e5dfa..4b1afe4 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java @@ -1,11 +1,11 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import java.util.Collection; import java.util.HashSet; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.YamlConfiguration; -import twolovers.exploitfixer.shared.interfaces.PunishmentModule; +import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; public class ConnectionModule implements PunishmentModule { private boolean uuidSpoofEnabled, nullAddressEnabled; diff --git a/src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java similarity index 91% rename from src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java index 0130d35..08c9515 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/CustomPayloadModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import java.util.HashMap; import java.util.Map; @@ -7,9 +7,9 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.Violations; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.bukkit.instanceables.Violations; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; public class CustomPayloadModule implements ViolationModule { private Map multipliers = new HashMap<>(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java new file mode 100644 index 0000000..7808578 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -0,0 +1,110 @@ +package dev._2lstudios.exploitfixer.bukkit.modules; + +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.configuration.Configuration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; + +public class ItemsFixModule implements Module { + private final Plugin plugin; + private boolean enabled; + private int enchantLimit, maxStackSize; + private Collection blacklist; + + public ItemsFixModule(final Plugin plugin, final Configuration configYml) { + this.plugin = plugin; + reload(configYml); + } + + final public void reload(final Configuration configYml) { + final String name = getName().toLowerCase(); + + this.enabled = configYml.getBoolean(name + ".enabled", true); + this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); + this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); + this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "ItemsFix"; + } + + public int getEnchantLimit() { + return enchantLimit; + } + + public int getMaxStackSize() { + return maxStackSize; + } + + public Collection getBlacklist() { + return blacklist; + } + + public ItemStack fixItem(final ItemStack itemStack) { + final Material material = Material.getMaterial(itemStack.getType().name()); + final ItemMeta itemMeta = itemStack.getItemMeta(), + newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + final int maxStackSize = getMaxStackSize(); + final short durability = itemStack.getDurability(); + + if (itemStack.hasItemMeta()) { + final Map enchantments = itemStack.getEnchantments(); + final String displayName = itemMeta.getDisplayName(); + final List lore = itemMeta.getLore(); + + if (enchantLimit > -1) { + for (final Enchantment enchantment : enchantments.keySet()) { + final int level = enchantments.get(enchantment); + + if (level <= enchantLimit && level > -1) { + newItemMeta.addEnchant(enchantment, level, true); + } + } + } + + if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { + final BookMeta bookMeta = (BookMeta) itemMeta; + final BookMeta newBookMeta = (BookMeta) newItemMeta; + + newBookMeta.setTitle(bookMeta.getTitle()); + newBookMeta.setAuthor(bookMeta.getAuthor()); + newBookMeta.setPages(bookMeta.getPages()); + } + + if (displayName != null && displayName.getBytes().length < 128) + newItemMeta.setDisplayName(displayName); + + if (lore != null && lore.toString().getBytes().length < 1024) { + newItemMeta.setLore(lore); + } + } + + if (maxStackSize > 0 && itemStack.getAmount() > maxStackSize) { + itemStack.setAmount(maxStackSize); + } + + itemStack.setType(material); + itemStack.setItemMeta(newItemMeta); + itemStack.setDurability(durability); + + return itemStack; + } +} diff --git a/src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java similarity index 95% rename from src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java index 31d1fa9..f48920a 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java @@ -1,8 +1,8 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import org.bukkit.configuration.Configuration; -import twolovers.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class MessagesModule implements Module { private final String version; diff --git a/src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java similarity index 95% rename from src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java index 1f530b0..e747e08 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import java.lang.reflect.InvocationTargetException; import java.util.Collection; @@ -9,7 +9,7 @@ import org.bukkit.configuration.Configuration; import org.bukkit.entity.Player; -import twolovers.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class NotificationsModule implements Module { private final CommandSender console; diff --git a/src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java similarity index 92% rename from src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java rename to src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java index 144cf33..88be686 100644 --- a/src/twolovers/exploitfixer/bukkit/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.bukkit.modules; import java.util.HashMap; import java.util.Map; @@ -7,9 +7,9 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.plugin.Plugin; -import twolovers.exploitfixer.bukkit.instanceables.Violations; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.bukkit.instanceables.Violations; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; public class PacketsModule implements ViolationModule { private final Map multipliers = new HashMap<>(); diff --git a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java similarity index 95% rename from src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java rename to src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java index db17121..502d49a 100644 --- a/src/twolovers/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -1,83 +1,83 @@ -package twolovers.exploitfixer.bukkit.utils; - -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.Plugin; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class ConfigurationUtil { - final private Plugin plugin; - - public ConfigurationUtil(final Plugin plugin) { - this.plugin = plugin; - } - - public YamlConfiguration getConfiguration(String filePath) { - final File dataFolder = plugin.getDataFolder(); - final File file = new File(filePath.replace("%datafolder%", dataFolder.toPath().toString())); - - if (file.exists()) - return YamlConfiguration.loadConfiguration(file); - else - return new YamlConfiguration(); - } - - public void createConfiguration(String file) { - final Logger logger = plugin.getLogger(); - - try { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); - - final File configFile = new File(file); - - if (!configFile.exists()) { - final String[] files = file.split("/"); - final InputStream inputStream = plugin.getClass().getClassLoader() - .getResourceAsStream(files[files.length - 1]); - final File parentFile = configFile.getParentFile(); - - if (parentFile != null) - parentFile.mkdirs(); - - if (inputStream != null) { - Files.copy(inputStream, configFile.toPath()); - logger.log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") - .replace("%pluginname%", plugin.getDescription().getName())); - } else - configFile.createNewFile(); - } - } catch (final IOException e) { - logger.log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", - plugin.getDescription().getName())); - } - } - - public void saveConfiguration(final YamlConfiguration yamlConfiguration, final String file) { - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - try { - final File dataFolder = plugin.getDataFolder(); - - yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); - } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") - .replace("%pluginname%", plugin.getDescription().getName())); - } - }); - } - - public void deleteConfiguration(final String file) { - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - final File file1 = new File(file); - - if (file1.exists()) - file1.delete(); - }); - } +package dev._2lstudios.exploitfixer.bukkit.utils; + +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ConfigurationUtil { + final private Plugin plugin; + + public ConfigurationUtil(final Plugin plugin) { + this.plugin = plugin; + } + + public YamlConfiguration getConfiguration(String filePath) { + final File dataFolder = plugin.getDataFolder(); + final File file = new File(filePath.replace("%datafolder%", dataFolder.toPath().toString())); + + if (file.exists()) + return YamlConfiguration.loadConfiguration(file); + else + return new YamlConfiguration(); + } + + public void createConfiguration(String file) { + final Logger logger = plugin.getLogger(); + + try { + final File dataFolder = plugin.getDataFolder(); + + file = file.replace("%datafolder%", dataFolder.toPath().toString()); + + final File configFile = new File(file); + + if (!configFile.exists()) { + final String[] files = file.split("/"); + final InputStream inputStream = plugin.getClass().getClassLoader() + .getResourceAsStream(files[files.length - 1]); + final File parentFile = configFile.getParentFile(); + + if (parentFile != null) + parentFile.mkdirs(); + + if (inputStream != null) { + Files.copy(inputStream, configFile.toPath()); + logger.log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") + .replace("%pluginname%", plugin.getDescription().getName())); + } else + configFile.createNewFile(); + } + } catch (final IOException e) { + logger.log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", + plugin.getDescription().getName())); + } + } + + public void saveConfiguration(final YamlConfiguration yamlConfiguration, final String file) { + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { + try { + final File dataFolder = plugin.getDataFolder(); + + yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); + } catch (final IOException e) { + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") + .replace("%pluginname%", plugin.getDescription().getName())); + } + }); + } + + public void deleteConfiguration(final String file) { + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { + final File file1 = new File(file); + + if (file1.exists()) + file1.delete(); + }); + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java similarity index 89% rename from src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java rename to src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index a3566c5..2cf88e1 100644 --- a/src/twolovers/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bukkit.utils; +package dev._2lstudios.exploitfixer.bukkit.utils; import org.bukkit.Bukkit; diff --git a/src/twolovers/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java similarity index 79% rename from src/twolovers/exploitfixer/bungee/ExploitFixer.java rename to src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index da1b790..0843a19 100644 --- a/src/twolovers/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -1,17 +1,17 @@ -package twolovers.exploitfixer.bungee; +package dev._2lstudios.exploitfixer.bungee; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.commands.ExploitFixerCommand; -import twolovers.exploitfixer.bungee.listeners.ChatListener; -import twolovers.exploitfixer.bungee.listeners.DisconnectListener; -import twolovers.exploitfixer.bungee.listeners.PluginMessageListener; -import twolovers.exploitfixer.bungee.listeners.PostLoginListener; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.utils.ConfigurationUtil; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.bungee.listeners.ChatListener; +import dev._2lstudios.exploitfixer.bungee.listeners.DisconnectListener; +import dev._2lstudios.exploitfixer.bungee.listeners.PluginMessageListener; +import dev._2lstudios.exploitfixer.bungee.listeners.PostLoginListener; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.utils.ConfigurationUtil; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import java.util.concurrent.TimeUnit; diff --git a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java similarity index 88% rename from src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java rename to src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index 79652de..d5d646d 100644 --- a/src/twolovers/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -1,14 +1,14 @@ -package twolovers.exploitfixer.bungee.commands; +package dev._2lstudios.exploitfixer.bungee.commands; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; -import twolovers.exploitfixer.bungee.ExploitFixer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.MessagesModule; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bungee.ExploitFixer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import java.util.Locale; diff --git a/src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java similarity index 89% rename from src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java rename to src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java index 69b55f6..553406d 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java @@ -1,17 +1,17 @@ -package twolovers.exploitfixer.bungee.instanceables; +package dev._2lstudios.exploitfixer.bungee.instanceables; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Cancellable; import net.md_5.bungee.api.plugin.Plugin; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.MessagesModule; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; -import twolovers.exploitfixer.shared.interfaces.Module; -import twolovers.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; import java.io.BufferedReader; import java.io.InputStreamReader; diff --git a/src/twolovers/exploitfixer/bungee/instanceables/Violations.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java similarity index 92% rename from src/twolovers/exploitfixer/bungee/instanceables/Violations.java rename to src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java index 58f5421..c0d5bc0 100644 --- a/src/twolovers/exploitfixer/bungee/instanceables/Violations.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.bungee.instanceables; +package dev._2lstudios.exploitfixer.bungee.instanceables; import java.util.Collection; import java.util.HashMap; diff --git a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java similarity index 83% rename from src/twolovers/exploitfixer/bungee/listeners/ChatListener.java rename to src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index 30aceb2..8e83796 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -1,75 +1,75 @@ -package twolovers.exploitfixer.bungee.listeners; - -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.ChatEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.CommandsModule; -import twolovers.exploitfixer.bungee.modules.MessagesModule; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; - -public class ChatListener implements Listener { - private final Plugin plugin; - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - - public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.commandsModule = moduleManager.getCommandsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); - } - - @EventHandler(priority = -128) - public void onChat(final ChatEvent event) { - if (!event.isCancelled()) { - final Connection connection = event.getSender(); - - if (connection instanceof ProxiedPlayer) { - final ProxiedPlayer player = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - - if (!exploitPlayer.isLogged()) { - event.setCancelled(true); - } else if (commandsModule.isEnabled()) { - final ProxyServer server = plugin.getProxy(); - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ") || message.endsWith(command)) { - for (final String punishment : commandsModule.getPunishments()) { - if (punishment.equals("kick")) { - final String locale = player.getLocale().toString().substring(0, 2); - final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); - - player.disconnect(TextComponent.fromLegacyText(kickMessage)); - exploitPlayerManager.addPunishment(); - } else if (punishment.equals("notification")) { - final String moduleName = commandsModule.getName(); - - notificationsModule.sendNotification(moduleName, player, (int) 1); - } else { - server.getPluginManager().dispatchCommand(server.getConsole(), - punishment.replace("%player%", player.getName())); - } - } - - event.setCancelled(true); - break; - } - } - } - } - } - } -} +package dev._2lstudios.exploitfixer.bungee.listeners; + +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ChatEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.event.EventHandler; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.CommandsModule; +import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; + +public class ChatListener implements Listener { + private final Plugin plugin; + private final CommandsModule commandsModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + + public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.commandsModule = moduleManager.getCommandsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); + } + + @EventHandler(priority = -128) + public void onChat(final ChatEvent event) { + if (!event.isCancelled()) { + final Connection connection = event.getSender(); + + if (connection instanceof ProxiedPlayer) { + final ProxiedPlayer player = (ProxiedPlayer) connection; + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + + if (!exploitPlayer.isLogged()) { + event.setCancelled(true); + } else if (commandsModule.isEnabled()) { + final ProxyServer server = plugin.getProxy(); + final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + + for (final String command : commandsModule.getCommands()) { + if (message.startsWith(command + " ") || message.endsWith(command)) { + for (final String punishment : commandsModule.getPunishments()) { + if (punishment.equals("kick")) { + final String locale = player.getLocale().toString().substring(0, 2); + final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); + + player.disconnect(TextComponent.fromLegacyText(kickMessage)); + exploitPlayerManager.addPunishment(); + } else if (punishment.equals("notification")) { + final String moduleName = commandsModule.getName(); + + notificationsModule.sendNotification(moduleName, player, (int) 1); + } else { + server.getPluginManager().dispatchCommand(server.getConsole(), + punishment.replace("%player%", player.getName())); + } + } + + event.setCancelled(true); + break; + } + } + } + } + } + } +} diff --git a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java similarity index 74% rename from src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java rename to src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java index 87ad7f8..d5c72cd 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java @@ -1,33 +1,33 @@ -package twolovers.exploitfixer.bungee.listeners; - -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PlayerDisconnectEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; - -public class DisconnectListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - - public DisconnectListener(final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - } - - @EventHandler - public void onDisconnect(final PlayerDisconnectEvent event) { - final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); - - if (exploitPlayer != null) { - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); - } - - notificationsModule.setNotifications(proxiedPlayer, false); - } -} +package dev._2lstudios.exploitfixer.bungee.listeners; + +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PlayerDisconnectEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; + +public class DisconnectListener implements Listener { + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + + public DisconnectListener(final ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + } + + @EventHandler + public void onDisconnect(final PlayerDisconnectEvent event) { + final ProxiedPlayer proxiedPlayer = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); + + if (exploitPlayer != null) { + exploitPlayer.clearChannels(); + exploitPlayer.clearViolations(); + } + + notificationsModule.setNotifications(proxiedPlayer, false); + } +} diff --git a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java similarity index 86% rename from src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java rename to src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java index 5806969..9cf00f5 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -1,80 +1,80 @@ -package twolovers.exploitfixer.bungee.listeners; - -import java.util.logging.Logger; - -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PluginMessageEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.event.EventHandler; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.CustomPayloadModule; - -public class PluginMessageListener implements Listener { - private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - - public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - } - - @EventHandler(priority = -128) - public void onPluginMessage(final PluginMessageEvent event) { - if (!event.isCancelled() && customPayloadModule.isEnabled()) { - final Connection connection = event.getSender(); - - if (connection instanceof ProxiedPlayer) { - final Logger logger = plugin.getLogger(); - final ProxiedPlayer player = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - final String tag = event.getTag(), playerName = player.getName(); - final double tagVls = customPayloadModule.getTagVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); - return; - } else { - final byte[] data = event.getData(); - final int byteLength = data.length; - - if (byteLength > customPayloadModule.getDataBytes()) { - if (notificationsModule.isDebug()) { - logger.info("[PacketPlayInCustomPayload] Sent by " + playerName - + " got cancelled because its " + byteLength + " bytes long!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getDataVls()); - return; - } else if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - /* - * if (byteLength > customPayloadModule.getBookBytes()) { logger.info(playerName - * + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ - } - - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getMultiplier(tag)); - } - } - } - } -} +package dev._2lstudios.exploitfixer.bungee.listeners; + +import java.util.logging.Logger; + +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.event.EventHandler; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.CustomPayloadModule; + +public class PluginMessageListener implements Listener { + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + + public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + } + + @EventHandler(priority = -128) + public void onPluginMessage(final PluginMessageEvent event) { + if (!event.isCancelled() && customPayloadModule.isEnabled()) { + final Connection connection = event.getSender(); + + if (connection instanceof ProxiedPlayer) { + final Logger logger = plugin.getLogger(); + final ProxiedPlayer player = (ProxiedPlayer) connection; + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final String tag = event.getTag(), playerName = player.getName(); + final double tagVls = customPayloadModule.getTagVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + return; + } else { + final byte[] data = event.getData(); + final int byteLength = data.length; + + if (byteLength > customPayloadModule.getDataBytes()) { + if (notificationsModule.isDebug()) { + logger.info("[PacketPlayInCustomPayload] Sent by " + playerName + + " got cancelled because its " + byteLength + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getDataVls()); + return; + } else if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + /* + * if (byteLength > customPayloadModule.getBookBytes()) { logger.info(playerName + * + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, player, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } + } + } +} diff --git a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java similarity index 85% rename from src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java rename to src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 8bd8620..35e4963 100644 --- a/src/twolovers/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -1,84 +1,84 @@ -package twolovers.exploitfixer.bungee.listeners; - -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PostLoginEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.scheduler.TaskScheduler; -import net.md_5.bungee.event.EventHandler; -import net.md_5.bungee.event.EventPriority; -import twolovers.exploitfixer.bungee.modules.ConnectionModule; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.bungee.modules.MessagesModule; -import twolovers.exploitfixer.bungee.modules.NotificationsModule; - -import java.net.InetSocketAddress; -import java.util.Locale; -import java.util.UUID; - -public class PostLoginListener implements Listener { - private final Plugin plugin; - private final ConnectionModule connectionModule; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - private final ExploitPlayerManager exploitPlayerManager; - - public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.connectionModule = moduleManager.getConnectionModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPostLogin(final PostLoginEvent event) { - final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final InetSocketAddress address = proxiedPlayer.getAddress(); - final Locale playerLocale = proxiedPlayer.getLocale(); - final String locale; - - if (playerLocale != null) - locale = playerLocale.toLanguageTag().substring(0, 2); - else - locale = "en"; - - if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { - proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage("nulladdress", locale))); - } else { - final UUID uuid = proxiedPlayer.getUniqueId(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); - - if (connectionModule.isUUIDSpoofEnabled()) { - final TaskScheduler scheduler = plugin.getProxy().getScheduler(); - final String playerName = proxiedPlayer.getName(); - - scheduler.runAsync(plugin, () -> { - final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) - .toString().replace("-", ""); - - if (!originalUUID.contains(offlineUUID)) { - final String onlineUUID = exploitPlayer.getOnlineUUID(); - - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - - proxiedPlayer.disconnect(new TextComponent(uuidSpoofKickMessage)); - } - } - - exploitPlayer.setLogged(true); - }); - } else - exploitPlayer.setLogged(true); - } - - if (proxiedPlayer.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(proxiedPlayer, true); - } - } +package dev._2lstudios.exploitfixer.bungee.listeners; + +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PostLoginEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.api.scheduler.TaskScheduler; +import net.md_5.bungee.event.EventHandler; +import net.md_5.bungee.event.EventPriority; +import dev._2lstudios.exploitfixer.bungee.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; + +import java.net.InetSocketAddress; +import java.util.Locale; +import java.util.UUID; + +public class PostLoginListener implements Listener { + private final Plugin plugin; + private final ConnectionModule connectionModule; + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + private final ExploitPlayerManager exploitPlayerManager; + + public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.connectionModule = moduleManager.getConnectionModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.messagesModule = moduleManager.getMessagesModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPostLogin(final PostLoginEvent event) { + final ProxiedPlayer proxiedPlayer = event.getPlayer(); + final InetSocketAddress address = proxiedPlayer.getAddress(); + final Locale playerLocale = proxiedPlayer.getLocale(); + final String locale; + + if (playerLocale != null) + locale = playerLocale.toLanguageTag().substring(0, 2); + else + locale = "en"; + + if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { + proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage("nulladdress", locale))); + } else { + final UUID uuid = proxiedPlayer.getUniqueId(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); + + if (connectionModule.isUUIDSpoofEnabled()) { + final TaskScheduler scheduler = plugin.getProxy().getScheduler(); + final String playerName = proxiedPlayer.getName(); + + scheduler.runAsync(plugin, () -> { + final String originalUUID = uuid.toString().replace("-", ""); + final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) + .toString().replace("-", ""); + + if (!originalUUID.contains(offlineUUID)) { + final String onlineUUID = exploitPlayer.getOnlineUUID(); + + if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); + + proxiedPlayer.disconnect(new TextComponent(uuidSpoofKickMessage)); + } + } + + exploitPlayer.setLogged(true); + }); + } else + exploitPlayer.setLogged(true); + } + + if (proxiedPlayer.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(proxiedPlayer, true); + } + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java similarity index 89% rename from src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java rename to src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index aa81dc6..21ab45c 100644 --- a/src/twolovers/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -1,9 +1,9 @@ -package twolovers.exploitfixer.bungee.managers; +package dev._2lstudios.exploitfixer.bungee.managers; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; -import twolovers.exploitfixer.bungee.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import java.util.HashMap; import java.util.Iterator; import java.util.Map; diff --git a/src/twolovers/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java similarity index 91% rename from src/twolovers/exploitfixer/bungee/managers/ModuleManager.java rename to src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index c012635..52708e1 100644 --- a/src/twolovers/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -1,9 +1,9 @@ -package twolovers.exploitfixer.bungee.managers; +package dev._2lstudios.exploitfixer.bungee.managers; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.modules.*; -import twolovers.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.modules.*; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; public class ModuleManager { private CommandsModule commandsModule; diff --git a/src/twolovers/exploitfixer/bungee/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java similarity index 87% rename from src/twolovers/exploitfixer/bungee/modules/CommandsModule.java rename to src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java index 4842985..121b785 100644 --- a/src/twolovers/exploitfixer/bungee/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java @@ -1,7 +1,7 @@ -package twolovers.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.shared.interfaces.PunishmentModule; +import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; import java.util.Collection; diff --git a/src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java similarity index 89% rename from src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java rename to src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java index 0f8dfb2..36b2926 100644 --- a/src/twolovers/exploitfixer/bungee/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java @@ -1,10 +1,10 @@ -package twolovers.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.bungee.modules; import java.util.Collection; import java.util.HashSet; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.shared.interfaces.PunishmentModule; +import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; public class ConnectionModule implements PunishmentModule { private boolean uuidSpoofEnabled, nullAddressEnabled; diff --git a/src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java similarity index 90% rename from src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java rename to src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java index 141afce..482c2f1 100644 --- a/src/twolovers/exploitfixer/bungee/modules/CustomPayloadModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java @@ -1,13 +1,13 @@ -package twolovers.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.bungee.modules; import java.util.HashMap; import java.util.Map; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.bungee.instanceables.Violations; -import twolovers.exploitfixer.bungee.managers.ModuleManager; -import twolovers.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.bungee.instanceables.Violations; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; public class CustomPayloadModule implements ViolationModule { private Map multipliers = new HashMap<>(); diff --git a/src/twolovers/exploitfixer/bungee/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java similarity index 94% rename from src/twolovers/exploitfixer/bungee/modules/MessagesModule.java rename to src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java index 744c3b8..ad9e75c 100644 --- a/src/twolovers/exploitfixer/bungee/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java @@ -1,7 +1,7 @@ -package twolovers.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.bungee.modules; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class MessagesModule { private Configuration messagesYml; diff --git a/src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java similarity index 94% rename from src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java index dfd99a2..47f07f9 100644 --- a/src/twolovers/exploitfixer/bungee/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java @@ -1,11 +1,11 @@ -package twolovers.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.bungee.modules; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.config.Configuration; -import twolovers.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; import java.util.Collection; import java.util.HashSet; diff --git a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java similarity index 75% rename from src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java rename to src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java index 4714238..2aba245 100644 --- a/src/twolovers/exploitfixer/bungee/utils/ConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java @@ -1,78 +1,86 @@ -package twolovers.exploitfixer.bungee.utils; - -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import net.md_5.bungee.config.ConfigurationProvider; -import net.md_5.bungee.config.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.logging.Level; - -public class ConfigurationUtil { - final private Plugin plugin; - - public ConfigurationUtil(final Plugin plugin) { - this.plugin = plugin; - } - - public Configuration getConfiguration(String file) { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); - - try { - return ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(file)); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - public void createConfiguration(String file) { - try { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); - - final File configFile = new File(file); - - if (!configFile.exists()) { - final String[] files = file.split("/"); - final InputStream inputStream = plugin.getClass().getClassLoader().getResourceAsStream(files[files.length - 1]); - final File parentFile = configFile.getParentFile(); - - if (parentFile != null) parentFile.mkdirs(); - - if (inputStream != null) { - Files.copy(inputStream, configFile.toPath()); - plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName())); - } else configFile.createNewFile(); - } - } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName())); - } - } - - public void saveConfiguration(final Configuration configuration, final String file) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - try { - final File dataFolder = plugin.getDataFolder(); - - ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(file.replace("%datafolder%", dataFolder.toPath().toString()))); - } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName())); - } - }); - } - - public void deleteConfiguration(final String file) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final File file1 = new File(file); - - if (file1.exists()) file1.delete(); - }); - } +package dev._2lstudios.exploitfixer.bungee.utils; + +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; +import net.md_5.bungee.config.ConfigurationProvider; +import net.md_5.bungee.config.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.logging.Level; + +public class ConfigurationUtil { + final private Plugin plugin; + + public ConfigurationUtil(final Plugin plugin) { + this.plugin = plugin; + } + + public Configuration getConfiguration(String file) { + final File dataFolder = plugin.getDataFolder(); + + file = file.replace("%datafolder%", dataFolder.toPath().toString()); + + try { + return ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(file)); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + public void createConfiguration(String file) { + try { + final File dataFolder = plugin.getDataFolder(); + + file = file.replace("%datafolder%", dataFolder.toPath().toString()); + + final File configFile = new File(file); + + if (!configFile.exists()) { + final String[] files = file.split("/"); + final InputStream inputStream = plugin.getClass().getClassLoader() + .getResourceAsStream(files[files.length - 1]); + final File parentFile = configFile.getParentFile(); + + if (parentFile != null) + parentFile.mkdirs(); + + if (inputStream != null) { + Files.copy(inputStream, configFile.toPath()); + plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") + .replace("%pluginname%", plugin.getDescription().getName())); + } else + configFile.createNewFile(); + } + } catch (final IOException e) { + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!") + .replace("%pluginname%", plugin.getDescription().getName())); + } + } + + public void saveConfiguration(final Configuration configuration, final String file) { + plugin.getProxy().getScheduler().runAsync(plugin, () -> { + try { + final File dataFolder = plugin.getDataFolder(); + + ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, + new File(file.replace("%datafolder%", dataFolder.toPath().toString()))); + } catch (final IOException e) { + plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") + .replace("%pluginname%", plugin.getDescription().getName())); + } + }); + } + + public void deleteConfiguration(final String file) { + plugin.getProxy().getScheduler().runAsync(plugin, () -> { + final File file1 = new File(file); + + if (file1.exists()) + file1.delete(); + }); + } } \ No newline at end of file diff --git a/src/twolovers/exploitfixer/shared/interfaces/Module.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java similarity index 62% rename from src/twolovers/exploitfixer/shared/interfaces/Module.java rename to src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java index ad54c8c..eea6423 100644 --- a/src/twolovers/exploitfixer/shared/interfaces/Module.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.shared.interfaces; public interface Module { public boolean isEnabled(); diff --git a/src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java similarity index 70% rename from src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java rename to src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java index 8626cf8..649ec93 100644 --- a/src/twolovers/exploitfixer/shared/interfaces/PunishmentModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.shared.interfaces; import java.util.Collection; diff --git a/src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java similarity index 74% rename from src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java rename to src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java index 212b64d..931f481 100644 --- a/src/twolovers/exploitfixer/shared/interfaces/ViolationModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java @@ -1,4 +1,4 @@ -package twolovers.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.shared.interfaces; public interface ViolationModule extends Module { public double getCancelVls(); diff --git a/src/messages.yml b/src/messages.yml index 97eb460..55faa2b 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -69,37 +69,37 @@ es: &fJugadores en cache: &a%players_cached% &fJugadores sancionados: &a%players_punished% -# Portuguese +# Portuguese - Credits: LucaAzalim pt: commands: reload: "&aPlugin ExploitFixer recarregado!" help: |- &aExploitFixer &b%version%&a por &bLinsaFTW&a. &e /%command% help &7> &bComandos disponiveis. - &e /%command% reload &7> &bReload plugin. - &e /%command% notifications &7> &bAtivar as notificações do plugin. - &e /%command% stats &7> &bVer statisticas do plugin. + &e /%command% reload &7> &bRecarrega o plugin. + &e /%command% notifications &7> &bAtiva as notificações do plugin. + &e /%command% stats &7> &bVer as estatísticas do plugin. error: unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" - permission: "&cSem permissao para usar este comando!" - console: "&cEsse comando não pode ser executa pelo console!" + permission: "&cSem permissão para usar esse comando!" + console: "&cEsse comando não pode ser executado pelo console!" notifications: - enable: "&aVoce ativou as notificações!" - disable: "&cVoce desativou as notificações!" + enable: "&cVocê ativou as notificações!" + disable: "&cVocê desativou as notificações!" modules: custompayload: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" uuidspoof: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" commands: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" packets: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" nulladdress: - kick_message: "&cVoce foi temporariamente bloqueado!\n\n&7Reason: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" stats: message: |- - &fJugadores em cache: &a%players_cached% + &fJogadores em cache: &a%players_cached% &fJogadores punidos: &a%players_punished% # Italian diff --git a/src/plugin.yml b/src/plugin.yml index 03f903e..a91a811 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer -main: twolovers.exploitfixer.bukkit.ExploitFixer -version: 1.3.3 +main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer +version: 1.3.4 author: 2LS api: "1.13" api-version: "1.13" diff --git a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java b/src/twolovers/exploitfixer/bukkit/ExploitFixer.java deleted file mode 100644 index 4a77622..0000000 --- a/src/twolovers/exploitfixer/bukkit/ExploitFixer.java +++ /dev/null @@ -1,119 +0,0 @@ -package twolovers.exploitfixer.bukkit; - -import java.util.logging.Logger; - -import org.bukkit.Server; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitScheduler; - -import twolovers.exploitfixer.bukkit.commands.ExploitFixerCommand; -import twolovers.exploitfixer.bukkit.listeners.initializers.HamsterAPIListenerInitializer; -import twolovers.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.utils.ConfigurationUtil; -import twolovers.exploitfixer.bukkit.utils.VersionUtil; - -public class ExploitFixer extends JavaPlugin { - private static ExploitFixer exploitFixer; - private ModuleManager moduleManager; - private ListenerInitializer listenerInitializer; - private HamsterAPIListenerInitializer hamsterAPIListenerInitializer; - - @Override - public void onEnable() { - final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); - final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); - - final YamlConfiguration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); - - exploitFixer = this; - this.moduleManager = new ModuleManager(this, configYml, messagesYml); - this.listenerInitializer = new ListenerInitializer(this, moduleManager); - - if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - final Logger logger = this.getLogger(); - - this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); - - logger.info("Successfully hooked with HamsterAPI!"); - } else { - final Logger logger = this.getLogger(); - - for (int i = 0; i < 10; i++) { - logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); - } - } - - server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); - - VersionUtil.init(); - reload(); - - scheduler.runTaskTimerAsynchronously(this, () -> { - final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - - exploitPlayerManager.clear(); - }, 9000L, 9000L); - } - - @Override - public void onDisable() { - final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); - - scheduler.cancelTasks(this); - - this.listenerInitializer.stop(); - - if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.hamsterAPIListenerInitializer.stop(); - } else { - final Logger logger = this.getLogger(); - - for (int i = 0; i < 10; i++) { - logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); - } - } - } - - public void reload() { - if (isEnabled()) { - final Server server = getServer(); - final Logger logger = server.getLogger(); - final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - - server.getMessenger().unregisterIncomingPluginChannel(this); - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); - - final YamlConfiguration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); - final YamlConfiguration spigotYml = configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); - - moduleManager.reload(configYml, messagesYml, spigotYml); - - this.listenerInitializer.start(); - - if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.hamsterAPIListenerInitializer.start(); - } else { - for (int i = 0; i < 10; i++) { - logger.severe("ExploitFixer requires HamsterAPI to protect agaisnt exploits!"); - } - } - - getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); - } - } - - public static ExploitFixer getInstance() { - return exploitFixer; - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java deleted file mode 100644 index 1433d80..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerDecodeListener.java +++ /dev/null @@ -1,356 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; -import java.util.logging.Logger; - -import org.bukkit.GameMode; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; - -import hamsterapi.enums.PacketType; -import hamsterapi.interfaces.DecodeListener; -import hamsterapi.wrappers.EventWrapper; -import hamsterapi.wrappers.PacketWrapper; -import twolovers.exploitfixer.bukkit.instanceables.ExploitPlayer; -import twolovers.exploitfixer.bukkit.managers.ExploitPlayerManager; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; -import twolovers.exploitfixer.bukkit.modules.CustomPayloadModule; -import twolovers.exploitfixer.bukkit.modules.ItemsFixModule; -import twolovers.exploitfixer.bukkit.modules.NotificationsModule; -import twolovers.exploitfixer.bukkit.modules.PacketsModule; - -public class ExploitFixerDecodeListener implements DecodeListener { - private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; - private final ItemsFixModule itemsFixModule; - - public ExploitFixerDecodeListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.packetsModule = moduleManager.getPacketsModule(); - this.itemsFixModule = moduleManager.getItemsFixModule(); - } - - @Override - public void onPacketDecode(final EventWrapper event) { - if (!event.isCancelled()) { - final PacketWrapper packetWrapper = event.getPacket(); - final PacketType packetType = packetWrapper.getType(); - final Player player = event.getPlayer(); - - if (packetType != PacketType.PacketPlayInKeepAlive) { - final Logger logger = plugin.getLogger(); - - if (player != null && player.isOnline()) { - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - - if (exploitPlayer != null) { - final Map strings = packetWrapper.getStrings(); - final String packetName = packetWrapper.getName(); - - if (packetsModule.isEnabled()) { - final Map integers = packetWrapper.getIntegers(); - final Map items = packetWrapper.getItems(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(), - setCreativeSlot = packetsModule.getSetCreativeSlot(), - dataVls = packetsModule.getDataVls(); - final int dataBytes = packetsModule.getDataBytes(), - dataBytesSigns = packetsModule.getDataBytesSign(); - - if (integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(), - bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " has a slot less than 0 (" + slot + ")"); - } - - event.setCancelled(true); - return; - } else if (slot >= maxSlots) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " exceeded max available slots (" + slot + "/" - + maxSlots + ") on " + packetName + "! Added vls: " + windowClick); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - return; - } - } - - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { - if (player.getGameMode() != GameMode.CREATIVE) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " - + setCreativeSlot); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); - return; - } else if (itemsFixModule.isEnabled() && items.containsKey("b")) { - final ItemStack itemStack = itemsFixModule.fixItem(items.get("b")); - - packetWrapper.write("b", itemStack); - - if (notificationsModule.isDebug()) { - logger.info(playerName + " had a creative item fixed by ExploiFixer!"); - } - } - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += checkItem((ItemStack) object, exploitPlayer, player); - } else { - packetSize += String.valueOf(object) - .getBytes(StandardCharsets.UTF_8).length; - } - } - } - - if (dataBytes > 0 && packetSize > dataBytes) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "] Sent by " + playerName - + " got cancelled because its " + packetSize + " bytes long!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && checkSign(strings.values().toArray(new String[0]))) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " has sent a too big sign packet! Added vls: " - + dataVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); - return; - } - } - - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); - - exploitPlayer.addVls(plugin, event, player, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); - } - - if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = customPayloadModule.getTagVls(), - bookVls = customPayloadModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info( - playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); - return; - } else { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory - .getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " tried to send a " + tag - + " custompayload packet without a book in hand!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, bookVls); - return; - } /* - * else if (byteLength > customPayloadModule.getBookBytes()) { - * logger.info(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ - } - - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getMultiplier(tag)); - } - } else { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent a empty CustomPayload packet!"); - } - - event.setCancelled(true); - } - } - } else if (packetsModule.isOffline()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent a packet while offline!"); - } - - event.setCancelled(true); - event.abort(); - } - } else if (packetsModule.isOffline()) { - if (notificationsModule.isDebug()) { - logger.info("OFFLINEPLAYER sent a packet while offline!"); - } - - event.setCancelled(true); - event.abort(); - } - } - } - } - - private int checkItem(final ItemStack itemStack, final ExploitPlayer exploitPlayer, final Player player) { - final Logger logger = plugin.getLogger(); - int itemBytesLength = 0; - - if (itemStack != null) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - - try { - itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final Exception exception) { - if (notificationsModule.isDebug()) { - logger.info("There was an exception when processing itemStack data to String!"); - } - } - - if (itemStack.hasItemMeta() && itemMeta != null) { - try { - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += checkItem(itemStack1, exploitPlayer, player); - } - } - } - } else { - throw new Exception(); - } - } catch (final Exception exception) { - if (itemMeta instanceof BookMeta) { - itemBytesLength += checkBook(exploitPlayer, player, itemMeta); - } else { - try { - itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - itemBytesLength += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; - } - } - } - } - } - - return itemBytesLength; - } - - private int checkBook(final ExploitPlayer exploitPlayer, final Player player, final ItemMeta itemMeta) { - final Logger logger = plugin.getLogger(); - final BookMeta bookMeta = (BookMeta) itemMeta; - final double dataVls = packetsModule.getDataVls(); - final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); - int bookTotalBytes = 0; - - if (pageCount > 50) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" - + 50 + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); - } else { - for (final String page : bookMeta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; - - bookTotalBytes += pageBytes; - - if (pageBytes > dataBytesBook) { - if (notificationsModule.isDebug()) { - logger.info( - player.getName() + " has sent a packet with a book with too many characters per page! (" - + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); - break; - } - } - - return bookTotalBytes; - } - - return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } - - private boolean checkSign(final String[] linesString) { - final int dataBytesSign = packetsModule.getDataBytesSign(); - - if (linesString != null) { - if (linesString.length > 4) { - return true; - } else { - for (final String line : linesString) { - if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { - return true; - } - } - } - } - - return false; - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java b/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java deleted file mode 100644 index e89c89c..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners; - -import org.bukkit.plugin.Plugin; - -import hamsterapi.interfaces.PreProcessListener; -import hamsterapi.wrappers.EventWrapper; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; - -public class ExploitFixerPreProcessListener implements PreProcessListener { - public ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { - } - - @Override - public void onPacketPreProcess(final EventWrapper event) { - } -} \ No newline at end of file diff --git a/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java b/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java deleted file mode 100644 index a40a859..0000000 --- a/src/twolovers/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java +++ /dev/null @@ -1,40 +0,0 @@ -package twolovers.exploitfixer.bukkit.listeners.initializers; - -import org.bukkit.plugin.Plugin; - -import hamsterapi.HamsterAPI; -import hamsterapi.handlers.DecodeEventHandler; -import hamsterapi.handlers.PreProcessEventHandler; -import twolovers.exploitfixer.bukkit.listeners.ExploitFixerDecodeListener; -import twolovers.exploitfixer.bukkit.listeners.ExploitFixerPreProcessListener; -import twolovers.exploitfixer.bukkit.managers.ModuleManager; - -public class HamsterAPIListenerInitializer { - private final Plugin plugin; - private final ModuleManager moduleManager; - private ExploitFixerPreProcessListener exploitFixerPreProcessListener; - private ExploitFixerDecodeListener exploitFixerDecodeListener; - - public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.moduleManager = moduleManager; - } - - public void start() { - final PreProcessEventHandler preProcessEventHandler = HamsterAPI.getPreProcessEventHandler(); - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); - - // preProcessEventHandler.addListener(this.exploitFixerPreProcessListener = new - // ExploitFixerPreProcessListener(plugin, moduleManager)); - decodeEventHandler - .addListener(this.exploitFixerDecodeListener = new ExploitFixerDecodeListener(plugin, moduleManager)); - } - - public void stop() { - final PreProcessEventHandler preProcessEventHandler = HamsterAPI.getPreProcessEventHandler(); - final DecodeEventHandler decodeEventHandler = HamsterAPI.getDecodeEventHandler(); - - // preProcessEventHandler.removeListener(exploitFixerPreProcessListener); - decodeEventHandler.removeListener(exploitFixerDecodeListener); - } -} diff --git a/src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java deleted file mode 100644 index 5eab8c1..0000000 --- a/src/twolovers/exploitfixer/bukkit/modules/ItemsFixModule.java +++ /dev/null @@ -1,104 +0,0 @@ -package twolovers.exploitfixer.bukkit.modules; - -import java.util.List; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.configuration.Configuration; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; - -import twolovers.exploitfixer.bukkit.modules.ItemsFixModule; -import twolovers.exploitfixer.shared.interfaces.Module; - -public class ItemsFixModule implements Module { - private final Plugin plugin; - private boolean enabled; - private int enchantLimit, maxStackSize; - - public ItemsFixModule(final Plugin plugin, final Configuration configYml) { - this.plugin = plugin; - reload(configYml); - } - - final public void reload(final Configuration configYml) { - final String name = getName().toLowerCase(); - - this.enabled = configYml.getBoolean(name + ".enabled", true); - this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); - this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return "ItemsFix"; - } - - public int getEnchantLimit() { - return enchantLimit; - } - - public int getMaxStackSize() { - return maxStackSize; - } - - public ItemStack fixItem(final ItemStack itemStack) { - if (itemStack != null) { - final Material material = Material.getMaterial(itemStack.getType().name()); - final ItemMeta itemMeta = itemStack.getItemMeta(), - newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final int maxStackSize = getMaxStackSize(); - final short durability = itemStack.getDurability(); - - if (itemStack.hasItemMeta()) { - final Map enchantments = itemStack.getEnchantments(); - final String displayName = itemMeta.getDisplayName(); - final List lore = itemMeta.getLore(); - - if (enchantLimit > -1) { - for (final Enchantment enchantment : enchantments.keySet()) { - final int level = enchantments.get(enchantment); - - if (level <= enchantLimit && level > -1) { - newItemMeta.addEnchant(enchantment, level, true); - } - } - } - - if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; - final BookMeta newBookMeta = (BookMeta) newItemMeta; - - newBookMeta.setTitle(bookMeta.getTitle()); - newBookMeta.setAuthor(bookMeta.getAuthor()); - newBookMeta.setPages(bookMeta.getPages()); - } - - if (displayName != null && displayName.getBytes().length < 128) - newItemMeta.setDisplayName(displayName); - - if (lore != null && lore.toString().getBytes().length < 1024) { - newItemMeta.setLore(lore); - } - } - - if (maxStackSize > 0 && itemStack.getAmount() > maxStackSize) { - itemStack.setAmount(maxStackSize); - } - - itemStack.setType(material); - itemStack.setItemMeta(newItemMeta); - itemStack.setDurability(durability); - } - - return itemStack; - } -} From 7766e8caf24f54d5f6dc68b03d9b87f6e9f1ab17 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 May 2020 02:22:47 -0300 Subject: [PATCH 063/336] Updated source --- src/bungee.yml | 2 +- src/config.yml | 4 +- .../exploitfixer/bukkit/ExploitFixer.java | 49 ++- .../bukkit/instanceables/ExploitPlayer.java | 134 +++---- .../ExploitFixerPostProcessListener.java | 301 +++++++++++++++- .../ExploitFixerPreProcessListener.java | 330 +----------------- .../listeners/PlayerCommandListener.java | 6 +- .../bukkit/listeners/PlayerLoginListener.java | 7 +- .../bukkit/listeners/PlayerQuitListener.java | 10 +- .../listeners/PlayerTeleportListener.java | 2 +- .../HamsterAPIListenerInitializer.java | 13 +- .../initializers/ListenerInitializer.java | 13 +- .../bukkit/managers/ExploitPlayerManager.java | 11 +- .../bukkit/utils/VersionUtil.java | 2 +- src/plugin.yml | 4 +- 15 files changed, 457 insertions(+), 431 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index ec6e933..fa54434 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.4 +version: 1.3.5 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 6344b05..89f47b1 100644 --- a/src/config.yml +++ b/src/config.yml @@ -51,10 +51,10 @@ itemsfix: # List of materials that are unobtainable from Creative. blacklist: - - "BARRIER" - "END_PORTAL" - "NETHER_PORTAL" - - "COMMAND_BLOCK" + # - "BARRIER" + # - "COMMAND_BLOCK" # Prevents the use of CustomPayload packets to exploit the server. custompayload: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 6f65606..a7722e6 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -35,29 +35,32 @@ public void onEnable() { final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); - VersionUtil.init(); + VersionUtil.initialize(); exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); this.listenerInitializer = new ListenerInitializer(this, moduleManager); + registerListeners(); registerCommands(); if (checkHamsterAPI()) { server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); - registerHamsterApi(); - - scheduler.runTaskTimerAsynchronously(this, () -> { - final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); - exploitPlayerManager.clear(); - }, 9000L, 9000L); + registerHamsterApi(); } else { scheduler.runTaskTimer(this, () -> this.getLogger().severe( "ExploitFixer requires HamsterAPI 0.0.6 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), 20L, 20L); } + + scheduler.runTaskTimerAsynchronously(this, () -> { + final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); + + exploitPlayerManager.clear(); + }, 9000L, 9000L); } @Override @@ -67,10 +70,10 @@ public void onDisable() { scheduler.cancelTasks(this); - this.listenerInitializer.stop(); + this.listenerInitializer.unregister(); - if (server.getPluginManager().isPluginEnabled("HamsterAPI")) { - this.hamsterAPIListenerInitializer.stop(); + if (checkHamsterAPI()) { + this.hamsterAPIListenerInitializer.unregister(); } } @@ -87,13 +90,12 @@ public void reload() { moduleManager.reload(configYml, messagesYml, spigotYml); - this.listenerInitializer.start(); + registerCommands(); + registerListeners(); if (checkHamsterAPI()) { - this.hamsterAPIListenerInitializer.start(); + registerHamsterApi(); } - - registerCommands(); } private boolean checkHamsterAPI() { @@ -113,11 +115,26 @@ private void createConfigurations() { this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); } + private void registerListeners() { + final Logger logger = this.getLogger(); + + if (this.listenerInitializer.isRegistered()) { + this.listenerInitializer.unregister(); + } + + this.listenerInitializer.register(); + + logger.info("Successfully registered listeners!"); + } + private void registerHamsterApi() { final Logger logger = this.getLogger(); - this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); - this.hamsterAPIListenerInitializer.start(); + if (this.hamsterAPIListenerInitializer.isRegistered()) { + this.hamsterAPIListenerInitializer.unregister(); + } + + this.hamsterAPIListenerInitializer.register(); logger.info("Successfully hooked with HamsterAPI!"); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 961b9c8..0ab79ce 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -29,6 +29,7 @@ public class ExploitPlayer { private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; private final Map violations = new HashMap<>(); + private final Collection> punishments = new HashSet<>(); private final String name; private String onlineUUID = null; private double lastViolation = 0; @@ -47,10 +48,6 @@ public int getChannels() { return channels; } - public void clearChannels() { - this.channels = 0; - } - public int addChannels(final int channels) { return this.channels += channels; } @@ -86,98 +83,99 @@ public String getOnlineUUID() { return onlineUUID; } - public void addVls(final Plugin plugin, final Cancellable event, final Player player, final ViolationModule module, - final double amount) { - addVls(plugin, event, null, player, module, amount); + public void addVls(final Plugin plugin, final Cancellable event, final HamsterPlayer hamsterPlayer, + final ViolationModule module, final double amount) { + addVls(plugin, event, null, hamsterPlayer, module, amount); } - public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, final Player player, - final ViolationModule module, final double amount) { - if (player.isOnline()) { - final Violations violations = (Violations) module.getViolations(); + public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, + final HamsterPlayer hamsterPlayer, final ViolationModule module, final double amount) { + final Player player = hamsterPlayer.getPlayer(); + final Violations violations = (Violations) module.getViolations(); - if (violations != null) { - final Server server = plugin.getServer(); - final double currentTime = System.currentTimeMillis(); + if (violations != null) { + final Server server = plugin.getServer(); + final double currentTime = System.currentTimeMillis(); - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; + if (currentTime - lastViolation >= 1000) { + lastViolation = currentTime; - for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); + for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { + final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - if (vls <= 0) { - this.violations.remove(violationModule); - } else { - this.violations.put(violationModule, vls); - } + if (vls <= 0) { + this.violations.remove(violationModule); + } else { + this.violations.put(violationModule, vls); } } + } - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; - - this.violations.put(module, newVls); + final double newVls = getViolations(module) + amount; - if (event instanceof Cancellable && module.getCancelVls() <= newVls) { - ((Cancellable) event).setCancelled(true); - } + this.violations.put(module, newVls); - for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); + if (event instanceof Cancellable && module.getCancelVls() <= newVls) { + ((Cancellable) event).setCancelled(true); + } - if (commands != null && !commands.isEmpty()) { - for (final String punishCommand : commands) { - if (punishCommand.equals("kick")) { - final String locale; + for (final int threshold : violations.getViolations()) { + if (threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); - if (VersionUtil.isOneDotFifteen()) - locale = player.getLocale().substring(0, 2); - else - locale = player.spigot().getLocale().substring(0, 2); + if (commands != null && !commands.isEmpty() && !punishments.contains(commands)) { + for (final String punishCommand : commands) { + if (punishCommand.equals("kick")) { + final String locale; - final String kickMessage = messagesModule.getKickMessage(module, locale); - final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + if (VersionUtil.isOneDotFifteen()) { + locale = player.getLocale().substring(0, 2); + } else { + locale = player.spigot().getLocale().substring(0, 2); + } - hamsterPlayer.kickPlayer(kickMessage); - hamsterPlayer.abort(); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) { - final String moduleName = module.getName(); + final String kickMessage = messagesModule.getKickMessage(module, locale); - if (packet != null) { - final PacketType packetType = packet.getType(); - final String name; + hamsterPlayer.disconnect(kickMessage); + hamsterPlayer.closeChannel(); + exploitPlayerManager.addPunishment(); + } else if (punishCommand.equals("notification")) { + final String moduleName = module.getName(); - if (packetType != null) { - name = packetType.toString(); - } else { - name = moduleName; - } + if (packet != null) { + final PacketType packetType = packet.getType(); + final String name; - notificationsModule.sendNotification(name, player, (int) newVls); + if (packetType != null) { + name = packetType.toString(); } else { - notificationsModule.sendNotification(moduleName, player, (int) newVls); + name = moduleName; } + + notificationsModule.sendNotification(name, player, (int) newVls); } else { - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishCommand.replace("%player%", player.getName())); - }); + notificationsModule.sendNotification(moduleName, player, (int) newVls); } + } else { + server.getScheduler().runTask(plugin, () -> { + server.dispatchCommand(server.getConsoleSender(), + punishCommand.replace("%player%", player.getName())); + }); } } + + punishments.add(commands); } } } - } else if (event instanceof Cancellable) { - ((Cancellable) event).setCancelled(true); } } - public void clearViolations() { - violations.clear(); + public void clear() { + this.violations.clear(); + this.punishments.clear(); + this.lastViolation = 0; + this.channels = 0; } public void setLogged(final boolean logged) { @@ -195,4 +193,8 @@ public void updateTeleportTimeMillis() { public long getTeleportTimeMillis() { return this.teleportTimeMillis; } + + public Collection> getPunishments() { + return this.punishments; + } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java index 6187e57..e22ea7e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java @@ -1,35 +1,218 @@ package dev._2lstudios.exploitfixer.bukkit.listeners; +import java.nio.charset.StandardCharsets; +import java.util.Collection; import java.util.Map; import java.util.logging.Logger; +import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.interfaces.PostProcessListener; import dev._2lstudios.hamsterapi.wrappers.EventWrapper; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class ExploitFixerPostProcessListener implements PostProcessListener { private final Plugin plugin; - private final NotificationsModule notificationsModule; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; private final ItemsFixModule itemsFixModule; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; public ExploitFixerPostProcessListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.notificationsModule = moduleManager.getNotificationsModule(); + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); } @Override public void onPacketReceive(final EventWrapper event) { if (!event.isCancelled()) { + final Logger logger = plugin.getLogger(); + final Player player = event.getPlayer(); final PacketWrapper packetWrapper = event.getPacket(); + final PacketType packetType = packetWrapper.getType(); + + if (packetType != PacketType.PacketPlayInKeepAlive) { + final Map strings = packetWrapper.getStrings(); + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final String playerName = player.getName(), packetName = packetWrapper.getName(); + final double dataVls = packetsModule.getDataVls(); + final int dataBytes = packetsModule.getDataBytes(); + + if (packetsModule.isEnabled()) { + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(), + setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(), + bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " has a slot less than 0 (" + slot + ")"); + } + + event.setCancelled(true); + return; + } else if (slot >= maxSlots) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " exceeded max available slots (" + slot + "/" + maxSlots + + ") on " + packetName + "! Added vls: " + windowClick); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { + if (player.getGameMode() != GameMode.CREATIVE) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + + setCreativeSlot); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); + return; + } + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += getItemLength((ItemStack) object, exploitPlayer, hamsterPlayer); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "] Sent by " + playerName + " got blocked because its " + + packetSize + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && checkSign(strings.values().toArray(new String[0]))) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " has sent a too big sign packet! Added vls: " + dataVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = customPayloadModule.getTagVls(), + bookVls = customPayloadModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, tagVls); + return; + } else { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + if (notificationsModule.isDebug()) { + logger.info(playerName + " tried to send a " + tag + + " custompayload packet without a book in hand!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, bookVls); + return; + } /* + * else if (byteLength > customPayloadModule.getBookBytes()) { + * logger.info(playerName + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } else { + if (notificationsModule.isDebug()) { + logger.info(playerName + " sent a empty CustomPayload packet!"); + } + + event.setCancelled(true); + } + } + } + final Map items = packetWrapper.getItems(); if (itemsFixModule.isEnabled() && items.containsKey("b")) { @@ -53,9 +236,6 @@ public void onPacketReceive(final EventWrapper event) { packetWrapper.write("b", fixedItemStack); if (notificationsModule.isDebug()) { - final Player player = event.getPlayer(); - final Logger logger = plugin.getLogger(); - if (player != null) { if (blocked != null) { logger.info(player.getName() + " had a creative item blocked by ExploiFixer! (" @@ -73,4 +253,115 @@ public void onPacketReceive(final EventWrapper event) { @Override public void onPacketSend(final EventWrapper event) { } + + private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, + final HamsterPlayer hamsterPlayer) { + final Logger logger = plugin.getLogger(); + int itemBytesLength = 0; + + if (itemStack != null) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + + try { + itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final Exception exception) { + if (notificationsModule.isDebug()) { + logger.info("There was an exception when processing itemStack data to String!"); + } + } + + if (itemStack.hasItemMeta() && itemMeta != null) { + try { + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { + itemBytesLength += getItemLength(itemStack1, exploitPlayer, hamsterPlayer); + } + } + } + } else { + throw new Exception(); + } + } catch (final Exception exception) { + if (itemMeta instanceof BookMeta) { + itemBytesLength += getBookLength(exploitPlayer, hamsterPlayer, itemMeta); + } else { + try { + itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + itemBytesLength += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + } + } + } + } + + return itemBytesLength; + } + + private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, + final ItemMeta itemMeta) { + final Player player = hamsterPlayer.getPlayer(); + final Logger logger = plugin.getLogger(); + final BookMeta bookMeta = (BookMeta) itemMeta; + final double dataVls = packetsModule.getDataVls(); + final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); + int bookTotalBytes = 0; + + if (pageCount > 50) { + if (notificationsModule.isDebug()) { + logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" + + 50 + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + } else { + for (final String page : bookMeta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + bookTotalBytes += pageBytes; + + if (pageBytes > dataBytesBook) { + if (notificationsModule.isDebug()) { + logger.info( + player.getName() + " has sent a packet with a book with too many characters per page! (" + + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + break; + } + } + + return bookTotalBytes; + } + + return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } + + private boolean checkSign(final String[] linesString) { + final int dataBytesSign = packetsModule.getDataBytesSign(); + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else { + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { + return true; + } + } + } + } + + return false; + } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java index 5bccd4b..06b3b11 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java @@ -1,22 +1,8 @@ package dev._2lstudios.exploitfixer.bukkit.listeners; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; import java.util.logging.Logger; -import org.bukkit.GameMode; -import org.bukkit.block.BlockState; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; @@ -26,15 +12,12 @@ import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; import dev._2lstudios.hamsterapi.interfaces.PreProcessListener; -import dev._2lstudios.hamsterapi.utils.BufferIO; import dev._2lstudios.hamsterapi.wrappers.EventWrapper; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; import io.netty.buffer.ByteBuf; public class ExploitFixerPreProcessListener implements PreProcessListener { - private final HamsterAPI hamsterAPI; private final Plugin plugin; private final CustomPayloadModule customPayloadModule; private final ExploitPlayerManager exploitPlayerManager; @@ -42,7 +25,7 @@ public class ExploitFixerPreProcessListener implements PreProcessListener { private final PacketsModule packetsModule; public ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { - this.hamsterAPI = HamsterAPI.getInstance(); + HamsterAPI.getInstance().getBufferIO(); this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -57,200 +40,23 @@ public void onPacketDecode(final EventWrapper event) { final Player player = event.getPlayer(); if (player != null && player.isOnline()) { - final BufferIO bufferIO = hamsterAPI.getBufferIO(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); final int dataBytes = packetsModule.getDataBytes(); final double dataVls = packetsModule.getDataVls(); final String playerName = player.getName(); + final ByteBuf byteBuf = event.getByteBuf().copy(); - try { - final ByteBuf buf = bufferIO.decompress(event.getByteBuf().copy(), 256); - - if (buf != null) { - final PacketWrapper packetWrapper = bufferIO.decode(event.getChannelHandlerContext(), buf, - dataBytes); - - if (packetWrapper != null) { - final PacketType packetType = packetWrapper.getType(); - - if (packetType != PacketType.PacketPlayInKeepAlive) { - final Map strings = packetWrapper.getStrings(); - final String packetName = packetWrapper.getName(); - - if (packetsModule.isEnabled()) { - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(), - setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(), - bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " has a slot less than 0 (" + slot + ")"); - } - - event.setCancelled(true); - return; - } else if (slot >= maxSlots) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " exceeded max available slots (" + slot + "/" - + maxSlots + ") on " + packetName + "! Added vls: " - + windowClick); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, windowClick); - return; - } - } - - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { - if (player.getGameMode() != GameMode.CREATIVE) { - if (notificationsModule.isDebug()) { - logger.info(playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " - + setCreativeSlot); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, setCreativeSlot); - return; - } - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += getItemLength((ItemStack) object, exploitPlayer, - player); - } else { - packetSize += String.valueOf(object) - .getBytes(StandardCharsets.UTF_8).length; - } - } - } - - if (dataBytes > 0 && packetSize > dataBytes) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "] Sent by " + playerName - + " got blocked because its " + packetSize + " bytes long!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && checkSign(strings.values().toArray(new String[0]))) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " has sent a too big sign packet! Added vls: " - + dataVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, packetsModule, dataVls); - return; - } - } - - final double bytesDividerAddition = packetSize - / packetsModule.getDataBytesDivider(); - - exploitPlayer.addVls(plugin, event, player, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); - } - - if (customPayloadModule.isEnabled() - && packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = customPayloadModule.getTagVls(), - bookVls = customPayloadModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " - + tagVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); - return; - } else { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") - || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory - .getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null - && !itemInHand.getType().toString().contains("BOOK")) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " tried to send a " + tag - + " custompayload packet without a book in hand!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - bookVls); - return; - } /* - * else if (byteLength > customPayloadModule.getBookBytes()) { - * logger.info(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); - * event.setCancelled(true); exploitPlayer.addVls(plugin, event, - * player, customPayloadModule, customPayloadModule.getBookVls()); - * return; } // WORK IN PROGRESS - */ - } - - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getMultiplier(tag)); - } - } else { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent a empty CustomPayload packet!"); - } - - event.setCancelled(true); - } - } - } - } + if (byteBuf.capacity() > dataBytes) { + if (notificationsModule.isDebug()) { + logger.info("[Decoder] " + playerName + " sent a packet that exceeds size limit! Max: " + + dataBytes + " Vls: " + dataVls); } - } catch (final Exception exception) { - if (!(exception instanceof NullPointerException)) { - if (notificationsModule.isDebug()) { - logger.info("[Decoder - " + exception.toString() + "] " + playerName - + " sent a packet that exceeds size limit! Max: " + dataBytes); - } - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, dataVls); - return; - } else { - exception.printStackTrace(); - } + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, dataVls); + + return; } } else if (packetsModule.isOffline()) { if (notificationsModule.isDebug()) { @@ -262,116 +68,8 @@ && checkSign(strings.values().toArray(new String[0]))) { } event.setCancelled(true); - event.abort(); - } - } - } - - private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, final Player player) { - final Logger logger = plugin.getLogger(); - int itemBytesLength = 0; - - if (itemStack != null) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - - try { - itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final Exception exception) { - if (notificationsModule.isDebug()) { - logger.info("There was an exception when processing itemStack data to String!"); - } - } - - if (itemStack.hasItemMeta() && itemMeta != null) { - try { - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += getItemLength(itemStack1, exploitPlayer, player); - } - } - } - } else { - throw new Exception(); - } - } catch (final Exception exception) { - if (itemMeta instanceof BookMeta) { - itemBytesLength += getBookLength(exploitPlayer, player, itemMeta); - } else { - try { - itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - itemBytesLength += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; - } - } - } + event.close(); } } - - return itemBytesLength; - } - - private int getBookLength(final ExploitPlayer exploitPlayer, final Player player, final ItemMeta itemMeta) { - final Logger logger = plugin.getLogger(); - final BookMeta bookMeta = (BookMeta) itemMeta; - final double dataVls = packetsModule.getDataVls(); - final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); - int bookTotalBytes = 0; - - if (pageCount > 50) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" - + 50 + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); - } else { - for (final String page : bookMeta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; - - bookTotalBytes += pageBytes; - - if (pageBytes > dataBytesBook) { - if (notificationsModule.isDebug()) { - logger.info( - player.getName() + " has sent a packet with a book with too many characters per page! (" - + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, player, packetsModule, dataVls); - break; - } - } - - return bookTotalBytes; - } - - return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } - - private boolean checkSign(final String[] linesString) { - final int dataBytesSign = packetsModule.getDataBytesSign(); - - if (linesString != null) { - if (linesString.length > 4) { - return true; - } else { - for (final String line : linesString) { - if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { - return true; - } - } - } - } - - return false; } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java index 46b0498..4d3c1c5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java @@ -35,7 +35,7 @@ public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleMana @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (!exploitPlayer.isLogged()) { event.setCancelled(true); @@ -59,8 +59,8 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); - hamsterPlayer.kickPlayer(kickMessage); - hamsterPlayer.abort(); + hamsterPlayer.disconnect(kickMessage); + hamsterPlayer.closeChannel(); exploitPlayerManager.addPunishment(); } else if (command.equals("notification")) { final String moduleName = commandsModule.getName(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java index 11f6109..dcc3a6d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java @@ -52,11 +52,10 @@ public void onPlayerLogin(final PlayerLoginEvent event) { event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - new HamsterPlayer(player).kickPlayer(nullAddressKickMessage); } else { final UUID uuid = player.getUniqueId(); final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, player); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (connectionModule.isUUIDSpoofEnabled()) { final BukkitScheduler scheduler = plugin.getServer().getScheduler(); @@ -70,11 +69,13 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); event.setKickMessage(uuidSpoofKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - new HamsterPlayer(player).kickPlayer(uuidSpoofKickMessage); + hamsterPlayer.disconnect(uuidSpoofKickMessage); + hamsterPlayer.closeChannel(); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java index afe7832..320eec8 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java @@ -21,14 +21,10 @@ public PlayerQuitListener(final ModuleManager variables) { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); - - if (exploitPlayer != null) { - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); - exploitPlayer.setLogged(false); - } + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + exploitPlayer.clear(); + exploitPlayer.setLogged(false); notificationsModule.setNotifications(player, false); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java index 8ec2b36..a94d975 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java @@ -25,7 +25,7 @@ public void onPlayerTeleport(final PlayerTeleportEvent event) { if (from.getWorld() != to.getWorld()) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (exploitPlayer != null) { exploitPlayer.updateTeleportTimeMillis(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java index cbde13b..f766dc4 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java @@ -15,6 +15,7 @@ public class HamsterAPIListenerInitializer { private final ModuleManager moduleManager; private ExploitFixerPreProcessListener exploitFixerPreProcessListener; private ExploitFixerPostProcessListener exploitFixerPostProcessListener; + private boolean registered = false; public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { this.hamsterAPI = HamsterAPI.getInstance(); @@ -22,7 +23,9 @@ public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager mo this.moduleManager = moduleManager; } - public void start() { + public void register() { + this.registered = true; + final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); @@ -32,11 +35,17 @@ public void start() { this.exploitFixerPostProcessListener = new ExploitFixerPostProcessListener(plugin, moduleManager), 0); } - public void stop() { + public void unregister() { + this.registered = false; + final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); preProcessEventHandler.removeListener(exploitFixerPreProcessListener); postProcessEventHandler.removeListener(exploitFixerPostProcessListener); } + + public boolean isRegistered() { + return this.registered; + } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java index c31fa52..de0168a 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java @@ -14,13 +14,16 @@ public class ListenerInitializer { private final Plugin plugin; private final ModuleManager moduleManager; + private boolean registered = false; public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.moduleManager = moduleManager; } - public void start() { + public void register() { + this.registered = true; + final Server server = this.plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); @@ -30,7 +33,13 @@ public void start() { pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); } - public void stop() { + public void unregister() { + this.registered = false; + HandlerList.unregisterAll(plugin); } + + public boolean isRegistered() { + return this.registered; + } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 168337c..df09541 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -26,10 +26,13 @@ public class ExploitPlayerManager { reload(); } - public ExploitPlayer get(final UUID uuid, final Player player) { - ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + public ExploitPlayer get(final Player player) { + final UUID uuid = player.getUniqueId(); + final ExploitPlayer exploitPlayer; - if (exploitPlayer == null) { + if (exploitPlayers.containsKey(uuid)) { + exploitPlayer = exploitPlayers.get(uuid); + } else { exploitPlayer = new ExploitPlayer(this.plugin, player.getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -53,7 +56,7 @@ public void reload() { exploitPlayers.clear(); for (final Player player : server.getOnlinePlayers()) { - final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + final ExploitPlayer exploitPlayer = get(player); exploitPlayer.setLogged(true); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 2cf88e1..99291f0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -5,7 +5,7 @@ public class VersionUtil { private static boolean oneDotFifteen, oneDotSeven; - public static void init() { + public static void initialize() { oneDotFifteen = Bukkit.getServer().getVersion().contains("1.15"); oneDotSeven = Bukkit.getServer().getVersion().contains("1.7"); } diff --git a/src/plugin.yml b/src/plugin.yml index a91a811..8e07c70 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,10 +1,10 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.4 +version: 1.3.5 author: 2LS api: "1.13" api-version: "1.13" -soft-depend: [HamsterAPI] +softdepend: ['HamsterAPI'] commands: exploitfixer: description: The main ExploitFixer command From 3f46c0726f0c536f640567e8bb5868020a520545 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 21 Jun 2020 20:07:14 -0300 Subject: [PATCH 064/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 51 +++++---- .../exploitfixer/bukkit/ExploitFixer.java | 10 +- .../bukkit/commands/ExploitFixerCommand.java | 16 +-- .../bukkit/instanceables/ExploitPlayer.java | 38 +++---- .../ListenerInitializer.java | 7 +- .../PlayerCommandListener.java | 21 ++-- .../PlayerLoginListener.java | 20 ++-- .../PlayerQuitListener.java | 4 +- .../ExploitFixerPostProcessListener.java | 6 +- .../ExploitFixerPreProcessListener.java | 6 +- .../HamsterAPIListenerInitializer.java | 4 +- .../listeners/PlayerTeleportListener.java | 35 ------ .../bukkit/managers/ExploitPlayerManager.java | 3 +- .../bukkit/modules/ItemsFixModule.java | 12 +- .../bukkit/modules/MessagesModule.java | 34 +++--- .../bukkit/utils/VersionUtil.java | 27 ++++- .../exploitfixer/bungee/ExploitFixer.java | 78 ++++++++----- .../bungee/commands/ExploitFixerCommand.java | 9 +- .../bungee/listeners/ChatListener.java | 6 +- .../bungee/listeners/DisconnectListener.java | 2 +- .../bungee/listeners/ListenerInitializer.java | 42 +++++++ .../listeners/PluginMessageListener.java | 2 +- .../bungee/listeners/PostLoginListener.java | 2 +- .../bungee/modules/MessagesModule.java | 40 ++++--- src/messages.yml | 106 ++++++++---------- src/plugin.yml | 2 +- 27 files changed, 304 insertions(+), 281 deletions(-) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners/initializers => listener}/ListenerInitializer.java (71%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners => listener}/PlayerCommandListener.java (83%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners => listener}/PlayerLoginListener.java (85%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners => listener}/PlayerQuitListener.java (90%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners => listener/hamsterapi}/ExploitFixerPostProcessListener.java (98%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners => listener/hamsterapi}/ExploitFixerPreProcessListener.java (93%) rename src/dev/_2lstudios/exploitfixer/bukkit/{listeners/initializers => listener/hamsterapi}/HamsterAPIListenerInitializer.java (89%) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java diff --git a/src/bungee.yml b/src/bungee.yml index fa54434..48e689e 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.5 +version: 1.3.6 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 89f47b1..43c9307 100644 --- a/src/config.yml +++ b/src/config.yml @@ -5,7 +5,7 @@ # WARNING: Only Notifications, Connection, CustomPayload and Commands modules work on BungeeCord. # # This is because the other modules can't be executed on BungeeCord. -# The other modules require ExploitFixer to be installed on Spigot with dev._2lstudios.hamsterapi. (No performance impact) +# The other modules require ExploitFixer to be installed on Spigot with HamsterAPI. (No performance impact) # # INSTALL THE PLUGIN ON BUNGEECORD AND ALL SPIGOT SERVERS! # @@ -17,18 +17,18 @@ notifications: enabled: true + # Placeholders: %player% %ping% %check% %vls% + message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" + # This shows extra information about packets blocked. # Useful to identify false positives and reporting errors. debug: false - # Placeholders: %player% %ping% %check% %vls% - message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" - # Prevents a variety of exploits that occur on player connection. -# Players wont be able to type messages/commands until the connection is secured. (You wont notice this) +# Players wont be able to type messages/commands until the connection is secured. (You won't notice this) connection: # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. - # UUIDSpoof only affects non-firewalled servers with BungeeCord: true. + # UUIDSpoof only affects non-firewalled servers with bungeecord: true. uuidspoof: true # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. @@ -36,25 +36,7 @@ connection: nulladdress: true # Commands to run when a player is detected. - punishments: - - "" - -# Removes custom NBT tags from creative items to prevent harm to your server. -itemsfix: - enabled: true - - # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) - max_stack_size: 64 - - # Maximum enchant level obtainable with creative packets. (-1 to disable) - enchant_limit: 10 - - # List of materials that are unobtainable from Creative. - blacklist: - - "END_PORTAL" - - "NETHER_PORTAL" - # - "BARRIER" - # - "COMMAND_BLOCK" + punishments: [] # Prevents the use of CustomPayload packets to exploit the server. custompayload: @@ -97,7 +79,7 @@ custompayload: # When a valid packet is sent the following amount of vls will be applied. multipliers: - OTHER: 0.01 + OTHER: 0.001 SETTINGS: 0.05 MC|BSign: 10 MC|BEdit: 10 @@ -193,6 +175,23 @@ packets: - "notification" - "kick" +# Removes custom NBT tags from creative items to prevent harm to your server. +itemsfix: + enabled: true + + # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) + max_stack_size: 64 + + # Maximum enchant level obtainable with creative packets. (-1 to disable) + enchant_limit: 10 + + # List of materials that are unobtainable from Creative. + blacklist: + - "END_PORTAL" + - "NETHER_PORTAL" + # - "BARRIER" + # - "COMMAND_BLOCK" + # Checks if players try to crash/exploit the server with commands. commands: enabled: true diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index a7722e6..4034110 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -9,8 +9,8 @@ import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bukkit.listeners.initializers.HamsterAPIListenerInitializer; -import dev._2lstudios.exploitfixer.bukkit.listeners.initializers.ListenerInitializer; +import dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi.HamsterAPIListenerInitializer; +import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.utils.ConfigurationUtil; @@ -35,7 +35,7 @@ public void onEnable() { final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); - VersionUtil.initialize(); + VersionUtil.initialize(server); exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); @@ -52,7 +52,7 @@ public void onEnable() { registerHamsterApi(); } else { scheduler.runTaskTimer(this, () -> this.getLogger().severe( - "ExploitFixer requires HamsterAPI 0.0.6 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), + "ExploitFixer requires HamsterAPI 0.0.8 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), 20L, 20L); } @@ -104,7 +104,7 @@ private boolean checkHamsterAPI() { if (pluginManager.isPluginEnabled("HamsterAPI")) { return (Integer - .valueOf(pluginManager.getPlugin("HamsterAPI").getDescription().getVersion().replace(".", "")) > 5); + .valueOf(pluginManager.getPlugin("HamsterAPI").getDescription().getVersion().replace(".", "")) > 7); } else { return false; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 2484797..d373279 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -29,20 +29,12 @@ public ExploitFixerCommand(final ModuleManager moduleManager, final boolean hams public boolean onCommand(final CommandSender commandSender, final Command command, final String label, final String[] args) { final int length = args.length; - String lang = "en"; + final String lang; if (commandSender instanceof Player) { - if (VersionUtil.isOneDotFifteen()) { - final String locale = ((Player) commandSender).getLocale(); - - if (locale != null) - lang = locale.substring(0, 2); - } else { - final String locale = ((Player) commandSender).spigot().getLocale(); - - if (locale != null) - lang = locale.substring(0, 2); - } + lang = VersionUtil.getLocale((Player) commandSender); + } else { + lang = "en"; } if (length < 1 || args[0].equals("help")) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 0ab79ce..55871ae 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -20,28 +20,33 @@ import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; -import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class ExploitPlayer { private final ExploitPlayerManager exploitPlayerManager; private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; - private final Map violations = new HashMap<>(); - private final Collection> punishments = new HashSet<>(); + private final Map violations; + private final Collection> punishments; private final String name; - private String onlineUUID = null; - private double lastViolation = 0; - private long teleportTimeMillis = System.currentTimeMillis(); - private int channels = 0; - private boolean logged = false; + private String onlineUUID; + private double lastViolation; + private int channels; + private boolean logged; public ExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); + this.violations = new HashMap<>(); + this.punishments = new HashSet<>(); this.name = name; + this.onlineUUID = null; + this.lastViolation = 0; + this.channels = 0; + this.logged = false; } public int getChannels() { @@ -126,14 +131,7 @@ public void addVls(final Plugin plugin, final Cancellable event, final PacketWra if (commands != null && !commands.isEmpty() && !punishments.contains(commands)) { for (final String punishCommand : commands) { if (punishCommand.equals("kick")) { - final String locale; - - if (VersionUtil.isOneDotFifteen()) { - locale = player.getLocale().substring(0, 2); - } else { - locale = player.spigot().getLocale().substring(0, 2); - } - + final String locale = VersionUtil.getLocale(player); final String kickMessage = messagesModule.getKickMessage(module, locale); hamsterPlayer.disconnect(kickMessage); @@ -186,14 +184,6 @@ public boolean isLogged() { return logged; } - public void updateTeleportTimeMillis() { - this.teleportTimeMillis = System.currentTimeMillis(); - } - - public long getTeleportTimeMillis() { - return this.teleportTimeMillis; - } - public Collection> getPunishments() { return this.punishments; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java similarity index 71% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index de0168a..fc81f4b 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -1,14 +1,10 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners.initializers; +package dev._2lstudios.exploitfixer.bukkit.listener; import org.bukkit.Server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerCommandListener; -import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerLoginListener; -import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerQuitListener; -import dev._2lstudios.exploitfixer.bukkit.listeners.PlayerTeleportListener; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; public class ListenerInitializer { @@ -30,7 +26,6 @@ public void register() { pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); - pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); } public void unregister() { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java similarity index 83% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index 4d3c1c5..b2e623e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listener; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -8,7 +8,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.Plugin; -import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; @@ -16,6 +15,8 @@ import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; public class PlayerCommandListener implements Listener { private final Plugin plugin; @@ -24,7 +25,7 @@ public class PlayerCommandListener implements Listener { private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; - public PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { + PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -45,19 +46,13 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final String playerName = player.getName(); for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ") || message.endsWith(command)) { + if (message.startsWith(command + " ")) { for (final String punishment : commandsModule.getPunishments()) { if (command.equals("kick")) { - final String locale; - - if (VersionUtil.isOneDotFifteen()) { - locale = player.getLocale().substring(0, 2); - } else { - locale = player.spigot().getLocale().substring(0, 2); - } - + final String locale = VersionUtil.getLocale(player); final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); - final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() + .get(player); hamsterPlayer.disconnect(kickMessage); hamsterPlayer.closeChannel(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java similarity index 85% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index dcc3a6d..8812a6c 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listener; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -8,7 +8,8 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; -import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; @@ -27,7 +28,7 @@ public class PlayerLoginListener implements Listener { private final ConnectionModule connectionModule; private final ExploitPlayerManager exploitPlayerManager; - public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { + PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); @@ -39,13 +40,7 @@ public PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManage public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); final InetAddress address = event.getAddress(); - final String locale; - - if (VersionUtil.isOneDotFifteen()) { - locale = player.getLocale().substring(0, 2); - } else { - locale = player.spigot().getLocale().substring(0, 2); - } + final String locale = VersionUtil.getLocale(player); if (connectionModule.isNullAddressEnabled() && address == null) { final String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); @@ -69,7 +64,8 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final String onlineUUID = exploitPlayer.getOnlineUUID(); if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { - final HamsterPlayer hamsterPlayer = new HamsterPlayer(player); + final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() + .get(player); final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); event.setKickMessage(uuidSpoofKickMessage); @@ -80,11 +76,9 @@ public void onPlayerLogin(final PlayerLoginEvent event) { } exploitPlayer.setLogged(true); - exploitPlayer.updateTeleportTimeMillis(); }); } else { exploitPlayer.setLogged(true); - exploitPlayer.updateTeleportTimeMillis(); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java similarity index 90% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java index 320eec8..efe77c1 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listener; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,7 +13,7 @@ public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; - public PlayerQuitListener(final ModuleManager variables) { + PlayerQuitListener(final ModuleManager variables) { this.exploitPlayerManager = variables.getExploitPlayerManager(); this.notificationsModule = variables.getNotificationsModule(); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java similarity index 98% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java index e22ea7e..4d73eba 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPostProcessListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; import java.nio.charset.StandardCharsets; import java.util.Collection; @@ -27,8 +27,8 @@ import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; -import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.interfaces.PostProcessListener; import dev._2lstudios.hamsterapi.wrappers.EventWrapper; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; @@ -41,7 +41,7 @@ public class ExploitFixerPostProcessListener implements PostProcessListener { private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; - public ExploitFixerPostProcessListener(final Plugin plugin, final ModuleManager moduleManager) { + ExploitFixerPostProcessListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java similarity index 93% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java index 06b3b11..08530f1 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/ExploitFixerPreProcessListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; +package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; import java.util.logging.Logger; @@ -12,7 +12,7 @@ import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.adapters.HamsterPlayer; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.interfaces.PreProcessListener; import dev._2lstudios.hamsterapi.wrappers.EventWrapper; import io.netty.buffer.ByteBuf; @@ -24,7 +24,7 @@ public class ExploitFixerPreProcessListener implements PreProcessListener { private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; - public ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { + ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { HamsterAPI.getInstance().getBufferIO(); this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java similarity index 89% rename from src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java rename to src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java index f766dc4..1db0277 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/initializers/HamsterAPIListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java @@ -1,9 +1,7 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners.initializers; +package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.listeners.ExploitFixerPostProcessListener; -import dev._2lstudios.exploitfixer.bukkit.listeners.ExploitFixerPreProcessListener; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.handlers.PostProcessEventHandler; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java deleted file mode 100644 index a94d975..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listeners/PlayerTeleportListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listeners; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerTeleportEvent; - -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; - -public class PlayerTeleportListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; - - public PlayerTeleportListener(final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onPlayerTeleport(final PlayerTeleportEvent event) { - final Location from = event.getFrom(); - final Location to = event.getTo(); - - if (from.getWorld() != to.getWorld()) { - final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - if (exploitPlayer != null) { - exploitPlayer.updateTeleportTimeMillis(); - } - } - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index df09541..3adfd36 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -16,12 +16,13 @@ public class ExploitPlayerManager { private final Server server; private final ModuleManager moduleManager; private final Map exploitPlayers = new HashMap<>(); - private int punishments = 0; + private int punishments; ExploitPlayerManager(final Plugin plugin, final Server server, final ModuleManager moduleManager) { this.plugin = plugin; this.server = server; this.moduleManager = moduleManager; + this.punishments = 0; reload(); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 7808578..77c3ae6 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; @@ -80,17 +81,24 @@ public ItemStack fixItem(final ItemStack itemStack) { } } - if (itemMeta instanceof BookMeta && newItemMeta instanceof BookMeta) { + if (newItemMeta instanceof BookMeta) { final BookMeta bookMeta = (BookMeta) itemMeta; final BookMeta newBookMeta = (BookMeta) newItemMeta; newBookMeta.setTitle(bookMeta.getTitle()); newBookMeta.setAuthor(bookMeta.getAuthor()); newBookMeta.setPages(bookMeta.getPages()); + } else if (newItemMeta instanceof SkullMeta) { + final SkullMeta skullMeta = (SkullMeta) itemMeta; + final SkullMeta newSkullMeta = (SkullMeta) newItemMeta; + + newSkullMeta.setOwningPlayer(skullMeta.getOwningPlayer()); + newSkullMeta.setPlayerProfile(skullMeta.getPlayerProfile()); } - if (displayName != null && displayName.getBytes().length < 128) + if (displayName != null && displayName.getBytes().length < 128) { newItemMeta.setDisplayName(displayName); + } if (lore != null && lore.toString().getBytes().length < 1024) { newItemMeta.setLore(lore); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java index f48920a..88ccc74 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java @@ -1,43 +1,43 @@ package dev._2lstudios.exploitfixer.bukkit.modules; +import org.bukkit.ChatColor; import org.bukkit.configuration.Configuration; import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class MessagesModule implements Module { - private final String version; private Configuration messagesYml; + private final String version; public MessagesModule(final String version, final Configuration messagesYml) { - this.version = version; reload(messagesYml); + this.version = version; } - @Override public boolean isEnabled() { return true; } - @Override public String getName() { return "Messages"; } - public String getString(String locale, final String path) { - String string; - - if (locale == null) - locale = "en"; + public void reload(final Configuration messagesYml) { + this.messagesYml = messagesYml; + } - string = messagesYml.getString(locale + path); + private String getString(final String locale, final String path) { + String string = messagesYml.getString(locale + path); - if (string == null || string.isEmpty()) + if (string == null || string.isEmpty()) { string = messagesYml.getString("en" + path); + } - if (string != null) - string = string.replace("&", "\u00A7"); - else + if (string != null && !string.isEmpty()) { + string = ChatColor.translateAlternateColorCodes('&', string); + } else { string = ""; + } return string; } @@ -78,11 +78,7 @@ public final String getKickMessage(final String module, final String locale) { return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); } - public void reload(Object messagesYml) { - this.messagesYml = (Configuration) messagesYml; - } - - public String getStats(String locale) { + public String getStats(final String locale) { return getString(locale, ".modules.stats.message"); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 99291f0..6436ea9 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,13 +1,32 @@ package dev._2lstudios.exploitfixer.bukkit.utils; -import org.bukkit.Bukkit; +import org.bukkit.Server; +import org.bukkit.entity.Player; public class VersionUtil { private static boolean oneDotFifteen, oneDotSeven; - public static void initialize() { - oneDotFifteen = Bukkit.getServer().getVersion().contains("1.15"); - oneDotSeven = Bukkit.getServer().getVersion().contains("1.7"); + public static void initialize(final Server server) { + final String version = server.getVersion(); + + oneDotFifteen = version.contains("1.15"); + oneDotSeven = version.contains("1.7"); + } + + public static String getLocale(final Player player) { + final String locale; + + if (VersionUtil.isOneDotFifteen()) { + locale = player.getLocale(); + } else { + locale = player.spigot().getLocale(); + } + + if (locale != null && locale.length() > 1) { + return locale.substring(0, 2); + } else { + return "en"; + } } public static boolean isOneDotFifteen() { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index 0843a19..31aad42 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -1,42 +1,42 @@ package dev._2lstudios.exploitfixer.bungee; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.bungee.listeners.ListenerInitializer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.utils.ConfigurationUtil; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bungee.listeners.ChatListener; -import dev._2lstudios.exploitfixer.bungee.listeners.DisconnectListener; -import dev._2lstudios.exploitfixer.bungee.listeners.PluginMessageListener; -import dev._2lstudios.exploitfixer.bungee.listeners.PostLoginListener; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.ConfigurationUtil; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; - -import java.util.concurrent.TimeUnit; public class ExploitFixer extends Plugin { - private static ExploitFixer plugin; + private static ExploitFixer exploitFixer; + private ConfigurationUtil configurationUtil; private ModuleManager moduleManager; + private ListenerInitializer listenerInitializer; + @Override public void onEnable() { final TaskScheduler scheduler = getProxy().getScheduler(); - plugin = this; + this.configurationUtil = new ConfigurationUtil(this); - final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); + createConfigurations(); final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); + exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); + this.listenerInitializer = new ListenerInitializer(this, moduleManager); - reload(); + registerListeners(); + registerCommands(); - scheduler.cancel(this); scheduler.schedule(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -44,22 +44,46 @@ public void onEnable() { }, 5, 5, TimeUnit.MINUTES); } + @Override + public void onDisable() { + final TaskScheduler scheduler = getProxy().getScheduler(); + + scheduler.cancel(this); + } + public void reload() { - final PluginManager pluginManager = getProxy().getPluginManager(); final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); + createConfigurations(); final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); + moduleManager.reload(configYml, messagesYml, null); - pluginManager.unregisterListeners(this); - pluginManager.registerListener(this, new ChatListener(this, moduleManager)); - pluginManager.registerListener(this, new DisconnectListener(moduleManager)); - pluginManager.registerListener(this, new PluginMessageListener(this, moduleManager)); - pluginManager.registerListener(this, new PostLoginListener(this, moduleManager)); + registerCommands(); + registerListeners(); + } + + private void createConfigurations() { + this.configurationUtil.createConfiguration("%datafolder%/config.yml"); + this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); + } + + private void registerListeners() { + final Logger logger = this.getLogger(); + + if (this.listenerInitializer.isRegistered()) { + this.listenerInitializer.unregister(); + } + + this.listenerInitializer.register(); + + logger.info("Successfully registered listeners!"); + } + + private void registerCommands() { + final PluginManager pluginManager = getProxy().getPluginManager(); pluginManager.unregisterCommands(this); pluginManager.registerCommand(this, @@ -67,6 +91,6 @@ public void reload() { } public static ExploitFixer getInstance() { - return plugin; + return exploitFixer; } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index d5d646d..18f7a0f 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -32,8 +32,13 @@ public void execute(final CommandSender commandSender, final String[] args) { if (commandSender instanceof ProxiedPlayer) { final Locale locale = ((ProxiedPlayer) commandSender).getLocale(); - if (locale != null) - lang = locale.toLanguageTag().substring(0, 2); + if (locale != null) { + final String localeString = locale.toString(); + + if (localeString.length() > 1) { + lang = localeString.substring(0, 2); + } + } } if (length < 1 || args[0].equals("help")) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index 8e83796..aedaf7e 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -22,7 +22,7 @@ public class ChatListener implements Listener { private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; - public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { + ChatListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -32,7 +32,7 @@ public ChatListener(final Plugin plugin, final ModuleManager moduleManager) { @EventHandler(priority = -128) public void onChat(final ChatEvent event) { - if (!event.isCancelled()) { + if (!event.isCancelled() && event.isCommand()) { final Connection connection = event.getSender(); if (connection instanceof ProxiedPlayer) { @@ -46,7 +46,7 @@ public void onChat(final ChatEvent event) { final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ") || message.endsWith(command)) { + if (message.startsWith(command + " ")) { for (final String punishment : commandsModule.getPunishments()) { if (punishment.equals("kick")) { final String locale = player.getLocale().toString().substring(0, 2); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java index d5c72cd..1d8e197 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java @@ -13,7 +13,7 @@ public class DisconnectListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; - public DisconnectListener(final ModuleManager moduleManager) { + DisconnectListener(final ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.notificationsModule = moduleManager.getNotificationsModule(); } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java new file mode 100644 index 0000000..548c909 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java @@ -0,0 +1,42 @@ +package dev._2lstudios.exploitfixer.bungee.listeners; + +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.api.plugin.PluginManager; + +public class ListenerInitializer { + private final Plugin plugin; + private final ModuleManager moduleManager; + private boolean registered = false; + + public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.moduleManager = moduleManager; + } + + public void register() { + this.registered = true; + + final ProxyServer server = this.plugin.getProxy(); + final PluginManager pluginManager = server.getPluginManager(); + + pluginManager.registerListener(plugin, new ChatListener(plugin, moduleManager)); + pluginManager.registerListener(plugin, new DisconnectListener(moduleManager)); + pluginManager.registerListener(plugin, new PluginMessageListener(plugin, moduleManager)); + pluginManager.registerListener(plugin, new PostLoginListener(plugin, moduleManager)); + } + + public void unregister() { + final ProxyServer server = this.plugin.getProxy(); + final PluginManager pluginManager = server.getPluginManager(); + + this.registered = false; + + pluginManager.unregisterListeners(plugin); + } + + public boolean isRegistered() { + return this.registered; + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java index 9cf00f5..aa0a04a 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -20,7 +20,7 @@ public class PluginMessageListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; - public PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { + PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 35e4963..e4ea00d 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -26,7 +26,7 @@ public class PostLoginListener implements Listener { private final MessagesModule messagesModule; private final ExploitPlayerManager exploitPlayerManager; - public PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { + PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java index ad9e75c..e35b674 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java @@ -1,27 +1,43 @@ package dev._2lstudios.exploitfixer.bungee.modules; +import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.config.Configuration; + import dev._2lstudios.exploitfixer.shared.interfaces.Module; -public class MessagesModule { +public class MessagesModule implements Module { private Configuration messagesYml; - private String version; + private final String version; public MessagesModule(final String version, final Configuration messagesYml) { reload(messagesYml); this.version = version; } - public String getString(final String locale, final String path) { + public boolean isEnabled() { + return true; + } + + public String getName() { + return "Messages"; + } + + public void reload(final Configuration messagesYml) { + this.messagesYml = messagesYml; + } + + private String getString(final String locale, final String path) { String string = messagesYml.getString(locale + path); - if (string == null || string.isEmpty()) + if (string == null || string.isEmpty()) { string = messagesYml.getString("en" + path); + } - if (string != null) - string = string.replace("&", "\u00A7"); - else + if (string != null && !string.isEmpty()) { + string = ChatColor.translateAlternateColorCodes('&', string); + } else { string = ""; + } return string; } @@ -62,15 +78,7 @@ public final String getKickMessage(final String module, final String locale) { return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); } - public void reload(final Configuration messagesYml) { - this.messagesYml = messagesYml; - } - - public String getStats(String locale) { + public String getStats(final String locale) { return getString(locale, ".modules.stats.message"); } - - public String getName() { - return "Messages"; - } } \ No newline at end of file diff --git a/src/messages.yml b/src/messages.yml index 55faa2b..148aa8d 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -1,7 +1,5 @@ -# You can create as many locales as you want, -# because the language will change depending on the player locale. +# The language is automatically selected depending on the client language. # If the locale of the player doesnt exist in this file, english will be used by default. -# Use replace method of your text editor to quickly replace the Discord link in the messages. # English en: @@ -20,21 +18,20 @@ en: notifications: enable: "&aYou have enabled notifications!" disable: "&cYou have disabled notifications!" + stats: |- + &fPlayers cached: &a%players_cached% + &fPlayers punished: &a%players_punished% modules: custompayload: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fPlayers cached: &a%players_cached% - &fPlayers punished: &a%players_punished% + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%discord%&r" # Spanish es: @@ -53,21 +50,20 @@ es: notifications: enable: "&aHabilitaste las notificaciones!" disable: "&cDeshabilitaste las notificaciones!" + stats: |- + &fJugadores en cache: &a%players_cached% + &fJugadores sancionados: &a%players_punished% modules: custompayload: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fJugadores en cache: &a%players_cached% - &fJugadores sancionados: &a%players_punished% + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&n%discord%&r" # Portuguese - Credits: LucaAzalim pt: @@ -86,21 +82,20 @@ pt: notifications: enable: "&cVocê ativou as notificações!" disable: "&cVocê desativou as notificações!" + stats: |- + &fJogadores em cache: &a%players_cached% + &fJogadores punidos: &a%players_punished% modules: custompayload: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fJogadores em cache: &a%players_cached% - &fJogadores punidos: &a%players_punished% + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&n%discord%&r" # Italian it: @@ -119,21 +114,20 @@ it: notifications: enable: "&aHai abilitato le notifiche!" disable: "&cHai disabilitato le notifiche!" + stats: |- + &fGiocatori in cache: &a%players_cached% + &fGiocatori puniti: &a%players_punished% modules: custompayload: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fGiocatori in cache: &a%players_cached% - &fGiocatori puniti: &a%players_punished% + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&n%discord%&r" # French - Credits: HaVroz fr: @@ -152,21 +146,20 @@ fr: notifications: enable: "&aVous avez activé les notifications!" disable: "&cVous avez désactivé les notifications!" + stats: |- + &fJoueurs caché: &a%players_cached% + &fJoueurs sanctionné: &a%players_punished% modules: custompayload: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fJoueurs caché: &a%players_cached% - &fJoueurs sanctionné: &a%players_punished% + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&n%discord%&r" tr: commands: @@ -184,18 +177,17 @@ tr: notifications: enable: "&aBildirimleri etkinleştirdiniz!" disable: "&cBildirimleri devre dışı bıraktınız!" + stats: |- + &fPlayers önbelleğe alındı: &a%players_cached% + &fPlayers cezalandırıldı: &a%players_punished% modules: custompayload: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%discord%&r" uuidspoof: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&n%discord%&r" commands: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%discord%&r" packets: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&nhttps://discord.gg/gF36AT3&r" - stats: - message: |- - &fPlayers önbelleğe alındı: &a%players_cached% - &fPlayers cezalandırıldı: &a%players_punished% \ No newline at end of file + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%discord%&r" \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 8e07c70..f54755c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.5 +version: 1.3.6 author: 2LS api: "1.13" api-version: "1.13" From 3447b03bd7bf9165b863c2d0dd44c5cfb624d585 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Jun 2020 00:26:36 -0300 Subject: [PATCH 065/336] Updated Source --- src/bungee.yml | 2 +- .../_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java | 3 +-- src/plugin.yml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 48e689e..476ab7d 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.6 +version: 1.3.7 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 77c3ae6..6d08dd5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -92,8 +92,7 @@ public ItemStack fixItem(final ItemStack itemStack) { final SkullMeta skullMeta = (SkullMeta) itemMeta; final SkullMeta newSkullMeta = (SkullMeta) newItemMeta; - newSkullMeta.setOwningPlayer(skullMeta.getOwningPlayer()); - newSkullMeta.setPlayerProfile(skullMeta.getPlayerProfile()); + newSkullMeta.setOwner(skullMeta.getOwner()); } if (displayName != null && displayName.getBytes().length < 128) { diff --git a/src/plugin.yml b/src/plugin.yml index f54755c..ab8d3fb 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.6 +version: 1.3.7 author: 2LS api: "1.13" api-version: "1.13" From 664b0040463534b107ae5a456e96ae8afb1d74c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Jun 2020 03:54:04 -0300 Subject: [PATCH 066/336] Updated Source --- src/bungee.yml | 2 +- .../exploitfixer/bukkit/modules/MessagesModule.java | 8 +++++--- .../exploitfixer/bukkit/utils/VersionUtil.java | 12 ++++++++---- .../exploitfixer/bungee/utils/ConfigurationUtil.java | 10 +++++----- src/messages.yml | 1 + src/plugin.yml | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 476ab7d..97f1ff2 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.7 +version: 1.3.8 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java index 88ccc74..5fac35d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java @@ -6,8 +6,9 @@ import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class MessagesModule implements Module { - private Configuration messagesYml; private final String version; + private Configuration messagesYml; + private String discord; public MessagesModule(final String version, final Configuration messagesYml) { reload(messagesYml); @@ -24,6 +25,7 @@ public String getName() { public void reload(final Configuration messagesYml) { this.messagesYml = messagesYml; + this.discord = messagesYml.getString("discord", ""); } private String getString(final String locale, final String path) { @@ -39,7 +41,7 @@ private String getString(final String locale, final String path) { string = ""; } - return string; + return string.replace("%version%", version).replace("%discord%", discord); } public final String getReload(final String locale) { @@ -47,7 +49,7 @@ public final String getReload(final String locale) { } public final String getHelp(final String locale) { - return getString(locale, ".commands.help").replace("%version%", version); + return getString(locale, ".commands.help"); } public final String getUnknown(final String locale) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 6436ea9..d7da426 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -14,12 +14,16 @@ public static void initialize(final Server server) { } public static String getLocale(final Player player) { - final String locale; + String locale; - if (VersionUtil.isOneDotFifteen()) { + try { locale = player.getLocale(); - } else { - locale = player.spigot().getLocale(); + } catch (final Exception exception) { + try { + locale = player.spigot().getLocale(); + } catch (final Exception exception1) { + locale = "en"; + } } if (locale != null && locale.length() > 1) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java index 2aba245..81ef443 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java @@ -43,17 +43,16 @@ public void createConfiguration(String file) { final String[] files = file.split("/"); final InputStream inputStream = plugin.getClass().getClassLoader() .getResourceAsStream(files[files.length - 1]); - final File parentFile = configFile.getParentFile(); - if (parentFile != null) - parentFile.mkdirs(); + new File(configFile.getParent()).mkdirs(); if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") .replace("%pluginname%", plugin.getDescription().getName())); - } else + } else { configFile.createNewFile(); + } } } catch (final IOException e) { plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!") @@ -79,8 +78,9 @@ public void deleteConfiguration(final String file) { plugin.getProxy().getScheduler().runAsync(plugin, () -> { final File file1 = new File(file); - if (file1.exists()) + if (file1.exists()) { file1.delete(); + } }); } } \ No newline at end of file diff --git a/src/messages.yml b/src/messages.yml index 148aa8d..1320380 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -1,5 +1,6 @@ # The language is automatically selected depending on the client language. # If the locale of the player doesnt exist in this file, english will be used by default. +discord: "discord.gg/gF36AT3" # English en: diff --git a/src/plugin.yml b/src/plugin.yml index ab8d3fb..67e16d9 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.7 +version: 1.3.8 author: 2LS api: "1.13" api-version: "1.13" From 9f7fe4f830946f2d45aa2ed530cee490f7ac4425 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Jun 2020 04:21:14 -0300 Subject: [PATCH 067/336] Updated source --- src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index d7da426..44e12c8 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -17,9 +17,11 @@ public static String getLocale(final Player player) { String locale; try { + player.getClass().getMethod("getLocale"); locale = player.getLocale(); - } catch (final Exception exception) { + } catch (final NoSuchMethodException exception) { try { + player.spigot().getClass().getMethod("getLocale"); locale = player.spigot().getLocale(); } catch (final Exception exception1) { locale = "en"; From a20da3e04917e8bbddc7924bdddeb624734da81c Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Sun, 5 Jul 2020 20:16:57 -0300 Subject: [PATCH 068/336] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c77929..c6106f9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # ExploitFixer -Advanced plugin to maintain your server safe from multiple exploits. +Bukkit/BungeeCord plugin that aims on fixing Exploits in your Minecraft network. [Requires HamsterAPI to work] From 7bdc83b324e4dfb72dee92bf14fd98bcd0f1214a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Jul 2020 20:19:24 -0300 Subject: [PATCH 069/336] Updated source --- src/bungee.yml | 2 +- .../bukkit/instanceables/ExploitPlayer.java | 90 ++++++++------- .../bukkit/listener/ListenerInitializer.java | 2 +- .../listener/PlayerCommandListener.java | 45 +------- .../bukkit/modules/ItemsFixModule.java | 25 ++-- .../bukkit/utils/VersionUtil.java | 23 ++++ .../bungee/instanceables/ExploitPlayer.java | 109 ++++++++++-------- .../bungee/managers/ExploitPlayerManager.java | 22 ++-- src/plugin.yml | 4 +- 9 files changed, 171 insertions(+), 151 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 97f1ff2..82b1bd4 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.8 +version: 1.3.9 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 55871ae..5838416 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -10,21 +10,25 @@ import java.util.Map; import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.interfaces.Module; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class ExploitPlayer { + private final Plugin plugin; private final ExploitPlayerManager exploitPlayerManager; private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; @@ -37,6 +41,7 @@ public class ExploitPlayer { private boolean logged; public ExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { + this.plugin = plugin; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); @@ -95,11 +100,9 @@ public void addVls(final Plugin plugin, final Cancellable event, final HamsterPl public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, final HamsterPlayer hamsterPlayer, final ViolationModule module, final double amount) { - final Player player = hamsterPlayer.getPlayer(); final Violations violations = (Violations) module.getViolations(); if (violations != null) { - final Server server = plugin.getServer(); final double currentTime = System.currentTimeMillis(); if (currentTime - lastViolation >= 1000) { @@ -128,44 +131,55 @@ public void addVls(final Plugin plugin, final Cancellable event, final PacketWra if (threshold <= newVls) { final Collection commands = violations.getCommands(threshold); - if (commands != null && !commands.isEmpty() && !punishments.contains(commands)) { - for (final String punishCommand : commands) { - if (punishCommand.equals("kick")) { - final String locale = VersionUtil.getLocale(player); - final String kickMessage = messagesModule.getKickMessage(module, locale); - - hamsterPlayer.disconnect(kickMessage); - hamsterPlayer.closeChannel(); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) { - final String moduleName = module.getName(); - - if (packet != null) { - final PacketType packetType = packet.getType(); - final String name; - - if (packetType != null) { - name = packetType.toString(); - } else { - name = moduleName; - } - - notificationsModule.sendNotification(name, player, (int) newVls); - } else { - notificationsModule.sendNotification(moduleName, player, (int) newVls); - } - } else { - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishCommand.replace("%player%", player.getName())); - }); - } - } + punish(module, hamsterPlayer, packet, commands, (int) newVls); + } + } + } + } - punishments.add(commands); + public void punish(final Module module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, + final Collection punishments, final int newVls) { + if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { + final Server server = plugin.getServer(); + final CommandSender consoleSender = server.getConsoleSender(); + final BukkitScheduler scheduler = server.getScheduler(); + final Player player = hamsterPlayer.getPlayer(); + final String playerName = player.getName(); + + for (final String punishment : punishments) { + if (punishment.equals("kick")) { + final String locale = VersionUtil.getLocale(player); + final String kickMessage = messagesModule.getKickMessage(module, locale); + + hamsterPlayer.disconnect(kickMessage); + hamsterPlayer.closeChannel(); + } else if (punishment.equals("notification")) { + final String moduleName = module.getName(); + + if (packet != null) { + final PacketType packetType = packet.getType(); + + if (packetType != null) { + notificationsModule.sendNotification(packetType.toString(), player, (int) newVls); + } else { + notificationsModule.sendNotification(moduleName, player, (int) newVls); + } + } else { + notificationsModule.sendNotification(moduleName, player, (int) newVls); + } + } else { + if (server.isPrimaryThread()) { + server.dispatchCommand(consoleSender, punishment.replace("%player%", playerName)); + } else { + scheduler.runTask(plugin, () -> { + server.dispatchCommand(consoleSender, punishment.replace("%player%", playerName)); + }); } } } + + this.punishments.add(punishments); + this.exploitPlayerManager.addPunishment(); } } @@ -183,8 +197,4 @@ public void setLogged(final boolean logged) { public boolean isLogged() { return logged; } - - public Collection> getPunishments() { - return this.punishments; - } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index fc81f4b..cf833ce 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -23,7 +23,7 @@ public void register() { final Server server = this.plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); - pluginManager.registerEvents(new PlayerCommandListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index b2e623e..4d1c236 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -1,36 +1,28 @@ package dev._2lstudios.exploitfixer.bukkit.listener; -import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; public class PlayerCommandListener implements Listener { - private final Plugin plugin; + private final HamsterPlayerManager hamsterPlayerManager; private final CommandsModule commandsModule; private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - PlayerCommandListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; + PlayerCommandListener(final ModuleManager moduleManager) { + this.hamsterPlayerManager = HamsterAPI.getInstance().getHamsterPlayerManager(); this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @@ -41,38 +33,13 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { - final Server server = plugin.getServer(); final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); - final String playerName = player.getName(); for (final String command : commandsModule.getCommands()) { if (message.startsWith(command + " ")) { - for (final String punishment : commandsModule.getPunishments()) { - if (command.equals("kick")) { - final String locale = VersionUtil.getLocale(player); - final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); - final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() - .get(player); + final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); - hamsterPlayer.disconnect(kickMessage); - hamsterPlayer.closeChannel(); - exploitPlayerManager.addPunishment(); - } else if (command.equals("notification")) { - final String moduleName = commandsModule.getName(); - - notificationsModule.sendNotification(moduleName, player, 1); - } else { - if (server.isPrimaryThread()) { - server.dispatchCommand(server.getConsoleSender(), - punishment.replace("%player%", playerName)); - } else { - server.getScheduler().runTask(plugin, () -> { - server.dispatchCommand(server.getConsoleSender(), - punishment.replace("%player%", playerName)); - }); - } - } - } + exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); event.setCancelled(true); break; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 6d08dd5..0a217f9 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -3,18 +3,16 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Map; import org.bukkit.Material; import org.bukkit.configuration.Configuration; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.shared.interfaces.Module; public class ItemsFixModule implements Module { @@ -67,17 +65,24 @@ public ItemStack fixItem(final ItemStack itemStack) { final short durability = itemStack.getDurability(); if (itemStack.hasItemMeta()) { - final Map enchantments = itemStack.getEnchantments(); final String displayName = itemMeta.getDisplayName(); final List lore = itemMeta.getLore(); if (enchantLimit > -1) { - for (final Enchantment enchantment : enchantments.keySet()) { - final int level = enchantments.get(enchantment); - - if (level <= enchantLimit && level > -1) { - newItemMeta.addEnchant(enchantment, level, true); - } + if (itemMeta instanceof EnchantmentStorageMeta) { + final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) itemMeta; + + enchantmentStorageMeta.getStoredEnchants().forEach((enchantment, level) -> { + if (level <= enchantLimit && level > -1) { + enchantmentStorageMeta.addStoredEnchant(enchantment, level, true); + } + }); + } else { + itemStack.getEnchantments().forEach((enchantment, level) -> { + if (level <= enchantLimit && level > -1) { + newItemMeta.addEnchant(enchantment, level, true); + } + }); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 44e12c8..c1f4237 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,8 +1,12 @@ package dev._2lstudios.exploitfixer.bukkit.utils; +import java.util.Locale; + import org.bukkit.Server; import org.bukkit.entity.Player; +import net.md_5.bungee.api.connection.ProxiedPlayer; + public class VersionUtil { private static boolean oneDotFifteen, oneDotSeven; @@ -42,4 +46,23 @@ public static boolean isOneDotFifteen() { public static boolean isOneDotSeven() { return oneDotSeven; } + + public static String getLocale(ProxiedPlayer player) { + final Locale locale = player.getLocale(); + final String lang; + + if (locale != null) { + final String localeString = locale.toString(); + + if (localeString.length() > 1) { + lang = localeString.substring(0, 2); + } else { + lang = "en"; + } + } else { + lang = "en"; + } + + return lang; + } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java index 553406d..d33194e 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java @@ -1,39 +1,48 @@ package dev._2lstudios.exploitfixer.bungee.instanceables; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Cancellable; -import net.md_5.bungee.api.plugin.Plugin; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.shared.interfaces.Module; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.*; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; +import net.md_5.bungee.api.plugin.Plugin; public class ExploitPlayer { - final private ExploitPlayerManager exploitPlayerManager; - final private MessagesModule messagesModule; - final private NotificationsModule notificationsModule; - final private Map violations = new HashMap<>(); - final private String name; + private final ProxyServer server; + private final ExploitPlayerManager exploitPlayerManager; + private final MessagesModule messagesModule; + private final NotificationsModule notificationsModule; + private final Map violations; + private final Collection> punishments; + private final String name; private String onlineUUID = null; private boolean logged = false; private int channels = 0; private double lastViolation = 0; - public ExploitPlayer(final String name, final ModuleManager moduleManager) { + public ExploitPlayer(final ProxyServer server, final String name, final ModuleManager moduleManager) { + this.server = server; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); + this.violations = new HashMap<>(); + this.punishments = new HashSet<>(); this.name = name; } @@ -86,10 +95,7 @@ public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer final Violations violations = (Violations) module.getViolations(); if (violations != null) { - final ProxyServer server = plugin.getProxy(); final double currentTime = System.currentTimeMillis(); - final Locale locale = player.getLocale(); - String lang = null; if (currentTime - lastViolation >= 1000) { lastViolation = currentTime; @@ -97,45 +103,27 @@ public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - if (vls <= 0) + if (vls <= 0) { this.violations.remove(violationModule); - else + } else { this.violations.put(violationModule, vls); + } } } - final double oldVls = getViolations(module); - final double newVls = oldVls + amount; - - if (locale != null) - lang = locale.toString().substring(0, 2); - - final String kickMessage = messagesModule.getKickMessage(module, lang); + final double newVls = getViolations(module) + amount; this.violations.put(module, newVls); - if (event instanceof Cancellable && module.getCancelVls() <= newVls) + if (event instanceof Cancellable && module.getCancelVls() <= newVls) { ((Cancellable) event).setCancelled(true); + } for (final int threshold : violations.getViolations()) { - if (threshold > oldVls && threshold <= newVls) { + if (threshold <= newVls) { final Collection commands = violations.getCommands(threshold); - if (commands != null && !commands.isEmpty()) { - for (final String punishCommand : commands) { - if (!punishCommand.isEmpty()) { - if (punishCommand.equals("kick")) { - player.disconnect(new TextComponent(kickMessage)); - exploitPlayerManager.addPunishment(); - } else if (punishCommand.equals("notification")) { - notificationsModule.sendNotification(module.getName(), player, (int) newVls); - } else { - server.getPluginManager().dispatchCommand(server.getConsole(), - punishCommand.replace("%player%", player.getName())); - } - } - } - } + punish(module, player, commands, (int) newVls); } } } @@ -144,6 +132,33 @@ public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer } } + public void punish(final Module module, final ProxiedPlayer player, final Collection punishments, + final int newVls) { + if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { + final CommandSender consoleSender = server.getConsole(); + final String playerName = player.getName(); + + for (final String punishment : punishments) { + if (punishment.equals("kick")) { + final String locale = VersionUtil.getLocale(player); + final String kickMessage = messagesModule.getKickMessage(module, locale); + + player.disconnect(TextComponent.fromLegacyText(kickMessage)); + } else if (punishment.equals("notification")) { + final String moduleName = module.getName(); + + notificationsModule.sendNotification(moduleName, player, (int) newVls); + } else { + server.getPluginManager().dispatchCommand(consoleSender, + punishment.replace("%player%", playerName)); + } + } + + this.punishments.add(punishments); + this.exploitPlayerManager.addPunishment(); + } + } + public void clearViolations() { violations.clear(); } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index 21ab45c..d590139 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -1,23 +1,23 @@ package dev._2lstudios.exploitfixer.bungee.managers; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.UUID; import java.util.logging.Level; +import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; + public class ExploitPlayerManager { - private final ProxyServer proxy; + private final ProxyServer server; private final ModuleManager moduleManager; private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; - ExploitPlayerManager(final ProxyServer proxy, final ModuleManager moduleManager) { - this.proxy = proxy; + ExploitPlayerManager(final ProxyServer server, final ModuleManager moduleManager) { + this.server = server; this.moduleManager = moduleManager; reload(); @@ -35,7 +35,7 @@ public ExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); if (exploitPlayer == null) { - exploitPlayer = new ExploitPlayer(player.getName(), moduleManager); + exploitPlayer = new ExploitPlayer(server, player.getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -49,7 +49,7 @@ public int addPunishment() { public void reload() { exploitPlayers.clear(); - for (final ProxiedPlayer player : proxy.getPlayers()) { + for (final ProxiedPlayer player : server.getPlayers()) { final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); exploitPlayer.setLogged(true); @@ -63,14 +63,14 @@ public void clear() { while (iterator.hasNext()) { final UUID uuid = iterator.next(); - if (proxy.getPlayer(uuid) == null) { + if (server.getPlayer(uuid) == null) { iterator.remove(); cleared = true; } } if (cleared) { - proxy.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + server.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); } } } diff --git a/src/plugin.yml b/src/plugin.yml index 67e16d9..10789b2 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,10 +1,10 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.8 +version: 1.3.9 author: 2LS api: "1.13" api-version: "1.13" -softdepend: ['HamsterAPI'] +softdepend: [HamsterAPI] commands: exploitfixer: description: The main ExploitFixer command From d672f968ad9e2265baa0c1b034ec45ab1d0305e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 Jul 2020 20:43:41 -0300 Subject: [PATCH 070/336] Updated Source --- src/bungee.yml | 2 +- .../exploitfixer/bukkit/ExploitFixer.java | 74 +--- .../bukkit/commands/ExploitFixerCommand.java | 20 +- .../bukkit/listener/ListenerInitializer.java | 2 + .../bukkit/listener/PacketDecodeListener.java | 91 +++++ .../listener/PacketReceiveListener.java | 376 ++++++++++++++++++ .../listener/PlayerCommandListener.java | 4 +- .../bukkit/managers/ExploitPlayerManager.java | 5 +- .../bukkit/managers/ModuleManager.java | 11 +- .../bukkit/utils/VersionUtil.java | 23 -- .../bungee/commands/ExploitFixerCommand.java | 33 +- .../bungee/instanceables/ExploitPlayer.java | 2 +- .../bungee/listeners/ChatListener.java | 36 +- .../bungee/listeners/PostLoginListener.java | 14 +- .../bungee/managers/ExploitPlayerManager.java | 24 +- .../bungee/modules/NotificationsModule.java | 12 +- .../bungee/utils/VersionUtil.java | 26 ++ src/plugin.yml | 2 +- 18 files changed, 586 insertions(+), 171 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java diff --git a/src/bungee.yml b/src/bungee.yml index 82b1bd4..3e4dd1a 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.3.9 +version: 1.4.2 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 4034110..fa3ee23 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -9,7 +9,6 @@ import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi.HamsterAPIListenerInitializer; import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; @@ -21,7 +20,6 @@ public class ExploitFixer extends JavaPlugin { private ConfigurationUtil configurationUtil; private ModuleManager moduleManager; private ListenerInitializer listenerInitializer; - private HamsterAPIListenerInitializer hamsterAPIListenerInitializer; @Override public void onEnable() { @@ -41,20 +39,7 @@ public void onEnable() { this.moduleManager = new ModuleManager(this, configYml, messagesYml); this.listenerInitializer = new ListenerInitializer(this, moduleManager); - registerListeners(); - registerCommands(); - - if (checkHamsterAPI()) { - server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); - - this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); - - registerHamsterApi(); - } else { - scheduler.runTaskTimer(this, () -> this.getLogger().severe( - "ExploitFixer requires HamsterAPI 0.0.8 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), - 20L, 20L); - } + register(); scheduler.runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -71,30 +56,29 @@ public void onDisable() { scheduler.cancelTasks(this); this.listenerInitializer.unregister(); - - if (checkHamsterAPI()) { - this.hamsterAPIListenerInitializer.unregister(); - } } public void reload() { final Server server = getServer(); + final BukkitScheduler scheduler = server.getScheduler(); - server.getMessenger().unregisterIncomingPluginChannel(this); - - createConfigurations(); + if (checkHamsterAPI()) { + scheduler.cancelTasks(this); + server.getMessenger().unregisterIncomingPluginChannel(this); - final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); - final YamlConfiguration spigotYml = this.configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); + createConfigurations(); - moduleManager.reload(configYml, messagesYml, spigotYml); + final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); + final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final YamlConfiguration spigotYml = this.configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); - registerCommands(); - registerListeners(); + moduleManager.reload(configYml, messagesYml, spigotYml); - if (checkHamsterAPI()) { - registerHamsterApi(); + register(); + } else { + scheduler.runTaskTimer(this, () -> this.getLogger().severe( + "ExploitFixer requires HamsterAPI to work! Download: https://www.spigotmc.org/resources/78831/"), + 20L, 20L); } } @@ -102,12 +86,7 @@ private boolean checkHamsterAPI() { final Server server = this.getServer(); final PluginManager pluginManager = server.getPluginManager(); - if (pluginManager.isPluginEnabled("HamsterAPI")) { - return (Integer - .valueOf(pluginManager.getPlugin("HamsterAPI").getDescription().getVersion().replace(".", "")) > 7); - } else { - return false; - } + return pluginManager.isPluginEnabled("HamsterAPI"); } private void createConfigurations() { @@ -115,9 +94,13 @@ private void createConfigurations() { this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); } - private void registerListeners() { + private void register() { final Logger logger = this.getLogger(); + getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); + + logger.info("Successfully registered commands!"); + if (this.listenerInitializer.isRegistered()) { this.listenerInitializer.unregister(); } @@ -125,24 +108,9 @@ private void registerListeners() { this.listenerInitializer.register(); logger.info("Successfully registered listeners!"); - } - - private void registerHamsterApi() { - final Logger logger = this.getLogger(); - - if (this.hamsterAPIListenerInitializer.isRegistered()) { - this.hamsterAPIListenerInitializer.unregister(); - } - - this.hamsterAPIListenerInitializer.register(); - logger.info("Successfully hooked with HamsterAPI!"); } - private void registerCommands() { - getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager, checkHamsterAPI())); - } - public static ExploitFixer getInstance() { return exploitFixer; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index d373279..31836f6 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -1,28 +1,26 @@ package dev._2lstudios.exploitfixer.bukkit.commands; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; + import dev._2lstudios.exploitfixer.bukkit.ExploitFixer; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; public class ExploitFixerCommand implements CommandExecutor { private MessagesModule messagesModule; private NotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; - private final boolean hamsterApiEnabled; - public ExploitFixerCommand(final ModuleManager moduleManager, final boolean hamsterApiEnabled) { + public ExploitFixerCommand(final ModuleManager moduleManager) { this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.hamsterApiEnabled = hamsterApiEnabled; } @Override @@ -65,16 +63,14 @@ else if (args[0].equalsIgnoreCase("notifications")) { notificationsModule.setNotifications(player, false); commandSender.sendMessage(messagesModule.getDisable(lang)); } - } else + } else { commandSender.sendMessage(messagesModule.getPermission(lang)); - } else + } + } else { commandSender.sendMessage(messagesModule.getConsole(lang)); - } else + } + } else { commandSender.sendMessage(messagesModule.getUnknown(lang)); - - if (!hamsterApiEnabled) { - commandSender - .sendMessage(ChatColor.RED + "HamsterAPI is not installed! ExploitFixer will not behave properly!"); } return true; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index cf833ce..58afa9f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -23,6 +23,8 @@ public void register() { final Server server = this.plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); + pluginManager.registerEvents(new PacketDecodeListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PacketReceiveListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java new file mode 100644 index 0000000..bd33f3c --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -0,0 +1,91 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import java.util.logging.Logger; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import io.netty.buffer.ByteBuf; + +public class PacketDecodeListener implements Listener { + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + + PacketDecodeListener(final Plugin plugin, final ModuleManager moduleManager) { + HamsterAPI.getInstance().getBufferIO(); + this.plugin = plugin; + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onPacketReceive(final PacketDecodeEvent event) { + final Logger logger = plugin.getLogger(); + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + final Player player = hamsterPlayer.getPlayer(); + + if (player != null && player.isOnline()) { + final int dataBytes = packetsModule.getDataBytes(); + final ByteBuf byteBuf = event.getByteBuf().get(); + final int refCnt = byteBuf.refCnt(); + + if (refCnt < 1) { + final double dataVls = packetsModule.getDataVls(); + final String playerName = player.getName(), reason = "[Decoder|Data] " + playerName + + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; + + cancelExploit(event, hamsterPlayer, reason, dataVls); + } else if (byteBuf.capacity() > dataBytes) { + final double dataVls = packetsModule.getDataVls(); + final String playerName = player.getName(), reason = "[Decoder|Data] " + playerName + + " sent a packet that exceeds size limit! Max: " + dataBytes + " Vls: " + dataVls; + + cancelExploit(event, hamsterPlayer, reason, dataVls); + } + } else if (packetsModule.isOffline()) { + if (notificationsModule.isDebug()) { + if (player == null) { + logger.info("[Decoder|Offline] unknown sent a packet while offline!"); + } else { + logger.info("[Decoder|Offline] " + player.getName() + " sent a packet while offline!"); + } + } + + event.setCancelled(true); + hamsterPlayer.closeChannel(); + + return; + } + } + + private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final String reason, + final double vls) { + final Logger logger = plugin.getLogger(); + final Player player = hamsterPlayer.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + if (notificationsModule.isDebug()) { + logger.info(reason); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, vls); + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java new file mode 100644 index 0000000..669a20a --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -0,0 +1,376 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Map; +import java.util.logging.Logger; + +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; + +public class PacketReceiveListener implements Listener { + private final Plugin plugin; + private final CustomPayloadModule customPayloadModule; + private final ExploitPlayerManager exploitPlayerManager; + private final ItemsFixModule itemsFixModule; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + + PacketReceiveListener(final Plugin plugin, final ModuleManager moduleManager) { + this.plugin = plugin; + this.customPayloadModule = moduleManager.getCustomPayloadModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.itemsFixModule = moduleManager.getItemsFixModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onPacketReceive(final PacketReceiveEvent event) { + final Logger logger = plugin.getLogger(); + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + final Player player = hamsterPlayer.getPlayer(); + final PacketWrapper packetWrapper = event.getPacket(); + final PacketType packetType = packetWrapper.getType(); + + if (packetType != PacketType.PacketPlayInKeepAlive) { + final Map strings = packetWrapper.getStrings(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final String playerName = player.getName(), packetName = packetWrapper.getName(); + final double dataVls = packetsModule.getDataVls(); + final int dataBytes = packetsModule.getDataBytes(); + + if (packetsModule.isEnabled()) { + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(), + setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(), + bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999 && slot != -1) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); + return; + } else if (slot >= maxSlots) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { + if (player.getGameMode() != GameMode.CREATIVE) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); + return; + } + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += getItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, + packetName, dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize + + " bytes long!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && checkSign(strings.values().toArray(new String[0]))) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = customPayloadModule.getTagVls(), bookVls = customPayloadModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Tag] " + playerName + + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, tagVls); + return; + } else { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Book] " + playerName + " tried to send a " + tag + + " custompayload packet without a book in hand!"); + } + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, bookVls); + return; + } /* + * else if (byteLength > customPayloadModule.getBookBytes()) { + * logger.info(playerName + " tried to send a " + tag + + * " custompayload packet without a book in hand!"); event.setCancelled(true); + * exploitPlayer.addVls(plugin, event, player, customPayloadModule, + * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS + */ + } + + exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, + customPayloadModule.getMultiplier(tag)); + } + } else { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); + } + + event.setCancelled(true); + } + } + } + + final Map items = packetWrapper.getItems(); + + if (itemsFixModule.isEnabled() && items.containsKey("b")) { + final ItemStack itemStack = items.get("b"); + + if (itemStack != null) { + final String materialName = itemStack.getType().toString(); + String blocked = null; + + for (final String blockedMaterial : itemsFixModule.getBlacklist()) { + if (materialName.equals(blockedMaterial)) { + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + blocked = materialName; + break; + } + } + + final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); + + packetWrapper.write("b", fixedItemStack); + + if (notificationsModule.isDebug()) { + if (player != null) { + if (blocked != null) { + logger.info(player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + + ")"); + } else { + logger.info(player.getName() + " had a creative item fixed by ExploiFixer!"); + } + } + } + } + } + } + + private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, + final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { + final Logger logger = plugin.getLogger(); + int itemBytesLength = 0; + + if (itemStack != null) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + + try { + itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final Exception exception) { + if (notificationsModule.isDebug()) { + logger.info( + "[" + packetName + "] There was an exception when processing itemStack data to String!"); + } + } + + if (itemStack.hasItemMeta() && itemMeta != null) { + try { + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { + itemBytesLength += getItemLength(itemStack1, exploitPlayer, hamsterPlayer, + packetName, itemBytesMax); + + if (itemBytesLength > itemBytesMax) { + return itemBytesLength; + } + } + } + } + } else { + throw new Exception(); + } + } catch (final Exception exception) { + if (itemMeta instanceof BookMeta) { + itemBytesLength += getBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); + } else { + try { + itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e) { + itemBytesLength += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + } + } + } + } + + return itemBytesLength; + } + + private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, + final ItemMeta itemMeta, final String packetName) { + final Player player = hamsterPlayer.getPlayer(); + final Logger logger = plugin.getLogger(); + final BookMeta bookMeta = (BookMeta) itemMeta; + final double dataVls = packetsModule.getDataVls(); + final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); + int bookTotalBytes = 0; + + if (pageCount > 50) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + } else { + for (final String page : bookMeta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + bookTotalBytes += pageBytes; + + if (pageBytes > dataBytesBook) { + if (notificationsModule.isDebug()) { + logger.info("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many characters per page! (" + pageBytes + + "/" + dataBytesBook + ") Added vls: " + dataVls); + } + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + break; + } + } + + return bookTotalBytes; + } + + return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } + + private boolean checkSign(final String[] linesString) { + final int dataBytesSign = packetsModule.getDataBytesSign(); + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else { + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { + return true; + } + } + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index 4d1c236..b65dd2d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -33,10 +33,10 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ")) { + if (message.startsWith(command)) { final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 3adfd36..b498ed0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -16,13 +16,12 @@ public class ExploitPlayerManager { private final Server server; private final ModuleManager moduleManager; private final Map exploitPlayers = new HashMap<>(); - private int punishments; + private int punishments = 0; ExploitPlayerManager(final Plugin plugin, final Server server, final ModuleManager moduleManager) { this.plugin = plugin; this.server = server; this.moduleManager = moduleManager; - this.punishments = 0; reload(); } @@ -72,6 +71,6 @@ public int getPunishments() { } public int addPunishment() { - return ++punishments; + return punishments += 1; } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index ec7ae88..c57aa5e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -1,11 +1,18 @@ package dev._2lstudios.exploitfixer.bukkit.managers; +import java.util.logging.Level; + import org.bukkit.Server; import org.bukkit.configuration.Configuration; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.modules.*; -import java.util.logging.Level; +import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; public class ModuleManager { private Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index c1f4237..44e12c8 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,12 +1,8 @@ package dev._2lstudios.exploitfixer.bukkit.utils; -import java.util.Locale; - import org.bukkit.Server; import org.bukkit.entity.Player; -import net.md_5.bungee.api.connection.ProxiedPlayer; - public class VersionUtil { private static boolean oneDotFifteen, oneDotSeven; @@ -46,23 +42,4 @@ public static boolean isOneDotFifteen() { public static boolean isOneDotSeven() { return oneDotSeven; } - - public static String getLocale(ProxiedPlayer player) { - final Locale locale = player.getLocale(); - final String lang; - - if (locale != null) { - final String localeString = locale.toString(); - - if (localeString.length() > 1) { - lang = localeString.substring(0, 2); - } else { - lang = "en"; - } - } else { - lang = "en"; - } - - return lang; - } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index 18f7a0f..8227f6b 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -9,6 +9,7 @@ import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; import java.util.Locale; @@ -30,33 +31,25 @@ public void execute(final CommandSender commandSender, final String[] args) { final int length = args.length; if (commandSender instanceof ProxiedPlayer) { - final Locale locale = ((ProxiedPlayer) commandSender).getLocale(); - - if (locale != null) { - final String localeString = locale.toString(); - - if (localeString.length() > 1) { - lang = localeString.substring(0, 2); - } - } + lang = VersionUtil.getLocale((ProxiedPlayer) commandSender); } if (length < 1 || args[0].equals("help")) { - commandSender - .sendMessage(new TextComponent(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); + commandSender.sendMessage( + TextComponent.fromLegacyText(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); } else if (args[0].equals("reload")) if (commandSender.hasPermission("exploitfixer.admin")) { ExploitFixer.getInstance().reload(); - commandSender.sendMessage(new TextComponent(messagesModule.getReload(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getReload(lang))); } else - commandSender.sendMessage(new TextComponent(messagesModule.getPermission(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); else if (args[0].equals("stats")) if (commandSender.hasPermission("exploitfixer.admin")) - commandSender.sendMessage(new TextComponent(messagesModule.getStats(lang) + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getStats(lang) .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize())))); else - commandSender.sendMessage(new TextComponent(messagesModule.getPermission(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); else if (args[0].equalsIgnoreCase("notifications")) { if (commandSender instanceof ProxiedPlayer) { if (commandSender.hasPermission("exploitfixer.admin") @@ -65,16 +58,16 @@ else if (args[0].equalsIgnoreCase("notifications")) { if (!notificationsVariables.isNotifications(proxiedPlayer)) { notificationsVariables.setNotifications(proxiedPlayer, true); - commandSender.sendMessage(new TextComponent(messagesModule.getEnable(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getEnable(lang))); } else { notificationsVariables.setNotifications(proxiedPlayer, false); - commandSender.sendMessage(new TextComponent(messagesModule.getDisable(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getDisable(lang))); } } else - commandSender.sendMessage(new TextComponent(messagesModule.getPermission(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); } else - commandSender.sendMessage(new TextComponent(messagesModule.getConsole(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getConsole(lang))); } else - commandSender.sendMessage(new TextComponent(messagesModule.getUnknown(lang))); + commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getUnknown(lang))); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java index d33194e..6cc1aae 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java @@ -9,11 +9,11 @@ import java.util.HashSet; import java.util.Map; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.interfaces.Module; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; import net.md_5.bungee.api.CommandSender; diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index aedaf7e..007b1d4 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -1,19 +1,17 @@ package dev._2lstudios.exploitfixer.bungee.listeners; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.ChatEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.event.EventHandler; import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.CommandsModule; import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ChatEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.event.EventHandler; public class ChatListener implements Listener { private final Plugin plugin; @@ -42,27 +40,11 @@ public void onChat(final ChatEvent event) { if (!exploitPlayer.isLogged()) { event.setCancelled(true); } else if (commandsModule.isEnabled()) { - final ProxyServer server = plugin.getProxy(); - final String message = event.getMessage().replaceAll("[\\w]+:", "").toLowerCase(); + final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command + " ")) { - for (final String punishment : commandsModule.getPunishments()) { - if (punishment.equals("kick")) { - final String locale = player.getLocale().toString().substring(0, 2); - final String kickMessage = messagesModule.getKickMessage(commandsModule, locale); - - player.disconnect(TextComponent.fromLegacyText(kickMessage)); - exploitPlayerManager.addPunishment(); - } else if (punishment.equals("notification")) { - final String moduleName = commandsModule.getName(); - - notificationsModule.sendNotification(moduleName, player, (int) 1); - } else { - server.getPluginManager().dispatchCommand(server.getConsole(), - punishment.replace("%player%", player.getName())); - } - } + if (message.startsWith(command)) { + exploitPlayer.punish(commandsModule, player, commandsModule.getPunishments(), 1); event.setCancelled(true); break; diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index e4ea00d..f2a8912 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -14,6 +14,7 @@ import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; import java.net.InetSocketAddress; import java.util.Locale; @@ -38,16 +39,11 @@ public class PostLoginListener implements Listener { public void onPostLogin(final PostLoginEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); final InetSocketAddress address = proxiedPlayer.getAddress(); - final Locale playerLocale = proxiedPlayer.getLocale(); - final String locale; - - if (playerLocale != null) - locale = playerLocale.toLanguageTag().substring(0, 2); - else - locale = "en"; + final String locale = VersionUtil.getLocale(proxiedPlayer); if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { - proxiedPlayer.disconnect(new TextComponent(messagesModule.getKickMessage("nulladdress", locale))); + proxiedPlayer + .disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); } else { final UUID uuid = proxiedPlayer.getUniqueId(); final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); @@ -67,7 +63,7 @@ public void onPostLogin(final PostLoginEvent event) { if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - proxiedPlayer.disconnect(new TextComponent(uuidSpoofKickMessage)); + proxiedPlayer.disconnect(TextComponent.fromLegacyText(uuidSpoofKickMessage)); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index d590139..cda3ec3 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -23,14 +23,6 @@ public class ExploitPlayerManager { reload(); } - public int getSize() { - return exploitPlayers.size(); - } - - public int getPunishments() { - return punishments; - } - public ExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); @@ -42,10 +34,6 @@ public ExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { return exploitPlayer; } - public int addPunishment() { - return ++punishments; - } - public void reload() { exploitPlayers.clear(); @@ -73,4 +61,16 @@ public void clear() { server.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); } } + + public int getSize() { + return exploitPlayers.size(); + } + + public int getPunishments() { + return punishments; + } + + public int addPunishment() { + return punishments += 1; + } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java index 47f07f9..6575033 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java @@ -1,14 +1,15 @@ package dev._2lstudios.exploitfixer.bungee.modules; +import java.util.Collection; +import java.util.HashSet; + +import dev._2lstudios.exploitfixer.shared.interfaces.Module; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; - -import java.util.Collection; -import java.util.HashSet; public class NotificationsModule implements Module { private final CommandSender console; @@ -44,7 +45,8 @@ public final boolean isNotifications(final ProxiedPlayer player) { public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { if (enabled && player != null) { - final TextComponent notification = new TextComponent(message.replace("%player%", player.getName()) + final BaseComponent[] notification = TextComponent.fromLegacyText(message + .replace("%player%", player.getName()) .replace("%check%", check).replace("%ping%", String.valueOf(player.getPing())) .replace("%vls%", String.valueOf(violations))); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java new file mode 100644 index 0000000..27f1188 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java @@ -0,0 +1,26 @@ +package dev._2lstudios.exploitfixer.bungee.utils; + +import java.util.Locale; + +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class VersionUtil { + public static String getLocale(final ProxiedPlayer player) { + final Locale locale = player.getLocale(); + final String lang; + + if (locale != null) { + final String localeString = locale.toString(); + + if (localeString.length() > 1) { + lang = localeString.substring(0, 2); + } else { + lang = "en"; + } + } else { + lang = "en"; + } + + return lang; + } +} \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 10789b2..3b41279 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.3.9 +version: 1.4.2 author: 2LS api: "1.13" api-version: "1.13" From e8df3a79716d2a89a698ec06d7c8b1e74dd2723f Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 Jul 2020 20:45:50 -0300 Subject: [PATCH 071/336] Updated Source --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index 3b41279..d249644 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.2 +version: 1.4.3 author: 2LS api: "1.13" api-version: "1.13" From e19d47bb27bbfdc11a93ad1bb65f150d0a584ffa Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 Jul 2020 20:49:21 -0300 Subject: [PATCH 072/336] Updated Source --- src/bungee.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bungee.yml b/src/bungee.yml index 3e4dd1a..e24b2aa 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.2 +version: 1.4.3 author: 2LS commands: exploitfixer: From e0f8bfbda12c2959e3cef779c5489198642acde5 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Thu, 30 Jul 2020 11:59:11 -0300 Subject: [PATCH 073/336] Updated Source --- src/bungee.yml | 2 +- .../bukkit/commands/ExploitFixerCommand.java | 4 +- .../bukkit/instanceables/ExploitPlayer.java | 8 +- .../bukkit/listener/PacketDecodeListener.java | 18 +--- .../listener/PacketReceiveListener.java | 93 +++++++------------ .../bukkit/listener/PlayerLoginListener.java | 4 +- .../bukkit/managers/ModuleManager.java | 11 ++- .../bukkit/modules/BukkitMessagesModule.java | 47 ++++++++++ .../bukkit/modules/ItemsFixModule.java | 47 +++++++--- .../bukkit/modules/NotificationsModule.java | 15 ++- .../bungee/commands/ExploitFixerCommand.java | 6 +- .../bungee/instanceables/ExploitPlayer.java | 10 +- .../bungee/listeners/ChatListener.java | 8 -- .../listeners/PluginMessageListener.java | 17 +--- .../bungee/listeners/PostLoginListener.java | 5 +- .../bungee/managers/ModuleManager.java | 9 +- .../bungee/modules/BungeeMessagesModule.java | 45 +++++++++ .../bungee/modules/NotificationsModule.java | 20 ++-- .../shared/interfaces/IMessagesModule.java | 5 + .../shared/interfaces/IModule.java | 7 ++ .../shared/interfaces/PunishmentModule.java | 2 +- .../shared/interfaces/ViolationModule.java | 2 +- .../shared/modules/MessagesModule.java | 52 +++++++++++ src/plugin.yml | 2 +- 24 files changed, 286 insertions(+), 153 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java diff --git a/src/bungee.yml b/src/bungee.yml index e24b2aa..194443d 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.3 +version: 1.4.4 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 31836f6..2e3a723 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -8,12 +8,12 @@ import dev._2lstudios.exploitfixer.bukkit.ExploitFixer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; public class ExploitFixerCommand implements CommandExecutor { - private MessagesModule messagesModule; + private BukkitMessagesModule messagesModule; private NotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java index 5838416..6d6111d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java @@ -18,10 +18,10 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; @@ -30,7 +30,7 @@ public class ExploitPlayer { private final Plugin plugin; private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; + private final BukkitMessagesModule messagesModule; private final NotificationsModule notificationsModule; private final Map violations; private final Collection> punishments; @@ -137,7 +137,7 @@ public void addVls(final Plugin plugin, final Cancellable event, final PacketWra } } - public void punish(final Module module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, + public void punish(final IModule module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, final Collection punishments, final int newVls) { if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { final Server server = plugin.getServer(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index bd33f3c..2eaba56 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -1,7 +1,5 @@ package dev._2lstudios.exploitfixer.bukkit.listener; -import java.util.logging.Logger; - import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -37,7 +35,6 @@ public class PacketDecodeListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketReceive(final PacketDecodeEvent event) { - final Logger logger = plugin.getLogger(); final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); final Player player = hamsterPlayer.getPlayer(); @@ -60,12 +57,10 @@ public void onPacketReceive(final PacketDecodeEvent event) { cancelExploit(event, hamsterPlayer, reason, dataVls); } } else if (packetsModule.isOffline()) { - if (notificationsModule.isDebug()) { - if (player == null) { - logger.info("[Decoder|Offline] unknown sent a packet while offline!"); - } else { - logger.info("[Decoder|Offline] " + player.getName() + " sent a packet while offline!"); - } + if (player == null) { + notificationsModule.debug("[Decoder|Offline] unknown sent a packet while offline!"); + } else { + notificationsModule.debug("[Decoder|Offline] " + player.getName() + " sent a packet while offline!"); } event.setCancelled(true); @@ -77,13 +72,10 @@ public void onPacketReceive(final PacketDecodeEvent event) { private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final String reason, final double vls) { - final Logger logger = plugin.getLogger(); final Player player = hamsterPlayer.getPlayer(); final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (notificationsModule.isDebug()) { - logger.info(reason); - } + notificationsModule.debug(reason); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, vls); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 669a20a..5b375a4 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -3,7 +3,6 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Map; -import java.util.logging.Logger; import org.bukkit.GameMode; import org.bukkit.Material; @@ -54,7 +53,6 @@ public class PacketReceiveListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketReceive(final PacketReceiveEvent event) { - final Logger logger = plugin.getLogger(); final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); final Player player = hamsterPlayer.getPlayer(); final PacketWrapper packetWrapper = event.getPacket(); @@ -87,21 +85,17 @@ public void onPacketReceive(final PacketReceiveEvent event) { } if (slot < 0 && slot != -999 && slot != -1) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick); - } + notificationsModule.debug("[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); return; } else if (slot >= maxSlots) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " - + windowClick); - } + notificationsModule.debug( + "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + + slot + "/" + maxSlots + ") Added vls: " + windowClick); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); @@ -111,10 +105,8 @@ public void onPacketReceive(final PacketReceiveEvent event) { if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { if (player.getGameMode() != GameMode.CREATIVE) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|SetCreativeSlot] " + playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); - } + notificationsModule.debug("[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); @@ -141,10 +133,8 @@ public void onPacketReceive(final PacketReceiveEvent event) { } if (dataBytes > 0 && packetSize > dataBytes) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize - + " bytes long!"); - } + notificationsModule.debug("[" + packetName + "|Data] " + playerName + " sent a packet of " + + packetSize + " bytes long!"); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); @@ -153,10 +143,8 @@ public void onPacketReceive(final PacketReceiveEvent event) { if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign && checkSign(strings.values().toArray(new String[0]))) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Data] " + playerName - + " has sent a too big sign packet! Added vls: " + dataVls); - } + notificationsModule.debug("[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); @@ -176,10 +164,8 @@ && checkSign(strings.values().toArray(new String[0]))) { final double tagVls = customPayloadModule.getTagVls(), bookVls = customPayloadModule.getBookVls(); if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Tag] " + playerName - + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } + notificationsModule.debug("[" + packetName + "|Tag] " + playerName + + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, tagVls); @@ -190,17 +176,15 @@ && checkSign(strings.values().toArray(new String[0]))) { final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Book] " + playerName + " tried to send a " + tag - + " custompayload packet without a book in hand!"); - } + notificationsModule.debug("[" + packetName + "|Book] " + playerName + + " tried to send a " + tag + " custompayload packet without a book in hand!"); event.setCancelled(true); exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, bookVls); return; } /* * else if (byteLength > customPayloadModule.getBookBytes()) { - * logger.info(playerName + " tried to send a " + tag + + * notificationsModule.debug(playerName + " tried to send a " + tag + * " custompayload packet without a book in hand!"); event.setCancelled(true); * exploitPlayer.addVls(plugin, event, player, customPayloadModule, * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS @@ -211,9 +195,8 @@ && checkSign(strings.values().toArray(new String[0]))) { customPayloadModule.getMultiplier(tag)); } } else { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); - } + notificationsModule + .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); event.setCancelled(true); } @@ -242,14 +225,12 @@ && checkSign(strings.values().toArray(new String[0]))) { packetWrapper.write("b", fixedItemStack); - if (notificationsModule.isDebug()) { - if (player != null) { - if (blocked != null) { - logger.info(player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked - + ")"); - } else { - logger.info(player.getName() + " had a creative item fixed by ExploiFixer!"); - } + if (player != null) { + if (blocked != null) { + notificationsModule.debug( + player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); + } else { + notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); } } } @@ -258,7 +239,6 @@ && checkSign(strings.values().toArray(new String[0]))) { private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { - final Logger logger = plugin.getLogger(); int itemBytesLength = 0; if (itemStack != null) { @@ -267,10 +247,8 @@ private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploit try { itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; } catch (final Exception exception) { - if (notificationsModule.isDebug()) { - logger.info( - "[" + packetName + "] There was an exception when processing itemStack data to String!"); - } + notificationsModule + .debug("[" + packetName + "] There was an exception when processing itemStack data to String!"); } if (itemStack.hasItemMeta() && itemMeta != null) { @@ -318,18 +296,15 @@ private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploit private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, final ItemMeta itemMeta, final String packetName) { final Player player = hamsterPlayer.getPlayer(); - final Logger logger = plugin.getLogger(); final BookMeta bookMeta = (BookMeta) itemMeta; final double dataVls = packetsModule.getDataVls(); final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); int bookTotalBytes = 0; if (pageCount > 50) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 - + ") Added vls: " + dataVls); - } + notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " + + dataVls); exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); } else { @@ -339,11 +314,9 @@ private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer bookTotalBytes += pageBytes; if (pageBytes > dataBytesBook) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many characters per page! (" + pageBytes - + "/" + dataBytesBook + ") Added vls: " + dataVls); - } + notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" + + dataBytesBook + ") Added vls: " + dataVls); exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); break; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index 8812a6c..b47c574 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -15,7 +15,7 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import java.net.InetAddress; @@ -24,7 +24,7 @@ public class PlayerLoginListener implements Listener { private final Plugin plugin; private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; + private final BukkitMessagesModule messagesModule; private final ConnectionModule connectionModule; private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index c57aa5e..6c28969 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -10,7 +10,7 @@ import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.bukkit.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; @@ -20,7 +20,7 @@ public class ModuleManager { private final ConnectionModule connectionModule; private final CustomPayloadModule customPayloadModule; private final ItemsFixModule itemsFixModule; - private final MessagesModule messagesModule; + private final BukkitMessagesModule messagesModule; private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; @@ -31,8 +31,9 @@ public ModuleManager(final Plugin plugin, final Configuration configYml, final C this.connectionModule = new ConnectionModule(configYml); this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); this.itemsFixModule = new ItemsFixModule(plugin, configYml); - this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), configYml); + this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), plugin.getLogger(), + configYml); this.packetsModule = new PacketsModule(plugin, this, configYml); this.exploitPlayerManager = new ExploitPlayerManager(plugin, plugin.getServer(), this); } @@ -74,7 +75,7 @@ public ItemsFixModule getItemsFixModule() { return itemsFixModule; } - public MessagesModule getMessagesModule() { + public BukkitMessagesModule getMessagesModule() { return messagesModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java new file mode 100644 index 0000000..04ce403 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -0,0 +1,47 @@ +package dev._2lstudios.exploitfixer.bukkit.modules; + +import org.bukkit.ChatColor; +import org.bukkit.configuration.Configuration; + +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; + +public class BukkitMessagesModule extends MessagesModule { + private final String version; + private Configuration messagesYml; + private String discord; + + public BukkitMessagesModule(final String version, final Configuration messagesYml) { + reload(messagesYml); + this.version = version; + } + + public boolean isEnabled() { + return true; + } + + public String getName() { + return "Messages"; + } + + public void reload(final Configuration messagesYml) { + this.messagesYml = messagesYml; + this.discord = messagesYml.getString("discord", ""); + } + + @Override + public String getString(final String locale, final String path) { + String string = messagesYml.getString(locale + path); + + if (string == null || string.isEmpty()) { + string = messagesYml.getString("en" + path); + } + + if (string != null && !string.isEmpty()) { + return ChatColor.translateAlternateColorCodes('&', + string.replace("%version%", version).replace("%discord%", discord)); + } else { + return ""; + } + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 0a217f9..411909d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -7,15 +7,18 @@ import org.bukkit.Material; import org.bukkit.configuration.Configuration; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.inventory.meta.SpawnEggMeta; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -public class ItemsFixModule implements Module { +public class ItemsFixModule implements IModule { private final Plugin plugin; private boolean enabled; private int enchantLimit, maxStackSize; @@ -59,22 +62,23 @@ public Collection getBlacklist() { public ItemStack fixItem(final ItemStack itemStack) { final Material material = Material.getMaterial(itemStack.getType().name()); - final ItemMeta itemMeta = itemStack.getItemMeta(), + final ItemMeta oldItemMeta = itemStack.getItemMeta(), newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); final int maxStackSize = getMaxStackSize(); final short durability = itemStack.getDurability(); if (itemStack.hasItemMeta()) { - final String displayName = itemMeta.getDisplayName(); - final List lore = itemMeta.getLore(); + final String displayName = oldItemMeta.getDisplayName(); + final List lore = oldItemMeta.getLore(); if (enchantLimit > -1) { - if (itemMeta instanceof EnchantmentStorageMeta) { - final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) itemMeta; + if (oldItemMeta instanceof EnchantmentStorageMeta) { + final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; + final EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; enchantmentStorageMeta.getStoredEnchants().forEach((enchantment, level) -> { if (level <= enchantLimit && level > -1) { - enchantmentStorageMeta.addStoredEnchant(enchantment, level, true); + newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, true); } }); } else { @@ -87,17 +91,32 @@ public ItemStack fixItem(final ItemStack itemStack) { } if (newItemMeta instanceof BookMeta) { - final BookMeta bookMeta = (BookMeta) itemMeta; + final BookMeta oldBookMeta = (BookMeta) oldItemMeta; final BookMeta newBookMeta = (BookMeta) newItemMeta; - newBookMeta.setTitle(bookMeta.getTitle()); - newBookMeta.setAuthor(bookMeta.getAuthor()); - newBookMeta.setPages(bookMeta.getPages()); + newBookMeta.setTitle(oldBookMeta.getTitle()); + newBookMeta.setAuthor(oldBookMeta.getAuthor()); + newBookMeta.setPages(oldBookMeta.getPages()); } else if (newItemMeta instanceof SkullMeta) { - final SkullMeta skullMeta = (SkullMeta) itemMeta; + final SkullMeta oldSkullMeta = (SkullMeta) oldItemMeta; final SkullMeta newSkullMeta = (SkullMeta) newItemMeta; - newSkullMeta.setOwner(skullMeta.getOwner()); + newSkullMeta.setOwner(oldSkullMeta.getOwner()); + } else if (newItemMeta instanceof BannerMeta) { + final BannerMeta oldBannerMeta = (BannerMeta) oldItemMeta; + final BannerMeta newBannerMeta = (BannerMeta) newItemMeta; + + newBannerMeta.setBaseColor(oldBannerMeta.getBaseColor()); + } else if (newItemMeta instanceof SpawnEggMeta) { + final SpawnEggMeta oldSpawnEggMeta = (SpawnEggMeta) oldItemMeta; + final SpawnEggMeta newSpawnEggMeta = (SpawnEggMeta) newItemMeta; + + newSpawnEggMeta.setSpawnedType(oldSpawnEggMeta.getSpawnedType()); + } else if (newItemMeta instanceof LeatherArmorMeta) { + final LeatherArmorMeta oldLeatherArmorMeta = (LeatherArmorMeta) oldItemMeta; + final LeatherArmorMeta newLeatherArmorMeta = (LeatherArmorMeta) newItemMeta; + + newLeatherArmorMeta.setColor(oldLeatherArmorMeta.getColor()); } if (displayName != null && displayName.getBytes().length < 128) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java index e747e08..22ff5e5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java @@ -3,21 +3,24 @@ import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.HashSet; +import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.configuration.Configuration; import org.bukkit.entity.Player; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -public class NotificationsModule implements Module { +public class NotificationsModule implements IModule { private final CommandSender console; + private final Logger logger; private final Collection notifications = new HashSet<>(); private boolean enabled, debug; private String message; - public NotificationsModule(final CommandSender console, final Configuration configYml) { + public NotificationsModule(final CommandSender console, final Logger logger, final Configuration configYml) { + this.logger = logger; this.console = console; reload(configYml); } @@ -27,8 +30,10 @@ public boolean isEnabled() { return this.enabled; } - public boolean isDebug() { - return this.debug; + public void debug(final String message) { + if (this.debug) { + this.logger.info(message); + } } public final void setNotifications(final Player player, final boolean input) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index 8227f6b..58ec661 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -7,14 +7,12 @@ import dev._2lstudios.exploitfixer.bungee.ExploitFixer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import java.util.Locale; - public class ExploitFixerCommand extends Command { - private MessagesModule messagesModule; + private BungeeMessagesModule messagesModule; private NotificationsModule notificationsVariables; private ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java index 6cc1aae..ffa8191 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java @@ -11,10 +11,10 @@ import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -26,7 +26,7 @@ public class ExploitPlayer { private final ProxyServer server; private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; + private final BungeeMessagesModule messagesModule; private final NotificationsModule notificationsModule; private final Map violations; private final Collection> punishments; @@ -54,7 +54,7 @@ public int addChannels(final int channels) { return this.channels += channels; } - public double getViolations(final Module module) { + public double getViolations(final IModule module) { if (module instanceof ViolationModule) { return violations.getOrDefault(module, 0D); } else { @@ -132,7 +132,7 @@ public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer } } - public void punish(final Module module, final ProxiedPlayer player, final Collection punishments, + public void punish(final IModule module, final ProxiedPlayer player, final Collection punishments, final int newVls) { if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { final CommandSender consoleSender = server.getConsole(); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index 007b1d4..fbf541c 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -4,8 +4,6 @@ import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.modules.CommandsModule; -import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -14,18 +12,12 @@ import net.md_5.bungee.event.EventHandler; public class ChatListener implements Listener { - private final Plugin plugin; private final CommandsModule commandsModule; private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; ChatListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); } @EventHandler(priority = -128) diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java index aa0a04a..174c9f6 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -1,7 +1,5 @@ package dev._2lstudios.exploitfixer.bungee.listeners; -import java.util.logging.Logger; - import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; @@ -33,16 +31,13 @@ public void onPluginMessage(final PluginMessageEvent event) { final Connection connection = event.getSender(); if (connection instanceof ProxiedPlayer) { - final Logger logger = plugin.getLogger(); final ProxiedPlayer player = (ProxiedPlayer) connection; final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); final String tag = event.getTag(), playerName = player.getName(); final double tagVls = customPayloadModule.getTagVls(); if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } + notificationsModule.debug(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); event.setCancelled(true); exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); @@ -52,10 +47,8 @@ public void onPluginMessage(final PluginMessageEvent event) { final int byteLength = data.length; if (byteLength > customPayloadModule.getDataBytes()) { - if (notificationsModule.isDebug()) { - logger.info("[PacketPlayInCustomPayload] Sent by " + playerName - + " got cancelled because its " + byteLength + " bytes long!"); - } + notificationsModule.debug("[PacketPlayInCustomPayload] Sent by " + playerName + + " got cancelled because its " + byteLength + " bytes long!"); event.setCancelled(true); exploitPlayer.addVls(plugin, event, player, customPayloadModule, @@ -63,8 +56,8 @@ public void onPluginMessage(final PluginMessageEvent event) { return; } else if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { /* - * if (byteLength > customPayloadModule.getBookBytes()) { logger.info(playerName - * + " tried to send a " + tag + + * if (byteLength > customPayloadModule.getBookBytes()) { + * notificationsModule.debug(playerName + " tried to send a " + tag + * " custompayload packet without a book in hand!"); event.setCancelled(true); * exploitPlayer.addVls(plugin, event, player, customPayloadModule, * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index f2a8912..773d434 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -12,19 +12,18 @@ import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.MessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; import java.net.InetSocketAddress; -import java.util.Locale; import java.util.UUID; public class PostLoginListener implements Listener { private final Plugin plugin; private final ConnectionModule connectionModule; private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; + private final BungeeMessagesModule messagesModule; private final ExploitPlayerManager exploitPlayerManager; PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index 52708e1..8c0af8c 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -9,7 +9,7 @@ public class ModuleManager { private CommandsModule commandsModule; private final ConnectionModule connectionModule; private CustomPayloadModule customPayloadModule; - private MessagesModule messagesModule; + private BungeeMessagesModule messagesModule; private NotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; @@ -17,8 +17,9 @@ public ModuleManager(final Plugin plugin, final Configuration configYml, final C this.commandsModule = new CommandsModule(configYml); this.connectionModule = new ConnectionModule(configYml); this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); - this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new NotificationsModule(plugin.getProxy().getConsole(), configYml); + this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); + this.notificationsModule = new NotificationsModule(plugin.getProxy().getConsole(), plugin.getLogger(), + configYml); this.exploitPlayerManager = new ExploitPlayerManager(plugin.getProxy(), this); } @@ -43,7 +44,7 @@ public CustomPayloadModule getCustomPayloadModule() { return customPayloadModule; } - public MessagesModule getMessagesModule() { + public BungeeMessagesModule getMessagesModule() { return messagesModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java new file mode 100644 index 0000000..43a8949 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -0,0 +1,45 @@ +package dev._2lstudios.exploitfixer.bungee.modules; + +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.config.Configuration; + +public class BungeeMessagesModule extends MessagesModule { + private final String version; + private Configuration messagesYml; + private String discord; + + public BungeeMessagesModule(final String version, final Configuration messagesYml) { + reload(messagesYml); + this.version = version; + } + + public boolean isEnabled() { + return true; + } + + public String getName() { + return "Messages"; + } + + public void reload(final Configuration messagesYml) { + this.messagesYml = messagesYml; + this.discord = messagesYml.getString("discord", ""); + } + + @Override + public String getString(final String locale, final String path) { + String string = messagesYml.getString(locale + path); + + if (string == null || string.isEmpty()) { + string = messagesYml.getString("en" + path); + } + + if (string != null && !string.isEmpty()) { + return ChatColor.translateAlternateColorCodes('&', + string.replace("%version%", version).replace("%discord%", discord)); + } else { + return ""; + } + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java index 6575033..68a94cf 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java @@ -2,8 +2,9 @@ import java.util.Collection; import java.util.HashSet; +import java.util.logging.Logger; -import dev._2lstudios.exploitfixer.shared.interfaces.Module; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.BaseComponent; @@ -11,13 +12,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.config.Configuration; -public class NotificationsModule implements Module { +public class NotificationsModule implements IModule { private final CommandSender console; + private final Logger logger; private final Collection notifications = new HashSet<>(); private boolean enabled, debug; private String message; - public NotificationsModule(final CommandSender console, final Configuration configYml) { + public NotificationsModule(final CommandSender console, final Logger logger, final Configuration configYml) { + this.logger = logger; this.console = console; reload(configYml); } @@ -27,8 +30,10 @@ public boolean isEnabled() { return this.enabled; } - public boolean isDebug() { - return this.debug; + public void debug(final String message) { + if (this.debug) { + this.logger.info(message); + } } public final void setNotifications(final ProxiedPlayer player, final boolean input) { @@ -46,9 +51,8 @@ public final boolean isNotifications(final ProxiedPlayer player) { public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { if (enabled && player != null) { final BaseComponent[] notification = TextComponent.fromLegacyText(message - .replace("%player%", player.getName()) - .replace("%check%", check).replace("%ping%", String.valueOf(player.getPing())) - .replace("%vls%", String.valueOf(violations))); + .replace("%player%", player.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(player.getPing())).replace("%vls%", String.valueOf(violations))); console.sendMessage(notification); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java new file mode 100644 index 0000000..d4ebd00 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java @@ -0,0 +1,5 @@ +package dev._2lstudios.exploitfixer.shared.interfaces; + +public interface IMessagesModule { + String getString(final String locale, final String path); +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java new file mode 100644 index 0000000..51cf327 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java @@ -0,0 +1,7 @@ +package dev._2lstudios.exploitfixer.shared.interfaces; + +public interface IModule { + public boolean isEnabled(); + + public String getName(); +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java index 649ec93..d6d1b74 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java @@ -2,6 +2,6 @@ import java.util.Collection; -public interface PunishmentModule extends Module { +public interface PunishmentModule extends IModule { public Collection getPunishments(); } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java index 931f481..e176e59 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java @@ -1,6 +1,6 @@ package dev._2lstudios.exploitfixer.shared.interfaces; -public interface ViolationModule extends Module { +public interface ViolationModule extends IModule { public double getCancelVls(); public double getReduceVls(); diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java new file mode 100644 index 0000000..97ceeca --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -0,0 +1,52 @@ +package dev._2lstudios.exploitfixer.shared.modules; + +import dev._2lstudios.exploitfixer.shared.interfaces.IMessagesModule; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; + +public class MessagesModule implements IMessagesModule { + @Override + public String getString(final String locale, final String path) { + // This is override by BukkitMessagesModule/BungeeMessagesModule + return null; + } + + public final String getReload(final String locale) { + return getString(locale, ".commands.reload"); + } + + public final String getHelp(final String locale) { + return getString(locale, ".commands.help"); + } + + public final String getUnknown(final String locale) { + return getString(locale, ".commands.error.unknown"); + } + + public final String getPermission(final String locale) { + return getString(locale, ".commands.error.permission"); + } + + public final String getConsole(final String locale) { + return getString(locale, ".commands.error.console"); + } + + public final String getEnable(final String locale) { + return getString(locale, ".commands.notifications.enable"); + } + + public final String getDisable(final String locale) { + return getString(locale, ".commands.notifications.disable"); + } + + public final String getKickMessage(final IModule module, final String locale) { + return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); + } + + public final String getKickMessage(final String module, final String locale) { + return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); + } + + public String getStats(final String locale) { + return getString(locale, ".commands.stats"); + } +} \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index d249644..4cc57ab 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.3 +version: 1.4.4 author: 2LS api: "1.13" api-version: "1.13" From 19f0804ee5897b8f124bc5c58ed0eb36195fd682 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Fri, 31 Jul 2020 12:20:44 -0300 Subject: [PATCH 074/336] Updated Source --- .../ExploitFixerPostProcessListener.java | 367 ------------------ .../ExploitFixerPreProcessListener.java | 75 ---- .../HamsterAPIListenerInitializer.java | 49 --- .../bukkit/modules/BukkitMessagesModule.java | 9 - .../bukkit/modules/MessagesModule.java | 86 ---- .../bungee/modules/BungeeMessagesModule.java | 8 - .../bungee/modules/MessagesModule.java | 84 ---- .../shared/interfaces/Module.java | 7 - .../shared/modules/MessagesModule.java | 8 + 9 files changed, 8 insertions(+), 685 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java deleted file mode 100644 index 4d73eba..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPostProcessListener.java +++ /dev/null @@ -1,367 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; - -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; -import java.util.logging.Logger; - -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; -import dev._2lstudios.hamsterapi.enums.PacketType; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.interfaces.PostProcessListener; -import dev._2lstudios.hamsterapi.wrappers.EventWrapper; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; - -public class ExploitFixerPostProcessListener implements PostProcessListener { - private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; - private final ExploitPlayerManager exploitPlayerManager; - private final ItemsFixModule itemsFixModule; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; - - ExploitFixerPostProcessListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.itemsFixModule = moduleManager.getItemsFixModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketReceive(final EventWrapper event) { - if (!event.isCancelled()) { - final Logger logger = plugin.getLogger(); - final Player player = event.getPlayer(); - final PacketWrapper packetWrapper = event.getPacket(); - final PacketType packetType = packetWrapper.getType(); - - if (packetType != PacketType.PacketPlayInKeepAlive) { - final Map strings = packetWrapper.getStrings(); - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String playerName = player.getName(), packetName = packetWrapper.getName(); - final double dataVls = packetsModule.getDataVls(); - final int dataBytes = packetsModule.getDataBytes(); - - if (packetsModule.isEnabled()) { - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(), - setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(), - bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " has a slot less than 0 (" + slot + ")"); - } - - event.setCancelled(true); - return; - } else if (slot >= maxSlots) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " exceeded max available slots (" + slot + "/" + maxSlots - + ") on " + packetName + "! Added vls: " + windowClick); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); - return; - } - } - - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { - if (player.getGameMode() != GameMode.CREATIVE) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " - + setCreativeSlot); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); - return; - } - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += getItemLength((ItemStack) object, exploitPlayer, hamsterPlayer); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; - } - } - } - - if (dataBytes > 0 && packetSize > dataBytes) { - if (notificationsModule.isDebug()) { - logger.info("[" + packetName + "] Sent by " + playerName + " got blocked because its " - + packetSize + " bytes long!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && checkSign(strings.values().toArray(new String[0]))) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " has sent a too big sign packet! Added vls: " + dataVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } - } - - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); - } - - if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = customPayloadModule.getTagVls(), - bookVls = customPayloadModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, tagVls); - return; - } else { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - if (notificationsModule.isDebug()) { - logger.info(playerName + " tried to send a " + tag - + " custompayload packet without a book in hand!"); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, bookVls); - return; - } /* - * else if (byteLength > customPayloadModule.getBookBytes()) { - * logger.info(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ - } - - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, - customPayloadModule.getMultiplier(tag)); - } - } else { - if (notificationsModule.isDebug()) { - logger.info(playerName + " sent a empty CustomPayload packet!"); - } - - event.setCancelled(true); - } - } - } - - final Map items = packetWrapper.getItems(); - - if (itemsFixModule.isEnabled() && items.containsKey("b")) { - final ItemStack itemStack = items.get("b"); - - if (itemStack != null) { - final String materialName = itemStack.getType().toString(); - String blocked = null; - - for (final String blockedMaterial : itemsFixModule.getBlacklist()) { - if (materialName.equals(blockedMaterial)) { - itemStack.setType(Material.AIR); - itemStack.setItemMeta(null); - blocked = materialName; - break; - } - } - - final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); - - packetWrapper.write("b", fixedItemStack); - - if (notificationsModule.isDebug()) { - if (player != null) { - if (blocked != null) { - logger.info(player.getName() + " had a creative item blocked by ExploiFixer! (" - + blocked + ")"); - } else { - logger.info(player.getName() + " had a creative item fixed by ExploiFixer!"); - } - } - } - } - } - } - } - - @Override - public void onPacketSend(final EventWrapper event) { - } - - private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, - final HamsterPlayer hamsterPlayer) { - final Logger logger = plugin.getLogger(); - int itemBytesLength = 0; - - if (itemStack != null) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - - try { - itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final Exception exception) { - if (notificationsModule.isDebug()) { - logger.info("There was an exception when processing itemStack data to String!"); - } - } - - if (itemStack.hasItemMeta() && itemMeta != null) { - try { - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += getItemLength(itemStack1, exploitPlayer, hamsterPlayer); - } - } - } - } else { - throw new Exception(); - } - } catch (final Exception exception) { - if (itemMeta instanceof BookMeta) { - itemBytesLength += getBookLength(exploitPlayer, hamsterPlayer, itemMeta); - } else { - try { - itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { - itemBytesLength += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; - } - } - } - } - } - - return itemBytesLength; - } - - private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, - final ItemMeta itemMeta) { - final Player player = hamsterPlayer.getPlayer(); - final Logger logger = plugin.getLogger(); - final BookMeta bookMeta = (BookMeta) itemMeta; - final double dataVls = packetsModule.getDataVls(); - final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); - int bookTotalBytes = 0; - - if (pageCount > 50) { - if (notificationsModule.isDebug()) { - logger.info(player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" - + 50 + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); - } else { - for (final String page : bookMeta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; - - bookTotalBytes += pageBytes; - - if (pageBytes > dataBytesBook) { - if (notificationsModule.isDebug()) { - logger.info( - player.getName() + " has sent a packet with a book with too many characters per page! (" - + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); - } - - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); - break; - } - } - - return bookTotalBytes; - } - - return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } - - private boolean checkSign(final String[] linesString) { - final int dataBytesSign = packetsModule.getDataBytesSign(); - - if (linesString != null) { - if (linesString.length > 4) { - return true; - } else { - for (final String line : linesString) { - if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { - return true; - } - } - } - } - - return false; - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java deleted file mode 100644 index 08530f1..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/ExploitFixerPreProcessListener.java +++ /dev/null @@ -1,75 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; - -import java.util.logging.Logger; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.interfaces.PreProcessListener; -import dev._2lstudios.hamsterapi.wrappers.EventWrapper; -import io.netty.buffer.ByteBuf; - -public class ExploitFixerPreProcessListener implements PreProcessListener { - private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; - - ExploitFixerPreProcessListener(final Plugin plugin, final ModuleManager moduleManager) { - HamsterAPI.getInstance().getBufferIO(); - this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @Override - public void onPacketDecode(final EventWrapper event) { - if (!event.isCancelled()) { - final Logger logger = plugin.getLogger(); - final Player player = event.getPlayer(); - - if (player != null && player.isOnline()) { - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final int dataBytes = packetsModule.getDataBytes(); - final double dataVls = packetsModule.getDataVls(); - final String playerName = player.getName(); - final ByteBuf byteBuf = event.getByteBuf().copy(); - - if (byteBuf.capacity() > dataBytes) { - if (notificationsModule.isDebug()) { - logger.info("[Decoder] " + playerName + " sent a packet that exceeds size limit! Max: " - + dataBytes + " Vls: " + dataVls); - } - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, dataVls); - - return; - } - } else if (packetsModule.isOffline()) { - if (notificationsModule.isDebug()) { - if (player == null) { - logger.info("OFFLINEPLAYER sent a packet while offline!"); - } else { - logger.info(player.getName() + " sent a packet while offline!"); - } - } - - event.setCancelled(true); - event.close(); - } - } - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java deleted file mode 100644 index 1db0277..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/hamsterapi/HamsterAPIListenerInitializer.java +++ /dev/null @@ -1,49 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listener.hamsterapi; - -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.handlers.PostProcessEventHandler; -import dev._2lstudios.hamsterapi.handlers.PreProcessEventHandler; - -public class HamsterAPIListenerInitializer { - private final HamsterAPI hamsterAPI; - private final Plugin plugin; - private final ModuleManager moduleManager; - private ExploitFixerPreProcessListener exploitFixerPreProcessListener; - private ExploitFixerPostProcessListener exploitFixerPostProcessListener; - private boolean registered = false; - - public HamsterAPIListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { - this.hamsterAPI = HamsterAPI.getInstance(); - this.plugin = plugin; - this.moduleManager = moduleManager; - } - - public void register() { - this.registered = true; - - final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); - final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); - - preProcessEventHandler.addListener( - this.exploitFixerPreProcessListener = new ExploitFixerPreProcessListener(plugin, moduleManager), 0); - postProcessEventHandler.addListener( - this.exploitFixerPostProcessListener = new ExploitFixerPostProcessListener(plugin, moduleManager), 0); - } - - public void unregister() { - this.registered = false; - - final PreProcessEventHandler preProcessEventHandler = hamsterAPI.getPreProcessEventHandler(); - final PostProcessEventHandler postProcessEventHandler = hamsterAPI.getPostProcessEventHandler(); - - preProcessEventHandler.removeListener(exploitFixerPreProcessListener); - postProcessEventHandler.removeListener(exploitFixerPostProcessListener); - } - - public boolean isRegistered() { - return this.registered; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 04ce403..3fd140c 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -3,7 +3,6 @@ import org.bukkit.ChatColor; import org.bukkit.configuration.Configuration; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; public class BukkitMessagesModule extends MessagesModule { @@ -16,14 +15,6 @@ public BukkitMessagesModule(final String version, final Configuration messagesYm this.version = version; } - public boolean isEnabled() { - return true; - } - - public String getName() { - return "Messages"; - } - public void reload(final Configuration messagesYml) { this.messagesYml = messagesYml; this.discord = messagesYml.getString("discord", ""); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java deleted file mode 100644 index 5fac35d..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/MessagesModule.java +++ /dev/null @@ -1,86 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import org.bukkit.ChatColor; -import org.bukkit.configuration.Configuration; - -import dev._2lstudios.exploitfixer.shared.interfaces.Module; - -public class MessagesModule implements Module { - private final String version; - private Configuration messagesYml; - private String discord; - - public MessagesModule(final String version, final Configuration messagesYml) { - reload(messagesYml); - this.version = version; - } - - public boolean isEnabled() { - return true; - } - - public String getName() { - return "Messages"; - } - - public void reload(final Configuration messagesYml) { - this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord", ""); - } - - private String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); - } - - if (string != null && !string.isEmpty()) { - string = ChatColor.translateAlternateColorCodes('&', string); - } else { - string = ""; - } - - return string.replace("%version%", version).replace("%discord%", discord); - } - - public final String getReload(final String locale) { - return getString(locale, ".commands.reload"); - } - - public final String getHelp(final String locale) { - return getString(locale, ".commands.help"); - } - - public final String getUnknown(final String locale) { - return getString(locale, ".commands.error.unknown"); - } - - public final String getPermission(final String locale) { - return getString(locale, ".commands.error.permission"); - } - - public final String getConsole(final String locale) { - return getString(locale, ".commands.error.console"); - } - - public final String getEnable(final String locale) { - return getString(locale, ".commands.notifications.enable"); - } - - public final String getDisable(final String locale) { - return getString(locale, ".commands.notifications.disable"); - } - - public final String getKickMessage(final Module module, final String locale) { - return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); - } - - public final String getKickMessage(final String module, final String locale) { - return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); - } - - public String getStats(final String locale) { - return getString(locale, ".modules.stats.message"); - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java index 43a8949..32f5f16 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -14,14 +14,6 @@ public BungeeMessagesModule(final String version, final Configuration messagesYm this.version = version; } - public boolean isEnabled() { - return true; - } - - public String getName() { - return "Messages"; - } - public void reload(final Configuration messagesYml) { this.messagesYml = messagesYml; this.discord = messagesYml.getString("discord", ""); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java deleted file mode 100644 index e35b674..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/MessagesModule.java +++ /dev/null @@ -1,84 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.config.Configuration; - -import dev._2lstudios.exploitfixer.shared.interfaces.Module; - -public class MessagesModule implements Module { - private Configuration messagesYml; - private final String version; - - public MessagesModule(final String version, final Configuration messagesYml) { - reload(messagesYml); - this.version = version; - } - - public boolean isEnabled() { - return true; - } - - public String getName() { - return "Messages"; - } - - public void reload(final Configuration messagesYml) { - this.messagesYml = messagesYml; - } - - private String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); - } - - if (string != null && !string.isEmpty()) { - string = ChatColor.translateAlternateColorCodes('&', string); - } else { - string = ""; - } - - return string; - } - - public final String getReload(final String locale) { - return getString(locale, ".commands.reload"); - } - - public final String getHelp(final String locale) { - return getString(locale, ".commands.help").replace("%version%", version); - } - - public final String getUnknown(final String locale) { - return getString(locale, ".commands.error.unknown"); - } - - public final String getPermission(final String locale) { - return getString(locale, ".commands.error.permission"); - } - - public final String getConsole(final String locale) { - return getString(locale, ".commands.error.console"); - } - - public final String getEnable(final String locale) { - return getString(locale, ".commands.notifications.enable"); - } - - public final String getDisable(final String locale) { - return getString(locale, ".commands.notifications.disable"); - } - - public final String getKickMessage(final Module module, final String locale) { - return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); - } - - public final String getKickMessage(final String module, final String locale) { - return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); - } - - public String getStats(final String locale) { - return getString(locale, ".modules.stats.message"); - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java deleted file mode 100644 index eea6423..0000000 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/Module.java +++ /dev/null @@ -1,7 +0,0 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; - -public interface Module { - public boolean isEnabled(); - - public String getName(); -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 97ceeca..de1fa18 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -10,6 +10,14 @@ public String getString(final String locale, final String path) { return null; } + public boolean isEnabled() { + return true; + } + + public String getName() { + return "Messages"; + } + public final String getReload(final String locale) { return getString(locale, ".commands.reload"); } From aed80d0b4ba71a48aff076988101ae02991d05d5 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Sat, 1 Aug 2020 09:12:54 -0300 Subject: [PATCH 075/336] Updated Source --- src/bungee.yml | 2 +- .../exploitfixer/bukkit/modules/ItemsFixModule.java | 6 ------ src/plugin.yml | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/bungee.yml b/src/bungee.yml index 194443d..ae23049 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.4 +version: 1.4.5 author: 2LS commands: exploitfixer: diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 411909d..d1361cf 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -13,7 +13,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.inventory.meta.SpawnEggMeta; import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.shared.interfaces.IModule; @@ -107,11 +106,6 @@ public ItemStack fixItem(final ItemStack itemStack) { final BannerMeta newBannerMeta = (BannerMeta) newItemMeta; newBannerMeta.setBaseColor(oldBannerMeta.getBaseColor()); - } else if (newItemMeta instanceof SpawnEggMeta) { - final SpawnEggMeta oldSpawnEggMeta = (SpawnEggMeta) oldItemMeta; - final SpawnEggMeta newSpawnEggMeta = (SpawnEggMeta) newItemMeta; - - newSpawnEggMeta.setSpawnedType(oldSpawnEggMeta.getSpawnedType()); } else if (newItemMeta instanceof LeatherArmorMeta) { final LeatherArmorMeta oldLeatherArmorMeta = (LeatherArmorMeta) oldItemMeta; final LeatherArmorMeta newLeatherArmorMeta = (LeatherArmorMeta) newItemMeta; diff --git a/src/plugin.yml b/src/plugin.yml index 4cc57ab..255d565 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.4 +version: 1.4.5 author: 2LS api: "1.13" api-version: "1.13" From 07bec4bdf867a746b05509d3fe580ad2997f0a9b Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Mon, 3 Aug 2020 06:21:58 -0300 Subject: [PATCH 076/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 84 ++---- .../exploitfixer/bukkit/ExploitFixer.java | 46 +-- .../bukkit/commands/ExploitFixerCommand.java | 12 +- .../configuration/BukkitConfiguration.java | 65 +++++ .../BukkitExploitPlayer.java} | 120 ++------ .../bukkit/instanceables/Violations.java | 29 -- .../bukkit/listener/PacketDecodeListener.java | 15 +- .../listener/PacketReceiveListener.java | 270 +++++++++--------- .../listener/PlayerCommandListener.java | 6 +- .../bukkit/listener/PlayerLoginListener.java | 26 +- .../bukkit/listener/PlayerQuitListener.java | 11 +- .../bukkit/managers/ExploitPlayerManager.java | 18 +- .../bukkit/managers/ModuleManager.java | 45 ++- .../bukkit/modules/BukkitMessagesModule.java | 13 +- .../modules/BukkitNotificationsModule.java | 51 ++++ .../bukkit/modules/CommandsModule.java | 45 --- .../bukkit/modules/ConnectionModule.java | 50 ---- .../bukkit/modules/CustomPayloadModule.java | 103 ------- .../bukkit/modules/ItemsFixModule.java | 9 +- .../bukkit/modules/NotificationsModule.java | 88 ------ .../bukkit/modules/PacketsModule.java | 118 -------- .../bukkit/utils/ConfigurationUtil.java | 5 +- .../exploitfixer/bungee/ExploitFixer.java | 51 ++-- .../bungee/commands/ExploitFixerCommand.java | 22 +- .../configuration/BungeeConfiguration.java | 64 +++++ .../bungee/exploit/BungeeExploitPlayer.java | 109 +++++++ .../bungee/instanceables/ExploitPlayer.java | 173 ----------- .../bungee/listeners/ChatListener.java | 6 +- .../bungee/listeners/DisconnectListener.java | 15 +- .../bungee/listeners/ListenerInitializer.java | 2 +- .../listeners/PluginMessageListener.java | 54 ++-- .../bungee/listeners/PostLoginListener.java | 41 ++- .../bungee/managers/ExploitPlayerManager.java | 15 +- .../bungee/managers/ModuleManager.java | 43 +-- .../bungee/modules/BungeeMessagesModule.java | 13 +- .../modules/BungeeNotificationsModule.java | 39 +++ .../bungee/modules/CommandsModule.java | 41 --- .../bungee/modules/CustomPayloadModule.java | 100 ------- .../bungee/modules/NotificationsModule.java | 79 ----- .../shared/configuration/IConfiguration.java | 23 ++ .../shared/exploit/ExploitPlayer.java | 109 +++++++ .../exploit}/Violations.java | 9 +- .../interfaces/INotificationsModule.java | 5 + ...mentModule.java => IPunishmentModule.java} | 2 +- ...ationModule.java => IViolationModule.java} | 2 +- .../shared/modules/CommandsModule.java | 38 +++ .../modules/ConnectionModule.java | 20 +- .../shared/modules/MessagesModule.java | 2 +- .../shared/modules/NotificationsModule.java | 67 +++++ .../shared/modules/PacketsModule.java | 120 ++++++++ src/messages.yml | 26 +- src/plugin.yml | 2 +- 53 files changed, 1120 insertions(+), 1403 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java rename src/dev/_2lstudios/exploitfixer/bukkit/{instanceables/ExploitPlayer.java => exploit/BukkitExploitPlayer.java} (54%) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java rename src/dev/_2lstudios/exploitfixer/{bungee/instanceables => shared/exploit}/Violations.java (71%) create mode 100644 src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java rename src/dev/_2lstudios/exploitfixer/shared/interfaces/{PunishmentModule.java => IPunishmentModule.java} (71%) rename src/dev/_2lstudios/exploitfixer/shared/interfaces/{ViolationModule.java => IViolationModule.java} (75%) create mode 100644 src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java rename src/dev/_2lstudios/exploitfixer/{bungee => shared}/modules/ConnectionModule.java (59%) create mode 100644 src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java diff --git a/src/bungee.yml b/src/bungee.yml index ae23049..77503a2 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.5 +version: 1.4.6 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 43c9307..516eb42 100644 --- a/src/config.yml +++ b/src/config.yml @@ -2,16 +2,15 @@ # Please help by donating, we require funds to continue with the development. # https://paypal.me/LinsaFTW # -# WARNING: Only Notifications, Connection, CustomPayload and Commands modules work on BungeeCord. +# WARNING: Only Notifications, Connection, Commands and Packets (CustomPayload only) modules work on BungeeCord. # # This is because the other modules can't be executed on BungeeCord. -# The other modules require ExploitFixer to be installed on Spigot with HamsterAPI. (No performance impact) +# The other modules require ExploitFixer to be installed on Bukkit with HamsterAPI. (No performance impact) # -# INSTALL THE PLUGIN ON BUNGEECORD AND ALL SPIGOT SERVERS! +# INSTALL THE PLUGIN ON BUNGEECORD AND ALL BUKKIT SERVERS! # # Most of the check use Violations (vls), this a counter to execute different # actions on diverse levels to allow high customization of the modules. -# # Shows notifications to console and players with permissions. notifications: @@ -38,63 +37,8 @@ connection: # Commands to run when a player is detected. punishments: [] -# Prevents the use of CustomPayload packets to exploit the server. -custompayload: - enabled: true - - # Amount of violations required to cancel. - cancel_vls: 40 - - # Amount of violations to reduce per second. - reduce_vls: 40 - - # Limits the amount of channels a player can register. - channel: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 100 - - # Maximum amounts of channels allowed per player. - amount: 512 - - # Limits the amount of bytes a custompayload packet can handle. - data: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 100 - - # Maximum amount of bytes per packet. - bytes: 16000 - - # Checks CustomPayload books for invalid data. - book: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 100 - - # Maximum amount of bytes per page. - bytes: 300 - - # Checks if a tag of a CustomPayload packet is invalid. - tag: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 100 - - # When a valid packet is sent the following amount of vls will be applied. - multipliers: - OTHER: 0.001 - SETTINGS: 0.05 - MC|BSign: 10 - MC|BEdit: 10 - MC|BOpen: 10 - - # Commands to run when a player reachs certain violation level. - violations: - 50: - - "notification" - 100: - - "notification" - - "kick" - -# Prevents the use of packets to exploit the server. -# This prevents almost every exploit available for Bukkit. +# Prevents the use of invalid packets to exploit your server. +# This is the most advanced category in the plugin and it's not recommended to disable it. packets: enabled: true @@ -104,11 +48,10 @@ packets: # Amount of vls to reduce per second. reduce_vls: 60 - # Cancells packets if the player sending them is offline. + # Cancels packets if the player sending them is offline. offline: true - # Never disable this and instead increase max_bytes if you have false positives. - # This will check if integers, floats, doubles and packets have a invalid size. + # This will check if integers, floats, doubles and items have a invalid size in packets. data: # Vls to add when a packet fails the check. (Set to -1 to disable) vls: 600 @@ -126,6 +69,14 @@ packets: # This is made so big packets add more vls when received. bytes_divider: 1000 + # Cancels book packets when a book is not in hand + # Vls to add when a packet fails the check. (Set to -1 to disable) + book: 100 + + # Cancels CustomPayload packets with invalid tags + # Vls to add when a packet fails the check. (Set to -1 to disable) + tag: 600 + # Checks if players send PacketPlayInWindowClick packets with invalid data. # Vls to add when a packet fails the check. (Set to -1 to disable) window_click: 300 @@ -147,12 +98,15 @@ packets: # Unlisted packets are considered as "PacketPlayInOther" by default. # Remember to take a look at bytes_divider option. multipliers: + MC|BSign: 30 + MC|BEdit: 30 + MC|BOpen: 30 PacketPlayInOther: 0.1 PacketPlayInAbilities: 0.1 PacketPlayInArmAnimation: 0.3 PacketPlayInBlockDig: 0.3 PacketPlayInBlockPlace: 0.4 - PacketPlayInCustomPayload: 0.01 + PacketPlayInCustomPayload: 0.04 PacketPlayInEntityAction: 0.4 PacketPlayInFlying: 0.05 PacketPlayInLook: 0.1 diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index fa3ee23..da4c91f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -3,17 +3,18 @@ import java.util.logging.Logger; import org.bukkit.Server; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.bukkit.configuration.BukkitConfiguration; import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.utils.ConfigurationUtil; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; public class ExploitFixer extends JavaPlugin { private static ExploitFixer exploitFixer; @@ -26,18 +27,26 @@ public void onEnable() { final Server server = this.getServer(); final BukkitScheduler scheduler = server.getScheduler(); - this.configurationUtil = new ConfigurationUtil(this); + if (!checkHamsterAPI()) { + throw new NullPointerException( + "ExploitFixer requires HamsterAPI to listen to packets and block exploits! Download: https://www.spigotmc.org/resources/78831/"); + } + + configurationUtil = new ConfigurationUtil(this); createConfigurations(); - final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final IConfiguration configYml = new BukkitConfiguration( + configurationUtil.getConfiguration("%datafolder%/config.yml")); + final IConfiguration messagesYml = new BukkitConfiguration( + configurationUtil.getConfiguration("%datafolder%/messages.yml")); VersionUtil.initialize(server); exploitFixer = this; - this.moduleManager = new ModuleManager(this, configYml, messagesYml); - this.listenerInitializer = new ListenerInitializer(this, moduleManager); + moduleManager = new ModuleManager(this); + moduleManager.reload(configYml, messagesYml); + listenerInitializer = new ListenerInitializer(this, moduleManager); register(); @@ -45,7 +54,7 @@ public void onEnable() { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); exploitPlayerManager.clear(); - }, 9000L, 9000L); + }, 6000L, 6000L); } @Override @@ -62,24 +71,19 @@ public void reload() { final Server server = getServer(); final BukkitScheduler scheduler = server.getScheduler(); - if (checkHamsterAPI()) { - scheduler.cancelTasks(this); - server.getMessenger().unregisterIncomingPluginChannel(this); + scheduler.cancelTasks(this); + server.getMessenger().unregisterIncomingPluginChannel(this); - createConfigurations(); + createConfigurations(); - final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); - final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); - final YamlConfiguration spigotYml = this.configurationUtil.getConfiguration("%datafolder%/../spigot.yml"); + final IConfiguration configYml = new BukkitConfiguration( + this.configurationUtil.getConfiguration("%datafolder%/config.yml")); + final IConfiguration messagesYml = new BukkitConfiguration( + this.configurationUtil.getConfiguration("%datafolder%/messages.yml")); - moduleManager.reload(configYml, messagesYml, spigotYml); + moduleManager.reload(configYml, messagesYml); - register(); - } else { - scheduler.runTaskTimer(this, () -> this.getLogger().severe( - "ExploitFixer requires HamsterAPI to work! Download: https://www.spigotmc.org/resources/78831/"), - 20L, 20L); - } + register(); } private boolean checkHamsterAPI() { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 2e3a723..227ac14 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -9,12 +9,12 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; public class ExploitFixerCommand implements CommandExecutor { private BukkitMessagesModule messagesModule; - private NotificationsModule notificationsModule; + private BukkitNotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; public ExploitFixerCommand(final ModuleManager moduleManager) { @@ -54,13 +54,13 @@ else if (args[0].equalsIgnoreCase("notifications")) { if (commandSender instanceof Player) { if (commandSender.hasPermission("exploitfixer.admin") || commandSender.hasPermission("exploitfixer.notifications")) { - final Player player = (Player) commandSender; + final String playerName = commandSender.getName(); - if (!notificationsModule.isNotifications(player)) { - notificationsModule.setNotifications(player, true); + if (!notificationsModule.isNotifications(playerName)) { + notificationsModule.setNotifications(playerName, true); commandSender.sendMessage(messagesModule.getEnable(lang)); } else { - notificationsModule.setNotifications(player, false); + notificationsModule.setNotifications(playerName, false); commandSender.sendMessage(messagesModule.getDisable(lang)); } } else { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java new file mode 100644 index 0000000..01db4ba --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java @@ -0,0 +1,65 @@ +package dev._2lstudios.exploitfixer.bukkit.configuration; + +import java.util.Collection; +import java.util.HashSet; + +import org.bukkit.configuration.ConfigurationSection; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; + +public class BukkitConfiguration implements IConfiguration { + private final ConfigurationSection configuration; + + public BukkitConfiguration(final ConfigurationSection configuration) { + this.configuration = configuration; + } + + @Override + public IConfiguration getSection(final String path) { + return new BukkitConfiguration(configuration.getConfigurationSection(path)); + } + + @Override + public Collection getKeys() { + return configuration.getKeys(false); + } + + @Override + public Collection getStringList(final String path, final Collection def) { + if (configuration.contains(path)) { + return new HashSet<>(configuration.getStringList(path)); + } else { + return def; + } + } + + @Override + public String getString(final String path, final String def) { + return configuration.getString(path, def); + } + + @Override + public double getDouble(final String path, final double def) { + return configuration.getDouble(path, def); + } + + @Override + public long getLong(final String path, final long def) { + return configuration.getLong(path, def); + } + + @Override + public int getInt(final String path, final int def) { + return configuration.getInt(path, def); + } + + @Override + public boolean getBoolean(final String path, final boolean def) { + return configuration.getBoolean(path, def); + } + + @Override + public Object getObject() { + return configuration; + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java similarity index 54% rename from src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java rename to src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java index 6d6111d..10c96db 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java @@ -1,11 +1,6 @@ -package dev._2lstudios.exploitfixer.bukkit.instanceables; +package dev._2lstudios.exploitfixer.bukkit.exploit; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -18,110 +13,62 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.shared.exploit.Violations; import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; +import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; -public class ExploitPlayer { +public class BukkitExploitPlayer extends ExploitPlayer { private final Plugin plugin; private final ExploitPlayerManager exploitPlayerManager; - private final BukkitMessagesModule messagesModule; + private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; - private final Map violations; - private final Collection> punishments; - private final String name; - private String onlineUUID; - private double lastViolation; - private int channels; - private boolean logged; - - public ExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { + + public BukkitExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { + super(name); this.plugin = plugin; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); - this.violations = new HashMap<>(); - this.punishments = new HashSet<>(); - this.name = name; - this.onlineUUID = null; - this.lastViolation = 0; - this.channels = 0; - this.logged = false; - } - - public int getChannels() { - return channels; - } - - public int addChannels(final int channels) { - return this.channels += channels; - } - - public double getViolations(final ViolationModule module) { - return this.violations.getOrDefault(module, 0D); - } - - public String getOnlineUUID() { - if (onlineUUID == null) { - try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) - .openConnection(); - - connection.setDoOutput(true); - connection.connect(); - - final BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(connection.getInputStream())); - final StringBuilder response = new StringBuilder(); - - String inputLine; - - while ((inputLine = bufferedReader.readLine()) != null) - response.append(inputLine).append("\n"); - - bufferedReader.close(); - onlineUUID = response.toString(); - } catch (final Exception ignored) { - } - } - - return onlineUUID; } public void addVls(final Plugin plugin, final Cancellable event, final HamsterPlayer hamsterPlayer, - final ViolationModule module, final double amount) { + final IViolationModule module, final double amount) { addVls(plugin, event, null, hamsterPlayer, module, amount); } public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, - final HamsterPlayer hamsterPlayer, final ViolationModule module, final double amount) { + final HamsterPlayer hamsterPlayer, final IViolationModule module, final double amount) { final Violations violations = (Violations) module.getViolations(); if (violations != null) { - final double currentTime = System.currentTimeMillis(); + final Map violationsMap = getViolations(); + final long currentTime = System.currentTimeMillis(); + final long lastViolation = getLastViolation(); if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; + setLastViolation(currentTime); - for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); + for (final IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { + final double vls = violationsMap.get(violationModule) - violationModule.getReduceVls(); if (vls <= 0) { - this.violations.remove(violationModule); + violationsMap.remove(violationModule); } else { - this.violations.put(violationModule, vls); + violationsMap.put(violationModule, vls); } } } final double newVls = getViolations(module) + amount; - this.violations.put(module, newVls); + violationsMap.put(module, newVls); if (event instanceof Cancellable && module.getCancelVls() <= newVls) { ((Cancellable) event).setCancelled(true); @@ -139,7 +86,9 @@ public void addVls(final Plugin plugin, final Cancellable event, final PacketWra public void punish(final IModule module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, final Collection punishments, final int newVls) { - if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { + final Collection> punishmentsDone = getPunishmentsDone(); + + if (!punishments.isEmpty() && !punishmentsDone.contains(punishments)) { final Server server = plugin.getServer(); final CommandSender consoleSender = server.getConsoleSender(); final BukkitScheduler scheduler = server.getScheduler(); @@ -178,23 +127,8 @@ public void punish(final IModule module, final HamsterPlayer hamsterPlayer, fina } } - this.punishments.add(punishments); - this.exploitPlayerManager.addPunishment(); + punishmentsDone.add(punishments); + exploitPlayerManager.addPunishment(); } } - - public void clear() { - this.violations.clear(); - this.punishments.clear(); - this.lastViolation = 0; - this.channels = 0; - } - - public void setLogged(final boolean logged) { - this.logged = logged; - } - - public boolean isLogged() { - return logged; - } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java b/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java deleted file mode 100644 index e1239c5..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/instanceables/Violations.java +++ /dev/null @@ -1,29 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.instanceables; - -import org.bukkit.configuration.ConfigurationSection; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class Violations { - private Map> violations = new HashMap<>(); - - public Violations(final ConfigurationSection configuration) { - if (configuration != null) - for (final String key : configuration.getKeys(false)) { - try { - this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (final NumberFormatException ignored) { - } - } - } - - public Collection getCommands(final int violations) { - return this.violations.getOrDefault(violations, null); - } - - public Collection getViolations() { - return violations.keySet(); - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 2eaba56..8a02c40 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -6,12 +6,11 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; @@ -19,15 +18,13 @@ public class PacketDecodeListener implements Listener { private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; + private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; PacketDecodeListener(final Plugin plugin, final ModuleManager moduleManager) { HamsterAPI.getInstance().getBufferIO(); this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); @@ -73,11 +70,11 @@ public void onPacketReceive(final PacketDecodeEvent event) { private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final String reason, final double vls) { final Player player = hamsterPlayer.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); notificationsModule.debug(reason); event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, vls); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 5b375a4..553ca54 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -22,13 +22,12 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; @@ -36,15 +35,13 @@ public class PacketReceiveListener implements Listener { private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; private final ExploitPlayerManager exploitPlayerManager; private final ItemsFixModule itemsFixModule; - private final NotificationsModule notificationsModule; + private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; PacketReceiveListener(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); @@ -58,149 +55,139 @@ public void onPacketReceive(final PacketReceiveEvent event) { final PacketWrapper packetWrapper = event.getPacket(); final PacketType packetType = packetWrapper.getType(); - if (packetType != PacketType.PacketPlayInKeepAlive) { + if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { final Map strings = packetWrapper.getStrings(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); final String playerName = player.getName(), packetName = packetWrapper.getName(); final double dataVls = packetsModule.getDataVls(); - final int dataBytes = packetsModule.getDataBytes(); - - if (packetsModule.isEnabled()) { - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(), - setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(), - bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999 && slot != -1) { - notificationsModule.debug("[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick); + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(), + setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); - return; - } else if (slot >= maxSlots) { - notificationsModule.debug( - "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" - + slot + "/" + maxSlots + ") Added vls: " + windowClick); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); - return; - } - } + if (packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = packetsModule.getTagVls(), bookVls = packetsModule.getBookVls(); - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { - if (player.getGameMode() != GameMode.CREATIVE) { - notificationsModule.debug("[" + packetName + "|SetCreativeSlot] " + playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); + if (tagVls > 0 && tag == null || tag.isEmpty()) { + notificationsModule.debug("[" + packetName + "|Tag] " + playerName + + " sent a CustomPayload packet without TAG! Added vls: " + tagVls); event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, tagVls); return; - } - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); + } else if (bookVls > 0) { + if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + notificationsModule.debug("[" + packetName + "|Book] " + playerName + + " tried to send a " + tag + " CustomPayload packet without a book in hand!"); - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += getItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, - packetName, dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, bookVls); + return; } } } - if (dataBytes > 0 && packetSize > dataBytes) { - notificationsModule.debug("[" + packetName + "|Data] " + playerName + " sent a packet of " - + packetSize + " bytes long!"); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); + } else { + notificationsModule + .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } + event.setCancelled(true); + } + } - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && checkSign(strings.values().toArray(new String[0]))) { - notificationsModule.debug("[" + packetName + "|Data] " + playerName - + " has sent a too big sign packet! Added vls: " + dataVls); + if (windowClick > 0 && integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(), + bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); } - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + if (slot < 0 && slot != -999 && slot != -1) { + notificationsModule.debug("[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick); + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); + return; + } else if (slot >= maxSlots) { + notificationsModule + .debug("[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + + slot + "/" + maxSlots + ") Added vls: " + windowClick); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); + return; + } } - if (customPayloadModule.isEnabled() && packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = customPayloadModule.getTagVls(), bookVls = customPayloadModule.getBookVls(); + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { + if (player.getGameMode() != GameMode.CREATIVE) { + notificationsModule.debug("[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); - if (tagVls > 0 && tag == null || tag.isEmpty()) { - notificationsModule.debug("[" + packetName + "|Tag] " + playerName - + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); + return; + } + } - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, tagVls); - return; - } else { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + int packetSize = 0; - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - notificationsModule.debug("[" + packetName + "|Book] " + playerName - + " tried to send a " + tag + " custompayload packet without a book in hand!"); + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + final int dataBytes = packetsModule.getDataBytes(); - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, bookVls); - return; - } /* - * else if (byteLength > customPayloadModule.getBookBytes()) { - * notificationsModule.debug(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ - } + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); - exploitPlayer.addVls(plugin, event, hamsterPlayer, customPayloadModule, - customPayloadModule.getMultiplier(tag)); + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, packetName, + dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } } - } else { - notificationsModule - .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); + } + + if (dataBytes > 0 && packetSize > dataBytes) { + notificationsModule.debug("[" + packetName + "|Data] " + playerName + " sent a packet of " + + packetSize + " bytes long!"); event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && parseSign(strings.values().toArray(new String[0]))) { + notificationsModule.debug("[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls); + + event.setCancelled(true); + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); + return; } } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); } final Map items = packetWrapper.getItems(); @@ -209,18 +196,7 @@ && checkSign(strings.values().toArray(new String[0]))) { final ItemStack itemStack = items.get("b"); if (itemStack != null) { - final String materialName = itemStack.getType().toString(); - String blocked = null; - - for (final String blockedMaterial : itemsFixModule.getBlacklist()) { - if (materialName.equals(blockedMaterial)) { - itemStack.setType(Material.AIR); - itemStack.setItemMeta(null); - blocked = materialName; - break; - } - } - + final String blocked = clearIfBlocked(itemStack); final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); packetWrapper.write("b", fixedItemStack); @@ -237,7 +213,7 @@ && checkSign(strings.values().toArray(new String[0]))) { } } - private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploitPlayer, + private int parseItemLength(final ItemStack itemStack, final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { int itemBytesLength = 0; @@ -263,7 +239,7 @@ private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploit final InventoryHolder inventoryHolder = (InventoryHolder) blockState; for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += getItemLength(itemStack1, exploitPlayer, hamsterPlayer, + itemBytesLength += parseItemLength(itemStack1, exploitPlayer, hamsterPlayer, packetName, itemBytesMax); if (itemBytesLength > itemBytesMax) { @@ -273,15 +249,15 @@ private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploit } } } else { - throw new Exception(); + throw new NullPointerException(); } - } catch (final Exception exception) { + } catch (final NullPointerException e1) { if (itemMeta instanceof BookMeta) { - itemBytesLength += getBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); + itemBytesLength += parseBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); } else { try { itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e) { + } catch (final NullPointerException e2) { itemBytesLength += (itemMeta.getClass().getName() + "@" + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; } @@ -293,7 +269,7 @@ private int getItemLength(final ItemStack itemStack, final ExploitPlayer exploit return itemBytesLength; } - private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, + private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, final ItemMeta itemMeta, final String packetName) { final Player player = hamsterPlayer.getPlayer(); final BookMeta bookMeta = (BookMeta) itemMeta; @@ -301,7 +277,7 @@ private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); int bookTotalBytes = 0; - if (pageCount > 50) { + if (dataVls > 0 && pageCount > 50) { notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " + dataVls); @@ -313,7 +289,7 @@ private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer bookTotalBytes += pageBytes; - if (pageBytes > dataBytesBook) { + if (dataVls > 0 && pageBytes > dataBytesBook) { notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); @@ -329,7 +305,7 @@ private int getBookLength(final ExploitPlayer exploitPlayer, final HamsterPlayer return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; } - private boolean checkSign(final String[] linesString) { + private boolean parseSign(final String[] linesString) { final int dataBytesSign = packetsModule.getDataBytesSign(); if (linesString != null) { @@ -346,4 +322,18 @@ private boolean checkSign(final String[] linesString) { return false; } + + private String clearIfBlocked(final ItemStack itemStack) { + final String materialName = itemStack.getType().toString(); + + for (final String blockedMaterial : itemsFixModule.getBlacklist()) { + if (materialName.equals(blockedMaterial)) { + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + return materialName; + } + } + + return null; + } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index b65dd2d..4456113 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -6,10 +6,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; @@ -28,7 +28,7 @@ public class PlayerCommandListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (!exploitPlayer.isLogged()) { event.setCancelled(true); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index b47c574..e27200b 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -11,19 +11,19 @@ import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import java.net.InetAddress; import java.util.UUID; public class PlayerLoginListener implements Listener { private final Plugin plugin; - private final NotificationsModule notificationsModule; + private final BukkitNotificationsModule notificationsModule; private final BukkitMessagesModule messagesModule; private final ConnectionModule connectionModule; private final ExploitPlayerManager exploitPlayerManager; @@ -39,6 +39,7 @@ public class PlayerLoginListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); + final String playerName = player.getName(); final InetAddress address = event.getAddress(); final String locale = VersionUtil.getLocale(player); @@ -48,22 +49,19 @@ public void onPlayerLogin(final PlayerLoginEvent event) { event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); } else { - final UUID uuid = player.getUniqueId(); - final String playerName = player.getName(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final UUID originalUUID = player.getUniqueId(); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (connectionModule.isUUIDSpoofEnabled()) { final BukkitScheduler scheduler = plugin.getServer().getScheduler(); scheduler.runTaskAsynchronously(plugin, () -> { - final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) - .toString().replace("-", ""); + final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); - if (!originalUUID.contains(offlineUUID)) { - final String onlineUUID = exploitPlayer.getOnlineUUID(); + if (!originalUUID.equals(offlineUUID)) { + final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() .get(player); final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); @@ -83,7 +81,7 @@ public void onPlayerLogin(final PlayerLoginEvent event) { } if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(player, true); + notificationsModule.setNotifications(playerName, true); } } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java index efe77c1..f97744d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java @@ -4,14 +4,15 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; + +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; + private final BukkitNotificationsModule notificationsModule; PlayerQuitListener(final ModuleManager variables) { this.exploitPlayerManager = variables.getExploitPlayerManager(); @@ -21,10 +22,10 @@ public class PlayerQuitListener implements Listener { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); exploitPlayer.clear(); exploitPlayer.setLogged(false); - notificationsModule.setNotifications(player, false); + notificationsModule.setNotifications(player.getName(), false); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index b498ed0..6053d81 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -9,13 +9,13 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; public class ExploitPlayerManager { private final Plugin plugin; private final Server server; private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); + private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; ExploitPlayerManager(final Plugin plugin, final Server server, final ModuleManager moduleManager) { @@ -26,14 +26,14 @@ public class ExploitPlayerManager { reload(); } - public ExploitPlayer get(final Player player) { + public BukkitExploitPlayer get(final Player player) { final UUID uuid = player.getUniqueId(); - final ExploitPlayer exploitPlayer; + final BukkitExploitPlayer exploitPlayer; if (exploitPlayers.containsKey(uuid)) { exploitPlayer = exploitPlayers.get(uuid); } else { - exploitPlayer = new ExploitPlayer(this.plugin, player.getName(), moduleManager); + exploitPlayer = new BukkitExploitPlayer(this.plugin, player.getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -42,21 +42,27 @@ public ExploitPlayer get(final Player player) { public void clear() { final Iterator iterator = exploitPlayers.keySet().iterator(); + boolean cleared = false; while (iterator.hasNext()) { final UUID uuid = iterator.next(); if (server.getPlayer(uuid) == null) { iterator.remove(); + cleared = true; } } + + if (cleared) { + moduleManager.getNotificationsModule().debug("[ExploitFixer] Cleared unused cached players!"); + } } public void reload() { exploitPlayers.clear(); for (final Player player : server.getOnlinePlayers()) { - final ExploitPlayer exploitPlayer = get(player); + final BukkitExploitPlayer exploitPlayer = get(player); exploitPlayer.setLogged(true); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index 6c28969..54eb1a2 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -3,46 +3,43 @@ import java.util.logging.Level; import org.bukkit.Server; -import org.bukkit.configuration.Configuration; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.bukkit.modules.CustomPayloadModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.PacketsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; +import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; public class ModuleManager { private Plugin plugin; private final CommandsModule commandsModule; private final ConnectionModule connectionModule; - private final CustomPayloadModule customPayloadModule; private final ItemsFixModule itemsFixModule; private final BukkitMessagesModule messagesModule; - private final NotificationsModule notificationsModule; + private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; - public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { + public ModuleManager(final Plugin plugin) { + final Server server = plugin.getServer(); + this.plugin = plugin; - this.commandsModule = new CommandsModule(configYml); - this.connectionModule = new ConnectionModule(configYml); - this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); - this.itemsFixModule = new ItemsFixModule(plugin, configYml); - this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), plugin.getLogger(), - configYml); - this.packetsModule = new PacketsModule(plugin, this, configYml); - this.exploitPlayerManager = new ExploitPlayerManager(plugin, plugin.getServer(), this); + this.commandsModule = new CommandsModule(); + this.connectionModule = new ConnectionModule(); + this.itemsFixModule = new ItemsFixModule(plugin); + this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion()); + this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), plugin.getLogger(), server); + this.packetsModule = new PacketsModule(); + this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); } - public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) { + public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { try { this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); - this.customPayloadModule.reload(configYml); this.itemsFixModule.reload(configYml); this.messagesModule.reload(messagesYml); this.notificationsModule.reload(configYml); @@ -67,10 +64,6 @@ public ConnectionModule getConnectionModule() { return connectionModule; } - public CustomPayloadModule getCustomPayloadModule() { - return customPayloadModule; - } - public ItemsFixModule getItemsFixModule() { return itemsFixModule; } @@ -79,7 +72,7 @@ public BukkitMessagesModule getMessagesModule() { return messagesModule; } - public NotificationsModule getNotificationsModule() { + public BukkitNotificationsModule getNotificationsModule() { return notificationsModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 3fd140c..6d0ad77 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -1,31 +1,30 @@ package dev._2lstudios.exploitfixer.bukkit.modules; import org.bukkit.ChatColor; -import org.bukkit.configuration.Configuration; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; public class BukkitMessagesModule extends MessagesModule { private final String version; - private Configuration messagesYml; + private IConfiguration messagesYml; private String discord; - public BukkitMessagesModule(final String version, final Configuration messagesYml) { - reload(messagesYml); + public BukkitMessagesModule(final String version) { this.version = version; } - public void reload(final Configuration messagesYml) { + public void reload(final IConfiguration messagesYml) { this.messagesYml = messagesYml; this.discord = messagesYml.getString("discord", ""); } @Override public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); + String string = messagesYml.getString(locale + path, null); if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); + string = messagesYml.getString("en" + path, null); } if (string != null && !string.isEmpty()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java new file mode 100644 index 0000000..fce33e8 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java @@ -0,0 +1,51 @@ +package dev._2lstudios.exploitfixer.bukkit.modules; + +import java.util.logging.Logger; + +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; + +public class BukkitNotificationsModule extends NotificationsModule { + private final CommandSender console; + private final Server server; + + public BukkitNotificationsModule(final CommandSender console, final Logger logger, final Server server) { + super(logger); + this.console = console; + this.server = server; + } + + public void sendNotification(final String check, final Object player, final int violations) { + if (isEnabled() && player != null) { + final Player player1 = (Player) player; + final int ping = getPing(player1); + final String notification = getMessage().replace("%player%", player1.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); + + console.sendMessage(notification); + + for (final String playerName : getNotifications()) { + final Player player2 = server.getPlayer(playerName); + + if (player2 != null) { + player2.sendMessage(notification); + } + } + } + } + + private int getPing(final Player player) { + int ping = 0; + + try { + final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + ping = (int) playerHandle.getClass().getField("ping").get(playerHandle); + } catch (final Exception ignored) { + } + + return ping; + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java deleted file mode 100644 index 407174a..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/CommandsModule.java +++ /dev/null @@ -1,45 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.file.YamlConfiguration; -import dev._2lstudios.exploitfixer.bukkit.modules.CommandsModule; -import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; - -import java.util.Collection; - -public class CommandsModule implements PunishmentModule { - private Collection commands, punishments; - private String name; - private boolean enabled; - - public CommandsModule(final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - - this.name = "Commands"; - this.enabled = configYml1.getBoolean("commands.enabled"); - this.commands = configYml1.getStringList("commands.commands"); - this.punishments = configYml1.getStringList("commands.punishments"); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return this.name; - } - - public final Collection getCommands() { - return commands; - } - - public final Collection getPunishments() { - return punishments; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java deleted file mode 100644 index 4b1afe4..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ConnectionModule.java +++ /dev/null @@ -1,50 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import java.util.Collection; -import java.util.HashSet; - -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.file.YamlConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; - -public class ConnectionModule implements PunishmentModule { - private boolean uuidSpoofEnabled, nullAddressEnabled; - private String name; - private Collection punishments; - - public ConnectionModule(final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - final YamlConfiguration configYml1 = (YamlConfiguration) configYml; - - this.uuidSpoofEnabled = configYml1.getBoolean("connection.uuidspoof"); - this.nullAddressEnabled = configYml1.getBoolean("connection.nulladdress"); - this.name = "UUID-Spoof"; - this.punishments = new HashSet<>(configYml1.getStringList("connection.punishments")); - } - - public boolean isUUIDSpoofEnabled() { - return uuidSpoofEnabled; - } - - public boolean isNullAddressEnabled() { - return nullAddressEnabled; - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public Collection getPunishments() { - return this.punishments; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java deleted file mode 100644 index 08c9515..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/CustomPayloadModule.java +++ /dev/null @@ -1,103 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.instanceables.Violations; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; - -public class CustomPayloadModule implements ViolationModule { - private Map multipliers = new HashMap<>(); - private Violations violations; - private int channelAmount, dataBytes, bookBytes; - private double cancelVls, reduceVls, bookVls, channelVls, dataVls, tagVls; - private boolean enabled; - - public CustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - final ConfigurationSection configurationSection = configYml - .getConfigurationSection("custompayload.multipliers"); - final String name = getName().toLowerCase(); - - this.enabled = configYml.getBoolean(name + ".enabled"); - this.cancelVls = configYml.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml.getDouble(name + ".reduce_vls"); - this.bookVls = configYml.getDouble(name + ".book.vls"); - this.bookBytes = configYml.getInt(name + ".book.bytes"); - this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); - this.channelVls = configYml.getDouble(name + ".channel.vls"); - this.channelAmount = configYml.getInt(name + ".channel.amount"); - this.dataVls = configYml.getDouble(name + ".data.vls"); - this.dataBytes = configYml.getInt(name + ".data.bytes"); - this.tagVls = configYml.getDouble(name + ".tag.vls"); - - for (final String key : configurationSection.getKeys(false)) { - multipliers.put(key, configurationSection.getDouble(key)); - } - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - public String getName() { - return "CustomPayload"; - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - public double getMultiplier(final String packetName) { - return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); - } - - public double getTagVls() { - return this.tagVls; - } - - public double getBookVls() { - return this.bookVls; - } - - public double getChannelVls() { - return this.channelVls; - } - - public double getDataVls() { - return this.dataVls; - } - - public int getBookBytes() { - return this.bookBytes; - } - - public int getDataBytes() { - return this.dataBytes; - } - - public int getChannelAmount() { - return this.channelAmount; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index d1361cf..aba21e3 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -5,7 +5,6 @@ import java.util.List; import org.bukkit.Material; -import org.bukkit.configuration.Configuration; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BookMeta; @@ -15,6 +14,7 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.interfaces.IModule; public class ItemsFixModule implements IModule { @@ -23,18 +23,17 @@ public class ItemsFixModule implements IModule { private int enchantLimit, maxStackSize; private Collection blacklist; - public ItemsFixModule(final Plugin plugin, final Configuration configYml) { + public ItemsFixModule(final Plugin plugin) { this.plugin = plugin; - reload(configYml); } - final public void reload(final Configuration configYml) { + final public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); this.enabled = configYml.getBoolean(name + ".enabled", true); this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); - this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); + this.blacklist = configYml.getStringList(name + ".blacklist", new HashSet<>()); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java deleted file mode 100644 index 22ff5e5..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/NotificationsModule.java +++ /dev/null @@ -1,88 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.HashSet; -import java.util.logging.Logger; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.Configuration; -import org.bukkit.entity.Player; - -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; - -public class NotificationsModule implements IModule { - private final CommandSender console; - private final Logger logger; - private final Collection notifications = new HashSet<>(); - private boolean enabled, debug; - private String message; - - public NotificationsModule(final CommandSender console, final Logger logger, final Configuration configYml) { - this.logger = logger; - this.console = console; - reload(configYml); - } - - @Override - public boolean isEnabled() { - return this.enabled; - } - - public void debug(final String message) { - if (this.debug) { - this.logger.info(message); - } - } - - public final void setNotifications(final Player player, final boolean input) { - if (input) { - notifications.add(player); - } else { - notifications.remove(player); - } - } - - public final boolean isNotifications(final Player player) { - return notifications.contains(player); - } - - public void sendNotification(final String check, final Player player, final int violations) { - if (enabled && player != null) { - final Player player1 = (Player) player; - int ping = 0; - - try { - final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); - ping = (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (IllegalAccessException | NoSuchFieldException | InvocationTargetException - | NoSuchMethodException ignored) { - } - - final String notification = message.replace("%player%", player1.getName()).replace("%check%", check) - .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); - - console.sendMessage(notification); - - for (final Player player2 : getNotifications()) { - player2.sendMessage(notification); - } - } - } - - public final Collection getNotifications() { - return notifications; - } - - public void reload(final Configuration configYml) { - this.enabled = configYml.getBoolean("notifications.enabled"); - this.debug = configYml.getBoolean("notifications.debug"); - this.message = ChatColor.translateAlternateColorCodes('&', configYml.getString("notifications.message")); - } - - @Override - public String getName() { - return "Notifications"; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java deleted file mode 100644 index 88be686..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/PacketsModule.java +++ /dev/null @@ -1,118 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.instanceables.Violations; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; - -public class PacketsModule implements ViolationModule { - private final Map multipliers = new HashMap<>(); - private Violations violations; - private String name; - private double dataVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, reduceVls; - private int dataBytesBook, dataBytesSign, dataBytes, dataBytesDivider; - private boolean enabled, offline; - - public PacketsModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { - reload(configYml); - } - - final public void reload(final Configuration configYml) { - final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers"); - final String name = "packets"; - - this.name = "Packets"; - this.enabled = configYml.getBoolean(name + ".enabled"); - this.cancelVls = configYml.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml.getDouble(name + ".reduce_vls"); - this.offline = configYml.getBoolean(name + ".offline"); - this.dataVls = configYml.getDouble(name + ".data.vls"); - this.dataBytes = configYml.getInt(name + ".data.bytes", 24000); - this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268); - this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47); - this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200); - this.windowClick = configYml.getDouble(name + ".window_click"); - this.blockPlaceVls = configYml.getDouble(name + ".block_place"); - this.blockDigVls = configYml.getDouble(name + ".block_dig"); - this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); - this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); - - for (final String key : configurationSection.getKeys(false)) - multipliers.put(key, configurationSection.getDouble(key)); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return this.violations; - } - - public double getMultiplier(final String packetName) { - return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); - } - - public double getWindowClick() { - return this.windowClick; - } - - public double getSetCreativeSlot() { - return this.setCreativeSlot; - } - - public double getBlockDigVls() { - return this.blockDigVls; - } - - public double getBlockPlaceVls() { - return this.blockPlaceVls; - } - - public double getDataVls() { - return this.dataVls; - } - - public int getDataBytes() { - return this.dataBytes; - } - - public int getDataBytesBook() { - return this.dataBytesBook; - } - - public int getDataBytesSign() { - return this.dataBytesSign; - } - - public boolean isOffline() { - return this.offline; - } - - public int getDataBytesDivider() { - return this.dataBytesDivider; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java index 502d49a..f140abd 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -21,10 +21,11 @@ public YamlConfiguration getConfiguration(String filePath) { final File dataFolder = plugin.getDataFolder(); final File file = new File(filePath.replace("%datafolder%", dataFolder.toPath().toString())); - if (file.exists()) + if (file.exists()) { return YamlConfiguration.loadConfiguration(file); - else + } else { return new YamlConfiguration(); + } } public void createConfiguration(String file) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index 31aad42..f10b7aa 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -4,14 +4,15 @@ import java.util.logging.Logger; import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.bungee.configuration.BungeeConfiguration; import dev._2lstudios.exploitfixer.bungee.listeners.ListenerInitializer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; import dev._2lstudios.exploitfixer.bungee.utils.ConfigurationUtil; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.scheduler.TaskScheduler; -import net.md_5.bungee.config.Configuration; public class ExploitFixer extends Plugin { private static ExploitFixer exploitFixer; @@ -27,15 +28,17 @@ public void onEnable() { createConfigurations(); - final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); - final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final IConfiguration configYml = new BungeeConfiguration( + configurationUtil.getConfiguration("%datafolder%/config.yml")); + final IConfiguration messagesYml = new BungeeConfiguration( + configurationUtil.getConfiguration("%datafolder%/messages.yml")); exploitFixer = this; - this.moduleManager = new ModuleManager(this, configYml, messagesYml); - this.listenerInitializer = new ListenerInitializer(this, moduleManager); + moduleManager = new ModuleManager(this); + moduleManager.reload(configYml, messagesYml); + listenerInitializer = new ListenerInitializer(this, moduleManager); - registerListeners(); - registerCommands(); + register(); scheduler.schedule(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -56,22 +59,30 @@ public void reload() { createConfigurations(); - final Configuration configYml = configurationUtil.getConfiguration("%datafolder%/config.yml"); - final Configuration messagesYml = configurationUtil.getConfiguration("%datafolder%/messages.yml"); + final IConfiguration configYml = new BungeeConfiguration( + configurationUtil.getConfiguration("%datafolder%/config.yml")); + final IConfiguration messagesYml = new BungeeConfiguration( + configurationUtil.getConfiguration("%datafolder%/messages.yml")); - moduleManager.reload(configYml, messagesYml, null); + moduleManager.reload(configYml, messagesYml); - registerCommands(); - registerListeners(); + register(); } private void createConfigurations() { - this.configurationUtil.createConfiguration("%datafolder%/config.yml"); - this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); + configurationUtil.createConfiguration("%datafolder%/config.yml"); + configurationUtil.createConfiguration("%datafolder%/messages.yml"); } - private void registerListeners() { - final Logger logger = this.getLogger(); + private void register() { + final Logger logger = getLogger(); + final PluginManager pluginManager = getProxy().getPluginManager(); + + pluginManager.unregisterCommands(this); + pluginManager.registerCommand(this, + new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, moduleManager)); + + logger.info("Successfully registered commands!"); if (this.listenerInitializer.isRegistered()) { this.listenerInitializer.unregister(); @@ -82,14 +93,6 @@ private void registerListeners() { logger.info("Successfully registered listeners!"); } - private void registerCommands() { - final PluginManager pluginManager = getProxy().getPluginManager(); - - pluginManager.unregisterCommands(this); - pluginManager.registerCommand(this, - new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, moduleManager)); - } - public static ExploitFixer getInstance() { return exploitFixer; } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index 58ec661..98ba040 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -1,18 +1,18 @@ package dev._2lstudios.exploitfixer.bungee.commands; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Command; import dev._2lstudios.exploitfixer.bungee.ExploitFixer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Command; public class ExploitFixerCommand extends Command { - private BungeeMessagesModule messagesModule; + private MessagesModule messagesModule; private NotificationsModule notificationsVariables; private ExploitPlayerManager exploitPlayerManager; @@ -52,13 +52,13 @@ else if (args[0].equalsIgnoreCase("notifications")) { if (commandSender instanceof ProxiedPlayer) { if (commandSender.hasPermission("exploitfixer.admin") || commandSender.hasPermission("exploitfixer.notifications")) { - final ProxiedPlayer proxiedPlayer = (ProxiedPlayer) commandSender; + final String playerName = commandSender.getName(); - if (!notificationsVariables.isNotifications(proxiedPlayer)) { - notificationsVariables.setNotifications(proxiedPlayer, true); + if (!notificationsVariables.isNotifications(playerName)) { + notificationsVariables.setNotifications(playerName, true); commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getEnable(lang))); } else { - notificationsVariables.setNotifications(proxiedPlayer, false); + notificationsVariables.setNotifications(playerName, false); commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getDisable(lang))); } } else diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java new file mode 100644 index 0000000..bc8f0ea --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java @@ -0,0 +1,64 @@ +package dev._2lstudios.exploitfixer.bungee.configuration; + +import java.util.Collection; +import java.util.HashSet; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import net.md_5.bungee.config.Configuration; + +public class BungeeConfiguration implements IConfiguration { + private final Configuration configuration; + + public BungeeConfiguration(final Configuration configuration) { + this.configuration = configuration; + } + + @Override + public IConfiguration getSection(final String path) { + return new BungeeConfiguration(configuration.getSection(path)); + } + + @Override + public Collection getKeys() { + return configuration.getKeys(); + } + + @Override + public Collection getStringList(final String path, final Collection def) { + if (configuration.contains(path)) { + return new HashSet<>(configuration.getStringList(path)); + } else { + return def; + } + } + + @Override + public String getString(final String path, final String def) { + return configuration.getString(path, def); + } + + @Override + public double getDouble(final String path, final double def) { + return configuration.getDouble(path, def); + } + + @Override + public long getLong(final String path, final long def) { + return configuration.getLong(path, def); + } + + @Override + public int getInt(final String path, final int def) { + return configuration.getInt(path, def); + } + + @Override + public boolean getBoolean(final String path, final boolean def) { + return configuration.getBoolean(path, def); + } + + @Override + public Object getObject() { + return configuration; + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java new file mode 100644 index 0000000..13101b5 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java @@ -0,0 +1,109 @@ +package dev._2lstudios.exploitfixer.bungee.exploit; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; + +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.shared.exploit.Violations; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; +import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; + +public class BungeeExploitPlayer extends ExploitPlayer { + private final ProxyServer server; + private final ExploitPlayerManager exploitPlayerManager; + private final MessagesModule messagesModule; + private final NotificationsModule notificationsModule; + + public BungeeExploitPlayer(final ProxyServer server, final String name, final ModuleManager moduleManager) { + super(name); + this.server = server; + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.messagesModule = moduleManager.getMessagesModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + } + + public void addVls(final Object event, final ProxiedPlayer player, final IViolationModule module, + final double amount) { + if (player.isConnected()) { + final Violations violations = (Violations) module.getViolations(); + + if (violations != null) { + final Map violationsMap = getViolations(); + final long currentTime = System.currentTimeMillis(); + final long lastViolation = getLastViolation(); + + if (currentTime - lastViolation >= 1000) { + setLastViolation(currentTime); + + for (final IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { + final double vls = violationsMap.get(violationModule) - violationModule.getReduceVls(); + + if (vls <= 0) { + violationsMap.remove(violationModule); + } else { + violationsMap.put(violationModule, vls); + } + } + } + + final double newVls = getViolations(module) + amount; + + violationsMap.put(module, newVls); + + if (event instanceof Cancellable && module.getCancelVls() <= newVls) { + ((Cancellable) event).setCancelled(true); + } + + for (final int threshold : violations.getViolations()) { + if (threshold <= newVls) { + final Collection commands = violations.getCommands(threshold); + + punish(module, player, commands, (int) newVls); + } + } + } + } else if (event instanceof Cancellable) { + ((Cancellable) event).setCancelled(true); + } + } + + public void punish(final IModule module, final ProxiedPlayer player, final Collection punishments, + final int newVls) { + final Collection> punishmentsDone = getPunishmentsDone(); + + if (!punishments.isEmpty() && !punishmentsDone.contains(punishments)) { + final CommandSender consoleSender = server.getConsole(); + final String playerName = player.getName(); + + for (final String punishment : punishments) { + if (punishment.equals("kick")) { + final String locale = VersionUtil.getLocale(player); + final String kickMessage = messagesModule.getKickMessage(module, locale); + + player.disconnect(TextComponent.fromLegacyText(kickMessage)); + } else if (punishment.equals("notification")) { + final String moduleName = module.getName(); + + notificationsModule.sendNotification(moduleName, player, (int) newVls); + } else { + server.getPluginManager().dispatchCommand(consoleSender, + punishment.replace("%player%", playerName)); + } + } + + punishmentsDone.add(punishments); + exploitPlayerManager.addPunishment(); + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java deleted file mode 100644 index ffa8191..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/ExploitPlayer.java +++ /dev/null @@ -1,173 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.instanceables; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Cancellable; -import net.md_5.bungee.api.plugin.Plugin; - -public class ExploitPlayer { - private final ProxyServer server; - private final ExploitPlayerManager exploitPlayerManager; - private final BungeeMessagesModule messagesModule; - private final NotificationsModule notificationsModule; - private final Map violations; - private final Collection> punishments; - private final String name; - private String onlineUUID = null; - private boolean logged = false; - private int channels = 0; - private double lastViolation = 0; - - public ExploitPlayer(final ProxyServer server, final String name, final ModuleManager moduleManager) { - this.server = server; - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.messagesModule = moduleManager.getMessagesModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.violations = new HashMap<>(); - this.punishments = new HashSet<>(); - this.name = name; - } - - public void clearChannels() { - this.channels = 0; - } - - public int addChannels(final int channels) { - return this.channels += channels; - } - - public double getViolations(final IModule module) { - if (module instanceof ViolationModule) { - return violations.getOrDefault(module, 0D); - } else { - return 0D; - } - } - - public String getOnlineUUID() { - if (onlineUUID == null) { - try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) - .openConnection(); - - connection.setDoOutput(true); - connection.connect(); - - final BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(connection.getInputStream())); - final StringBuilder response = new StringBuilder(); - - String inputLine; - - while ((inputLine = bufferedReader.readLine()) != null) - response.append(inputLine).append("\n"); - - bufferedReader.close(); - onlineUUID = response.toString(); - } catch (Exception ignored) { - } - } - - return onlineUUID; - } - - public void addVls(final Plugin plugin, final Object event, final ProxiedPlayer player, - final ViolationModule module, final double amount) { - if (player.isConnected()) { - final Violations violations = (Violations) module.getViolations(); - - if (violations != null) { - final double currentTime = System.currentTimeMillis(); - - if (currentTime - lastViolation >= 1000) { - lastViolation = currentTime; - - for (final ViolationModule violationModule : new HashSet<>(this.violations.keySet())) { - final double vls = this.violations.get(violationModule) - violationModule.getReduceVls(); - - if (vls <= 0) { - this.violations.remove(violationModule); - } else { - this.violations.put(violationModule, vls); - } - } - } - - final double newVls = getViolations(module) + amount; - - this.violations.put(module, newVls); - - if (event instanceof Cancellable && module.getCancelVls() <= newVls) { - ((Cancellable) event).setCancelled(true); - } - - for (final int threshold : violations.getViolations()) { - if (threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); - - punish(module, player, commands, (int) newVls); - } - } - } - } else if (event instanceof Cancellable) { - ((Cancellable) event).setCancelled(true); - } - } - - public void punish(final IModule module, final ProxiedPlayer player, final Collection punishments, - final int newVls) { - if (!punishments.isEmpty() && !this.punishments.contains(punishments)) { - final CommandSender consoleSender = server.getConsole(); - final String playerName = player.getName(); - - for (final String punishment : punishments) { - if (punishment.equals("kick")) { - final String locale = VersionUtil.getLocale(player); - final String kickMessage = messagesModule.getKickMessage(module, locale); - - player.disconnect(TextComponent.fromLegacyText(kickMessage)); - } else if (punishment.equals("notification")) { - final String moduleName = module.getName(); - - notificationsModule.sendNotification(moduleName, player, (int) newVls); - } else { - server.getPluginManager().dispatchCommand(consoleSender, - punishment.replace("%player%", playerName)); - } - } - - this.punishments.add(punishments); - this.exploitPlayerManager.addPunishment(); - } - } - - public void clearViolations() { - violations.clear(); - } - - public void setLogged(final boolean logged) { - this.logged = logged; - } - - public boolean isLogged() { - return logged; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index fbf541c..9b73f43 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -1,9 +1,9 @@ package dev._2lstudios.exploitfixer.bungee.listeners; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.CommandsModule; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -27,7 +27,7 @@ public void onChat(final ChatEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer player = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); if (!exploitPlayer.isLogged()) { event.setCancelled(true); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java index 1d8e197..fd117e4 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java @@ -1,13 +1,13 @@ package dev._2lstudios.exploitfixer.bungee.listeners; +import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; public class DisconnectListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; @@ -21,13 +21,12 @@ public class DisconnectListener implements Listener { @EventHandler public void onDisconnect(final PlayerDisconnectEvent event) { final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); if (exploitPlayer != null) { - exploitPlayer.clearChannels(); - exploitPlayer.clearViolations(); + exploitPlayer.clear(); } - notificationsModule.setNotifications(proxiedPlayer, false); + notificationsModule.setNotifications(proxiedPlayer.getName(), false); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java index 548c909..74925ba 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java @@ -23,7 +23,7 @@ public void register() { pluginManager.registerListener(plugin, new ChatListener(plugin, moduleManager)); pluginManager.registerListener(plugin, new DisconnectListener(moduleManager)); - pluginManager.registerListener(plugin, new PluginMessageListener(plugin, moduleManager)); + pluginManager.registerListener(plugin, new PluginMessageListener(moduleManager)); pluginManager.registerListener(plugin, new PostLoginListener(plugin, moduleManager)); } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java index 174c9f6..6535aba 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -1,72 +1,60 @@ package dev._2lstudios.exploitfixer.bungee.listeners; +import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.CustomPayloadModule; public class PluginMessageListener implements Listener { - private final Plugin plugin; - private final CustomPayloadModule customPayloadModule; + private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; - PluginMessageListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.customPayloadModule = moduleManager.getCustomPayloadModule(); + PluginMessageListener(final ModuleManager moduleManager) { + this.packetsModule = moduleManager.getPacketsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.notificationsModule = moduleManager.getNotificationsModule(); } @EventHandler(priority = -128) public void onPluginMessage(final PluginMessageEvent event) { - if (!event.isCancelled() && customPayloadModule.isEnabled()) { + if (!event.isCancelled() && packetsModule.isEnabled()) { final Connection connection = event.getSender(); if (connection instanceof ProxiedPlayer) { final ProxiedPlayer player = (ProxiedPlayer) connection; - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); final String tag = event.getTag(), playerName = player.getName(); - final double tagVls = customPayloadModule.getTagVls(); + final double tagVls = packetsModule.getTagVls(), dataVls = packetsModule.getDataVls(); if (tagVls > 0 && tag == null || tag.isEmpty()) { - notificationsModule.debug(playerName + " sent CUSTOM_PAYLOAD without TAG! Added vls: " + tagVls); + notificationsModule.debug("[PacketPlayInCustomPayload|Tag] Sent by " + playerName + + " got cancelled because it doesn't have a TAG! Added vls: " + tagVls); event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, tagVls); + exploitPlayer.addVls(event, player, packetsModule, tagVls); return; - } else { + } else if (dataVls > 0) { final byte[] data = event.getData(); final int byteLength = data.length; - if (byteLength > customPayloadModule.getDataBytes()) { - notificationsModule.debug("[PacketPlayInCustomPayload] Sent by " + playerName - + " got cancelled because its " + byteLength + " bytes long!"); + if (byteLength > packetsModule.getDataBytes()) { + notificationsModule.debug("[PacketPlayInCustomPayload|Data] Sent by " + playerName + + " got cancelled because its " + byteLength + " bytes long! Added vls: " + dataVls); event.setCancelled(true); - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getDataVls()); + exploitPlayer.addVls(event, player, packetsModule, dataVls); return; - } else if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - /* - * if (byteLength > customPayloadModule.getBookBytes()) { - * notificationsModule.debug(playerName + " tried to send a " + tag + - * " custompayload packet without a book in hand!"); event.setCancelled(true); - * exploitPlayer.addVls(plugin, event, player, customPayloadModule, - * customPayloadModule.getBookVls()); return; } // WORK IN PROGRESS - */ } - - exploitPlayer.addVls(plugin, event, player, customPayloadModule, - customPayloadModule.getMultiplier(tag)); } + + exploitPlayer.addVls(event, player, packetsModule, packetsModule.getMultiplier(tag)); } } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 773d434..e470b46 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -8,13 +8,13 @@ import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; -import dev._2lstudios.exploitfixer.bungee.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; -import dev._2lstudios.exploitfixer.bungee.modules.NotificationsModule; import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; import java.net.InetSocketAddress; import java.util.UUID; @@ -23,7 +23,7 @@ public class PostLoginListener implements Listener { private final Plugin plugin; private final ConnectionModule connectionModule; private final NotificationsModule notificationsModule; - private final BungeeMessagesModule messagesModule; + private final MessagesModule messagesModule; private final ExploitPlayerManager exploitPlayerManager; PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { @@ -36,33 +36,30 @@ public class PostLoginListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(final PostLoginEvent event) { - final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final InetSocketAddress address = proxiedPlayer.getAddress(); - final String locale = VersionUtil.getLocale(proxiedPlayer); + final ProxiedPlayer player = event.getPlayer(); + final String playerName = player.getName(); + final InetSocketAddress address = player.getAddress(); + final String locale = VersionUtil.getLocale(player); if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { - proxiedPlayer - .disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); + player.disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); } else { - final UUID uuid = proxiedPlayer.getUniqueId(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(uuid, proxiedPlayer); + final UUID originalUUID = player.getUniqueId(); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(originalUUID, player); if (connectionModule.isUUIDSpoofEnabled()) { final TaskScheduler scheduler = plugin.getProxy().getScheduler(); - final String playerName = proxiedPlayer.getName(); scheduler.runAsync(plugin, () -> { - final String originalUUID = uuid.toString().replace("-", ""); - final String offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()) - .toString().replace("-", ""); + final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); - if (!originalUUID.contains(offlineUUID)) { - final String onlineUUID = exploitPlayer.getOnlineUUID(); + if (!originalUUID.equals(offlineUUID)) { + final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - if (onlineUUID == null || !onlineUUID.contains(originalUUID)) { + if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - proxiedPlayer.disconnect(TextComponent.fromLegacyText(uuidSpoofKickMessage)); + player.disconnect(TextComponent.fromLegacyText(uuidSpoofKickMessage)); } } @@ -72,8 +69,8 @@ public void onPostLogin(final PostLoginEvent event) { exploitPlayer.setLogged(true); } - if (proxiedPlayer.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(proxiedPlayer, true); + if (player.hasPermission("exploitfixer.notifications")) { + notificationsModule.setNotifications(playerName, true); } } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index cda3ec3..98a51d5 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -4,16 +4,15 @@ import java.util.Iterator; import java.util.Map; import java.util.UUID; -import java.util.logging.Level; -import dev._2lstudios.exploitfixer.bungee.instanceables.ExploitPlayer; +import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; public class ExploitPlayerManager { private final ProxyServer server; private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); + private final Map exploitPlayers = new HashMap<>(); private int punishments = 0; ExploitPlayerManager(final ProxyServer server, final ModuleManager moduleManager) { @@ -23,11 +22,11 @@ public class ExploitPlayerManager { reload(); } - public ExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { - ExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + public BungeeExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { + BungeeExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); if (exploitPlayer == null) { - exploitPlayer = new ExploitPlayer(server, player.getName(), moduleManager); + exploitPlayer = new BungeeExploitPlayer(server, player.getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -38,7 +37,7 @@ public void reload() { exploitPlayers.clear(); for (final ProxiedPlayer player : server.getPlayers()) { - final ExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + final BungeeExploitPlayer exploitPlayer = get(player.getUniqueId(), player); exploitPlayer.setLogged(true); } @@ -58,7 +57,7 @@ public void clear() { } if (cleared) { - server.getLogger().log(Level.INFO, "[ExploitFixer] Cleared unused cached players!"); + moduleManager.getNotificationsModule().debug("[ExploitFixer] Cleared unused cached players!"); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index 8c0af8c..2227052 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -1,32 +1,39 @@ package dev._2lstudios.exploitfixer.bungee.managers; +import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; +import dev._2lstudios.exploitfixer.bungee.modules.BungeeNotificationsModule; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; +import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.bungee.modules.*; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; public class ModuleManager { private CommandsModule commandsModule; - private final ConnectionModule connectionModule; - private CustomPayloadModule customPayloadModule; + private ConnectionModule connectionModule; + private PacketsModule packetsModule; private BungeeMessagesModule messagesModule; private NotificationsModule notificationsModule; private ExploitPlayerManager exploitPlayerManager; - public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { - this.commandsModule = new CommandsModule(configYml); - this.connectionModule = new ConnectionModule(configYml); - this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); - this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion(), messagesYml); - this.notificationsModule = new NotificationsModule(plugin.getProxy().getConsole(), plugin.getLogger(), - configYml); - this.exploitPlayerManager = new ExploitPlayerManager(plugin.getProxy(), this); + public ModuleManager(final Plugin plugin) { + final ProxyServer server = plugin.getProxy(); + + this.commandsModule = new CommandsModule(); + this.connectionModule = new ConnectionModule(); + this.packetsModule = new PacketsModule(); + this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion()); + this.notificationsModule = new BungeeNotificationsModule(server.getConsole(), plugin.getLogger(), server); + this.exploitPlayerManager = new ExploitPlayerManager(server, this); } - public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) { + public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); - this.customPayloadModule.reload(configYml); + this.packetsModule.reload(configYml); this.messagesModule.reload(messagesYml); this.notificationsModule.reload(configYml); this.exploitPlayerManager.reload(); @@ -40,11 +47,11 @@ public ConnectionModule getConnectionModule() { return connectionModule; } - public CustomPayloadModule getCustomPayloadModule() { - return customPayloadModule; + public PacketsModule getPacketsModule() { + return packetsModule; } - public BungeeMessagesModule getMessagesModule() { + public MessagesModule getMessagesModule() { return messagesModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java index 32f5f16..86d71dc 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -1,30 +1,29 @@ package dev._2lstudios.exploitfixer.bungee.modules; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.config.Configuration; public class BungeeMessagesModule extends MessagesModule { private final String version; - private Configuration messagesYml; + private IConfiguration messagesYml; private String discord; - public BungeeMessagesModule(final String version, final Configuration messagesYml) { - reload(messagesYml); + public BungeeMessagesModule(final String version) { this.version = version; } - public void reload(final Configuration messagesYml) { + public void reload(final IConfiguration messagesYml) { this.messagesYml = messagesYml; this.discord = messagesYml.getString("discord", ""); } @Override public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); + String string = messagesYml.getString(locale + path, null); if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); + string = messagesYml.getString("en" + path, null); } if (string != null && !string.isEmpty()) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java new file mode 100644 index 0000000..7c5b3c6 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java @@ -0,0 +1,39 @@ +package dev._2lstudios.exploitfixer.bungee.modules; + +import java.util.logging.Logger; + +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class BungeeNotificationsModule extends NotificationsModule { + private final CommandSender console; + private final ProxyServer server; + + public BungeeNotificationsModule(final CommandSender console, final Logger logger, final ProxyServer server) { + super(logger); + this.console = console; + this.server = server; + } + + public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { + if (isEnabled() && player != null) { + final BaseComponent[] notification = TextComponent.fromLegacyText(getMessage() + .replace("%player%", player.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(player.getPing())).replace("%vls%", String.valueOf(violations))); + + console.sendMessage(notification); + + for (final String playerName : getNotifications()) { + final ProxiedPlayer player2 = server.getPlayer(playerName); + + if (player2 != null) { + player2.sendMessage(notification); + } + } + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java deleted file mode 100644 index 121b785..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/CommandsModule.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; - -import java.util.Collection; - -public class CommandsModule implements PunishmentModule { - private Collection commands, punishments; - private String name; - private boolean enabled; - - public CommandsModule(final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - this.name = "Commands"; - this.enabled = configYml.getBoolean("commands.enabled"); - this.commands = configYml.getStringList("commands.commands"); - this.punishments = configYml.getStringList("commands.punishments"); - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - @Override - public String getName() { - return this.name; - } - - public final Collection getCommands() { - return commands; - } - - public final Collection getPunishments() { - return punishments; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java deleted file mode 100644 index 482c2f1..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/CustomPayloadModule.java +++ /dev/null @@ -1,100 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import java.util.HashMap; -import java.util.Map; - -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.bungee.instanceables.Violations; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.interfaces.ViolationModule; - -public class CustomPayloadModule implements ViolationModule { - private Map multipliers = new HashMap<>(); - private Violations violations; - private int channelAmount, dataBytes, bookBytes; - private double cancelVls, reduceVls, bookVls, channelVls, dataVls, tagVls; - private boolean enabled; - - public CustomPayloadModule(final Plugin plugin, final ModuleManager moduleManager, final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - final Configuration configurationSection = configYml.getSection("custompayload.multipliers"); - final String name = getName().toLowerCase(); - - this.enabled = configYml.getBoolean(name + ".enabled"); - this.cancelVls = configYml.getDouble(name + ".cancel_vls"); - this.reduceVls = configYml.getDouble(name + ".reduce_vls"); - this.bookVls = configYml.getDouble(name + ".book.vls"); - this.bookBytes = configYml.getInt(name + ".book.bytes"); - this.violations = new Violations(configYml.getSection(name + ".violations")); - this.channelVls = configYml.getDouble(name + ".channel.vls"); - this.channelAmount = configYml.getInt(name + ".channel.amount"); - this.dataVls = configYml.getDouble(name + ".data.vls"); - this.dataBytes = configYml.getInt(name + ".data.bytes"); - this.tagVls = configYml.getDouble(name + ".tag.vls"); - - for (final String key : configurationSection.getKeys()) { - multipliers.put(key, configurationSection.getDouble(key)); - } - } - - @Override - public double getCancelVls() { - return cancelVls; - } - - @Override - public double getReduceVls() { - return reduceVls; - } - - @Override - public Violations getViolations() { - return violations; - } - - @Override - public String getName() { - return "CustomPayload"; - } - - @Override - final public boolean isEnabled() { - return enabled; - } - - public double getMultiplier(final String packetName) { - return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); - } - - public double getTagVls() { - return this.tagVls; - } - - public double getBookVls() { - return this.bookVls; - } - - public double getChannelVls() { - return this.channelVls; - } - - public double getDataVls() { - return this.dataVls; - } - - public int getBookBytes() { - return this.bookBytes; - } - - public int getDataBytes() { - return this.dataBytes; - } - - public int getChannelAmount() { - return this.channelAmount; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java deleted file mode 100644 index 68a94cf..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/NotificationsModule.java +++ /dev/null @@ -1,79 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import java.util.Collection; -import java.util.HashSet; -import java.util.logging.Logger; - -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.config.Configuration; - -public class NotificationsModule implements IModule { - private final CommandSender console; - private final Logger logger; - private final Collection notifications = new HashSet<>(); - private boolean enabled, debug; - private String message; - - public NotificationsModule(final CommandSender console, final Logger logger, final Configuration configYml) { - this.logger = logger; - this.console = console; - reload(configYml); - } - - @Override - public boolean isEnabled() { - return this.enabled; - } - - public void debug(final String message) { - if (this.debug) { - this.logger.info(message); - } - } - - public final void setNotifications(final ProxiedPlayer player, final boolean input) { - if (input) { - notifications.add(player); - } else { - notifications.remove(player); - } - } - - public final boolean isNotifications(final ProxiedPlayer player) { - return notifications.contains(player); - } - - public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { - if (enabled && player != null) { - final BaseComponent[] notification = TextComponent.fromLegacyText(message - .replace("%player%", player.getName()).replace("%check%", check) - .replace("%ping%", String.valueOf(player.getPing())).replace("%vls%", String.valueOf(violations))); - - console.sendMessage(notification); - - for (final ProxiedPlayer player1 : getNotifications()) { - player1.sendMessage(notification); - } - } - } - - public final Collection getNotifications() { - return notifications; - } - - public void reload(final Configuration configYml) { - this.enabled = configYml.getBoolean("notifications.enabled"); - this.debug = configYml.getBoolean("notifications.debug"); - this.message = ChatColor.translateAlternateColorCodes('&', configYml.getString("notifications.message")); - } - - @Override - public String getName() { - return "Notifications"; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java new file mode 100644 index 0000000..6cd97c0 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java @@ -0,0 +1,23 @@ +package dev._2lstudios.exploitfixer.shared.configuration; + +import java.util.Collection; + +public interface IConfiguration { + public IConfiguration getSection(final String string); + + public Collection getKeys(); + + public Collection getStringList(final String string, final Collection arrayList); + + public String getString(final String path, final String def); + + public double getDouble(final String path, final double def); + + public long getLong(final String path, final long def); + + public int getInt(final String path, final int def); + + public boolean getBoolean(final String path, final boolean def); + + public Object getObject(); +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java new file mode 100644 index 0000000..b004058 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -0,0 +1,109 @@ +package dev._2lstudios.exploitfixer.shared.exploit; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.UUID; + +import com.google.gson.JsonParser; + +import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; + +public class ExploitPlayer { + private final Map violations; + private final Collection> punishmentsDone; + private final String name; + private UUID onlineUUID; + private long lastViolation; + private int channels; + private boolean logged; + + public ExploitPlayer(final String name) { + this.violations = new HashMap<>(); + this.punishmentsDone = new HashSet<>(); + this.name = name; + this.onlineUUID = null; + this.logged = false; + + clear(); + } + + public void clear() { + violations.clear(); + punishmentsDone.clear(); + setLastViolation(0); + channels = 0; + } + + public Collection> getPunishmentsDone() { + return punishmentsDone; + } + + public long getLastViolation() { + return lastViolation; + } + + public void setLastViolation(final long lastViolation) { + this.lastViolation = lastViolation; + } + + public int getChannels() { + return channels; + } + + public int addChannels(final int channels) { + return this.channels += channels; + } + + public Map getViolations() { + return violations; + } + + public double getViolations(final IViolationModule module) { + return violations.getOrDefault(module, 0D); + } + + public UUID getOnlineUUID() { + if (onlineUUID == null) { + try { + final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) + .openConnection(); + + connection.connect(); + + try (final InputStream inputStream = connection.getInputStream()) { + try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { + final StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = bufferedReader.readLine()) != null) { + response.append(inputLine); + } + + onlineUUID = UUID.fromString(new JsonParser().parse(response.toString()).getAsJsonObject() + .get("id").getAsString().replaceFirst( + "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", + "$1-$2-$3-$4-$5")); + } + } + } catch (final Exception ignored) { + } + } + + return onlineUUID; + } + + public void setLogged(final boolean logged) { + this.logged = logged; + } + + public boolean isLogged() { + return logged; + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java similarity index 71% rename from src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java rename to src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java index c0d5bc0..a4916a7 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/instanceables/Violations.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java @@ -1,19 +1,20 @@ -package dev._2lstudios.exploitfixer.bungee.instanceables; +package dev._2lstudios.exploitfixer.shared.exploit; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; -import net.md_5.bungee.config.Configuration; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; public class Violations { private Map> violations = new HashMap<>(); - public Violations(final Configuration configuration) { + public Violations(final IConfiguration configuration) { if (configuration != null) { for (final String key : configuration.getKeys()) { try { - this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); + this.violations.put(Integer.parseInt(key), configuration.getStringList(key, new HashSet<>())); } catch (final NumberFormatException ignored) { } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java new file mode 100644 index 0000000..500207d --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java @@ -0,0 +1,5 @@ +package dev._2lstudios.exploitfixer.shared.interfaces; + +public interface INotificationsModule extends IModule { + public void sendNotification(final String check, final Object player, final int violations); +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java similarity index 71% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java rename to src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java index d6d1b74..e9e9f2b 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/PunishmentModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java @@ -2,6 +2,6 @@ import java.util.Collection; -public interface PunishmentModule extends IModule { +public interface IPunishmentModule extends IModule { public Collection getPunishments(); } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java similarity index 75% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java rename to src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java index e176e59..8c800e5 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/ViolationModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java @@ -1,6 +1,6 @@ package dev._2lstudios.exploitfixer.shared.interfaces; -public interface ViolationModule extends IModule { +public interface IViolationModule extends IModule { public double getCancelVls(); public double getReduceVls(); diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java new file mode 100644 index 0000000..6f56cc4 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java @@ -0,0 +1,38 @@ +package dev._2lstudios.exploitfixer.shared.modules; + +import java.util.Collection; +import java.util.HashSet; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; + +public class CommandsModule implements IPunishmentModule { + private Collection commands, punishments; + private String name; + private boolean enabled; + + public void reload(final IConfiguration configYml) { + this.name = "Commands"; + this.enabled = configYml.getBoolean("commands.enabled", true); + this.commands = configYml.getStringList("commands.commands", new HashSet<>()); + this.punishments = configYml.getStringList("commands.punishments", new HashSet<>()); + } + + @Override + final public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return name; + } + + public final Collection getCommands() { + return commands; + } + + public final Collection getPunishments() { + return punishments; + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java similarity index 59% rename from src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java rename to src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java index 36b2926..675f059 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java @@ -1,25 +1,21 @@ -package dev._2lstudios.exploitfixer.bungee.modules; +package dev._2lstudios.exploitfixer.shared.modules; import java.util.Collection; import java.util.HashSet; -import net.md_5.bungee.config.Configuration; -import dev._2lstudios.exploitfixer.shared.interfaces.PunishmentModule; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; -public class ConnectionModule implements PunishmentModule { +public class ConnectionModule implements IPunishmentModule { private boolean uuidSpoofEnabled, nullAddressEnabled; private String name; private Collection punishments; - public ConnectionModule(final Configuration configYml) { - reload(configYml); - } - - public void reload(final Configuration configYml) { - this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof"); - this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress"); + public void reload(final IConfiguration configYml) { + this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof", true); + this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress", true); this.name = "UUID-Spoof"; - this.punishments = new HashSet<>(configYml.getStringList("connection.punishments")); + this.punishments = configYml.getStringList("connection.punishments", new HashSet<>()); } public boolean isUUIDSpoofEnabled() { diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index de1fa18..e3d153f 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -6,7 +6,7 @@ public class MessagesModule implements IMessagesModule { @Override public String getString(final String locale, final String path) { - // This is override by BukkitMessagesModule/BungeeMessagesModule + // Overrided by parent Bukkit/Bungee MessagesModule return null; } diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java new file mode 100644 index 0000000..51910c7 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -0,0 +1,67 @@ +package dev._2lstudios.exploitfixer.shared.modules; + +import java.util.Collection; +import java.util.HashSet; +import java.util.logging.Logger; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.INotificationsModule; + +public class NotificationsModule implements INotificationsModule { + private final Logger logger; + private final Collection notifications = new HashSet<>(); + private boolean enabled, debug; + private String message; + + public NotificationsModule(final Logger logger) { + this.logger = logger; + } + + public String getMessage() { + return message; + } + + public void reload(final IConfiguration configYml) { + this.enabled = configYml.getBoolean("notifications.enabled", true); + this.debug = configYml.getBoolean("notifications.debug", true); + this.message = configYml.getString("notifications.message", "[Message not found in configuration]").replace('&', + '\u00A7'); + } + + @Override + public boolean isEnabled() { + return this.enabled; + } + + public void debug(final String message) { + if (this.debug) { + this.logger.info(message); + } + } + + public final void setNotifications(final String playerName, final boolean input) { + if (input) { + notifications.add(playerName); + } else { + notifications.remove(playerName); + } + } + + public final boolean isNotifications(final String playerName) { + return notifications.contains(playerName); + } + + public final Collection getNotifications() { + return notifications; + } + + @Override + public String getName() { + return "Notifications"; + } + + @Override + public void sendNotification(String check, Object player, int violations) { + // Overrided by parent Bukkit/Bungee NotificationsModule + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java new file mode 100644 index 0000000..76b7596 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java @@ -0,0 +1,120 @@ +package dev._2lstudios.exploitfixer.shared.modules; + +import java.util.HashMap; +import java.util.Map; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.exploit.Violations; +import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; + +public class PacketsModule implements IViolationModule { + private final Map multipliers = new HashMap<>(); + private Violations violations; + private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, + reduceVls; + private int dataBytesBook, dataBytesSign, dataBytes, dataBytesDivider; + private boolean enabled, offline; + + public void reload(final IConfiguration configYml) { + final IConfiguration configurationSection = configYml.getSection("custompayload.multipliers"); + final String name = getName().toLowerCase(); + + this.enabled = configYml.getBoolean(name + ".enabled", false); + this.cancelVls = configYml.getDouble(name + ".cancel_vls", 0); + this.reduceVls = configYml.getDouble(name + ".reduce_vls", 0); + this.offline = configYml.getBoolean(name + ".offline", false); + this.dataVls = configYml.getDouble(name + ".data.vls", 0); + this.bookVls = configYml.getDouble(name + ".book", 0); + this.tagVls = configYml.getDouble(name + ".tag", 0); + this.dataBytes = configYml.getInt(name + ".data.bytes", 0); + this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 0); + this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 0); + this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 0); + this.windowClick = configYml.getDouble(name + ".window_click", 0); + this.blockPlaceVls = configYml.getDouble(name + ".block_place", 0); + this.blockDigVls = configYml.getDouble(name + ".block_dig", 0); + this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot", 0); + this.violations = new Violations(configYml.getSection(name + ".violations")); + + for (final String key : configurationSection.getKeys()) { + multipliers.put(key, configurationSection.getDouble(key, 0)); + } + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return "Packets"; + } + + @Override + public double getCancelVls() { + return cancelVls; + } + + @Override + public double getReduceVls() { + return reduceVls; + } + + @Override + public Violations getViolations() { + return violations; + } + + public double getMultiplier(final String packetName) { + return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); + } + + public double getWindowClick() { + return windowClick; + } + + public double getSetCreativeSlot() { + return setCreativeSlot; + } + + public double getBlockDigVls() { + return blockDigVls; + } + + public double getBlockPlaceVls() { + return blockPlaceVls; + } + + public double getDataVls() { + return dataVls; + } + + public double getBookVls() { + return bookVls; + } + + public double getTagVls() { + return tagVls; + } + + public int getDataBytes() { + return dataBytes; + } + + public int getDataBytesBook() { + return dataBytesBook; + } + + public int getDataBytesSign() { + return dataBytesSign; + } + + public boolean isOffline() { + return offline; + } + + public int getDataBytesDivider() { + return dataBytesDivider; + } +} diff --git a/src/messages.yml b/src/messages.yml index 1320380..ee40221 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -19,9 +19,7 @@ en: notifications: enable: "&aYou have enabled notifications!" disable: "&cYou have disabled notifications!" - stats: |- - &fPlayers cached: &a%players_cached% - &fPlayers punished: &a%players_punished% + stats: "&c&lEF: &ePlayers cached: &a%players_cached%&e Players punished: &a%players_punished%" modules: custompayload: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%discord%&r" @@ -51,9 +49,7 @@ es: notifications: enable: "&aHabilitaste las notificaciones!" disable: "&cDeshabilitaste las notificaciones!" - stats: |- - &fJugadores en cache: &a%players_cached% - &fJugadores sancionados: &a%players_punished% + stats: "&c&lEF: &eJugadores en cache: &a%players_cached%&e Jugadores sancionados: &a%players_punished%" modules: custompayload: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" @@ -83,9 +79,7 @@ pt: notifications: enable: "&cVocê ativou as notificações!" disable: "&cVocê desativou as notificações!" - stats: |- - &fJogadores em cache: &a%players_cached% - &fJogadores punidos: &a%players_punished% + stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" modules: custompayload: kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" @@ -115,9 +109,7 @@ it: notifications: enable: "&aHai abilitato le notifiche!" disable: "&cHai disabilitato le notifiche!" - stats: |- - &fGiocatori in cache: &a%players_cached% - &fGiocatori puniti: &a%players_punished% + stats: "&c&lEF: &eGiocatori in cache: &a%players_cached%&e Giocatori puniti: &a%players_punished%" modules: custompayload: kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%discord%&r" @@ -147,9 +139,7 @@ fr: notifications: enable: "&aVous avez activé les notifications!" disable: "&cVous avez désactivé les notifications!" - stats: |- - &fJoueurs caché: &a%players_cached% - &fJoueurs sanctionné: &a%players_punished% + stats: "&c&lEF: &eJoueurs caché: &a%players_cached%&e Joueurs sanctionné: &a%players_punished%" modules: custompayload: kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%discord%&r" @@ -166,7 +156,7 @@ tr: commands: reload: "&aPlugin ExploitFixer yeniden yüklendi!" help: |- - &aExploitFixer &b%version% &a &bLinsaFTW &a. + &aExploitFixer &b%version% &ayazan &bLinsaFTW&a. &e /%command% help &7> &bMevcut komutları gösterir. &e /%command% reload &7> &bEklentiyi yükler. &e /%command% notifications &7> &bEklentinin bildirimlerini değiştirir. @@ -178,9 +168,7 @@ tr: notifications: enable: "&aBildirimleri etkinleştirdiniz!" disable: "&cBildirimleri devre dışı bıraktınız!" - stats: |- - &fPlayers önbelleğe alındı: &a%players_cached% - &fPlayers cezalandırıldı: &a%players_punished% + stats: "&c&lEF: &ePlayers önbelleğe alındı: &a%players_cached%&e Players cezalandırıldı: &a%players_punished%" modules: custompayload: kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%discord%&r" diff --git a/src/plugin.yml b/src/plugin.yml index 255d565..d3bde79 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.5 +version: 1.4.6 author: 2LS api: "1.13" api-version: "1.13" From b48400b21d303f628ceb497a557d919164971124 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Mon, 3 Aug 2020 06:32:06 -0300 Subject: [PATCH 077/336] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6106f9..855fa07 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # ExploitFixer -Bukkit/BungeeCord plugin that aims on fixing Exploits in your Minecraft network. [Requires HamsterAPI to work] +Lightweight and highly customizable Bukkit/BungeeCord plugin that fixes Exploits related to invalid Packets. [Requires HamsterAPI to work] From eeba201f43e7565ecb7d4f5b591650fbc6c7d6b2 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Mon, 3 Aug 2020 10:23:11 -0300 Subject: [PATCH 078/336] Updated Source --- .../exploitfixer/bukkit/ExploitFixer.java | 6 ++-- .../bukkit/commands/ExploitFixerCommand.java | 15 ++++---- .../configuration/BukkitConfiguration.java | 24 ++++++------- .../bukkit/managers/ModuleManager.java | 15 +++----- .../bukkit/modules/BukkitMessagesModule.java | 6 ++-- .../bukkit/modules/ItemsFixModule.java | 9 +++-- .../exploitfixer/bungee/ExploitFixer.java | 2 +- .../bungee/commands/ExploitFixerCommand.java | 13 ++++--- .../configuration/BungeeConfiguration.java | 24 ++++++------- .../bungee/managers/ModuleManager.java | 36 ++++++++++++------- .../bungee/modules/BungeeMessagesModule.java | 6 ++-- .../shared/configuration/IConfiguration.java | 12 +++---- .../shared/exploit/Violations.java | 3 +- .../shared/modules/CommandsModule.java | 7 ++-- .../shared/modules/ConnectionModule.java | 7 ++-- .../shared/modules/NotificationsModule.java | 7 ++-- .../shared/modules/PacketsModule.java | 36 +++++++++---------- 17 files changed, 118 insertions(+), 110 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index da4c91f..18fd751 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -94,14 +94,14 @@ private boolean checkHamsterAPI() { } private void createConfigurations() { - this.configurationUtil.createConfiguration("%datafolder%/config.yml"); - this.configurationUtil.createConfiguration("%datafolder%/messages.yml"); + configurationUtil.createConfiguration("%datafolder%/config.yml"); + configurationUtil.createConfiguration("%datafolder%/messages.yml"); } private void register() { final Logger logger = this.getLogger(); - getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(moduleManager)); + getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(this, moduleManager)); logger.info("Successfully registered commands!"); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index 227ac14..ce5cd8e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -13,11 +13,13 @@ import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; public class ExploitFixerCommand implements CommandExecutor { - private BukkitMessagesModule messagesModule; - private BukkitNotificationsModule notificationsModule; - private ExploitPlayerManager exploitPlayerManager; + private final ExploitFixer exploitFixer; + private final BukkitMessagesModule messagesModule; + private final BukkitNotificationsModule notificationsModule; + private final ExploitPlayerManager exploitPlayerManager; - public ExploitFixerCommand(final ModuleManager moduleManager) { + public ExploitFixerCommand(final ExploitFixer exploitFixer, final ModuleManager moduleManager) { + this.exploitFixer = exploitFixer; this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -39,10 +41,11 @@ public boolean onCommand(final CommandSender commandSender, final Command comman commandSender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); } else if (args[0].equals("reload")) if (commandSender.hasPermission("exploitfixer.admin")) { - ExploitFixer.getInstance().reload(); + exploitFixer.reload(); commandSender.sendMessage(messagesModule.getReload(lang)); - } else + } else { commandSender.sendMessage(messagesModule.getPermission(lang)); + } else if (args[0].equals("stats")) if (commandSender.hasPermission("exploitfixer.admin")) commandSender.sendMessage(messagesModule.getStats(lang) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java index 01db4ba..2e5061b 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java @@ -25,37 +25,37 @@ public Collection getKeys() { } @Override - public Collection getStringList(final String path, final Collection def) { + public Collection getStringList(final String path) { if (configuration.contains(path)) { return new HashSet<>(configuration.getStringList(path)); } else { - return def; + return null; } } @Override - public String getString(final String path, final String def) { - return configuration.getString(path, def); + public String getString(final String path) { + return configuration.getString(path); } @Override - public double getDouble(final String path, final double def) { - return configuration.getDouble(path, def); + public double getDouble(final String path) { + return configuration.getDouble(path); } @Override - public long getLong(final String path, final long def) { - return configuration.getLong(path, def); + public long getLong(final String path) { + return configuration.getLong(path); } @Override - public int getInt(final String path, final int def) { - return configuration.getInt(path, def); + public int getInt(final String path) { + return configuration.getInt(path); } @Override - public boolean getBoolean(final String path, final boolean def) { - return configuration.getBoolean(path, def); + public boolean getBoolean(final String path) { + return configuration.getBoolean(path); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index 54eb1a2..0a77e1f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -1,7 +1,5 @@ package dev._2lstudios.exploitfixer.bukkit.managers; -import java.util.logging.Level; - import org.bukkit.Server; import org.bukkit.plugin.Plugin; @@ -14,7 +12,6 @@ import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; public class ModuleManager { - private Plugin plugin; private final CommandsModule commandsModule; private final ConnectionModule connectionModule; private final ItemsFixModule itemsFixModule; @@ -26,7 +23,6 @@ public class ModuleManager { public ModuleManager(final Plugin plugin) { final Server server = plugin.getServer(); - this.plugin = plugin; this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); this.itemsFixModule = new ItemsFixModule(plugin); @@ -45,14 +41,13 @@ public void reload(final IConfiguration configYml, final IConfiguration messages this.notificationsModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); - } catch (final NullPointerException e) { - final Server server = plugin.getServer(); - - server.getLogger().log(Level.SEVERE, + } catch (final NullPointerException exception) { + final NullPointerException newException = new NullPointerException( "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); - server.getPluginManager().disablePlugin(plugin); - e.printStackTrace(); + newException.setStackTrace(exception.getStackTrace()); + + throw newException; } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java index 6d0ad77..c57077c 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java @@ -16,15 +16,15 @@ public BukkitMessagesModule(final String version) { public void reload(final IConfiguration messagesYml) { this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord", ""); + this.discord = messagesYml.getString("discord"); } @Override public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path, null); + String string = messagesYml.getString(locale + path); if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path, null); + string = messagesYml.getString("en" + path); } if (string != null && !string.isEmpty()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index aba21e3..21d9f74 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -1,7 +1,6 @@ package dev._2lstudios.exploitfixer.bukkit.modules; import java.util.Collection; -import java.util.HashSet; import java.util.List; import org.bukkit.Material; @@ -30,10 +29,10 @@ public ItemsFixModule(final Plugin plugin) { final public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); - this.enabled = configYml.getBoolean(name + ".enabled", true); - this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); - this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); - this.blacklist = configYml.getStringList(name + ".blacklist", new HashSet<>()); + this.enabled = configYml.getBoolean(name + ".enabled"); + this.enchantLimit = configYml.getInt(name + ".enchant_limit"); + this.maxStackSize = configYml.getInt(name + ".max_stack_size"); + this.blacklist = configYml.getStringList(name + ".blacklist"); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index f10b7aa..ee44eb6 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -80,7 +80,7 @@ private void register() { pluginManager.unregisterCommands(this); pluginManager.registerCommand(this, - new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, moduleManager)); + new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, this, moduleManager)); logger.info("Successfully registered commands!"); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java index 98ba040..abab0c9 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java @@ -12,12 +12,15 @@ import net.md_5.bungee.api.plugin.Command; public class ExploitFixerCommand extends Command { - private MessagesModule messagesModule; - private NotificationsModule notificationsVariables; - private ExploitPlayerManager exploitPlayerManager; + private final ExploitFixer exploitFixer; + private final MessagesModule messagesModule; + private final NotificationsModule notificationsVariables; + private final ExploitPlayerManager exploitPlayerManager; - public ExploitFixerCommand(final String string, final String[] aliases, final ModuleManager moduleManager) { + public ExploitFixerCommand(final String string, final String[] aliases, final ExploitFixer exploitFixer, + final ModuleManager moduleManager) { super(string, null, aliases); + this.exploitFixer = exploitFixer; this.messagesModule = moduleManager.getMessagesModule(); this.notificationsVariables = moduleManager.getNotificationsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); @@ -37,7 +40,7 @@ public void execute(final CommandSender commandSender, final String[] args) { TextComponent.fromLegacyText(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); } else if (args[0].equals("reload")) if (commandSender.hasPermission("exploitfixer.admin")) { - ExploitFixer.getInstance().reload(); + exploitFixer.reload(); commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getReload(lang))); } else commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java index bc8f0ea..7811f6a 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java @@ -24,37 +24,37 @@ public Collection getKeys() { } @Override - public Collection getStringList(final String path, final Collection def) { + public Collection getStringList(final String path) { if (configuration.contains(path)) { return new HashSet<>(configuration.getStringList(path)); } else { - return def; + return null; } } @Override - public String getString(final String path, final String def) { - return configuration.getString(path, def); + public String getString(final String path) { + return configuration.getString(path); } @Override - public double getDouble(final String path, final double def) { - return configuration.getDouble(path, def); + public double getDouble(final String path) { + return configuration.getDouble(path); } @Override - public long getLong(final String path, final long def) { - return configuration.getLong(path, def); + public long getLong(final String path) { + return configuration.getLong(path); } @Override - public int getInt(final String path, final int def) { - return configuration.getInt(path, def); + public int getInt(final String path) { + return configuration.getInt(path); } @Override - public boolean getBoolean(final String path, final boolean def) { - return configuration.getBoolean(path, def); + public boolean getBoolean(final String path) { + return configuration.getBoolean(path); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index 2227052..9179d4c 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -1,5 +1,8 @@ package dev._2lstudios.exploitfixer.bungee.managers; +import org.apache.commons.lang.ObjectUtils.Null; +import org.bukkit.Server; + import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.BungeeNotificationsModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; @@ -12,12 +15,12 @@ import net.md_5.bungee.api.plugin.Plugin; public class ModuleManager { - private CommandsModule commandsModule; - private ConnectionModule connectionModule; - private PacketsModule packetsModule; - private BungeeMessagesModule messagesModule; - private NotificationsModule notificationsModule; - private ExploitPlayerManager exploitPlayerManager; + private final CommandsModule commandsModule; + private final ConnectionModule connectionModule; + private final PacketsModule packetsModule; + private final BungeeMessagesModule messagesModule; + private final NotificationsModule notificationsModule; + private final ExploitPlayerManager exploitPlayerManager; public ModuleManager(final Plugin plugin) { final ProxyServer server = plugin.getProxy(); @@ -31,12 +34,21 @@ public ModuleManager(final Plugin plugin) { } public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { - this.commandsModule.reload(configYml); - this.connectionModule.reload(configYml); - this.packetsModule.reload(configYml); - this.messagesModule.reload(messagesYml); - this.notificationsModule.reload(configYml); - this.exploitPlayerManager.reload(); + try { + this.commandsModule.reload(configYml); + this.connectionModule.reload(configYml); + this.packetsModule.reload(configYml); + this.messagesModule.reload(messagesYml); + this.notificationsModule.reload(configYml); + this.exploitPlayerManager.reload(); + } catch (final NullPointerException exception) { + final NullPointerException newException = new NullPointerException( + "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); + + newException.setStackTrace(exception.getStackTrace()); + + throw newException; + } } public CommandsModule getCommandsModule() { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java index 86d71dc..ad8e788 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java @@ -15,15 +15,15 @@ public BungeeMessagesModule(final String version) { public void reload(final IConfiguration messagesYml) { this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord", ""); + this.discord = messagesYml.getString("discord"); } @Override public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path, null); + String string = messagesYml.getString(locale + path); if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path, null); + string = messagesYml.getString("en" + path); } if (string != null && !string.isEmpty()) { diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java index 6cd97c0..ec0cbaa 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java @@ -7,17 +7,17 @@ public interface IConfiguration { public Collection getKeys(); - public Collection getStringList(final String string, final Collection arrayList); + public Collection getStringList(final String string); - public String getString(final String path, final String def); + public String getString(final String path); - public double getDouble(final String path, final double def); + public double getDouble(final String path); - public long getLong(final String path, final long def); + public long getLong(final String path); - public int getInt(final String path, final int def); + public int getInt(final String path); - public boolean getBoolean(final String path, final boolean def); + public boolean getBoolean(final String path); public Object getObject(); } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java index a4916a7..2b1e31d 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java @@ -2,7 +2,6 @@ import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; @@ -14,7 +13,7 @@ public Violations(final IConfiguration configuration) { if (configuration != null) { for (final String key : configuration.getKeys()) { try { - this.violations.put(Integer.parseInt(key), configuration.getStringList(key, new HashSet<>())); + this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); } catch (final NumberFormatException ignored) { } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java index 6f56cc4..6fc2082 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java @@ -1,7 +1,6 @@ package dev._2lstudios.exploitfixer.shared.modules; import java.util.Collection; -import java.util.HashSet; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; @@ -13,9 +12,9 @@ public class CommandsModule implements IPunishmentModule { public void reload(final IConfiguration configYml) { this.name = "Commands"; - this.enabled = configYml.getBoolean("commands.enabled", true); - this.commands = configYml.getStringList("commands.commands", new HashSet<>()); - this.punishments = configYml.getStringList("commands.punishments", new HashSet<>()); + this.enabled = configYml.getBoolean("commands.enabled"); + this.commands = configYml.getStringList("commands.commands"); + this.punishments = configYml.getStringList("commands.punishments"); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java index 675f059..2813535 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java @@ -1,7 +1,6 @@ package dev._2lstudios.exploitfixer.shared.modules; import java.util.Collection; -import java.util.HashSet; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; @@ -12,10 +11,10 @@ public class ConnectionModule implements IPunishmentModule { private Collection punishments; public void reload(final IConfiguration configYml) { - this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof", true); - this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress", true); + this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof"); + this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress"); this.name = "UUID-Spoof"; - this.punishments = configYml.getStringList("connection.punishments", new HashSet<>()); + this.punishments = configYml.getStringList("connection.punishments"); } public boolean isUUIDSpoofEnabled() { diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java index 51910c7..a743710 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -22,10 +22,9 @@ public String getMessage() { } public void reload(final IConfiguration configYml) { - this.enabled = configYml.getBoolean("notifications.enabled", true); - this.debug = configYml.getBoolean("notifications.debug", true); - this.message = configYml.getString("notifications.message", "[Message not found in configuration]").replace('&', - '\u00A7'); + this.enabled = configYml.getBoolean("notifications.enabled"); + this.debug = configYml.getBoolean("notifications.debug"); + this.message = configYml.getString("notifications.message").replace('&', '\u00A7'); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java index 76b7596..7fe86a6 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java @@ -16,28 +16,28 @@ public class PacketsModule implements IViolationModule { private boolean enabled, offline; public void reload(final IConfiguration configYml) { - final IConfiguration configurationSection = configYml.getSection("custompayload.multipliers"); final String name = getName().toLowerCase(); - - this.enabled = configYml.getBoolean(name + ".enabled", false); - this.cancelVls = configYml.getDouble(name + ".cancel_vls", 0); - this.reduceVls = configYml.getDouble(name + ".reduce_vls", 0); - this.offline = configYml.getBoolean(name + ".offline", false); - this.dataVls = configYml.getDouble(name + ".data.vls", 0); - this.bookVls = configYml.getDouble(name + ".book", 0); - this.tagVls = configYml.getDouble(name + ".tag", 0); - this.dataBytes = configYml.getInt(name + ".data.bytes", 0); - this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 0); - this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 0); - this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 0); - this.windowClick = configYml.getDouble(name + ".window_click", 0); - this.blockPlaceVls = configYml.getDouble(name + ".block_place", 0); - this.blockDigVls = configYml.getDouble(name + ".block_dig", 0); - this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot", 0); + final IConfiguration configurationSection = configYml.getSection(name + ".multipliers"); + + this.enabled = configYml.getBoolean(name + ".enabled"); + this.cancelVls = configYml.getDouble(name + ".cancel_vls"); + this.reduceVls = configYml.getDouble(name + ".reduce_vls"); + this.offline = configYml.getBoolean(name + ".offline"); + this.dataVls = configYml.getDouble(name + ".data.vls"); + this.bookVls = configYml.getDouble(name + ".book"); + this.tagVls = configYml.getDouble(name + ".tag"); + this.dataBytes = configYml.getInt(name + ".data.bytes"); + this.dataBytesBook = configYml.getInt(name + ".data.bytes_book"); + this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign"); + this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider"); + this.windowClick = configYml.getDouble(name + ".window_click"); + this.blockPlaceVls = configYml.getDouble(name + ".block_place"); + this.blockDigVls = configYml.getDouble(name + ".block_dig"); + this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); this.violations = new Violations(configYml.getSection(name + ".violations")); for (final String key : configurationSection.getKeys()) { - multipliers.put(key, configurationSection.getDouble(key, 0)); + multipliers.put(key, configurationSection.getDouble(key)); } } From 03fb7e2070c67dda8d4bf89015831a9e4d435785 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Tue, 11 Aug 2020 22:34:38 -0300 Subject: [PATCH 079/336] Updated Source --- src/bungee.yml | 2 +- src/config.yml | 3 + .../bukkit/commands/ExploitFixerCommand.java | 4 +- .../configuration/BukkitConfiguration.java | 5 ++ .../bukkit/listener/PacketDecodeListener.java | 58 +++++++++++-------- .../bukkit/listener/PlayerLoginListener.java | 4 +- .../bukkit/listener/PlayerQuitListener.java | 4 +- .../bukkit/managers/ExploitPlayerManager.java | 22 ++++--- .../bukkit/managers/ModuleManager.java | 10 ++-- .../bukkit/modules/BukkitMessagesModule.java | 37 ------------ .../configuration/BungeeConfiguration.java | 5 ++ .../bungee/listeners/ChatListener.java | 2 +- .../bungee/listeners/DisconnectListener.java | 14 ++--- .../listeners/PluginMessageListener.java | 2 +- .../bungee/listeners/PostLoginListener.java | 2 +- .../bungee/managers/ExploitPlayerManager.java | 14 +++-- .../bungee/managers/ModuleManager.java | 10 +--- .../bungee/modules/BungeeMessagesModule.java | 36 ------------ .../shared/configuration/IConfiguration.java | 2 + .../shared/modules/MessagesModule.java | 39 ++++++++++++- src/plugin.yml | 2 +- 21 files changed, 129 insertions(+), 148 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java diff --git a/src/bungee.yml b/src/bungee.yml index 77503a2..e85739c 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.6 +version: 1.4.7 author: 2LS commands: exploitfixer: diff --git a/src/config.yml b/src/config.yml index 516eb42..96e8568 100644 --- a/src/config.yml +++ b/src/config.yml @@ -12,6 +12,9 @@ # Most of the check use Violations (vls), this a counter to execute different # actions on diverse levels to allow high customization of the modules. +# Default language used by the plugin (This changes depending on the client language) +locale: "en" + # Shows notifications to console and players with permissions. notifications: enabled: true diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java index ce5cd8e..ac3a001 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java @@ -8,13 +8,13 @@ import dev._2lstudios.exploitfixer.bukkit.ExploitFixer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; public class ExploitFixerCommand implements CommandExecutor { private final ExploitFixer exploitFixer; - private final BukkitMessagesModule messagesModule; + private final MessagesModule messagesModule; private final BukkitNotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java index 2e5061b..5603e6b 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java @@ -58,6 +58,11 @@ public boolean getBoolean(final String path) { return configuration.getBoolean(path); } + @Override + public boolean contains(final String path) { + return configuration.contains(path); + } + @Override public Object getObject() { return configuration; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 8a02c40..96858d7 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -36,45 +36,55 @@ public void onPacketReceive(final PacketDecodeEvent event) { final Player player = hamsterPlayer.getPlayer(); if (player != null && player.isOnline()) { - final int dataBytes = packetsModule.getDataBytes(); final ByteBuf byteBuf = event.getByteBuf().get(); - final int refCnt = byteBuf.refCnt(); + final String playerName = player.getName(); + final int dataBytes = packetsModule.getDataBytes(), refCnt = byteBuf.refCnt(), + capacity = byteBuf.capacity(); - if (refCnt < 1) { + if (capacity < 0) { final double dataVls = packetsModule.getDataVls(); - final String playerName = player.getName(), reason = "[Decoder|Data] " + playerName - + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; + final String reason = "[Decoder|Data] " + playerName + + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; - cancelExploit(event, hamsterPlayer, reason, dataVls); - } else if (byteBuf.capacity() > dataBytes) { + cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } else if (refCnt < 1) { final double dataVls = packetsModule.getDataVls(); - final String playerName = player.getName(), reason = "[Decoder|Data] " + playerName - + " sent a packet that exceeds size limit! Max: " + dataBytes + " Vls: " + dataVls; + final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid refCnt! refCnt: " + + refCnt + " Vls: " + dataVls; - cancelExploit(event, hamsterPlayer, reason, dataVls); + cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } else if (capacity > dataBytes) { + final double dataVls = packetsModule.getDataVls(); + final String reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds size limit! Max: " + + dataBytes + " Vls: " + dataVls; + + cancelExploit(event, hamsterPlayer, player, reason, dataVls); } } else if (packetsModule.isOffline()) { - if (player == null) { - notificationsModule.debug("[Decoder|Offline] unknown sent a packet while offline!"); - } else { - notificationsModule.debug("[Decoder|Offline] " + player.getName() + " sent a packet while offline!"); - } + final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; - event.setCancelled(true); + cancelExploit(event, hamsterPlayer, player, reason, 0); hamsterPlayer.closeChannel(); - - return; } } - private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final String reason, - final double vls) { - final Player player = hamsterPlayer.getPlayer(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + private String getName(final Player player) { + if (player == null) { + return "unknown"; + } else { + return player.getName(); + } + } + private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, + final String reason, final double vls) { notificationsModule.debug(reason); - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + + if (vls > 0) { + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + } } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index e27200b..48bba35 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -15,7 +15,7 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import java.net.InetAddress; @@ -24,7 +24,7 @@ public class PlayerLoginListener implements Listener { private final Plugin plugin; private final BukkitNotificationsModule notificationsModule; - private final BukkitMessagesModule messagesModule; + private final MessagesModule messagesModule; private final ConnectionModule connectionModule; private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java index f97744d..8c0317e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java @@ -5,10 +5,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; @@ -22,7 +22,7 @@ public class PlayerQuitListener implements Listener { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); exploitPlayer.clear(); exploitPlayer.setLogged(false); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 6053d81..b8dc98f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -22,8 +22,6 @@ public class ExploitPlayerManager { this.plugin = plugin; this.server = server; this.moduleManager = moduleManager; - - reload(); } public BukkitExploitPlayer get(final Player player) { @@ -40,6 +38,16 @@ public BukkitExploitPlayer get(final Player player) { return exploitPlayer; } + public void reload() { + exploitPlayers.clear(); + + for (final Player player : server.getOnlinePlayers()) { + final BukkitExploitPlayer exploitPlayer = get(player); + + exploitPlayer.setLogged(true); + } + } + public void clear() { final Iterator iterator = exploitPlayers.keySet().iterator(); boolean cleared = false; @@ -58,16 +66,6 @@ public void clear() { } } - public void reload() { - exploitPlayers.clear(); - - for (final Player player : server.getOnlinePlayers()) { - final BukkitExploitPlayer exploitPlayer = get(player); - - exploitPlayer.setLogged(true); - } - } - public int getSize() { return exploitPlayers.size(); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index 0a77e1f..52dab51 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -3,19 +3,19 @@ import org.bukkit.Server; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitMessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; public class ModuleManager { private final CommandsModule commandsModule; private final ConnectionModule connectionModule; private final ItemsFixModule itemsFixModule; - private final BukkitMessagesModule messagesModule; + private final MessagesModule messagesModule; private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; @@ -26,7 +26,7 @@ public ModuleManager(final Plugin plugin) { this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); this.itemsFixModule = new ItemsFixModule(plugin); - this.messagesModule = new BukkitMessagesModule(plugin.getDescription().getVersion()); + this.messagesModule = new MessagesModule(plugin.getDescription().getVersion()); this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), plugin.getLogger(), server); this.packetsModule = new PacketsModule(); this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); @@ -37,7 +37,7 @@ public void reload(final IConfiguration configYml, final IConfiguration messages this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); this.itemsFixModule.reload(configYml); - this.messagesModule.reload(messagesYml); + this.messagesModule.reload(configYml, messagesYml); this.notificationsModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); @@ -63,7 +63,7 @@ public ItemsFixModule getItemsFixModule() { return itemsFixModule; } - public BukkitMessagesModule getMessagesModule() { + public MessagesModule getMessagesModule() { return messagesModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java deleted file mode 100644 index c57077c..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitMessagesModule.java +++ /dev/null @@ -1,37 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; - -import org.bukkit.ChatColor; - -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; - -public class BukkitMessagesModule extends MessagesModule { - private final String version; - private IConfiguration messagesYml; - private String discord; - - public BukkitMessagesModule(final String version) { - this.version = version; - } - - public void reload(final IConfiguration messagesYml) { - this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord"); - } - - @Override - public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); - } - - if (string != null && !string.isEmpty()) { - return ChatColor.translateAlternateColorCodes('&', - string.replace("%version%", version).replace("%discord%", discord)); - } else { - return ""; - } - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java index 7811f6a..16dfb34 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java @@ -57,6 +57,11 @@ public boolean getBoolean(final String path) { return configuration.getBoolean(path); } + @Override + public boolean contains(final String path) { + return configuration.contains(path); + } + @Override public Object getObject() { return configuration; diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index 9b73f43..e922a76 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -27,7 +27,7 @@ public void onChat(final ChatEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer player = (ProxiedPlayer) connection; - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (!exploitPlayer.isLogged()) { event.setCancelled(true); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java index fd117e4..bd79edb 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java @@ -1,8 +1,8 @@ package dev._2lstudios.exploitfixer.bungee.listeners; -import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; @@ -20,13 +20,11 @@ public class DisconnectListener implements Listener { @EventHandler public void onDisconnect(final PlayerDisconnectEvent event) { - final ProxiedPlayer proxiedPlayer = event.getPlayer(); - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(proxiedPlayer.getUniqueId(), proxiedPlayer); + final ProxiedPlayer player = event.getPlayer(); + final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (exploitPlayer != null) { - exploitPlayer.clear(); - } - - notificationsModule.setNotifications(proxiedPlayer.getName(), false); + exploitPlayer.clear(); + exploitPlayer.setLogged(false); + notificationsModule.setNotifications(player.getName(), false); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java index 6535aba..84bfa5b 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java @@ -29,7 +29,7 @@ public void onPluginMessage(final PluginMessageEvent event) { if (connection instanceof ProxiedPlayer) { final ProxiedPlayer player = (ProxiedPlayer) connection; - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player.getUniqueId(), player); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); final String tag = event.getTag(), playerName = player.getName(); final double tagVls = packetsModule.getTagVls(), dataVls = packetsModule.getDataVls(); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index e470b46..709a561 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -45,7 +45,7 @@ public void onPostLogin(final PostLoginEvent event) { player.disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); } else { final UUID originalUUID = player.getUniqueId(); - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(originalUUID, player); + final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (connectionModule.isUUIDSpoofEnabled()) { final TaskScheduler scheduler = plugin.getProxy().getScheduler(); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index 98a51d5..8ca5910 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -6,6 +6,7 @@ import java.util.UUID; import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; +import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -18,14 +19,15 @@ public class ExploitPlayerManager { ExploitPlayerManager(final ProxyServer server, final ModuleManager moduleManager) { this.server = server; this.moduleManager = moduleManager; - - reload(); } - public BungeeExploitPlayer get(final UUID uuid, final ProxiedPlayer player) { - BungeeExploitPlayer exploitPlayer = exploitPlayers.getOrDefault(uuid, null); + public BungeeExploitPlayer get(final ProxiedPlayer player) { + final UUID uuid = player.getUniqueId(); + final BungeeExploitPlayer exploitPlayer; - if (exploitPlayer == null) { + if (exploitPlayers.containsKey(uuid)) { + exploitPlayer = exploitPlayers.get(uuid); + } else { exploitPlayer = new BungeeExploitPlayer(server, player.getName(), moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -37,7 +39,7 @@ public void reload() { exploitPlayers.clear(); for (final ProxiedPlayer player : server.getPlayers()) { - final BungeeExploitPlayer exploitPlayer = get(player.getUniqueId(), player); + final ExploitPlayer exploitPlayer = get(player); exploitPlayer.setLogged(true); } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index 9179d4c..2308b3e 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -1,9 +1,5 @@ package dev._2lstudios.exploitfixer.bungee.managers; -import org.apache.commons.lang.ObjectUtils.Null; -import org.bukkit.Server; - -import dev._2lstudios.exploitfixer.bungee.modules.BungeeMessagesModule; import dev._2lstudios.exploitfixer.bungee.modules.BungeeNotificationsModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; @@ -18,7 +14,7 @@ public class ModuleManager { private final CommandsModule commandsModule; private final ConnectionModule connectionModule; private final PacketsModule packetsModule; - private final BungeeMessagesModule messagesModule; + private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; @@ -28,7 +24,7 @@ public ModuleManager(final Plugin plugin) { this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); this.packetsModule = new PacketsModule(); - this.messagesModule = new BungeeMessagesModule(plugin.getDescription().getVersion()); + this.messagesModule = new MessagesModule(plugin.getDescription().getVersion()); this.notificationsModule = new BungeeNotificationsModule(server.getConsole(), plugin.getLogger(), server); this.exploitPlayerManager = new ExploitPlayerManager(server, this); } @@ -38,7 +34,7 @@ public void reload(final IConfiguration configYml, final IConfiguration messages this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); this.packetsModule.reload(configYml); - this.messagesModule.reload(messagesYml); + this.messagesModule.reload(configYml, messagesYml); this.notificationsModule.reload(configYml); this.exploitPlayerManager.reload(); } catch (final NullPointerException exception) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java deleted file mode 100644 index ad8e788..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeMessagesModule.java +++ /dev/null @@ -1,36 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import net.md_5.bungee.api.ChatColor; - -public class BungeeMessagesModule extends MessagesModule { - private final String version; - private IConfiguration messagesYml; - private String discord; - - public BungeeMessagesModule(final String version) { - this.version = version; - } - - public void reload(final IConfiguration messagesYml) { - this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord"); - } - - @Override - public String getString(final String locale, final String path) { - String string = messagesYml.getString(locale + path); - - if (string == null || string.isEmpty()) { - string = messagesYml.getString("en" + path); - } - - if (string != null && !string.isEmpty()) { - return ChatColor.translateAlternateColorCodes('&', - string.replace("%version%", version).replace("%discord%", discord)); - } else { - return ""; - } - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java index ec0cbaa..c35c9ef 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java @@ -20,4 +20,6 @@ public interface IConfiguration { public boolean getBoolean(final String path); public Object getObject(); + + public boolean contains(final String string); } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index e3d153f..17dbaa4 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -1,13 +1,48 @@ package dev._2lstudios.exploitfixer.shared.modules; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.interfaces.IMessagesModule; import dev._2lstudios.exploitfixer.shared.interfaces.IModule; public class MessagesModule implements IMessagesModule { + private final String version; + private IConfiguration messagesYml; + private String discord, locale; + + public MessagesModule(final String version) { + this.version = version; + } + + public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { + this.messagesYml = messagesYml; + this.discord = messagesYml.getString("discord"); + + final String locale = configYml.getString("locale"); + + if (locale != null) { + this.locale = locale; + } else { + this.locale = "en"; + } + } + @Override public String getString(final String locale, final String path) { - // Overrided by parent Bukkit/Bungee MessagesModule - return null; + final String string; + + if (messagesYml.contains(locale + path)) { + string = messagesYml.getString(locale + path); + } else if (messagesYml.contains(this.locale + path)) { + string = messagesYml.getString(this.locale + path); + } else { + string = ""; + } + + if (string != null) { + return string.replace("%version%", version).replace("%discord%", discord).replace('&', '\u00a7'); + } else { + return string; + } } public boolean isEnabled() { diff --git a/src/plugin.yml b/src/plugin.yml index d3bde79..4d2133c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.6 +version: 1.4.7 author: 2LS api: "1.13" api-version: "1.13" From 3bbf7dfae9d7ec122438f28746c7b02415fe3c35 Mon Sep 17 00:00:00 2001 From: Kuglof Date: Sun, 16 Aug 2020 15:52:52 +0200 Subject: [PATCH 080/336] Added Hungarian language --- src/messages.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/messages.yml b/src/messages.yml index ee40221..80e75bd 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -179,4 +179,34 @@ tr: packets: kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%discord%&r" nulladdress: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%discord%&r" \ No newline at end of file + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%discord%&r" + +#Hungarian +hu: + commands: + reload: "&aAz ExploitFixer sikeresen újraindult!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bElérhető parancsok. + &e /%command% reload &7> &bPlugin újraindítása. + &e /%command% notifications &7> &bÉrtesítések ki/be kapcsolása. + &e /%command% stats &7> &bA plugin statisztikáinak megtekintése. + error: + unknown: "&cIsmeretlen parancs. Használd a /exploitfixer help parancsot!" + permission: "&cNincs jogod a parancs használatához!" + console: "&cEzt a parancsot nem bírod használni a konzolból!" + notifications: + enable: "&aBekapcsoltad az értesítéseket!" + disable: "&cKikapcsoltad az értesítéseket!" + stats: "&c&lEF: &eJátékosok: &a%players_cached%&e Büntetések: &a%players_punished%" + modules: + custompayload: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" + uuidspoof: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fUUID Spoofingot észleltünk.\n&7Discord: &b&n%discord%&r" + commands: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + packets: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fCsomag exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + nulladdress: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fNull addresst észleltünk.\n&7Discord: &b&n%discord%&r" From ae850b0f76a0a5d211bb61462ec2d6c58bceaaec Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Tue, 1 Sep 2020 16:51:07 -0300 Subject: [PATCH 081/336] Updated Source --- .../bukkit/listener/ListenerInitializer.java | 10 +- .../bukkit/listener/PacketDecodeListener.java | 249 +++++++++++-- .../listener/PacketReceiveListener.java | 339 ------------------ .../bukkit/managers/ExploitPlayerManager.java | 2 +- .../modules/BukkitNotificationsModule.java | 9 +- .../bukkit/modules/ItemsFixModule.java | 1 - .../bukkit/utils/ConfigurationUtil.java | 45 +-- .../bukkit/utils/ExploitUtil.java | 158 ++++++++ 8 files changed, 418 insertions(+), 395 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index 58afa9f..3ba7bba 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -6,6 +6,9 @@ import org.bukkit.plugin.PluginManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.utils.BufferIO; public class ListenerInitializer { private final Plugin plugin; @@ -20,11 +23,12 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage public void register() { this.registered = true; - final Server server = this.plugin.getServer(); + final Server server = plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); + final BufferIO bufferIO = HamsterAPI.getInstance().getBufferIO(); + final ExploitUtil exploitUtil = new ExploitUtil(moduleManager, plugin); - pluginManager.registerEvents(new PacketDecodeListener(plugin, moduleManager), plugin); - pluginManager.registerEvents(new PacketReceiveListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PacketDecodeListener(plugin, bufferIO, exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 96858d7..8f15c48 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -1,45 +1,246 @@ package dev._2lstudios.exploitfixer.bukkit.listener; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Map; + +import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.utils.BufferIO; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; import io.netty.buffer.ByteBuf; +import io.netty.handler.codec.DecoderException; public class PacketDecodeListener implements Listener { private final Plugin plugin; + private final BufferIO bufferIO; + private final ExploitUtil exploitUtil; private final ExploitPlayerManager exploitPlayerManager; + private final ItemsFixModule itemsFixModule; private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; - PacketDecodeListener(final Plugin plugin, final ModuleManager moduleManager) { + PacketDecodeListener(final Plugin plugin, final BufferIO bufferIO, final ExploitUtil exploitUtil, + final ModuleManager moduleManager) { HamsterAPI.getInstance().getBufferIO(); this.plugin = plugin; + this.bufferIO = bufferIO; + this.exploitUtil = exploitUtil; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); } + private String getName(final Player player) { + if (player == null) { + return "unknown"; + } else { + return player.getName(); + } + } + + private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, + final String reason, final double vls) { + notificationsModule.debug(reason); + event.setCancelled(true); + + if (vls > 0) { + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + } + } + + public void onPacketReceive(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, + final PacketWrapper packetWrapper) { + final PacketType packetType = packetWrapper.getType(); + + if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { + final Map strings = packetWrapper.getStrings(); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final String playerName = player.getName(); + final String packetName = packetWrapper.getName(); + final double dataVls = packetsModule.getDataVls(); + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(); + final double setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = packetsModule.getTagVls(); + final double bookVls = packetsModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + final String reason = "[" + packetName + "|Tag] " + playerName + + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; + + cancelExploit(event, hamsterPlayer, player, reason, tagVls); + return; + } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") + || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + + " CustomPayload packet without a book in hand!"; + + cancelExploit(event, hamsterPlayer, player, reason, bookVls); + return; + } + } + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); + } else { + notificationsModule + .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); + + event.setCancelled(true); + } + } + + if (windowClick > 0 && integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999 && slot != -1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick; + + cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } else if (slot >= maxSlots) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + + cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot + && player.getGameMode() != GameMode.CREATIVE) { + final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; + + cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); + return; + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + final int dataBytes = packetsModule.getDataBytes(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, + packetName, dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize + + " bytes long!"; + + cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { + final String reason = "[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls; + + cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + final Map items = packetWrapper.getItems(); + + if (itemsFixModule.isEnabled() && items.containsKey("b")) { + final ItemStack itemStack = items.get("b"); + + if (itemStack != null) { + final String blocked = exploitUtil.clearIfBlocked(itemStack); + final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); + + packetWrapper.write("b", fixedItemStack); + + if (player != null) { + if (blocked != null) { + notificationsModule.debug( + player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); + } else { + notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); + } + } + } + } + } + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPacketReceive(final PacketDecodeEvent event) { + public void onPacketDecode(final PacketDecodeEvent event) { final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); final Player player = hamsterPlayer.getPlayer(); if (player != null && player.isOnline()) { - final ByteBuf byteBuf = event.getByteBuf().get(); + final ByteBuf byteBuf = event.getByteBuf().get().copy(); final String playerName = player.getName(); - final int dataBytes = packetsModule.getDataBytes(), refCnt = byteBuf.refCnt(), - capacity = byteBuf.capacity(); + final int dataBytes = packetsModule.getDataBytes(); + final int refCnt = byteBuf.refCnt(); + final int capacity = byteBuf.capacity(); if (capacity < 0) { final double dataVls = packetsModule.getDataVls(); @@ -59,32 +260,28 @@ public void onPacketReceive(final PacketDecodeEvent event) { + dataBytes + " Vls: " + dataVls; cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } else { + try { + final String reason = "[Decoder|Offline] " + getName(player) + + " sent a null packet! (Player offline?)"; + final PacketWrapper packet = bufferIO.decode(event.getChannelHandlerContext(), byteBuf, dataBytes); + + if (packet != null) { + onPacketReceive(event, hamsterPlayer, player, packet); + } else { + cancelExploit(event, hamsterPlayer, player, reason, 0); + hamsterPlayer.disconnect(reason); + } + } catch (final DecoderException | IllegalAccessException | InvocationTargetException + | NoSuchMethodException | InstantiationException | NoSuchFieldException | IOException e) { + e.printStackTrace(); + } } } else if (packetsModule.isOffline()) { final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; cancelExploit(event, hamsterPlayer, player, reason, 0); - hamsterPlayer.closeChannel(); - } - } - - private String getName(final Player player) { - if (player == null) { - return "unknown"; - } else { - return player.getName(); - } - } - - private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, - final String reason, final double vls) { - notificationsModule.debug(reason); - event.setCancelled(true); - - if (vls > 0) { - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + hamsterPlayer.disconnect(reason); } } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java deleted file mode 100644 index 553ca54..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ /dev/null @@ -1,339 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; - -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; - -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; - -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.hamsterapi.enums.PacketType; -import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; - -public class PacketReceiveListener implements Listener { - private final Plugin plugin; - private final ExploitPlayerManager exploitPlayerManager; - private final ItemsFixModule itemsFixModule; - private final BukkitNotificationsModule notificationsModule; - private final PacketsModule packetsModule; - - PacketReceiveListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.itemsFixModule = moduleManager.getItemsFixModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.packetsModule = moduleManager.getPacketsModule(); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPacketReceive(final PacketReceiveEvent event) { - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - final Player player = hamsterPlayer.getPlayer(); - final PacketWrapper packetWrapper = event.getPacket(); - final PacketType packetType = packetWrapper.getType(); - - if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { - final Map strings = packetWrapper.getStrings(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String playerName = player.getName(), packetName = packetWrapper.getName(); - final double dataVls = packetsModule.getDataVls(); - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(), - setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = packetsModule.getTagVls(), bookVls = packetsModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - notificationsModule.debug("[" + packetName + "|Tag] " + playerName - + " sent a CustomPayload packet without TAG! Added vls: " + tagVls); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, tagVls); - return; - } else if (bookVls > 0) { - if (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - notificationsModule.debug("[" + packetName + "|Book] " + playerName - + " tried to send a " + tag + " CustomPayload packet without a book in hand!"); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, bookVls); - return; - } - } - } - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); - } else { - notificationsModule - .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); - - event.setCancelled(true); - } - } - - if (windowClick > 0 && integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(), - bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999 && slot != -1) { - notificationsModule.debug("[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); - return; - } else if (slot >= maxSlots) { - notificationsModule - .debug("[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" - + slot + "/" + maxSlots + ") Added vls: " + windowClick); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, windowClick); - return; - } - } - - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot) { - if (player.getGameMode() != GameMode.CREATIVE) { - notificationsModule.debug("[" + packetName + "|SetCreativeSlot] " + playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, setCreativeSlot); - return; - } - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - final int dataBytes = packetsModule.getDataBytes(); - - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, packetName, - dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; - } - } - } - - if (dataBytes > 0 && packetSize > dataBytes) { - notificationsModule.debug("[" + packetName + "|Data] " + playerName + " sent a packet of " - + packetSize + " bytes long!"); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && parseSign(strings.values().toArray(new String[0]))) { - notificationsModule.debug("[" + packetName + "|Data] " + playerName - + " has sent a too big sign packet! Added vls: " + dataVls); - - event.setCancelled(true); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, dataVls); - return; - } - } - - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); - } - - final Map items = packetWrapper.getItems(); - - if (itemsFixModule.isEnabled() && items.containsKey("b")) { - final ItemStack itemStack = items.get("b"); - - if (itemStack != null) { - final String blocked = clearIfBlocked(itemStack); - final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); - - packetWrapper.write("b", fixedItemStack); - - if (player != null) { - if (blocked != null) { - notificationsModule.debug( - player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); - } else { - notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); - } - } - } - } - } - - private int parseItemLength(final ItemStack itemStack, final BukkitExploitPlayer exploitPlayer, - final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { - int itemBytesLength = 0; - - if (itemStack != null) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - - try { - itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final Exception exception) { - notificationsModule - .debug("[" + packetName + "] There was an exception when processing itemStack data to String!"); - } - - if (itemStack.hasItemMeta() && itemMeta != null) { - try { - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += parseItemLength(itemStack1, exploitPlayer, hamsterPlayer, - packetName, itemBytesMax); - - if (itemBytesLength > itemBytesMax) { - return itemBytesLength; - } - } - } - } - } else { - throw new NullPointerException(); - } - } catch (final NullPointerException e1) { - if (itemMeta instanceof BookMeta) { - itemBytesLength += parseBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); - } else { - try { - itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e2) { - itemBytesLength += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; - } - } - } - } - } - - return itemBytesLength; - } - - private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, - final ItemMeta itemMeta, final String packetName) { - final Player player = hamsterPlayer.getPlayer(); - final BookMeta bookMeta = (BookMeta) itemMeta; - final double dataVls = packetsModule.getDataVls(); - final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); - int bookTotalBytes = 0; - - if (dataVls > 0 && pageCount > 50) { - notificationsModule.debug("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " - + dataVls); - - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); - } else { - for (final String page : bookMeta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; - - bookTotalBytes += pageBytes; - - if (dataVls > 0 && pageBytes > dataBytesBook) { - notificationsModule.debug("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" - + dataBytesBook + ") Added vls: " + dataVls); - - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); - break; - } - } - - return bookTotalBytes; - } - - return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } - - private boolean parseSign(final String[] linesString) { - final int dataBytesSign = packetsModule.getDataBytesSign(); - - if (linesString != null) { - if (linesString.length > 4) { - return true; - } else { - for (final String line : linesString) { - if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { - return true; - } - } - } - } - - return false; - } - - private String clearIfBlocked(final ItemStack itemStack) { - final String materialName = itemStack.getType().toString(); - - for (final String blockedMaterial : itemsFixModule.getBlacklist()) { - if (materialName.equals(blockedMaterial)) { - itemStack.setType(Material.AIR); - itemStack.setItemMeta(null); - return materialName; - } - } - - return null; - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index b8dc98f..0448f03 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -75,6 +75,6 @@ public int getPunishments() { } public int addPunishment() { - return punishments += 1; + return punishments++; } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java index fce33e8..e4c0129 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java @@ -18,6 +18,7 @@ public BukkitNotificationsModule(final CommandSender console, final Logger logge this.server = server; } + @Override public void sendNotification(final String check, final Object player, final int violations) { if (isEnabled() && player != null) { final Player player1 = (Player) player; @@ -38,14 +39,12 @@ public void sendNotification(final String check, final Object player, final int } private int getPing(final Player player) { - int ping = 0; - try { final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); - ping = (int) playerHandle.getClass().getField("ping").get(playerHandle); + + return (int) playerHandle.getClass().getField("ping").get(playerHandle); } catch (final Exception ignored) { + return 0; } - - return ping; } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 21d9f74..117ce56 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -61,7 +61,6 @@ public ItemStack fixItem(final ItemStack itemStack) { final Material material = Material.getMaterial(itemStack.getType().name()); final ItemMeta oldItemMeta = itemStack.getItemMeta(), newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final int maxStackSize = getMaxStackSize(); final short durability = itemStack.getDurability(); if (itemStack.hasItemMeta()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java index f140abd..ee77d44 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java @@ -7,19 +7,23 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.util.logging.Level; +import java.nio.file.Path; import java.util.logging.Logger; public class ConfigurationUtil { - final private Plugin plugin; + private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; + private final String dataFolderPath; + private final String prefix; + private final Plugin plugin; public ConfigurationUtil(final Plugin plugin) { this.plugin = plugin; + this.dataFolderPath = plugin.getDataFolder().toString(); + this.prefix = "[" + plugin.getName() + "]"; } public YamlConfiguration getConfiguration(String filePath) { - final File dataFolder = plugin.getDataFolder(); - final File file = new File(filePath.replace("%datafolder%", dataFolder.toPath().toString())); + final File file = new File(filePath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); if (file.exists()) { return YamlConfiguration.loadConfiguration(file); @@ -32,9 +36,7 @@ public void createConfiguration(String file) { final Logger logger = plugin.getLogger(); try { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); + file = file.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); final File configFile = new File(file); @@ -44,41 +46,44 @@ public void createConfiguration(String file) { .getResourceAsStream(files[files.length - 1]); final File parentFile = configFile.getParentFile(); - if (parentFile != null) + if (parentFile != null) { parentFile.mkdirs(); + } if (inputStream != null) { Files.copy(inputStream, configFile.toPath()); - logger.log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") - .replace("%pluginname%", plugin.getDescription().getName())); - } else + } else { configFile.createNewFile(); + } + + logger.info(prefix + " File '" + file + "' has been created!"); } } catch (final IOException e) { - logger.log(Level.INFO, ("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", - plugin.getDescription().getName())); + logger.info(prefix + " Unable to create '" + file + "'!"); } } public void saveConfiguration(final YamlConfiguration yamlConfiguration, final String file) { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { try { - final File dataFolder = plugin.getDataFolder(); + yamlConfiguration.save(file.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); - yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString())); + plugin.getLogger().info(prefix + " File '" + file + "' has been saved!"); } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") - .replace("%pluginname%", plugin.getDescription().getName())); + plugin.getLogger().info(prefix + " Unable to save '" + file + "'!"); } }); } public void deleteConfiguration(final String file) { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - final File file1 = new File(file); + try { + Files.delete(Path.of(file)); - if (file1.exists()) - file1.delete(); + plugin.getLogger().info(prefix + " File '" + file + "' has been removed!"); + } catch (IOException e) { + plugin.getLogger().info(prefix + " Unable to remove '" + file + "'!"); + } }); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java new file mode 100644 index 0000000..646252c --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -0,0 +1,158 @@ +package dev._2lstudios.exploitfixer.bukkit.utils; + +import java.nio.charset.StandardCharsets; + +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; + +public class ExploitUtil { + private final ItemsFixModule itemsFixModule; + private final NotificationsModule notificationsModule; + private final PacketsModule packetsModule; + private final Plugin plugin; + + public ExploitUtil(final ModuleManager moduleManager, final Plugin plugin) { + this.itemsFixModule = moduleManager.getItemsFixModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + this.plugin = plugin; + } + + private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, + final ItemMeta itemMeta, final String packetName) { + final Player player = hamsterPlayer.getPlayer(); + final BookMeta bookMeta = (BookMeta) itemMeta; + final double dataVls = packetsModule.getDataVls(); + final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); + int bookTotalBytes = 0; + + if (dataVls > 0 && pageCount > 50) { + notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " + + dataVls); + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + } else { + for (final String page : bookMeta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + bookTotalBytes += pageBytes; + + if (dataVls > 0 && pageBytes > dataBytesBook) { + notificationsModule.debug("[" + packetName + "|Book] " + player.getName() + + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" + + dataBytesBook + ") Added vls: " + dataVls); + + exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + break; + } + } + + return bookTotalBytes; + } + + return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } + + public int parseItemLength(final ItemStack itemStack, final BukkitExploitPlayer exploitPlayer, + final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { + int itemBytesLength = 0; + + if (itemStack != null) { + final ItemMeta itemMeta = itemStack.getItemMeta(); + + try { + itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final Exception exception) { + notificationsModule + .debug("[" + packetName + "] There was an exception when processing itemStack data to String!"); + } + + if (itemStack.hasItemMeta() && itemMeta != null) { + try { + if (itemMeta instanceof BlockStateMeta) { + final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; + + if (blockStateMeta.hasBlockState()) { + final BlockState blockState = blockStateMeta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { + itemBytesLength += parseItemLength(itemStack1, exploitPlayer, hamsterPlayer, + packetName, itemBytesMax); + + if (itemBytesLength > itemBytesMax) { + return itemBytesLength; + } + } + } + } + } else { + throw new NullPointerException(); + } + } catch (final NullPointerException e1) { + if (itemMeta instanceof BookMeta) { + itemBytesLength += parseBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); + } else { + try { + itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + } catch (final NullPointerException e2) { + itemBytesLength += (itemMeta.getClass().getName() + "@" + + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; + } + } + } + } + } + + return itemBytesLength; + } + + public boolean parseSign(final String[] linesString) { + final int dataBytesSign = packetsModule.getDataBytesSign(); + + if (linesString != null) { + if (linesString.length > 4) { + return true; + } else { + for (final String line : linesString) { + if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { + return true; + } + } + } + } + + return false; + } + + public String clearIfBlocked(final ItemStack itemStack) { + final String materialName = itemStack.getType().toString(); + + for (final String blockedMaterial : itemsFixModule.getBlacklist()) { + if (materialName.equals(blockedMaterial)) { + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + return materialName; + } + } + + return null; + } +} From 21a3cb09458ca16eebd0a28724ad2881ad1882ed Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Tue, 1 Sep 2020 16:53:50 -0300 Subject: [PATCH 082/336] Updated Version Number --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index 4d2133c..065e826 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.7 +version: 1.4.8 author: 2LS api: "1.13" api-version: "1.13" From bf65b39492dd86b1b844a59fcf6abec57ace6672 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Fri, 18 Sep 2020 00:11:31 -0300 Subject: [PATCH 083/336] Updated Source --- .../exploitfixer/bukkit/ExploitFixer.java | 42 ++- .../configuration/BukkitConfiguration.java | 17 +- .../bukkit/listener/ListenerInitializer.java | 6 +- .../bukkit/listener/PacketDecodeListener.java | 250 ++---------------- .../listener/PacketReceiveListener.java | 210 +++++++++++++++ .../bukkit/listener/PlayerLoginListener.java | 21 +- .../bukkit/managers/ModuleManager.java | 20 +- .../bukkit/utils/BukkitConfigurationUtil.java | 105 ++++++++ .../bukkit/utils/ExploitUtil.java | 20 +- .../exploitfixer/bungee/ExploitFixer.java | 45 ++-- .../configuration/BungeeConfiguration.java | 17 +- .../bungee/listeners/PostLoginListener.java | 14 +- .../bungee/managers/ModuleManager.java | 22 +- .../bungee/utils/BungeeConfigurationUtil.java | 112 ++++++++ .../shared/configuration/IConfiguration.java | 2 + .../shared/exploit/ExploitPlayer.java | 35 ++- .../shared/interfaces/IConfigurationUtil.java | 13 + .../shared/modules/MessagesModule.java | 128 ++++++--- src/resources/bungee.yml | 9 + src/resources/config.yml | 180 +++++++++++++ src/resources/locales/en.yml | 29 ++ src/resources/locales/es.yml | 29 ++ src/resources/locales/fr.yml | 29 ++ src/resources/locales/hu.yml | 28 ++ src/resources/locales/it.yml | 29 ++ src/resources/locales/pt.yml | 29 ++ src/resources/locales/tr.yml | 29 ++ src/resources/plugin.yml | 12 + 28 files changed, 1121 insertions(+), 361 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java create mode 100644 src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java create mode 100644 src/resources/bungee.yml create mode 100644 src/resources/config.yml create mode 100644 src/resources/locales/en.yml create mode 100644 src/resources/locales/es.yml create mode 100644 src/resources/locales/fr.yml create mode 100644 src/resources/locales/hu.yml create mode 100644 src/resources/locales/it.yml create mode 100644 src/resources/locales/pt.yml create mode 100644 src/resources/locales/tr.yml create mode 100644 src/resources/plugin.yml diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 18fd751..30e1bd0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -8,22 +8,30 @@ import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bukkit.configuration.BukkitConfiguration; import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.utils.ConfigurationUtil; +import dev._2lstudios.exploitfixer.bukkit.utils.BukkitConfigurationUtil; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; public class ExploitFixer extends JavaPlugin { - private static ExploitFixer exploitFixer; - private ConfigurationUtil configurationUtil; + private static ExploitFixer instance; + private BukkitConfigurationUtil configurationUtil; private ModuleManager moduleManager; private ListenerInitializer listenerInitializer; + public static synchronized ExploitFixer getInstance() { + return instance; + } + + public static synchronized void setInstance(final ExploitFixer exploitFixer) { + ExploitFixer.instance = exploitFixer; + } + @Override public void onEnable() { + setInstance(this); final Server server = this.getServer(); final BukkitScheduler scheduler = server.getScheduler(); @@ -32,20 +40,16 @@ public void onEnable() { "ExploitFixer requires HamsterAPI to listen to packets and block exploits! Download: https://www.spigotmc.org/resources/78831/"); } - configurationUtil = new ConfigurationUtil(this); + configurationUtil = new BukkitConfigurationUtil(this); createConfigurations(); - final IConfiguration configYml = new BukkitConfiguration( - configurationUtil.getConfiguration("%datafolder%/config.yml")); - final IConfiguration messagesYml = new BukkitConfiguration( - configurationUtil.getConfiguration("%datafolder%/messages.yml")); + final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); VersionUtil.initialize(server); - exploitFixer = this; - moduleManager = new ModuleManager(this); - moduleManager.reload(configYml, messagesYml); + moduleManager = new ModuleManager(configurationUtil, this); + moduleManager.reload(configYml); listenerInitializer = new ListenerInitializer(this, moduleManager); register(); @@ -76,12 +80,9 @@ public void reload() { createConfigurations(); - final IConfiguration configYml = new BukkitConfiguration( - this.configurationUtil.getConfiguration("%datafolder%/config.yml")); - final IConfiguration messagesYml = new BukkitConfiguration( - this.configurationUtil.getConfiguration("%datafolder%/messages.yml")); + final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - moduleManager.reload(configYml, messagesYml); + moduleManager.reload(configYml); register(); } @@ -94,8 +95,7 @@ private boolean checkHamsterAPI() { } private void createConfigurations() { - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); + configurationUtil.create("%datafolder%/config.yml", "config.yml"); } private void register() { @@ -114,8 +114,4 @@ private void register() { logger.info("Successfully registered listeners!"); logger.info("Successfully hooked with HamsterAPI!"); } - - public static ExploitFixer getInstance() { - return exploitFixer; - } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java index 5603e6b..76df4ae 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java @@ -16,7 +16,13 @@ public BukkitConfiguration(final ConfigurationSection configuration) { @Override public IConfiguration getSection(final String path) { - return new BukkitConfiguration(configuration.getConfigurationSection(path)); + final Object section = configuration.get(path); + + if (section instanceof ConfigurationSection) { + return new BukkitConfiguration((ConfigurationSection) section); + } else { + return null; + } } @Override @@ -38,6 +44,15 @@ public String getString(final String path) { return configuration.getString(path); } + @Override + public String getStringOrDefault(String path, String def) { + if (contains(path)) { + return getString(path); + } else { + return def; + } + } + @Override public double getDouble(final String path) { return configuration.getDouble(path); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index 3ba7bba..19b730e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -7,8 +7,6 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.utils.BufferIO; public class ListenerInitializer { private final Plugin plugin; @@ -25,10 +23,10 @@ public void register() { final Server server = plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); - final BufferIO bufferIO = HamsterAPI.getInstance().getBufferIO(); final ExploitUtil exploitUtil = new ExploitUtil(moduleManager, plugin); - pluginManager.registerEvents(new PacketDecodeListener(plugin, bufferIO, exploitUtil, moduleManager), plugin); + pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); + pluginManager.registerEvents(new PacketReceiveListener(plugin, exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 8f15c48..5112017 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -1,57 +1,24 @@ package dev._2lstudios.exploitfixer.bukkit.listener; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; - -import org.bukkit.GameMode; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.utils.BufferIO; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; import io.netty.buffer.ByteBuf; -import io.netty.handler.codec.DecoderException; public class PacketDecodeListener implements Listener { - private final Plugin plugin; - private final BufferIO bufferIO; private final ExploitUtil exploitUtil; - private final ExploitPlayerManager exploitPlayerManager; - private final ItemsFixModule itemsFixModule; - private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; - PacketDecodeListener(final Plugin plugin, final BufferIO bufferIO, final ExploitUtil exploitUtil, - final ModuleManager moduleManager) { - HamsterAPI.getInstance().getBufferIO(); - this.plugin = plugin; - this.bufferIO = bufferIO; + PacketDecodeListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.itemsFixModule = moduleManager.getItemsFixModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); } @@ -63,180 +30,9 @@ private String getName(final Player player) { } } - private void cancelExploit(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, - final String reason, final double vls) { - notificationsModule.debug(reason); - event.setCancelled(true); - - if (vls > 0) { - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); - } - } - - public void onPacketReceive(final PacketDecodeEvent event, final HamsterPlayer hamsterPlayer, final Player player, - final PacketWrapper packetWrapper) { - final PacketType packetType = packetWrapper.getType(); - - if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { - final Map strings = packetWrapper.getStrings(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String playerName = player.getName(); - final String packetName = packetWrapper.getName(); - final double dataVls = packetsModule.getDataVls(); - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(); - final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = packetsModule.getTagVls(); - final double bookVls = packetsModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - final String reason = "[" + packetName + "|Tag] " + playerName - + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; - - cancelExploit(event, hamsterPlayer, player, reason, tagVls); - return; - } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") - || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag - + " CustomPayload packet without a book in hand!"; - - cancelExploit(event, hamsterPlayer, player, reason, bookVls); - return; - } - } - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); - } else { - notificationsModule - .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); - - event.setCancelled(true); - } - } - - if (windowClick > 0 && integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } - - if (slot < 0 && slot != -999 && slot != -1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick; - - cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } else if (slot >= maxSlots) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " - + windowClick; - - cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } - } - - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot - && player.getGameMode() != GameMode.CREATIVE) { - final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; - - cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); - return; - } - - int packetSize = 0; - - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - final int dataBytes = packetsModule.getDataBytes(); - - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, - packetName, dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; - } - } - } - - if (dataBytes > 0 && packetSize > dataBytes) { - final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize - + " bytes long!"; - - cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { - final String reason = "[" + packetName + "|Data] " + playerName - + " has sent a too big sign packet! Added vls: " + dataVls; - - cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - } - - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); - - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); - } - - final Map items = packetWrapper.getItems(); - - if (itemsFixModule.isEnabled() && items.containsKey("b")) { - final ItemStack itemStack = items.get("b"); - - if (itemStack != null) { - final String blocked = exploitUtil.clearIfBlocked(itemStack); - final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); - - packetWrapper.write("b", fixedItemStack); - - if (player != null) { - if (blocked != null) { - notificationsModule.debug( - player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); - } else { - notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); - } - } - } - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPacketDecode(final PacketDecodeEvent event) { - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - final Player player = hamsterPlayer.getPlayer(); - + private void onPacketDecode(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, + final ByteBuf byteBuf) { if (player != null && player.isOnline()) { - final ByteBuf byteBuf = event.getByteBuf().get().copy(); final String playerName = player.getName(); final int dataBytes = packetsModule.getDataBytes(); final int refCnt = byteBuf.refCnt(); @@ -247,41 +43,39 @@ public void onPacketDecode(final PacketDecodeEvent event) { final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; - cancelExploit(event, hamsterPlayer, player, reason, dataVls); + byteBuf.release(); + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (refCnt < 1) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; - cancelExploit(event, hamsterPlayer, player, reason, dataVls); + byteBuf.release(); + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (capacity > dataBytes) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds size limit! Max: " + dataBytes + " Vls: " + dataVls; - cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } else { - try { - final String reason = "[Decoder|Offline] " + getName(player) - + " sent a null packet! (Player offline?)"; - final PacketWrapper packet = bufferIO.decode(event.getChannelHandlerContext(), byteBuf, dataBytes); + byteBuf.release(); - if (packet != null) { - onPacketReceive(event, hamsterPlayer, player, packet); - } else { - cancelExploit(event, hamsterPlayer, player, reason, 0); - hamsterPlayer.disconnect(reason); - } - } catch (final DecoderException | IllegalAccessException | InvocationTargetException - | NoSuchMethodException | InstantiationException | NoSuchFieldException | IOException e) { - e.printStackTrace(); - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } } else if (packetsModule.isOffline()) { final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; - cancelExploit(event, hamsterPlayer, player, reason, 0); - hamsterPlayer.disconnect(reason); + byteBuf.release(); + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); } } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onPacketDecode(final PacketDecodeEvent event) { + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + + onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get().copy()); + } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java new file mode 100644 index 0000000..8aabf80 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -0,0 +1,210 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Map; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.Plugin; + +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; +import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; + +public class PacketReceiveListener implements Listener { + private final Plugin plugin; + private final ExploitUtil exploitUtil; + private final ExploitPlayerManager exploitPlayerManager; + private final ItemsFixModule itemsFixModule; + private final BukkitNotificationsModule notificationsModule; + private final PacketsModule packetsModule; + + PacketReceiveListener(final Plugin plugin, final ExploitUtil exploitUtil, final ModuleManager moduleManager) { + this.plugin = plugin; + this.exploitUtil = exploitUtil; + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.itemsFixModule = moduleManager.getItemsFixModule(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.packetsModule = moduleManager.getPacketsModule(); + } + + public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, + final PacketWrapper packetWrapper) { + final PacketType packetType = packetWrapper.getType(); + + if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { + final Map strings = packetWrapper.getStrings(); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final String playerName = player.getName(); + final String packetName = packetWrapper.getName(); + final double dataVls = packetsModule.getDataVls(); + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(); + final double setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = packetsModule.getTagVls(); + final double bookVls = packetsModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + final String reason = "[" + packetName + "|Tag] " + playerName + + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); + return; + } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") + || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + + " CustomPayload packet without a book in hand!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + return; + } + } + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); + } else { + notificationsModule + .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); + + event.setCancelled(true); + } + } + + if (windowClick > 0 && integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999 && slot != -1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } else if (slot >= maxSlots) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } + } + + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot + && player.getGameMode() != GameMode.CREATIVE) { + final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); + return; + } + + int packetSize = 0; + + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + final int dataBytes = packetsModule.getDataBytes(); + + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, + packetName, dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } + } + } + + if (dataBytes > 0 && packetSize > dataBytes) { + final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize + + " bytes long!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { + final String reason = "[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + } + + final Map items = packetWrapper.getItems(); + + if (itemsFixModule.isEnabled() && items.containsKey("b")) { + final ItemStack itemStack = items.get("b"); + + if (itemStack != null) { + final String blocked = exploitUtil.clearIfBlocked(itemStack); + final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); + + packetWrapper.write("b", fixedItemStack); + + if (player != null) { + if (blocked != null) { + notificationsModule.debug( + player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); + } else { + notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); + } + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onPacketReceive(final PacketReceiveEvent event) { + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + + onPacketReceive(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getPacket()); + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index 48bba35..afdda71 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -18,6 +18,7 @@ import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import java.io.IOException; import java.net.InetAddress; import java.util.UUID; @@ -59,17 +60,19 @@ public void onPlayerLogin(final PlayerLoginEvent event) { final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); if (!originalUUID.equals(offlineUUID)) { - final UUID onlineUUID = exploitPlayer.getOnlineUUID(); + final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() + .get(player); - if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { - final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() - .get(player); - final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); + try { + final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - event.setKickMessage(uuidSpoofKickMessage); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - hamsterPlayer.disconnect(uuidSpoofKickMessage); - hamsterPlayer.closeChannel(); + if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { + final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); + + hamsterPlayer.disconnect(uuidSpoofKickMessage); + } + } catch (IOException e) { + hamsterPlayer.disconnect(messagesModule.getMojangDown(locale)); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index 52dab51..acb9d11 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -1,17 +1,22 @@ package dev._2lstudios.exploitfixer.bukkit.managers; +import java.io.File; +import java.util.logging.Logger; + import org.bukkit.Server; import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; public class ModuleManager { + private final Plugin plugin; private final CommandsModule commandsModule; private final ConnectionModule connectionModule; private final ItemsFixModule itemsFixModule; @@ -20,24 +25,31 @@ public class ModuleManager { private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; - public ModuleManager(final Plugin plugin) { + public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin plugin) { + this.plugin = plugin; + final Server server = plugin.getServer(); + final Logger logger = plugin.getLogger(); this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); this.itemsFixModule = new ItemsFixModule(plugin); - this.messagesModule = new MessagesModule(plugin.getDescription().getVersion()); + this.messagesModule = new MessagesModule(configurationUtil, logger, plugin.getDescription().getVersion()); this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), plugin.getLogger(), server); this.packetsModule = new PacketsModule(); this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); } - public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { + public void reload(final IConfiguration configYml) { try { + final File localeFolder = new File(plugin.getDataFolder() + "/locales/"); + + localeFolder.mkdirs(); + this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); this.itemsFixModule.reload(configYml); - this.messagesModule.reload(configYml, messagesYml); + this.messagesModule.reload(configYml, localeFolder); this.notificationsModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java new file mode 100644 index 0000000..ba26285 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java @@ -0,0 +1,105 @@ +package dev._2lstudios.exploitfixer.bukkit.utils; + +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; + +import dev._2lstudios.exploitfixer.bukkit.configuration.BukkitConfiguration; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.logging.Logger; + +public class BukkitConfigurationUtil implements IConfigurationUtil { + private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; + private final String dataFolderPath; + private final String prefix; + private final Logger logger; + private final Plugin plugin; + private final BukkitScheduler scheduler; + private final ClassLoader classLoader; + + public BukkitConfigurationUtil(final Plugin plugin) { + this.plugin = plugin; + this.scheduler = plugin.getServer().getScheduler(); + this.logger = plugin.getLogger(); + this.classLoader = plugin.getClass().getClassLoader(); + this.dataFolderPath = plugin.getDataFolder().toString(); + this.prefix = "[" + plugin.getName() + "]"; + } + + private void createParentFolder(final File file) { + final File parentFile = file.getParentFile(); + + if (parentFile != null) { + parentFile.mkdirs(); + } + } + + public IConfiguration get(final String path) { + final File file = new File(path.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); + + if (file.exists()) { + return new BukkitConfiguration(YamlConfiguration.loadConfiguration(file)); + } else { + return new BukkitConfiguration(new YamlConfiguration()); + } + } + + public void create(final String rawPath, final String resourcePath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + try { + final File configFile = new File(path); + + if (!configFile.exists()) { + final InputStream inputStream = classLoader.getResourceAsStream(resourcePath); + + createParentFolder(configFile); + + if (inputStream != null) { + Files.copy(inputStream, configFile.toPath()); + } else { + configFile.createNewFile(); + } + + logger.info(prefix + " File '" + path + "' has been created!"); + } + } catch (final IOException e) { + logger.info(prefix + " Unable to create '" + path + "'!"); + } + } + + public void save(final IConfiguration configuration, final String rawPath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + scheduler.runTaskAsynchronously(plugin, () -> { + try { + ((YamlConfiguration) configuration.getObject()).save(path); + + logger.info(prefix + " File '" + path + "' has been saved!"); + } catch (final IOException e) { + logger.info(prefix + " Unable to save '" + path + "'!"); + } + }); + } + + public void delete(final String rawPath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + scheduler.runTaskAsynchronously(plugin, () -> { + try { + Files.delete(Path.of(path)); + + logger.info(prefix + " File '" + path + "' has been removed!"); + } catch (IOException e) { + logger.info(prefix + " Unable to remove '" + path + "'!"); + } + }); + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 646252c..84a778e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; @@ -13,6 +14,7 @@ import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; @@ -20,12 +22,14 @@ import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; public class ExploitUtil { + private final ExploitPlayerManager exploitPlayerManager; private final ItemsFixModule itemsFixModule; private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; private final Plugin plugin; public ExploitUtil(final ModuleManager moduleManager, final Plugin plugin) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); @@ -104,9 +108,9 @@ public int parseItemLength(final ItemStack itemStack, final BukkitExploitPlayer } } } else { - throw new NullPointerException(); + throw new IllegalStateException(); } - } catch (final NullPointerException e1) { + } catch (final IllegalStateException e1) { if (itemMeta instanceof BookMeta) { itemBytesLength += parseBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); } else { @@ -155,4 +159,16 @@ public String clearIfBlocked(final ItemStack itemStack) { return null; } + + public void cancelExploit(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, + final String reason, final double vls) { + notificationsModule.debug(reason); + event.setCancelled(true); + + if (vls > 0) { + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + } + } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index ee44eb6..b87fc9d 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -4,38 +4,43 @@ import java.util.logging.Logger; import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bungee.configuration.BungeeConfiguration; import dev._2lstudios.exploitfixer.bungee.listeners.ListenerInitializer; import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.ConfigurationUtil; +import dev._2lstudios.exploitfixer.bungee.utils.BungeeConfigurationUtil; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.scheduler.TaskScheduler; public class ExploitFixer extends Plugin { - private static ExploitFixer exploitFixer; - private ConfigurationUtil configurationUtil; + private static ExploitFixer instance; + private BungeeConfigurationUtil configurationUtil; private ModuleManager moduleManager; private ListenerInitializer listenerInitializer; + public static synchronized ExploitFixer getInstance() { + return instance; + } + + public static synchronized void setInstance(final ExploitFixer exploitFixer) { + ExploitFixer.instance = exploitFixer; + } + @Override public void onEnable() { + setInstance(this); + final TaskScheduler scheduler = getProxy().getScheduler(); - this.configurationUtil = new ConfigurationUtil(this); + configurationUtil = new BungeeConfigurationUtil(this); createConfigurations(); - final IConfiguration configYml = new BungeeConfiguration( - configurationUtil.getConfiguration("%datafolder%/config.yml")); - final IConfiguration messagesYml = new BungeeConfiguration( - configurationUtil.getConfiguration("%datafolder%/messages.yml")); + final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - exploitFixer = this; - moduleManager = new ModuleManager(this); - moduleManager.reload(configYml, messagesYml); + moduleManager = new ModuleManager(configurationUtil, this); + moduleManager.reload(configYml); listenerInitializer = new ListenerInitializer(this, moduleManager); register(); @@ -55,23 +60,19 @@ public void onDisable() { } public void reload() { - final ConfigurationUtil configurationUtil = new ConfigurationUtil(this); + final BungeeConfigurationUtil configurationUtil = new BungeeConfigurationUtil(this); createConfigurations(); - final IConfiguration configYml = new BungeeConfiguration( - configurationUtil.getConfiguration("%datafolder%/config.yml")); - final IConfiguration messagesYml = new BungeeConfiguration( - configurationUtil.getConfiguration("%datafolder%/messages.yml")); + final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - moduleManager.reload(configYml, messagesYml); + moduleManager.reload(configYml); register(); } private void createConfigurations() { - configurationUtil.createConfiguration("%datafolder%/config.yml"); - configurationUtil.createConfiguration("%datafolder%/messages.yml"); + configurationUtil.create("%datafolder%/config.yml", "config.yml"); } private void register() { @@ -92,8 +93,4 @@ private void register() { logger.info("Successfully registered listeners!"); } - - public static ExploitFixer getInstance() { - return exploitFixer; - } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java index 16dfb34..98ffe53 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java @@ -15,7 +15,13 @@ public BungeeConfiguration(final Configuration configuration) { @Override public IConfiguration getSection(final String path) { - return new BungeeConfiguration(configuration.getSection(path)); + final Object section = configuration.get(path); + + if (section instanceof Configuration) { + return new BungeeConfiguration((Configuration) section); + } else { + return null; + } } @Override @@ -37,6 +43,15 @@ public String getString(final String path) { return configuration.getString(path); } + @Override + public String getStringOrDefault(String path, String def) { + if (contains(path)) { + return getString(path); + } else { + return def; + } + } + @Override public double getDouble(final String path) { return configuration.getDouble(path); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 709a561..643cb26 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -16,6 +16,7 @@ import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import java.io.IOException; import java.net.InetSocketAddress; import java.util.UUID; @@ -54,12 +55,15 @@ public void onPostLogin(final PostLoginEvent event) { final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); if (!originalUUID.equals(offlineUUID)) { - final UUID onlineUUID = exploitPlayer.getOnlineUUID(); + try { + final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - - player.disconnect(TextComponent.fromLegacyText(uuidSpoofKickMessage)); + if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { + player.disconnect(TextComponent + .fromLegacyText(messagesModule.getKickMessage("uuidspoof", locale))); + } + } catch (IOException e) { + player.disconnect(TextComponent.fromLegacyText(messagesModule.getMojangDown(locale))); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java index 2308b3e..10385b4 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java @@ -1,7 +1,11 @@ package dev._2lstudios.exploitfixer.bungee.managers; +import java.io.File; +import java.util.logging.Logger; + import dev._2lstudios.exploitfixer.bungee.modules.BungeeNotificationsModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; @@ -11,6 +15,7 @@ import net.md_5.bungee.api.plugin.Plugin; public class ModuleManager { + private final Plugin plugin; private final CommandsModule commandsModule; private final ConnectionModule connectionModule; private final PacketsModule packetsModule; @@ -18,23 +23,30 @@ public class ModuleManager { private final NotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; - public ModuleManager(final Plugin plugin) { + public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin plugin) { + this.plugin = plugin; + final ProxyServer server = plugin.getProxy(); + final Logger logger = plugin.getLogger(); this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); this.packetsModule = new PacketsModule(); - this.messagesModule = new MessagesModule(plugin.getDescription().getVersion()); - this.notificationsModule = new BungeeNotificationsModule(server.getConsole(), plugin.getLogger(), server); + this.messagesModule = new MessagesModule(configurationUtil, logger, plugin.getDescription().getVersion()); + this.notificationsModule = new BungeeNotificationsModule(server.getConsole(), logger, server); this.exploitPlayerManager = new ExploitPlayerManager(server, this); } - public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { + public void reload(final IConfiguration configYml) { try { + final File localeFolder = new File(plugin.getDataFolder() + "/locales/"); + + localeFolder.mkdirs(); + this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); this.packetsModule.reload(configYml); - this.messagesModule.reload(configYml, messagesYml); + this.messagesModule.reload(configYml, localeFolder); this.notificationsModule.reload(configYml); this.exploitPlayerManager.reload(); } catch (final NullPointerException exception) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java new file mode 100644 index 0000000..7834c34 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java @@ -0,0 +1,112 @@ +package dev._2lstudios.exploitfixer.bungee.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.logging.Logger; + +import dev._2lstudios.exploitfixer.bungee.configuration.BungeeConfiguration; +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.api.scheduler.TaskScheduler; +import net.md_5.bungee.config.Configuration; +import net.md_5.bungee.config.ConfigurationProvider; +import net.md_5.bungee.config.YamlConfiguration; + +public class BungeeConfigurationUtil implements IConfigurationUtil { + private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; + private final String dataFolderPath; + private final String prefix; + private final Logger logger; + private final Plugin plugin; + private final TaskScheduler scheduler; + private final ClassLoader classLoader; + + public BungeeConfigurationUtil(final Plugin plugin) { + this.plugin = plugin; + this.scheduler = plugin.getProxy().getScheduler(); + this.logger = plugin.getLogger(); + this.classLoader = plugin.getClass().getClassLoader(); + this.dataFolderPath = plugin.getDataFolder().toString(); + this.prefix = "[" + plugin.getDescription().getName() + "]"; + } + + private void createParentFolder(final File file) { + final File parentFile = file.getParentFile(); + + if (parentFile != null) { + parentFile.mkdirs(); + } + } + + public IConfiguration get(final String path) { + final File file = new File(path.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); + + if (file.exists()) { + try { + return new BungeeConfiguration(ConfigurationProvider.getProvider(YamlConfiguration.class).load(file)); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } else { + return null; + } + } + + public void create(final String rawPath, final String resourcePath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + try { + final File configFile = new File(path); + + if (!configFile.exists()) { + final InputStream inputStream = classLoader.getResourceAsStream(resourcePath); + + createParentFolder(configFile); + + if (inputStream != null) { + Files.copy(inputStream, configFile.toPath()); + } else { + configFile.createNewFile(); + } + + logger.info(prefix + " File '" + path + "' has been created!"); + } + } catch (final IOException e) { + logger.info(prefix + " Unable to create '" + path + "'!"); + } + } + + public void save(final IConfiguration configuration, final String rawPath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + scheduler.runAsync(plugin, () -> { + try { + ConfigurationProvider.getProvider(YamlConfiguration.class) + .save((Configuration) configuration.getObject(), new File(path)); + + logger.info(prefix + " File '" + path + "' has been saved!"); + } catch (final IOException e) { + logger.info(prefix + " Unable to save '" + path + "'!"); + } + }); + } + + public void delete(final String rawPath) { + final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + + scheduler.runAsync(plugin, () -> { + try { + Files.delete(Path.of(path)); + + logger.info(prefix + " File '" + path + "' has been removed!"); + } catch (IOException e) { + logger.info(prefix + " Unable to remove '" + path + "'!"); + } + }); + } +} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java index c35c9ef..708ebf2 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java @@ -11,6 +11,8 @@ public interface IConfiguration { public String getString(final String path); + public String getStringOrDefault(final String path, final String def); + public double getDouble(final String path); public long getLong(final String path); diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index b004058..5427d33 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -1,8 +1,10 @@ package dev._2lstudios.exploitfixer.shared.exploit; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.Collection; @@ -69,30 +71,27 @@ public double getViolations(final IViolationModule module) { return violations.getOrDefault(module, 0D); } - public UUID getOnlineUUID() { + public UUID getOnlineUUID() throws MalformedURLException, IOException { if (onlineUUID == null) { - try { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) - .openConnection(); + final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) + .openConnection(); - connection.connect(); + connection.connect(); - try (final InputStream inputStream = connection.getInputStream()) { - try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { - final StringBuilder response = new StringBuilder(); - String inputLine; + try (final InputStream inputStream = connection.getInputStream()) { + try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { + final StringBuilder response = new StringBuilder(); + String inputLine; - while ((inputLine = bufferedReader.readLine()) != null) { - response.append(inputLine); - } - - onlineUUID = UUID.fromString(new JsonParser().parse(response.toString()).getAsJsonObject() - .get("id").getAsString().replaceFirst( - "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", - "$1-$2-$3-$4-$5")); + while ((inputLine = bufferedReader.readLine()) != null) { + response.append(inputLine); } + + onlineUUID = UUID.fromString(new JsonParser().parse(response.toString()).getAsJsonObject().get("id") + .getAsString().replaceFirst( + "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", + "$1-$2-$3-$4-$5")); } - } catch (final Exception ignored) { } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java new file mode 100644 index 0000000..b75248f --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java @@ -0,0 +1,13 @@ +package dev._2lstudios.exploitfixer.shared.interfaces; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; + +public interface IConfigurationUtil { + public IConfiguration get(final String file); + + public void create(final String file, final String resourcePath); + + public void save(final IConfiguration configuration, final String file); + + public void delete(final String file); +} diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 17dbaa4..fed0ca3 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -1,47 +1,82 @@ package dev._2lstudios.exploitfixer.shared.modules; +import java.io.File; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Logger; + import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; import dev._2lstudios.exploitfixer.shared.interfaces.IMessagesModule; import dev._2lstudios.exploitfixer.shared.interfaces.IModule; public class MessagesModule implements IMessagesModule { + private static final String NOTFOUND_STRING = " (Reset ExploitFixer locale folder)"; + private final IConfigurationUtil configurationUtil; + private final Logger logger; private final String version; - private IConfiguration messagesYml; - private String discord, locale; - - public MessagesModule(final String version) { + private final Map> locales = new HashMap<>(); + private final Collection defaultLocales = new HashSet<>(); + private String web; + private String defaultLocale; + + public MessagesModule(final IConfigurationUtil configurationUtil, final Logger logger, final String version) { + this.configurationUtil = configurationUtil; + this.logger = logger; this.version = version; - } - - public void reload(final IConfiguration configYml, final IConfiguration messagesYml) { - this.messagesYml = messagesYml; - this.discord = messagesYml.getString("discord"); - final String locale = configYml.getString("locale"); + defaultLocales.add("en"); + defaultLocales.add("es"); + defaultLocales.add("pt"); + defaultLocales.add("it"); + defaultLocales.add("fr"); + defaultLocales.add("tr"); + } - if (locale != null) { - this.locale = locale; - } else { - this.locale = "en"; + public void putSection(final IConfiguration langFile, final Map locale, final String currentPath) { + for (final String key : langFile.getKeys()) { + final IConfiguration section = langFile.getSection(key); + + if (section != null) { + if (currentPath.isEmpty()) { + putSection(section, locale, key); + } else { + putSection(section, locale, currentPath + "." + key); + } + } else { + if (currentPath.isEmpty()) { + locale.put(key, langFile.getString(key)); + } else { + locale.put(currentPath + "." + key, langFile.getString(key)); + } + } } } - @Override - public String getString(final String locale, final String path) { - final String string; + public void reload(final IConfiguration configYml, final File localeFolder) { + web = configYml.getStringOrDefault("web", " (Reset ExploitFixer config file)"); + defaultLocale = configYml.getStringOrDefault("locale", "en").toLowerCase(); - if (messagesYml.contains(locale + path)) { - string = messagesYml.getString(locale + path); - } else if (messagesYml.contains(this.locale + path)) { - string = messagesYml.getString(this.locale + path); - } else { - string = ""; + for (final String locale : defaultLocales) { + configurationUtil.create("%datafolder%/locales/" + locale + ".yml", "locales/" + locale + ".yml"); } - if (string != null) { - return string.replace("%version%", version).replace("%discord%", discord).replace('&', '\u00a7'); - } else { - return string; + for (final File file : localeFolder.listFiles()) { + final String fileName = file.getName(); + + try { + final IConfiguration langFile = configurationUtil.get(file.toPath().toString()); + final Map locale = new HashMap<>(); + + putSection(langFile, locale, ""); + + locales.put(fileName.substring(0, 2).toLowerCase(), locale); + } catch (final Exception ex) { + logger.info( + "Wasn't able to load locale " + fileName + " because of a " + ex.getClass().getName() + "!"); + } } } @@ -53,43 +88,62 @@ public String getName() { return "Messages"; } + @Override + public String getString(final String locale, final String path) { + final String string; + + if (locales.containsKey(locale)) { + string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING); + } else if (locales.containsKey(defaultLocale)) { + string = locales.get(defaultLocale).getOrDefault(path, NOTFOUND_STRING); + } else { + string = NOTFOUND_STRING; + } + + return string.replace("%version%", version).replace("%web%", web).replace('&', '\u00a7'); + } + public final String getReload(final String locale) { - return getString(locale, ".commands.reload"); + return getString(locale, "commands.reload"); } public final String getHelp(final String locale) { - return getString(locale, ".commands.help"); + return getString(locale, "commands.help"); } public final String getUnknown(final String locale) { - return getString(locale, ".commands.error.unknown"); + return getString(locale, "commands.error.unknown"); } public final String getPermission(final String locale) { - return getString(locale, ".commands.error.permission"); + return getString(locale, "commands.error.permission"); } public final String getConsole(final String locale) { - return getString(locale, ".commands.error.console"); + return getString(locale, "commands.error.console"); } public final String getEnable(final String locale) { - return getString(locale, ".commands.notifications.enable"); + return getString(locale, "commands.notifications.enable"); } public final String getDisable(final String locale) { - return getString(locale, ".commands.notifications.disable"); + return getString(locale, "commands.notifications.disable"); } public final String getKickMessage(final IModule module, final String locale) { - return getString(locale, ".modules." + module.getName().toLowerCase() + ".kick_message"); + return getString(locale, "modules." + module.getName().toLowerCase() + ".kick_message"); } public final String getKickMessage(final String module, final String locale) { - return getString(locale, ".modules." + module.toLowerCase() + ".kick_message"); + return getString(locale, "modules." + module.toLowerCase() + ".kick_message"); } public String getStats(final String locale) { - return getString(locale, ".commands.stats"); + return getString(locale, "commands.stats"); + } + + public String getMojangDown(final String locale) { + return getString(locale, "mojang_down"); } } \ No newline at end of file diff --git a/src/resources/bungee.yml b/src/resources/bungee.yml new file mode 100644 index 0000000..b04a0f8 --- /dev/null +++ b/src/resources/bungee.yml @@ -0,0 +1,9 @@ +name: ExploitFixer +main: dev._2lstudios.exploitfixer.bungee.ExploitFixer +version: 1.4.8 +author: 2LS +commands: + exploitfixer: + description: The main ExploitFixer command + usage: /exploitfixer + aliases: [ef] diff --git a/src/resources/config.yml b/src/resources/config.yml new file mode 100644 index 0000000..e3912a2 --- /dev/null +++ b/src/resources/config.yml @@ -0,0 +1,180 @@ +# ExploitFixer by LinsaFTW +# Please help by donating, we require funds to continue with the development. +# https://paypal.me/LinsaFTW +# +# WARNING: Only Notifications, Connection, Commands and Packets (CustomPayload only) modules work on BungeeCord. +# +# This is because the other modules can't be executed on BungeeCord. +# The other modules require ExploitFixer to be installed on Bukkit with HamsterAPI. (No performance impact) +# +# INSTALL THE PLUGIN ON BUNGEECORD AND ALL BUKKIT SERVERS! +# +# Most of the check use Violations (vls), this a counter to execute different +# actions on diverse levels to allow high customization of the modules. + +# Default language used by the plugin (This changes depending on the client language) +locale: "en" + +# Web link used on the messages +web: "discord.gg/gF36AT3" + +# Shows notifications to console and players with permissions. +notifications: + enabled: true + + # Placeholders: %player% %ping% %check% %vls% + message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" + + # This shows extra information about packets blocked. + # Useful to identify false positives and reporting errors. + debug: false + +# Prevents a variety of exploits that occur on player connection. +# Players wont be able to type messages/commands until the connection is secured. (You won't notice this) +connection: + # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. + # UUIDSpoof only affects non-firewalled servers with bungeecord: true. + uuidspoof: true + + # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. + # NullAddress only affects non-firewalled servers using IP Whitelist. + nulladdress: true + + # Commands to run when a player is detected. + punishments: [] + +# Prevents the use of invalid packets to exploit your server. +# This is the most advanced category in the plugin and it's not recommended to disable it. +packets: + enabled: true + + # Amount of vls required to start cancelling packets. + cancel_vls: 100 + + # Amount of vls to reduce per second. + reduce_vls: 60 + + # Cancels packets if the player sending them is offline. + offline: true + + # This will check if integers, floats, doubles and items have a invalid size in packets. + data: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 600 + + # Maximum amount of bytes allowed per packet. (Set to -1 to disable) + bytes: 16000 + + # Maximum amount of bytes allowed per book page. (Set to -1 to disable) + bytes_book: 300 + + # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) + bytes_sign: 47 + + # Packets will add their amount of bytes divided by this number to vl count. + # This is made so big packets add more vls when received. + bytes_divider: 1000 + + # Cancels book packets when a book is not in hand + # Vls to add when a packet fails the check. (Set to -1 to disable) + book: 100 + + # Cancels CustomPayload packets with invalid tags + # Vls to add when a packet fails the check. (Set to -1 to disable) + tag: 600 + + # Checks if players send PacketPlayInWindowClick packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + window_click: 300 + + # Checks if players send PacketPlayInBlockPlace packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_place: 300 + + # Checks if players send PacketPlayInBlockDig packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_dig: 600 + + # Checks if players send PacketPlayInCreativeSlot packets without creative. + # Vls to add when a packet fails the check. (Set to -1 to disable) + set_creative_slot: 600 + + # Vls to add when a normal packet is sent by a player. + # This option is made to work as a packet limiter feature. + # Unlisted packets are considered as "PacketPlayInOther" by default. + # Remember to take a look at bytes_divider option. + multipliers: + MC|BSign: 30 + MC|BEdit: 30 + MC|BOpen: 30 + PacketPlayInOther: 0.1 + PacketPlayInAbilities: 0.1 + PacketPlayInArmAnimation: 0.3 + PacketPlayInBlockDig: 0.3 + PacketPlayInBlockPlace: 0.4 + PacketPlayInCustomPayload: 0.04 + PacketPlayInEntityAction: 0.4 + PacketPlayInFlying: 0.05 + PacketPlayInLook: 0.1 + PacketPlayInPositionLook: 0.1 + PacketPlayInPosition: 0.35 + PacketPlayInSetCreativeSlot: 0.1 + PacketPlayInSettings: 0.5 + PacketPlayInTabComplete: 0.2 + PacketPlayInUpdateSign: 10 + PacketPlayInUseEntity: 0.4 + PacketPlayInUseItem: 0.4 + PacketPlayInWindowClick: 0.5 + + # Placeholders: %player% + # Commands to run when a player reachs certain violation level. + violations: + 350: + - "notification" + 600: + - "notification" + - "kick" + +# Removes custom NBT tags from creative items to prevent harm to your server. +itemsfix: + enabled: true + + # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) + max_stack_size: 64 + + # Maximum enchant level obtainable with creative packets. (-1 to disable) + enchant_limit: 10 + + # List of materials that are unobtainable from Creative. + blacklist: + - "END_PORTAL" + - "NETHER_PORTAL" + # - "BARRIER" + # - "COMMAND_BLOCK" + +# Checks if players try to crash/exploit the server with commands. +commands: + enabled: true + + # Commands that are excempt from this server. + commands: + - "//calc" + - "//calculate" + - "//eval" + - "//evaluate" + - "//solve" + - "/hd readtext" + - "/holo readtext" + - "/hologram readtext" + - "/holograms readtext" + - "/holographicdisplays readtext" + - "/pex promote" + - "/pex demote" + - "/promote" + - "/demote" + - "/execute" + + # Placeholders: %player% + punishments: + - "notification" + - "kick" diff --git a/src/resources/locales/en.yml b/src/resources/locales/en.yml new file mode 100644 index 0000000..96b990b --- /dev/null +++ b/src/resources/locales/en.yml @@ -0,0 +1,29 @@ +# English - Credits: LinsaFTW +commands: + reload: "&aPlugin ExploitFixer reloaded!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bShows available commands. + &e /%command% reload &7> &bReloads the plugin. + &e /%command% notifications &7> &bToggles notifications of the plugin. + &e /%command% stats &7> &bWatch the stats of the plugin. + error: + unknown: "&cUnknown command. Use /exploitfixer help to see available commands!" + permission: "&cYou dont have permission to use this command!" + console: "&cThis command cant be executed from the console!" + notifications: + enable: "&aYou have enabled notifications!" + disable: "&cYou have disabled notifications!" + stats: "&c&lEF: &ePlayers cached: &a%players_cached%&e Players punished: &a%players_punished%" +modules: + custompayload: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang servers are down, please come back later!\n\n&7Reason: &fExploitFixer can't check the UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/locales/es.yml b/src/resources/locales/es.yml new file mode 100644 index 0000000..44065f0 --- /dev/null +++ b/src/resources/locales/es.yml @@ -0,0 +1,29 @@ +# Spanish - Credits: LinsaFTW +commands: + reload: "&aPlugin ExploitFixer recargado!" + help: |- + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bMuestra los comandos disponibles. + &e /%command% reload &7> &bRecarga el plugin. + &e /%command% notifications &7> &bAlterna las notificaciones del plugin. + &e /%command% stats &7> &bMira las estadisticas del plugin. + error: + unknown: "&cComando desconocido. Usa /exploitfixer help para ver comandos disponibles!" + permission: "&cNo tienes permiso para usar ese comando!" + console: "&cEste comando no puede ser usado desde la consola!" + notifications: + enable: "&aHabilitaste las notificaciones!" + disable: "&cDeshabilitaste las notificaciones!" + stats: "&c&lEF: &eJugadores en cache: &a%players_cached%&e Jugadores sancionados: &a%players_punished%" +modules: + custompayload: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de UUID detectado.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Packets detectado.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Red nula detectado.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang esta apagado, vuelve pronto!\n\n&7Razon: &fExploitFixer no puede confirmar la UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/locales/fr.yml b/src/resources/locales/fr.yml new file mode 100644 index 0000000..760d2ad --- /dev/null +++ b/src/resources/locales/fr.yml @@ -0,0 +1,29 @@ +# French - Credits: HaVroz +commands: + reload: "&aPlugin Exploitfixer rechargé!" + help: |- + &aExploitFixer &b%version%&a par &bLinsaFTW&a. + &e /%command% help &7> &bAfficher les commandes disponibles. + &e /%command% reload &7> &bRecharger le plugin. + &e /%command% notifications &7> &bActiver/Désactiver les notifications du plugin. + &e /%command% stats &7> &bVoir les statistiques du plugin. + error: + unknown: "&cCommande inconnue. Utilisez /exploitfixer help pour voir les commandes disponibles!" + permission: "&cVous n’avez pas la permission d’utiliser cette commande!" + console: "&cCette commande ne peut pas être exécutée depuis la console!" + notifications: + enable: "&aVous avez activé les notifications!" + disable: "&cVous avez désactivé les notifications!" + stats: "&c&lEF: &eJoueurs caché: &a%players_cached%&e Joueurs sanctionné: &a%players_punished%" +modules: + custompayload: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang est désactivé, revenez bientôt!\n\n&7Raison: &fExploitFixer ne peut pas confirmer l'UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/locales/hu.yml b/src/resources/locales/hu.yml new file mode 100644 index 0000000..d93792c --- /dev/null +++ b/src/resources/locales/hu.yml @@ -0,0 +1,28 @@ +#Hungarian +commands: + reload: "&aAz ExploitFixer sikeresen újraindult!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bElérhető parancsok. + &e /%command% reload &7> &bPlugin újraindítása. + &e /%command% notifications &7> &bÉrtesítések ki/be kapcsolása. + &e /%command% stats &7> &bA plugin statisztikáinak megtekintése. + error: + unknown: "&cIsmeretlen parancs. Használd a /exploitfixer help parancsot!" + permission: "&cNincs jogod a parancs használatához!" + console: "&cEzt a parancsot nem bírod használni a konzolból!" + notifications: + enable: "&aBekapcsoltad az értesítéseket!" + disable: "&cKikapcsoltad az értesítéseket!" + stats: "&c&lEF: &eJátékosok: &a%players_cached%&e Büntetések: &a%players_punished%" +modules: + custompayload: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" + uuidspoof: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fUUID Spoofingot észleltünk.\n&7Discord: &b&n%discord%&r" + commands: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + packets: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fCsomag exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + nulladdress: + kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fNull addresst észleltünk.\n&7Discord: &b&n%discord%&r" \ No newline at end of file diff --git a/src/resources/locales/it.yml b/src/resources/locales/it.yml new file mode 100644 index 0000000..b8d991f --- /dev/null +++ b/src/resources/locales/it.yml @@ -0,0 +1,29 @@ +# Italian +commands: + reload: "&aPlugin ExploitFixer ricaricato!" + help: |- + &aExploitFixer &b%version%&a da parte di &bLinsaFTW&a. + &e /%command% help &7> &bMostra i commandi disponibili. + &e /%command% reload &7> &bRicarica il plugin. + &e /%command% notifications &7> &bCambia le notifiche del plugin. + &e /%command% stats &7> &bMostra le statistiche del plugin. + error: + unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" + permission: "&cNon hai il permesso per questo commando!" + console: "&cQuesto commando non può essere eseguito dalla console!" + notifications: + enable: "&aHai abilitato le notifiche!" + disable: "&cHai disabilitato le notifiche!" + stats: "&c&lEF: &eGiocatori in cache: &a%players_cached%&e Giocatori puniti: &a%players_punished%" +modules: + custompayload: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang è disattivato, torna presto!\n\n&7Reason: &fExploitFixer non può confermare l'UUID. \n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/locales/pt.yml b/src/resources/locales/pt.yml new file mode 100644 index 0000000..48cf614 --- /dev/null +++ b/src/resources/locales/pt.yml @@ -0,0 +1,29 @@ +# Portuguese - Credits: LucaAzalim +commands: + reload: "&aPlugin ExploitFixer recarregado!" + help: |- + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bComandos disponiveis. + &e /%command% reload &7> &bRecarrega o plugin. + &e /%command% notifications &7> &bAtiva as notificações do plugin. + &e /%command% stats &7> &bVer as estatísticas do plugin. + error: + unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" + permission: "&cSem permissão para usar esse comando!" + console: "&cEsse comando não pode ser executado pelo console!" + notifications: + enable: "&cVocê ativou as notificações!" + disable: "&cVocê desativou as notificações!" + stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" +modules: + custompayload: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang está desligado, volte logo!\n\n&7Motivo: &fExploitFixer não pode confirmar UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/locales/tr.yml b/src/resources/locales/tr.yml new file mode 100644 index 0000000..f6ed3f8 --- /dev/null +++ b/src/resources/locales/tr.yml @@ -0,0 +1,29 @@ +# Turkish +commands: + reload: "&aPlugin ExploitFixer yeniden yüklendi!" + help: |- + &aExploitFixer &b%version% &ayazan &bLinsaFTW&a. + &e /%command% help &7> &bMevcut komutları gösterir. + &e /%command% reload &7> &bEklentiyi yükler. + &e /%command% notifications &7> &bEklentinin bildirimlerini değiştirir. + &e /%command% stats &7> &bEklentinin istatistiklerini izleyin. + error: + unknown: "&cBilinmeyen komut. Kullanılabilir komutları görmek için / exploitfixer yardımını kullanın!" + permission: "&cBu komutu kullanma izniniz yok!" + console: "&cBu komut konsoldan yürütülemez!" + notifications: + enable: "&aBildirimleri etkinleştirdiniz!" + disable: "&cBildirimleri devre dışı bıraktınız!" + stats: "&c&lEF: &ePlayers önbelleğe alındı: &a%players_cached%&e Players cezalandırıldı: &a%players_punished%" +modules: + custompayload: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang kapalı, kısa süre sonra tekrar gelin!\n\n&7Neden: &fExploitFixer UUID'yi doğrulayamıyor.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml new file mode 100644 index 0000000..92b735e --- /dev/null +++ b/src/resources/plugin.yml @@ -0,0 +1,12 @@ +name: ExploitFixer +main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer +version: 1.4.8 +author: 2LS +api: "1.13" +api-version: "1.13" +softdepend: [HamsterAPI] +commands: + exploitfixer: + description: The main ExploitFixer command + usage: /exploitfixer + aliases: [ef] From 0ff8ef2a03c7f6af0fcaa5c4dc7549b92b58857e Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Fri, 18 Sep 2020 00:13:49 -0300 Subject: [PATCH 084/336] Updated Source --- src/bungee.yml | 9 - src/config.yml | 177 --------------- .../bukkit/utils/ConfigurationUtil.java | 89 -------- .../bungee/utils/ConfigurationUtil.java | 86 ------- src/messages.yml | 212 ------------------ src/plugin.yml | 12 - 6 files changed, 585 deletions(-) delete mode 100644 src/bungee.yml delete mode 100644 src/config.yml delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java delete mode 100644 src/messages.yml delete mode 100644 src/plugin.yml diff --git a/src/bungee.yml b/src/bungee.yml deleted file mode 100644 index e85739c..0000000 --- a/src/bungee.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: ExploitFixer -main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.7 -author: 2LS -commands: - exploitfixer: - description: The main ExploitFixer command - usage: /exploitfixer - aliases: [ef] diff --git a/src/config.yml b/src/config.yml deleted file mode 100644 index 96e8568..0000000 --- a/src/config.yml +++ /dev/null @@ -1,177 +0,0 @@ -# ExploitFixer by LinsaFTW -# Please help by donating, we require funds to continue with the development. -# https://paypal.me/LinsaFTW -# -# WARNING: Only Notifications, Connection, Commands and Packets (CustomPayload only) modules work on BungeeCord. -# -# This is because the other modules can't be executed on BungeeCord. -# The other modules require ExploitFixer to be installed on Bukkit with HamsterAPI. (No performance impact) -# -# INSTALL THE PLUGIN ON BUNGEECORD AND ALL BUKKIT SERVERS! -# -# Most of the check use Violations (vls), this a counter to execute different -# actions on diverse levels to allow high customization of the modules. - -# Default language used by the plugin (This changes depending on the client language) -locale: "en" - -# Shows notifications to console and players with permissions. -notifications: - enabled: true - - # Placeholders: %player% %ping% %check% %vls% - message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" - - # This shows extra information about packets blocked. - # Useful to identify false positives and reporting errors. - debug: false - -# Prevents a variety of exploits that occur on player connection. -# Players wont be able to type messages/commands until the connection is secured. (You won't notice this) -connection: - # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. - # UUIDSpoof only affects non-firewalled servers with bungeecord: true. - uuidspoof: true - - # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. - # NullAddress only affects non-firewalled servers using IP Whitelist. - nulladdress: true - - # Commands to run when a player is detected. - punishments: [] - -# Prevents the use of invalid packets to exploit your server. -# This is the most advanced category in the plugin and it's not recommended to disable it. -packets: - enabled: true - - # Amount of vls required to start cancelling packets. - cancel_vls: 100 - - # Amount of vls to reduce per second. - reduce_vls: 60 - - # Cancels packets if the player sending them is offline. - offline: true - - # This will check if integers, floats, doubles and items have a invalid size in packets. - data: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 600 - - # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 16000 - - # Maximum amount of bytes allowed per book page. (Set to -1 to disable) - bytes_book: 300 - - # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) - bytes_sign: 47 - - # Packets will add their amount of bytes divided by this number to vl count. - # This is made so big packets add more vls when received. - bytes_divider: 1000 - - # Cancels book packets when a book is not in hand - # Vls to add when a packet fails the check. (Set to -1 to disable) - book: 100 - - # Cancels CustomPayload packets with invalid tags - # Vls to add when a packet fails the check. (Set to -1 to disable) - tag: 600 - - # Checks if players send PacketPlayInWindowClick packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - window_click: 300 - - # Checks if players send PacketPlayInBlockPlace packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_place: 300 - - # Checks if players send PacketPlayInBlockDig packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_dig: 600 - - # Checks if players send PacketPlayInCreativeSlot packets without creative. - # Vls to add when a packet fails the check. (Set to -1 to disable) - set_creative_slot: 600 - - # Vls to add when a normal packet is sent by a player. - # This option is made to work as a packet limiter feature. - # Unlisted packets are considered as "PacketPlayInOther" by default. - # Remember to take a look at bytes_divider option. - multipliers: - MC|BSign: 30 - MC|BEdit: 30 - MC|BOpen: 30 - PacketPlayInOther: 0.1 - PacketPlayInAbilities: 0.1 - PacketPlayInArmAnimation: 0.3 - PacketPlayInBlockDig: 0.3 - PacketPlayInBlockPlace: 0.4 - PacketPlayInCustomPayload: 0.04 - PacketPlayInEntityAction: 0.4 - PacketPlayInFlying: 0.05 - PacketPlayInLook: 0.1 - PacketPlayInPositionLook: 0.1 - PacketPlayInPosition: 0.35 - PacketPlayInSetCreativeSlot: 0.1 - PacketPlayInSettings: 0.5 - PacketPlayInTabComplete: 0.2 - PacketPlayInUpdateSign: 10 - PacketPlayInUseEntity: 0.4 - PacketPlayInUseItem: 0.4 - PacketPlayInWindowClick: 0.5 - - # Placeholders: %player% - # Commands to run when a player reachs certain violation level. - violations: - 350: - - "notification" - 600: - - "notification" - - "kick" - -# Removes custom NBT tags from creative items to prevent harm to your server. -itemsfix: - enabled: true - - # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) - max_stack_size: 64 - - # Maximum enchant level obtainable with creative packets. (-1 to disable) - enchant_limit: 10 - - # List of materials that are unobtainable from Creative. - blacklist: - - "END_PORTAL" - - "NETHER_PORTAL" - # - "BARRIER" - # - "COMMAND_BLOCK" - -# Checks if players try to crash/exploit the server with commands. -commands: - enabled: true - - # Commands that are excempt from this server. - commands: - - "//calc" - - "//calculate" - - "//eval" - - "//evaluate" - - "//solve" - - "/hd readtext" - - "/holo readtext" - - "/hologram readtext" - - "/holograms readtext" - - "/holographicdisplays readtext" - - "/pex promote" - - "/pex demote" - - "/promote" - - "/demote" - - "/execute" - - # Placeholders: %player% - punishments: - - "notification" - - "kick" diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java deleted file mode 100644 index ee77d44..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ConfigurationUtil.java +++ /dev/null @@ -1,89 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.utils; - -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.Plugin; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.logging.Logger; - -public class ConfigurationUtil { - private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; - private final String dataFolderPath; - private final String prefix; - private final Plugin plugin; - - public ConfigurationUtil(final Plugin plugin) { - this.plugin = plugin; - this.dataFolderPath = plugin.getDataFolder().toString(); - this.prefix = "[" + plugin.getName() + "]"; - } - - public YamlConfiguration getConfiguration(String filePath) { - final File file = new File(filePath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); - - if (file.exists()) { - return YamlConfiguration.loadConfiguration(file); - } else { - return new YamlConfiguration(); - } - } - - public void createConfiguration(String file) { - final Logger logger = plugin.getLogger(); - - try { - file = file.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); - - final File configFile = new File(file); - - if (!configFile.exists()) { - final String[] files = file.split("/"); - final InputStream inputStream = plugin.getClass().getClassLoader() - .getResourceAsStream(files[files.length - 1]); - final File parentFile = configFile.getParentFile(); - - if (parentFile != null) { - parentFile.mkdirs(); - } - - if (inputStream != null) { - Files.copy(inputStream, configFile.toPath()); - } else { - configFile.createNewFile(); - } - - logger.info(prefix + " File '" + file + "' has been created!"); - } - } catch (final IOException e) { - logger.info(prefix + " Unable to create '" + file + "'!"); - } - } - - public void saveConfiguration(final YamlConfiguration yamlConfiguration, final String file) { - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - try { - yamlConfiguration.save(file.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); - - plugin.getLogger().info(prefix + " File '" + file + "' has been saved!"); - } catch (final IOException e) { - plugin.getLogger().info(prefix + " Unable to save '" + file + "'!"); - } - }); - } - - public void deleteConfiguration(final String file) { - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - try { - Files.delete(Path.of(file)); - - plugin.getLogger().info(prefix + " File '" + file + "' has been removed!"); - } catch (IOException e) { - plugin.getLogger().info(prefix + " Unable to remove '" + file + "'!"); - } - }); - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java deleted file mode 100644 index 81ef443..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/utils/ConfigurationUtil.java +++ /dev/null @@ -1,86 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.utils; - -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.config.Configuration; -import net.md_5.bungee.config.ConfigurationProvider; -import net.md_5.bungee.config.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.logging.Level; - -public class ConfigurationUtil { - final private Plugin plugin; - - public ConfigurationUtil(final Plugin plugin) { - this.plugin = plugin; - } - - public Configuration getConfiguration(String file) { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); - - try { - return ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(file)); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - public void createConfiguration(String file) { - try { - final File dataFolder = plugin.getDataFolder(); - - file = file.replace("%datafolder%", dataFolder.toPath().toString()); - - final File configFile = new File(file); - - if (!configFile.exists()) { - final String[] files = file.split("/"); - final InputStream inputStream = plugin.getClass().getClassLoader() - .getResourceAsStream(files[files.length - 1]); - - new File(configFile.getParent()).mkdirs(); - - if (inputStream != null) { - Files.copy(inputStream, configFile.toPath()); - plugin.getLogger().log(Level.INFO, ("[%pluginname%] File " + configFile + " has been created!") - .replace("%pluginname%", plugin.getDescription().getName())); - } else { - configFile.createNewFile(); - } - } - } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to create configuration file!") - .replace("%pluginname%", plugin.getDescription().getName())); - } - } - - public void saveConfiguration(final Configuration configuration, final String file) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - try { - final File dataFolder = plugin.getDataFolder(); - - ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, - new File(file.replace("%datafolder%", dataFolder.toPath().toString()))); - } catch (final IOException e) { - plugin.getLogger().log(Level.INFO, ("[%pluginname%] Unable to save configuration file!") - .replace("%pluginname%", plugin.getDescription().getName())); - } - }); - } - - public void deleteConfiguration(final String file) { - plugin.getProxy().getScheduler().runAsync(plugin, () -> { - final File file1 = new File(file); - - if (file1.exists()) { - file1.delete(); - } - }); - } -} \ No newline at end of file diff --git a/src/messages.yml b/src/messages.yml deleted file mode 100644 index 80e75bd..0000000 --- a/src/messages.yml +++ /dev/null @@ -1,212 +0,0 @@ -# The language is automatically selected depending on the client language. -# If the locale of the player doesnt exist in this file, english will be used by default. -discord: "discord.gg/gF36AT3" - -# English -en: - commands: - reload: "&aPlugin ExploitFixer reloaded!" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW&a. - &e /%command% help &7> &bShows available commands. - &e /%command% reload &7> &bReloads the plugin. - &e /%command% notifications &7> &bToggles notifications of the plugin. - &e /%command% stats &7> &bWatch the stats of the plugin. - error: - unknown: "&cUnknown command. Use /exploitfixer help to see available commands!" - permission: "&cYou dont have permission to use this command!" - console: "&cThis command cant be executed from the console!" - notifications: - enable: "&aYou have enabled notifications!" - disable: "&cYou have disabled notifications!" - stats: "&c&lEF: &ePlayers cached: &a%players_cached%&e Players punished: &a%players_punished%" - modules: - custompayload: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%discord%&r" - -# Spanish -es: - commands: - reload: "&aPlugin ExploitFixer recargado!" - help: |- - &aExploitFixer &b%version%&a por &bLinsaFTW&a. - &e /%command% help &7> &bMuestra los comandos disponibles. - &e /%command% reload &7> &bRecarga el plugin. - &e /%command% notifications &7> &bAlterna las notificaciones del plugin. - &e /%command% stats &7> &bMira las estadisticas del plugin. - error: - unknown: "&cComando desconocido. Usa /exploitfixer help para ver comandos disponibles!" - permission: "&cNo tienes permiso para usar ese comando!" - console: "&cEste comando no puede ser usado desde la consola!" - notifications: - enable: "&aHabilitaste las notificaciones!" - disable: "&cDeshabilitaste las notificaciones!" - stats: "&c&lEF: &eJugadores en cache: &a%players_cached%&e Jugadores sancionados: &a%players_punished%" - modules: - custompayload: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de UUID detectado.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Comandos detectado.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Packets detectado.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Reason: &fExploit de Red nula detectado.\n&7Discord: &b&n%discord%&r" - -# Portuguese - Credits: LucaAzalim -pt: - commands: - reload: "&aPlugin ExploitFixer recarregado!" - help: |- - &aExploitFixer &b%version%&a por &bLinsaFTW&a. - &e /%command% help &7> &bComandos disponiveis. - &e /%command% reload &7> &bRecarrega o plugin. - &e /%command% notifications &7> &bAtiva as notificações do plugin. - &e /%command% stats &7> &bVer as estatísticas do plugin. - error: - unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" - permission: "&cSem permissão para usar esse comando!" - console: "&cEsse comando não pode ser executado pelo console!" - notifications: - enable: "&cVocê ativou as notificações!" - disable: "&cVocê desativou as notificações!" - stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" - modules: - custompayload: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&n%discord%&r" - -# Italian -it: - commands: - reload: "&aPlugin ExploitFixer ricaricato!" - help: |- - &aExploitFixer &b%version%&a da parte di &bLinsaFTW&a. - &e /%command% help &7> &bMostra i commandi disponibili. - &e /%command% reload &7> &bRicarica il plugin. - &e /%command% notifications &7> &bCambia le notifiche del plugin. - &e /%command% stats &7> &bMostra le statistiche del plugin. - error: - unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" - permission: "&cNon hai il permesso per questo commando!" - console: "&cQuesto commando non può essere eseguito dalla console!" - notifications: - enable: "&aHai abilitato le notifiche!" - disable: "&cHai disabilitato le notifiche!" - stats: "&c&lEF: &eGiocatori in cache: &a%players_cached%&e Giocatori puniti: &a%players_punished%" - modules: - custompayload: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&n%discord%&r" - -# French - Credits: HaVroz -fr: - commands: - reload: "&aPlugin Exploitfixer rechargé!" - help: |- - &aExploitFixer &b%version%&a par &bLinsaFTW&a. - &e /%command% help &7> &bAfficher les commandes disponibles. - &e /%command% reload &7> &bRecharger le plugin. - &e /%command% notifications &7> &bActiver/Désactiver les notifications du plugin. - &e /%command% stats &7> &bVoir les statistiques du plugin. - error: - unknown: "&cCommande inconnue. Utilisez /exploitfixer help pour voir les commandes disponibles!" - permission: "&cVous n’avez pas la permission d’utiliser cette commande!" - console: "&cCette commande ne peut pas être exécutée depuis la console!" - notifications: - enable: "&aVous avez activé les notifications!" - disable: "&cVous avez désactivé les notifications!" - stats: "&c&lEF: &eJoueurs caché: &a%players_cached%&e Joueurs sanctionné: &a%players_punished%" - modules: - custompayload: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&n%discord%&r" - -tr: - commands: - reload: "&aPlugin ExploitFixer yeniden yüklendi!" - help: |- - &aExploitFixer &b%version% &ayazan &bLinsaFTW&a. - &e /%command% help &7> &bMevcut komutları gösterir. - &e /%command% reload &7> &bEklentiyi yükler. - &e /%command% notifications &7> &bEklentinin bildirimlerini değiştirir. - &e /%command% stats &7> &bEklentinin istatistiklerini izleyin. - error: - unknown: "&cBilinmeyen komut. Kullanılabilir komutları görmek için / exploitfixer yardımını kullanın!" - permission: "&cBu komutu kullanma izniniz yok!" - console: "&cBu komut konsoldan yürütülemez!" - notifications: - enable: "&aBildirimleri etkinleştirdiniz!" - disable: "&cBildirimleri devre dışı bıraktınız!" - stats: "&c&lEF: &ePlayers önbelleğe alındı: &a%players_cached%&e Players cezalandırıldı: &a%players_punished%" - modules: - custompayload: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%discord%&r" - -#Hungarian -hu: - commands: - reload: "&aAz ExploitFixer sikeresen újraindult!" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW&a. - &e /%command% help &7> &bElérhető parancsok. - &e /%command% reload &7> &bPlugin újraindítása. - &e /%command% notifications &7> &bÉrtesítések ki/be kapcsolása. - &e /%command% stats &7> &bA plugin statisztikáinak megtekintése. - error: - unknown: "&cIsmeretlen parancs. Használd a /exploitfixer help parancsot!" - permission: "&cNincs jogod a parancs használatához!" - console: "&cEzt a parancsot nem bírod használni a konzolból!" - notifications: - enable: "&aBekapcsoltad az értesítéseket!" - disable: "&cKikapcsoltad az értesítéseket!" - stats: "&c&lEF: &eJátékosok: &a%players_cached%&e Büntetések: &a%players_punished%" - modules: - custompayload: - kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fUUID Spoofingot észleltünk.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fCsomag exploitot észleltünk.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cKi lettél rúgva a szerverről!\n\n&7Reason: &fNull addresst észleltünk.\n&7Discord: &b&n%discord%&r" diff --git a/src/plugin.yml b/src/plugin.yml deleted file mode 100644 index 065e826..0000000 --- a/src/plugin.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: ExploitFixer -main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.8 -author: 2LS -api: "1.13" -api-version: "1.13" -softdepend: [HamsterAPI] -commands: - exploitfixer: - description: The main ExploitFixer command - usage: /exploitfixer - aliases: [ef] From c3ae108a9c6e3b2100f8c7df3fcfe60c5d518c24 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Fri, 18 Sep 2020 00:16:36 -0300 Subject: [PATCH 085/336] Updated Source --- .../exploitfixer/shared/modules/MessagesModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index fed0ca3..2d0bd04 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -29,9 +29,10 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("en"); defaultLocales.add("es"); - defaultLocales.add("pt"); - defaultLocales.add("it"); defaultLocales.add("fr"); + defaultLocales.add("hu"); + defaultLocales.add("it"); + defaultLocales.add("pt"); defaultLocales.add("tr"); } From 4b61e6310c4a303604e39af52c14851f67daceb7 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Fri, 18 Sep 2020 03:20:07 -0300 Subject: [PATCH 086/336] Update PacketDecodeListener.java Use the real bytebuf instead of a copy because it isn't necessary. --- .../exploitfixer/bukkit/listener/PacketDecodeListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 5112017..e3644b2 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -76,6 +76,6 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster public void onPacketDecode(final PacketDecodeEvent event) { final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get().copy()); + onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get()); } -} \ No newline at end of file +} From 7fb95a7a6763bc6b723fd38c6066bd3fad08af7a Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+LinsaFTW@users.noreply.github.com> Date: Fri, 18 Sep 2020 06:55:26 -0300 Subject: [PATCH 087/336] Update PacketDecodeListener.java Let HamsterAPI handle ByteBuf when the event is cancelled. --- .../bukkit/listener/PacketDecodeListener.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index e3644b2..26fbc34 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -43,39 +43,29 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; - byteBuf.release(); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (refCnt < 1) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; - byteBuf.release(); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (capacity > dataBytes) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds size limit! Max: " + dataBytes + " Vls: " + dataVls; - byteBuf.release(); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } } else if (packetsModule.isOffline()) { final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; - byteBuf.release(); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); } } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketDecode(final PacketDecodeEvent event) { - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - - onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get()); + onPacketDecode(event, hamsterPlayer, event.getHamsterPlayer().getPlayer(), event.getByteBuf().get()); } } From 5b33dd936decbf5c369375e02ffd9825dcc041c9 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Fri, 18 Sep 2020 06:59:50 -0300 Subject: [PATCH 088/336] Bumped version number --- src/resources/bungee.yml | 2 +- src/resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resources/bungee.yml b/src/resources/bungee.yml index b04a0f8..e029775 100644 --- a/src/resources/bungee.yml +++ b/src/resources/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.8 +version: 1.4.9 author: 2LS commands: exploitfixer: diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index 92b735e..f5c6c25 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.8 +version: 1.4.9 author: 2LS api: "1.13" api-version: "1.13" From d674f6b0c1b23362c712e4206ea5a8d56f8f99ee Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata Date: Sat, 19 Sep 2020 02:06:51 -0300 Subject: [PATCH 089/336] Updated Source --- .../exploitfixer/bukkit/listener/PacketDecodeListener.java | 4 +++- .../exploitfixer/bukkit/listener/PlayerLoginListener.java | 2 +- .../exploitfixer/bungee/listeners/PostLoginListener.java | 2 +- .../_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 26fbc34..9948b18 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -66,6 +66,8 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketDecode(final PacketDecodeEvent event) { - onPacketDecode(event, hamsterPlayer, event.getHamsterPlayer().getPlayer(), event.getByteBuf().get()); + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + + onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get()); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index afdda71..389b874 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -71,7 +71,7 @@ public void onPlayerLogin(final PlayerLoginEvent event) { hamsterPlayer.disconnect(uuidSpoofKickMessage); } - } catch (IOException e) { + } catch (IllegalStateException | IOException e) { hamsterPlayer.disconnect(messagesModule.getMojangDown(locale)); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 643cb26..0482d53 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -62,7 +62,7 @@ public void onPostLogin(final PostLoginEvent event) { player.disconnect(TextComponent .fromLegacyText(messagesModule.getKickMessage("uuidspoof", locale))); } - } catch (IOException e) { + } catch (IllegalStateException | IOException e) { player.disconnect(TextComponent.fromLegacyText(messagesModule.getMojangDown(locale))); } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 5427d33..0e5a992 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -71,7 +71,7 @@ public double getViolations(final IViolationModule module) { return violations.getOrDefault(module, 0D); } - public UUID getOnlineUUID() throws MalformedURLException, IOException { + public UUID getOnlineUUID() throws MalformedURLException, IOException, IllegalStateException { if (onlineUUID == null) { final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) .openConnection(); From 7b70b33fee09bc01d3937cd12f57f39917552831 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 20 Oct 2020 22:58:30 -0300 Subject: [PATCH 090/336] Updated Source --- .../exploitfixer/bukkit/ExploitFixer.java | 9 ++-- .../bukkit/listener/PacketDecodeListener.java | 3 +- .../listener/PacketReceiveListener.java | 51 +++++++++++-------- .../bukkit/listener/PlayerLoginListener.java | 4 +- .../bukkit/modules/ItemsFixModule.java | 11 ++-- .../tasks/ExploitFixerRepeatingTask.java | 30 +++++++++++ .../bukkit/utils/BukkitConfigurationUtil.java | 3 +- .../bukkit/utils/ExploitUtil.java | 16 +++--- .../bukkit/utils/VersionUtil.java | 13 +++-- .../exploitfixer/bungee/ExploitFixer.java | 11 ++-- .../tasks/ExploitFixerRepeatingTask.java | 30 +++++++++++ .../bungee/utils/BungeeConfigurationUtil.java | 3 +- .../shared/modules/NotificationsModule.java | 36 +++++++++++++ 13 files changed, 163 insertions(+), 57 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java create mode 100644 src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 30e1bd0..067ec9e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -9,8 +9,8 @@ import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.tasks.ExploitFixerRepeatingTask; import dev._2lstudios.exploitfixer.bukkit.utils.BukkitConfigurationUtil; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; @@ -54,11 +54,8 @@ public void onEnable() { register(); - scheduler.runTaskTimerAsynchronously(this, () -> { - final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - - exploitPlayerManager.clear(); - }, 6000L, 6000L); + scheduler.runTaskTimerAsynchronously(this, new ExploitFixerRepeatingTask( + moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 20L, 20L); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 9948b18..5ea4113 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -37,6 +37,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final int dataBytes = packetsModule.getDataBytes(); final int refCnt = byteBuf.refCnt(); final int capacity = byteBuf.capacity(); + final int readableBytes = byteBuf.readableBytes(); if (capacity < 0) { final double dataVls = packetsModule.getDataVls(); @@ -50,7 +51,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster + refCnt + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } else if (capacity > dataBytes) { + } else if (capacity > dataBytes || readableBytes > dataBytes) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds size limit! Max: " + dataBytes + " Vls: " + dataVls; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 8aabf80..cb5c17d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -3,8 +3,10 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.GameMode; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; @@ -141,17 +143,25 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final Map objects = packetWrapper.getObjects(); final int dataBytes = packetsModule.getDataBytes(); - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, - packetName, dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + try { + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); + + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, + hamsterPlayer, packetName, dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; + } } } + } catch (final Exception exception) { + final String reason = "[" + packetName + "|Data] " + playerName + + " has sent an unparseable packet! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; } if (dataBytes > 0 && packetSize > dataBytes) { @@ -178,27 +188,28 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster packetsModule.getMultiplier(packetName) + bytesDividerAddition); } - final Map items = packetWrapper.getItems(); - - if (itemsFixModule.isEnabled() && items.containsKey("b")) { - final ItemStack itemStack = items.get("b"); + if (packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled()) { + final Map items = packetWrapper.getItems(); - if (itemStack != null) { - final String blocked = exploitUtil.clearIfBlocked(itemStack); - final ItemStack fixedItemStack = itemsFixModule.fixItem(itemStack); + for (final Entry itemsEntry : items.entrySet()) { + final ItemStack itemStack = itemsEntry.getValue(); - packetWrapper.write("b", fixedItemStack); + if (itemStack != null) { + final String blacklisted = exploitUtil.clearIfBlacklisted(itemStack); - if (player != null) { - if (blocked != null) { + if (blacklisted != null) { + packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); notificationsModule.debug( - player.getName() + " had a creative item blocked by ExploiFixer! (" + blocked + ")"); + player.getName() + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); } else { + packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(itemStack)); notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); } } } } + + notificationsModule.addPacketDebug(packetType.toString()); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index 389b874..2904179 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -37,7 +37,7 @@ public class PlayerLoginListener implements Listener { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerLogin(final PlayerLoginEvent event) { final Player player = event.getPlayer(); final String playerName = player.getName(); @@ -71,7 +71,7 @@ public void onPlayerLogin(final PlayerLoginEvent event) { hamsterPlayer.disconnect(uuidSpoofKickMessage); } - } catch (IllegalStateException | IOException e) { + } catch (final IllegalStateException | IOException e) { hamsterPlayer.disconnect(messagesModule.getMojangDown(locale)); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 117ce56..7313342 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -19,14 +19,15 @@ public class ItemsFixModule implements IModule { private final Plugin plugin; private boolean enabled; - private int enchantLimit, maxStackSize; + private int enchantLimit; + private int maxStackSize; private Collection blacklist; public ItemsFixModule(final Plugin plugin) { this.plugin = plugin; } - final public void reload(final IConfiguration configYml) { + public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); this.enabled = configYml.getBoolean(name + ".enabled"); @@ -36,7 +37,7 @@ final public void reload(final IConfiguration configYml) { } @Override - final public boolean isEnabled() { + public boolean isEnabled() { return enabled; } @@ -59,8 +60,8 @@ public Collection getBlacklist() { public ItemStack fixItem(final ItemStack itemStack) { final Material material = Material.getMaterial(itemStack.getType().name()); - final ItemMeta oldItemMeta = itemStack.getItemMeta(), - newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + final ItemMeta oldItemMeta = itemStack.getItemMeta(); + final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); final short durability = itemStack.getDurability(); if (itemStack.hasItemMeta()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java b/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java new file mode 100644 index 0000000..a57d8ec --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java @@ -0,0 +1,30 @@ +package dev._2lstudios.exploitfixer.bukkit.tasks; + +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; + +public class ExploitFixerRepeatingTask implements Runnable { + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + int seconds = 0; + + public ExploitFixerRepeatingTask(final ExploitPlayerManager exploitPlayerManager, + final NotificationsModule notificationsModule) { + this.exploitPlayerManager = exploitPlayerManager; + this.notificationsModule = notificationsModule; + } + + @Override + public void run() { + if (seconds > 300) { + seconds = 0; + exploitPlayerManager.clear(); + } else { + if (seconds % 10 == 9) { + notificationsModule.debugPackets(); + } + + seconds++; + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java index ba26285..0033304 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java @@ -12,7 +12,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.nio.file.Path; import java.util.logging.Logger; public class BukkitConfigurationUtil implements IConfigurationUtil { @@ -94,7 +93,7 @@ public void delete(final String rawPath) { scheduler.runTaskAsynchronously(plugin, () -> { try { - Files.delete(Path.of(path)); + Files.delete(new File(path).toPath()); logger.info(prefix + " File '" + path + "' has been removed!"); } catch (IOException e) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 84a778e..4b9d7a6 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -1,6 +1,7 @@ package dev._2lstudios.exploitfixer.bukkit.utils; import java.nio.charset.StandardCharsets; +import java.util.Collection; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -146,14 +147,17 @@ public boolean parseSign(final String[] linesString) { return false; } - public String clearIfBlocked(final ItemStack itemStack) { + public String clearIfBlacklisted(final ItemStack itemStack) { + final Collection blacklist = itemsFixModule.getBlacklist(); final String materialName = itemStack.getType().toString(); - for (final String blockedMaterial : itemsFixModule.getBlacklist()) { - if (materialName.equals(blockedMaterial)) { - itemStack.setType(Material.AIR); - itemStack.setItemMeta(null); - return materialName; + if (blacklist != null) { + for (final String blockedMaterial : blacklist) { + if (materialName.equals(blockedMaterial)) { + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + return materialName; + } } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 44e12c8..4864535 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,7 +1,10 @@ package dev._2lstudios.exploitfixer.bukkit.utils; +import java.lang.reflect.InvocationTargetException; + import org.bukkit.Server; import org.bukkit.entity.Player; +import org.bukkit.entity.Player.Spigot; public class VersionUtil { private static boolean oneDotFifteen, oneDotSeven; @@ -17,12 +20,12 @@ public static String getLocale(final Player player) { String locale; try { - player.getClass().getMethod("getLocale"); - locale = player.getLocale(); - } catch (final NoSuchMethodException exception) { + locale = player.getClass().getMethod("getLocale").invoke(player, (Object[]) null).toString(); + } catch (final Exception exception) { try { - player.spigot().getClass().getMethod("getLocale"); - locale = player.spigot().getLocale(); + final Spigot spigot = player.spigot(); + + locale = spigot.getClass().getMethod("getLocale").invoke(spigot, (Object[]) null).toString(); } catch (final Exception exception1) { locale = "en"; } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java index b87fc9d..895148b 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java @@ -5,8 +5,8 @@ import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; import dev._2lstudios.exploitfixer.bungee.listeners.ListenerInitializer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.tasks.ExploitFixerRepeatingTask; import dev._2lstudios.exploitfixer.bungee.utils.BungeeConfigurationUtil; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import net.md_5.bungee.api.plugin.Plugin; @@ -45,11 +45,8 @@ public void onEnable() { register(); - scheduler.schedule(this, () -> { - final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); - - exploitPlayerManager.clear(); - }, 5, 5, TimeUnit.MINUTES); + scheduler.schedule(this, new ExploitFixerRepeatingTask( + moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 1, 1, TimeUnit.SECONDS); } @Override @@ -60,8 +57,6 @@ public void onDisable() { } public void reload() { - final BungeeConfigurationUtil configurationUtil = new BungeeConfigurationUtil(this); - createConfigurations(); final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); diff --git a/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java b/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java new file mode 100644 index 0000000..e38aa1c --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java @@ -0,0 +1,30 @@ +package dev._2lstudios.exploitfixer.bungee.tasks; + +import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; + +public class ExploitFixerRepeatingTask implements Runnable { + private final ExploitPlayerManager exploitPlayerManager; + private final NotificationsModule notificationsModule; + int seconds = 0; + + public ExploitFixerRepeatingTask(final ExploitPlayerManager exploitPlayerManager, + final NotificationsModule notificationsModule) { + this.exploitPlayerManager = exploitPlayerManager; + this.notificationsModule = notificationsModule; + } + + @Override + public void run() { + if (seconds > 300) { + seconds = 0; + exploitPlayerManager.clear(); + } else { + if (seconds % 10 == 9) { + notificationsModule.debugPackets(); + } + + seconds++; + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java index 7834c34..295c5e9 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.nio.file.Path; import java.util.logging.Logger; import dev._2lstudios.exploitfixer.bungee.configuration.BungeeConfiguration; @@ -101,7 +100,7 @@ public void delete(final String rawPath) { scheduler.runAsync(plugin, () -> { try { - Files.delete(Path.of(path)); + Files.delete(new File(path).toPath()); logger.info(prefix + " File '" + path + "' has been removed!"); } catch (IOException e) { diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java index a743710..d09be12 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -1,7 +1,11 @@ package dev._2lstudios.exploitfixer.shared.modules; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; import java.util.logging.Logger; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; @@ -9,6 +13,7 @@ public class NotificationsModule implements INotificationsModule { private final Logger logger; + private final Map packetDebug = new HashMap<>(); private final Collection notifications = new HashSet<>(); private boolean enabled, debug; private String message; @@ -32,6 +37,37 @@ public boolean isEnabled() { return this.enabled; } + public void addPacketDebug(final String packetType) { + if (this.debug) { + packetDebug.put(packetType, packetDebug.getOrDefault(packetType, 0) + 1); + } + } + + public void debugPackets() { + if (this.debug && !packetDebug.isEmpty()) { + final Set> entries = new HashSet<>(packetDebug.entrySet()); + final StringBuilder stringBuilder = new StringBuilder("Received Packets: "); + boolean isFirst = true; + + packetDebug.clear(); + + for (final Entry packetEntry : entries) { + final String packetType = packetEntry.getKey(); + final int amount = packetEntry.getValue(); + + if (isFirst) { + isFirst = false; + } else { + stringBuilder.append(", "); + } + + stringBuilder.append("x").append(amount).append(" ").append(packetType); + } + + debug(stringBuilder.toString()); + } + } + public void debug(final String message) { if (this.debug) { this.logger.info(message); From a543ff85cb0562ade4e04c02d22dc521a2f6a0ad Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 21 Oct 2020 03:51:22 -0300 Subject: [PATCH 091/336] Updated Source --- .../exploitfixer/bukkit/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index cb5c17d..e36b84a 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -209,7 +209,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - notificationsModule.addPacketDebug(packetType.toString()); + notificationsModule.addPacketDebug(String.valueOf(packetType)); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) From 769d31c359dc710f57d0e32ff2ec2b80ff0576cc Mon Sep 17 00:00:00 2001 From: ahdg <36436808+ahdg6@users.noreply.github.com> Date: Sat, 14 Nov 2020 16:42:59 +0800 Subject: [PATCH 092/336] Added Simplified Chinese Translation --- src/resources/locales/zh.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/resources/locales/zh.yml diff --git a/src/resources/locales/zh.yml b/src/resources/locales/zh.yml new file mode 100644 index 0000000..42915e1 --- /dev/null +++ b/src/resources/locales/zh.yml @@ -0,0 +1,28 @@ +commands: + reload: "&aæˆåŠŸé‡è½½æ’ä»¶ExploitFixer!" + help: |- + &aExploitFixer指令: + &e/%command% help &7- &bS显示帮助指令! + &e/%command% reload &7- &bé‡è½½æ’ä»¶! + &e/%command% notifications &7- &b开关æ’ä»¶æ¶ˆæ¯æé†’! + &e/%command% stats &7- &b查看æ’件统计数æ®! + error: + unknown: "&c未知指令。请使用 /exploitfixer help æ¥æŸ¥çœ‹æŒ‡ä»¤!" + permission: "&c你没有使用这个指令的æƒé™!" + console: "&cè¿™ä¸ªæŒ‡ä»¤æ— æ³•åœ¨æŽ§åˆ¶å°æ‰§è¡Œ!" + notifications: + enable: "&a你已开坿醒!" + disable: "&c你已关闭æé†’!" + stats: "&c&lEF: &e已缓存的玩家: &a%players_cached% &e已被惩罚的玩家: &a%players_punished%" +modules: + custompayload: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到CustomPayloadå‘包过多。\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到无效的UUID。\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到滥用指令。\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到å‘包异常。\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&c您被暂时å°ç¦äº†!\n\n&7原因: &f检测到空地å€ã€‚\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang æœåŠ¡å™¨åœæœºäº†ï¼Œè¯·ç¨åŽå†æ¥çœ‹çœ‹!\n\n&7原因: &fExploitFixer 无法检查UUID。\n&7Discord: &b&n%web%&r" From bd2a18eb96437b34455b7c751ed8c2a432df422e Mon Sep 17 00:00:00 2001 From: ahdg <36436808+ahdg6@users.noreply.github.com> Date: Sat, 14 Nov 2020 18:26:46 +0800 Subject: [PATCH 093/336] Rename zh.yml to cn.yml --- src/resources/locales/{zh.yml => cn.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/resources/locales/{zh.yml => cn.yml} (100%) diff --git a/src/resources/locales/zh.yml b/src/resources/locales/cn.yml similarity index 100% rename from src/resources/locales/zh.yml rename to src/resources/locales/cn.yml From a2cc6d10e456a25bbaa207de4d9bcb16725f68ea Mon Sep 17 00:00:00 2001 From: ahdg <36436808+ahdg6@users.noreply.github.com> Date: Sat, 14 Nov 2020 18:28:04 +0800 Subject: [PATCH 094/336] Rename cn.yml to zh.yml --- src/resources/locales/{cn.yml => zh.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/resources/locales/{cn.yml => zh.yml} (100%) diff --git a/src/resources/locales/cn.yml b/src/resources/locales/zh.yml similarity index 100% rename from src/resources/locales/cn.yml rename to src/resources/locales/zh.yml From 1ea1b57b8cea720aa74031fbc6c8cb6e2e823085 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Dec 2020 01:43:53 -0300 Subject: [PATCH 095/336] Updated Source --- .../exploitfixer/bukkit/ExploitFixer.java | 5 +- .../bukkit/exploit/BukkitExploitPlayer.java | 6 +- .../EntityDamageByEntityListener.java | 40 ++++ .../bukkit/listener/ListenerInitializer.java | 6 +- .../bukkit/listener/PacketDecodeListener.java | 21 +- .../listener/PacketReceiveListener.java | 224 +++++++++--------- .../bukkit/listener/PlayerMoveListener.java | 39 +++ .../bukkit/managers/ExploitPlayerManager.java | 2 +- .../bukkit/managers/ModuleManager.java | 10 +- .../bukkit/modules/EventsModule.java | 34 +++ .../bukkit/utils/ExploitUtil.java | 11 +- .../bukkit/utils/VersionUtil.java | 20 -- .../bungee/listeners/ChatListener.java | 3 +- .../bungee/listeners/ListenerInitializer.java | 4 +- .../bungee/listeners/PostLoginListener.java | 53 +---- .../bungee/managers/ExploitPlayerManager.java | 6 +- .../shared/modules/ConnectionModule.java | 7 +- src/resources/bungee.yml | 2 +- src/resources/config.yml | 26 +- src/resources/plugin.yml | 2 +- 20 files changed, 298 insertions(+), 223 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 067ec9e..68ea7ea 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -12,7 +12,6 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.tasks.ExploitFixerRepeatingTask; import dev._2lstudios.exploitfixer.bukkit.utils.BukkitConfigurationUtil; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; public class ExploitFixer extends JavaPlugin { @@ -36,7 +35,7 @@ public void onEnable() { final BukkitScheduler scheduler = server.getScheduler(); if (!checkHamsterAPI()) { - throw new NullPointerException( + throw new IllegalStateException( "ExploitFixer requires HamsterAPI to listen to packets and block exploits! Download: https://www.spigotmc.org/resources/78831/"); } @@ -46,8 +45,6 @@ public void onEnable() { final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - VersionUtil.initialize(server); - moduleManager = new ModuleManager(configurationUtil, this); moduleManager.reload(configYml); listenerInitializer = new ListenerInitializer(this, moduleManager); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java index 10c96db..ced3cdf 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java @@ -38,12 +38,12 @@ public BukkitExploitPlayer(final Plugin plugin, final String name, final ModuleM this.notificationsModule = moduleManager.getNotificationsModule(); } - public void addVls(final Plugin plugin, final Cancellable event, final HamsterPlayer hamsterPlayer, + public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, final IViolationModule module, final double amount) { - addVls(plugin, event, null, hamsterPlayer, module, amount); + addVls(event, null, hamsterPlayer, module, amount); } - public void addVls(final Plugin plugin, final Cancellable event, final PacketWrapper packet, + public void addVls(final Cancellable event, final PacketWrapper packet, final HamsterPlayer hamsterPlayer, final IViolationModule module, final double amount) { final Violations violations = (Violations) module.getViolations(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java new file mode 100644 index 0000000..7239aca --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java @@ -0,0 +1,40 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; + +public class EntityDamageByEntityListener implements Listener { + private final NotificationsModule notificationsModule; + private final EventsModule eventsModule; + + EntityDamageByEntityListener(final ModuleManager moduleManager) { + this.notificationsModule = moduleManager.getNotificationsModule(); + this.eventsModule = moduleManager.getEventsModule(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) { + if (!eventsModule.isSelfDamage()) { + return; + } + + final Entity entity = event.getEntity(); + + if (entity instanceof Player) { + final Entity damager = event.getDamager(); + + if (damager instanceof Player && entity == damager) { + event.setCancelled(true); + notificationsModule.debug("[Events] Cancelled self damage by " + entity.getName() + "!"); + } + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index 19b730e..fce2a77 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -23,12 +23,14 @@ public void register() { final Server server = plugin.getServer(); final PluginManager pluginManager = server.getPluginManager(); - final ExploitUtil exploitUtil = new ExploitUtil(moduleManager, plugin); + final ExploitUtil exploitUtil = new ExploitUtil(moduleManager); + pluginManager.registerEvents(new EntityDamageByEntityListener(moduleManager), plugin); pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); - pluginManager.registerEvents(new PacketReceiveListener(plugin, exploitUtil, moduleManager), plugin); + pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); + pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 5ea4113..6fc895d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -51,12 +51,21 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster + refCnt + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } else if (capacity > dataBytes || readableBytes > dataBytes) { + } else { final double dataVls = packetsModule.getDataVls(); - final String reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds size limit! Max: " - + dataBytes + " Vls: " + dataVls; + String reason = null; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + if (capacity > dataBytes) { + reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds capacity bytes limit! " + capacity + + "/" + dataBytes + " Vls: " + dataVls; + } else if (readableBytes > dataBytes) { + reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + + "/" + dataBytes + " Vls: " + dataVls; + } + + if (reason != null) { + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } } } else if (packetsModule.isOffline()) { final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; @@ -67,6 +76,10 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketDecode(final PacketDecodeEvent event) { + if (!packetsModule.isEnabled()) { + return; + } + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get()); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index e36b84a..087948d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -17,7 +17,6 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; @@ -32,15 +31,13 @@ import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class PacketReceiveListener implements Listener { - private final Plugin plugin; private final ExploitUtil exploitUtil; private final ExploitPlayerManager exploitPlayerManager; private final ItemsFixModule itemsFixModule; private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; - PacketReceiveListener(final Plugin plugin, final ExploitUtil exploitUtil, final ModuleManager moduleManager) { - this.plugin = plugin; + PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); @@ -52,142 +49,139 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final PacketWrapper packetWrapper) { final PacketType packetType = packetWrapper.getType(); - if (packetType != PacketType.PacketPlayInKeepAlive && packetsModule.isEnabled()) { - final Map strings = packetWrapper.getStrings(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String playerName = player.getName(); - final String packetName = packetWrapper.getName(); - final double dataVls = packetsModule.getDataVls(); - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(); - final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); - - if (packetType == PacketType.PacketPlayInCustomPayload) { - if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = packetsModule.getTagVls(); - final double bookVls = packetsModule.getBookVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - final String reason = "[" + packetName + "|Tag] " + playerName - + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); - return; - } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") - || tag.equals("MC|BOpen")) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + if (packetType == PacketType.PacketPlayInKeepAlive) { + return; + } - if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag - + " CustomPayload packet without a book in hand!"; + final Map strings = packetWrapper.getStrings(); + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + final String playerName = player.getName(); + final String packetName = packetWrapper.getName(); + final double dataVls = packetsModule.getDataVls(); + final Map integers = packetWrapper.getIntegers(); + final InventoryView inventoryView = player.getOpenInventory(); + final double windowClick = packetsModule.getWindowClick(); + final double setCreativeSlot = packetsModule.getSetCreativeSlot(); + final int dataBytesSigns = packetsModule.getDataBytesSign(); + + if (packetType == PacketType.PacketPlayInCustomPayload) { + if (!strings.isEmpty()) { + final String tag = strings.values().iterator().next(); + final double tagVls = packetsModule.getTagVls(); + final double bookVls = packetsModule.getBookVls(); + + if (tagVls > 0 && tag == null || tag.isEmpty()) { + final String reason = "[" + packetName + "|Tag] " + playerName + + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); + return; + } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + final PlayerInventory playerInventory = player.getInventory(); + final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); - return; - } + if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { + final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + + " CustomPayload packet without a book in hand!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + return; } + } - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); - } else { - notificationsModule - .debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); + exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); + } else { + notificationsModule.debug("[" + packetName + "] " + playerName + " sent a empty CustomPayload packet!"); - event.setCancelled(true); - } + event.setCancelled(true); } + } - if (windowClick > 0 && integers.containsKey("slot")) { - final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; + if (windowClick > 0 && integers.containsKey("slot")) { + final Inventory topInventory = inventoryView.getTopInventory(); + final Inventory bottomInventory = inventoryView.getBottomInventory(); + final int slot = integers.get("slot"), maxSlots; - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } + if (bottomInventory.getType() == InventoryType.PLAYER && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } - if (slot < 0 && slot != -999 && slot != -1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick; + if (slot < 0 && slot != -999 && slot != -1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } else if (slot >= maxSlots) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " - + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } else if (slot >= maxSlots) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; } + } - if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot - && player.getGameMode() != GameMode.CREATIVE) { - final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName - + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; + if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot + && player.getGameMode() != GameMode.CREATIVE) { + final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); - return; - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); + return; + } - int packetSize = 0; + int packetSize = 0; - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - final int dataBytes = packetsModule.getDataBytes(); + if (dataVls > 0) { + final Map objects = packetWrapper.getObjects(); + final int dataBytes = packetsModule.getDataBytes(); - try { - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); + try { + if (!objects.isEmpty()) { + final Collection objectsValues = objects.values(); - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, - hamsterPlayer, packetName, dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; - } + for (final Object object : objectsValues) { + if (object instanceof ItemStack) { + packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, + packetName, dataBytes); + } else { + packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; } } - } catch (final Exception exception) { - final String reason = "[" + packetName + "|Data] " + playerName - + " has sent an unparseable packet! Added vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; } + } catch (final Exception exception) { + final String reason = "[" + packetName + "|Data] " + playerName + + " has sent an unparseable packet! Added vls: " + dataVls; - if (dataBytes > 0 && packetSize > dataBytes) { - final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize - + " bytes long!"; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { - final String reason = "[" + packetName + "|Data] " + playerName - + " has sent a too big sign packet! Added vls: " + dataVls; + if (dataBytes > 0 && packetSize > dataBytes) { + final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize + + " bytes long!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; } - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign + && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { + final String reason = "[" + packetName + "|Data] " + playerName + + " has sent a too big sign packet! Added vls: " + dataVls; - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } } + final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + + exploitPlayer.addVls(event, hamsterPlayer, packetsModule, + packetsModule.getMultiplier(packetName) + bytesDividerAddition); + if (packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled()) { final Map items = packetWrapper.getItems(); @@ -199,8 +193,8 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); - notificationsModule.debug( - player.getName() + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); + notificationsModule.debug(player.getName() + + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); } else { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(itemStack)); notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); @@ -214,6 +208,10 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPacketReceive(final PacketReceiveEvent event) { + if (!packetsModule.isEnabled()) { + return; + } + final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); onPacketReceive(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getPacket()); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java new file mode 100644 index 0000000..060c1e2 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java @@ -0,0 +1,39 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; + +public class PlayerMoveListener implements Listener { + private final NotificationsModule notificationsModule; + private final EventsModule eventsModule; + + PlayerMoveListener(final ModuleManager moduleManager) { + this.notificationsModule = moduleManager.getNotificationsModule(); + this.eventsModule = moduleManager.getEventsModule(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerMove(final PlayerMoveEvent event) { + if (!eventsModule.isNullChunk()) { + return; + } + + final Location to = event.getTo(); + final World world = to.getWorld(); + final Chunk chunk = to.getChunk(); + + if (chunk == null || !world.isChunkLoaded(chunk)) { + event.setCancelled(true); + notificationsModule.debug("[Events] Cancelled movement to null chunk by " + event.getPlayer().getName() + "!"); + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 0448f03..f246073 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -62,7 +62,7 @@ public void clear() { } if (cleared) { - moduleManager.getNotificationsModule().debug("[ExploitFixer] Cleared unused cached players!"); + moduleManager.getNotificationsModule().debug("Cleared unused cached players!"); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java index acb9d11..25b6547 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java @@ -7,6 +7,7 @@ import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; @@ -19,6 +20,7 @@ public class ModuleManager { private final Plugin plugin; private final CommandsModule commandsModule; private final ConnectionModule connectionModule; + private final EventsModule eventsModule; private final ItemsFixModule itemsFixModule; private final MessagesModule messagesModule; private final BukkitNotificationsModule notificationsModule; @@ -33,9 +35,10 @@ public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin pl this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); + this.eventsModule = new EventsModule(); this.itemsFixModule = new ItemsFixModule(plugin); this.messagesModule = new MessagesModule(configurationUtil, logger, plugin.getDescription().getVersion()); - this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), plugin.getLogger(), server); + this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), logger, server); this.packetsModule = new PacketsModule(); this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); } @@ -48,6 +51,7 @@ public void reload(final IConfiguration configYml) { this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); + this.eventsModule.reload(configYml); this.itemsFixModule.reload(configYml); this.messagesModule.reload(configYml, localeFolder); this.notificationsModule.reload(configYml); @@ -71,6 +75,10 @@ public ConnectionModule getConnectionModule() { return connectionModule; } + public EventsModule getEventsModule() { + return eventsModule; + } + public ItemsFixModule getItemsFixModule() { return itemsFixModule; } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java new file mode 100644 index 0000000..9ce1c60 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java @@ -0,0 +1,34 @@ +package dev._2lstudios.exploitfixer.bukkit.modules; + +import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.shared.interfaces.IModule; + +public class EventsModule implements IModule { + private boolean nullChunk; + private boolean selfDamage; + + public void reload(final IConfiguration configYml) { + final String name = getName().toLowerCase(); + + nullChunk = configYml.getBoolean(name + ".null_chunk"); + selfDamage = configYml.getBoolean(name + ".self_damage"); + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return "events"; + } + + public boolean isSelfDamage() { + return selfDamage; + } + + public boolean isNullChunk() { + return nullChunk; + } +} diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 4b9d7a6..d8f1940 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -12,7 +12,6 @@ import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; @@ -27,14 +26,12 @@ public class ExploitUtil { private final ItemsFixModule itemsFixModule; private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; - private final Plugin plugin; - public ExploitUtil(final ModuleManager moduleManager, final Plugin plugin) { + public ExploitUtil(final ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); - this.plugin = plugin; } private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, @@ -50,7 +47,7 @@ private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final Hamst + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " + dataVls); - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + exploitPlayer.addVls(null, hamsterPlayer, packetsModule, dataVls); } else { for (final String page : bookMeta.getPages()) { final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; @@ -62,7 +59,7 @@ private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final Hamst + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" + dataBytesBook + ") Added vls: " + dataVls); - exploitPlayer.addVls(plugin, null, hamsterPlayer, packetsModule, dataVls); + exploitPlayer.addVls(null, hamsterPlayer, packetsModule, dataVls); break; } } @@ -172,7 +169,7 @@ public void cancelExploit(final Cancellable event, final HamsterPlayer hamsterPl if (vls > 0) { final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - exploitPlayer.addVls(plugin, event, hamsterPlayer, packetsModule, vls); + exploitPlayer.addVls(event, hamsterPlayer, packetsModule, vls); } } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 4864535..6fe6ef5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -1,21 +1,9 @@ package dev._2lstudios.exploitfixer.bukkit.utils; -import java.lang.reflect.InvocationTargetException; - -import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.entity.Player.Spigot; public class VersionUtil { - private static boolean oneDotFifteen, oneDotSeven; - - public static void initialize(final Server server) { - final String version = server.getVersion(); - - oneDotFifteen = version.contains("1.15"); - oneDotSeven = version.contains("1.7"); - } - public static String getLocale(final Player player) { String locale; @@ -37,12 +25,4 @@ public static String getLocale(final Player player) { return "en"; } } - - public static boolean isOneDotFifteen() { - return oneDotFifteen; - } - - public static boolean isOneDotSeven() { - return oneDotSeven; - } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index e922a76..9429391 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -8,14 +8,13 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; public class ChatListener implements Listener { private final CommandsModule commandsModule; private final ExploitPlayerManager exploitPlayerManager; - ChatListener(final Plugin plugin, final ModuleManager moduleManager) { + ChatListener(final ModuleManager moduleManager) { this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java index 74925ba..4bd7dd2 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java @@ -21,10 +21,10 @@ public void register() { final ProxyServer server = this.plugin.getProxy(); final PluginManager pluginManager = server.getPluginManager(); - pluginManager.registerListener(plugin, new ChatListener(plugin, moduleManager)); + pluginManager.registerListener(plugin, new ChatListener(moduleManager)); pluginManager.registerListener(plugin, new DisconnectListener(moduleManager)); pluginManager.registerListener(plugin, new PluginMessageListener(moduleManager)); - pluginManager.registerListener(plugin, new PostLoginListener(plugin, moduleManager)); + pluginManager.registerListener(plugin, new PostLoginListener(moduleManager)); } public void unregister() { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java index 0482d53..c35d842 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java @@ -1,38 +1,28 @@ package dev._2lstudios.exploitfixer.bungee.listeners; +import java.net.InetSocketAddress; + +import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; +import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; -import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.UUID; public class PostLoginListener implements Listener { - private final Plugin plugin; private final ConnectionModule connectionModule; private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; - private final ExploitPlayerManager exploitPlayerManager; - PostLoginListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; + PostLoginListener(final ModuleManager moduleManager) { this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST) @@ -44,33 +34,6 @@ public void onPostLogin(final PostLoginEvent event) { if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { player.disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); - } else { - final UUID originalUUID = player.getUniqueId(); - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - if (connectionModule.isUUIDSpoofEnabled()) { - final TaskScheduler scheduler = plugin.getProxy().getScheduler(); - - scheduler.runAsync(plugin, () -> { - final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); - - if (!originalUUID.equals(offlineUUID)) { - try { - final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - - if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { - player.disconnect(TextComponent - .fromLegacyText(messagesModule.getKickMessage("uuidspoof", locale))); - } - } catch (IllegalStateException | IOException e) { - player.disconnect(TextComponent.fromLegacyText(messagesModule.getMojangDown(locale))); - } - } - - exploitPlayer.setLogged(true); - }); - } else - exploitPlayer.setLogged(true); } if (player.hasPermission("exploitfixer.notifications")) { diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java index 8ca5910..3ee2c7c 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java @@ -59,7 +59,7 @@ public void clear() { } if (cleared) { - moduleManager.getNotificationsModule().debug("[ExploitFixer] Cleared unused cached players!"); + moduleManager.getNotificationsModule().debug("Cleared unused cached players!"); } } @@ -72,6 +72,8 @@ public int getPunishments() { } public int addPunishment() { - return punishments += 1; + punishments += 1; + + return punishments; } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java index 2813535..b0dcc6f 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java @@ -6,14 +6,15 @@ import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; public class ConnectionModule implements IPunishmentModule { - private boolean uuidSpoofEnabled, nullAddressEnabled; + private boolean uuidSpoofEnabled; + private boolean nullAddressEnabled; private String name; private Collection punishments; public void reload(final IConfiguration configYml) { this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof"); - this.nullAddressEnabled = configYml.getBoolean("connection.nulladdress"); - this.name = "UUID-Spoof"; + this.nullAddressEnabled = configYml.getBoolean("connection.null_address"); + this.name = "Connection"; this.punishments = configYml.getStringList("connection.punishments"); } diff --git a/src/resources/bungee.yml b/src/resources/bungee.yml index e029775..96bdd48 100644 --- a/src/resources/bungee.yml +++ b/src/resources/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.4.9 +version: 1.5.1 author: 2LS commands: exploitfixer: diff --git a/src/resources/config.yml b/src/resources/config.yml index e3912a2..7312fb1 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -4,9 +4,6 @@ # # WARNING: Only Notifications, Connection, Commands and Packets (CustomPayload only) modules work on BungeeCord. # -# This is because the other modules can't be executed on BungeeCord. -# The other modules require ExploitFixer to be installed on Bukkit with HamsterAPI. (No performance impact) -# # INSTALL THE PLUGIN ON BUNGEECORD AND ALL BUKKIT SERVERS! # # Most of the check use Violations (vls), this a counter to execute different @@ -25,26 +22,31 @@ notifications: # Placeholders: %player% %ping% %check% %vls% message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" - # This shows extra information about packets blocked. - # Useful to identify false positives and reporting errors. + # This shows extra information about blocked packets. debug: false -# Prevents a variety of exploits that occur on player connection. -# Players wont be able to type messages/commands until the connection is secured. (You won't notice this) +# Prevents exploits that occur on different Bukkit events. +events: + # Prevents moving if the chunk is null. (Prevents chunk overloading) + null_chunk: true + + # Prevents players from damaging themselves and consuming ram. + self_damage: true + +# Prevents exploits that occur on player connection. connection: - # Prevents changing UUIDs with spoofed BungeeCord IP Forwarding. + # Prevents stealing admin's account. (ForceOP/UUIDSpoof) # UUIDSpoof only affects non-firewalled servers with bungeecord: true. uuidspoof: true - # Prevents null addresses from fake Bungee IP Forwarding to bypass IP Whitelist. + # Prevents bypassing IPWhitelist to steal accounts. # NullAddress only affects non-firewalled servers using IP Whitelist. - nulladdress: true + null_address: true # Commands to run when a player is detected. punishments: [] -# Prevents the use of invalid packets to exploit your server. -# This is the most advanced category in the plugin and it's not recommended to disable it. +# Prevents the use of invalid packets to crash the server. packets: enabled: true diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index f5c6c25..e428c81 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.4.9 +version: 1.5.1 author: 2LS api: "1.13" api-version: "1.13" From 325c90c9f117f6da1ba250f098e9900b196da15d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Dec 2020 02:13:45 -0300 Subject: [PATCH 096/336] Updated Source --- .../bukkit/configuration/BukkitConfiguration.java | 7 ++++++- .../exploitfixer/bukkit/modules/EventsModule.java | 4 ++-- .../bungee/configuration/BungeeConfiguration.java | 7 ++++++- .../exploitfixer/shared/configuration/IConfiguration.java | 4 +++- .../exploitfixer/shared/modules/MessagesModule.java | 4 ++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java index 76df4ae..774dfef 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java @@ -45,7 +45,7 @@ public String getString(final String path) { } @Override - public String getStringOrDefault(String path, String def) { + public String getString(String path, String def) { if (contains(path)) { return getString(path); } else { @@ -73,6 +73,11 @@ public boolean getBoolean(final String path) { return configuration.getBoolean(path); } + @Override + public boolean getBoolean(final String path, final boolean def) { + return configuration.getBoolean(path, def); + } + @Override public boolean contains(final String path) { return configuration.contains(path); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java index 9ce1c60..c389701 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java @@ -10,8 +10,8 @@ public class EventsModule implements IModule { public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); - nullChunk = configYml.getBoolean(name + ".null_chunk"); - selfDamage = configYml.getBoolean(name + ".self_damage"); + nullChunk = configYml.getBoolean(name + ".null_chunk", true); + selfDamage = configYml.getBoolean(name + ".self_damage", true); } @Override diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java index 98ffe53..29536f5 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java @@ -44,7 +44,7 @@ public String getString(final String path) { } @Override - public String getStringOrDefault(String path, String def) { + public String getString(String path, String def) { if (contains(path)) { return getString(path); } else { @@ -72,6 +72,11 @@ public boolean getBoolean(final String path) { return configuration.getBoolean(path); } + @Override + public boolean getBoolean(final String path, final boolean def) { + return configuration.getBoolean(path, def); + } + @Override public boolean contains(final String path) { return configuration.contains(path); diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java index 708ebf2..6725155 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java @@ -11,7 +11,7 @@ public interface IConfiguration { public String getString(final String path); - public String getStringOrDefault(final String path, final String def); + public String getString(final String path, final String def); public double getDouble(final String path); @@ -21,6 +21,8 @@ public interface IConfiguration { public boolean getBoolean(final String path); + public boolean getBoolean(final String path, final boolean def); + public Object getObject(); public boolean contains(final String string); diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 2d0bd04..833a455 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -57,8 +57,8 @@ public void putSection(final IConfiguration langFile, final Map } public void reload(final IConfiguration configYml, final File localeFolder) { - web = configYml.getStringOrDefault("web", " (Reset ExploitFixer config file)"); - defaultLocale = configYml.getStringOrDefault("locale", "en").toLowerCase(); + web = configYml.getString("web", " (Reset ExploitFixer config file)"); + defaultLocale = configYml.getString("locale", "en").toLowerCase(); for (final String locale : defaultLocales) { configurationUtil.create("%datafolder%/locales/" + locale + ".yml", "locales/" + locale + ".yml"); From 6fab7a3cd683909b093d80129b6ef87b4fec131f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Dec 2020 10:18:57 -0300 Subject: [PATCH 097/336] Updated Source --- .../exploitfixer/bungee/listeners/ChatListener.java | 4 +--- src/resources/bungee.yml | 2 +- src/resources/plugin.yml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java index 9429391..19fa653 100644 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java @@ -28,9 +28,7 @@ public void onChat(final ChatEvent event) { final ProxiedPlayer player = (ProxiedPlayer) connection; final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (!exploitPlayer.isLogged()) { - event.setCancelled(true); - } else if (commandsModule.isEnabled()) { + if (commandsModule.isEnabled()) { final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { diff --git a/src/resources/bungee.yml b/src/resources/bungee.yml index 96bdd48..2d2f9c4 100644 --- a/src/resources/bungee.yml +++ b/src/resources/bungee.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.5.1 +version: 1.5.2 author: 2LS commands: exploitfixer: diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index e428c81..dc46f31 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.1 +version: 1.5.2 author: 2LS api: "1.13" api-version: "1.13" From f530dc1040cc4e4b2ba871dfc5651ff2f2a64de0 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Mon, 8 Mar 2021 20:15:05 -0300 Subject: [PATCH 098/336] Added .gitignore and pom.xml --- .gitignore | 6 +++++ pom.xml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..387d394 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.project +.vscode +.settings +.factorypath +.classpath +/target \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a591414 --- /dev/null +++ b/pom.xml @@ -0,0 +1,76 @@ + + 4.0.0 + exploitfixer + ExploitFixer + SNAPSHOT + + 1.8 + 1.8 + + + ${project.artifactId} + src + + + . + ${basedir}/src/resources/ + + + + + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + + + + + org.spigotmc + spigot-api + 1.16.5-R0.1-SNAPSHOT + provided + + + net.md-5 + bungeecord-api + 1.16-R0.5-SNAPSHOT + jar + provided + + + net.md-5 + bungeecord-api + 1.16-R0.5-SNAPSHOT + javadoc + provided + + + net + ProtocolLib + SNAPSHOT + system + C:\JAR Files\ProtocolLib.jar + + + net + HamsterAPI + SNAPSHOT + system + C:\JAR Files\HamsterAPI.jar + + + \ No newline at end of file From 4a539a4b868f0b0a1092dd55cce35733f7053780 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Mon, 8 Mar 2021 20:20:09 -0300 Subject: [PATCH 099/336] Block TabComplete from blocked commands --- .../bukkit/listener/ListenerInitializer.java | 1 + .../bukkit/listener/TabCompleteListener.java | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index fce2a77..1bda460 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -32,6 +32,7 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new TabCompleteListener(moduleManager), plugin); } public void unregister() { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java new file mode 100644 index 0000000..ed9aedd --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java @@ -0,0 +1,55 @@ +package dev._2lstudios.exploitfixer.bukkit.listener; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.server.TabCompleteEvent; + +import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; +import dev._2lstudios.hamsterapi.HamsterAPI; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; + +public class TabCompleteListener implements Listener { + private final HamsterPlayerManager hamsterPlayerManager; + private final CommandsModule commandsModule; + private final ExploitPlayerManager exploitPlayerManager; + + TabCompleteListener(final ModuleManager moduleManager) { + this.hamsterPlayerManager = HamsterAPI.getInstance().getHamsterPlayerManager(); + this.commandsModule = moduleManager.getCommandsModule(); + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerCommand(final TabCompleteEvent event) { + final CommandSender sender = event.getSender(); + + if (sender instanceof Player) { + final Player player = (Player) sender; + final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + if (!exploitPlayer.isLogged()) { + event.setCancelled(true); + } else if (commandsModule.isEnabled()) { + final String message = event.getBuffer().replaceAll("[\\w]{1,}:", "").toLowerCase(); + + for (final String command : commandsModule.getCommands()) { + if (message.startsWith(command)) { + final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); + + exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); + + event.setCancelled(true); + break; + } + } + } + } + } +} \ No newline at end of file From 9cfa12e08d4de7694d958d7ced742659c006985c Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Mon, 8 Mar 2021 20:49:07 -0300 Subject: [PATCH 100/336] Removed ProtocolLib dependency --- pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pom.xml b/pom.xml index a591414..541993f 100644 --- a/pom.xml +++ b/pom.xml @@ -58,13 +58,6 @@ javadoc provided - - net - ProtocolLib - SNAPSHOT - system - C:\JAR Files\ProtocolLib.jar - net HamsterAPI From 16b0b85748b97655056aa7432f41d193474e9815 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Wed, 10 Mar 2021 12:27:39 -0300 Subject: [PATCH 101/336] Fixed bugs --- .../bukkit/listener/PacketReceiveListener.java | 8 +++++++- .../exploitfixer/shared/modules/MessagesModule.java | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 087948d..885ad16 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -177,7 +177,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - final double bytesDividerAddition = packetSize / packetsModule.getDataBytesDivider(); + final double bytesDividerAddition; + + if (packetsModule.getDataBytesDivider() > 0) { + bytesDividerAddition = (double) packetSize / packetsModule.getDataBytesDivider(); + } else { + bytesDividerAddition = packetSize; + } exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName) + bytesDividerAddition); diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 833a455..8733fb7 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -13,7 +13,7 @@ import dev._2lstudios.exploitfixer.shared.interfaces.IModule; public class MessagesModule implements IMessagesModule { - private static final String NOTFOUND_STRING = " (Reset ExploitFixer locale folder)"; + private static final String NOTFOUND_STRING = ""; private final IConfigurationUtil configurationUtil; private final Logger logger; private final String version; @@ -94,11 +94,11 @@ public String getString(final String locale, final String path) { final String string; if (locales.containsKey(locale)) { - string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING); + string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); } else if (locales.containsKey(defaultLocale)) { - string = locales.get(defaultLocale).getOrDefault(path, NOTFOUND_STRING); + string = locales.get(defaultLocale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); } else { - string = NOTFOUND_STRING; + string = NOTFOUND_STRING.replace("%PATH%", locale.toUpperCase()); } return string.replace("%version%", version).replace("%web%", web).replace('&', '\u00a7'); From 440abb01d52b17bc47033ccf512b330213403c0f Mon Sep 17 00:00:00 2001 From: Rollczi Date: Fri, 26 Mar 2021 03:19:58 +0100 Subject: [PATCH 102/336] Add Polish language support. --- src/resources/locales/pl.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/resources/locales/pl.yml diff --git a/src/resources/locales/pl.yml b/src/resources/locales/pl.yml new file mode 100644 index 0000000..bd5b1cd --- /dev/null +++ b/src/resources/locales/pl.yml @@ -0,0 +1,29 @@ +# Polish - Credits: Rollczi +commands: + reload: "&aExploitFixer zostaÅ‚ przeÅ‚adowany!" + help: |- + &aExploitFixer &b%version%&a stworzony przez &bLinsaFTW&a. + &e /%command% help &7> &bLista dostÄ™pnych komend. + &e /%command% reload &7> &bPrzeÅ‚adowanie konfiguracji pluginu. + &e /%command% notifications &7> &bWłącza i wyłącza powiadomienia pluginu. + &e /%command% stats &7> &bStatystyki pluginu. + error: + unknown: "&cNieznana komenda. Użyj /exploitfixer help, aby zobaczyć listÄ™ komend!" + permission: "&cNie masz permisji do tej komendy!" + console: "&cTego polecenia nie można wykonać z poziomu konsoli!" + notifications: + enable: "&aWłączono powiadomienia!" + disable: "&cWyłączono powiadomienia!" + stats: "&c&lEF: &eGracze w pamiÄ™ci podrÄ™cznej: &a%players_cached%&e Ukarani gracze : &a%players_punished%" +modules: + custompayload: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto zbyt wiele pakietów CustomPayload.\n&7Discord: &b&n%web%&r" + uuidspoof: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto podszywanie siÄ™ pod UUID.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploit poleceÅ„.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploity dla pakietów.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto \"null address\".\n&7Discord: &b&n%web%&r" +mojang_down: "&cSerwery Mojang przestaÅ‚y dziaÅ‚ać! Spróbuj wejść na serwer później!\n\n&7Powód: &fExploitFixer nie może sprawdzić UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file From 8e33b075e094ad9a1385c03787e8d0496515461d Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 30 Mar 2021 16:33:04 -0300 Subject: [PATCH 103/336] Removed Connection Module --- .../bukkit/exploit/BukkitExploitPlayer.java | 3 +- .../bukkit/listener/ListenerInitializer.java | 1 - .../listener/PlayerCommandListener.java | 4 +- .../bukkit/listener/PlayerLoginListener.java | 54 +-------- .../bukkit/listener/PlayerQuitListener.java | 1 - .../bukkit/listener/TabCompleteListener.java | 4 +- .../bukkit/managers/ExploitPlayerManager.java | 6 +- .../exploitfixer/bungee/ExploitFixer.java | 91 -------------- .../bungee/commands/ExploitFixerCommand.java | 74 ------------ .../configuration/BungeeConfiguration.java | 89 -------------- .../bungee/exploit/BungeeExploitPlayer.java | 109 ----------------- .../bungee/listeners/ChatListener.java | 46 -------- .../bungee/listeners/DisconnectListener.java | 30 ----- .../bungee/listeners/ListenerInitializer.java | 42 ------- .../listeners/PluginMessageListener.java | 61 ---------- .../bungee/listeners/PostLoginListener.java | 43 ------- .../bungee/managers/ExploitPlayerManager.java | 79 ------------- .../bungee/managers/ModuleManager.java | 85 -------------- .../modules/BungeeNotificationsModule.java | 39 ------ .../tasks/ExploitFixerRepeatingTask.java | 30 ----- .../bungee/utils/BungeeConfigurationUtil.java | 111 ------------------ .../bungee/utils/VersionUtil.java | 26 ---- .../shared/exploit/ExploitPlayer.java | 53 +-------- .../shared/modules/ConnectionModule.java | 6 - src/resources/config.yml | 17 +-- src/resources/locales/en.yml | 2 - src/resources/locales/es.yml | 2 - src/resources/locales/fr.yml | 2 - src/resources/locales/hu.yml | 2 - src/resources/locales/it.yml | 2 - src/resources/locales/pl.yml | 2 - src/resources/locales/pt.yml | 2 - src/resources/locales/tr.yml | 2 - src/resources/locales/zh.yml | 2 - 34 files changed, 12 insertions(+), 1110 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java delete mode 100644 src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java index ced3cdf..3f88e9a 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java @@ -30,8 +30,7 @@ public class BukkitExploitPlayer extends ExploitPlayer { private final MessagesModule messagesModule; private final NotificationsModule notificationsModule; - public BukkitExploitPlayer(final Plugin plugin, final String name, final ModuleManager moduleManager) { - super(name); + public BukkitExploitPlayer(final Plugin plugin, final ModuleManager moduleManager) { this.plugin = plugin; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index 1bda460..d49d4a9 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -29,7 +29,6 @@ public void register() { pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); - pluginManager.registerEvents(new PlayerLoginListener(plugin, moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new TabCompleteListener(moduleManager), plugin); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index 4456113..3bf4b3f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -30,9 +30,7 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (!exploitPlayer.isLogged()) { - event.setCancelled(true); - } else if (commandsModule.isEnabled()) { + if (commandsModule.isEnabled()) { final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index 2904179..dbfc49d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -1,40 +1,28 @@ package dev._2lstudios.exploitfixer.bukkit.listener; +import java.net.InetAddress; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitScheduler; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; +import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; - -import java.io.IOException; -import java.net.InetAddress; -import java.util.UUID; public class PlayerLoginListener implements Listener { - private final Plugin plugin; private final BukkitNotificationsModule notificationsModule; private final MessagesModule messagesModule; private final ConnectionModule connectionModule; - private final ExploitPlayerManager exploitPlayerManager; - PlayerLoginListener(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; + PlayerLoginListener(final ModuleManager moduleManager) { this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @@ -49,38 +37,6 @@ public void onPlayerLogin(final PlayerLoginEvent event) { event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - } else { - final UUID originalUUID = player.getUniqueId(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - if (connectionModule.isUUIDSpoofEnabled()) { - final BukkitScheduler scheduler = plugin.getServer().getScheduler(); - - scheduler.runTaskAsynchronously(plugin, () -> { - final UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes()); - - if (!originalUUID.equals(offlineUUID)) { - final HamsterPlayer hamsterPlayer = HamsterAPI.getInstance().getHamsterPlayerManager() - .get(player); - - try { - final UUID onlineUUID = exploitPlayer.getOnlineUUID(); - - if (onlineUUID == null || !originalUUID.equals(onlineUUID)) { - final String uuidSpoofKickMessage = messagesModule.getKickMessage("uuidspoof", locale); - - hamsterPlayer.disconnect(uuidSpoofKickMessage); - } - } catch (final IllegalStateException | IOException e) { - hamsterPlayer.disconnect(messagesModule.getMojangDown(locale)); - } - } - - exploitPlayer.setLogged(true); - }); - } else { - exploitPlayer.setLogged(true); - } } if (player.hasPermission("exploitfixer.notifications")) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java index 8c0317e..b6367ec 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java @@ -25,7 +25,6 @@ public void onPlayerQuit(final PlayerQuitEvent event) { final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); exploitPlayer.clear(); - exploitPlayer.setLogged(false); notificationsModule.setNotifications(player.getName(), false); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java index ed9aedd..fde38bb 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java @@ -34,9 +34,7 @@ public void onPlayerCommand(final TabCompleteEvent event) { final Player player = (Player) sender; final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (!exploitPlayer.isLogged()) { - event.setCancelled(true); - } else if (commandsModule.isEnabled()) { + if (commandsModule.isEnabled()) { final String message = event.getBuffer().replaceAll("[\\w]{1,}:", "").toLowerCase(); for (final String command : commandsModule.getCommands()) { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index f246073..4cc2019 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -31,7 +31,7 @@ public BukkitExploitPlayer get(final Player player) { if (exploitPlayers.containsKey(uuid)) { exploitPlayer = exploitPlayers.get(uuid); } else { - exploitPlayer = new BukkitExploitPlayer(this.plugin, player.getName(), moduleManager); + exploitPlayer = new BukkitExploitPlayer(this.plugin, moduleManager); exploitPlayers.put(uuid, exploitPlayer); } @@ -42,9 +42,7 @@ public void reload() { exploitPlayers.clear(); for (final Player player : server.getOnlinePlayers()) { - final BukkitExploitPlayer exploitPlayer = get(player); - - exploitPlayer.setLogged(true); + get(player); } } diff --git a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java deleted file mode 100644 index 895148b..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/ExploitFixer.java +++ /dev/null @@ -1,91 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee; - -import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; - -import dev._2lstudios.exploitfixer.bungee.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bungee.listeners.ListenerInitializer; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.tasks.ExploitFixerRepeatingTask; -import dev._2lstudios.exploitfixer.bungee.utils.BungeeConfigurationUtil; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.plugin.PluginManager; -import net.md_5.bungee.api.scheduler.TaskScheduler; - -public class ExploitFixer extends Plugin { - private static ExploitFixer instance; - private BungeeConfigurationUtil configurationUtil; - private ModuleManager moduleManager; - private ListenerInitializer listenerInitializer; - - public static synchronized ExploitFixer getInstance() { - return instance; - } - - public static synchronized void setInstance(final ExploitFixer exploitFixer) { - ExploitFixer.instance = exploitFixer; - } - - @Override - public void onEnable() { - setInstance(this); - - final TaskScheduler scheduler = getProxy().getScheduler(); - - configurationUtil = new BungeeConfigurationUtil(this); - - createConfigurations(); - - final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - - moduleManager = new ModuleManager(configurationUtil, this); - moduleManager.reload(configYml); - listenerInitializer = new ListenerInitializer(this, moduleManager); - - register(); - - scheduler.schedule(this, new ExploitFixerRepeatingTask( - moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 1, 1, TimeUnit.SECONDS); - } - - @Override - public void onDisable() { - final TaskScheduler scheduler = getProxy().getScheduler(); - - scheduler.cancel(this); - } - - public void reload() { - createConfigurations(); - - final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); - - moduleManager.reload(configYml); - - register(); - } - - private void createConfigurations() { - configurationUtil.create("%datafolder%/config.yml", "config.yml"); - } - - private void register() { - final Logger logger = getLogger(); - final PluginManager pluginManager = getProxy().getPluginManager(); - - pluginManager.unregisterCommands(this); - pluginManager.registerCommand(this, - new ExploitFixerCommand("exploitfixer", new String[] { "ef" }, this, moduleManager)); - - logger.info("Successfully registered commands!"); - - if (this.listenerInitializer.isRegistered()) { - this.listenerInitializer.unregister(); - } - - this.listenerInitializer.register(); - - logger.info("Successfully registered listeners!"); - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java deleted file mode 100644 index abab0c9..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/commands/ExploitFixerCommand.java +++ /dev/null @@ -1,74 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.commands; - -import dev._2lstudios.exploitfixer.bungee.ExploitFixer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Command; - -public class ExploitFixerCommand extends Command { - private final ExploitFixer exploitFixer; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsVariables; - private final ExploitPlayerManager exploitPlayerManager; - - public ExploitFixerCommand(final String string, final String[] aliases, final ExploitFixer exploitFixer, - final ModuleManager moduleManager) { - super(string, null, aliases); - this.exploitFixer = exploitFixer; - this.messagesModule = moduleManager.getMessagesModule(); - this.notificationsVariables = moduleManager.getNotificationsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @Override - public void execute(final CommandSender commandSender, final String[] args) { - String lang = "en"; - final int length = args.length; - - if (commandSender instanceof ProxiedPlayer) { - lang = VersionUtil.getLocale((ProxiedPlayer) commandSender); - } - - if (length < 1 || args[0].equals("help")) { - commandSender.sendMessage( - TextComponent.fromLegacyText(messagesModule.getHelp(lang).replace("%command%", "exploitfixer"))); - } else if (args[0].equals("reload")) - if (commandSender.hasPermission("exploitfixer.admin")) { - exploitFixer.reload(); - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getReload(lang))); - } else - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); - else if (args[0].equals("stats")) - if (commandSender.hasPermission("exploitfixer.admin")) - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getStats(lang) - .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) - .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize())))); - else - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); - else if (args[0].equalsIgnoreCase("notifications")) { - if (commandSender instanceof ProxiedPlayer) { - if (commandSender.hasPermission("exploitfixer.admin") - || commandSender.hasPermission("exploitfixer.notifications")) { - final String playerName = commandSender.getName(); - - if (!notificationsVariables.isNotifications(playerName)) { - notificationsVariables.setNotifications(playerName, true); - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getEnable(lang))); - } else { - notificationsVariables.setNotifications(playerName, false); - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getDisable(lang))); - } - } else - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getPermission(lang))); - } else - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getConsole(lang))); - } else - commandSender.sendMessage(TextComponent.fromLegacyText(messagesModule.getUnknown(lang))); - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java b/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java deleted file mode 100644 index 29536f5..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/configuration/BungeeConfiguration.java +++ /dev/null @@ -1,89 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.configuration; - -import java.util.Collection; -import java.util.HashSet; - -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import net.md_5.bungee.config.Configuration; - -public class BungeeConfiguration implements IConfiguration { - private final Configuration configuration; - - public BungeeConfiguration(final Configuration configuration) { - this.configuration = configuration; - } - - @Override - public IConfiguration getSection(final String path) { - final Object section = configuration.get(path); - - if (section instanceof Configuration) { - return new BungeeConfiguration((Configuration) section); - } else { - return null; - } - } - - @Override - public Collection getKeys() { - return configuration.getKeys(); - } - - @Override - public Collection getStringList(final String path) { - if (configuration.contains(path)) { - return new HashSet<>(configuration.getStringList(path)); - } else { - return null; - } - } - - @Override - public String getString(final String path) { - return configuration.getString(path); - } - - @Override - public String getString(String path, String def) { - if (contains(path)) { - return getString(path); - } else { - return def; - } - } - - @Override - public double getDouble(final String path) { - return configuration.getDouble(path); - } - - @Override - public long getLong(final String path) { - return configuration.getLong(path); - } - - @Override - public int getInt(final String path) { - return configuration.getInt(path); - } - - @Override - public boolean getBoolean(final String path) { - return configuration.getBoolean(path); - } - - @Override - public boolean getBoolean(final String path, final boolean def) { - return configuration.getBoolean(path, def); - } - - @Override - public boolean contains(final String path) { - return configuration.contains(path); - } - - @Override - public Object getObject() { - return configuration; - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java deleted file mode 100644 index 13101b5..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/exploit/BungeeExploitPlayer.java +++ /dev/null @@ -1,109 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.exploit; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; - -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; -import dev._2lstudios.exploitfixer.shared.exploit.Violations; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Cancellable; - -public class BungeeExploitPlayer extends ExploitPlayer { - private final ProxyServer server; - private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsModule; - - public BungeeExploitPlayer(final ProxyServer server, final String name, final ModuleManager moduleManager) { - super(name); - this.server = server; - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.messagesModule = moduleManager.getMessagesModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - } - - public void addVls(final Object event, final ProxiedPlayer player, final IViolationModule module, - final double amount) { - if (player.isConnected()) { - final Violations violations = (Violations) module.getViolations(); - - if (violations != null) { - final Map violationsMap = getViolations(); - final long currentTime = System.currentTimeMillis(); - final long lastViolation = getLastViolation(); - - if (currentTime - lastViolation >= 1000) { - setLastViolation(currentTime); - - for (final IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { - final double vls = violationsMap.get(violationModule) - violationModule.getReduceVls(); - - if (vls <= 0) { - violationsMap.remove(violationModule); - } else { - violationsMap.put(violationModule, vls); - } - } - } - - final double newVls = getViolations(module) + amount; - - violationsMap.put(module, newVls); - - if (event instanceof Cancellable && module.getCancelVls() <= newVls) { - ((Cancellable) event).setCancelled(true); - } - - for (final int threshold : violations.getViolations()) { - if (threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); - - punish(module, player, commands, (int) newVls); - } - } - } - } else if (event instanceof Cancellable) { - ((Cancellable) event).setCancelled(true); - } - } - - public void punish(final IModule module, final ProxiedPlayer player, final Collection punishments, - final int newVls) { - final Collection> punishmentsDone = getPunishmentsDone(); - - if (!punishments.isEmpty() && !punishmentsDone.contains(punishments)) { - final CommandSender consoleSender = server.getConsole(); - final String playerName = player.getName(); - - for (final String punishment : punishments) { - if (punishment.equals("kick")) { - final String locale = VersionUtil.getLocale(player); - final String kickMessage = messagesModule.getKickMessage(module, locale); - - player.disconnect(TextComponent.fromLegacyText(kickMessage)); - } else if (punishment.equals("notification")) { - final String moduleName = module.getName(); - - notificationsModule.sendNotification(moduleName, player, (int) newVls); - } else { - server.getPluginManager().dispatchCommand(consoleSender, - punishment.replace("%player%", playerName)); - } - } - - punishmentsDone.add(punishments); - exploitPlayerManager.addPunishment(); - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java deleted file mode 100644 index 19fa653..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ChatListener.java +++ /dev/null @@ -1,46 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.listeners; - -import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.ChatEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; - -public class ChatListener implements Listener { - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; - - ChatListener(final ModuleManager moduleManager) { - this.commandsModule = moduleManager.getCommandsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = -128) - public void onChat(final ChatEvent event) { - if (!event.isCancelled() && event.isCommand()) { - final Connection connection = event.getSender(); - - if (connection instanceof ProxiedPlayer) { - final ProxiedPlayer player = (ProxiedPlayer) connection; - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - if (commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); - - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command)) { - exploitPlayer.punish(commandsModule, player, commandsModule.getPunishments(), 1); - - event.setCancelled(true); - break; - } - } - } - } - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java deleted file mode 100644 index bd79edb..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/DisconnectListener.java +++ /dev/null @@ -1,30 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.listeners; - -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PlayerDisconnectEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; - -public class DisconnectListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - - DisconnectListener(final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - } - - @EventHandler - public void onDisconnect(final PlayerDisconnectEvent event) { - final ProxiedPlayer player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - exploitPlayer.clear(); - exploitPlayer.setLogged(false); - notificationsModule.setNotifications(player.getName(), false); - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java deleted file mode 100644 index 4bd7dd2..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/ListenerInitializer.java +++ /dev/null @@ -1,42 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.listeners; - -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.plugin.PluginManager; - -public class ListenerInitializer { - private final Plugin plugin; - private final ModuleManager moduleManager; - private boolean registered = false; - - public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { - this.plugin = plugin; - this.moduleManager = moduleManager; - } - - public void register() { - this.registered = true; - - final ProxyServer server = this.plugin.getProxy(); - final PluginManager pluginManager = server.getPluginManager(); - - pluginManager.registerListener(plugin, new ChatListener(moduleManager)); - pluginManager.registerListener(plugin, new DisconnectListener(moduleManager)); - pluginManager.registerListener(plugin, new PluginMessageListener(moduleManager)); - pluginManager.registerListener(plugin, new PostLoginListener(moduleManager)); - } - - public void unregister() { - final ProxyServer server = this.plugin.getProxy(); - final PluginManager pluginManager = server.getPluginManager(); - - this.registered = false; - - pluginManager.unregisterListeners(plugin); - } - - public boolean isRegistered() { - return this.registered; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java deleted file mode 100644 index 84bfa5b..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PluginMessageListener.java +++ /dev/null @@ -1,61 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.listeners; - -import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PluginMessageEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; - -public class PluginMessageListener implements Listener { - private final PacketsModule packetsModule; - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - - PluginMessageListener(final ModuleManager moduleManager) { - this.packetsModule = moduleManager.getPacketsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - this.notificationsModule = moduleManager.getNotificationsModule(); - } - - @EventHandler(priority = -128) - public void onPluginMessage(final PluginMessageEvent event) { - if (!event.isCancelled() && packetsModule.isEnabled()) { - final Connection connection = event.getSender(); - - if (connection instanceof ProxiedPlayer) { - final ProxiedPlayer player = (ProxiedPlayer) connection; - final BungeeExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String tag = event.getTag(), playerName = player.getName(); - final double tagVls = packetsModule.getTagVls(), dataVls = packetsModule.getDataVls(); - - if (tagVls > 0 && tag == null || tag.isEmpty()) { - notificationsModule.debug("[PacketPlayInCustomPayload|Tag] Sent by " + playerName - + " got cancelled because it doesn't have a TAG! Added vls: " + tagVls); - - event.setCancelled(true); - exploitPlayer.addVls(event, player, packetsModule, tagVls); - return; - } else if (dataVls > 0) { - final byte[] data = event.getData(); - final int byteLength = data.length; - - if (byteLength > packetsModule.getDataBytes()) { - notificationsModule.debug("[PacketPlayInCustomPayload|Data] Sent by " + playerName - + " got cancelled because its " + byteLength + " bytes long! Added vls: " + dataVls); - - event.setCancelled(true); - exploitPlayer.addVls(event, player, packetsModule, dataVls); - return; - } - } - - exploitPlayer.addVls(event, player, packetsModule, packetsModule.getMultiplier(tag)); - } - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java b/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java deleted file mode 100644 index c35d842..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/listeners/PostLoginListener.java +++ /dev/null @@ -1,43 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.listeners; - -import java.net.InetSocketAddress; - -import dev._2lstudios.exploitfixer.bungee.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bungee.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PostLoginEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; -import net.md_5.bungee.event.EventPriority; - -public class PostLoginListener implements Listener { - private final ConnectionModule connectionModule; - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - - PostLoginListener(final ModuleManager moduleManager) { - this.connectionModule = moduleManager.getConnectionModule(); - this.notificationsModule = moduleManager.getNotificationsModule(); - this.messagesModule = moduleManager.getMessagesModule(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPostLogin(final PostLoginEvent event) { - final ProxiedPlayer player = event.getPlayer(); - final String playerName = player.getName(); - final InetSocketAddress address = player.getAddress(); - final String locale = VersionUtil.getLocale(player); - - if (connectionModule.isNullAddressEnabled() && (address == null || address.isUnresolved())) { - player.disconnect(TextComponent.fromLegacyText(messagesModule.getKickMessage("nulladdress", locale))); - } - - if (player.hasPermission("exploitfixer.notifications")) { - notificationsModule.setNotifications(playerName, true); - } - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java deleted file mode 100644 index 3ee2c7c..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ExploitPlayerManager.java +++ /dev/null @@ -1,79 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.managers; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; - -import dev._2lstudios.exploitfixer.bungee.exploit.BungeeExploitPlayer; -import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class ExploitPlayerManager { - private final ProxyServer server; - private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); - private int punishments = 0; - - ExploitPlayerManager(final ProxyServer server, final ModuleManager moduleManager) { - this.server = server; - this.moduleManager = moduleManager; - } - - public BungeeExploitPlayer get(final ProxiedPlayer player) { - final UUID uuid = player.getUniqueId(); - final BungeeExploitPlayer exploitPlayer; - - if (exploitPlayers.containsKey(uuid)) { - exploitPlayer = exploitPlayers.get(uuid); - } else { - exploitPlayer = new BungeeExploitPlayer(server, player.getName(), moduleManager); - exploitPlayers.put(uuid, exploitPlayer); - } - - return exploitPlayer; - } - - public void reload() { - exploitPlayers.clear(); - - for (final ProxiedPlayer player : server.getPlayers()) { - final ExploitPlayer exploitPlayer = get(player); - - exploitPlayer.setLogged(true); - } - } - - public void clear() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean cleared = false; - - while (iterator.hasNext()) { - final UUID uuid = iterator.next(); - - if (server.getPlayer(uuid) == null) { - iterator.remove(); - cleared = true; - } - } - - if (cleared) { - moduleManager.getNotificationsModule().debug("Cleared unused cached players!"); - } - } - - public int getSize() { - return exploitPlayers.size(); - } - - public int getPunishments() { - return punishments; - } - - public int addPunishment() { - punishments += 1; - - return punishments; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java deleted file mode 100644 index 10385b4..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/managers/ModuleManager.java +++ /dev/null @@ -1,85 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.managers; - -import java.io.File; -import java.util.logging.Logger; - -import dev._2lstudios.exploitfixer.bungee.modules.BungeeNotificationsModule; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; -import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.plugin.Plugin; - -public class ModuleManager { - private final Plugin plugin; - private final CommandsModule commandsModule; - private final ConnectionModule connectionModule; - private final PacketsModule packetsModule; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsModule; - private final ExploitPlayerManager exploitPlayerManager; - - public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin plugin) { - this.plugin = plugin; - - final ProxyServer server = plugin.getProxy(); - final Logger logger = plugin.getLogger(); - - this.commandsModule = new CommandsModule(); - this.connectionModule = new ConnectionModule(); - this.packetsModule = new PacketsModule(); - this.messagesModule = new MessagesModule(configurationUtil, logger, plugin.getDescription().getVersion()); - this.notificationsModule = new BungeeNotificationsModule(server.getConsole(), logger, server); - this.exploitPlayerManager = new ExploitPlayerManager(server, this); - } - - public void reload(final IConfiguration configYml) { - try { - final File localeFolder = new File(plugin.getDataFolder() + "/locales/"); - - localeFolder.mkdirs(); - - this.commandsModule.reload(configYml); - this.connectionModule.reload(configYml); - this.packetsModule.reload(configYml); - this.messagesModule.reload(configYml, localeFolder); - this.notificationsModule.reload(configYml); - this.exploitPlayerManager.reload(); - } catch (final NullPointerException exception) { - final NullPointerException newException = new NullPointerException( - "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); - - newException.setStackTrace(exception.getStackTrace()); - - throw newException; - } - } - - public CommandsModule getCommandsModule() { - return commandsModule; - } - - public ConnectionModule getConnectionModule() { - return connectionModule; - } - - public PacketsModule getPacketsModule() { - return packetsModule; - } - - public MessagesModule getMessagesModule() { - return messagesModule; - } - - public NotificationsModule getNotificationsModule() { - return notificationsModule; - } - - public ExploitPlayerManager getExploitPlayerManager() { - return exploitPlayerManager; - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java deleted file mode 100644 index 7c5b3c6..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/modules/BungeeNotificationsModule.java +++ /dev/null @@ -1,39 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.modules; - -import java.util.logging.Logger; - -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class BungeeNotificationsModule extends NotificationsModule { - private final CommandSender console; - private final ProxyServer server; - - public BungeeNotificationsModule(final CommandSender console, final Logger logger, final ProxyServer server) { - super(logger); - this.console = console; - this.server = server; - } - - public void sendNotification(final String check, final ProxiedPlayer player, final int violations) { - if (isEnabled() && player != null) { - final BaseComponent[] notification = TextComponent.fromLegacyText(getMessage() - .replace("%player%", player.getName()).replace("%check%", check) - .replace("%ping%", String.valueOf(player.getPing())).replace("%vls%", String.valueOf(violations))); - - console.sendMessage(notification); - - for (final String playerName : getNotifications()) { - final ProxiedPlayer player2 = server.getPlayer(playerName); - - if (player2 != null) { - player2.sendMessage(notification); - } - } - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java b/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java deleted file mode 100644 index e38aa1c..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/tasks/ExploitFixerRepeatingTask.java +++ /dev/null @@ -1,30 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.tasks; - -import dev._2lstudios.exploitfixer.bungee.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; - -public class ExploitFixerRepeatingTask implements Runnable { - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; - int seconds = 0; - - public ExploitFixerRepeatingTask(final ExploitPlayerManager exploitPlayerManager, - final NotificationsModule notificationsModule) { - this.exploitPlayerManager = exploitPlayerManager; - this.notificationsModule = notificationsModule; - } - - @Override - public void run() { - if (seconds > 300) { - seconds = 0; - exploitPlayerManager.clear(); - } else { - if (seconds % 10 == 9) { - notificationsModule.debugPackets(); - } - - seconds++; - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java deleted file mode 100644 index 295c5e9..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/utils/BungeeConfigurationUtil.java +++ /dev/null @@ -1,111 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.logging.Logger; - -import dev._2lstudios.exploitfixer.bungee.configuration.BungeeConfiguration; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.scheduler.TaskScheduler; -import net.md_5.bungee.config.Configuration; -import net.md_5.bungee.config.ConfigurationProvider; -import net.md_5.bungee.config.YamlConfiguration; - -public class BungeeConfigurationUtil implements IConfigurationUtil { - private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; - private final String dataFolderPath; - private final String prefix; - private final Logger logger; - private final Plugin plugin; - private final TaskScheduler scheduler; - private final ClassLoader classLoader; - - public BungeeConfigurationUtil(final Plugin plugin) { - this.plugin = plugin; - this.scheduler = plugin.getProxy().getScheduler(); - this.logger = plugin.getLogger(); - this.classLoader = plugin.getClass().getClassLoader(); - this.dataFolderPath = plugin.getDataFolder().toString(); - this.prefix = "[" + plugin.getDescription().getName() + "]"; - } - - private void createParentFolder(final File file) { - final File parentFile = file.getParentFile(); - - if (parentFile != null) { - parentFile.mkdirs(); - } - } - - public IConfiguration get(final String path) { - final File file = new File(path.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); - - if (file.exists()) { - try { - return new BungeeConfiguration(ConfigurationProvider.getProvider(YamlConfiguration.class).load(file)); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } else { - return null; - } - } - - public void create(final String rawPath, final String resourcePath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); - - try { - final File configFile = new File(path); - - if (!configFile.exists()) { - final InputStream inputStream = classLoader.getResourceAsStream(resourcePath); - - createParentFolder(configFile); - - if (inputStream != null) { - Files.copy(inputStream, configFile.toPath()); - } else { - configFile.createNewFile(); - } - - logger.info(prefix + " File '" + path + "' has been created!"); - } - } catch (final IOException e) { - logger.info(prefix + " Unable to create '" + path + "'!"); - } - } - - public void save(final IConfiguration configuration, final String rawPath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); - - scheduler.runAsync(plugin, () -> { - try { - ConfigurationProvider.getProvider(YamlConfiguration.class) - .save((Configuration) configuration.getObject(), new File(path)); - - logger.info(prefix + " File '" + path + "' has been saved!"); - } catch (final IOException e) { - logger.info(prefix + " Unable to save '" + path + "'!"); - } - }); - } - - public void delete(final String rawPath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); - - scheduler.runAsync(plugin, () -> { - try { - Files.delete(new File(path).toPath()); - - logger.info(prefix + " File '" + path + "' has been removed!"); - } catch (IOException e) { - logger.info(prefix + " Unable to remove '" + path + "'!"); - } - }); - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java deleted file mode 100644 index 27f1188..0000000 --- a/src/dev/_2lstudios/exploitfixer/bungee/utils/VersionUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev._2lstudios.exploitfixer.bungee.utils; - -import java.util.Locale; - -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class VersionUtil { - public static String getLocale(final ProxiedPlayer player) { - final Locale locale = player.getLocale(); - final String lang; - - if (locale != null) { - final String localeString = locale.toString(); - - if (localeString.length() > 1) { - lang = localeString.substring(0, 2); - } else { - lang = "en"; - } - } else { - lang = "en"; - } - - return lang; - } -} \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 0e5a992..3359d20 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -1,37 +1,21 @@ package dev._2lstudios.exploitfixer.shared.exploit; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.UUID; - -import com.google.gson.JsonParser; import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; public class ExploitPlayer { private final Map violations; private final Collection> punishmentsDone; - private final String name; - private UUID onlineUUID; private long lastViolation; private int channels; - private boolean logged; - public ExploitPlayer(final String name) { + public ExploitPlayer() { this.violations = new HashMap<>(); this.punishmentsDone = new HashSet<>(); - this.name = name; - this.onlineUUID = null; - this.logged = false; clear(); } @@ -70,39 +54,4 @@ public Map getViolations() { public double getViolations(final IViolationModule module) { return violations.getOrDefault(module, 0D); } - - public UUID getOnlineUUID() throws MalformedURLException, IOException, IllegalStateException { - if (onlineUUID == null) { - final URLConnection connection = new URL("https://api.mojang.com/users/profiles/minecraft/" + name) - .openConnection(); - - connection.connect(); - - try (final InputStream inputStream = connection.getInputStream()) { - try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { - final StringBuilder response = new StringBuilder(); - String inputLine; - - while ((inputLine = bufferedReader.readLine()) != null) { - response.append(inputLine); - } - - onlineUUID = UUID.fromString(new JsonParser().parse(response.toString()).getAsJsonObject().get("id") - .getAsString().replaceFirst( - "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", - "$1-$2-$3-$4-$5")); - } - } - } - - return onlineUUID; - } - - public void setLogged(final boolean logged) { - this.logged = logged; - } - - public boolean isLogged() { - return logged; - } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java index b0dcc6f..852e79d 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java @@ -6,22 +6,16 @@ import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; public class ConnectionModule implements IPunishmentModule { - private boolean uuidSpoofEnabled; private boolean nullAddressEnabled; private String name; private Collection punishments; public void reload(final IConfiguration configYml) { - this.uuidSpoofEnabled = configYml.getBoolean("connection.uuidspoof"); this.nullAddressEnabled = configYml.getBoolean("connection.null_address"); this.name = "Connection"; this.punishments = configYml.getStringList("connection.punishments"); } - public boolean isUUIDSpoofEnabled() { - return uuidSpoofEnabled; - } - public boolean isNullAddressEnabled() { return nullAddressEnabled; } diff --git a/src/resources/config.yml b/src/resources/config.yml index 7312fb1..75e9d9e 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -2,9 +2,7 @@ # Please help by donating, we require funds to continue with the development. # https://paypal.me/LinsaFTW # -# WARNING: Only Notifications, Connection, Commands and Packets (CustomPayload only) modules work on BungeeCord. -# -# INSTALL THE PLUGIN ON BUNGEECORD AND ALL BUKKIT SERVERS! +# INSTALL THE PLUGIN ON ALL BUKKIT SERVERS! # # Most of the check use Violations (vls), this a counter to execute different # actions on diverse levels to allow high customization of the modules. @@ -33,19 +31,6 @@ events: # Prevents players from damaging themselves and consuming ram. self_damage: true -# Prevents exploits that occur on player connection. -connection: - # Prevents stealing admin's account. (ForceOP/UUIDSpoof) - # UUIDSpoof only affects non-firewalled servers with bungeecord: true. - uuidspoof: true - - # Prevents bypassing IPWhitelist to steal accounts. - # NullAddress only affects non-firewalled servers using IP Whitelist. - null_address: true - - # Commands to run when a player is detected. - punishments: [] - # Prevents the use of invalid packets to crash the server. packets: enabled: true diff --git a/src/resources/locales/en.yml b/src/resources/locales/en.yml index 96b990b..e41654f 100644 --- a/src/resources/locales/en.yml +++ b/src/resources/locales/en.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fUUID Spoofing detected.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/es.yml b/src/resources/locales/es.yml index 44065f0..b859bf1 100644 --- a/src/resources/locales/es.yml +++ b/src/resources/locales/es.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de UUID detectado.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/fr.yml b/src/resources/locales/fr.yml index 760d2ad..61c2a02 100644 --- a/src/resources/locales/fr.yml +++ b/src/resources/locales/fr.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fSpoofing UUID détecté.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/hu.yml b/src/resources/locales/hu.yml index d93792c..0f81960 100644 --- a/src/resources/locales/hu.yml +++ b/src/resources/locales/hu.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" - uuidspoof: - kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fUUID Spoofingot észleltünk.\n&7Discord: &b&n%discord%&r" commands: kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" packets: diff --git a/src/resources/locales/it.yml b/src/resources/locales/it.yml index b8d991f..8c63bf4 100644 --- a/src/resources/locales/it.yml +++ b/src/resources/locales/it.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fUUID Spoofing rilevato.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/pl.yml b/src/resources/locales/pl.yml index bd5b1cd..c99f50d 100644 --- a/src/resources/locales/pl.yml +++ b/src/resources/locales/pl.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto zbyt wiele pakietów CustomPayload.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto podszywanie siÄ™ pod UUID.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploit poleceÅ„.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/pt.yml b/src/resources/locales/pt.yml index 48cf614..3390ce4 100644 --- a/src/resources/locales/pt.yml +++ b/src/resources/locales/pt.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de UUID detectado.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/tr.yml b/src/resources/locales/tr.yml index f6ed3f8..77da929 100644 --- a/src/resources/locales/tr.yml +++ b/src/resources/locales/tr.yml @@ -18,8 +18,6 @@ commands: modules: custompayload: kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fUUID Kimlik sahtekarlığı algılandı.\n&7Discord: &b&n%web%&r" commands: kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%web%&r" packets: diff --git a/src/resources/locales/zh.yml b/src/resources/locales/zh.yml index 42915e1..2d52b2a 100644 --- a/src/resources/locales/zh.yml +++ b/src/resources/locales/zh.yml @@ -17,8 +17,6 @@ commands: modules: custompayload: kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到CustomPayloadå‘包过多。\n&7Discord: &b&n%web%&r" - uuidspoof: - kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到无效的UUID。\n&7Discord: &b&n%web%&r" commands: kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到滥用指令。\n&7Discord: &b&n%web%&r" packets: From f2f796448c697aee67b87895b23718724272c382 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 30 Mar 2021 16:56:45 -0300 Subject: [PATCH 104/336] Improved Item fixing --- .../bukkit/modules/ItemsFixModule.java | 64 +++++++++++-------- src/resources/config.yml | 8 ++- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 7313342..524bad3 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -2,8 +2,10 @@ import java.util.Collection; import java.util.List; +import java.util.Map.Entry; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BookMeta; @@ -58,32 +60,38 @@ public Collection getBlacklist() { return blacklist; } - public ItemStack fixItem(final ItemStack itemStack) { - final Material material = Material.getMaterial(itemStack.getType().name()); - final ItemMeta oldItemMeta = itemStack.getItemMeta(); + public ItemStack fixItem(final ItemStack item) { + final Material material = Material.getMaterial(item.getType().name()); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final short durability = itemStack.getDurability(); + final short durability = item.getDurability(); - if (itemStack.hasItemMeta()) { + if (item.hasItemMeta()) { + final ItemMeta oldItemMeta = item.getItemMeta(); final String displayName = oldItemMeta.getDisplayName(); final List lore = oldItemMeta.getLore(); + // This applies vanilla levels to enchants + final boolean applyLevelRestriction = enchantLimit != 0; - if (enchantLimit > -1) { - if (oldItemMeta instanceof EnchantmentStorageMeta) { - final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; - final EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; - - enchantmentStorageMeta.getStoredEnchants().forEach((enchantment, level) -> { - if (level <= enchantLimit && level > -1) { - newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, true); - } - }); - } else { - itemStack.getEnchantments().forEach((enchantment, level) -> { - if (level <= enchantLimit && level > -1) { - newItemMeta.addEnchant(enchantment, level, true); - } - }); + if (oldItemMeta instanceof EnchantmentStorageMeta) { + final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; + final EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; + + for (final Entry entry : enchantmentStorageMeta.getStoredEnchants().entrySet()) { + final Enchantment enchantment = entry.getKey(); + final int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); + + if (enchantLimit > -1 && level > -1) { + newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, !applyLevelRestriction); + } + } + } else { + for (final Entry entry : item.getEnchantments().entrySet()) { + final Enchantment enchantment = entry.getKey(); + final int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); + + if (enchantLimit > -1 && level > -1) { + newItemMeta.addEnchant(enchantment, level, !applyLevelRestriction); + } } } @@ -111,7 +119,7 @@ public ItemStack fixItem(final ItemStack itemStack) { newLeatherArmorMeta.setColor(oldLeatherArmorMeta.getColor()); } - if (displayName != null && displayName.getBytes().length < 128) { + if (displayName.getBytes().length < 128) { newItemMeta.setDisplayName(displayName); } @@ -120,14 +128,14 @@ public ItemStack fixItem(final ItemStack itemStack) { } } - if (maxStackSize > 0 && itemStack.getAmount() > maxStackSize) { - itemStack.setAmount(maxStackSize); + if (maxStackSize > 0 && item.getAmount() > maxStackSize) { + item.setAmount(maxStackSize); } - itemStack.setType(material); - itemStack.setItemMeta(newItemMeta); - itemStack.setDurability(durability); + item.setType(material); + item.setItemMeta(newItemMeta); + item.setDurability(durability); - return itemStack; + return item; } } diff --git a/src/resources/config.yml b/src/resources/config.yml index 75e9d9e..847ac6e 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -123,14 +123,16 @@ packets: - "kick" # Removes custom NBT tags from creative items to prevent harm to your server. +# Negative enchant values will be always removed. itemsfix: enabled: true - # Maximum stack size obtainable with creative packets. (Set to -1 to allow everything) + # Maximum stack size obtainable with creative packets. (-1 to allow anything) max_stack_size: 64 - # Maximum enchant level obtainable with creative packets. (-1 to disable) - enchant_limit: 10 + # Maximum enchant level obtainable with creative packets. + # -1 removes all enchants, 0 forces vanilla values + enchant_limit: 0 # List of materials that are unobtainable from Creative. blacklist: From e27401b85079320bf5684d6d7070b1c78fcf0c10 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Tue, 30 Mar 2021 17:04:10 -0300 Subject: [PATCH 105/336] Removed Bungee references --- README.md | 2 +- pom.xml | 18 ------------------ .../shared/modules/NotificationsModule.java | 2 +- src/resources/bungee.yml | 9 --------- 4 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 src/resources/bungee.yml diff --git a/README.md b/README.md index 855fa07..f1e5da3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # ExploitFixer -Lightweight and highly customizable Bukkit/BungeeCord plugin that fixes Exploits related to invalid Packets. [Requires HamsterAPI to work] +Lightweight and highly customizable Bukkit plugin that fixes Exploits related to invalid Packets. [Requires HamsterAPI to work] diff --git a/pom.xml b/pom.xml index 541993f..00241f6 100644 --- a/pom.xml +++ b/pom.xml @@ -32,10 +32,6 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - bungeecord-repo - https://oss.sonatype.org/content/repositories/snapshots - @@ -44,20 +40,6 @@ 1.16.5-R0.1-SNAPSHOT provided - - net.md-5 - bungeecord-api - 1.16-R0.5-SNAPSHOT - jar - provided - - - net.md-5 - bungeecord-api - 1.16-R0.5-SNAPSHOT - javadoc - provided - net HamsterAPI diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java index d09be12..6788985 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -97,6 +97,6 @@ public String getName() { @Override public void sendNotification(String check, Object player, int violations) { - // Overrided by parent Bukkit/Bungee NotificationsModule + // Overrided by parent Bukkit NotificationsModule } } \ No newline at end of file diff --git a/src/resources/bungee.yml b/src/resources/bungee.yml deleted file mode 100644 index 2d2f9c4..0000000 --- a/src/resources/bungee.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: ExploitFixer -main: dev._2lstudios.exploitfixer.bungee.ExploitFixer -version: 1.5.2 -author: 2LS -commands: - exploitfixer: - description: The main ExploitFixer command - usage: /exploitfixer - aliases: [ef] From c40d2f8b312c79a5c26448a44f3a2b69ca56b5da Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Wed, 31 Mar 2021 14:23:15 -0300 Subject: [PATCH 106/336] Added Netty Dependency --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 00241f6..ba93dd1 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,11 @@ + + io.netty + netty-all + 4.1.62.Final + org.spigotmc spigot-api From 4842f9f4e970787acbdc40988fd59cc5bdffd7a9 Mon Sep 17 00:00:00 2001 From: MacacoLew <72635645+MacacoLew@users.noreply.github.com> Date: Thu, 1 Apr 2021 10:28:03 -0400 Subject: [PATCH 107/336] Check if readerIndex >= writerIndex --- .../bukkit/listener/PacketDecodeListener.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 6fc895d..931e329 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -38,8 +38,16 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final int refCnt = byteBuf.refCnt(); final int capacity = byteBuf.capacity(); final int readableBytes = byteBuf.readableBytes(); + final int readerIndex = byteBuf.readerIndex(); + final int writerIndex = byteBuf.writerIndex(); + + if (readerIndex >= writerIndex) { + final double dataVls = packetsModule.getDataVls(); + final String reason = "[Decoder|Data] " + playerName + + " sent a packet with invalid reader index! reader index: " + readerIndex + " Vls: " + dataVls; - if (capacity < 0) { + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } else if (capacity < 0) { final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; From 6ded7b59c8e2519551ce74ddc3beedec12b44911 Mon Sep 17 00:00:00 2001 From: MacacoLew <72635645+MacacoLew@users.noreply.github.com> Date: Thu, 1 Apr 2021 10:31:54 -0400 Subject: [PATCH 108/336] Forgot a check --- .../bukkit/listener/PacketDecodeListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index 931e329..b447fb4 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -42,10 +42,16 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final int writerIndex = byteBuf.writerIndex(); if (readerIndex >= writerIndex) { - final double dataVls = packetsModule.getDataVls(); + final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid reader index! reader index: " + readerIndex + " Vls: " + dataVls; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } else if (writerIndex < 1) { + final double dataVls = packetsModule.getDataVls(); + final String reason = "[Decoder|Data] " + playerName + + " sent a packet with invalid writer index! writer index: " + writerIndex + " Vls: " + dataVls; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (capacity < 0) { final double dataVls = packetsModule.getDataVls(); From d18a37111bd4b4a937420b60e7a4ba0abfdb4ab4 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Wed, 7 Apr 2021 12:18:52 -0300 Subject: [PATCH 109/336] Updated Packet Thresholds --- src/resources/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/resources/config.yml b/src/resources/config.yml index 847ac6e..d4691be 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -91,10 +91,12 @@ packets: # Unlisted packets are considered as "PacketPlayInOther" by default. # Remember to take a look at bytes_divider option. multipliers: + PacketPlayInOther: 0.1 MC|BSign: 30 MC|BEdit: 30 MC|BOpen: 30 - PacketPlayInOther: 0.1 + PacketPlayInAutoRecipe: 10 + PacketPlayInUpdateSign: 10 PacketPlayInAbilities: 0.1 PacketPlayInArmAnimation: 0.3 PacketPlayInBlockDig: 0.3 @@ -108,7 +110,6 @@ packets: PacketPlayInSetCreativeSlot: 0.1 PacketPlayInSettings: 0.5 PacketPlayInTabComplete: 0.2 - PacketPlayInUpdateSign: 10 PacketPlayInUseEntity: 0.4 PacketPlayInUseItem: 0.4 PacketPlayInWindowClick: 0.5 From abb0b12e532bbd07c94b2c4c3d01cb62a3976a0c Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Wed, 14 Apr 2021 20:51:21 -0300 Subject: [PATCH 110/336] Bump version number to 1.5.3 --- src/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index dc46f31..aa2f5e5 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.2 +version: 1.5.3 author: 2LS api: "1.13" api-version: "1.13" From 28269943984dbdb31896d583908324889fe76b9f Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Thu, 15 Apr 2021 13:27:32 -0300 Subject: [PATCH 111/336] Removed readerIndex/writerIndex check --- .../bukkit/listener/PacketDecodeListener.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java index b447fb4..d771396 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java @@ -34,39 +34,23 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final ByteBuf byteBuf) { if (player != null && player.isOnline()) { final String playerName = player.getName(); + final double dataVls = packetsModule.getDataVls(); final int dataBytes = packetsModule.getDataBytes(); final int refCnt = byteBuf.refCnt(); final int capacity = byteBuf.capacity(); - final int readableBytes = byteBuf.readableBytes(); - final int readerIndex = byteBuf.readerIndex(); - final int writerIndex = byteBuf.writerIndex(); - - if (readerIndex >= writerIndex) { - final double dataVls = packetsModule.getDataVls(); - final String reason = "[Decoder|Data] " + playerName - + " sent a packet with invalid reader index! reader index: " + readerIndex + " Vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } else if (writerIndex < 1) { - final double dataVls = packetsModule.getDataVls(); - final String reason = "[Decoder|Data] " + playerName - + " sent a packet with invalid writer index! writer index: " + writerIndex + " Vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } else if (capacity < 0) { - final double dataVls = packetsModule.getDataVls(); + if (capacity < 0) { final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (refCnt < 1) { - final double dataVls = packetsModule.getDataVls(); final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else { - final double dataVls = packetsModule.getDataVls(); + final int readableBytes = byteBuf.readableBytes(); String reason = null; if (capacity > dataBytes) { From 533c6e747716da9a2c5f2d819b004298aed79f9c Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 15 Apr 2021 13:29:33 -0300 Subject: [PATCH 112/336] Bump version number to 1.5.4 --- src/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index aa2f5e5..f8e524b 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.3 +version: 1.5.4 author: 2LS api: "1.13" api-version: "1.13" From 6275a4a96d05f891b4a61d1c1c1db6ca688af70c Mon Sep 17 00:00:00 2001 From: user Date: Sat, 17 Apr 2021 19:46:45 -0300 Subject: [PATCH 113/336] Fixed displayName NPE --- pom.xml | 2 +- .../_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ba93dd1..6745237 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ HamsterAPI SNAPSHOT system - C:\JAR Files\HamsterAPI.jar + /home/user/java/bin/HamsterAPI.jar \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java index 524bad3..859a193 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java @@ -119,7 +119,7 @@ public ItemStack fixItem(final ItemStack item) { newLeatherArmorMeta.setColor(oldLeatherArmorMeta.getColor()); } - if (displayName.getBytes().length < 128) { + if (displayName != null && displayName.getBytes().length < 128) { newItemMeta.setDisplayName(displayName); } From 19dc718c53b724ac2a956c5ec1a58b207afe569d Mon Sep 17 00:00:00 2001 From: Hazuki Onohara Date: Mon, 19 Apr 2021 11:04:21 +0700 Subject: [PATCH 114/336] Added Thai language --- src/resources/locales/th.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/resources/locales/th.yml diff --git a/src/resources/locales/th.yml b/src/resources/locales/th.yml new file mode 100644 index 0000000..91f3895 --- /dev/null +++ b/src/resources/locales/th.yml @@ -0,0 +1,27 @@ +# Thai (ภาษาไทย) - Credits: Hazuki-san +commands: + reload: "&aปลั๊à¸à¸­à¸´à¸™ ExploitFixer ได้โหลดใหม่à¹à¸¥à¹‰à¸§!" + help: |- + &aExploitFixer &b%version%&a โดย &bLinsaFTW&a + &e /%command% help &7> &bà¹à¸ªà¸”งคำสั่งที่ใช้ได้ + &e /%command% reload &7> &bโหลดปลั๊à¸à¸­à¸´à¸™à¹ƒà¸«à¸¡à¹ˆ + &e /%command% notifications &7> &bเปิดหรือปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนของปลั๊à¸à¸­à¸´à¸™ + &e /%command% stats &7> &bดูสถานะของปลั๊à¸à¸­à¸´à¸™ + error: + unknown: "&cไม่รู้จัà¸à¸„ำสั่งนี้ ใช้ /exploitfixer help เพื่อดูคำสั่งที่สามารถใช้ได้!" + permission: "&cคุณไม่มีสิทธิที่จะใช้คำสั่งนี้!" + console: "&cคำสั่งนี้ไม่สามารถใช้งานในคอลโซลได้!" + notifications: + enable: "&aคุณได้เปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" + disable: "&cคุณได้ปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" + stats: "&c&lEF: &eผู้เล่นที่à¹à¸„ชà¹à¸¥à¹‰à¸§: &a%players_cached%&e ผู้เล่นที่ลงโทษà¹à¸¥à¹‰à¸§: &a%players_punished%" +modules: + custompayload: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบเจอà¹à¸žà¹‡à¸„เà¸à¹‡à¸— CustomPayload มาà¸à¹€à¸à¸´à¸™à¹„ป\n&7ดิสคอร์ด: &b&n%web%&r" + commands: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸„ำสั่งที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" + packets: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¹à¸žà¹‡à¸—เà¸à¹‡à¸—ที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" + nulladdress: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸—ี่อยู่ที่ไม่มีค่า\n&7ดิสคอร์ด: &b&n%web%&r" +mojang_down: "&cขณะนี้เซิร์ฟเวอร์ Mojang ใช้งานไม่ได้ ค่อยมาใหม่อีà¸à¸—ีทีหลังนะ!\n\n&7สาเหตุ: &fExploitFixer ไม่สามารถตรวจสอบ UUID ได้\n&7ดิสคอร์ด: &b&n%web%&r" From e90143c603f6e11eb53363b7dad27e2a9f6b7d82 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:55:07 -0300 Subject: [PATCH 115/336] Bump version number --- src/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index f8e524b..ace8c7f 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.4 +version: 1.5.5 author: 2LS api: "1.13" api-version: "1.13" From a8b8a0c615d40cfb22455ecfc913480ec506e27a Mon Sep 17 00:00:00 2001 From: Dominik Date: Sat, 1 May 2021 13:18:40 +0200 Subject: [PATCH 116/336] Create de.yml --- src/resources/locales/de.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/resources/locales/de.yml diff --git a/src/resources/locales/de.yml b/src/resources/locales/de.yml new file mode 100644 index 0000000..a55c3b0 --- /dev/null +++ b/src/resources/locales/de.yml @@ -0,0 +1,27 @@ +# German - Credits: Dominik48N +commands: + reload: "&aPlugin ExploitFixer wurde neugeladen!" + help: |- + &aExploitFixer &b%version%&a von &bLinsaFTW&a. + &e /%command% help &7> &bZeigt alle verfügbaren Befehle. + &e /%command% reload &7> &bLäd das Plugin neu. + &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. + &e /%command% stats &7> &bZeigt die Stats vom Plugin an. + error: + unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" + permission: "&cDu darfst diesen Command nicht ausführen!" + console: "&cDiesen Command darfst du nicht als Konsole ausführen!" + notifications: + enable: "&aDu hast die Benachrichtigungen aktiviert!" + disable: "&cDu hast die Benachrichtigungen deaktiviert!" + stats: "&c&lEF: &eSpieler cached: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" +modules: + custompayload: + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload packets wurden erkannt.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fCommand exploit erkannt.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fPackets exploit erkannt.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fUnbekannte IP-Addresse erkannt.\n&7Discord: &b&n%web%&r" +mojang_down: "&cDie Mojang servers sind down, komm bitte später zurück!\n\n&7Grund: &fExploitFixer kann die UUID nicht checken.\n&7Discord: &b&n%web%&r" From 7f7254331997ca157112e0ac50d650eb1145c7b6 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Tue, 4 May 2021 22:07:21 -0300 Subject: [PATCH 117/336] Recode item & packet checks --- pom.xml | 2 +- .../listener/PacketReceiveListener.java | 72 +++------- .../bukkit/utils/ExploitUtil.java | 134 +++++++----------- .../shared/modules/PacketsModule.java | 7 +- src/resources/config.yml | 5 - 5 files changed, 70 insertions(+), 150 deletions(-) diff --git a/pom.xml b/pom.xml index 6745237..58723da 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ HamsterAPI SNAPSHOT system - /home/user/java/bin/HamsterAPI.jar + /home/linsaftw/java/bin/HamsterAPI.jar \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 885ad16..097f2aa 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -1,7 +1,5 @@ package dev._2lstudios.exploitfixer.bukkit.listener; -import java.nio.charset.StandardCharsets; -import java.util.Collection; import java.util.Map; import java.util.Map.Entry; @@ -62,7 +60,8 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final InventoryView inventoryView = player.getOpenInventory(); final double windowClick = packetsModule.getWindowClick(); final double setCreativeSlot = packetsModule.getSetCreativeSlot(); - final int dataBytesSigns = packetsModule.getDataBytesSign(); + + exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName)); if (packetType == PacketType.PacketPlayInCustomPayload) { if (!strings.isEmpty()) { @@ -132,43 +131,9 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster return; } - int packetSize = 0; - if (dataVls > 0) { - final Map objects = packetWrapper.getObjects(); - final int dataBytes = packetsModule.getDataBytes(); - - try { - if (!objects.isEmpty()) { - final Collection objectsValues = objects.values(); - - for (final Object object : objectsValues) { - if (object instanceof ItemStack) { - packetSize += exploitUtil.parseItemLength((ItemStack) object, exploitPlayer, hamsterPlayer, - packetName, dataBytes); - } else { - packetSize += String.valueOf(object).getBytes(StandardCharsets.UTF_8).length; - } - } - } - } catch (final Exception exception) { - final String reason = "[" + packetName + "|Data] " + playerName - + " has sent an unparseable packet! Added vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - - if (dataBytes > 0 && packetSize > dataBytes) { - final String reason = "[" + packetName + "|Data] " + playerName + " sent a packet of " + packetSize - + " bytes long!"; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - - if (dataBytesSigns > 0 && packetType == PacketType.PacketPlayInUpdateSign - && exploitUtil.parseSign(strings.values().toArray(new String[0]))) { + if (packetType == PacketType.PacketPlayInUpdateSign + && !exploitUtil.checkSign(strings.values().toArray(new String[0]))) { final String reason = "[" + packetName + "|Data] " + playerName + " has sent a too big sign packet! Added vls: " + dataVls; @@ -177,32 +142,27 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - final double bytesDividerAddition; - - if (packetsModule.getDataBytesDivider() > 0) { - bytesDividerAddition = (double) packetSize / packetsModule.getDataBytesDivider(); - } else { - bytesDividerAddition = packetSize; - } - - exploitPlayer.addVls(event, hamsterPlayer, packetsModule, - packetsModule.getMultiplier(packetName) + bytesDividerAddition); + final boolean creativeMode = packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled(); - if (packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled()) { - final Map items = packetWrapper.getItems(); + for (final Entry itemsEntry : packetWrapper.getItems().entrySet()) { + final ItemStack item = itemsEntry.getValue(); - for (final Entry itemsEntry : items.entrySet()) { - final ItemStack itemStack = itemsEntry.getValue(); + if (item != null) { + if (dataVls > 0 && !exploitUtil.checkItem(item)) { + final String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid item! Added vls: " + dataVls; - if (itemStack != null) { - final String blacklisted = exploitUtil.clearIfBlacklisted(itemStack); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } else if (creativeMode) { + final String blacklisted = exploitUtil.clearIfBlacklisted(item); if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); notificationsModule.debug(player.getName() + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); } else { - packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(itemStack)); + packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index d8f1940..a026fac 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -34,114 +34,84 @@ public ExploitUtil(final ModuleManager moduleManager) { this.packetsModule = moduleManager.getPacketsModule(); } - private int parseBookLength(final BukkitExploitPlayer exploitPlayer, final HamsterPlayer hamsterPlayer, - final ItemMeta itemMeta, final String packetName) { - final Player player = hamsterPlayer.getPlayer(); - final BookMeta bookMeta = (BookMeta) itemMeta; - final double dataVls = packetsModule.getDataVls(); - final int pageCount = bookMeta.getPageCount(), dataBytesBook = packetsModule.getDataBytesBook(); - int bookTotalBytes = 0; - - if (dataVls > 0 && pageCount > 50) { - notificationsModule.debug("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many pages! (" + pageCount + "/" + 50 + ") Added vls: " - + dataVls); - - exploitPlayer.addVls(null, hamsterPlayer, packetsModule, dataVls); - } else { - for (final String page : bookMeta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; - - bookTotalBytes += pageBytes; - - if (dataVls > 0 && pageBytes > dataBytesBook) { - notificationsModule.debug("[" + packetName + "|Book] " + player.getName() - + " has sent a packet with a book with too many characters per page! (" + pageBytes + "/" - + dataBytesBook + ") Added vls: " + dataVls); - - exploitPlayer.addVls(null, hamsterPlayer, packetsModule, dataVls); - break; + private boolean checkBlockState(final BlockStateMeta meta) { + if (meta.hasBlockState()) { + final BlockState blockState = meta.getBlockState(); + + if (blockState instanceof InventoryHolder) { + final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + + for (final ItemStack item1 : inventoryHolder.getInventory().getContents()) { + return checkItem(item1); } } - - return bookTotalBytes; } - return itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; + return true; } - public int parseItemLength(final ItemStack itemStack, final BukkitExploitPlayer exploitPlayer, - final HamsterPlayer hamsterPlayer, final String packetName, final int itemBytesMax) { - int itemBytesLength = 0; + private boolean checkBook(final BookMeta meta) { + if (meta.getTitle().length() > 32) { + return false; + } - if (itemStack != null) { - final ItemMeta itemMeta = itemStack.getItemMeta(); + if (meta.getAuthor().length() > 16) { + return false; + } - try { - itemBytesLength += itemStack.getData().toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final Exception exception) { - notificationsModule - .debug("[" + packetName + "] There was an exception when processing itemStack data to String!"); - } + if (meta.getPageCount() > 50) { + return false; + } - if (itemStack.hasItemMeta() && itemMeta != null) { - try { - if (itemMeta instanceof BlockStateMeta) { - final BlockStateMeta blockStateMeta = (BlockStateMeta) itemMeta; - - if (blockStateMeta.hasBlockState()) { - final BlockState blockState = blockStateMeta.getBlockState(); - - if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - - for (final ItemStack itemStack1 : inventoryHolder.getInventory().getContents()) { - itemBytesLength += parseItemLength(itemStack1, exploitPlayer, hamsterPlayer, - packetName, itemBytesMax); - - if (itemBytesLength > itemBytesMax) { - return itemBytesLength; - } - } - } - } - } else { - throw new IllegalStateException(); - } - } catch (final IllegalStateException e1) { - if (itemMeta instanceof BookMeta) { - itemBytesLength += parseBookLength(exploitPlayer, hamsterPlayer, itemMeta, packetName); - } else { - try { - itemBytesLength += itemMeta.toString().getBytes(StandardCharsets.UTF_8).length; - } catch (final NullPointerException e2) { - itemBytesLength += (itemMeta.getClass().getName() + "@" - + Integer.toHexString(itemMeta.hashCode())).getBytes(StandardCharsets.UTF_8).length; - } - } - } + final int dataBytesBook = packetsModule.getDataBytesBook(); + + for (final String page : meta.getPages()) { + final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + + if (pageBytes > dataBytesBook) { + return false; } } - return itemBytesLength; + return true; + } + + public boolean checkItem(final ItemStack item) { + final ItemMeta itemMeta = item.getItemMeta(); + + if (itemMeta.getDisplayName().length() > 64) { + return false; + } + + if (itemMeta.getLore().size() > 32) { + return false; + } + + if (itemMeta instanceof BookMeta) { + return checkBook((BookMeta) itemMeta); + } else if (itemMeta instanceof BlockStateMeta) { + return checkBlockState((BlockStateMeta) itemMeta); + } + + return true; } - public boolean parseSign(final String[] linesString) { + public boolean checkSign(final String[] linesString) { final int dataBytesSign = packetsModule.getDataBytesSign(); - if (linesString != null) { + if (linesString != null && dataBytesSign > 0) { if (linesString.length > 4) { return true; } else { for (final String line : linesString) { if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { - return true; + return false; } } } } - return false; + return true; } public String clearIfBlacklisted(final ItemStack itemStack) { diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java index 7fe86a6..cd806fb 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java @@ -12,7 +12,7 @@ public class PacketsModule implements IViolationModule { private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, reduceVls; - private int dataBytesBook, dataBytesSign, dataBytes, dataBytesDivider; + private int dataBytesBook, dataBytesSign, dataBytes; private boolean enabled, offline; public void reload(final IConfiguration configYml) { @@ -29,7 +29,6 @@ public void reload(final IConfiguration configYml) { this.dataBytes = configYml.getInt(name + ".data.bytes"); this.dataBytesBook = configYml.getInt(name + ".data.bytes_book"); this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign"); - this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider"); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); @@ -113,8 +112,4 @@ public int getDataBytesSign() { public boolean isOffline() { return offline; } - - public int getDataBytesDivider() { - return dataBytesDivider; - } } diff --git a/src/resources/config.yml b/src/resources/config.yml index d4691be..e5e543c 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -58,10 +58,6 @@ packets: # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) bytes_sign: 47 - # Packets will add their amount of bytes divided by this number to vl count. - # This is made so big packets add more vls when received. - bytes_divider: 1000 - # Cancels book packets when a book is not in hand # Vls to add when a packet fails the check. (Set to -1 to disable) book: 100 @@ -89,7 +85,6 @@ packets: # Vls to add when a normal packet is sent by a player. # This option is made to work as a packet limiter feature. # Unlisted packets are considered as "PacketPlayInOther" by default. - # Remember to take a look at bytes_divider option. multipliers: PacketPlayInOther: 0.1 MC|BSign: 30 From 2b8ea2333e99e267191e41e0f4ecf9ddb7ca66ca Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Tue, 4 May 2021 22:13:46 -0300 Subject: [PATCH 118/336] Reuse playerName variable --- .../exploitfixer/bukkit/listener/PacketReceiveListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 097f2aa..cff36bc 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -159,11 +159,11 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); - notificationsModule.debug(player.getName() + notificationsModule.debug(playerName + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); } else { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); - notificationsModule.debug(player.getName() + " had a creative item fixed by ExploiFixer!"); + notificationsModule.debug(playerName + " had a creative item fixed by ExploiFixer!"); } } } From 802d2e3503a0756ee68621146194ac8aae15e165 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Tue, 4 May 2021 22:18:38 -0300 Subject: [PATCH 119/336] Renamed a variable --- src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index a026fac..b100cc5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -41,8 +41,8 @@ private boolean checkBlockState(final BlockStateMeta meta) { if (blockState instanceof InventoryHolder) { final InventoryHolder inventoryHolder = (InventoryHolder) blockState; - for (final ItemStack item1 : inventoryHolder.getInventory().getContents()) { - return checkItem(item1); + for (final ItemStack item : inventoryHolder.getInventory().getContents()) { + return checkItem(item); } } } From 21b263fca0205b4efeca5c26fb1ac036611027e1 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:10:33 -0300 Subject: [PATCH 120/336] Fix exception --- .../bukkit/utils/ExploitUtil.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index b100cc5..94368ac 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -77,20 +77,22 @@ private boolean checkBook(final BookMeta meta) { } public boolean checkItem(final ItemStack item) { - final ItemMeta itemMeta = item.getItemMeta(); + if (item.hasItemMeta()) { + final ItemMeta itemMeta = item.getItemMeta(); - if (itemMeta.getDisplayName().length() > 64) { - return false; - } + if (itemMeta.getDisplayName().length() > 64) { + return false; + } - if (itemMeta.getLore().size() > 32) { - return false; - } + if (itemMeta.getLore().size() > 32) { + return false; + } - if (itemMeta instanceof BookMeta) { - return checkBook((BookMeta) itemMeta); - } else if (itemMeta instanceof BlockStateMeta) { - return checkBlockState((BlockStateMeta) itemMeta); + if (itemMeta instanceof BookMeta) { + return checkBook((BookMeta) itemMeta); + } else if (itemMeta instanceof BlockStateMeta) { + return checkBlockState((BlockStateMeta) itemMeta); + } } return true; From 073419a25d4794e8a3c0057ba68f7823c72fe042 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:12:22 -0300 Subject: [PATCH 121/336] Fix exception --- src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 94368ac..0b1f410 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -77,7 +77,7 @@ private boolean checkBook(final BookMeta meta) { } public boolean checkItem(final ItemStack item) { - if (item.hasItemMeta()) { + if (item != null && item.hasItemMeta()) { final ItemMeta itemMeta = item.getItemMeta(); if (itemMeta.getDisplayName().length() > 64) { From b873a4f61fe800cc8268a0ef21efd5bae994e48a Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:14:23 -0300 Subject: [PATCH 122/336] Fix exception --- .../bukkit/utils/ExploitUtil.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 0b1f410..aabb320 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -80,18 +80,20 @@ public boolean checkItem(final ItemStack item) { if (item != null && item.hasItemMeta()) { final ItemMeta itemMeta = item.getItemMeta(); - if (itemMeta.getDisplayName().length() > 64) { - return false; - } + if (itemMeta != null) { + if (itemMeta.getDisplayName().length() > 64) { + return false; + } - if (itemMeta.getLore().size() > 32) { - return false; - } + if (itemMeta.getLore().size() > 32) { + return false; + } - if (itemMeta instanceof BookMeta) { - return checkBook((BookMeta) itemMeta); - } else if (itemMeta instanceof BlockStateMeta) { - return checkBlockState((BlockStateMeta) itemMeta); + if (itemMeta instanceof BookMeta) { + return checkBook((BookMeta) itemMeta); + } else if (itemMeta instanceof BlockStateMeta) { + return checkBlockState((BlockStateMeta) itemMeta); + } } } From d3d234f01d6cfd4b3b662233ff3bd9ce0fa894ac Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:19:06 -0300 Subject: [PATCH 123/336] Fix exception --- .../exploitfixer/bukkit/utils/ExploitUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index aabb320..d36f6bd 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -2,6 +2,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.List; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -81,11 +82,15 @@ public boolean checkItem(final ItemStack item) { final ItemMeta itemMeta = item.getItemMeta(); if (itemMeta != null) { - if (itemMeta.getDisplayName().length() > 64) { + final String displayName = itemMeta.getDisplayName(); + + if (displayName.length() > 64) { return false; } - if (itemMeta.getLore().size() > 32) { + final List lore = itemMeta.getLore(); + + if (lore.size() > 32) { return false; } From b09d23d99151ba1bfa768e4d0b608c3b6d9a5524 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:20:12 -0300 Subject: [PATCH 124/336] Fix exception --- src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index d36f6bd..858098e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -84,13 +84,13 @@ public boolean checkItem(final ItemStack item) { if (itemMeta != null) { final String displayName = itemMeta.getDisplayName(); - if (displayName.length() > 64) { + if (displayName != null && displayName.length() > 64) { return false; } final List lore = itemMeta.getLore(); - if (lore.size() > 32) { + if (lore != null && lore.size() > 32) { return false; } From bebe140f9664af363a50db4cb2587feb8729cb08 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:25:11 -0300 Subject: [PATCH 125/336] Better debug information --- .../exploitfixer/shared/modules/NotificationsModule.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java index 6788985..18b582e 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -46,8 +46,9 @@ public void addPacketDebug(final String packetType) { public void debugPackets() { if (this.debug && !packetDebug.isEmpty()) { final Set> entries = new HashSet<>(packetDebug.entrySet()); - final StringBuilder stringBuilder = new StringBuilder("Received Packets: "); + final StringBuilder stringBuilder = new StringBuilder("Received Packets (%total%): "); boolean isFirst = true; + int total = 0; packetDebug.clear(); @@ -62,9 +63,10 @@ public void debugPackets() { } stringBuilder.append("x").append(amount).append(" ").append(packetType); + total += amount; } - debug(stringBuilder.toString()); + debug(stringBuilder.toString().replace("%total%", String.valueOf(total))); } } From 43f68ab8a2162a745ac2376be1a83815d351ea1b Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Thu, 6 May 2021 17:27:11 -0300 Subject: [PATCH 126/336] Better debug information --- .../exploitfixer/shared/modules/NotificationsModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java index 18b582e..b8ad133 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java @@ -46,7 +46,7 @@ public void addPacketDebug(final String packetType) { public void debugPackets() { if (this.debug && !packetDebug.isEmpty()) { final Set> entries = new HashSet<>(packetDebug.entrySet()); - final StringBuilder stringBuilder = new StringBuilder("Received Packets (%total%): "); + final StringBuilder stringBuilder = new StringBuilder("Received Packets (x%total%): "); boolean isFirst = true; int total = 0; From dd5b3166664dd21c8b5f64c6512ce595c925d066 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 18:58:08 -0300 Subject: [PATCH 127/336] Improve ExploitFixer reload --- .../exploitfixer/bukkit/ExploitFixer.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 68ea7ea..4ef23cf 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -32,7 +32,6 @@ public static synchronized void setInstance(final ExploitFixer exploitFixer) { public void onEnable() { setInstance(this); final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); if (!checkHamsterAPI()) { throw new IllegalStateException( @@ -50,34 +49,21 @@ public void onEnable() { listenerInitializer = new ListenerInitializer(this, moduleManager); register(); - - scheduler.runTaskTimerAsynchronously(this, new ExploitFixerRepeatingTask( - moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 20L, 20L); } @Override public void onDisable() { - final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); - - scheduler.cancelTasks(this); - - this.listenerInitializer.unregister(); + unregister(); } public void reload() { - final Server server = getServer(); - final BukkitScheduler scheduler = server.getScheduler(); - - scheduler.cancelTasks(this); - server.getMessenger().unregisterIncomingPluginChannel(this); - createConfigurations(); final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); moduleManager.reload(configYml); + unregister(); register(); } @@ -92,7 +78,19 @@ private void createConfigurations() { configurationUtil.create("%datafolder%/config.yml", "config.yml"); } + public void unregister() { + final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); + + scheduler.cancelTasks(this); + server.getMessenger().unregisterIncomingPluginChannel(this); + + this.listenerInitializer.unregister(); + } + private void register() { + final Server server = this.getServer(); + final BukkitScheduler scheduler = server.getScheduler(); final Logger logger = this.getLogger(); getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(this, moduleManager)); @@ -107,5 +105,10 @@ private void register() { logger.info("Successfully registered listeners!"); logger.info("Successfully hooked with HamsterAPI!"); + + scheduler.runTaskTimerAsynchronously(this, new ExploitFixerRepeatingTask( + moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 20L, 20L); + + logger.info("Successfully registered tasks!"); } } \ No newline at end of file From 3f80fa8e32125922f7eb441f9dce32225e1a6e4b Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:16:09 -0300 Subject: [PATCH 128/336] Improved default config --- src/resources/config.yml | 335 ++++++++++++++++++++------------------- 1 file changed, 170 insertions(+), 165 deletions(-) diff --git a/src/resources/config.yml b/src/resources/config.yml index e5e543c..23916cd 100644 --- a/src/resources/config.yml +++ b/src/resources/config.yml @@ -1,165 +1,170 @@ -# ExploitFixer by LinsaFTW -# Please help by donating, we require funds to continue with the development. -# https://paypal.me/LinsaFTW -# -# INSTALL THE PLUGIN ON ALL BUKKIT SERVERS! -# -# Most of the check use Violations (vls), this a counter to execute different -# actions on diverse levels to allow high customization of the modules. - -# Default language used by the plugin (This changes depending on the client language) -locale: "en" - -# Web link used on the messages -web: "discord.gg/gF36AT3" - -# Shows notifications to console and players with permissions. -notifications: - enabled: true - - # Placeholders: %player% %ping% %check% %vls% - message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" - - # This shows extra information about blocked packets. - debug: false - -# Prevents exploits that occur on different Bukkit events. -events: - # Prevents moving if the chunk is null. (Prevents chunk overloading) - null_chunk: true - - # Prevents players from damaging themselves and consuming ram. - self_damage: true - -# Prevents the use of invalid packets to crash the server. -packets: - enabled: true - - # Amount of vls required to start cancelling packets. - cancel_vls: 100 - - # Amount of vls to reduce per second. - reduce_vls: 60 - - # Cancels packets if the player sending them is offline. - offline: true - - # This will check if integers, floats, doubles and items have a invalid size in packets. - data: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 600 - - # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 16000 - - # Maximum amount of bytes allowed per book page. (Set to -1 to disable) - bytes_book: 300 - - # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) - bytes_sign: 47 - - # Cancels book packets when a book is not in hand - # Vls to add when a packet fails the check. (Set to -1 to disable) - book: 100 - - # Cancels CustomPayload packets with invalid tags - # Vls to add when a packet fails the check. (Set to -1 to disable) - tag: 600 - - # Checks if players send PacketPlayInWindowClick packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - window_click: 300 - - # Checks if players send PacketPlayInBlockPlace packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_place: 300 - - # Checks if players send PacketPlayInBlockDig packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_dig: 600 - - # Checks if players send PacketPlayInCreativeSlot packets without creative. - # Vls to add when a packet fails the check. (Set to -1 to disable) - set_creative_slot: 600 - - # Vls to add when a normal packet is sent by a player. - # This option is made to work as a packet limiter feature. - # Unlisted packets are considered as "PacketPlayInOther" by default. - multipliers: - PacketPlayInOther: 0.1 - MC|BSign: 30 - MC|BEdit: 30 - MC|BOpen: 30 - PacketPlayInAutoRecipe: 10 - PacketPlayInUpdateSign: 10 - PacketPlayInAbilities: 0.1 - PacketPlayInArmAnimation: 0.3 - PacketPlayInBlockDig: 0.3 - PacketPlayInBlockPlace: 0.4 - PacketPlayInCustomPayload: 0.04 - PacketPlayInEntityAction: 0.4 - PacketPlayInFlying: 0.05 - PacketPlayInLook: 0.1 - PacketPlayInPositionLook: 0.1 - PacketPlayInPosition: 0.35 - PacketPlayInSetCreativeSlot: 0.1 - PacketPlayInSettings: 0.5 - PacketPlayInTabComplete: 0.2 - PacketPlayInUseEntity: 0.4 - PacketPlayInUseItem: 0.4 - PacketPlayInWindowClick: 0.5 - - # Placeholders: %player% - # Commands to run when a player reachs certain violation level. - violations: - 350: - - "notification" - 600: - - "notification" - - "kick" - -# Removes custom NBT tags from creative items to prevent harm to your server. -# Negative enchant values will be always removed. -itemsfix: - enabled: true - - # Maximum stack size obtainable with creative packets. (-1 to allow anything) - max_stack_size: 64 - - # Maximum enchant level obtainable with creative packets. - # -1 removes all enchants, 0 forces vanilla values - enchant_limit: 0 - - # List of materials that are unobtainable from Creative. - blacklist: - - "END_PORTAL" - - "NETHER_PORTAL" - # - "BARRIER" - # - "COMMAND_BLOCK" - -# Checks if players try to crash/exploit the server with commands. -commands: - enabled: true - - # Commands that are excempt from this server. - commands: - - "//calc" - - "//calculate" - - "//eval" - - "//evaluate" - - "//solve" - - "/hd readtext" - - "/holo readtext" - - "/hologram readtext" - - "/holograms readtext" - - "/holographicdisplays readtext" - - "/pex promote" - - "/pex demote" - - "/promote" - - "/demote" - - "/execute" - - # Placeholders: %player% - punishments: - - "notification" - - "kick" +# ExploitFixer by LinsaFTW +# Please help by donating, we require funds to continue with the development. +# https://paypal.me/LinsaFTW +# +# INSTALL THE PLUGIN ON ALL BUKKIT SERVERS! +# +# Most of the check use Violations (vls), this a counter to execute different +# actions on diverse levels to allow high customization of the modules. + +# Default language used by the plugin (This changes depending on the client language) +locale: "en" + +# Web link used on the messages +web: "discord.gg/gF36AT3" + +# Shows notifications to console and players with permissions. +notifications: + enabled: true + + # Placeholders: %player% %ping% %check% %vls% + message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" + + # This shows extra information about blocked packets. + debug: true + +# Prevents exploits that occur on different Bukkit events. +events: + # Prevents moving if the chunk is null. (Prevents chunk overloading) + null_chunk: true + + # Prevents players from damaging themselves and consuming ram. + self_damage: true + +# Prevents the use of invalid packets to crash the server. +packets: + enabled: true + + # Amount of vls required to start cancelling packets. + cancel_vls: 25 + + # Amount of vls to reduce per second. + reduce_vls: 25 + + # Cancels packets if the player sending them is offline. + offline: true + + # This will check if integers, floats, doubles and items have a invalid size in packets. + data: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 + + # Maximum amount of bytes allowed per packet. (Set to -1 to disable) + bytes: 16000 + + # Maximum amount of bytes allowed per book page. (Set to -1 to disable) + bytes_book: 300 + + # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) + bytes_sign: 47 + + # Cancels book packets when a book is not in hand + # Vls to add when a packet fails the check. (Set to -1 to disable) + book: 10 + + # Cancels CustomPayload packets with invalid tags + # Vls to add when a packet fails the check. (Set to -1 to disable) + tag: 100 + + # Checks if players send PacketPlayInWindowClick packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + window_click: 100 + + # Checks if players send PacketPlayInBlockPlace packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_place: 100 + + # Checks if players send PacketPlayInBlockDig packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_dig: 100 + + # Checks if players send PacketPlayInCreativeSlot packets without creative. + # Vls to add when a packet fails the check. (Set to -1 to disable) + set_creative_slot: 100 + + # Vls to add when a normal packet is sent by a player. + # This option is made to work as a packet limiter feature. + # Unlisted packets are considered as "PacketPlayInOther" by default. + # Remember to take a look at bytes_divider option. + multipliers: + PacketPlayInOther: 0.1 + MC|BSign: 4.5 + MC|BEdit: 4.5 + MC|BOpen: 4.5 + PacketPlayInAutoRecipe: 6 + PacketPlayInUpdateSign: 6 + PacketPlayInAbilities: 0.25 + PacketPlayInArmAnimation: 0.05 + PacketPlayInBlockDig: 0.5 + PacketPlayInBlockPlace: 0.5 + PacketPlayInCustomPayload: 0.15 + PacketPlayInEntityAction: 0.5 + PacketPlayInFlying: 0.25 + PacketPlayInLook: 0.5 + PacketPlayInPositionLook: 0.05 + PacketPlayInPosition: 0.2 + PacketPlayInSetCreativeSlot: 0.5 + PacketPlayInSettings: 1 + PacketPlayInTabComplete: 1 + PacketPlayInUseEntity: 0.5 + PacketPlayInUseItem: 1 + PacketPlayInWindowClick: 1 + + # Placeholders: %player% + # Commands to run when a player reachs certain violation level. + violations: + 25: + - "notification" + 50: + - "notification" + 75: + - "notification" + 100: + - "notification" + - "kick" + +# Removes custom NBT tags from creative items to prevent harm to your server. +# Negative enchant values will be always removed. +itemsfix: + enabled: true + + # Maximum stack size obtainable with creative packets. (-1 to allow anything) + max_stack_size: 64 + + # Maximum enchant level obtainable with creative packets. + # -1 removes all enchants, 0 forces vanilla values + enchant_limit: 0 + + # List of materials that are unobtainable from Creative. + blacklist: + - "END_PORTAL" + - "NETHER_PORTAL" + # - "BARRIER" + # - "COMMAND_BLOCK" + +# Checks if players try to crash/exploit the server with commands. +commands: + enabled: true + + # Commands that are excempt from this server. + commands: + - "//calc" + - "//calculate" + - "//eval" + - "//evaluate" + - "//solve" + - "/hd readtext" + - "/holo readtext" + - "/hologram readtext" + - "/holograms readtext" + - "/holographicdisplays readtext" + - "/pex promote" + - "/pex demote" + - "/promote" + - "/demote" + - "/execute" + + # Placeholders: %player% + punishments: + - "notification" + - "kick" From 65b84af3d7dcd9a3cf4c44478f6e496f4691cb96 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:24:15 -0300 Subject: [PATCH 129/336] Clear punishments done each second --- .../bukkit/exploit/BukkitExploitPlayer.java | 2 +- .../bukkit/managers/ExploitPlayerManager.java | 2 ++ .../exploitfixer/shared/exploit/ExploitPlayer.java | 14 +++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java index 3f88e9a..a8fdee0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java @@ -85,7 +85,7 @@ public void addVls(final Cancellable event, final PacketWrapper packet, public void punish(final IModule module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, final Collection punishments, final int newVls) { - final Collection> punishmentsDone = getPunishmentsDone(); + final Collection> punishmentsDone = this.getPunishments(); if (!punishments.isEmpty() && !punishmentsDone.contains(punishments)) { final Server server = plugin.getServer(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 4cc2019..601798d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -56,6 +56,8 @@ public void clear() { if (server.getPlayer(uuid) == null) { iterator.remove(); cleared = true; + } else { + exploitPlayers.get(uuid).clearPunishments();; } } diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 3359d20..9157002 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -9,26 +9,30 @@ public class ExploitPlayer { private final Map violations; - private final Collection> punishmentsDone; + private final Collection> punishments; private long lastViolation; private int channels; public ExploitPlayer() { this.violations = new HashMap<>(); - this.punishmentsDone = new HashSet<>(); + this.punishments = new HashSet<>(); clear(); } + public void clearPunishments() { + this.punishments.clear(); + } + public void clear() { violations.clear(); - punishmentsDone.clear(); + clearPunishments(); setLastViolation(0); channels = 0; } - public Collection> getPunishmentsDone() { - return punishmentsDone; + public Collection> getPunishments() { + return punishments; } public long getLastViolation() { From e0f9b1a3721793627b287c34ddfec8d47c446c19 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:33:23 -0300 Subject: [PATCH 130/336] Improve ExploitPlayer API --- .../exploitfixer/bukkit/ExploitFixer.java | 5 +-- .../bukkit/listener/PlayerLoginListener.java | 5 +++ .../bukkit/listener/PlayerQuitListener.java | 4 +- .../bukkit/managers/ExploitPlayerManager.java | 42 +++++++++---------- .../tasks/ExploitFixerRepeatingTask.java | 7 +--- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java index 4ef23cf..e53c1da 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java @@ -31,7 +31,6 @@ public static synchronized void setInstance(final ExploitFixer exploitFixer) { @Override public void onEnable() { setInstance(this); - final Server server = this.getServer(); if (!checkHamsterAPI()) { throw new IllegalStateException( @@ -106,8 +105,8 @@ private void register() { logger.info("Successfully registered listeners!"); logger.info("Successfully hooked with HamsterAPI!"); - scheduler.runTaskTimerAsynchronously(this, new ExploitFixerRepeatingTask( - moduleManager.getExploitPlayerManager(), moduleManager.getNotificationsModule()), 20L, 20L); + scheduler.runTaskTimerAsynchronously(this, + new ExploitFixerRepeatingTask(moduleManager.getNotificationsModule()), 20L, 20L); logger.info("Successfully registered tasks!"); } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index dbfc49d..9e96f80 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -8,6 +8,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; +import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; @@ -15,11 +16,13 @@ import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; public class PlayerLoginListener implements Listener { + private final ExploitPlayerManager exploitPlayerManager; private final BukkitNotificationsModule notificationsModule; private final MessagesModule messagesModule; private final ConnectionModule connectionModule; PlayerLoginListener(final ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); @@ -42,5 +45,7 @@ public void onPlayerLogin(final PlayerLoginEvent event) { if (player.hasPermission("exploitfixer.notifications")) { notificationsModule.setNotifications(playerName, true); } + + exploitPlayerManager.add(player); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java index b6367ec..a3d1b41 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java @@ -8,7 +8,6 @@ import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; @@ -22,9 +21,8 @@ public class PlayerQuitListener implements Listener { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); - final ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - exploitPlayer.clear(); + exploitPlayerManager.remove(player); notificationsModule.setNotifications(player.getName(), false); } } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index 601798d..a876866 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -1,7 +1,6 @@ package dev._2lstudios.exploitfixer.bukkit.managers; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.UUID; @@ -24,8 +23,7 @@ public class ExploitPlayerManager { this.moduleManager = moduleManager; } - public BukkitExploitPlayer get(final Player player) { - final UUID uuid = player.getUniqueId(); + public BukkitExploitPlayer add(final UUID uuid) { final BukkitExploitPlayer exploitPlayer; if (exploitPlayers.containsKey(uuid)) { @@ -38,31 +36,31 @@ public BukkitExploitPlayer get(final Player player) { return exploitPlayer; } - public void reload() { - exploitPlayers.clear(); + public BukkitExploitPlayer add(final Player player) { + return add(player.getUniqueId()); + } - for (final Player player : server.getOnlinePlayers()) { - get(player); - } + public void remove(final UUID uuid) { + exploitPlayers.remove(uuid); } - public void clear() { - final Iterator iterator = exploitPlayers.keySet().iterator(); - boolean cleared = false; + public void remove(final Player player) { + remove(player.getUniqueId()); + } - while (iterator.hasNext()) { - final UUID uuid = iterator.next(); + public BukkitExploitPlayer get(final UUID uuid) { + return exploitPlayers.getOrDefault(uuid, null); + } - if (server.getPlayer(uuid) == null) { - iterator.remove(); - cleared = true; - } else { - exploitPlayers.get(uuid).clearPunishments();; - } - } + public BukkitExploitPlayer get(final Player player) { + return get(player.getUniqueId()); + } - if (cleared) { - moduleManager.getNotificationsModule().debug("Cleared unused cached players!"); + public void reload() { + exploitPlayers.clear(); + + for (final Player player : server.getOnlinePlayers()) { + add(player); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java b/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java index a57d8ec..5f55da5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java @@ -1,16 +1,12 @@ package dev._2lstudios.exploitfixer.bukkit.tasks; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; public class ExploitFixerRepeatingTask implements Runnable { - private final ExploitPlayerManager exploitPlayerManager; private final NotificationsModule notificationsModule; int seconds = 0; - public ExploitFixerRepeatingTask(final ExploitPlayerManager exploitPlayerManager, - final NotificationsModule notificationsModule) { - this.exploitPlayerManager = exploitPlayerManager; + public ExploitFixerRepeatingTask(final NotificationsModule notificationsModule) { this.notificationsModule = notificationsModule; } @@ -18,7 +14,6 @@ public ExploitFixerRepeatingTask(final ExploitPlayerManager exploitPlayerManager public void run() { if (seconds > 300) { seconds = 0; - exploitPlayerManager.clear(); } else { if (seconds % 10 == 9) { notificationsModule.debugPackets(); From 48d257a14d83c07115a742274be921c62e9b9080 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:34:09 -0300 Subject: [PATCH 131/336] Improve ExploitPlayer API --- .../exploitfixer/shared/exploit/ExploitPlayer.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 9157002..7910b83 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -10,27 +10,18 @@ public class ExploitPlayer { private final Map violations; private final Collection> punishments; - private long lastViolation; - private int channels; + private long lastViolation = 0; + private int channels = 0; public ExploitPlayer() { this.violations = new HashMap<>(); this.punishments = new HashSet<>(); - - clear(); } public void clearPunishments() { this.punishments.clear(); } - public void clear() { - violations.clear(); - clearPunishments(); - setLastViolation(0); - channels = 0; - } - public Collection> getPunishments() { return punishments; } From e6e9ec65643621022029745f1d4ec9dfe02801ed Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:34:52 -0300 Subject: [PATCH 132/336] Remove unused variables --- .../exploitfixer/shared/exploit/ExploitPlayer.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 7910b83..8febb93 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -34,14 +34,6 @@ public void setLastViolation(final long lastViolation) { this.lastViolation = lastViolation; } - public int getChannels() { - return channels; - } - - public int addChannels(final int channels) { - return this.channels += channels; - } - public Map getViolations() { return violations; } From 3db86d6321d323b6ba867f5b1333c488cf6f5f49 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:35:00 -0300 Subject: [PATCH 133/336] Remove unused variables --- .../_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java index 8febb93..ca24c99 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java @@ -11,7 +11,6 @@ public class ExploitPlayer { private final Map violations; private final Collection> punishments; private long lastViolation = 0; - private int channels = 0; public ExploitPlayer() { this.violations = new HashMap<>(); From d3ff20bec3972fc019e03864996ef5e668d4923e Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:36:19 -0300 Subject: [PATCH 134/336] Clear punishments done each second --- .../exploitfixer/bukkit/exploit/BukkitExploitPlayer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java index a8fdee0..3028280 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java @@ -52,6 +52,7 @@ public void addVls(final Cancellable event, final PacketWrapper packet, final long lastViolation = getLastViolation(); if (currentTime - lastViolation >= 1000) { + clearPunishments(); setLastViolation(currentTime); for (final IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { From 240d9d675a2f4bef770d5fc3462aa1a46036c7b0 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:44:14 -0300 Subject: [PATCH 135/336] Register login event --- .../exploitfixer/bukkit/listener/ListenerInitializer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index d49d4a9..96ab0e2 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -29,6 +29,7 @@ public void register() { pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new TabCompleteListener(moduleManager), plugin); From 2be0ceae2f13b77c0e9550e20b366207f0aaac32 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:47:18 -0300 Subject: [PATCH 136/336] Fix player registering --- .../bukkit/listener/PlayerLoginListener.java | 5 ----- .../bukkit/managers/ExploitPlayerManager.java | 16 ++++------------ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java index 9e96f80..dbfc49d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java @@ -8,7 +8,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; @@ -16,13 +15,11 @@ import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; public class PlayerLoginListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; private final BukkitNotificationsModule notificationsModule; private final MessagesModule messagesModule; private final ConnectionModule connectionModule; PlayerLoginListener(final ModuleManager moduleManager) { - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); @@ -45,7 +42,5 @@ public void onPlayerLogin(final PlayerLoginEvent event) { if (player.hasPermission("exploitfixer.notifications")) { notificationsModule.setNotifications(playerName, true); } - - exploitPlayerManager.add(player); } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java index a876866..b330b2f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java @@ -23,7 +23,7 @@ public class ExploitPlayerManager { this.moduleManager = moduleManager; } - public BukkitExploitPlayer add(final UUID uuid) { + public BukkitExploitPlayer get(final UUID uuid) { final BukkitExploitPlayer exploitPlayer; if (exploitPlayers.containsKey(uuid)) { @@ -36,8 +36,8 @@ public BukkitExploitPlayer add(final UUID uuid) { return exploitPlayer; } - public BukkitExploitPlayer add(final Player player) { - return add(player.getUniqueId()); + public BukkitExploitPlayer get(final Player player) { + return get(player.getUniqueId()); } public void remove(final UUID uuid) { @@ -48,19 +48,11 @@ public void remove(final Player player) { remove(player.getUniqueId()); } - public BukkitExploitPlayer get(final UUID uuid) { - return exploitPlayers.getOrDefault(uuid, null); - } - - public BukkitExploitPlayer get(final Player player) { - return get(player.getUniqueId()); - } - public void reload() { exploitPlayers.clear(); for (final Player player : server.getOnlinePlayers()) { - add(player); + get(player); } } From 05cb22ea02d652b3971410cd3acc31dadf5ffb94 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 19:57:31 -0300 Subject: [PATCH 137/336] Change resource path --- pom.xml | 2 +- {src/resources => resources}/config.yml | 0 {src/resources => resources}/locales/de.yml | 0 {src/resources => resources}/locales/en.yml | 0 {src/resources => resources}/locales/es.yml | 0 {src/resources => resources}/locales/fr.yml | 0 {src/resources => resources}/locales/hu.yml | 0 {src/resources => resources}/locales/it.yml | 0 {src/resources => resources}/locales/pl.yml | 0 {src/resources => resources}/locales/pt.yml | 0 {src/resources => resources}/locales/th.yml | 0 {src/resources => resources}/locales/tr.yml | 0 {src/resources => resources}/locales/zh.yml | 0 {src/resources => resources}/plugin.yml | 0 14 files changed, 1 insertion(+), 1 deletion(-) rename {src/resources => resources}/config.yml (100%) rename {src/resources => resources}/locales/de.yml (100%) rename {src/resources => resources}/locales/en.yml (100%) rename {src/resources => resources}/locales/es.yml (100%) rename {src/resources => resources}/locales/fr.yml (100%) rename {src/resources => resources}/locales/hu.yml (100%) rename {src/resources => resources}/locales/it.yml (100%) rename {src/resources => resources}/locales/pl.yml (100%) rename {src/resources => resources}/locales/pt.yml (100%) rename {src/resources => resources}/locales/th.yml (100%) rename {src/resources => resources}/locales/tr.yml (100%) rename {src/resources => resources}/locales/zh.yml (100%) rename {src/resources => resources}/plugin.yml (100%) diff --git a/pom.xml b/pom.xml index 58723da..5d210c6 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ . - ${basedir}/src/resources/ + ${basedir}/resources/ diff --git a/src/resources/config.yml b/resources/config.yml similarity index 100% rename from src/resources/config.yml rename to resources/config.yml diff --git a/src/resources/locales/de.yml b/resources/locales/de.yml similarity index 100% rename from src/resources/locales/de.yml rename to resources/locales/de.yml diff --git a/src/resources/locales/en.yml b/resources/locales/en.yml similarity index 100% rename from src/resources/locales/en.yml rename to resources/locales/en.yml diff --git a/src/resources/locales/es.yml b/resources/locales/es.yml similarity index 100% rename from src/resources/locales/es.yml rename to resources/locales/es.yml diff --git a/src/resources/locales/fr.yml b/resources/locales/fr.yml similarity index 100% rename from src/resources/locales/fr.yml rename to resources/locales/fr.yml diff --git a/src/resources/locales/hu.yml b/resources/locales/hu.yml similarity index 100% rename from src/resources/locales/hu.yml rename to resources/locales/hu.yml diff --git a/src/resources/locales/it.yml b/resources/locales/it.yml similarity index 100% rename from src/resources/locales/it.yml rename to resources/locales/it.yml diff --git a/src/resources/locales/pl.yml b/resources/locales/pl.yml similarity index 100% rename from src/resources/locales/pl.yml rename to resources/locales/pl.yml diff --git a/src/resources/locales/pt.yml b/resources/locales/pt.yml similarity index 100% rename from src/resources/locales/pt.yml rename to resources/locales/pt.yml diff --git a/src/resources/locales/th.yml b/resources/locales/th.yml similarity index 100% rename from src/resources/locales/th.yml rename to resources/locales/th.yml diff --git a/src/resources/locales/tr.yml b/resources/locales/tr.yml similarity index 100% rename from src/resources/locales/tr.yml rename to resources/locales/tr.yml diff --git a/src/resources/locales/zh.yml b/resources/locales/zh.yml similarity index 100% rename from src/resources/locales/zh.yml rename to resources/locales/zh.yml diff --git a/src/resources/plugin.yml b/resources/plugin.yml similarity index 100% rename from src/resources/plugin.yml rename to resources/plugin.yml From 01ed77749c550265ac52cdfc173a30c5cefc3484 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Sat, 8 May 2021 20:03:23 -0300 Subject: [PATCH 138/336] Bump version number --- pom.xml | 2 +- resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5d210c6..c04742b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 exploitfixer ExploitFixer - SNAPSHOT + 1.5.6 1.8 1.8 diff --git a/resources/plugin.yml b/resources/plugin.yml index ace8c7f..615de59 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.5 +version: 1.5.6 author: 2LS api: "1.13" api-version: "1.13" From 6bfa1a210ba7f8f1b2a1b9bd50a6277e39f01995 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Sun, 9 May 2021 11:07:51 -0300 Subject: [PATCH 139/336] Update config.yml --- resources/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 23916cd..2a24a02 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -21,7 +21,7 @@ notifications: message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" # This shows extra information about blocked packets. - debug: true + debug: false # Prevents exploits that occur on different Bukkit events. events: @@ -97,7 +97,7 @@ packets: PacketPlayInArmAnimation: 0.05 PacketPlayInBlockDig: 0.5 PacketPlayInBlockPlace: 0.5 - PacketPlayInCustomPayload: 0.15 + PacketPlayInCustomPayload: 0.01 PacketPlayInEntityAction: 0.5 PacketPlayInFlying: 0.25 PacketPlayInLook: 0.5 From ec48a9ebd1e68507182b031a69cba5e2400b8ce6 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Sun, 9 May 2021 11:35:27 -0300 Subject: [PATCH 140/336] Update plugin.yml --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 615de59..3e4e6a8 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.6 +version: 1.5.7 author: 2LS api: "1.13" api-version: "1.13" From 79c0fe46c6538088d7d27857dc83bdd580b1cf92 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Wed, 12 May 2021 10:38:05 -0300 Subject: [PATCH 141/336] Fix false positives with plugins --- src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 858098e..5ec3401 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -84,7 +84,7 @@ public boolean checkItem(final ItemStack item) { if (itemMeta != null) { final String displayName = itemMeta.getDisplayName(); - if (displayName != null && displayName.length() > 64) { + if (displayName != null && displayName.length() > 128) { return false; } From e41ced6fbfad2bd26bbd11efd2dec32e0e3dca42 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Wed, 12 May 2021 10:39:48 -0300 Subject: [PATCH 142/336] Improve default config --- resources/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 2a24a02..3066db3 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -104,11 +104,11 @@ packets: PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.5 - PacketPlayInSettings: 1 - PacketPlayInTabComplete: 1 + PacketPlayInSettings: 0.5 + PacketPlayInTabComplete: 2 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 1 - PacketPlayInWindowClick: 1 + PacketPlayInWindowClick: 0.65 # Placeholders: %player% # Commands to run when a player reachs certain violation level. From 948031a41bb617ec2020b201d532a74f1a26c10c Mon Sep 17 00:00:00 2001 From: HiKings <44883335+HiKingsFR@users.noreply.github.com> Date: Thu, 13 May 2021 00:51:47 +0200 Subject: [PATCH 143/336] Fixed checkBook NPE --- .../_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 5ec3401..49124de 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -52,11 +52,15 @@ private boolean checkBlockState(final BlockStateMeta meta) { } private boolean checkBook(final BookMeta meta) { - if (meta.getTitle().length() > 32) { + final String title = meta.getTitle(); + + if (title != null && title.length() > 32) { return false; } + + final String author = meta.getAuthor(); - if (meta.getAuthor().length() > 16) { + if (author != null && author.length() > 16) { return false; } From b8966c873ca608a6efbf1940b8b3c33102d39095 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Fri, 14 May 2021 17:51:14 -0300 Subject: [PATCH 144/336] Update plugin.yml --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 3e4e6a8..2ceb6eb 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.7 +version: 1.5.8 author: 2LS api: "1.13" api-version: "1.13" From 8c956636c5b8373558dc57c38f926836179edcec Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Fri, 14 May 2021 17:53:09 -0300 Subject: [PATCH 145/336] Fix compilation issues --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c04742b..3c5726d 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ HamsterAPI SNAPSHOT system - /home/linsaftw/java/bin/HamsterAPI.jar + /home/linsaftw/Jars/HamsterAPI.jar \ No newline at end of file From 33af2c4eca6c81739d489d100b7a2ee1347bba12 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Fri, 14 May 2021 18:01:43 -0300 Subject: [PATCH 146/336] Bump pom.xml version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c5726d..354d347 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 exploitfixer ExploitFixer - 1.5.6 + 1.5.8 1.8 1.8 From 3158a6cab10e84e89a0107a8aeca0557b5dac799 Mon Sep 17 00:00:00 2001 From: Kua Date: Sat, 15 May 2021 20:53:54 +0900 Subject: [PATCH 147/336] Added Korean language --- resources/locales/ko.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/locales/ko.yml diff --git a/resources/locales/ko.yml b/resources/locales/ko.yml new file mode 100644 index 0000000..3033a2b --- /dev/null +++ b/resources/locales/ko.yml @@ -0,0 +1,27 @@ +# Korean +commands: + reload: "&aExploitFixer 플러그ì¸ì´ 리로드ë˜ì—ˆìŠµë‹ˆë‹¤!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &b사용 가능 명령어를 표시합니다. + &e /%command% reload &7> &b플러그ì¸ì„ 다시 로드합니다. + &e /%command% notifications &7> &bí”ŒëŸ¬ê·¸ì¸ ì•ŒëžŒì„ í† ê¸€í•©ë‹ˆë‹¤. + &e /%command% stats &7> &b플레ì´ì–´ ìž‘ë™ í˜„í™©ì„ í™•ì¸í•©ë‹ˆë‹¤. + error: + unknown: "&c알 수 없는 명령어입니다. /exploitfixer help 명령어를 통해 사용 가능한 명령어를 확ì¸í•˜ì„¸ìš”!" + permission: "&cë‹¹ì‹ ì€ ì´ ëª…ë ¹ì–´ë¥¼ 사용할 ê¶Œí•œì´ ëª¨ìžëžë‹ˆë‹¤!" + console: "&cì´ ëª…ë ¹ì–´ëŠ” 콘솔ì—서 입력할 수 없습니다!" + notifications: + enable: "&aì•ŒëžŒì„ í™œì„±í™” 하였습니다!" + disable: "&cì•ŒëžŒì„ ë¹„í™œì„±í™” 하였습니다!" + stats: "&c&lEF: &e플레ì´ì–´ ìºì‹œ: &a%players_cached%&e ì œìž¬ëœ í”Œë ˆì´ì–´: &a%players_punished%" +modules: + custompayload: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f너무 ë§Žì€ CustomPayload íŒ¨í‚·ì´ ê°ì§€ë¨.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f명령어 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f패킷 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &fNull address ê°ì§€.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang ì„œë²„ì— ë¬¸ì œê°€ ìƒê²¼ìŠµë‹ˆë‹¤, ë‚˜ì¤‘ì— ë‹¤ì‹œ 와주세요!\n\n&7사유: &fExploitFixer UUID를 ì°¾ì„ ìˆ˜ 없었습니다.\n&7Discord: &b&n%web%&r" \ No newline at end of file From 9301de1554f7e165b156d5f96e600bcc434ab769 Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Sat, 15 May 2021 21:41:31 +0200 Subject: [PATCH 148/336] Added missing languages Added missing languages --- .../exploitfixer/shared/modules/MessagesModule.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 8733fb7..696ce93 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -34,6 +34,10 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("it"); defaultLocales.add("pt"); defaultLocales.add("tr"); + defaultLocales.add("de"); + defaultLocales.add("pl"); + defaultLocales.add("tr"); + defaultLocales.add("zh"); } public void putSection(final IConfiguration langFile, final Map locale, final String currentPath) { @@ -147,4 +151,4 @@ public String getStats(final String locale) { public String getMojangDown(final String locale) { return getString(locale, "mojang_down"); } -} \ No newline at end of file +} From b3bd719fc6203ca00413a6fa2df7302750e45207 Mon Sep 17 00:00:00 2001 From: terrarier2111 <58695553+terrarier2111@users.noreply.github.com> Date: Sun, 16 May 2021 22:15:14 +0200 Subject: [PATCH 149/336] Use Collection#contains --- .../_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java index 49124de..5a2e340 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java @@ -131,14 +131,10 @@ public String clearIfBlacklisted(final ItemStack itemStack) { final Collection blacklist = itemsFixModule.getBlacklist(); final String materialName = itemStack.getType().toString(); - if (blacklist != null) { - for (final String blockedMaterial : blacklist) { - if (materialName.equals(blockedMaterial)) { + if (blacklist != null && blacklist.contains(materialName)) { itemStack.setType(Material.AIR); itemStack.setItemMeta(null); return materialName; - } - } } return null; From b94052ff6d3495a5add96810b1042d19382642b1 Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Tue, 18 May 2021 13:09:28 +0200 Subject: [PATCH 150/336] Improved German translation Improved German translation --- resources/locales/de.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index a55c3b0..50beafe 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -4,24 +4,24 @@ commands: help: |- &aExploitFixer &b%version%&a von &bLinsaFTW&a. &e /%command% help &7> &bZeigt alle verfügbaren Befehle. - &e /%command% reload &7> &bLäd das Plugin neu. + &e /%command% reload &7> &bLädt das Plugin neu. &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. &e /%command% stats &7> &bZeigt die Stats vom Plugin an. error: unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" permission: "&cDu darfst diesen Command nicht ausführen!" - console: "&cDiesen Command darfst du nicht als Konsole ausführen!" + console: "&cDiesen Command darfst von der Konsole nicht ausgeführt werden!" notifications: enable: "&aDu hast die Benachrichtigungen aktiviert!" disable: "&cDu hast die Benachrichtigungen deaktiviert!" - stats: "&c&lEF: &eSpieler cached: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" + stats: "&c&lEF: &eSpieler zwischengespeichert: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" modules: custompayload: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload packets wurden erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packets wurden erkannt.\n&7Discord: &b&n%web%&r" commands: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fCommand exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fCommand Exploit erkannt.\n&7Discord: &b&n%web%&r" packets: kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fPackets exploit erkannt.\n&7Discord: &b&n%web%&r" nulladdress: kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fUnbekannte IP-Addresse erkannt.\n&7Discord: &b&n%web%&r" -mojang_down: "&cDie Mojang servers sind down, komm bitte später zurück!\n\n&7Grund: &fExploitFixer kann die UUID nicht checken.\n&7Discord: &b&n%web%&r" +mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" From 4dd58d59405c159fc09e5cf6ab79f67a690d8fe6 Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Tue, 18 May 2021 13:10:51 +0200 Subject: [PATCH 151/336] Improved German translation 2 Improved German translation 2 --- resources/locales/de.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index 50beafe..075dbdd 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -10,7 +10,7 @@ commands: error: unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" permission: "&cDu darfst diesen Command nicht ausführen!" - console: "&cDiesen Command darfst von der Konsole nicht ausgeführt werden!" + console: "&cDiesen Command darf von der Konsole nicht ausgeführt werden!" notifications: enable: "&aDu hast die Benachrichtigungen aktiviert!" disable: "&cDu hast die Benachrichtigungen deaktiviert!" From 921dd5225996a6725f01b3d7f1e02e86ba73021a Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Tue, 18 May 2021 13:12:32 +0200 Subject: [PATCH 152/336] Improved German translation 3 Improved German translation 3 --- resources/locales/de.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index 075dbdd..cd0a663 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -9,19 +9,19 @@ commands: &e /%command% stats &7> &bZeigt die Stats vom Plugin an. error: unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" - permission: "&cDu darfst diesen Command nicht ausführen!" - console: "&cDiesen Command darf von der Konsole nicht ausgeführt werden!" + permission: "&cDu darfst diesen Befehl nicht ausführen!" + console: "&cDieser Befehl darf von der Konsole nicht ausgeführt werden!" notifications: enable: "&aDu hast die Benachrichtigungen aktiviert!" disable: "&cDu hast die Benachrichtigungen deaktiviert!" stats: "&c&lEF: &eSpieler zwischengespeichert: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" modules: custompayload: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packets wurden erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" commands: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fCommand Exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" packets: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fPackets exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fPackete Exploit erkannt.\n&7Discord: &b&n%web%&r" nulladdress: kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fUnbekannte IP-Addresse erkannt.\n&7Discord: &b&n%web%&r" mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" From dde35a8b1aa55c48e8bda680a2c335de790c5fbe Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Fri, 21 May 2021 16:15:06 -0300 Subject: [PATCH 153/336] Bump version number --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 2ceb6eb..c2f41cb 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.8 +version: 1.5.9 author: 2LS api: "1.13" api-version: "1.13" From 345b56a0a11a4654c481c6489da3a606df34033c Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Fri, 21 May 2021 16:18:11 -0300 Subject: [PATCH 154/336] Use SNAPSHOT on pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 354d347..904b4c5 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 exploitfixer ExploitFixer - 1.5.8 + SNAPSHOT 1.8 1.8 @@ -53,4 +53,4 @@ /home/linsaftw/Jars/HamsterAPI.jar - \ No newline at end of file + From 6b35b385b021431a700d3f8ad7abdf481f896ccc Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Sat, 22 May 2021 02:59:47 +0200 Subject: [PATCH 155/336] Improved german language (typos, grammar) --- resources/locales/de.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index cd0a663..5aa6798 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -3,25 +3,25 @@ commands: reload: "&aPlugin ExploitFixer wurde neugeladen!" help: |- &aExploitFixer &b%version%&a von &bLinsaFTW&a. - &e /%command% help &7> &bZeigt alle verfügbaren Befehle. + &e /%command% help &7> &bZeigt alle verfügbaren Befehle an. &e /%command% reload &7> &bLädt das Plugin neu. &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. &e /%command% stats &7> &bZeigt die Stats vom Plugin an. error: unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" permission: "&cDu darfst diesen Befehl nicht ausführen!" - console: "&cDieser Befehl darf von der Konsole nicht ausgeführt werden!" + console: "&cDieser Befehl darf nicht von der Konsole ausgeführt werden!" notifications: enable: "&aDu hast die Benachrichtigungen aktiviert!" disable: "&cDu hast die Benachrichtigungen deaktiviert!" - stats: "&c&lEF: &eSpieler zwischengespeichert: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" + stats: "&c&lEF: &eZwischengespeicherte Spieler: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" modules: custompayload: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" commands: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" packets: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fPackete Exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fPackete Exploit erkannt.\n&7Discord: &b&n%web%&r" nulladdress: - kick_message: "&cDu bist temprorär vom Server gesperrt!\n\n&7Grund: &fUnbekannte IP-Addresse erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fNulladresse erkannt.\n&7Discord: &b&n%web%&r" mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" From 1fc5a7325f3e9267d2805af77d05a2581f567e83 Mon Sep 17 00:00:00 2001 From: Hazuki Onohara Date: Sun, 23 May 2021 22:08:41 +0700 Subject: [PATCH 156/336] Missing Thai language --- .../_2lstudios/exploitfixer/shared/modules/MessagesModule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 696ce93..5b7e981 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -36,6 +36,7 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("tr"); defaultLocales.add("de"); defaultLocales.add("pl"); + defaultLocales.add("th"); defaultLocales.add("tr"); defaultLocales.add("zh"); } From d3e6a1d90d671b029e84fe07a91d8fa44b6324b1 Mon Sep 17 00:00:00 2001 From: DoubleNico <55035625+DoubleNico@users.noreply.github.com> Date: Mon, 24 May 2021 22:15:10 +0300 Subject: [PATCH 157/336] Romanian Language --- resources/locales/ro.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/locales/ro.yml diff --git a/resources/locales/ro.yml b/resources/locales/ro.yml new file mode 100644 index 0000000..1e350b0 --- /dev/null +++ b/resources/locales/ro.yml @@ -0,0 +1,27 @@ +# Romanian Language by DoubleNico +commands: + reload: "&aPluginul ExploitFixer a fost reîncărcat!" + help: |- + &aExploitFixer &b%version%&a creat de &bLinsaFTW&a. + &e /%command% help &7> &bAfiÈ™ează comenzile disponibile. + &e /%command% reload &7> &bReîncărcaÈ›i pluginul. + &e /%command% notifications &7> &bComută notificările despre plugin. + &e /%command% stats &7> &bUrmăriÈ›i statisticile pluginului. + error: + unknown: "&cComanda necunoscută. UtilizaÈ›i /exploitfixer help pentru a vedea comenzile disponibile!" + permission: "&cNu aveÈ›i permisiunea de a utiliza această comandă!" + console: "&cAceastă comandă nu poate fi executată din consola!" + notifications: + enable: "&aAÈ›i activat notificările!" + disable: "&cAveÈ›i notificările dezactivate!" + stats: "&c&lEF: &eJucători cached: &a%players_cached%&e Jucători pedepsiti: &a%players_punished%" +modules: + custompayload: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fPrea multe pachete de tip CustomPayload.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fFolosirea Comenzilor Exploatabile.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fExploatarea pachetelor.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fAdresa null.\n&7Discord: &b&n%web%&r" +mojang_down: "&cServerele Mojang sunt offline, vă rugăm să reveniÈ›i mai târziu!\n\n&7Motiv: &fNu putem detecta adresa UUID.\n&7Discord: &b&n%web%&r" From f5de4552b8db43fee370a24eb78f14a74a3d04c7 Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Tue, 25 May 2021 00:37:50 +0200 Subject: [PATCH 158/336] Improved german language (grammar) Improved german language (grammar) --- resources/locales/de.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index 5aa6798..afcef1a 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -1,6 +1,7 @@ # German - Credits: Dominik48N +# German - Edited: NoJokeFNA / GeGrieftGames commands: - reload: "&aPlugin ExploitFixer wurde neugeladen!" + reload: "&aPlugin ExploitFixer wurde neu geladen!" help: |- &aExploitFixer &b%version%&a von &bLinsaFTW&a. &e /%command% help &7> &bZeigt alle verfügbaren Befehle an. @@ -21,7 +22,7 @@ modules: commands: kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" packets: - kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fPackete Exploit erkannt.\n&7Discord: &b&n%web%&r" + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fPacket Exploit erkannt.\n&7Discord: &b&n%web%&r" nulladdress: kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fNulladresse erkannt.\n&7Discord: &b&n%web%&r" mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" From 492f96768ea7ca8d765eb5b7989880244aba5143 Mon Sep 17 00:00:00 2001 From: "GeGrieftGames.de" <68118361+GeGrieftGames@users.noreply.github.com> Date: Tue, 25 May 2021 00:40:13 +0200 Subject: [PATCH 159/336] Update de.yml --- resources/locales/de.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index afcef1a..7905a69 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -1,5 +1,4 @@ -# German - Credits: Dominik48N -# German - Edited: NoJokeFNA / GeGrieftGames +# German - Credits: Dominik48N / NoJokeFNA / GeGrieftGames commands: reload: "&aPlugin ExploitFixer wurde neu geladen!" help: |- From 65092d78ff07e1caf5d21e7af9240e22fded8ea5 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Mon, 24 May 2021 21:20:40 -0300 Subject: [PATCH 160/336] Reordered language initialization --- .../exploitfixer/shared/modules/MessagesModule.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java index 5b7e981..5cdc5fe 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java @@ -27,15 +27,16 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l this.logger = logger; this.version = version; + defaultLocales.add("de"); defaultLocales.add("en"); defaultLocales.add("es"); defaultLocales.add("fr"); defaultLocales.add("hu"); defaultLocales.add("it"); - defaultLocales.add("pt"); - defaultLocales.add("tr"); - defaultLocales.add("de"); + defaultLocales.add("ko"); defaultLocales.add("pl"); + defaultLocales.add("pt"); + defaultLocales.add("ro"); defaultLocales.add("th"); defaultLocales.add("tr"); defaultLocales.add("zh"); From af65521f26ab4702a129e45c1d126c87785dc584 Mon Sep 17 00:00:00 2001 From: linsaftw <25271111+linsaftw@users.noreply.github.com> Date: Mon, 24 May 2021 21:22:23 -0300 Subject: [PATCH 161/336] Improve locale handling --- .../_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java index 6fe6ef5..52a1531 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java @@ -20,9 +20,11 @@ public static String getLocale(final Player player) { } if (locale != null && locale.length() > 1) { - return locale.substring(0, 2); + locale = locale.substring(0, 2); } else { - return "en"; + locale = "en"; } + + return locale; } } \ No newline at end of file From 2a05f396460b3f5b49b261ab23d9b99393f6c34c Mon Sep 17 00:00:00 2001 From: terrarier2111 <58695553+terrarier2111@users.noreply.github.com> Date: Mon, 7 Jun 2021 11:17:58 +0200 Subject: [PATCH 162/336] Update german translation --- resources/locales/de.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/locales/de.yml b/resources/locales/de.yml index 7905a69..8423527 100644 --- a/resources/locales/de.yml +++ b/resources/locales/de.yml @@ -6,7 +6,7 @@ commands: &e /%command% help &7> &bZeigt alle verfügbaren Befehle an. &e /%command% reload &7> &bLädt das Plugin neu. &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. - &e /%command% stats &7> &bZeigt die Stats vom Plugin an. + &e /%command% stats &7> &bZeigt die Statistiken des Plugins an. error: unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" permission: "&cDu darfst diesen Befehl nicht ausführen!" @@ -14,7 +14,7 @@ commands: notifications: enable: "&aDu hast die Benachrichtigungen aktiviert!" disable: "&cDu hast die Benachrichtigungen deaktiviert!" - stats: "&c&lEF: &eZwischengespeicherte Spieler: &a%players_cached%&e bestrafte Spieler: &a%players_punished%" + stats: "&c&lEF: &eZwischengespeicherte Spieler: &a%players_cached%&e Bestrafte Spieler: &a%players_punished%" modules: custompayload: kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" From 97701b18b35d92aba4b2175abbafb60d9d594473 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 10 Jun 2021 10:55:10 -0300 Subject: [PATCH 163/336] update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 904b4c5..6b1f8c0 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ HamsterAPI SNAPSHOT system - /home/linsaftw/Jars/HamsterAPI.jar + C:\Users\LinsaFTW\Documents\Jars\HamsterAPI.jar From 053c1246d7cf8bdfdab6dd6c3cf96739455d86d5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 10 Jun 2021 11:01:13 -0300 Subject: [PATCH 164/336] check for invalid numbers --- .../bukkit/listener/PacketReceiveListener.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index cff36bc..172229f 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -159,8 +159,8 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); - notificationsModule.debug(playerName - + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); + notificationsModule.debug( + playerName + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); } else { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); notificationsModule.debug(playerName + " had a creative item fixed by ExploiFixer!"); @@ -169,6 +169,18 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } + if (dataVls > 0) { + for (final float val : packetWrapper.getFloats().values()) { + if (val > Integer.MAX_VALUE || val < -Integer.MAX_VALUE) { + final String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid number! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + } + notificationsModule.addPacketDebug(String.valueOf(packetType)); } From 3fe999089dc8a6b6ad9b2eca9d6e57372b390581 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 10 Jun 2021 11:06:26 -0300 Subject: [PATCH 165/336] Update plugin.yml --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index c2f41cb..113f2f7 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer -version: 1.5.9 +version: 1.6.0 author: 2LS api: "1.13" api-version: "1.13" From 43c1c8f5be8ab69fa5871fe2a764f2235a50e9cf Mon Sep 17 00:00:00 2001 From: HakanGulgen Date: Wed, 16 Jun 2021 21:09:15 +0300 Subject: [PATCH 166/336] Packet level tab complete protection. --- .../bukkit/listener/ListenerInitializer.java | 1 - .../listener/PacketReceiveListener.java | 20 +++++++ .../bukkit/listener/TabCompleteListener.java | 53 ------------------- 3 files changed, 20 insertions(+), 54 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java index 96ab0e2..eba096c 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java @@ -32,7 +32,6 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); - pluginManager.registerEvents(new TabCompleteListener(moduleManager), plugin); } public void unregister() { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 172229f..9b83c6e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -3,6 +3,7 @@ import java.util.Map; import java.util.Map.Entry; +import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -34,6 +35,7 @@ public class PacketReceiveListener implements Listener { private final ItemsFixModule itemsFixModule; private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; + private final CommandsModule commandsModule; PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; @@ -41,6 +43,7 @@ public class PacketReceiveListener implements Listener { this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); + this.commandsModule = moduleManager.getCommandsModule(); } public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, @@ -63,6 +66,23 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName)); + if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { + if (!strings.isEmpty()) { + final String message = strings.values().iterator().next() + .replaceAll("[\\w]{1,}:", "").toLowerCase(); + + for (final String command : commandsModule.getCommands()) { + if (message.startsWith(command)) { + exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), 1); + + event.setCancelled(true); + + return; + } + } + } + } + if (packetType == PacketType.PacketPlayInCustomPayload) { if (!strings.isEmpty()) { final String tag = strings.values().iterator().next(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java deleted file mode 100644 index fde38bb..0000000 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/TabCompleteListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.server.TabCompleteEvent; - -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; -import dev._2lstudios.hamsterapi.HamsterAPI; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; - -public class TabCompleteListener implements Listener { - private final HamsterPlayerManager hamsterPlayerManager; - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; - - TabCompleteListener(final ModuleManager moduleManager) { - this.hamsterPlayerManager = HamsterAPI.getInstance().getHamsterPlayerManager(); - this.commandsModule = moduleManager.getCommandsModule(); - this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final TabCompleteEvent event) { - final CommandSender sender = event.getSender(); - - if (sender instanceof Player) { - final Player player = (Player) sender; - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - - if (commandsModule.isEnabled()) { - final String message = event.getBuffer().replaceAll("[\\w]{1,}:", "").toLowerCase(); - - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command)) { - final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); - - exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); - - event.setCancelled(true); - break; - } - } - } - } - } -} \ No newline at end of file From d01e090e6af5eded866cef9c16e7dfd5b0693cc4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:03:22 -0300 Subject: [PATCH 167/336] reuse logic to avoid redundancy --- .../shared/modules/CommandsModule.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java index 6fc2082..f4bba7f 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java @@ -6,7 +6,8 @@ import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; public class CommandsModule implements IPunishmentModule { - private Collection commands, punishments; + private Collection commands; + private Collection punishments; private String name; private boolean enabled; @@ -27,8 +28,18 @@ public String getName() { return name; } - public final Collection getCommands() { - return commands; + public final boolean isCommand(final String rawMessage) { + if (rawMessage != null) { + final String message = rawMessage.replaceAll("[\\w]{1,}:", "").toLowerCase(); + + for (final String command : commands) { + if (message.startsWith(command)) { + return true; + } + } + } + + return false; } public final Collection getPunishments() { From 61e62b73f3a2180723081ca976ac6ff1d46e351c Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:03:39 -0300 Subject: [PATCH 168/336] update command listeners --- .../bukkit/listener/PacketReceiveListener.java | 14 +++++--------- .../bukkit/listener/PlayerCommandListener.java | 16 ++++------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java index 9b83c6e..6381843 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java @@ -68,17 +68,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { if (!strings.isEmpty()) { - final String message = strings.values().iterator().next() - .replaceAll("[\\w]{1,}:", "").toLowerCase(); + final String rawMessage = strings.values().iterator().next(); - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command)) { - exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), 1); + if (commandsModule.isCommand(rawMessage)) { + exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), 1); + event.setCancelled(true); - event.setCancelled(true); - - return; - } + return; } } } diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java index 3bf4b3f..7da6319 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java @@ -30,19 +30,11 @@ public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - if (commandsModule.isEnabled()) { - final String message = event.getMessage().replaceAll("[\\w]{1,}:", "").toLowerCase(); + if (commandsModule.isEnabled() && commandsModule.isCommand(event.getMessage())) { + final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); - for (final String command : commandsModule.getCommands()) { - if (message.startsWith(command)) { - final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); - - exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); - - event.setCancelled(true); - break; - } - } + exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); + event.setCancelled(true); } } } \ No newline at end of file From 243aca80270863ec2e54c9c937bf4b3b01ae5cf8 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:04:39 -0300 Subject: [PATCH 169/336] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6b1f8c0..a6823f9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - exploitfixer + dev._2lstudios ExploitFixer SNAPSHOT @@ -9,7 +9,7 @@ ${project.artifactId} - src + ${basedir}/src/ . From 840b045d077254e978adf494c80525788c602e21 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:12:54 -0300 Subject: [PATCH 170/336] merge interfaces with plugin --- resources/plugin.yml | 2 +- .../{bukkit => }/ExploitFixer.java | 14 ++++++------- .../commands/ExploitFixerCommand.java | 14 ++++++------- .../configuration/BukkitConfiguration.java | 4 ++-- .../configuration/IConfiguration.java | 2 +- .../exploit/BukkitExploitPlayer.java | 20 +++++++++---------- .../{shared => }/exploit/ExploitPlayer.java | 4 ++-- .../{shared => }/exploit/Violations.java | 4 ++-- .../interfaces/IConfigurationUtil.java | 4 ++-- .../interfaces/IMessagesModule.java | 2 +- .../{shared => }/interfaces/IModule.java | 2 +- .../interfaces/INotificationsModule.java | 2 +- .../interfaces/IPunishmentModule.java | 2 +- .../interfaces/IViolationModule.java | 2 +- .../EntityDamageByEntityListener.java | 8 ++++---- .../listener/ListenerInitializer.java | 6 +++--- .../listener/PacketDecodeListener.java | 8 ++++---- .../listener/PacketReceiveListener.java | 18 ++++++++--------- .../listener/PlayerCommandListener.java | 10 +++++----- .../listener/PlayerLoginListener.java | 12 +++++------ .../listener/PlayerMoveListener.java | 8 ++++---- .../listener/PlayerQuitListener.java | 8 ++++---- .../managers/ExploitPlayerManager.java | 4 ++-- .../{bukkit => }/managers/ModuleManager.java | 20 +++++++++---------- .../modules/BukkitNotificationsModule.java | 4 ++-- .../{shared => }/modules/CommandsModule.java | 6 +++--- .../modules/ConnectionModule.java | 6 +++--- .../{bukkit => }/modules/EventsModule.java | 6 +++--- .../{bukkit => }/modules/ItemsFixModule.java | 6 +++--- .../{shared => }/modules/MessagesModule.java | 10 +++++----- .../modules/NotificationsModule.java | 6 +++--- .../{shared => }/modules/PacketsModule.java | 8 ++++---- .../tasks/ExploitFixerRepeatingTask.java | 4 ++-- .../utils/BukkitConfigurationUtil.java | 8 ++++---- .../{bukkit => }/utils/ExploitUtil.java | 14 ++++++------- .../{bukkit => }/utils/VersionUtil.java | 2 +- 36 files changed, 130 insertions(+), 130 deletions(-) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/ExploitFixer.java (85%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/commands/ExploitFixerCommand.java (86%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/configuration/BukkitConfiguration.java (94%) rename src/dev/_2lstudios/exploitfixer/{shared => }/configuration/IConfiguration.java (92%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/exploit/BukkitExploitPlayer.java (87%) rename src/dev/_2lstudios/exploitfixer/{shared => }/exploit/ExploitPlayer.java (88%) rename src/dev/_2lstudios/exploitfixer/{shared => }/exploit/Violations.java (84%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/IConfigurationUtil.java (69%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/IMessagesModule.java (64%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/IModule.java (62%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/INotificationsModule.java (73%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/IPunishmentModule.java (70%) rename src/dev/_2lstudios/exploitfixer/{shared => }/interfaces/IViolationModule.java (74%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/EntityDamageByEntityListener.java (81%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/ListenerInitializer.java (88%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PacketDecodeListener.java (93%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PacketReceiveListener.java (94%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PlayerCommandListener.java (81%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PlayerLoginListener.java (78%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PlayerMoveListener.java (80%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/listener/PlayerQuitListener.java (73%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/managers/ExploitPlayerManager.java (92%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/managers/ModuleManager.java (80%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/modules/BukkitNotificationsModule.java (91%) rename src/dev/_2lstudios/exploitfixer/{shared => }/modules/CommandsModule.java (83%) rename src/dev/_2lstudios/exploitfixer/{shared => }/modules/ConnectionModule.java (78%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/modules/EventsModule.java (75%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/modules/ItemsFixModule.java (96%) rename src/dev/_2lstudios/exploitfixer/{shared => }/modules/MessagesModule.java (94%) rename src/dev/_2lstudios/exploitfixer/{shared => }/modules/NotificationsModule.java (93%) rename src/dev/_2lstudios/exploitfixer/{shared => }/modules/PacketsModule.java (91%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/tasks/ExploitFixerRepeatingTask.java (81%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/utils/BukkitConfigurationUtil.java (91%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/utils/ExploitUtil.java (91%) rename src/dev/_2lstudios/exploitfixer/{bukkit => }/utils/VersionUtil.java (93%) diff --git a/resources/plugin.yml b/resources/plugin.yml index 113f2f7..c0cbd1f 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,5 +1,5 @@ name: ExploitFixer -main: dev._2lstudios.exploitfixer.bukkit.ExploitFixer +main: dev._2lstudios.exploitfixer.ExploitFixer version: 1.6.0 author: 2LS api: "1.13" diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java b/src/dev/_2lstudios/exploitfixer/ExploitFixer.java similarity index 85% rename from src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java rename to src/dev/_2lstudios/exploitfixer/ExploitFixer.java index e53c1da..210a6e0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/ExploitFixer.java +++ b/src/dev/_2lstudios/exploitfixer/ExploitFixer.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit; +package dev._2lstudios.exploitfixer; import java.util.logging.Logger; @@ -7,12 +7,12 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; -import dev._2lstudios.exploitfixer.bukkit.commands.ExploitFixerCommand; -import dev._2lstudios.exploitfixer.bukkit.listener.ListenerInitializer; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.tasks.ExploitFixerRepeatingTask; -import dev._2lstudios.exploitfixer.bukkit.utils.BukkitConfigurationUtil; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.listener.ListenerInitializer; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.tasks.ExploitFixerRepeatingTask; +import dev._2lstudios.exploitfixer.utils.BukkitConfigurationUtil; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class ExploitFixer extends JavaPlugin { private static ExploitFixer instance; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java similarity index 86% rename from src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java rename to src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index ac3a001..9b849e7 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -1,16 +1,16 @@ -package dev._2lstudios.exploitfixer.bukkit.commands; +package dev._2lstudios.exploitfixer.commands; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import dev._2lstudios.exploitfixer.bukkit.ExploitFixer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.ExploitFixer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.utils.VersionUtil; +import dev._2lstudios.exploitfixer.modules.MessagesModule; public class ExploitFixerCommand implements CommandExecutor { private final ExploitFixer exploitFixer; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java similarity index 94% rename from src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java rename to src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java index 774dfef..e95d9b0 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java @@ -1,11 +1,11 @@ -package dev._2lstudios.exploitfixer.bukkit.configuration; +package dev._2lstudios.exploitfixer.configuration; import java.util.Collection; import java.util.HashSet; import org.bukkit.configuration.ConfigurationSection; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class BukkitConfiguration implements IConfiguration { private final ConfigurationSection configuration; diff --git a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java b/src/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java similarity index 92% rename from src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java rename to src/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java index 6725155..55ac82c 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/configuration/IConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.configuration; +package dev._2lstudios.exploitfixer.configuration; import java.util.Collection; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java similarity index 87% rename from src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java rename to src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 3028280..34e650d 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.exploit; +package dev._2lstudios.exploitfixer.exploit; import java.util.Collection; import java.util.HashSet; @@ -11,15 +11,15 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.exploit.ExploitPlayer; -import dev._2lstudios.exploitfixer.shared.exploit.Violations; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; -import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.utils.VersionUtil; +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.exploit.Violations; +import dev._2lstudios.exploitfixer.interfaces.IModule; +import dev._2lstudios.exploitfixer.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.modules.MessagesModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java similarity index 88% rename from src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java rename to src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index ca24c99..35f4cb4 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -1,11 +1,11 @@ -package dev._2lstudios.exploitfixer.shared.exploit; +package dev._2lstudios.exploitfixer.exploit; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.interfaces.IViolationModule; public class ExploitPlayer { private final Map violations; diff --git a/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java b/src/dev/_2lstudios/exploitfixer/exploit/Violations.java similarity index 84% rename from src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java rename to src/dev/_2lstudios/exploitfixer/exploit/Violations.java index 2b1e31d..87ac478 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/exploit/Violations.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/Violations.java @@ -1,10 +1,10 @@ -package dev._2lstudios.exploitfixer.shared.exploit; +package dev._2lstudios.exploitfixer.exploit; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class Violations { private Map> violations = new HashMap<>(); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java similarity index 69% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java rename to src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java index b75248f..eeff34e 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java @@ -1,6 +1,6 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; public interface IConfigurationUtil { public IConfiguration get(final String file); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java b/src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java similarity index 64% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java rename to src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java index d4ebd00..3ce37ba 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; public interface IMessagesModule { String getString(final String locale, final String path); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java b/src/dev/_2lstudios/exploitfixer/interfaces/IModule.java similarity index 62% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java rename to src/dev/_2lstudios/exploitfixer/interfaces/IModule.java index 51cf327..f22f4bc 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IModule.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/IModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; public interface IModule { public boolean isEnabled(); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java b/src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java similarity index 73% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java index 500207d..4aef3a4 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/INotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; public interface INotificationsModule extends IModule { public void sendNotification(final String check, final Object player, final int violations); diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java b/src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java similarity index 70% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java rename to src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java index e9e9f2b..0865c40 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IPunishmentModule.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; import java.util.Collection; diff --git a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java b/src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java similarity index 74% rename from src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java rename to src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java index 8c800e5..dba3172 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/interfaces/IViolationModule.java +++ b/src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.interfaces; +package dev._2lstudios.exploitfixer.interfaces; public interface IViolationModule extends IModule { public double getCancelVls(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java b/src/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java similarity index 81% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java rename to src/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java index 7239aca..2a326dd 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/EntityDamageByEntityListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -7,9 +7,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class EntityDamageByEntityListener implements Listener { private final NotificationsModule notificationsModule; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java similarity index 88% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java rename to src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index eba096c..11401b5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -1,12 +1,12 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.Server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; public class ListenerInitializer { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java similarity index 93% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index d771396..7267bb9 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -6,9 +6,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; +import dev._2lstudios.exploitfixer.modules.PacketsModule; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import io.netty.buffer.ByteBuf; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java similarity index 94% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 6381843..3d580a5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -1,9 +1,9 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import java.util.Map; import java.util.Map.Entry; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; +import dev._2lstudios.exploitfixer.modules.CommandsModule; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,13 +17,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.bukkit.utils.ExploitUtil; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; +import dev._2lstudios.exploitfixer.modules.PacketsModule; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java similarity index 81% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index 7da6319..dbbbe76 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerCommandListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -6,10 +6,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.CommandsModule; import dev._2lstudios.hamsterapi.HamsterAPI; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java similarity index 78% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java index dbfc49d..1fa4594 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import java.net.InetAddress; @@ -8,11 +8,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.utils.VersionUtil; -import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.utils.VersionUtil; +import dev._2lstudios.exploitfixer.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.modules.MessagesModule; public class PlayerLoginListener implements Listener { private final BukkitNotificationsModule notificationsModule; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java similarity index 80% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java index 060c1e2..a1e4bb3 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerMoveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.Chunk; import org.bukkit.Location; @@ -8,9 +8,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class PlayerMoveListener implements Listener { private final NotificationsModule notificationsModule; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java similarity index 73% rename from src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java rename to src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java index a3d1b41..86e94c7 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java @@ -1,13 +1,13 @@ -package dev._2lstudios.exploitfixer.bukkit.listener; +package dev._2lstudios.exploitfixer.listener; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java b/src/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java similarity index 92% rename from src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java rename to src/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java index b330b2f..e5dd601 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ExploitPlayerManager.java +++ b/src/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.managers; +package dev._2lstudios.exploitfixer.managers; import java.util.HashMap; import java.util.Map; @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; public class ExploitPlayerManager { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java similarity index 80% rename from src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java rename to src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java index 25b6547..df12df8 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.managers; +package dev._2lstudios.exploitfixer.managers; import java.io.File; import java.util.logging.Logger; @@ -6,15 +6,15 @@ import org.bukkit.Server; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.bukkit.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.EventsModule; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; -import dev._2lstudios.exploitfixer.shared.modules.CommandsModule; -import dev._2lstudios.exploitfixer.shared.modules.ConnectionModule; -import dev._2lstudios.exploitfixer.shared.modules.MessagesModule; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; +import dev._2lstudios.exploitfixer.modules.CommandsModule; +import dev._2lstudios.exploitfixer.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.modules.MessagesModule; +import dev._2lstudios.exploitfixer.modules.PacketsModule; public class ModuleManager { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java similarity index 91% rename from src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java index e4c0129..105b17e 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/BukkitNotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.logging.Logger; @@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class BukkitNotificationsModule extends NotificationsModule { private final CommandSender console; diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java similarity index 83% rename from src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index f4bba7f..9fb5fa8 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -1,9 +1,9 @@ -package dev._2lstudios.exploitfixer.shared.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.Collection; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IPunishmentModule; public class CommandsModule implements IPunishmentModule { private Collection commands; diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java similarity index 78% rename from src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java rename to src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java index 852e79d..81ab14d 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java @@ -1,9 +1,9 @@ -package dev._2lstudios.exploitfixer.shared.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.Collection; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IPunishmentModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IPunishmentModule; public class ConnectionModule implements IPunishmentModule { private boolean nullAddressEnabled; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java similarity index 75% rename from src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/EventsModule.java index c389701..4ebb772 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/EventsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -1,7 +1,7 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.modules; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IModule; public class EventsModule implements IModule { private boolean nullChunk; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java similarity index 96% rename from src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java rename to src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 859a193..a2c7dc5 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.Collection; import java.util.List; @@ -15,8 +15,8 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IModule; public class ItemsFixModule implements IModule { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java similarity index 94% rename from src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java rename to src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index 5cdc5fe..9d40c3a 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.modules; +package dev._2lstudios.exploitfixer.modules; import java.io.File; import java.util.Collection; @@ -7,10 +7,10 @@ import java.util.Map; import java.util.logging.Logger; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; -import dev._2lstudios.exploitfixer.shared.interfaces.IMessagesModule; -import dev._2lstudios.exploitfixer.shared.interfaces.IModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; +import dev._2lstudios.exploitfixer.interfaces.IMessagesModule; +import dev._2lstudios.exploitfixer.interfaces.IModule; public class MessagesModule implements IMessagesModule { private static final String NOTFOUND_STRING = ""; diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java similarity index 93% rename from src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index b8ad133..93bb4fe 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.shared.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.Collection; import java.util.HashMap; @@ -8,8 +8,8 @@ import java.util.Map.Entry; import java.util.logging.Logger; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.INotificationsModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.INotificationsModule; public class NotificationsModule implements INotificationsModule { private final Logger logger; diff --git a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java similarity index 91% rename from src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index cd806fb..7852c3f 100644 --- a/src/dev/_2lstudios/exploitfixer/shared/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -1,11 +1,11 @@ -package dev._2lstudios.exploitfixer.shared.modules; +package dev._2lstudios.exploitfixer.modules; import java.util.HashMap; import java.util.Map; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.exploit.Violations; -import dev._2lstudios.exploitfixer.shared.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.exploit.Violations; +import dev._2lstudios.exploitfixer.interfaces.IViolationModule; public class PacketsModule implements IViolationModule { private final Map multipliers = new HashMap<>(); diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java b/src/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java similarity index 81% rename from src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java rename to src/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java index 5f55da5..fd72453 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/tasks/ExploitFixerRepeatingTask.java +++ b/src/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java @@ -1,6 +1,6 @@ -package dev._2lstudios.exploitfixer.bukkit.tasks; +package dev._2lstudios.exploitfixer.tasks; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class ExploitFixerRepeatingTask implements Runnable { private final NotificationsModule notificationsModule; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java similarity index 91% rename from src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java rename to src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java index 0033304..4ceb9b7 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/BukkitConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java @@ -1,12 +1,12 @@ -package dev._2lstudios.exploitfixer.bukkit.utils; +package dev._2lstudios.exploitfixer.utils; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; -import dev._2lstudios.exploitfixer.bukkit.configuration.BukkitConfiguration; -import dev._2lstudios.exploitfixer.shared.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.shared.interfaces.IConfigurationUtil; +import dev._2lstudios.exploitfixer.configuration.BukkitConfiguration; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; import java.io.File; import java.io.IOException; diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java similarity index 91% rename from src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java rename to src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 5a2e340..5829d13 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.utils; +package dev._2lstudios.exploitfixer.utils; import java.nio.charset.StandardCharsets; import java.util.Collection; @@ -14,12 +14,12 @@ import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; -import dev._2lstudios.exploitfixer.bukkit.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.bukkit.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.bukkit.managers.ModuleManager; -import dev._2lstudios.exploitfixer.bukkit.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.shared.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.shared.modules.PacketsModule; +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.modules.PacketsModule; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; public class ExploitUtil { diff --git a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java b/src/dev/_2lstudios/exploitfixer/utils/VersionUtil.java similarity index 93% rename from src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java rename to src/dev/_2lstudios/exploitfixer/utils/VersionUtil.java index 52a1531..13a2a47 100644 --- a/src/dev/_2lstudios/exploitfixer/bukkit/utils/VersionUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/VersionUtil.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.bukkit.utils; +package dev._2lstudios.exploitfixer.utils; import org.bukkit.entity.Player; import org.bukkit.entity.Player.Spigot; From 3ffc2535352d097d1d7bad64de75e108e3c186d8 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:16:59 -0300 Subject: [PATCH 171/336] organize exploitfixer command --- .../commands/ExploitFixerCommand.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 9b849e7..cd905a6 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -26,54 +26,53 @@ public ExploitFixerCommand(final ExploitFixer exploitFixer, final ModuleManager } @Override - public boolean onCommand(final CommandSender commandSender, final Command command, final String label, + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { final int length = args.length; final String lang; - if (commandSender instanceof Player) { - lang = VersionUtil.getLocale((Player) commandSender); + if (sender instanceof Player) { + lang = VersionUtil.getLocale((Player) sender); } else { lang = "en"; } - if (length < 1 || args[0].equals("help")) { - commandSender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); - } else if (args[0].equals("reload")) - if (commandSender.hasPermission("exploitfixer.admin")) { + if (length < 1 || args[0].equalsIgnoreCase("help")) { + sender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); + } else if (args[0].equalsIgnoreCase("reload")) + if (sender.hasPermission("exploitfixer.admin")) { exploitFixer.reload(); - commandSender.sendMessage(messagesModule.getReload(lang)); + sender.sendMessage(messagesModule.getReload(lang)); } else { - commandSender.sendMessage(messagesModule.getPermission(lang)); + sender.sendMessage(messagesModule.getPermission(lang)); } - else if (args[0].equals("stats")) - if (commandSender.hasPermission("exploitfixer.admin")) - commandSender.sendMessage(messagesModule.getStats(lang) + else if (args[0].equalsIgnoreCase("stats")) + if (sender.hasPermission("exploitfixer.admin")) + sender.sendMessage(messagesModule.getStats(lang) .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize()))); else - commandSender.sendMessage(messagesModule.getPermission(lang)); + sender.sendMessage(messagesModule.getPermission(lang)); else if (args[0].equalsIgnoreCase("notifications")) { - if (commandSender instanceof Player) { - if (commandSender.hasPermission("exploitfixer.admin") - || commandSender.hasPermission("exploitfixer.notifications")) { - final String playerName = commandSender.getName(); + if (sender instanceof Player) { + if (sender.hasPermission("exploitfixer.admin") || sender.hasPermission("exploitfixer.notifications")) { + final String playerName = sender.getName(); if (!notificationsModule.isNotifications(playerName)) { notificationsModule.setNotifications(playerName, true); - commandSender.sendMessage(messagesModule.getEnable(lang)); + sender.sendMessage(messagesModule.getEnable(lang)); } else { notificationsModule.setNotifications(playerName, false); - commandSender.sendMessage(messagesModule.getDisable(lang)); + sender.sendMessage(messagesModule.getDisable(lang)); } } else { - commandSender.sendMessage(messagesModule.getPermission(lang)); + sender.sendMessage(messagesModule.getPermission(lang)); } } else { - commandSender.sendMessage(messagesModule.getConsole(lang)); + sender.sendMessage(messagesModule.getConsole(lang)); } } else { - commandSender.sendMessage(messagesModule.getUnknown(lang)); + sender.sendMessage(messagesModule.getUnknown(lang)); } return true; From caa2c359576492ebd087af03b34c0ce31549982c Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:18:23 -0300 Subject: [PATCH 172/336] separate notifications command on a file --- .../commands/ExploitFixerCommand.java | 18 +------- .../commands/NotificationsCommand.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index cd905a6..1a3363a 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -54,23 +54,9 @@ else if (args[0].equalsIgnoreCase("stats")) else sender.sendMessage(messagesModule.getPermission(lang)); else if (args[0].equalsIgnoreCase("notifications")) { - if (sender instanceof Player) { - if (sender.hasPermission("exploitfixer.admin") || sender.hasPermission("exploitfixer.notifications")) { - final String playerName = sender.getName(); + final NotificationsCommand notificationsCommand = new NotificationsCommand(notificationsModule, messagesModule, lang); - if (!notificationsModule.isNotifications(playerName)) { - notificationsModule.setNotifications(playerName, true); - sender.sendMessage(messagesModule.getEnable(lang)); - } else { - notificationsModule.setNotifications(playerName, false); - sender.sendMessage(messagesModule.getDisable(lang)); - } - } else { - sender.sendMessage(messagesModule.getPermission(lang)); - } - } else { - sender.sendMessage(messagesModule.getConsole(lang)); - } + return notificationsCommand.onCommand(sender, command, label, args); } else { sender.sendMessage(messagesModule.getUnknown(lang)); } diff --git a/src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java b/src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java new file mode 100644 index 0000000..8d17d6f --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java @@ -0,0 +1,45 @@ +package dev._2lstudios.exploitfixer.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import dev._2lstudios.exploitfixer.modules.MessagesModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; + +public class NotificationsCommand implements CommandExecutor { + private final NotificationsModule notificationsModule; + private final MessagesModule messagesModule; + private final String lang; + + public NotificationsCommand(final NotificationsModule notificationsModule, final MessagesModule messagesModule, final String lang) { + this.notificationsModule = notificationsModule; + this.messagesModule = messagesModule; + this.lang = lang; + } + + @Override + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { + if (sender instanceof Player) { + if (sender.hasPermission("exploitfixer.admin") + || sender.hasPermission("exploitfixer.notifications")) { + final String playerName = sender.getName(); + + if (!notificationsModule.isNotifications(playerName)) { + notificationsModule.setNotifications(playerName, true); + sender.sendMessage(messagesModule.getEnable(lang)); + } else { + notificationsModule.setNotifications(playerName, false); + sender.sendMessage(messagesModule.getDisable(lang)); + } + } else { + sender.sendMessage(messagesModule.getPermission(lang)); + } + } else { + sender.sendMessage(messagesModule.getConsole(lang)); + } + + return true; + } +} From 5c03aec47262ace0f36474285699a9102662ea8d Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:20:55 -0300 Subject: [PATCH 173/336] separate stats command on a file --- .../commands/ExploitFixerCommand.java | 20 +++++------ .../exploitfixer/commands/StatsCommand.java | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 1a3363a..9917ce0 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -39,24 +39,22 @@ public boolean onCommand(final CommandSender sender, final Command command, fina if (length < 1 || args[0].equalsIgnoreCase("help")) { sender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); - } else if (args[0].equalsIgnoreCase("reload")) + } else if (args[0].equalsIgnoreCase("reload")) { if (sender.hasPermission("exploitfixer.admin")) { exploitFixer.reload(); sender.sendMessage(messagesModule.getReload(lang)); } else { sender.sendMessage(messagesModule.getPermission(lang)); } - else if (args[0].equalsIgnoreCase("stats")) - if (sender.hasPermission("exploitfixer.admin")) - sender.sendMessage(messagesModule.getStats(lang) - .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) - .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize()))); - else - sender.sendMessage(messagesModule.getPermission(lang)); - else if (args[0].equalsIgnoreCase("notifications")) { - final NotificationsCommand notificationsCommand = new NotificationsCommand(notificationsModule, messagesModule, lang); + } else if (args[0].equalsIgnoreCase("stats")) { + final StatsCommand statsCommand = new StatsCommand(exploitPlayerManager, messagesModule, lang); + + statsCommand.onCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("notifications")) { + final NotificationsCommand notificationsCommand = new NotificationsCommand(notificationsModule, + messagesModule, lang); - return notificationsCommand.onCommand(sender, command, label, args); + notificationsCommand.onCommand(sender, command, label, args); } else { sender.sendMessage(messagesModule.getUnknown(lang)); } diff --git a/src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java b/src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java new file mode 100644 index 0000000..35826f3 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java @@ -0,0 +1,33 @@ +package dev._2lstudios.exploitfixer.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.modules.MessagesModule; + +public class StatsCommand implements CommandExecutor { + private final ExploitPlayerManager exploitPlayerManager; + private final MessagesModule messagesModule; + private final String lang; + + public StatsCommand(final ExploitPlayerManager exploitPlayerManager, final MessagesModule messagesModule, final String lang) { + this.exploitPlayerManager = exploitPlayerManager; + this.messagesModule = messagesModule; + this.lang = lang; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender.hasPermission("exploitfixer.admin")) { + sender.sendMessage(messagesModule.getStats(lang) + .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) + .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize()))); + } else { + sender.sendMessage(messagesModule.getPermission(lang)); + } + + return true; + } +} From c91620ba97335f2d497509f9c0c309dda64ff74f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:24:09 -0300 Subject: [PATCH 174/336] separate reload command in a file --- .../commands/ExploitFixerCommand.java | 9 ++---- .../exploitfixer/commands/ReloadCommand.java | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 9917ce0..755c117 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -40,12 +40,9 @@ public boolean onCommand(final CommandSender sender, final Command command, fina if (length < 1 || args[0].equalsIgnoreCase("help")) { sender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); } else if (args[0].equalsIgnoreCase("reload")) { - if (sender.hasPermission("exploitfixer.admin")) { - exploitFixer.reload(); - sender.sendMessage(messagesModule.getReload(lang)); - } else { - sender.sendMessage(messagesModule.getPermission(lang)); - } + final ReloadCommand reloadCommand = new ReloadCommand(exploitFixer, messagesModule, lang); + + reloadCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("stats")) { final StatsCommand statsCommand = new StatsCommand(exploitPlayerManager, messagesModule, lang); diff --git a/src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java new file mode 100644 index 0000000..19dba59 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java @@ -0,0 +1,32 @@ +package dev._2lstudios.exploitfixer.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import dev._2lstudios.exploitfixer.ExploitFixer; +import dev._2lstudios.exploitfixer.modules.MessagesModule; + +public class ReloadCommand implements CommandExecutor { + private final ExploitFixer exploitFixer; + private final MessagesModule messagesModule; + private final String lang; + + public ReloadCommand(ExploitFixer exploitFixer, MessagesModule messagesModule, String lang) { + this.exploitFixer = exploitFixer; + this.messagesModule = messagesModule; + this.lang = lang; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender.hasPermission("exploitfixer.admin")) { + exploitFixer.reload(); + sender.sendMessage(messagesModule.getReload(lang)); + } else { + sender.sendMessage(messagesModule.getPermission(lang)); + } + + return true; + } +} From 374c8453f66f1b9882ca0de95b157385ccd2f26e Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:25:32 -0300 Subject: [PATCH 175/336] separate help command in a file --- .../commands/ExploitFixerCommand.java | 4 +++- .../exploitfixer/commands/HelpCommand.java | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 755c117..bc46b73 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -38,7 +38,9 @@ public boolean onCommand(final CommandSender sender, final Command command, fina } if (length < 1 || args[0].equalsIgnoreCase("help")) { - sender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); + final HelpCommand helpCommand = new HelpCommand(messagesModule, lang); + + helpCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("reload")) { final ReloadCommand reloadCommand = new ReloadCommand(exploitFixer, messagesModule, lang); diff --git a/src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java b/src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java new file mode 100644 index 0000000..7f37498 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java @@ -0,0 +1,24 @@ +package dev._2lstudios.exploitfixer.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import dev._2lstudios.exploitfixer.modules.MessagesModule; + +public class HelpCommand implements CommandExecutor { + private final MessagesModule messagesModule; + private final String lang; + + public HelpCommand(MessagesModule messagesModule, String lang) { + this.messagesModule = messagesModule; + this.lang = lang; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + sender.sendMessage(messagesModule.getHelp(lang).replace("%command%", label)); + + return true; + } +} From 411df04fe4cf31fb7cfb83e274509496fab038c8 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:26:25 -0300 Subject: [PATCH 176/336] reorder stuff --- .../_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java | 4 ++-- src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java | 2 +- src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java | 2 +- src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java | 1 - src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java | 1 - src/dev/_2lstudios/exploitfixer/modules/EventsModule.java | 1 - .../exploitfixer/{interfaces => modules}/IMessagesModule.java | 2 +- .../exploitfixer/{interfaces => modules}/IModule.java | 2 +- .../{interfaces => modules}/INotificationsModule.java | 2 +- .../{interfaces => modules}/IPunishmentModule.java | 2 +- .../{interfaces => modules}/IViolationModule.java | 2 +- src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java | 1 - src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java | 4 +--- .../_2lstudios/exploitfixer/modules/NotificationsModule.java | 1 - src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java | 1 - .../exploitfixer/utils/BukkitConfigurationUtil.java | 1 - .../{interfaces => utils}/IConfigurationUtil.java | 2 +- 17 files changed, 11 insertions(+), 20 deletions(-) rename src/dev/_2lstudios/exploitfixer/{interfaces => modules}/IMessagesModule.java (67%) rename src/dev/_2lstudios/exploitfixer/{interfaces => modules}/IModule.java (65%) rename src/dev/_2lstudios/exploitfixer/{interfaces => modules}/INotificationsModule.java (76%) rename src/dev/_2lstudios/exploitfixer/{interfaces => modules}/IPunishmentModule.java (73%) rename src/dev/_2lstudios/exploitfixer/{interfaces => modules}/IViolationModule.java (76%) rename src/dev/_2lstudios/exploitfixer/{interfaces => utils}/IConfigurationUtil.java (87%) diff --git a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 34e650d..81c40dd 100644 --- a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -16,8 +16,8 @@ import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; import dev._2lstudios.exploitfixer.exploit.Violations; -import dev._2lstudios.exploitfixer.interfaces.IModule; -import dev._2lstudios.exploitfixer.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.modules.IModule; +import dev._2lstudios.exploitfixer.modules.IViolationModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.hamsterapi.enums.PacketType; diff --git a/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index 35f4cb4..63a9b16 100644 --- a/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Map; -import dev._2lstudios.exploitfixer.interfaces.IViolationModule; +import dev._2lstudios.exploitfixer.modules.IViolationModule; public class ExploitPlayer { private final Map violations; diff --git a/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java index df12df8..8b50e79 100644 --- a/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java @@ -10,11 +10,11 @@ import dev._2lstudios.exploitfixer.modules.EventsModule; import dev._2lstudios.exploitfixer.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; import dev._2lstudios.exploitfixer.modules.CommandsModule; import dev._2lstudios.exploitfixer.modules.ConnectionModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; import dev._2lstudios.exploitfixer.modules.PacketsModule; +import dev._2lstudios.exploitfixer.utils.IConfigurationUtil; public class ModuleManager { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index 9fb5fa8..f97bc09 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -3,7 +3,6 @@ import java.util.Collection; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IPunishmentModule; public class CommandsModule implements IPunishmentModule { private Collection commands; diff --git a/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java b/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java index 81ab14d..34a981c 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java @@ -3,7 +3,6 @@ import java.util.Collection; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IPunishmentModule; public class ConnectionModule implements IPunishmentModule { private boolean nullAddressEnabled; diff --git a/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java index 4ebb772..274e869 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -1,7 +1,6 @@ package dev._2lstudios.exploitfixer.modules; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IModule; public class EventsModule implements IModule { private boolean nullChunk; diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java b/src/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java similarity index 67% rename from src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java rename to src/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java index 3ce37ba..ac3127f 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/IMessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.modules; public interface IMessagesModule { String getString(final String locale, final String path); diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/IModule.java b/src/dev/_2lstudios/exploitfixer/modules/IModule.java similarity index 65% rename from src/dev/_2lstudios/exploitfixer/interfaces/IModule.java rename to src/dev/_2lstudios/exploitfixer/modules/IModule.java index f22f4bc..7d2de31 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/IModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/IModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.modules; public interface IModule { public boolean isEnabled(); diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java similarity index 76% rename from src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java rename to src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java index 4aef3a4..c275564 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/INotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.modules; public interface INotificationsModule extends IModule { public void sendNotification(final String check, final Object player, final int violations); diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java b/src/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java similarity index 73% rename from src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java rename to src/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java index 0865c40..c50735b 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/IPunishmentModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.modules; import java.util.Collection; diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java b/src/dev/_2lstudios/exploitfixer/modules/IViolationModule.java similarity index 76% rename from src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java rename to src/dev/_2lstudios/exploitfixer/modules/IViolationModule.java index dba3172..210528a 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/IViolationModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/IViolationModule.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.modules; public interface IViolationModule extends IModule { public double getCancelVls(); diff --git a/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index a2c7dc5..0e7f7c8 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -16,7 +16,6 @@ import org.bukkit.plugin.Plugin; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IModule; public class ItemsFixModule implements IModule { private final Plugin plugin; diff --git a/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index 9d40c3a..54b2a99 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -8,9 +8,7 @@ import java.util.logging.Logger; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; -import dev._2lstudios.exploitfixer.interfaces.IMessagesModule; -import dev._2lstudios.exploitfixer.interfaces.IModule; +import dev._2lstudios.exploitfixer.utils.IConfigurationUtil; public class MessagesModule implements IMessagesModule { private static final String NOTFOUND_STRING = ""; diff --git a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index 93bb4fe..b2b10a7 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -9,7 +9,6 @@ import java.util.logging.Logger; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.INotificationsModule; public class NotificationsModule implements INotificationsModule { private final Logger logger; diff --git a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 7852c3f..b169635 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -5,7 +5,6 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; import dev._2lstudios.exploitfixer.exploit.Violations; -import dev._2lstudios.exploitfixer.interfaces.IViolationModule; public class PacketsModule implements IViolationModule { private final Map multipliers = new HashMap<>(); diff --git a/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java index 4ceb9b7..724fcd7 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java @@ -6,7 +6,6 @@ import dev._2lstudios.exploitfixer.configuration.BukkitConfiguration; import dev._2lstudios.exploitfixer.configuration.IConfiguration; -import dev._2lstudios.exploitfixer.interfaces.IConfigurationUtil; import java.io.File; import java.io.IOException; diff --git a/src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java b/src/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java similarity index 87% rename from src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java rename to src/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java index eeff34e..1e4d570 100644 --- a/src/dev/_2lstudios/exploitfixer/interfaces/IConfigurationUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java @@ -1,4 +1,4 @@ -package dev._2lstudios.exploitfixer.interfaces; +package dev._2lstudios.exploitfixer.utils; import dev._2lstudios.exploitfixer.configuration.IConfiguration; From 898f6bc2bfb65d89193bf630d2018958166d6698 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:26:57 -0300 Subject: [PATCH 177/336] clean imports --- .../exploitfixer/configuration/BukkitConfiguration.java | 2 -- .../_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java | 2 -- .../exploitfixer/modules/BukkitNotificationsModule.java | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java b/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java index e95d9b0..2c5c254 100644 --- a/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java +++ b/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java @@ -5,8 +5,6 @@ import org.bukkit.configuration.ConfigurationSection; -import dev._2lstudios.exploitfixer.configuration.IConfiguration; - public class BukkitConfiguration implements IConfiguration { private final ConfigurationSection configuration; diff --git a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 81c40dd..088e232 100644 --- a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -14,8 +14,6 @@ import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.utils.VersionUtil; -import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; -import dev._2lstudios.exploitfixer.exploit.Violations; import dev._2lstudios.exploitfixer.modules.IModule; import dev._2lstudios.exploitfixer.modules.IViolationModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; diff --git a/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java index 105b17e..5104b9b 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java @@ -6,8 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import dev._2lstudios.exploitfixer.modules.NotificationsModule; - public class BukkitNotificationsModule extends NotificationsModule { private final CommandSender console; private final Server server; From a12051f11c156c9425cace7824cb7f3a125a536f Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:42:05 -0300 Subject: [PATCH 178/336] Update plugin.yml --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index c0cbd1f..5db2ce5 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.0 +version: 1.6.1 author: 2LS api: "1.13" api-version: "1.13" From 15ba6ecc8305cc35196e2ec718841cebc6962953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD=E8=98=AD=E9=9C=B2=20Flandre=5Ftw?= <51469621+gregman98@users.noreply.github.com> Date: Wed, 23 Jun 2021 23:13:41 +0800 Subject: [PATCH 179/336] Chinese Traditional translation Hello, I have completed the Chinese Traditional translation. :) --- resources/locales/zhtw.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/locales/zhtw.yml diff --git a/resources/locales/zhtw.yml b/resources/locales/zhtw.yml new file mode 100644 index 0000000..b04a9b8 --- /dev/null +++ b/resources/locales/zhtw.yml @@ -0,0 +1,27 @@ +# Chinese Traditional - Credits: Flandre_tw +commands: + reload: "&aExploitFixer 已經æˆåŠŸè¼‰å…¥ ï¼" + help: |- + &aExploitFixer 指令 : + &e /%command% help &7> &b顯示說明指令。 + &e /%command% reload &7> &b釿–°è¼‰å…¥æ’件。 + &e /%command% notifications &7> &bé–‹é—œæ’ä»¶æé†’通知。 + &e /%command% stats &7> &b查看æ’件統計資料。 + error: + unknown: "&c未知的指令。請使用 /exploitfixer help 查看指令說明 ï¼" + permission: "&cä½ æ²’æœ‰ä½¿ç”¨è©²æŒ‡ä»¤çš„æ¬Šé™ ï¼" + console: "&c該指令無法在控制å°åŸ·è¡Œ ï¼" + notifications: + enable: "&a你已開啟æé†’通知 ï¼" + disable: "&c你已關閉æé†’通知 ï¼" + stats: "&c&lEF: &e已快å–的玩家 : &a%players_cached% &e已被懲罰的玩家 : &a%players_punished%" +modules: + custompayload: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到éŽå¤šçš„ CustomPayload å°åŒ…。\n&7Discord : &b&n%web%&r" + commands: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到濫用指令。\n&7Discord : &b&n%web%&r" + packets: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到å°åŒ…異常。\n&7Discord : &b&n%web%&r" + nulladdress: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到空的ä½å€ã€‚\n&7Discord : &b&n%web%&r" +mojang_down: "&cMojang 伺æœå™¨é›¢ç·šï¼Œè«‹ç¨å¾Œå†æŸ¥çœ‹ ï¼ \n\n&7原因 : &fExploitFixer 無法檢查 UUID。\n&7Discord : &b&n%web%&r" From 15e9083aac46a79367b96ac394c516691b21bfe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD=E8=98=AD=E9=9C=B2=20Flandre=5Ftw?= <51469621+gregman98@users.noreply.github.com> Date: Wed, 23 Jun 2021 23:26:17 +0800 Subject: [PATCH 180/336] Update zhtw.yml --- resources/locales/zhtw.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/locales/zhtw.yml b/resources/locales/zhtw.yml index b04a9b8..fc0ce74 100644 --- a/resources/locales/zhtw.yml +++ b/resources/locales/zhtw.yml @@ -14,7 +14,7 @@ commands: notifications: enable: "&a你已開啟æé†’通知 ï¼" disable: "&c你已關閉æé†’通知 ï¼" - stats: "&c&lEF: &e已快å–的玩家 : &a%players_cached% &e已被懲罰的玩家 : &a%players_punished%" + stats: "&c&lEF : &e已快å–的玩家 : &a%players_cached% &e已被懲罰的玩家 : &a%players_punished%" modules: custompayload: kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到éŽå¤šçš„ CustomPayload å°åŒ…。\n&7Discord : &b&n%web%&r" From ebb05634fe62ca933ab98fe33f0550f3c586db60 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sat, 26 Jun 2021 02:07:18 -0300 Subject: [PATCH 181/336] update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a6823f9..7c58abb 100644 --- a/pom.xml +++ b/pom.xml @@ -12,14 +12,13 @@ ${basedir}/src/ - . ${basedir}/resources/ maven-compiler-plugin - 3.7.0 + 3.8.1 1.8 1.8 @@ -38,6 +37,7 @@ io.netty netty-all 4.1.62.Final + provided org.spigotmc From ee5937f907ad4c168ef9638cf1c909bb797f585c Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Fri, 2 Jul 2021 13:54:06 -0300 Subject: [PATCH 182/336] Create LICENSE --- LICENSE | 695 ++------------------------------------------------------ 1 file changed, 21 insertions(+), 674 deletions(-) diff --git a/LICENSE b/LICENSE index f288702..ad9b949 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +MIT License + +Copyright (c) 2021 2LStudios - Minecraft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 7ba05ef6855346dfd4f97ebaf07288c260d4eeab Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sat, 10 Jul 2021 15:09:01 -0300 Subject: [PATCH 183/336] add packet blacklist system --- resources/config.yml | 4 ++++ .../listener/PacketReceiveListener.java | 15 ++++++++++++--- .../exploitfixer/modules/PacketsModule.java | 8 ++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 3066db3..4d06810 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -110,6 +110,10 @@ packets: PacketPlayInUseItem: 1 PacketPlayInWindowClick: 0.65 + # This packets will be completely cancelled. + blacklist: + - "PacketPlayInAutoRecipe" + # Placeholders: %player% # Commands to run when a player reachs certain violation level. violations: diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 3d580a5..4b53681 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -54,10 +54,18 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster return; } + final String packetName = packetWrapper.getName(); + final String playerName = player.getName(); + + if (packetsModule.isBlacklisted(packetName)) { + final String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); + return; + } + final Map strings = packetWrapper.getStrings(); final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final String playerName = player.getName(); - final String packetName = packetWrapper.getName(); final double dataVls = packetsModule.getDataVls(); final Map integers = packetWrapper.getIntegers(); final InventoryView inventoryView = player.getOpenInventory(); @@ -71,7 +79,8 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final String rawMessage = strings.values().iterator().next(); if (commandsModule.isCommand(rawMessage)) { - exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), 1); + exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), + 1); event.setCancelled(true); return; diff --git a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index b169635..0ae50e4 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -1,6 +1,8 @@ package dev._2lstudios.exploitfixer.modules; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import dev._2lstudios.exploitfixer.configuration.IConfiguration; @@ -8,6 +10,7 @@ public class PacketsModule implements IViolationModule { private final Map multipliers = new HashMap<>(); + private Collection blacklist = new HashSet<>(); private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, reduceVls; @@ -32,6 +35,7 @@ public void reload(final IConfiguration configYml) { this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); + this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); this.violations = new Violations(configYml.getSection(name + ".violations")); for (final String key : configurationSection.getKeys()) { @@ -111,4 +115,8 @@ public int getDataBytesSign() { public boolean isOffline() { return offline; } + + public boolean isBlacklisted(final String packetName) { + return blacklist.contains(packetName); + } } From 32527dd415526674897bb86550e077a453b5e9ba Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sun, 11 Jul 2021 16:26:31 -0300 Subject: [PATCH 184/336] improve packet blacklist system --- .../listener/PacketReceiveListener.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 4b53681..1892d8b 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -56,14 +56,6 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final String packetName = packetWrapper.getName(); final String playerName = player.getName(); - - if (packetsModule.isBlacklisted(packetName)) { - final String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); - return; - } - final Map strings = packetWrapper.getStrings(); final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); final double dataVls = packetsModule.getDataVls(); @@ -74,6 +66,12 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName)); + if (packetsModule.isBlacklisted(packetName)) { + final String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); + } + if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { if (!strings.isEmpty()) { final String rawMessage = strings.values().iterator().next(); From e30eea92269d524a1b28ec9d16de8d7495111bb8 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Sun, 11 Jul 2021 17:25:35 -0300 Subject: [PATCH 185/336] Update plugin.yml --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 5db2ce5..ad1be82 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.1 +version: 1.6.2 author: 2LS api: "1.13" api-version: "1.13" From 9906f7ef224c6f501ef13c3ae76bd0ed037f0157 Mon Sep 17 00:00:00 2001 From: terrarier2111 <58695553+terrarier2111@users.noreply.github.com> Date: Wed, 14 Jul 2021 14:59:53 +0200 Subject: [PATCH 186/336] A minor cleanup for PacketDecodeListener --- .../listener/PacketDecodeListener.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 7267bb9..10f01d6 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -14,6 +14,9 @@ import io.netty.buffer.ByteBuf; public class PacketDecodeListener implements Listener { + + private static final String PREFIX = "[Decoder|Data] "; + private static final String PREFIX_OFFLINE = "[Decoder|Offline] "; private final ExploitUtil exploitUtil; private final PacketsModule packetsModule; @@ -25,9 +28,8 @@ public class PacketDecodeListener implements Listener { private String getName(final Player player) { if (player == null) { return "unknown"; - } else { - return player.getName(); } + return player.getName(); } private void onPacketDecode(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, @@ -40,12 +42,12 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster final int capacity = byteBuf.capacity(); if (capacity < 0) { - final String reason = "[Decoder|Data] " + playerName + final String reason = PREFIX + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (refCnt < 1) { - final String reason = "[Decoder|Data] " + playerName + " sent a packet with invalid refCnt! refCnt: " + final String reason = PREFIX + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); @@ -54,19 +56,19 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster String reason = null; if (capacity > dataBytes) { - reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds capacity bytes limit! " + capacity + reason = PREFIX + playerName + " sent a packet that exceeds capacity bytes limit! " + capacity + "/" + dataBytes + " Vls: " + dataVls; } else if (readableBytes > dataBytes) { - reason = "[Decoder|Data] " + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; + }else { + return; } - if (reason != null) { - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } } else if (packetsModule.isOffline()) { - final String reason = "[Decoder|Offline] " + getName(player) + " sent a packet while offline!"; + final String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); } From 55fbea08fdc210a0d9f593e6feb9a805a16974cd Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Wed, 14 Jul 2021 16:09:53 -0300 Subject: [PATCH 187/336] Update PacketDecodeListener.java --- .../_2lstudios/exploitfixer/listener/PacketDecodeListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 10f01d6..402fab5 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -61,7 +61,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster } else if (readableBytes > dataBytes) { reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; - }else { + } else { return; } From f8647abe434c506a217ff99be8215783dea25783 Mon Sep 17 00:00:00 2001 From: Luca Azalim Date: Wed, 28 Jul 2021 10:05:33 -0300 Subject: [PATCH 188/336] Improving portuguese translation to match the english one. --- resources/locales/pt.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/locales/pt.yml b/resources/locales/pt.yml index 3390ce4..f71a658 100644 --- a/resources/locales/pt.yml +++ b/resources/locales/pt.yml @@ -17,11 +17,11 @@ commands: stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" modules: custompayload: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" commands: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de comandos detectado.\n&7Discord: &b&n%web%&r" packets: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Packets detectado.\n&7Discord: &b&n%web%&r" + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de packets detectado.\n&7Discord: &b&n%web%&r" nulladdress: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de Rede nula detectado.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang está desligado, volte logo!\n\n&7Motivo: &fExploitFixer não pode confirmar UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de endereço nulo detectado.\n&7Discord: &b&n%web%&r" +mojang_down: "&cOs servidores da Mojang estão indisponíveis. Tente novamente mais tarde.\n\n&7Motivo: &fExploitFixer não pôde confirmar UUID.\n&7Discord: &b&n%web%&r" From b7946b8ac09633c61595f84faab9accd05e2dba7 Mon Sep 17 00:00:00 2001 From: Sammwy Date: Sat, 14 Aug 2021 20:16:28 -0300 Subject: [PATCH 189/336] Changed local reference for HamsterAPI to a remote repository --- pom.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 7c58abb..4ea4b12 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + 2lstudios-repo + https://repo.2lstudios.dev/ + @@ -46,11 +50,9 @@ provided - net + dev._2lstudios HamsterAPI - SNAPSHOT - system - C:\Users\LinsaFTW\Documents\Jars\HamsterAPI.jar + 0.1.8 From 3815c4f005d0be7f6c85ef443c0dcd19d73e3e2e Mon Sep 17 00:00:00 2001 From: LewUwU <72635645+LewUwU@users.noreply.github.com> Date: Sat, 21 Aug 2021 08:17:22 -0400 Subject: [PATCH 190/336] Bump netty to latest version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4ea4b12..197080e 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ io.netty netty-all - 4.1.62.Final + 4.1.67.Final provided From c20b8ddb16d294b16df25749e9e9c0a200847e3e Mon Sep 17 00:00:00 2001 From: xIsm4 <76608233+xIsm4@users.noreply.github.com> Date: Fri, 12 Nov 2021 00:38:52 +0100 Subject: [PATCH 191/336] Fix dependencies issue, bump versions --- .idea/compiler.xml | 13 +++++++++++++ .idea/discord.xml | 7 +++++++ .idea/jarRepositories.xml | 35 +++++++++++++++++++++++++++++++++++ .idea/misc.xml | 17 +++++++++++++++++ ExploitFixer.iml | 12 ++++++++++++ pom.xml | 10 +++++----- 6 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/discord.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 ExploitFixer.iml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..c9bd9e2 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..d8e9561 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..320ced2 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a8259e2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExploitFixer.iml b/ExploitFixer.iml new file mode 100644 index 0000000..fa63d4b --- /dev/null +++ b/ExploitFixer.iml @@ -0,0 +1,12 @@ + + + + + + + SPIGOT + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 197080e..c0ccf76 100644 --- a/pom.xml +++ b/pom.xml @@ -32,27 +32,27 @@ https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - 2lstudios-repo - https://repo.2lstudios.dev/ + 2lstudios + https://ci.2lstudios.dev/plugin/repository/everything/ io.netty netty-all - 4.1.67.Final + 4.1.69.Final provided org.spigotmc spigot-api - 1.16.5-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided dev._2lstudios HamsterAPI - 0.1.8 + 0.2.2 From d4daec37719d0910a440a8fb5c2b06f24cbfb4af Mon Sep 17 00:00:00 2001 From: xIsm4 <76608233+xIsm4@users.noreply.github.com> Date: Fri, 12 Nov 2021 00:41:34 +0100 Subject: [PATCH 192/336] Remove IDE addons --- .idea/compiler.xml | 13 ------------- .idea/discord.xml | 7 ------- .idea/jarRepositories.xml | 35 ----------------------------------- .idea/misc.xml | 17 ----------------- ExploitFixer.iml | 12 ------------ 5 files changed, 84 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/discord.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/misc.xml delete mode 100644 ExploitFixer.iml diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index c9bd9e2..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index d8e9561..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 320ced2..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a8259e2..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ExploitFixer.iml b/ExploitFixer.iml deleted file mode 100644 index fa63d4b..0000000 --- a/ExploitFixer.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - SPIGOT - - - - - \ No newline at end of file From baf637959d91875119cc1eae6c04996ce3f47ae9 Mon Sep 17 00:00:00 2001 From: Blocky38 <86119630+Blocky38@users.noreply.github.com> Date: Thu, 6 Jan 2022 22:02:13 +0100 Subject: [PATCH 193/336] ExploitFixer cannot spell its name & Grammar change --- .../exploitfixer/listener/PacketReceiveListener.java | 4 ++-- .../_2lstudios/exploitfixer/modules/NotificationsModule.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 1892d8b..b02877c 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -183,10 +183,10 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); notificationsModule.debug( - playerName + " had a creative item blacklisted by ExploiFixer! (" + blacklisted + ")"); + playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); } else { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); - notificationsModule.debug(playerName + " had a creative item fixed by ExploiFixer!"); + notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); } } } diff --git a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index b2b10a7..13c64dc 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -98,6 +98,6 @@ public String getName() { @Override public void sendNotification(String check, Object player, int violations) { - // Overrided by parent Bukkit NotificationsModule + // Overwritten by parent Bukkit NotificationsModule } } \ No newline at end of file From fa36c996ca017ba13ef75dce8e46d06ca1b9dc31 Mon Sep 17 00:00:00 2001 From: Blocky38 <86119630+Blocky38@users.noreply.github.com> Date: Thu, 6 Jan 2022 22:10:45 +0100 Subject: [PATCH 194/336] Remove redundant casts --- .../exploitfixer/exploit/BukkitExploitPlayer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 088e232..ab66a04 100644 --- a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -107,12 +107,12 @@ public void punish(final IModule module, final HamsterPlayer hamsterPlayer, fina final PacketType packetType = packet.getType(); if (packetType != null) { - notificationsModule.sendNotification(packetType.toString(), player, (int) newVls); + notificationsModule.sendNotification(packetType.toString(), player, newVls); } else { - notificationsModule.sendNotification(moduleName, player, (int) newVls); + notificationsModule.sendNotification(moduleName, player, newVls); } } else { - notificationsModule.sendNotification(moduleName, player, (int) newVls); + notificationsModule.sendNotification(moduleName, player, newVls); } } else { if (server.isPrimaryThread()) { From dfea11e6d10e5b75d732028e059694d9d677dc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Mart=C3=ADnez?= <76608233+xIsm4@users.noreply.github.com> Date: Wed, 23 Feb 2022 16:30:35 +0100 Subject: [PATCH 195/336] Bump dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c0ccf76..f7fbad6 100644 --- a/pom.xml +++ b/pom.xml @@ -40,13 +40,13 @@ io.netty netty-all - 4.1.69.Final + 4.1.74.Final provided org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided From 8d741ae3686083c69cdc6f01cff1dcf0285e1071 Mon Sep 17 00:00:00 2001 From: cosmos <39018409+cosmos223@users.noreply.github.com> Date: Sun, 6 Mar 2022 11:09:47 +0900 Subject: [PATCH 196/336] Added Japanese translation --- resources/locales/ja.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/locales/ja.yml diff --git a/resources/locales/ja.yml b/resources/locales/ja.yml new file mode 100644 index 0000000..9057844 --- /dev/null +++ b/resources/locales/ja.yml @@ -0,0 +1,27 @@ +# Japanese - Credits: cosmos223 +commands: + reload: "&aプラグイン ExploitFixer をリロードã—ã¾ã—ãŸã€‚" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW + &e /%command% help &7> &b使用å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’表示ã—ã¾ã™ã€‚ + &e /%command% reload &7> &bプラグインをリロードã—ã¾ã™ã€‚ + &e /%command% notifications &7> &bプラグインã®é€šçŸ¥ã‚’切り替ãˆã¾ã™ã€‚ + &e /%command% stats &7> &bプラグインã®çµ±è¨ˆæƒ…報を表示ã—ã¾ã™ã€‚ + error: + unknown: "&c䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ /exploitfixer help ã¨å…¥åŠ›ã—ã¦ä½¿ç”¨å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’確èªã—ã¦ãã ã•ã„。" + permission: "&c権é™ãŒã‚りã¾ã›ã‚“。" + console: "&cã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰å®Ÿè¡Œã§ãã¾ã›ã‚“。" + notifications: + enable: "&a通知を有効ã«ã—ã¾ã—ãŸã€‚" + disable: "&c通知を無効ã«ã—ã¾ã—ãŸã€‚" + stats: "&c&lEF: &eキャッシュã•れãŸãƒ—レイヤー: &a%players_cached%&e ç½°ã›ã‚‰ã‚ŒãŸãƒ—レイヤー: &a%players_punished%" +modules: + custompayload: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fCustomPayloadパケットãŒå¤šã検出ã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fコマンドã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fパケットã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fNullã‚¢ãƒ‰ãƒ¬ã‚¹ãŒæ¤œå‡ºã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojangã®ã‚µãƒ¼ãƒãƒ¼ãŒå¿œç­”ã—ã¦ã„ã¾ã›ã‚“。時間を置ã„ã¦ã‹ã‚‰å†åº¦æŽ¥ç¶šã—ã¦ãã ã•ã„。\n\n&7ç†ç”±: &fExploitFixer 㯠UUID を確èªã§ãã¾ã›ã‚“ã§ã—ãŸã€‚\n&7Discord: &b&n%web%&r" From 57a037865635da6b2c77e55b8cd0c0a58978d33d Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Tue, 5 Apr 2022 11:13:21 -0300 Subject: [PATCH 197/336] Update pom.xml Co-authored-by: Julian <53055251+NoJokeFNA@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f7fbad6..1d33b54 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ io.netty netty-all - 4.1.74.Final + 4.1.75.Final provided From f990df5489a469d4daa4670e18cb04a8b43943f5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 16:35:47 -0300 Subject: [PATCH 198/336] Vl Multiplier Data Option --- resources/config.yml | 12 ++++++--- .../listener/PacketDecodeListener.java | 4 ++- .../listener/PacketReceiveListener.java | 1 - .../exploitfixer/modules/PacketsModule.java | 7 +++++- .../exploitfixer/utils/ExploitUtil.java | 25 +++++++++++-------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 4d06810..a9e123b 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -50,7 +50,7 @@ packets: vls: 100 # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 16000 + bytes: 64000 # Maximum amount of bytes allowed per book page. (Set to -1 to disable) bytes_book: 300 @@ -58,6 +58,10 @@ packets: # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) bytes_sign: 47 + # This option adds vls per byte received. + # Vls to add per byte received. (Set to -1 to disable) + vl_multiplier: 0.003125 + # Cancels book packets when a book is not in hand # Vls to add when a packet fails the check. (Set to -1 to disable) book: 10 @@ -91,8 +95,8 @@ packets: MC|BSign: 4.5 MC|BEdit: 4.5 MC|BOpen: 4.5 - PacketPlayInAutoRecipe: 6 - PacketPlayInUpdateSign: 6 + PacketPlayInAutoRecipe: 10 + PacketPlayInUpdateSign: 5 PacketPlayInAbilities: 0.25 PacketPlayInArmAnimation: 0.05 PacketPlayInBlockDig: 0.5 @@ -105,7 +109,7 @@ packets: PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.5 PacketPlayInSettings: 0.5 - PacketPlayInTabComplete: 2 + PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 1 PacketPlayInWindowClick: 0.65 diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 402fab5..44e63c2 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -7,8 +7,8 @@ import org.bukkit.event.Listener; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.utils.ExploitUtil; import dev._2lstudios.exploitfixer.modules.PacketsModule; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import io.netty.buffer.ByteBuf; @@ -37,6 +37,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster if (player != null && player.isOnline()) { final String playerName = player.getName(); final double dataVls = packetsModule.getDataVls(); + final double dataVlMultiplier = packetsModule.getDataVlMultiplier(); final int dataBytes = packetsModule.getDataBytes(); final int refCnt = byteBuf.refCnt(); final int capacity = byteBuf.capacity(); @@ -62,6 +63,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; } else { + exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier); return; } diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index b02877c..1499d05 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -80,7 +80,6 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), 1); event.setCancelled(true); - return; } } diff --git a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 0ae50e4..1be7427 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -13,7 +13,7 @@ public class PacketsModule implements IViolationModule { private Collection blacklist = new HashSet<>(); private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, - reduceVls; + reduceVls, vlMultiplier; private int dataBytesBook, dataBytesSign, dataBytes; private boolean enabled, offline; @@ -31,6 +31,7 @@ public void reload(final IConfiguration configYml) { this.dataBytes = configYml.getInt(name + ".data.bytes"); this.dataBytesBook = configYml.getInt(name + ".data.bytes_book"); this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign"); + this.vlMultiplier = configYml.getDouble(name + ".data.vl_multiplier"); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); @@ -112,6 +113,10 @@ public int getDataBytesSign() { return dataBytesSign; } + public double getDataVlMultiplier() { + return vlMultiplier; + } + public boolean isOffline() { return offline; } diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 5829d13..557f917 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -53,11 +53,11 @@ private boolean checkBlockState(final BlockStateMeta meta) { private boolean checkBook(final BookMeta meta) { final String title = meta.getTitle(); - + if (title != null && title.length() > 32) { return false; } - + final String author = meta.getAuthor(); if (author != null && author.length() > 16) { @@ -132,23 +132,28 @@ public String clearIfBlacklisted(final ItemStack itemStack) { final String materialName = itemStack.getType().toString(); if (blacklist != null && blacklist.contains(materialName)) { - itemStack.setType(Material.AIR); - itemStack.setItemMeta(null); - return materialName; + itemStack.setType(Material.AIR); + itemStack.setItemMeta(null); + return materialName; } return null; } - public void cancelExploit(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, - final String reason, final double vls) { - notificationsModule.debug(reason); - event.setCancelled(true); - + public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, + final double vls) { if (vls > 0) { final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); exploitPlayer.addVls(event, hamsterPlayer, packetsModule, vls); } } + + public void cancelExploit(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, + final String reason, final double vls) { + notificationsModule.debug(reason); + event.setCancelled(true); + + addVls(event, hamsterPlayer, player, vls); + } } From 5a5047bb9ea5ad5e8aaa23cd9505a4e4cbf0eb09 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 17:46:11 -0300 Subject: [PATCH 199/336] 1.18 Compatibility Support --- resources/config.yml | 2 +- .../exploitfixer/listener/PacketDecodeListener.java | 7 +++++-- .../exploitfixer/listener/PacketReceiveListener.java | 2 +- src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index a9e123b..a941c0c 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -60,7 +60,7 @@ packets: # This option adds vls per byte received. # Vls to add per byte received. (Set to -1 to disable) - vl_multiplier: 0.003125 + vl_multiplier: 0.0001 # Cancels book packets when a book is not in hand # Vls to add when a packet fails the check. (Set to -1 to disable) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 44e63c2..bdbb37a 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -14,7 +14,7 @@ import io.netty.buffer.ByteBuf; public class PacketDecodeListener implements Listener { - + private static final String PREFIX = "[Decoder|Data] "; private static final String PREFIX_OFFLINE = "[Decoder|Offline] "; private final ExploitUtil exploitUtil; @@ -63,7 +63,10 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; } else { - exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier); + if (dataVlMultiplier > 0) { + exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier); + } + return; } diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 1499d05..673f90f 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -49,7 +49,7 @@ public class PacketReceiveListener implements Listener { public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, final PacketWrapper packetWrapper) { final PacketType packetType = packetWrapper.getType(); - + if (packetType == PacketType.PacketPlayInKeepAlive) { return; } diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 557f917..c05df82 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -88,13 +88,13 @@ public boolean checkItem(final ItemStack item) { if (itemMeta != null) { final String displayName = itemMeta.getDisplayName(); - if (displayName != null && displayName.length() > 128) { + if (displayName != null && displayName.length() > 256) { return false; } final List lore = itemMeta.getLore(); - if (lore != null && lore.size() > 32) { + if (lore != null && lore.size() > 64) { return false; } From c4ce731b95d0a39d843dab0347a2e74d118c9717 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 17:47:51 -0300 Subject: [PATCH 200/336] 1.6.3 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index ad1be82..5c9e5b7 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.2 +version: 1.6.3 author: 2LS api: "1.13" api-version: "1.13" From ed421926c004121a3905286e83e21177799f9a20 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 18:26:14 -0300 Subject: [PATCH 201/336] Lectern Exploit Fix --- .../listener/PacketReceiveListener.java | 53 +++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 673f90f..5df5293 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -49,7 +49,7 @@ public class PacketReceiveListener implements Listener { public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, final PacketWrapper packetWrapper) { final PacketType packetType = packetWrapper.getType(); - + if (packetType == PacketType.PacketPlayInKeepAlive) { return; } @@ -118,29 +118,52 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - if (windowClick > 0 && integers.containsKey("slot")) { + if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { final Inventory topInventory = inventoryView.getTopInventory(); - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final int slot = integers.get("slot"), maxSlots; - if (bottomInventory.getType() == InventoryType.PLAYER && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); + if (packetType == PacketType.PacketPlayInWindowClick) { + for (Entry entry : integers.entrySet()) { + System.out.println(entry.getKey() + " - " + entry.getValue()); + } } - if (slot < 0 && slot != -999 && slot != -1) { + if (topInventory.getType().name().equals("LECTERN") && integers.containsKey("b") + && integers.get("b") == 1) { final String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; + + " tried to quick move on a lectern! Added vls: " + + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); return; - } else if (slot >= maxSlots) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; + } else { + final Inventory bottomInventory = inventoryView.getBottomInventory(); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; + if (integers.containsKey("slot")) { + final int slot = integers.get("slot"), maxSlots; + + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } + + if (slot < 0 && slot != -999 && slot != -1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } else if (slot >= maxSlots) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } + } } } From deea62fefc5a3d783826a5e11d1acb98b1d95961 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 18:26:27 -0300 Subject: [PATCH 202/336] Disable Map Tracking --- resources/config.yml | 3 + .../listener/ListenerInitializer.java | 1 + .../listener/PlayerInteractListener.java | 55 +++++++++++++++++++ .../exploitfixer/modules/EventsModule.java | 6 ++ 4 files changed, 65 insertions(+) create mode 100644 src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java diff --git a/resources/config.yml b/resources/config.yml index a941c0c..29ddff0 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -31,6 +31,9 @@ events: # Prevents players from damaging themselves and consuming ram. self_damage: true + # Prevents maps from tracking fixing many crash exploits + disable_tracking: true + # Prevents the use of invalid packets to crash the server. packets: enabled: true diff --git a/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 11401b5..ea92ca6 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -29,6 +29,7 @@ public void register() { pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerInteractListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java new file mode 100644 index 0000000..dcdb444 --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java @@ -0,0 +1,55 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.MapMeta; + +import dev._2lstudios.exploitfixer.managers.ModuleManager; + +public class PlayerInteractListener implements Listener { + private ModuleManager moduleManager; + + public PlayerInteractListener(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEntityEvent event) { + if (moduleManager.getEventsModule().isDisableTracking()) { + Entity rightClicked = event.getRightClicked(); + + if (rightClicked instanceof ItemFrame) { + ItemFrame frame = (ItemFrame) rightClicked; + + if (frame.isEmpty()) { + PlayerInventory inventory = event.getPlayer().getInventory(); + EquipmentSlot equipmentSlot = event.getHand(); + ItemStack itemInHand = inventory.getItem(inventory.getHeldItemSlot()); + + if (itemInHand != null && itemInHand.hasItemMeta()) { + ItemMeta itemMeta = itemInHand.getItemMeta(); + + if (itemMeta instanceof MapMeta) { + MapMeta mapMeta = (MapMeta) itemMeta; + + if (equipmentSlot == EquipmentSlot.HAND) { + mapMeta.getMapView().setTrackingPosition(false); + } + + if (equipmentSlot == EquipmentSlot.OFF_HAND) { + mapMeta.getMapView().setTrackingPosition(false); + } + } + } + } + } + } + } +} diff --git a/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java index 274e869..c017e09 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -5,12 +5,14 @@ public class EventsModule implements IModule { private boolean nullChunk; private boolean selfDamage; + private boolean disableTracking; public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); nullChunk = configYml.getBoolean(name + ".null_chunk", true); selfDamage = configYml.getBoolean(name + ".self_damage", true); + disableTracking = configYml.getBoolean(name + ".disable_tracking", true); } @Override @@ -30,4 +32,8 @@ public boolean isSelfDamage() { public boolean isNullChunk() { return nullChunk; } + + public boolean isDisableTracking() { + return disableTracking; + } } From 3ad3ac6e6381fbb43ab74885f82de18956a938fd Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 14 Apr 2022 18:27:54 -0300 Subject: [PATCH 203/336] Remove Logger --- .../exploitfixer/listener/PacketReceiveListener.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 5df5293..3129fd6 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -121,12 +121,6 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { final Inventory topInventory = inventoryView.getTopInventory(); - if (packetType == PacketType.PacketPlayInWindowClick) { - for (Entry entry : integers.entrySet()) { - System.out.println(entry.getKey() + " - " + entry.getValue()); - } - } - if (topInventory.getType().name().equals("LECTERN") && integers.containsKey("b") && integers.get("b") == 1) { final String reason = "[" + packetName + "|WindowClick] " + playerName From 3a85055843e0feb15e6741ca4d75b81c1b6d943f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sun, 24 Apr 2022 18:48:15 -0300 Subject: [PATCH 204/336] Fix Creative False Positives --- resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/config.yml b/resources/config.yml index 29ddff0..53f67f6 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -110,7 +110,7 @@ packets: PacketPlayInLook: 0.5 PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 - PacketPlayInSetCreativeSlot: 0.5 + PacketPlayInSetCreativeSlot: 0.15 PacketPlayInSettings: 0.5 PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 From 5fb669456c9937532ae9926b53ac26b803696d00 Mon Sep 17 00:00:00 2001 From: LewUwU Date: Thu, 28 Apr 2022 14:08:11 -0400 Subject: [PATCH 205/336] Prevent CommandBlock Payload exploits This ensures that players cannot send a command block payload without being op (Follows vanilla logic) --- .../exploitfixer/listener/PacketReceiveListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 3129fd6..47e766f 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -108,6 +108,12 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); return; } + } else if (tag.equals("MC|AdvCdm") && !player.isOp()) { + final String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag + + " CustomPayload packet without being op!"; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + return; } exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); @@ -233,4 +239,4 @@ public void onPacketReceive(final PacketReceiveEvent event) { onPacketReceive(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getPacket()); } -} \ No newline at end of file +} From 4c7643dc8b2ff546b5d3e7cc9ad67ab0c2db705e Mon Sep 17 00:00:00 2001 From: LewUwU Date: Sat, 30 Apr 2022 16:22:31 -0400 Subject: [PATCH 206/336] Fix some issues --- .../exploitfixer/listener/PacketReceiveListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 47e766f..46ad6df 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -91,13 +91,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final double tagVls = packetsModule.getTagVls(); final double bookVls = packetsModule.getBookVls(); - if (tagVls > 0 && tag == null || tag.isEmpty()) { + if (tagVls > 0 && (tag == null || tag.isEmpty())) { final String reason = "[" + packetName + "|Tag] " + playerName + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); return; - } else if (bookVls > 0 && tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen")) { + } else if (bookVls > 0 && (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen"))) { final PlayerInventory playerInventory = player.getInventory(); final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); From 8778b0e61f2582dd825d521353d7c40f9e6dec74 Mon Sep 17 00:00:00 2001 From: Ismael Hanbel <76608233+xIsm4@users.noreply.github.com> Date: Tue, 10 May 2022 15:05:37 +0200 Subject: [PATCH 207/336] Bump dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1d33b54..5a040cd 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ io.netty netty-all - 4.1.75.Final + 4.1.76.Final provided @@ -52,7 +52,7 @@ dev._2lstudios HamsterAPI - 0.2.2 + 0.2.3 From b3765ad5424633e2d6edf7267e2c4e76d73ea697 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Fri, 13 May 2022 00:45:32 -0300 Subject: [PATCH 208/336] Improved Map Tracking Disabler --- .../listener/PlayerInteractListener.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java index dcdb444..6bd7a4a 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java @@ -5,11 +5,11 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.MapMeta; +import org.bukkit.map.MapView; import dev._2lstudios.exploitfixer.managers.ModuleManager; @@ -30,7 +30,6 @@ public void onPlayerInteract(PlayerInteractEntityEvent event) { if (frame.isEmpty()) { PlayerInventory inventory = event.getPlayer().getInventory(); - EquipmentSlot equipmentSlot = event.getHand(); ItemStack itemInHand = inventory.getItem(inventory.getHeldItemSlot()); if (itemInHand != null && itemInHand.hasItemMeta()) { @@ -38,13 +37,11 @@ public void onPlayerInteract(PlayerInteractEntityEvent event) { if (itemMeta instanceof MapMeta) { MapMeta mapMeta = (MapMeta) itemMeta; + MapView mapView = mapMeta.getMapView(); - if (equipmentSlot == EquipmentSlot.HAND) { - mapMeta.getMapView().setTrackingPosition(false); - } - - if (equipmentSlot == EquipmentSlot.OFF_HAND) { - mapMeta.getMapView().setTrackingPosition(false); + if (mapView.isTrackingPosition()) { + mapView.setTrackingPosition(false); + itemInHand.setItemMeta(mapMeta); } } } From b6c40806d23a0b76fe678da709d3de8ed31edc06 Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Sun, 15 May 2022 18:46:07 -0300 Subject: [PATCH 209/336] 1.6.4 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 5c9e5b7..bb6d08c 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.3 +version: 1.6.4 author: 2LS api: "1.13" api-version: "1.13" From c86250db885220dbc14d9a9ae206aff30c5c89b4 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Tue, 17 May 2022 06:10:05 +0200 Subject: [PATCH 210/336] fix: fixed #108 --- .../listener/PacketReceiveListener.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 46ad6df..3ae58f5 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -4,6 +4,7 @@ import java.util.Map.Entry; import dev._2lstudios.exploitfixer.modules.CommandsModule; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -36,6 +37,7 @@ public class PacketReceiveListener implements Listener { private final BukkitNotificationsModule notificationsModule; private final PacketsModule packetsModule; private final CommandsModule commandsModule; + private final String version; PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; @@ -44,6 +46,7 @@ public class PacketReceiveListener implements Listener { this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); this.commandsModule = moduleManager.getCommandsModule(); + this.version = Bukkit.getServer().getClass().getPackage().getName().split( "\\." )[3]; } public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, @@ -127,13 +130,24 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { final Inventory topInventory = inventoryView.getTopInventory(); - if (topInventory.getType().name().equals("LECTERN") && integers.containsKey("b") - && integers.get("b") == 1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " tried to quick move on a lectern! Added vls: " - + windowClick; + if (topInventory.getType().name().equals("LECTERN")) { + if (version.equals("v1_18_R1") || version.equals("v_1_18_R2")) { + if (integers.containsKey("a") && integers.get("a") == 1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + } + } else { + if (integers.containsKey("b") && integers.get("b") == 1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + } + } return; } else { final Inventory bottomInventory = inventoryView.getBottomInventory(); From 457f7769785ff877f8805741594127fd02838fd9 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Tue, 17 May 2022 19:41:24 +0200 Subject: [PATCH 211/336] remove: removed stupid 1.18.2 check.. lol --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 3ae58f5..5401e5f 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -131,7 +131,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final Inventory topInventory = inventoryView.getTopInventory(); if (topInventory.getType().name().equals("LECTERN")) { - if (version.equals("v1_18_R1") || version.equals("v_1_18_R2")) { + if (version.equals("v1_18_R1")) { if (integers.containsKey("a") && integers.get("a") == 1) { final String reason = "[" + packetName + "|WindowClick] " + playerName + " tried to quick move on a lectern! Added vls: " From bc8ae7a8af8520e2f2c8979280fbe8eda6d33c20 Mon Sep 17 00:00:00 2001 From: Stijn Bannink Date: Thu, 19 May 2022 08:02:33 +0200 Subject: [PATCH 212/336] Added Dutch (NL) translation --- resources/locales/nl.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/locales/nl.yml diff --git a/resources/locales/nl.yml b/resources/locales/nl.yml new file mode 100644 index 0000000..ed2cbbe --- /dev/null +++ b/resources/locales/nl.yml @@ -0,0 +1,27 @@ +# Dutch - Credits: LinsaFTW +commands: + reload: "&aPlugin ExploitFixer herladen!" + help: |- + &aExploitFixer &b%version%&a door &bLinsaFTW&a. + &e /%command% help &7> &bLaat de beschikbare commando's zien. + &e /%command% reload &7> &bHerlaad de plugin. + &e /%command% notifications &7> &bToggled notificaties van de plugin. + &e /%command% stats &7> &bLaat de statistieken zien van de plugin. + error: + unknown: "&cOnbekend commando. Gebruik /exploitfixer help om de beschikbare commando's te zien!" + permission: "&cJe hebt niet de benodigde permissie om dit commando te gebruiken!" + console: "&cJe kunt dit commando niet vanaf console uitvoeren!" + notifications: + enable: "&aJe hebt notificaties ingeschakeld!" + disable: "&cJe hebt notificaties uitgeschakeld!" + stats: "&c&lEF: &eSpelers gecached: &a%players_cached%&e Spelers gestraft: &a%players_punished%" +modules: + custompayload: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden &fTe veel CustomPayload packets gedetecteerd.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fCommando exploit gedetecteerd.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fPackets exploit gedetecteerd.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fOnbekend adres gedetecteerd.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang servers zijn offline, kom later terug!\n\n&7Reden: &fExploitFixer kan het UUID niet detecteren.\n&7Discord: &b&n%web%&r" From 027a85b7fb7761305f2f39e7cd040aa8481b09c7 Mon Sep 17 00:00:00 2001 From: Stijn Bannink Date: Thu, 19 May 2022 08:03:37 +0200 Subject: [PATCH 213/336] Updated credits --- resources/locales/nl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/locales/nl.yml b/resources/locales/nl.yml index ed2cbbe..cc2ddc5 100644 --- a/resources/locales/nl.yml +++ b/resources/locales/nl.yml @@ -1,4 +1,4 @@ -# Dutch - Credits: LinsaFTW +# Dutch - Credits: SBDeveloper commands: reload: "&aPlugin ExploitFixer herladen!" help: |- From 253b810cd97ebdb627f48d4b0864d27fad40638c Mon Sep 17 00:00:00 2001 From: Scot_Survivor Date: Sat, 4 Jun 2022 14:08:46 +0100 Subject: [PATCH 214/336] Fix spelling mistakes in config.yml. Scot_Survivor --- resources/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 53f67f6..ad6c44b 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -117,12 +117,12 @@ packets: PacketPlayInUseItem: 1 PacketPlayInWindowClick: 0.65 - # This packets will be completely cancelled. + # These packets will be completely cancelled. blacklist: - "PacketPlayInAutoRecipe" # Placeholders: %player% - # Commands to run when a player reachs certain violation level. + # Commands to run when a player reaches certain violation level. violations: 25: - "notification" @@ -135,7 +135,7 @@ packets: - "kick" # Removes custom NBT tags from creative items to prevent harm to your server. -# Negative enchant values will be always removed. +# Negative enchant values will always be removed. itemsfix: enabled: true @@ -157,7 +157,7 @@ itemsfix: commands: enabled: true - # Commands that are excempt from this server. + # Commands that are exempt from this server. commands: - "//calc" - "//calculate" From 1687f7e18efe5211404db996c7ccdf26d64634b8 Mon Sep 17 00:00:00 2001 From: Scot_Survivor Date: Sat, 4 Jun 2022 14:44:59 +0100 Subject: [PATCH 215/336] Add documentation for the new Placeholders Scot_Survivor --- resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/config.yml b/resources/config.yml index ad6c44b..82d1ca0 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -121,7 +121,7 @@ packets: blacklist: - "PacketPlayInAutoRecipe" - # Placeholders: %player% + # Placeholders: %player%, %vl%, %ping%, %check% # Commands to run when a player reaches certain violation level. violations: 25: From fe453144f6d5881a3c1ddb9f1603c777219413e6 Mon Sep 17 00:00:00 2001 From: Scot_Survivor Date: Sat, 4 Jun 2022 14:45:50 +0100 Subject: [PATCH 216/336] Add code to support new placeholders: ping, check & violations. Scot_Survivor --- .../exploit/BukkitExploitPlayer.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index ab66a04..a14040c 100644 --- a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -115,11 +115,18 @@ public void punish(final IModule module, final HamsterPlayer hamsterPlayer, fina notificationsModule.sendNotification(moduleName, player, newVls); } } else { + String check_name = packet != null ? packet.getType().toString() : module.getName(); + int ping = getPing(player); + String replacement_punishment = punishment + .replace("%player%", playerName) + .replace("%vls%", String.valueOf(newVls)) + .replace("%ping%", String.valueOf(ping)) + .replace("%check%", check_name); if (server.isPrimaryThread()) { - server.dispatchCommand(consoleSender, punishment.replace("%player%", playerName)); + server.dispatchCommand(consoleSender, replacement_punishment); } else { scheduler.runTask(plugin, () -> { - server.dispatchCommand(consoleSender, punishment.replace("%player%", playerName)); + server.dispatchCommand(consoleSender, replacement_punishment); }); } } @@ -129,4 +136,13 @@ public void punish(final IModule module, final HamsterPlayer hamsterPlayer, fina exploitPlayerManager.addPunishment(); } } + private int getPing(final Player player) { + try { + final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + + return (int) playerHandle.getClass().getField("ping").get(playerHandle); + } catch (final Exception ignored) { + return 0; + } + } } From e94e728afdbde4ba5b89cdcda039a1b21a7abba8 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:38:04 +0200 Subject: [PATCH 217/336] fix: don't check for lectern exploit if the server version is 1.18.2 or 1.19 --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 5401e5f..4f105d4 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -130,7 +130,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { final Inventory topInventory = inventoryView.getTopInventory(); - if (topInventory.getType().name().equals("LECTERN")) { + if (topInventory.getType().name().equals("LECTERN") && !version.equals("v1_18_R2") && !version.equals("v1_19_R1")) { if (version.equals("v1_18_R1")) { if (integers.containsKey("a") && integers.get("a") == 1) { final String reason = "[" + packetName + "|WindowClick] " + playerName From ba41eaf7d111bc1b626d7a44c4c5160d1c172cb9 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Fri, 10 Jun 2022 19:56:37 +0200 Subject: [PATCH 218/336] change: changed manual checks by cached value --- .../listener/PacketReceiveListener.java | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 4f105d4..55065bc 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -1,9 +1,17 @@ package dev._2lstudios.exploitfixer.listener; -import java.util.Map; -import java.util.Map.Entry; - +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.modules.CommandsModule; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.modules.PacketsModule; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -18,17 +26,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; -import dev._2lstudios.exploitfixer.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.utils.ExploitUtil; -import dev._2lstudios.exploitfixer.modules.PacketsModule; -import dev._2lstudios.hamsterapi.enums.PacketType; -import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; +import java.util.Map; +import java.util.Map.Entry; public class PacketReceiveListener implements Listener { private final ExploitUtil exploitUtil; @@ -38,6 +37,7 @@ public class PacketReceiveListener implements Listener { private final PacketsModule packetsModule; private final CommandsModule commandsModule; private final String version; + private final boolean checkLectern; PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; @@ -46,7 +46,8 @@ public class PacketReceiveListener implements Listener { this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); this.commandsModule = moduleManager.getCommandsModule(); - this.version = Bukkit.getServer().getClass().getPackage().getName().split( "\\." )[3]; + this.version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; + this.checkLectern = !version.equals("v1_18_R2") && !version.equals("v1_19_R1"); } public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, @@ -130,22 +131,24 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { final Inventory topInventory = inventoryView.getTopInventory(); - if (topInventory.getType().name().equals("LECTERN") && !version.equals("v1_18_R2") && !version.equals("v1_19_R1")) { - if (version.equals("v1_18_R1")) { - if (integers.containsKey("a") && integers.get("a") == 1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " tried to quick move on a lectern! Added vls: " - + windowClick; + if (topInventory.getType().name().equals("LECTERN")) { + if (this.checkLectern) { + if (version.equals("v1_18_R1")) { + if (integers.containsKey("a") && integers.get("a") == 1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - } - } else { - if (integers.containsKey("b") && integers.get("b") == 1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " tried to quick move on a lectern! Added vls: " - + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + } + } else { + if (integers.containsKey("b") && integers.get("b") == 1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + } } } return; From 84df1147788061b30c2aaf73aca4a36bf4e6e76f Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 2 Jul 2022 12:31:47 -0300 Subject: [PATCH 219/336] Only check specific versions --- .../exploitfixer/listener/PacketReceiveListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 55065bc..0ed3f2a 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -47,7 +47,11 @@ public class PacketReceiveListener implements Listener { this.packetsModule = moduleManager.getPacketsModule(); this.commandsModule = moduleManager.getCommandsModule(); this.version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - this.checkLectern = !version.equals("v1_18_R2") && !version.equals("v1_19_R1"); + this.checkLectern = version.equals("v1_18_R1") + || version.startsWith("v1_17") || version.startsWith("v1_16") + || version.startsWith("v1_15") || version.startsWith("v1_14") + || version.startsWith("v1_13") || version.startsWith("v1_12") + || version.startsWith("v1_11") || version.startsWith("v1_10"); } public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, From ba9e6a532608c6f0bdf05e2317e8f875fb3d83ef Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 2 Jul 2022 12:56:42 -0300 Subject: [PATCH 220/336] Update netty --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a040cd..c904261 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ io.netty netty-all - 4.1.76.Final + 4.1.77.Final provided From 7d73902853e2a9fff9a558137f21e7bac4e212f1 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 21 Jul 2022 23:51:13 -0300 Subject: [PATCH 221/336] Detect new exploits --- pom.xml | 4 +- .../listener/PacketReceiveListener.java | 70 ++++++++++--------- .../exploitfixer/utils/ExploitUtil.java | 2 +- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/pom.xml b/pom.xml index c904261..964c7c5 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ io.netty netty-all - 4.1.77.Final + 4.1.79.Final provided @@ -55,4 +55,4 @@ 0.2.3 - + \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 0ed3f2a..e62d902 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -48,10 +48,10 @@ public class PacketReceiveListener implements Listener { this.commandsModule = moduleManager.getCommandsModule(); this.version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; this.checkLectern = version.equals("v1_18_R1") - || version.startsWith("v1_17") || version.startsWith("v1_16") - || version.startsWith("v1_15") || version.startsWith("v1_14") - || version.startsWith("v1_13") || version.startsWith("v1_12") - || version.startsWith("v1_11") || version.startsWith("v1_10"); + || version.startsWith("v1_17") || version.startsWith("v1_16") + || version.startsWith("v1_15") || version.startsWith("v1_14") + || version.startsWith("v1_13") || version.startsWith("v1_12") + || version.startsWith("v1_11") || version.startsWith("v1_10"); } public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, @@ -105,7 +105,8 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); return; - } else if (bookVls > 0 && (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen"))) { + } else if (bookVls > 0 + && (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen"))) { final PlayerInventory playerInventory = player.getInventory(); final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); @@ -117,11 +118,11 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster return; } } else if (tag.equals("MC|AdvCdm") && !player.isOp()) { - final String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag - + " CustomPayload packet without being op!"; + final String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag + + " CustomPayload packet without being op!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); - return; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + return; } exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(tag)); @@ -144,6 +145,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; } } else { if (integers.containsKey("b") && integers.get("b") == 1) { @@ -152,38 +154,38 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; } } } - return; - } else { - final Inventory bottomInventory = inventoryView.getBottomInventory(); + } - if (integers.containsKey("slot")) { - final int slot = integers.get("slot"), maxSlots; + final Inventory bottomInventory = inventoryView.getBottomInventory(); + final boolean containsSlot = integers.containsKey("slot"); - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } + if (containsSlot || integers.containsKey("d")) { + final int slot = containsSlot ? integers.get("slot") : integers.get("d"); + final int maxSlots; - if (slot < 0 && slot != -999 && slot != -1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } else if (slot >= maxSlots) { - final String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " - + windowClick; + if (bottomInventory.getType() == InventoryType.PLAYER + && topInventory.getType() == InventoryType.CRAFTING) { + maxSlots = inventoryView.countSlots() + 4; + } else { + maxSlots = inventoryView.countSlots(); + } - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); - return; - } + if (slot < 0 && slot != -999 && slot != -1) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; + } else if (slot >= maxSlots) { + final String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + return; } } } diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index c05df82..e74906f 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -88,7 +88,7 @@ public boolean checkItem(final ItemStack item) { if (itemMeta != null) { final String displayName = itemMeta.getDisplayName(); - if (displayName != null && displayName.length() > 256) { + if (displayName != null && displayName.length() > 1536) { return false; } From 126320d08eb5b1ac0a75f0382e5878adcd77366f Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 21 Jul 2022 23:55:21 -0300 Subject: [PATCH 222/336] 1.6.5 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index bb6d08c..a0de34e 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.4 +version: 1.6.5 author: 2LS api: "1.13" api-version: "1.13" From 3aa752bf0c6abbc4b78e83b718288d7f8c58db08 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Fri, 29 Jul 2022 22:19:29 -0300 Subject: [PATCH 223/336] prevent crashes from invalid items --- .../listener/PacketReceiveListener.java | 4 +++ .../modules/NotificationsModule.java | 4 +++ .../exploitfixer/utils/ExploitUtil.java | 34 +++++++++++-------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index e62d902..c8ed426 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -249,6 +249,10 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } + if (notificationsModule.isDebug()) { + notificationsModule.debug("Received packet: " + packetName + " Integers: " + integers + " Strings: " + strings); + } + notificationsModule.addPacketDebug(String.valueOf(packetType)); } diff --git a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index 13c64dc..aca54b9 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -87,6 +87,10 @@ public final boolean isNotifications(final String playerName) { return notifications.contains(playerName); } + public final boolean isDebug() { + return debug; + } + public final Collection getNotifications() { return notifications; } diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index e74906f..6bdda5d 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -82,28 +82,32 @@ private boolean checkBook(final BookMeta meta) { } public boolean checkItem(final ItemStack item) { - if (item != null && item.hasItemMeta()) { - final ItemMeta itemMeta = item.getItemMeta(); + try { + if (item != null && item.hasItemMeta()) { + final ItemMeta itemMeta = item.getItemMeta(); - if (itemMeta != null) { - final String displayName = itemMeta.getDisplayName(); + if (itemMeta != null) { + final String displayName = itemMeta.getDisplayName(); - if (displayName != null && displayName.length() > 1536) { - return false; - } + if (displayName != null && displayName.length() > 1536) { + return false; + } - final List lore = itemMeta.getLore(); + final List lore = itemMeta.getLore(); - if (lore != null && lore.size() > 64) { - return false; - } + if (lore != null && lore.size() > 64) { + return false; + } - if (itemMeta instanceof BookMeta) { - return checkBook((BookMeta) itemMeta); - } else if (itemMeta instanceof BlockStateMeta) { - return checkBlockState((BlockStateMeta) itemMeta); + if (itemMeta instanceof BookMeta) { + return checkBook((BookMeta) itemMeta); + } else if (itemMeta instanceof BlockStateMeta) { + return checkBlockState((BlockStateMeta) itemMeta); + } } } + } catch (IllegalArgumentException ex) { + return false; } return true; From 9de47cb1a707311a039bf38e8a67d5d2bd07d585 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sun, 7 Aug 2022 10:39:07 -0300 Subject: [PATCH 224/336] ignore keep alive on packet decode --- .../listener/PacketDecodeListener.java | 12 ++++++++- .../listener/PacketReceiveListener.java | 5 ---- .../exploitfixer/utils/ProtocolUtil.java | 27 +++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index bdbb37a..ba44c96 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -9,6 +9,7 @@ import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.modules.PacketsModule; import dev._2lstudios.exploitfixer.utils.ExploitUtil; +import dev._2lstudios.exploitfixer.utils.ProtocolUtil; import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import io.netty.buffer.ByteBuf; @@ -63,6 +64,14 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; } else { + final int packetId = ProtocolUtil.readVarInt(byteBuf); + + byteBuf.resetReaderIndex(); + + if (packetId == 18) { + return; + } + if (dataVlMultiplier > 0) { exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier); } @@ -86,7 +95,8 @@ public void onPacketDecode(final PacketDecodeEvent event) { } final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + final ByteBuf byteBuf = event.getByteBuf().get(); - onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getByteBuf().get()); + onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), byteBuf); } } diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index c8ed426..568a9fd 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -57,11 +57,6 @@ public class PacketReceiveListener implements Listener { public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, final PacketWrapper packetWrapper) { final PacketType packetType = packetWrapper.getType(); - - if (packetType == PacketType.PacketPlayInKeepAlive) { - return; - } - final String packetName = packetWrapper.getName(); final String playerName = player.getName(); final Map strings = packetWrapper.getStrings(); diff --git a/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java new file mode 100644 index 0000000..37a4e8d --- /dev/null +++ b/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java @@ -0,0 +1,27 @@ +package dev._2lstudios.exploitfixer.utils; + +import io.netty.buffer.ByteBuf; + +public class ProtocolUtil { + private static final int SEGMENT_BITS = 0x7F; + private static final int CONTINUE_BIT = 0x80; + + public static int readVarInt(ByteBuf byteBuf) { + int value = 0; + int position = 0; + byte currentByte; + + while (true) { + currentByte = byteBuf.readByte(); + value |= (currentByte & SEGMENT_BITS) << position; + + if ((currentByte & CONTINUE_BIT) == 0) break; + + position += 7; + + if (position >= 32) throw new RuntimeException("VarInt is too big"); + } + + return value; + } +} From d7ce59c5f408ed3a5523fd3e856cfff72712c275 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sun, 7 Aug 2022 15:03:30 -0300 Subject: [PATCH 225/336] 1.6.6 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index a0de34e..4277c35 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.5 +version: 1.6.6 author: 2LS api: "1.13" api-version: "1.13" From 0023d604fc1042037d0e52957b4b8f68bc92a63b Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sun, 7 Aug 2022 21:39:17 -0300 Subject: [PATCH 226/336] security checks for packets --- .../exploitfixer/listener/PacketDecodeListener.java | 11 +++++++---- .../_2lstudios/exploitfixer/utils/ProtocolUtil.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index ba44c96..3c1b1de 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -13,6 +13,7 @@ import dev._2lstudios.hamsterapi.events.PacketDecodeEvent; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import io.netty.buffer.ByteBuf; +import io.netty.buffer.EmptyByteBuf; public class PacketDecodeListener implements Listener { @@ -64,12 +65,14 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster reason = PREFIX + playerName + " sent a packet that exceeds readable bytes limit! " + readableBytes + "/" + dataBytes + " Vls: " + dataVls; } else { - final int packetId = ProtocolUtil.readVarInt(byteBuf); + if (!(byteBuf instanceof EmptyByteBuf)) { + final int packetId = ProtocolUtil.readVarInt(byteBuf); - byteBuf.resetReaderIndex(); + byteBuf.resetReaderIndex(); - if (packetId == 18) { - return; + if (packetId == 18) { + return; + } } if (dataVlMultiplier > 0) { diff --git a/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java index 37a4e8d..dcf2eb2 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java @@ -11,7 +11,7 @@ public static int readVarInt(ByteBuf byteBuf) { int position = 0; byte currentByte; - while (true) { + while (byteBuf.isReadable()) { currentByte = byteBuf.readByte(); value |= (currentByte & SEGMENT_BITS) << position; From 03e40ba47284c0817fedfd90066b6669f511bd30 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 08:58:05 -0300 Subject: [PATCH 227/336] 1.6.7 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 4277c35..3641b7e 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.6 +version: 1.6.7 author: 2LS api: "1.13" api-version: "1.13" From a96e45c1a11a7e1a259590abb42f52363192a712 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 10:14:37 -0300 Subject: [PATCH 228/336] disable extreme debug --- .../exploitfixer/listener/PacketReceiveListener.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 568a9fd..a4fc7e2 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -244,10 +244,6 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - if (notificationsModule.isDebug()) { - notificationsModule.debug("Received packet: " + packetName + " Integers: " + integers + " Strings: " + strings); - } - notificationsModule.addPacketDebug(String.valueOf(packetType)); } From 8ff7b5ef9254623ab3dfeab912b7d239f19bc4ec Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 11:04:39 -0300 Subject: [PATCH 229/336] check fireworks --- .../exploitfixer/utils/ExploitUtil.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 6bdda5d..8a94cd4 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.List; +import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; @@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; @@ -81,6 +83,28 @@ private boolean checkBook(final BookMeta meta) { return true; } + private boolean checkFirework(final FireworkMeta meta) { + if (meta.getPower() > 3) { + return false; + } + + if (meta.getEffectsSize() > 12) { + return false; + } + + for (FireworkEffect effect : meta.getEffects()) { + if (effect.getColors().size() > 6) { + return false; + } + + if (effect.getFadeColors().size() > 6) { + return false; + } + } + + return true; + } + public boolean checkItem(final ItemStack item) { try { if (item != null && item.hasItemMeta()) { @@ -103,6 +127,8 @@ public boolean checkItem(final ItemStack item) { return checkBook((BookMeta) itemMeta); } else if (itemMeta instanceof BlockStateMeta) { return checkBlockState((BlockStateMeta) itemMeta); + } else if (itemMeta instanceof FireworkMeta) { + return checkFirework((FireworkMeta) itemMeta); } } } From e0763e075f834d33ed6dff4be4a5b44297aa9942 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 11:05:34 -0300 Subject: [PATCH 230/336] 1.6.8 --- resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 3641b7e..5908d51 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: ExploitFixer main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.7 +version: 1.6.8 author: 2LS api: "1.13" api-version: "1.13" From c3d76a8025da792550e76975695e94dcf5ba71cb Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 11:11:50 -0300 Subject: [PATCH 231/336] check if firework has effects before checking --- .../exploitfixer/utils/ExploitUtil.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 8a94cd4..7bf66e4 100644 --- a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -88,17 +88,19 @@ private boolean checkFirework(final FireworkMeta meta) { return false; } - if (meta.getEffectsSize() > 12) { - return false; - } - - for (FireworkEffect effect : meta.getEffects()) { - if (effect.getColors().size() > 6) { + if (meta.hasEffects()) { + if (meta.getEffectsSize() > 12) { return false; } - if (effect.getFadeColors().size() > 6) { - return false; + for (FireworkEffect effect : meta.getEffects()) { + if (effect.getColors().size() > 6) { + return false; + } + + if (effect.getFadeColors().size() > 6) { + return false; + } } } From aedb0fc699a586ccb24c355049973882fee6492c Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 8 Aug 2022 11:30:35 -0300 Subject: [PATCH 232/336] better number checks --- .../listener/PacketReceiveListener.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index a4fc7e2..1b438db 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -234,9 +234,29 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (dataVls > 0) { for (final float val : packetWrapper.getFloats().values()) { - if (val > Integer.MAX_VALUE || val < -Integer.MAX_VALUE) { + if (val > Float.MAX_VALUE || val < Float.MIN_VALUE) { final String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid number! Added vls: " + dataVls; + + " sent an invalid float! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + for (final double val : packetWrapper.getDouble().values()) { + if (val > Double.MAX_VALUE || val < Double.MIN_VALUE) { + final String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid double! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + for (final int val : integers.values()) { + if (val > Integer.MAX_VALUE || val < Integer.MIN_VALUE) { + final String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid integer! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); return; From b0abe4276bad7982468f60da3eb6af25654e4b21 Mon Sep 17 00:00:00 2001 From: ImLew_x Date: Mon, 8 Aug 2022 10:54:11 -0400 Subject: [PATCH 233/336] Reduce object allocation from creative item check --- .../exploitfixer/listener/PacketReceiveListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 1b438db..b7f8d33 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -38,6 +38,7 @@ public class PacketReceiveListener implements Listener { private final CommandsModule commandsModule; private final String version; private final boolean checkLectern; + private final ItemStack AIR = new ItemStack(Material.AIR); PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { this.exploitUtil = exploitUtil; @@ -221,7 +222,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final String blacklisted = exploitUtil.clearIfBlacklisted(item); if (blacklisted != null) { - packetWrapper.write(itemsEntry.getKey(), new ItemStack(Material.AIR)); + packetWrapper.write(itemsEntry.getKey(), AIR); notificationsModule.debug( playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); } else { From 55f1f927e96a1a6f7578c84e9207ef688f5a1880 Mon Sep 17 00:00:00 2001 From: ImLew_x Date: Mon, 8 Aug 2022 13:55:01 -0400 Subject: [PATCH 234/336] Add missing return --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 1b438db..75f30f0 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -73,6 +73,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); + return; } if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { From ebbfff4afdf522825a59d5cabd2bab7a81f5573c Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 21:04:03 -0300 Subject: [PATCH 235/336] better notification module --- .../commands/ExploitFixerCommand.java | 4 +- .../listener/PacketReceiveListener.java | 4 +- .../listener/PlayerLoginListener.java | 4 +- .../listener/PlayerQuitListener.java | 4 +- .../exploitfixer/managers/ModuleManager.java | 8 ++-- .../modules/BukkitNotificationsModule.java | 48 ------------------- .../modules/INotificationsModule.java | 4 +- .../modules/NotificationsModule.java | 42 +++++++++++++--- 8 files changed, 51 insertions(+), 67 deletions(-) delete mode 100644 src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index bc46b73..ef95aed 100644 --- a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -8,14 +8,14 @@ import dev._2lstudios.exploitfixer.ExploitFixer; import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.modules.MessagesModule; public class ExploitFixerCommand implements CommandExecutor { private final ExploitFixer exploitFixer; private final MessagesModule messagesModule; - private final BukkitNotificationsModule notificationsModule; + private final NotificationsModule notificationsModule; private final ExploitPlayerManager exploitPlayerManager; public ExploitFixerCommand(final ExploitFixer exploitFixer, final ModuleManager moduleManager) { diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 1b438db..6fb0270 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -3,9 +3,9 @@ import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; import dev._2lstudios.exploitfixer.modules.CommandsModule; import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.exploitfixer.modules.PacketsModule; import dev._2lstudios.exploitfixer.utils.ExploitUtil; import dev._2lstudios.hamsterapi.enums.PacketType; @@ -33,7 +33,7 @@ public class PacketReceiveListener implements Listener { private final ExploitUtil exploitUtil; private final ExploitPlayerManager exploitPlayerManager; private final ItemsFixModule itemsFixModule; - private final BukkitNotificationsModule notificationsModule; + private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; private final CommandsModule commandsModule; private final String version; diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java index 1fa4594..ffcf71b 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java @@ -9,13 +9,13 @@ import org.bukkit.event.player.PlayerLoginEvent; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.modules.ConnectionModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; public class PlayerLoginListener implements Listener { - private final BukkitNotificationsModule notificationsModule; + private final NotificationsModule notificationsModule; private final MessagesModule messagesModule; private final ConnectionModule connectionModule; diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java b/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java index 86e94c7..85ec73e 100644 --- a/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java +++ b/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java @@ -7,11 +7,11 @@ import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class PlayerQuitListener implements Listener { private final ExploitPlayerManager exploitPlayerManager; - private final BukkitNotificationsModule notificationsModule; + private final NotificationsModule notificationsModule; PlayerQuitListener(final ModuleManager variables) { this.exploitPlayerManager = variables.getExploitPlayerManager(); diff --git a/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java index 8b50e79..2e1c7cc 100644 --- a/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java +++ b/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java @@ -6,7 +6,7 @@ import org.bukkit.Server; import org.bukkit.plugin.Plugin; -import dev._2lstudios.exploitfixer.modules.BukkitNotificationsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.exploitfixer.modules.EventsModule; import dev._2lstudios.exploitfixer.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.configuration.IConfiguration; @@ -23,7 +23,7 @@ public class ModuleManager { private final EventsModule eventsModule; private final ItemsFixModule itemsFixModule; private final MessagesModule messagesModule; - private final BukkitNotificationsModule notificationsModule; + private final NotificationsModule notificationsModule; private final PacketsModule packetsModule; private final ExploitPlayerManager exploitPlayerManager; @@ -38,7 +38,7 @@ public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin pl this.eventsModule = new EventsModule(); this.itemsFixModule = new ItemsFixModule(plugin); this.messagesModule = new MessagesModule(configurationUtil, logger, plugin.getDescription().getVersion()); - this.notificationsModule = new BukkitNotificationsModule(server.getConsoleSender(), logger, server); + this.notificationsModule = new NotificationsModule(server, logger); this.packetsModule = new PacketsModule(); this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); } @@ -87,7 +87,7 @@ public MessagesModule getMessagesModule() { return messagesModule; } - public BukkitNotificationsModule getNotificationsModule() { + public NotificationsModule getNotificationsModule() { return notificationsModule; } diff --git a/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java deleted file mode 100644 index 5104b9b..0000000 --- a/src/dev/_2lstudios/exploitfixer/modules/BukkitNotificationsModule.java +++ /dev/null @@ -1,48 +0,0 @@ -package dev._2lstudios.exploitfixer.modules; - -import java.util.logging.Logger; - -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class BukkitNotificationsModule extends NotificationsModule { - private final CommandSender console; - private final Server server; - - public BukkitNotificationsModule(final CommandSender console, final Logger logger, final Server server) { - super(logger); - this.console = console; - this.server = server; - } - - @Override - public void sendNotification(final String check, final Object player, final int violations) { - if (isEnabled() && player != null) { - final Player player1 = (Player) player; - final int ping = getPing(player1); - final String notification = getMessage().replace("%player%", player1.getName()).replace("%check%", check) - .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); - - console.sendMessage(notification); - - for (final String playerName : getNotifications()) { - final Player player2 = server.getPlayer(playerName); - - if (player2 != null) { - player2.sendMessage(notification); - } - } - } - } - - private int getPing(final Player player) { - try { - final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); - - return (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (final Exception ignored) { - return 0; - } - } -} diff --git a/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java index c275564..721e333 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java @@ -1,5 +1,7 @@ package dev._2lstudios.exploitfixer.modules; +import org.bukkit.entity.Player; + public interface INotificationsModule extends IModule { - public void sendNotification(final String check, final Object player, final int violations); + public void sendNotification(final String check, final Player player, final int violations); } \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index aca54b9..7f3a074 100644 --- a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -8,16 +8,22 @@ import java.util.Map.Entry; import java.util.logging.Logger; +import org.bukkit.Server; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; + import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class NotificationsModule implements INotificationsModule { + private final Server server; private final Logger logger; private final Map packetDebug = new HashMap<>(); private final Collection notifications = new HashSet<>(); private boolean enabled, debug; private String message; - public NotificationsModule(final Logger logger) { + public NotificationsModule(final Server server, final Logger logger) { + this.server = server; this.logger = logger; } @@ -95,13 +101,37 @@ public final Collection getNotifications() { return notifications; } + public void sendNotification(final String check, final Player exploiterPlayer, final int violations) { + if (isEnabled() && exploiterPlayer != null) { + final int ping = getPing(exploiterPlayer); + final String notification = getMessage().replace("%player%", exploiterPlayer.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); + final ConsoleCommandSender console = server.getConsoleSender(); + + console.sendMessage(notification); + + for (final String notificationPlayerName : getNotifications()) { + final Player notificationPlayer = server.getPlayer(notificationPlayerName); + + if (notificationPlayer != null) { + notificationPlayer.sendMessage(notification); + } + } + } + } + + private int getPing(final Player player) { + try { + final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + + return (int) playerHandle.getClass().getField("ping").get(playerHandle); + } catch (final Exception ignored) { + return 0; + } + } + @Override public String getName() { return "Notifications"; } - - @Override - public void sendNotification(String check, Object player, int violations) { - // Overwritten by parent Bukkit NotificationsModule - } } \ No newline at end of file From dac612d7cfd83a5d8f94335154edfe758a9bd33d Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 21:12:22 -0300 Subject: [PATCH 236/336] update project workflow --- pom.xml | 64 ++++--- .../_2lstudios/exploitfixer/ExploitFixer.java | 0 .../commands/ExploitFixerCommand.java | 0 .../exploitfixer/commands/HelpCommand.java | 0 .../commands/NotificationsCommand.java | 0 .../exploitfixer/commands/ReloadCommand.java | 0 .../exploitfixer/commands/StatsCommand.java | 0 .../configuration/BukkitConfiguration.java | 0 .../configuration/IConfiguration.java | 0 .../exploit/BukkitExploitPlayer.java | 0 .../exploitfixer/exploit/ExploitPlayer.java | 0 .../exploitfixer/exploit/Violations.java | 0 .../EntityDamageByEntityListener.java | 0 .../listener/ListenerInitializer.java | 0 .../listener/PacketDecodeListener.java | 0 .../listener/PacketReceiveListener.java | 0 .../listener/PlayerCommandListener.java | 0 .../listener/PlayerInteractListener.java | 0 .../listener/PlayerLoginListener.java | 0 .../listener/PlayerMoveListener.java | 0 .../listener/PlayerQuitListener.java | 0 .../managers/ExploitPlayerManager.java | 0 .../exploitfixer/managers/ModuleManager.java | 0 .../exploitfixer/modules/CommandsModule.java | 0 .../modules/ConnectionModule.java | 0 .../exploitfixer/modules/EventsModule.java | 0 .../exploitfixer/modules/IMessagesModule.java | 0 .../exploitfixer/modules/IModule.java | 0 .../modules/INotificationsModule.java | 0 .../modules/IPunishmentModule.java | 0 .../modules/IViolationModule.java | 0 .../exploitfixer/modules/ItemsFixModule.java | 0 .../exploitfixer/modules/MessagesModule.java | 0 .../modules/NotificationsModule.java | 0 .../exploitfixer/modules/PacketsModule.java | 0 .../tasks/ExploitFixerRepeatingTask.java | 0 .../utils/BukkitConfigurationUtil.java | 0 .../exploitfixer/utils/ExploitUtil.java | 0 .../utils/IConfigurationUtil.java | 0 .../exploitfixer/utils/ProtocolUtil.java | 0 .../exploitfixer/utils/VersionUtil.java | 0 src/main/resources/config.yml | 181 ++++++++++++++++++ src/main/resources/locales/de.yml | 27 +++ src/main/resources/locales/en.yml | 27 +++ src/main/resources/locales/es.yml | 27 +++ src/main/resources/locales/fr.yml | 27 +++ src/main/resources/locales/hu.yml | 26 +++ src/main/resources/locales/it.yml | 27 +++ src/main/resources/locales/ja.yml | 27 +++ src/main/resources/locales/ko.yml | 27 +++ src/main/resources/locales/nl.yml | 27 +++ src/main/resources/locales/pl.yml | 27 +++ src/main/resources/locales/pt.yml | 27 +++ src/main/resources/locales/ro.yml | 27 +++ src/main/resources/locales/th.yml | 27 +++ src/main/resources/locales/tr.yml | 27 +++ src/main/resources/locales/zh.yml | 26 +++ src/main/resources/locales/zhtw.yml | 27 +++ src/main/resources/plugin.yml | 14 ++ 59 files changed, 660 insertions(+), 29 deletions(-) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/ExploitFixer.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/commands/HelpCommand.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/commands/StatsCommand.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/exploit/Violations.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/managers/ModuleManager.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/CommandsModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/EventsModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/IModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/IViolationModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/MessagesModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/modules/PacketsModule.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java (100%) rename src/{ => main/java}/dev/_2lstudios/exploitfixer/utils/VersionUtil.java (100%) create mode 100644 src/main/resources/config.yml create mode 100644 src/main/resources/locales/de.yml create mode 100644 src/main/resources/locales/en.yml create mode 100644 src/main/resources/locales/es.yml create mode 100644 src/main/resources/locales/fr.yml create mode 100644 src/main/resources/locales/hu.yml create mode 100644 src/main/resources/locales/it.yml create mode 100644 src/main/resources/locales/ja.yml create mode 100644 src/main/resources/locales/ko.yml create mode 100644 src/main/resources/locales/nl.yml create mode 100644 src/main/resources/locales/pl.yml create mode 100644 src/main/resources/locales/pt.yml create mode 100644 src/main/resources/locales/ro.yml create mode 100644 src/main/resources/locales/th.yml create mode 100644 src/main/resources/locales/tr.yml create mode 100644 src/main/resources/locales/zh.yml create mode 100644 src/main/resources/locales/zhtw.yml create mode 100644 src/main/resources/plugin.yml diff --git a/pom.xml b/pom.xml index 964c7c5..c04c71f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,31 +1,20 @@ 4.0.0 + dev._2lstudios ExploitFixer - SNAPSHOT + jar + + ExploitFixer + Advanced anti-exploit security plugin for Spigot servers. + 1.6.8 + https://www.spigotmc.org/resources/62842/ + - 1.8 - 1.8 + 2LS + UTF-8 - - ${project.artifactId} - ${basedir}/src/ - - - ${basedir}/resources/ - - - - - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - - - + spigot-repo @@ -36,17 +25,12 @@ https://ci.2lstudios.dev/plugin/repository/everything/ + - - io.netty - netty-all - 4.1.79.Final - provided - org.spigotmc spigot-api - 1.18.1-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT provided @@ -55,4 +39,26 @@ 0.2.3 + + + ${artifactId} + src/main/java + clean install + + + src/main/resources + + + + + + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + \ No newline at end of file diff --git a/src/dev/_2lstudios/exploitfixer/ExploitFixer.java b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/ExploitFixer.java rename to src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java rename to src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/commands/HelpCommand.java rename to src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java rename to src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java rename to src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/commands/StatsCommand.java rename to src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java diff --git a/src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java b/src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java rename to src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java diff --git a/src/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java b/src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java rename to src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java diff --git a/src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java rename to src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java diff --git a/src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java rename to src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java diff --git a/src/dev/_2lstudios/exploitfixer/exploit/Violations.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/exploit/Violations.java rename to src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java diff --git a/src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java rename to src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java diff --git a/src/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java rename to src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java diff --git a/src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/managers/ModuleManager.java rename to src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/CommandsModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/EventsModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/IModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/IModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/IModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/IModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/IPunishmentModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/IViolationModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/IViolationModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/IViolationModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/IViolationModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/MessagesModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/modules/PacketsModule.java rename to src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java diff --git a/src/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java b/src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java rename to src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java diff --git a/src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java rename to src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java rename to src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java rename to src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java rename to src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java diff --git a/src/dev/_2lstudios/exploitfixer/utils/VersionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java similarity index 100% rename from src/dev/_2lstudios/exploitfixer/utils/VersionUtil.java rename to src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..0b8d5ba --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,181 @@ +# ExploitFixer by LinsaFTW +# Please help by donating, we require funds to continue with the development. +# https://paypal.me/LinsaFTW +# +# INSTALL THE PLUGIN ON ALL BUKKIT SERVERS! +# +# Most of the check use Violations (vls), this a counter to execute different +# actions on diverse levels to allow high customization of the modules. + +# Default language used by the plugin (This changes depending on the client language) +locale: "en" + +# Web link used on the messages +web: "discord.gg/gF36AT3" + +# Shows notifications to console and players with permissions. +notifications: + enabled: true + + # Placeholders: %player% %ping% %check% %vls% + message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" + + # This shows extra information about blocked packets. + debug: false + +# Prevents exploits that occur on different Bukkit events. +events: + # Prevents moving if the chunk is null. (Prevents chunk overloading) + null_chunk: true + + # Prevents players from damaging themselves and consuming ram. + self_damage: true + + # Prevents maps from tracking fixing many crash exploits + disable_tracking: true + +# Prevents the use of invalid packets to crash the server. +packets: + enabled: true + + # Amount of vls required to start cancelling packets. + cancel_vls: 25 + + # Amount of vls to reduce per second. + reduce_vls: 25 + + # Cancels packets if the player sending them is offline. + offline: true + + # This will check if integers, floats, doubles and items have a invalid size in packets. + data: + # Vls to add when a packet fails the check. (Set to -1 to disable) + vls: 100 + + # Maximum amount of bytes allowed per packet. (Set to -1 to disable) + bytes: 64000 + + # Maximum amount of bytes allowed per book page. (Set to -1 to disable) + bytes_book: 300 + + # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) + bytes_sign: 47 + + # This option adds vls per byte received. + # Vls to add per byte received. (Set to -1 to disable) + vl_multiplier: 0.0001 + + # Cancels book packets when a book is not in hand + # Vls to add when a packet fails the check. (Set to -1 to disable) + book: 10 + + # Cancels CustomPayload packets with invalid tags + # Vls to add when a packet fails the check. (Set to -1 to disable) + tag: 100 + + # Checks if players send PacketPlayInWindowClick packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + window_click: 100 + + # Checks if players send PacketPlayInBlockPlace packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_place: 100 + + # Checks if players send PacketPlayInBlockDig packets with invalid data. + # Vls to add when a packet fails the check. (Set to -1 to disable) + block_dig: 100 + + # Checks if players send PacketPlayInCreativeSlot packets without creative. + # Vls to add when a packet fails the check. (Set to -1 to disable) + set_creative_slot: 100 + + # Vls to add when a normal packet is sent by a player. + # This option is made to work as a packet limiter feature. + # Unlisted packets are considered as "PacketPlayInOther" by default. + # Remember to take a look at bytes_divider option. + multipliers: + PacketPlayInOther: 0.1 + MC|BSign: 4.5 + MC|BEdit: 4.5 + MC|BOpen: 4.5 + PacketPlayInAutoRecipe: 10 + PacketPlayInUpdateSign: 5 + PacketPlayInAbilities: 0.25 + PacketPlayInArmAnimation: 0.05 + PacketPlayInBlockDig: 0.5 + PacketPlayInBlockPlace: 0.5 + PacketPlayInCustomPayload: 0.01 + PacketPlayInEntityAction: 0.5 + PacketPlayInFlying: 0.25 + PacketPlayInLook: 0.5 + PacketPlayInPositionLook: 0.05 + PacketPlayInPosition: 0.2 + PacketPlayInSetCreativeSlot: 0.15 + PacketPlayInSettings: 0.5 + PacketPlayInTabComplete: 0.75 + PacketPlayInUseEntity: 0.5 + PacketPlayInUseItem: 1 + PacketPlayInWindowClick: 0.65 + + # These packets will be completely cancelled. + blacklist: + - "PacketPlayInAutoRecipe" + + # Placeholders: %player%, %vl%, %ping%, %check% + # Commands to run when a player reaches certain violation level. + violations: + 25: + - "notification" + 50: + - "notification" + 75: + - "notification" + 100: + - "notification" + - "kick" + +# Removes custom NBT tags from creative items to prevent harm to your server. +# Negative enchant values will always be removed. +itemsfix: + enabled: true + + # Maximum stack size obtainable with creative packets. (-1 to allow anything) + max_stack_size: 64 + + # Maximum enchant level obtainable with creative packets. + # -1 removes all enchants, 0 forces vanilla values + enchant_limit: 0 + + # List of materials that are unobtainable from Creative. + blacklist: + - "END_PORTAL" + - "NETHER_PORTAL" + # - "BARRIER" + # - "COMMAND_BLOCK" + +# Checks if players try to crash/exploit the server with commands. +commands: + enabled: true + + # Commands that are exempt from this server. + commands: + - "//calc" + - "//calculate" + - "//eval" + - "//evaluate" + - "//solve" + - "/hd readtext" + - "/holo readtext" + - "/hologram readtext" + - "/holograms readtext" + - "/holographicdisplays readtext" + - "/pex promote" + - "/pex demote" + - "/promote" + - "/demote" + - "/execute" + + # Placeholders: %player% + punishments: + - "notification" + - "kick" diff --git a/src/main/resources/locales/de.yml b/src/main/resources/locales/de.yml new file mode 100644 index 0000000..8423527 --- /dev/null +++ b/src/main/resources/locales/de.yml @@ -0,0 +1,27 @@ +# German - Credits: Dominik48N / NoJokeFNA / GeGrieftGames +commands: + reload: "&aPlugin ExploitFixer wurde neu geladen!" + help: |- + &aExploitFixer &b%version%&a von &bLinsaFTW&a. + &e /%command% help &7> &bZeigt alle verfügbaren Befehle an. + &e /%command% reload &7> &bLädt das Plugin neu. + &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. + &e /%command% stats &7> &bZeigt die Statistiken des Plugins an. + error: + unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" + permission: "&cDu darfst diesen Befehl nicht ausführen!" + console: "&cDieser Befehl darf nicht von der Konsole ausgeführt werden!" + notifications: + enable: "&aDu hast die Benachrichtigungen aktiviert!" + disable: "&cDu hast die Benachrichtigungen deaktiviert!" + stats: "&c&lEF: &eZwischengespeicherte Spieler: &a%players_cached%&e Bestrafte Spieler: &a%players_punished%" +modules: + custompayload: + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fPacket Exploit erkannt.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fNulladresse erkannt.\n&7Discord: &b&n%web%&r" +mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/en.yml b/src/main/resources/locales/en.yml new file mode 100644 index 0000000..e41654f --- /dev/null +++ b/src/main/resources/locales/en.yml @@ -0,0 +1,27 @@ +# English - Credits: LinsaFTW +commands: + reload: "&aPlugin ExploitFixer reloaded!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bShows available commands. + &e /%command% reload &7> &bReloads the plugin. + &e /%command% notifications &7> &bToggles notifications of the plugin. + &e /%command% stats &7> &bWatch the stats of the plugin. + error: + unknown: "&cUnknown command. Use /exploitfixer help to see available commands!" + permission: "&cYou dont have permission to use this command!" + console: "&cThis command cant be executed from the console!" + notifications: + enable: "&aYou have enabled notifications!" + disable: "&cYou have disabled notifications!" + stats: "&c&lEF: &ePlayers cached: &a%players_cached%&e Players punished: &a%players_punished%" +modules: + custompayload: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang servers are down, please come back later!\n\n&7Reason: &fExploitFixer can't check the UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/es.yml b/src/main/resources/locales/es.yml new file mode 100644 index 0000000..b859bf1 --- /dev/null +++ b/src/main/resources/locales/es.yml @@ -0,0 +1,27 @@ +# Spanish - Credits: LinsaFTW +commands: + reload: "&aPlugin ExploitFixer recargado!" + help: |- + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bMuestra los comandos disponibles. + &e /%command% reload &7> &bRecarga el plugin. + &e /%command% notifications &7> &bAlterna las notificaciones del plugin. + &e /%command% stats &7> &bMira las estadisticas del plugin. + error: + unknown: "&cComando desconocido. Usa /exploitfixer help para ver comandos disponibles!" + permission: "&cNo tienes permiso para usar ese comando!" + console: "&cEste comando no puede ser usado desde la consola!" + notifications: + enable: "&aHabilitaste las notificaciones!" + disable: "&cDeshabilitaste las notificaciones!" + stats: "&c&lEF: &eJugadores en cache: &a%players_cached%&e Jugadores sancionados: &a%players_punished%" +modules: + custompayload: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Packets detectado.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Red nula detectado.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang esta apagado, vuelve pronto!\n\n&7Razon: &fExploitFixer no puede confirmar la UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml new file mode 100644 index 0000000..61c2a02 --- /dev/null +++ b/src/main/resources/locales/fr.yml @@ -0,0 +1,27 @@ +# French - Credits: HaVroz +commands: + reload: "&aPlugin Exploitfixer rechargé!" + help: |- + &aExploitFixer &b%version%&a par &bLinsaFTW&a. + &e /%command% help &7> &bAfficher les commandes disponibles. + &e /%command% reload &7> &bRecharger le plugin. + &e /%command% notifications &7> &bActiver/Désactiver les notifications du plugin. + &e /%command% stats &7> &bVoir les statistiques du plugin. + error: + unknown: "&cCommande inconnue. Utilisez /exploitfixer help pour voir les commandes disponibles!" + permission: "&cVous n’avez pas la permission d’utiliser cette commande!" + console: "&cCette commande ne peut pas être exécutée depuis la console!" + notifications: + enable: "&aVous avez activé les notifications!" + disable: "&cVous avez désactivé les notifications!" + stats: "&c&lEF: &eJoueurs caché: &a%players_cached%&e Joueurs sanctionné: &a%players_punished%" +modules: + custompayload: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang est désactivé, revenez bientôt!\n\n&7Raison: &fExploitFixer ne peut pas confirmer l'UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/hu.yml b/src/main/resources/locales/hu.yml new file mode 100644 index 0000000..0f81960 --- /dev/null +++ b/src/main/resources/locales/hu.yml @@ -0,0 +1,26 @@ +#Hungarian +commands: + reload: "&aAz ExploitFixer sikeresen újraindult!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &bElérhetÅ‘ parancsok. + &e /%command% reload &7> &bPlugin újraindítása. + &e /%command% notifications &7> &bÉrtesítések ki/be kapcsolása. + &e /%command% stats &7> &bA plugin statisztikáinak megtekintése. + error: + unknown: "&cIsmeretlen parancs. Használd a /exploitfixer help parancsot!" + permission: "&cNincs jogod a parancs használatához!" + console: "&cEzt a parancsot nem bírod használni a konzolból!" + notifications: + enable: "&aBekapcsoltad az értesítéseket!" + disable: "&cKikapcsoltad az értesítéseket!" + stats: "&c&lEF: &eJátékosok: &a%players_cached%&e Büntetések: &a%players_punished%" +modules: + custompayload: + kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" + commands: + kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + packets: + kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fCsomag exploitot észleltünk.\n&7Discord: &b&n%discord%&r" + nulladdress: + kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fNull addresst észleltünk.\n&7Discord: &b&n%discord%&r" \ No newline at end of file diff --git a/src/main/resources/locales/it.yml b/src/main/resources/locales/it.yml new file mode 100644 index 0000000..8c63bf4 --- /dev/null +++ b/src/main/resources/locales/it.yml @@ -0,0 +1,27 @@ +# Italian +commands: + reload: "&aPlugin ExploitFixer ricaricato!" + help: |- + &aExploitFixer &b%version%&a da parte di &bLinsaFTW&a. + &e /%command% help &7> &bMostra i commandi disponibili. + &e /%command% reload &7> &bRicarica il plugin. + &e /%command% notifications &7> &bCambia le notifiche del plugin. + &e /%command% stats &7> &bMostra le statistiche del plugin. + error: + unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" + permission: "&cNon hai il permesso per questo commando!" + console: "&cQuesto commando non può essere eseguito dalla console!" + notifications: + enable: "&aHai abilitato le notifiche!" + disable: "&cHai disabilitato le notifiche!" + stats: "&c&lEF: &eGiocatori in cache: &a%players_cached%&e Giocatori puniti: &a%players_punished%" +modules: + custompayload: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang è disattivato, torna presto!\n\n&7Reason: &fExploitFixer non può confermare l'UUID. \n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/ja.yml b/src/main/resources/locales/ja.yml new file mode 100644 index 0000000..9057844 --- /dev/null +++ b/src/main/resources/locales/ja.yml @@ -0,0 +1,27 @@ +# Japanese - Credits: cosmos223 +commands: + reload: "&aプラグイン ExploitFixer をリロードã—ã¾ã—ãŸã€‚" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW + &e /%command% help &7> &b使用å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’表示ã—ã¾ã™ã€‚ + &e /%command% reload &7> &bプラグインをリロードã—ã¾ã™ã€‚ + &e /%command% notifications &7> &bプラグインã®é€šçŸ¥ã‚’切り替ãˆã¾ã™ã€‚ + &e /%command% stats &7> &bプラグインã®çµ±è¨ˆæƒ…報を表示ã—ã¾ã™ã€‚ + error: + unknown: "&c䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ /exploitfixer help ã¨å…¥åŠ›ã—ã¦ä½¿ç”¨å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’確èªã—ã¦ãã ã•ã„。" + permission: "&c権é™ãŒã‚りã¾ã›ã‚“。" + console: "&cã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰å®Ÿè¡Œã§ãã¾ã›ã‚“。" + notifications: + enable: "&a通知を有効ã«ã—ã¾ã—ãŸã€‚" + disable: "&c通知を無効ã«ã—ã¾ã—ãŸã€‚" + stats: "&c&lEF: &eキャッシュã•れãŸãƒ—レイヤー: &a%players_cached%&e ç½°ã›ã‚‰ã‚ŒãŸãƒ—レイヤー: &a%players_punished%" +modules: + custompayload: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fCustomPayloadパケットãŒå¤šã検出ã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fコマンドã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fパケットã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fNullã‚¢ãƒ‰ãƒ¬ã‚¹ãŒæ¤œå‡ºã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojangã®ã‚µãƒ¼ãƒãƒ¼ãŒå¿œç­”ã—ã¦ã„ã¾ã›ã‚“。時間を置ã„ã¦ã‹ã‚‰å†åº¦æŽ¥ç¶šã—ã¦ãã ã•ã„。\n\n&7ç†ç”±: &fExploitFixer 㯠UUID を確èªã§ãã¾ã›ã‚“ã§ã—ãŸã€‚\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/ko.yml b/src/main/resources/locales/ko.yml new file mode 100644 index 0000000..3033a2b --- /dev/null +++ b/src/main/resources/locales/ko.yml @@ -0,0 +1,27 @@ +# Korean +commands: + reload: "&aExploitFixer 플러그ì¸ì´ 리로드ë˜ì—ˆìŠµë‹ˆë‹¤!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &b사용 가능 명령어를 표시합니다. + &e /%command% reload &7> &b플러그ì¸ì„ 다시 로드합니다. + &e /%command% notifications &7> &bí”ŒëŸ¬ê·¸ì¸ ì•ŒëžŒì„ í† ê¸€í•©ë‹ˆë‹¤. + &e /%command% stats &7> &b플레ì´ì–´ ìž‘ë™ í˜„í™©ì„ í™•ì¸í•©ë‹ˆë‹¤. + error: + unknown: "&c알 수 없는 명령어입니다. /exploitfixer help 명령어를 통해 사용 가능한 명령어를 확ì¸í•˜ì„¸ìš”!" + permission: "&cë‹¹ì‹ ì€ ì´ ëª…ë ¹ì–´ë¥¼ 사용할 ê¶Œí•œì´ ëª¨ìžëžë‹ˆë‹¤!" + console: "&cì´ ëª…ë ¹ì–´ëŠ” 콘솔ì—서 입력할 수 없습니다!" + notifications: + enable: "&aì•ŒëžŒì„ í™œì„±í™” 하였습니다!" + disable: "&cì•ŒëžŒì„ ë¹„í™œì„±í™” 하였습니다!" + stats: "&c&lEF: &e플레ì´ì–´ ìºì‹œ: &a%players_cached%&e ì œìž¬ëœ í”Œë ˆì´ì–´: &a%players_punished%" +modules: + custompayload: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f너무 ë§Žì€ CustomPayload íŒ¨í‚·ì´ ê°ì§€ë¨.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f명령어 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f패킷 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &fNull address ê°ì§€.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang ì„œë²„ì— ë¬¸ì œê°€ ìƒê²¼ìŠµë‹ˆë‹¤, ë‚˜ì¤‘ì— ë‹¤ì‹œ 와주세요!\n\n&7사유: &fExploitFixer UUID를 ì°¾ì„ ìˆ˜ 없었습니다.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/nl.yml b/src/main/resources/locales/nl.yml new file mode 100644 index 0000000..cc2ddc5 --- /dev/null +++ b/src/main/resources/locales/nl.yml @@ -0,0 +1,27 @@ +# Dutch - Credits: SBDeveloper +commands: + reload: "&aPlugin ExploitFixer herladen!" + help: |- + &aExploitFixer &b%version%&a door &bLinsaFTW&a. + &e /%command% help &7> &bLaat de beschikbare commando's zien. + &e /%command% reload &7> &bHerlaad de plugin. + &e /%command% notifications &7> &bToggled notificaties van de plugin. + &e /%command% stats &7> &bLaat de statistieken zien van de plugin. + error: + unknown: "&cOnbekend commando. Gebruik /exploitfixer help om de beschikbare commando's te zien!" + permission: "&cJe hebt niet de benodigde permissie om dit commando te gebruiken!" + console: "&cJe kunt dit commando niet vanaf console uitvoeren!" + notifications: + enable: "&aJe hebt notificaties ingeschakeld!" + disable: "&cJe hebt notificaties uitgeschakeld!" + stats: "&c&lEF: &eSpelers gecached: &a%players_cached%&e Spelers gestraft: &a%players_punished%" +modules: + custompayload: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden &fTe veel CustomPayload packets gedetecteerd.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fCommando exploit gedetecteerd.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fPackets exploit gedetecteerd.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fOnbekend adres gedetecteerd.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang servers zijn offline, kom later terug!\n\n&7Reden: &fExploitFixer kan het UUID niet detecteren.\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml new file mode 100644 index 0000000..c99f50d --- /dev/null +++ b/src/main/resources/locales/pl.yml @@ -0,0 +1,27 @@ +# Polish - Credits: Rollczi +commands: + reload: "&aExploitFixer zostaÅ‚ przeÅ‚adowany!" + help: |- + &aExploitFixer &b%version%&a stworzony przez &bLinsaFTW&a. + &e /%command% help &7> &bLista dostÄ™pnych komend. + &e /%command% reload &7> &bPrzeÅ‚adowanie konfiguracji pluginu. + &e /%command% notifications &7> &bWłącza i wyłącza powiadomienia pluginu. + &e /%command% stats &7> &bStatystyki pluginu. + error: + unknown: "&cNieznana komenda. Użyj /exploitfixer help, aby zobaczyć listÄ™ komend!" + permission: "&cNie masz permisji do tej komendy!" + console: "&cTego polecenia nie można wykonać z poziomu konsoli!" + notifications: + enable: "&aWłączono powiadomienia!" + disable: "&cWyłączono powiadomienia!" + stats: "&c&lEF: &eGracze w pamiÄ™ci podrÄ™cznej: &a%players_cached%&e Ukarani gracze : &a%players_punished%" +modules: + custompayload: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto zbyt wiele pakietów CustomPayload.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploit poleceÅ„.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploity dla pakietów.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto \"null address\".\n&7Discord: &b&n%web%&r" +mojang_down: "&cSerwery Mojang przestaÅ‚y dziaÅ‚ać! Spróbuj wejść na serwer później!\n\n&7Powód: &fExploitFixer nie może sprawdzić UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/pt.yml b/src/main/resources/locales/pt.yml new file mode 100644 index 0000000..f71a658 --- /dev/null +++ b/src/main/resources/locales/pt.yml @@ -0,0 +1,27 @@ +# Portuguese - Credits: LucaAzalim +commands: + reload: "&aPlugin ExploitFixer recarregado!" + help: |- + &aExploitFixer &b%version%&a por &bLinsaFTW&a. + &e /%command% help &7> &bComandos disponiveis. + &e /%command% reload &7> &bRecarrega o plugin. + &e /%command% notifications &7> &bAtiva as notificações do plugin. + &e /%command% stats &7> &bVer as estatísticas do plugin. + error: + unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" + permission: "&cSem permissão para usar esse comando!" + console: "&cEsse comando não pode ser executado pelo console!" + notifications: + enable: "&cVocê ativou as notificações!" + disable: "&cVocê desativou as notificações!" + stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" +modules: + custompayload: + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de comandos detectado.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de packets detectado.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de endereço nulo detectado.\n&7Discord: &b&n%web%&r" +mojang_down: "&cOs servidores da Mojang estão indisponíveis. Tente novamente mais tarde.\n\n&7Motivo: &fExploitFixer não pôde confirmar UUID.\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/ro.yml b/src/main/resources/locales/ro.yml new file mode 100644 index 0000000..1e350b0 --- /dev/null +++ b/src/main/resources/locales/ro.yml @@ -0,0 +1,27 @@ +# Romanian Language by DoubleNico +commands: + reload: "&aPluginul ExploitFixer a fost reîncărcat!" + help: |- + &aExploitFixer &b%version%&a creat de &bLinsaFTW&a. + &e /%command% help &7> &bAfiÈ™ează comenzile disponibile. + &e /%command% reload &7> &bReîncărcaÈ›i pluginul. + &e /%command% notifications &7> &bComută notificările despre plugin. + &e /%command% stats &7> &bUrmăriÈ›i statisticile pluginului. + error: + unknown: "&cComanda necunoscută. UtilizaÈ›i /exploitfixer help pentru a vedea comenzile disponibile!" + permission: "&cNu aveÈ›i permisiunea de a utiliza această comandă!" + console: "&cAceastă comandă nu poate fi executată din consola!" + notifications: + enable: "&aAÈ›i activat notificările!" + disable: "&cAveÈ›i notificările dezactivate!" + stats: "&c&lEF: &eJucători cached: &a%players_cached%&e Jucători pedepsiti: &a%players_punished%" +modules: + custompayload: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fPrea multe pachete de tip CustomPayload.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fFolosirea Comenzilor Exploatabile.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fExploatarea pachetelor.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fAdresa null.\n&7Discord: &b&n%web%&r" +mojang_down: "&cServerele Mojang sunt offline, vă rugăm să reveniÈ›i mai târziu!\n\n&7Motiv: &fNu putem detecta adresa UUID.\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/th.yml b/src/main/resources/locales/th.yml new file mode 100644 index 0000000..91f3895 --- /dev/null +++ b/src/main/resources/locales/th.yml @@ -0,0 +1,27 @@ +# Thai (ภาษาไทย) - Credits: Hazuki-san +commands: + reload: "&aปลั๊à¸à¸­à¸´à¸™ ExploitFixer ได้โหลดใหม่à¹à¸¥à¹‰à¸§!" + help: |- + &aExploitFixer &b%version%&a โดย &bLinsaFTW&a + &e /%command% help &7> &bà¹à¸ªà¸”งคำสั่งที่ใช้ได้ + &e /%command% reload &7> &bโหลดปลั๊à¸à¸­à¸´à¸™à¹ƒà¸«à¸¡à¹ˆ + &e /%command% notifications &7> &bเปิดหรือปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนของปลั๊à¸à¸­à¸´à¸™ + &e /%command% stats &7> &bดูสถานะของปลั๊à¸à¸­à¸´à¸™ + error: + unknown: "&cไม่รู้จัà¸à¸„ำสั่งนี้ ใช้ /exploitfixer help เพื่อดูคำสั่งที่สามารถใช้ได้!" + permission: "&cคุณไม่มีสิทธิที่จะใช้คำสั่งนี้!" + console: "&cคำสั่งนี้ไม่สามารถใช้งานในคอลโซลได้!" + notifications: + enable: "&aคุณได้เปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" + disable: "&cคุณได้ปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" + stats: "&c&lEF: &eผู้เล่นที่à¹à¸„ชà¹à¸¥à¹‰à¸§: &a%players_cached%&e ผู้เล่นที่ลงโทษà¹à¸¥à¹‰à¸§: &a%players_punished%" +modules: + custompayload: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบเจอà¹à¸žà¹‡à¸„เà¸à¹‡à¸— CustomPayload มาà¸à¹€à¸à¸´à¸™à¹„ป\n&7ดิสคอร์ด: &b&n%web%&r" + commands: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸„ำสั่งที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" + packets: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¹à¸žà¹‡à¸—เà¸à¹‡à¸—ที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" + nulladdress: + kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸—ี่อยู่ที่ไม่มีค่า\n&7ดิสคอร์ด: &b&n%web%&r" +mojang_down: "&cขณะนี้เซิร์ฟเวอร์ Mojang ใช้งานไม่ได้ ค่อยมาใหม่อีà¸à¸—ีทีหลังนะ!\n\n&7สาเหตุ: &fExploitFixer ไม่สามารถตรวจสอบ UUID ได้\n&7ดิสคอร์ด: &b&n%web%&r" diff --git a/src/main/resources/locales/tr.yml b/src/main/resources/locales/tr.yml new file mode 100644 index 0000000..77da929 --- /dev/null +++ b/src/main/resources/locales/tr.yml @@ -0,0 +1,27 @@ +# Turkish +commands: + reload: "&aPlugin ExploitFixer yeniden yüklendi!" + help: |- + &aExploitFixer &b%version% &ayazan &bLinsaFTW&a. + &e /%command% help &7> &bMevcut komutları gösterir. + &e /%command% reload &7> &bEklentiyi yükler. + &e /%command% notifications &7> &bEklentinin bildirimlerini deÄŸiÅŸtirir. + &e /%command% stats &7> &bEklentinin istatistiklerini izleyin. + error: + unknown: "&cBilinmeyen komut. Kullanılabilir komutları görmek için / exploitfixer yardımını kullanın!" + permission: "&cBu komutu kullanma izniniz yok!" + console: "&cBu komut konsoldan yürütülemez!" + notifications: + enable: "&aBildirimleri etkinleÅŸtirdiniz!" + disable: "&cBildirimleri devre dışı bıraktınız!" + stats: "&c&lEF: &ePlayers önbelleÄŸe alındı: &a%players_cached%&e Players cezalandırıldı: &a%players_punished%" +modules: + custompayload: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang kapalı, kısa süre sonra tekrar gelin!\n\n&7Neden: &fExploitFixer UUID'yi doÄŸrulayamıyor.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/src/main/resources/locales/zh.yml b/src/main/resources/locales/zh.yml new file mode 100644 index 0000000..2d52b2a --- /dev/null +++ b/src/main/resources/locales/zh.yml @@ -0,0 +1,26 @@ +commands: + reload: "&aæˆåŠŸé‡è½½æ’ä»¶ExploitFixer!" + help: |- + &aExploitFixer指令: + &e/%command% help &7- &bS显示帮助指令! + &e/%command% reload &7- &bé‡è½½æ’ä»¶! + &e/%command% notifications &7- &b开关æ’ä»¶æ¶ˆæ¯æé†’! + &e/%command% stats &7- &b查看æ’件统计数æ®! + error: + unknown: "&c未知指令。请使用 /exploitfixer help æ¥æŸ¥çœ‹æŒ‡ä»¤!" + permission: "&c你没有使用这个指令的æƒé™!" + console: "&cè¿™ä¸ªæŒ‡ä»¤æ— æ³•åœ¨æŽ§åˆ¶å°æ‰§è¡Œ!" + notifications: + enable: "&a你已开坿醒!" + disable: "&c你已关闭æé†’!" + stats: "&c&lEF: &e已缓存的玩家: &a%players_cached% &e已被惩罚的玩家: &a%players_punished%" +modules: + custompayload: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到CustomPayloadå‘包过多。\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到滥用指令。\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到å‘包异常。\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&c您被暂时å°ç¦äº†!\n\n&7原因: &f检测到空地å€ã€‚\n&7Discord: &b&n%web%&r" +mojang_down: "&cMojang æœåŠ¡å™¨åœæœºäº†ï¼Œè¯·ç¨åŽå†æ¥çœ‹çœ‹!\n\n&7原因: &fExploitFixer 无法检查UUID。\n&7Discord: &b&n%web%&r" diff --git a/src/main/resources/locales/zhtw.yml b/src/main/resources/locales/zhtw.yml new file mode 100644 index 0000000..fc0ce74 --- /dev/null +++ b/src/main/resources/locales/zhtw.yml @@ -0,0 +1,27 @@ +# Chinese Traditional - Credits: Flandre_tw +commands: + reload: "&aExploitFixer 已經æˆåŠŸè¼‰å…¥ ï¼" + help: |- + &aExploitFixer 指令 : + &e /%command% help &7> &b顯示說明指令。 + &e /%command% reload &7> &b釿–°è¼‰å…¥æ’件。 + &e /%command% notifications &7> &bé–‹é—œæ’ä»¶æé†’通知。 + &e /%command% stats &7> &b查看æ’件統計資料。 + error: + unknown: "&c未知的指令。請使用 /exploitfixer help 查看指令說明 ï¼" + permission: "&cä½ æ²’æœ‰ä½¿ç”¨è©²æŒ‡ä»¤çš„æ¬Šé™ ï¼" + console: "&c該指令無法在控制å°åŸ·è¡Œ ï¼" + notifications: + enable: "&a你已開啟æé†’通知 ï¼" + disable: "&c你已關閉æé†’通知 ï¼" + stats: "&c&lEF : &e已快å–的玩家 : &a%players_cached% &e已被懲罰的玩家 : &a%players_punished%" +modules: + custompayload: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到éŽå¤šçš„ CustomPayload å°åŒ…。\n&7Discord : &b&n%web%&r" + commands: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到濫用指令。\n&7Discord : &b&n%web%&r" + packets: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到å°åŒ…異常。\n&7Discord : &b&n%web%&r" + nulladdress: + kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到空的ä½å€ã€‚\n&7Discord : &b&n%web%&r" +mojang_down: "&cMojang 伺æœå™¨é›¢ç·šï¼Œè«‹ç¨å¾Œå†æŸ¥çœ‹ ï¼ \n\n&7原因 : &fExploitFixer 無法檢查 UUID。\n&7Discord : &b&n%web%&r" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..59e7501 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,14 @@ +name: ${name} +description: ${description} +author: ${author} +version: ${version} +url: ${url} +main: dev._2lstudios.exploitfixer.ExploitFixer +api: "1.13" +api-version: "1.13" +softdepend: [HamsterAPI] +commands: + exploitfixer: + description: The main ExploitFixer command + usage: /exploitfixer + aliases: [ef] From db68eea44bc0df6c5d91bbdcdf6c4a8316b4c85d Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 22:21:46 -0300 Subject: [PATCH 237/336] delete old configs --- resources/config.yml | 181 ------------------------------------- resources/locales/de.yml | 27 ------ resources/locales/en.yml | 27 ------ resources/locales/es.yml | 27 ------ resources/locales/fr.yml | 27 ------ resources/locales/hu.yml | 26 ------ resources/locales/it.yml | 27 ------ resources/locales/ja.yml | 27 ------ resources/locales/ko.yml | 27 ------ resources/locales/nl.yml | 27 ------ resources/locales/pl.yml | 27 ------ resources/locales/pt.yml | 27 ------ resources/locales/ro.yml | 27 ------ resources/locales/th.yml | 27 ------ resources/locales/tr.yml | 27 ------ resources/locales/zh.yml | 26 ------ resources/locales/zhtw.yml | 27 ------ resources/plugin.yml | 12 --- 18 files changed, 623 deletions(-) delete mode 100644 resources/config.yml delete mode 100644 resources/locales/de.yml delete mode 100644 resources/locales/en.yml delete mode 100644 resources/locales/es.yml delete mode 100644 resources/locales/fr.yml delete mode 100644 resources/locales/hu.yml delete mode 100644 resources/locales/it.yml delete mode 100644 resources/locales/ja.yml delete mode 100644 resources/locales/ko.yml delete mode 100644 resources/locales/nl.yml delete mode 100644 resources/locales/pl.yml delete mode 100644 resources/locales/pt.yml delete mode 100644 resources/locales/ro.yml delete mode 100644 resources/locales/th.yml delete mode 100644 resources/locales/tr.yml delete mode 100644 resources/locales/zh.yml delete mode 100644 resources/locales/zhtw.yml delete mode 100644 resources/plugin.yml diff --git a/resources/config.yml b/resources/config.yml deleted file mode 100644 index 82d1ca0..0000000 --- a/resources/config.yml +++ /dev/null @@ -1,181 +0,0 @@ -# ExploitFixer by LinsaFTW -# Please help by donating, we require funds to continue with the development. -# https://paypal.me/LinsaFTW -# -# INSTALL THE PLUGIN ON ALL BUKKIT SERVERS! -# -# Most of the check use Violations (vls), this a counter to execute different -# actions on diverse levels to allow high customization of the modules. - -# Default language used by the plugin (This changes depending on the client language) -locale: "en" - -# Web link used on the messages -web: "discord.gg/gF36AT3" - -# Shows notifications to console and players with permissions. -notifications: - enabled: true - - # Placeholders: %player% %ping% %check% %vls% - message: "&c&lEF: &e%player% &7(&a%ping%ms&7) &ffailed &6%check% &7(&c%vls% vls&7)" - - # This shows extra information about blocked packets. - debug: false - -# Prevents exploits that occur on different Bukkit events. -events: - # Prevents moving if the chunk is null. (Prevents chunk overloading) - null_chunk: true - - # Prevents players from damaging themselves and consuming ram. - self_damage: true - - # Prevents maps from tracking fixing many crash exploits - disable_tracking: true - -# Prevents the use of invalid packets to crash the server. -packets: - enabled: true - - # Amount of vls required to start cancelling packets. - cancel_vls: 25 - - # Amount of vls to reduce per second. - reduce_vls: 25 - - # Cancels packets if the player sending them is offline. - offline: true - - # This will check if integers, floats, doubles and items have a invalid size in packets. - data: - # Vls to add when a packet fails the check. (Set to -1 to disable) - vls: 100 - - # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 64000 - - # Maximum amount of bytes allowed per book page. (Set to -1 to disable) - bytes_book: 300 - - # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) - bytes_sign: 47 - - # This option adds vls per byte received. - # Vls to add per byte received. (Set to -1 to disable) - vl_multiplier: 0.0001 - - # Cancels book packets when a book is not in hand - # Vls to add when a packet fails the check. (Set to -1 to disable) - book: 10 - - # Cancels CustomPayload packets with invalid tags - # Vls to add when a packet fails the check. (Set to -1 to disable) - tag: 100 - - # Checks if players send PacketPlayInWindowClick packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - window_click: 100 - - # Checks if players send PacketPlayInBlockPlace packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_place: 100 - - # Checks if players send PacketPlayInBlockDig packets with invalid data. - # Vls to add when a packet fails the check. (Set to -1 to disable) - block_dig: 100 - - # Checks if players send PacketPlayInCreativeSlot packets without creative. - # Vls to add when a packet fails the check. (Set to -1 to disable) - set_creative_slot: 100 - - # Vls to add when a normal packet is sent by a player. - # This option is made to work as a packet limiter feature. - # Unlisted packets are considered as "PacketPlayInOther" by default. - # Remember to take a look at bytes_divider option. - multipliers: - PacketPlayInOther: 0.1 - MC|BSign: 4.5 - MC|BEdit: 4.5 - MC|BOpen: 4.5 - PacketPlayInAutoRecipe: 10 - PacketPlayInUpdateSign: 5 - PacketPlayInAbilities: 0.25 - PacketPlayInArmAnimation: 0.05 - PacketPlayInBlockDig: 0.5 - PacketPlayInBlockPlace: 0.5 - PacketPlayInCustomPayload: 0.01 - PacketPlayInEntityAction: 0.5 - PacketPlayInFlying: 0.25 - PacketPlayInLook: 0.5 - PacketPlayInPositionLook: 0.05 - PacketPlayInPosition: 0.2 - PacketPlayInSetCreativeSlot: 0.15 - PacketPlayInSettings: 0.5 - PacketPlayInTabComplete: 0.75 - PacketPlayInUseEntity: 0.5 - PacketPlayInUseItem: 1 - PacketPlayInWindowClick: 0.65 - - # These packets will be completely cancelled. - blacklist: - - "PacketPlayInAutoRecipe" - - # Placeholders: %player%, %vl%, %ping%, %check% - # Commands to run when a player reaches certain violation level. - violations: - 25: - - "notification" - 50: - - "notification" - 75: - - "notification" - 100: - - "notification" - - "kick" - -# Removes custom NBT tags from creative items to prevent harm to your server. -# Negative enchant values will always be removed. -itemsfix: - enabled: true - - # Maximum stack size obtainable with creative packets. (-1 to allow anything) - max_stack_size: 64 - - # Maximum enchant level obtainable with creative packets. - # -1 removes all enchants, 0 forces vanilla values - enchant_limit: 0 - - # List of materials that are unobtainable from Creative. - blacklist: - - "END_PORTAL" - - "NETHER_PORTAL" - # - "BARRIER" - # - "COMMAND_BLOCK" - -# Checks if players try to crash/exploit the server with commands. -commands: - enabled: true - - # Commands that are exempt from this server. - commands: - - "//calc" - - "//calculate" - - "//eval" - - "//evaluate" - - "//solve" - - "/hd readtext" - - "/holo readtext" - - "/hologram readtext" - - "/holograms readtext" - - "/holographicdisplays readtext" - - "/pex promote" - - "/pex demote" - - "/promote" - - "/demote" - - "/execute" - - # Placeholders: %player% - punishments: - - "notification" - - "kick" diff --git a/resources/locales/de.yml b/resources/locales/de.yml deleted file mode 100644 index 8423527..0000000 --- a/resources/locales/de.yml +++ /dev/null @@ -1,27 +0,0 @@ -# German - Credits: Dominik48N / NoJokeFNA / GeGrieftGames -commands: - reload: "&aPlugin ExploitFixer wurde neu geladen!" - help: |- - &aExploitFixer &b%version%&a von &bLinsaFTW&a. - &e /%command% help &7> &bZeigt alle verfügbaren Befehle an. - &e /%command% reload &7> &bLädt das Plugin neu. - &e /%command% notifications &7> &bSchaltet Benachrichtigungen des Plugins um. - &e /%command% stats &7> &bZeigt die Statistiken des Plugins an. - error: - unknown: "&cUnbekannter Befehl. Nutze /exploitfixer help um die verfügbaren Befehle aufzulisten!" - permission: "&cDu darfst diesen Befehl nicht ausführen!" - console: "&cDieser Befehl darf nicht von der Konsole ausgeführt werden!" - notifications: - enable: "&aDu hast die Benachrichtigungen aktiviert!" - disable: "&cDu hast die Benachrichtigungen deaktiviert!" - stats: "&c&lEF: &eZwischengespeicherte Spieler: &a%players_cached%&e Bestrafte Spieler: &a%players_punished%" -modules: - custompayload: - kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fZu viele CustomPayload Packete wurden erkannt.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fBefehl Exploit erkannt.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fPacket Exploit erkannt.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cDu bist temporär vom Server gesperrt!\n\n&7Grund: &fNulladresse erkannt.\n&7Discord: &b&n%web%&r" -mojang_down: "&cDie Mojang Server sind nicht verfügbar, versuche es später erneut!\n\n&7Grund: &fExploitFixer kann die UUID nicht überprüfen.\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/en.yml b/resources/locales/en.yml deleted file mode 100644 index e41654f..0000000 --- a/resources/locales/en.yml +++ /dev/null @@ -1,27 +0,0 @@ -# English - Credits: LinsaFTW -commands: - reload: "&aPlugin ExploitFixer reloaded!" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW&a. - &e /%command% help &7> &bShows available commands. - &e /%command% reload &7> &bReloads the plugin. - &e /%command% notifications &7> &bToggles notifications of the plugin. - &e /%command% stats &7> &bWatch the stats of the plugin. - error: - unknown: "&cUnknown command. Use /exploitfixer help to see available commands!" - permission: "&cYou dont have permission to use this command!" - console: "&cThis command cant be executed from the console!" - notifications: - enable: "&aYou have enabled notifications!" - disable: "&cYou have disabled notifications!" - stats: "&c&lEF: &ePlayers cached: &a%players_cached%&e Players punished: &a%players_punished%" -modules: - custompayload: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cYou are temporally blocked from this server!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang servers are down, please come back later!\n\n&7Reason: &fExploitFixer can't check the UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/es.yml b/resources/locales/es.yml deleted file mode 100644 index b859bf1..0000000 --- a/resources/locales/es.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Spanish - Credits: LinsaFTW -commands: - reload: "&aPlugin ExploitFixer recargado!" - help: |- - &aExploitFixer &b%version%&a por &bLinsaFTW&a. - &e /%command% help &7> &bMuestra los comandos disponibles. - &e /%command% reload &7> &bRecarga el plugin. - &e /%command% notifications &7> &bAlterna las notificaciones del plugin. - &e /%command% stats &7> &bMira las estadisticas del plugin. - error: - unknown: "&cComando desconocido. Usa /exploitfixer help para ver comandos disponibles!" - permission: "&cNo tienes permiso para usar ese comando!" - console: "&cEste comando no puede ser usado desde la consola!" - notifications: - enable: "&aHabilitaste las notificaciones!" - disable: "&cDeshabilitaste las notificaciones!" - stats: "&c&lEF: &eJugadores en cache: &a%players_cached%&e Jugadores sancionados: &a%players_punished%" -modules: - custompayload: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Comandos detectado.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Packets detectado.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cFuiste bloqueado temporalmente!\n\n&7Razon: &fExploit de Red nula detectado.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang esta apagado, vuelve pronto!\n\n&7Razon: &fExploitFixer no puede confirmar la UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/fr.yml b/resources/locales/fr.yml deleted file mode 100644 index 61c2a02..0000000 --- a/resources/locales/fr.yml +++ /dev/null @@ -1,27 +0,0 @@ -# French - Credits: HaVroz -commands: - reload: "&aPlugin Exploitfixer rechargé!" - help: |- - &aExploitFixer &b%version%&a par &bLinsaFTW&a. - &e /%command% help &7> &bAfficher les commandes disponibles. - &e /%command% reload &7> &bRecharger le plugin. - &e /%command% notifications &7> &bActiver/Désactiver les notifications du plugin. - &e /%command% stats &7> &bVoir les statistiques du plugin. - error: - unknown: "&cCommande inconnue. Utilisez /exploitfixer help pour voir les commandes disponibles!" - permission: "&cVous n’avez pas la permission d’utiliser cette commande!" - console: "&cCette commande ne peut pas être exécutée depuis la console!" - notifications: - enable: "&aVous avez activé les notifications!" - disable: "&cVous avez désactivé les notifications!" - stats: "&c&lEF: &eJoueurs caché: &a%players_cached%&e Joueurs sanctionné: &a%players_punished%" -modules: - custompayload: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fTrop de paquets Custompayload détectés.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de commande détecté.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fExploit de Packets détecté.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cVous êtes temporairement bloqué du serveur!\n\n&7Raison: &fAdresse nulle détectée.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang est désactivé, revenez bientôt!\n\n&7Raison: &fExploitFixer ne peut pas confirmer l'UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/hu.yml b/resources/locales/hu.yml deleted file mode 100644 index 0f81960..0000000 --- a/resources/locales/hu.yml +++ /dev/null @@ -1,26 +0,0 @@ -#Hungarian -commands: - reload: "&aAz ExploitFixer sikeresen újraindult!" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW&a. - &e /%command% help &7> &bElérhetÅ‘ parancsok. - &e /%command% reload &7> &bPlugin újraindítása. - &e /%command% notifications &7> &bÉrtesítések ki/be kapcsolása. - &e /%command% stats &7> &bA plugin statisztikáinak megtekintése. - error: - unknown: "&cIsmeretlen parancs. Használd a /exploitfixer help parancsot!" - permission: "&cNincs jogod a parancs használatához!" - console: "&cEzt a parancsot nem bírod használni a konzolból!" - notifications: - enable: "&aBekapcsoltad az értesítéseket!" - disable: "&cKikapcsoltad az értesítéseket!" - stats: "&c&lEF: &eJátékosok: &a%players_cached%&e Büntetések: &a%players_punished%" -modules: - custompayload: - kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fTúl sok CustomPayload csomagot észleltünk.\n&7Discord: &b&n%discord%&r" - commands: - kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fParancs exploitot észleltünk.\n&7Discord: &b&n%discord%&r" - packets: - kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fCsomag exploitot észleltünk.\n&7Discord: &b&n%discord%&r" - nulladdress: - kick_message: "&cKi lettél rúgva a szerverrÅ‘l!\n\n&7Reason: &fNull addresst észleltünk.\n&7Discord: &b&n%discord%&r" \ No newline at end of file diff --git a/resources/locales/it.yml b/resources/locales/it.yml deleted file mode 100644 index 8c63bf4..0000000 --- a/resources/locales/it.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Italian -commands: - reload: "&aPlugin ExploitFixer ricaricato!" - help: |- - &aExploitFixer &b%version%&a da parte di &bLinsaFTW&a. - &e /%command% help &7> &bMostra i commandi disponibili. - &e /%command% reload &7> &bRicarica il plugin. - &e /%command% notifications &7> &bCambia le notifiche del plugin. - &e /%command% stats &7> &bMostra le statistiche del plugin. - error: - unknown: "&cCommando sconosciuto. Usa /exploitfixer help per vedere i commandi disponibili!" - permission: "&cNon hai il permesso per questo commando!" - console: "&cQuesto commando non può essere eseguito dalla console!" - notifications: - enable: "&aHai abilitato le notifiche!" - disable: "&cHai disabilitato le notifiche!" - stats: "&c&lEF: &eGiocatori in cache: &a%players_cached%&e Giocatori puniti: &a%players_punished%" -modules: - custompayload: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fTroppi pacchetti CustomPayload.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di commandi rilevati.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fExploit di pacchetti rilevati.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cSei stato temporaneamente bloccato da questo server!\n\n&7Motivo: &fIndirizzo null rilevato.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang è disattivato, torna presto!\n\n&7Reason: &fExploitFixer non può confermare l'UUID. \n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/ja.yml b/resources/locales/ja.yml deleted file mode 100644 index 9057844..0000000 --- a/resources/locales/ja.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Japanese - Credits: cosmos223 -commands: - reload: "&aプラグイン ExploitFixer をリロードã—ã¾ã—ãŸã€‚" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW - &e /%command% help &7> &b使用å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’表示ã—ã¾ã™ã€‚ - &e /%command% reload &7> &bプラグインをリロードã—ã¾ã™ã€‚ - &e /%command% notifications &7> &bプラグインã®é€šçŸ¥ã‚’切り替ãˆã¾ã™ã€‚ - &e /%command% stats &7> &bプラグインã®çµ±è¨ˆæƒ…報を表示ã—ã¾ã™ã€‚ - error: - unknown: "&c䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ /exploitfixer help ã¨å…¥åŠ›ã—ã¦ä½¿ç”¨å¯èƒ½ãªã‚³ãƒžãƒ³ãƒ‰ã‚’確èªã—ã¦ãã ã•ã„。" - permission: "&c権é™ãŒã‚りã¾ã›ã‚“。" - console: "&cã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰å®Ÿè¡Œã§ãã¾ã›ã‚“。" - notifications: - enable: "&a通知を有効ã«ã—ã¾ã—ãŸã€‚" - disable: "&c通知を無効ã«ã—ã¾ã—ãŸã€‚" - stats: "&c&lEF: &eキャッシュã•れãŸãƒ—レイヤー: &a%players_cached%&e ç½°ã›ã‚‰ã‚ŒãŸãƒ—レイヤー: &a%players_punished%" -modules: - custompayload: - kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fCustomPayloadパケットãŒå¤šã検出ã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fコマンドã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fパケットã®è„†å¼±æ€§ã‚’使用ã—ãŸã“ã¨ã‚’検出ã—ã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cã‚ãªãŸã¯ã“ã®ã‚µãƒ¼ãƒãƒ¼ã‹ã‚‰ä¸€æ™‚çš„ã«ãƒ–ロックã•れã¦ã„ã¾ã™ã€‚\n\n&7ç†ç”±: &fNullã‚¢ãƒ‰ãƒ¬ã‚¹ãŒæ¤œå‡ºã•れã¾ã—ãŸã€‚\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojangã®ã‚µãƒ¼ãƒãƒ¼ãŒå¿œç­”ã—ã¦ã„ã¾ã›ã‚“。時間を置ã„ã¦ã‹ã‚‰å†åº¦æŽ¥ç¶šã—ã¦ãã ã•ã„。\n\n&7ç†ç”±: &fExploitFixer 㯠UUID を確èªã§ãã¾ã›ã‚“ã§ã—ãŸã€‚\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/ko.yml b/resources/locales/ko.yml deleted file mode 100644 index 3033a2b..0000000 --- a/resources/locales/ko.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Korean -commands: - reload: "&aExploitFixer 플러그ì¸ì´ 리로드ë˜ì—ˆìŠµë‹ˆë‹¤!" - help: |- - &aExploitFixer &b%version%&a by &bLinsaFTW&a. - &e /%command% help &7> &b사용 가능 명령어를 표시합니다. - &e /%command% reload &7> &b플러그ì¸ì„ 다시 로드합니다. - &e /%command% notifications &7> &bí”ŒëŸ¬ê·¸ì¸ ì•ŒëžŒì„ í† ê¸€í•©ë‹ˆë‹¤. - &e /%command% stats &7> &b플레ì´ì–´ ìž‘ë™ í˜„í™©ì„ í™•ì¸í•©ë‹ˆë‹¤. - error: - unknown: "&c알 수 없는 명령어입니다. /exploitfixer help 명령어를 통해 사용 가능한 명령어를 확ì¸í•˜ì„¸ìš”!" - permission: "&cë‹¹ì‹ ì€ ì´ ëª…ë ¹ì–´ë¥¼ 사용할 ê¶Œí•œì´ ëª¨ìžëžë‹ˆë‹¤!" - console: "&cì´ ëª…ë ¹ì–´ëŠ” 콘솔ì—서 입력할 수 없습니다!" - notifications: - enable: "&aì•ŒëžŒì„ í™œì„±í™” 하였습니다!" - disable: "&cì•ŒëžŒì„ ë¹„í™œì„±í™” 하였습니다!" - stats: "&c&lEF: &e플레ì´ì–´ ìºì‹œ: &a%players_cached%&e ì œìž¬ëœ í”Œë ˆì´ì–´: &a%players_punished%" -modules: - custompayload: - kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f너무 ë§Žì€ CustomPayload íŒ¨í‚·ì´ ê°ì§€ë¨.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f명령어 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &f패킷 ì·¨ì•½ì  ê°ì§€.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cë‹¹ì‹ ì€ ì´ ì„œë²„ì—서 ì¼ì‹œì ìœ¼ë¡œ 차단ë˜ì—ˆìŠµë‹ˆë‹¤!\n\n&7사유: &fNull address ê°ì§€.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang ì„œë²„ì— ë¬¸ì œê°€ ìƒê²¼ìŠµë‹ˆë‹¤, ë‚˜ì¤‘ì— ë‹¤ì‹œ 와주세요!\n\n&7사유: &fExploitFixer UUID를 ì°¾ì„ ìˆ˜ 없었습니다.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/nl.yml b/resources/locales/nl.yml deleted file mode 100644 index cc2ddc5..0000000 --- a/resources/locales/nl.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Dutch - Credits: SBDeveloper -commands: - reload: "&aPlugin ExploitFixer herladen!" - help: |- - &aExploitFixer &b%version%&a door &bLinsaFTW&a. - &e /%command% help &7> &bLaat de beschikbare commando's zien. - &e /%command% reload &7> &bHerlaad de plugin. - &e /%command% notifications &7> &bToggled notificaties van de plugin. - &e /%command% stats &7> &bLaat de statistieken zien van de plugin. - error: - unknown: "&cOnbekend commando. Gebruik /exploitfixer help om de beschikbare commando's te zien!" - permission: "&cJe hebt niet de benodigde permissie om dit commando te gebruiken!" - console: "&cJe kunt dit commando niet vanaf console uitvoeren!" - notifications: - enable: "&aJe hebt notificaties ingeschakeld!" - disable: "&cJe hebt notificaties uitgeschakeld!" - stats: "&c&lEF: &eSpelers gecached: &a%players_cached%&e Spelers gestraft: &a%players_punished%" -modules: - custompayload: - kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden &fTe veel CustomPayload packets gedetecteerd.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fCommando exploit gedetecteerd.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fPackets exploit gedetecteerd.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cJe bent tijdelijk geblokkeerd van deze server!\n\n&7Reden: &fOnbekend adres gedetecteerd.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang servers zijn offline, kom later terug!\n\n&7Reden: &fExploitFixer kan het UUID niet detecteren.\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/pl.yml b/resources/locales/pl.yml deleted file mode 100644 index c99f50d..0000000 --- a/resources/locales/pl.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Polish - Credits: Rollczi -commands: - reload: "&aExploitFixer zostaÅ‚ przeÅ‚adowany!" - help: |- - &aExploitFixer &b%version%&a stworzony przez &bLinsaFTW&a. - &e /%command% help &7> &bLista dostÄ™pnych komend. - &e /%command% reload &7> &bPrzeÅ‚adowanie konfiguracji pluginu. - &e /%command% notifications &7> &bWłącza i wyłącza powiadomienia pluginu. - &e /%command% stats &7> &bStatystyki pluginu. - error: - unknown: "&cNieznana komenda. Użyj /exploitfixer help, aby zobaczyć listÄ™ komend!" - permission: "&cNie masz permisji do tej komendy!" - console: "&cTego polecenia nie można wykonać z poziomu konsoli!" - notifications: - enable: "&aWłączono powiadomienia!" - disable: "&cWyłączono powiadomienia!" - stats: "&c&lEF: &eGracze w pamiÄ™ci podrÄ™cznej: &a%players_cached%&e Ukarani gracze : &a%players_punished%" -modules: - custompayload: - kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto zbyt wiele pakietów CustomPayload.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploit poleceÅ„.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto exploity dla pakietów.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cZostaÅ‚eÅ› tymczasowo zablokowany na tym serwerze!\n\n&7Powód: &fWykryto \"null address\".\n&7Discord: &b&n%web%&r" -mojang_down: "&cSerwery Mojang przestaÅ‚y dziaÅ‚ać! Spróbuj wejść na serwer później!\n\n&7Powód: &fExploitFixer nie może sprawdzić UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/pt.yml b/resources/locales/pt.yml deleted file mode 100644 index f71a658..0000000 --- a/resources/locales/pt.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Portuguese - Credits: LucaAzalim -commands: - reload: "&aPlugin ExploitFixer recarregado!" - help: |- - &aExploitFixer &b%version%&a por &bLinsaFTW&a. - &e /%command% help &7> &bComandos disponiveis. - &e /%command% reload &7> &bRecarrega o plugin. - &e /%command% notifications &7> &bAtiva as notificações do plugin. - &e /%command% stats &7> &bVer as estatísticas do plugin. - error: - unknown: "&cComando desconhecido. Use /exploitfixer para ver os comandos disponiveis!" - permission: "&cSem permissão para usar esse comando!" - console: "&cEsse comando não pode ser executado pelo console!" - notifications: - enable: "&cVocê ativou as notificações!" - disable: "&cVocê desativou as notificações!" - stats: "&c&lEF: &eJogadores em cache: &a%players_cached%&e Jogadores punidos: &a%players_punished%" -modules: - custompayload: - kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de CustomPayload detectado.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de comandos detectado.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cVocê está temporariamente bloqueado!\n\n&7Motivo: &fExploit de packets detectado.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cVocê foi temporariamente bloqueado!\n\n&7Motivo: &fExploit de endereço nulo detectado.\n&7Discord: &b&n%web%&r" -mojang_down: "&cOs servidores da Mojang estão indisponíveis. Tente novamente mais tarde.\n\n&7Motivo: &fExploitFixer não pôde confirmar UUID.\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/ro.yml b/resources/locales/ro.yml deleted file mode 100644 index 1e350b0..0000000 --- a/resources/locales/ro.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Romanian Language by DoubleNico -commands: - reload: "&aPluginul ExploitFixer a fost reîncărcat!" - help: |- - &aExploitFixer &b%version%&a creat de &bLinsaFTW&a. - &e /%command% help &7> &bAfiÈ™ează comenzile disponibile. - &e /%command% reload &7> &bReîncărcaÈ›i pluginul. - &e /%command% notifications &7> &bComută notificările despre plugin. - &e /%command% stats &7> &bUrmăriÈ›i statisticile pluginului. - error: - unknown: "&cComanda necunoscută. UtilizaÈ›i /exploitfixer help pentru a vedea comenzile disponibile!" - permission: "&cNu aveÈ›i permisiunea de a utiliza această comandă!" - console: "&cAceastă comandă nu poate fi executată din consola!" - notifications: - enable: "&aAÈ›i activat notificările!" - disable: "&cAveÈ›i notificările dezactivate!" - stats: "&c&lEF: &eJucători cached: &a%players_cached%&e Jucători pedepsiti: &a%players_punished%" -modules: - custompayload: - kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fPrea multe pachete de tip CustomPayload.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fFolosirea Comenzilor Exploatabile.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fExploatarea pachetelor.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cSunteÈ›i blocat temporar de pe acest server!\n\n&7Motiv: &fAdresa null.\n&7Discord: &b&n%web%&r" -mojang_down: "&cServerele Mojang sunt offline, vă rugăm să reveniÈ›i mai târziu!\n\n&7Motiv: &fNu putem detecta adresa UUID.\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/th.yml b/resources/locales/th.yml deleted file mode 100644 index 91f3895..0000000 --- a/resources/locales/th.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Thai (ภาษาไทย) - Credits: Hazuki-san -commands: - reload: "&aปลั๊à¸à¸­à¸´à¸™ ExploitFixer ได้โหลดใหม่à¹à¸¥à¹‰à¸§!" - help: |- - &aExploitFixer &b%version%&a โดย &bLinsaFTW&a - &e /%command% help &7> &bà¹à¸ªà¸”งคำสั่งที่ใช้ได้ - &e /%command% reload &7> &bโหลดปลั๊à¸à¸­à¸´à¸™à¹ƒà¸«à¸¡à¹ˆ - &e /%command% notifications &7> &bเปิดหรือปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนของปลั๊à¸à¸­à¸´à¸™ - &e /%command% stats &7> &bดูสถานะของปลั๊à¸à¸­à¸´à¸™ - error: - unknown: "&cไม่รู้จัà¸à¸„ำสั่งนี้ ใช้ /exploitfixer help เพื่อดูคำสั่งที่สามารถใช้ได้!" - permission: "&cคุณไม่มีสิทธิที่จะใช้คำสั่งนี้!" - console: "&cคำสั่งนี้ไม่สามารถใช้งานในคอลโซลได้!" - notifications: - enable: "&aคุณได้เปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" - disable: "&cคุณได้ปิดà¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•ือนà¹à¸¥à¹‰à¸§!" - stats: "&c&lEF: &eผู้เล่นที่à¹à¸„ชà¹à¸¥à¹‰à¸§: &a%players_cached%&e ผู้เล่นที่ลงโทษà¹à¸¥à¹‰à¸§: &a%players_punished%" -modules: - custompayload: - kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบเจอà¹à¸žà¹‡à¸„เà¸à¹‡à¸— CustomPayload มาà¸à¹€à¸à¸´à¸™à¹„ป\n&7ดิสคอร์ด: &b&n%web%&r" - commands: - kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸„ำสั่งที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" - packets: - kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¹à¸žà¹‡à¸—เà¸à¹‡à¸—ที่มีช่องโหว่\n&7ดิสคอร์ด: &b&n%web%&r" - nulladdress: - kick_message: "&cคุณถูà¸à¸šà¸¥à¹Šà¸­à¸à¸ˆà¸²à¸à¹€à¸‹à¸´à¸£à¹Œà¸Ÿà¹€à¸§à¸­à¸£à¹Œà¸Šà¸±à¹ˆà¸§à¸„ราว!\n\n&7สาเหตุ: &fตรวจพบà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸—ี่อยู่ที่ไม่มีค่า\n&7ดิสคอร์ด: &b&n%web%&r" -mojang_down: "&cขณะนี้เซิร์ฟเวอร์ Mojang ใช้งานไม่ได้ ค่อยมาใหม่อีà¸à¸—ีทีหลังนะ!\n\n&7สาเหตุ: &fExploitFixer ไม่สามารถตรวจสอบ UUID ได้\n&7ดิสคอร์ด: &b&n%web%&r" diff --git a/resources/locales/tr.yml b/resources/locales/tr.yml deleted file mode 100644 index 77da929..0000000 --- a/resources/locales/tr.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Turkish -commands: - reload: "&aPlugin ExploitFixer yeniden yüklendi!" - help: |- - &aExploitFixer &b%version% &ayazan &bLinsaFTW&a. - &e /%command% help &7> &bMevcut komutları gösterir. - &e /%command% reload &7> &bEklentiyi yükler. - &e /%command% notifications &7> &bEklentinin bildirimlerini deÄŸiÅŸtirir. - &e /%command% stats &7> &bEklentinin istatistiklerini izleyin. - error: - unknown: "&cBilinmeyen komut. Kullanılabilir komutları görmek için / exploitfixer yardımını kullanın!" - permission: "&cBu komutu kullanma izniniz yok!" - console: "&cBu komut konsoldan yürütülemez!" - notifications: - enable: "&aBildirimleri etkinleÅŸtirdiniz!" - disable: "&cBildirimleri devre dışı bıraktınız!" - stats: "&c&lEF: &ePlayers önbelleÄŸe alındı: &a%players_cached%&e Players cezalandırıldı: &a%players_punished%" -modules: - custompayload: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fBirçok CustomPayload paketi algılandı.\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fKomuttan yararlanma algılandı.\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fPackets istismar tespit edildi.\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&cBu sunucudan geçici olarak engellendiniz!\n\n&7Reason: &fNull adres algılandı.\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang kapalı, kısa süre sonra tekrar gelin!\n\n&7Neden: &fExploitFixer UUID'yi doÄŸrulayamıyor.\n&7Discord: &b&n%web%&r" \ No newline at end of file diff --git a/resources/locales/zh.yml b/resources/locales/zh.yml deleted file mode 100644 index 2d52b2a..0000000 --- a/resources/locales/zh.yml +++ /dev/null @@ -1,26 +0,0 @@ -commands: - reload: "&aæˆåŠŸé‡è½½æ’ä»¶ExploitFixer!" - help: |- - &aExploitFixer指令: - &e/%command% help &7- &bS显示帮助指令! - &e/%command% reload &7- &bé‡è½½æ’ä»¶! - &e/%command% notifications &7- &b开关æ’ä»¶æ¶ˆæ¯æé†’! - &e/%command% stats &7- &b查看æ’件统计数æ®! - error: - unknown: "&c未知指令。请使用 /exploitfixer help æ¥æŸ¥çœ‹æŒ‡ä»¤!" - permission: "&c你没有使用这个指令的æƒé™!" - console: "&cè¿™ä¸ªæŒ‡ä»¤æ— æ³•åœ¨æŽ§åˆ¶å°æ‰§è¡Œ!" - notifications: - enable: "&a你已开坿醒!" - disable: "&c你已关闭æé†’!" - stats: "&c&lEF: &e已缓存的玩家: &a%players_cached% &e已被惩罚的玩家: &a%players_punished%" -modules: - custompayload: - kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到CustomPayloadå‘包过多。\n&7Discord: &b&n%web%&r" - commands: - kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到滥用指令。\n&7Discord: &b&n%web%&r" - packets: - kick_message: "&c你被暂时å°ç¦äº†!\n\n&7原因: &f检测到å‘包异常。\n&7Discord: &b&n%web%&r" - nulladdress: - kick_message: "&c您被暂时å°ç¦äº†!\n\n&7原因: &f检测到空地å€ã€‚\n&7Discord: &b&n%web%&r" -mojang_down: "&cMojang æœåŠ¡å™¨åœæœºäº†ï¼Œè¯·ç¨åŽå†æ¥çœ‹çœ‹!\n\n&7原因: &fExploitFixer 无法检查UUID。\n&7Discord: &b&n%web%&r" diff --git a/resources/locales/zhtw.yml b/resources/locales/zhtw.yml deleted file mode 100644 index fc0ce74..0000000 --- a/resources/locales/zhtw.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Chinese Traditional - Credits: Flandre_tw -commands: - reload: "&aExploitFixer 已經æˆåŠŸè¼‰å…¥ ï¼" - help: |- - &aExploitFixer 指令 : - &e /%command% help &7> &b顯示說明指令。 - &e /%command% reload &7> &b釿–°è¼‰å…¥æ’件。 - &e /%command% notifications &7> &bé–‹é—œæ’ä»¶æé†’通知。 - &e /%command% stats &7> &b查看æ’件統計資料。 - error: - unknown: "&c未知的指令。請使用 /exploitfixer help 查看指令說明 ï¼" - permission: "&cä½ æ²’æœ‰ä½¿ç”¨è©²æŒ‡ä»¤çš„æ¬Šé™ ï¼" - console: "&c該指令無法在控制å°åŸ·è¡Œ ï¼" - notifications: - enable: "&a你已開啟æé†’通知 ï¼" - disable: "&c你已關閉æé†’通知 ï¼" - stats: "&c&lEF : &e已快å–的玩家 : &a%players_cached% &e已被懲罰的玩家 : &a%players_punished%" -modules: - custompayload: - kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到éŽå¤šçš„ CustomPayload å°åŒ…。\n&7Discord : &b&n%web%&r" - commands: - kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到濫用指令。\n&7Discord : &b&n%web%&r" - packets: - kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到å°åŒ…異常。\n&7Discord : &b&n%web%&r" - nulladdress: - kick_message: "&c你暫時被伺æœå™¨è¸¢å‡º ï¼ \n\n&7原因 : &f檢測到空的ä½å€ã€‚\n&7Discord : &b&n%web%&r" -mojang_down: "&cMojang 伺æœå™¨é›¢ç·šï¼Œè«‹ç¨å¾Œå†æŸ¥çœ‹ ï¼ \n\n&7原因 : &fExploitFixer 無法檢查 UUID。\n&7Discord : &b&n%web%&r" diff --git a/resources/plugin.yml b/resources/plugin.yml deleted file mode 100644 index 5908d51..0000000 --- a/resources/plugin.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: ExploitFixer -main: dev._2lstudios.exploitfixer.ExploitFixer -version: 1.6.8 -author: 2LS -api: "1.13" -api-version: "1.13" -softdepend: [HamsterAPI] -commands: - exploitfixer: - description: The main ExploitFixer command - usage: /exploitfixer - aliases: [ef] From 09271b6f62566ac47b7837a879b449f197ee6c7e Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 22:22:39 -0300 Subject: [PATCH 238/336] 1.6.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c04c71f..dae00ee 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.6.8 + 1.6.9 https://www.spigotmc.org/resources/62842/ From 0c47bdc74bd5191330530f5a7d48ee312a38a5f2 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 22:26:33 -0300 Subject: [PATCH 239/336] fix filtering of plugin.yml --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index dae00ee..cc6859f 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,18 @@ src/main/resources + true + + plugin.yml + bungee.yml + + + + src/main/resources + + plugin.yml + bungee.yml + From 8de62f878afad17cf97e0055ada976659cf9314e Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 22:38:42 -0300 Subject: [PATCH 240/336] check if numbers are nan --- .../listener/PacketReceiveListener.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 2b314f4..a20f2fa 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -235,30 +235,20 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } if (dataVls > 0) { - for (final float val : packetWrapper.getFloats().values()) { - if (val > Float.MAX_VALUE || val < Float.MIN_VALUE) { + for (final Double val : packetWrapper.getDouble().values()) { + if (Double.isNaN(val)) { final String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid float! Added vls: " + dataVls; + + " sent an invalid double: " + val + "! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); return; } } - for (final double val : packetWrapper.getDouble().values()) { - if (val > Double.MAX_VALUE || val < Double.MIN_VALUE) { + for (final Float val : packetWrapper.getFloats().values()) { + if (Float.isNaN(val)) { final String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid double! Added vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - } - - for (final int val : integers.values()) { - if (val > Integer.MAX_VALUE || val < Integer.MIN_VALUE) { - final String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid integer! Added vls: " + dataVls; + + " sent an invalid float: " + val + "! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); return; From 0cec41df2800fb91802a1072331c64e13e066c0e Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 10 Aug 2022 22:38:50 -0300 Subject: [PATCH 241/336] fis packetplayinuseitem false positive --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0b8d5ba..c333fb9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -114,7 +114,7 @@ packets: PacketPlayInSettings: 0.5 PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 - PacketPlayInUseItem: 1 + PacketPlayInUseItem: 0.1 PacketPlayInWindowClick: 0.65 # These packets will be completely cancelled. From b09074e20ac354e9efff1035b0f59131a976ff31 Mon Sep 17 00:00:00 2001 From: ImLew_x Date: Thu, 11 Aug 2022 06:42:49 -0400 Subject: [PATCH 242/336] Improved float number checking Use Float#isFinite instead of NaN since isFinite verifies if the number is NaN or Infinity --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index a20f2fa..46e7e02 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -246,7 +246,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } for (final Float val : packetWrapper.getFloats().values()) { - if (Float.isNaN(val)) { + if (!Float.isFinite(val)) { final String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid float: " + val + "! Added vls: " + dataVls; From 04f07240248234aff0c000d1b6d3bc90b2e8223d Mon Sep 17 00:00:00 2001 From: ImLew_x Date: Thu, 11 Aug 2022 08:19:35 -0400 Subject: [PATCH 243/336] Check for double too --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 46e7e02..7905487 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -236,7 +236,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (dataVls > 0) { for (final Double val : packetWrapper.getDouble().values()) { - if (Double.isNaN(val)) { + if (!Double.isFinite(val)) { final String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid double: " + val + "! Added vls: " + dataVls; From c78a752f011e1fa7f3740709ec59ac8c9e67af82 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 11 Aug 2022 12:56:38 -0300 Subject: [PATCH 244/336] 1.7.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cc6859f..9e114d1 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.6.9 + 1.7.0 https://www.spigotmc.org/resources/62842/ @@ -73,4 +73,4 @@ - \ No newline at end of file + From a26f63e8628ec3c0f2b8365969d903763bc8c4bf Mon Sep 17 00:00:00 2001 From: ImLew_x Date: Tue, 23 Aug 2022 18:25:44 -0400 Subject: [PATCH 245/336] Prevent sending a " " as Payload TAG --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 7905487..3f0f08f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -96,7 +96,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster final double tagVls = packetsModule.getTagVls(); final double bookVls = packetsModule.getBookVls(); - if (tagVls > 0 && (tag == null || tag.isEmpty())) { + if (tagVls > 0 && (tag == null || tag.trim().isEmpty())) { final String reason = "[" + packetName + "|Tag] " + playerName + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; From 0cf8d4cf52d9d0111e4771b8c69dc9ce341da414 Mon Sep 17 00:00:00 2001 From: GreenL1nk Date: Wed, 24 Aug 2022 21:53:37 +0300 Subject: [PATCH 246/336] Added Russian (RU) translation --- src/main/resources/locales/ru.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/resources/locales/ru.yml diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml new file mode 100644 index 0000000..0a71164 --- /dev/null +++ b/src/main/resources/locales/ru.yml @@ -0,0 +1,27 @@ +# Russian - Credits: GreenLink +commands: + reload: "&aПлагин ExploitFixer перезагружен!" + help: |- + &aExploitFixer &b%version%&a автор &bLinsaFTW&a. + &e /%command% help &7> &bПоказывает доÑтупные команды. + &e /%command% reload &7> &bПерезагружает плагин. + &e /%command% notifications &7> &bВключает/Отключает ÑƒÐ²ÐµÐ´Ð¾Ð¼Ð»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð°. + &e /%command% stats &7> &bПроÑмотр ÑтатиÑтики плагина. + error: + unknown: "&cÐеизвеÑÑ‚Ð½Ð°Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´Ð°. ВоÑпользуйтеÑÑŒ /exploitfixer help чтобы проÑмотреть доÑтупные команды!" + permission: "&cУ Ð²Ð°Ñ Ð½ÐµÑ‚ Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ñ Ð½Ð° иÑпользование Ñтой команды!" + console: "&cЭта команда не может быть выполнена из конÑоли!" + notifications: + enable: "&aÐ’Ñ‹ включили уведомлениÑ!" + disable: "&cÐ’Ñ‹ отключили уведомлениÑ!" + stats: "&c&lEF: &Сохранённых игроков: &a%players_cached%&e Ðаказанных игроков: &a%players_punished%" +modules: + custompayload: + kick_message: "&cÐ’Ñ‹ временно заблокированы на Ñтом Ñервере!\n\n&7Причина: &fОбнаружено Ñлишком много пользовательÑких пакетов.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&cÐ’Ñ‹ временно заблокированы на Ñтом Ñервере!\n\n&7Причина: &fОбнаружена уÑзвимоÑть команды.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&cÐ’Ñ‹ временно заблокированы на Ñтом Ñервере!\n\n&7Причина: &fОбнаружена уÑзвимоÑть пакетов.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&cÐ’Ñ‹ временно заблокированы на Ñтом Ñервере!\n\n&7Причина: &fОбнаружен пуÑтой адреÑ.\n&7Discord: &b&n%web%&r" +mojang_down: "&cСервера Mojang не работают, пожалуйÑта, возвращайтеÑÑŒ позже!\n\n&7Причина: &fExploitFixer не может проверить UUID.\n&7Discord: &b&n%web%&r" \ No newline at end of file From 41074abc0ec9cdd9744f5388dd567688741c147a Mon Sep 17 00:00:00 2001 From: Guy Date: Mon, 29 Aug 2022 23:41:15 +0300 Subject: [PATCH 247/336] Support for CustomModelData & Added exempt for materials in ItemFix ItemFix now supports CustomModelData. Added exempt list containing materials which will be exempted when fixing items for exploits. --- .../exploitfixer/listener/PacketReceiveListener.java | 3 ++- .../exploitfixer/modules/ItemsFixModule.java | 9 +++++++++ .../_2lstudios/exploitfixer/utils/ExploitUtil.java | 11 +++++++++++ src/main/resources/config.yml | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 7905487..3e5c582 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -221,12 +221,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster return; } else if (creativeMode) { final String blacklisted = exploitUtil.clearIfBlacklisted(item); + final String exempted = exploitUtil.exemptIfExempted(item); if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), AIR); notificationsModule.debug( playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); - } else { + } else if (exempted == null) { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 0e7f7c8..2a7a110 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -23,6 +23,7 @@ public class ItemsFixModule implements IModule { private int enchantLimit; private int maxStackSize; private Collection blacklist; + private Collection exempt; public ItemsFixModule(final Plugin plugin) { this.plugin = plugin; @@ -35,6 +36,7 @@ public void reload(final IConfiguration configYml) { this.enchantLimit = configYml.getInt(name + ".enchant_limit"); this.maxStackSize = configYml.getInt(name + ".max_stack_size"); this.blacklist = configYml.getStringList(name + ".blacklist"); + this.exempt = configYml.getStringList(name + ".exempt"); } @Override @@ -59,6 +61,10 @@ public Collection getBlacklist() { return blacklist; } + public Collection getExempt() { + return exempt; + } + public ItemStack fixItem(final ItemStack item) { final Material material = Material.getMaterial(item.getType().name()); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); @@ -71,6 +77,9 @@ public ItemStack fixItem(final ItemStack item) { // This applies vanilla levels to enchants final boolean applyLevelRestriction = enchantLimit != 0; + if (oldItemMeta.hasCustomModelData()) + newItemMeta.setCustomModelData(oldItemMeta.getCustomModelData()); + if (oldItemMeta instanceof EnchantmentStorageMeta) { final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; final EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 7bf66e4..4dccff1 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -172,6 +172,17 @@ public String clearIfBlacklisted(final ItemStack itemStack) { return null; } + public String exemptIfExempted(final ItemStack itemStack) { + final Collection exempt = itemsFixModule.getExempt(); + final String materialName = itemStack.getType().toString(); + + if (exempt != null && exempt.contains(materialName)) { + return materialName; + } + + return null; + } + public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, final double vls) { if (vls > 0) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c333fb9..8246ad6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -153,6 +153,10 @@ itemsfix: # - "BARRIER" # - "COMMAND_BLOCK" + # List of materials that will be exempt from itemsfix. + exempt: + # - "PAPER" + # Checks if players try to crash/exploit the server with commands. commands: enabled: true From 91471a924c2cc5cec5d42a10e63ee993df5c797c Mon Sep 17 00:00:00 2001 From: Guy <88142748+ItzGuy@users.noreply.github.com> Date: Wed, 31 Aug 2022 01:16:48 +0300 Subject: [PATCH 248/336] Hebrew Translation --- src/main/resources/locales/he.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/resources/locales/he.yml diff --git a/src/main/resources/locales/he.yml b/src/main/resources/locales/he.yml new file mode 100644 index 0000000..0f2774d --- /dev/null +++ b/src/main/resources/locales/he.yml @@ -0,0 +1,27 @@ +# Hebrew - Credits: ItzGuy +commands: + reload: "&aהפל×גין תיקון פרצות רוענן!" + help: |- + &aExploitFixer &b%version%&a by &bLinsaFTW&a. + &e /%command% help &7> &b.פקודות זמינות + &e /%command% reload &7> &b.ריענון הפל×גין + &e /%command% notifications &7> &bשינוי התר×ות הפל×גין. + &e /%command% stats &7> &bסטטיסטיקות של הפל×גין. + error: + unknown: "&cפקודה ×œ× ×™×“×•×¢×”! השתמש ב - /exploitfixer help" + permission: "&c×ין לך גישה להשתמש בפקודה ×–×ת!" + console: "&cהפקודה ×”×–×ת ×œ× ×™×›×•×œ×” לרוץ בקונסול!" + notifications: + enable: "&aהדלקת התר×ות!" + disable: "&cכיבית התר×ות!" + stats: "&c&lEF: &e×©×—×§× ×™× ×©×ž×•×¨×™×: &a%players_cached%&e ×©×—×§× ×™× ×©×”×•×¢× ×©×•: &a%players_punished%" +modules: + custompayload: + kick_message: "&c×תה ×—×¡×•× ×–×ž× ×™×ª מהשרת ×”×–×”!\n\n&7Reason: &fToo many CustomPayload packets detected.\n&7Discord: &b&n%web%&r" + commands: + kick_message: "&c×תה ×—×¡×•× ×–×ž× ×™×ª מהשרת ×”×–×”!\n\n&7Reason: &fCommand exploit detected.\n&7Discord: &b&n%web%&r" + packets: + kick_message: "&c×תה ×—×¡×•× ×–×ž× ×™×ª מהשרת ×”×–×”!\n\n&7Reason: &fPackets exploit detected.\n&7Discord: &b&n%web%&r" + nulladdress: + kick_message: "&c×תה ×—×¡×•× ×–×ž× ×™×ª מהשרת ×”×–×”!\n\n&7Reason: &fNull address detected.\n&7Discord: &b&n%web%&r" +mojang_down: "&cשרתי ×”×ימות של מוג'×× ×’ ×œ× ×¤×•×¢×œ×™×, תחזרו מ×וחר יותר!\n\n&7Reason: &fExploitFixer can't check the UUID.\n&7Discord: &b&n%web%&r" From f4da46e6d2091cfdf9cf4c22fe8d88774fa49b4e Mon Sep 17 00:00:00 2001 From: linsaftw Date: Wed, 31 Aug 2022 19:08:58 -0300 Subject: [PATCH 249/336] remove exempt function of itemsfix --- .../exploitfixer/listener/PacketReceiveListener.java | 3 +-- .../exploitfixer/modules/ItemsFixModule.java | 6 ------ .../_2lstudios/exploitfixer/utils/ExploitUtil.java | 11 ----------- src/main/resources/config.yml | 4 ---- 4 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 3e5c582..7905487 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -221,13 +221,12 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster return; } else if (creativeMode) { final String blacklisted = exploitUtil.clearIfBlacklisted(item); - final String exempted = exploitUtil.exemptIfExempted(item); if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), AIR); notificationsModule.debug( playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); - } else if (exempted == null) { + } else { packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 2a7a110..9d8bb3e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -23,7 +23,6 @@ public class ItemsFixModule implements IModule { private int enchantLimit; private int maxStackSize; private Collection blacklist; - private Collection exempt; public ItemsFixModule(final Plugin plugin) { this.plugin = plugin; @@ -36,7 +35,6 @@ public void reload(final IConfiguration configYml) { this.enchantLimit = configYml.getInt(name + ".enchant_limit"); this.maxStackSize = configYml.getInt(name + ".max_stack_size"); this.blacklist = configYml.getStringList(name + ".blacklist"); - this.exempt = configYml.getStringList(name + ".exempt"); } @Override @@ -61,10 +59,6 @@ public Collection getBlacklist() { return blacklist; } - public Collection getExempt() { - return exempt; - } - public ItemStack fixItem(final ItemStack item) { final Material material = Material.getMaterial(item.getType().name()); final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 4dccff1..7bf66e4 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -172,17 +172,6 @@ public String clearIfBlacklisted(final ItemStack itemStack) { return null; } - public String exemptIfExempted(final ItemStack itemStack) { - final Collection exempt = itemsFixModule.getExempt(); - final String materialName = itemStack.getType().toString(); - - if (exempt != null && exempt.contains(materialName)) { - return materialName; - } - - return null; - } - public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, final double vls) { if (vls > 0) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8246ad6..c333fb9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -153,10 +153,6 @@ itemsfix: # - "BARRIER" # - "COMMAND_BLOCK" - # List of materials that will be exempt from itemsfix. - exempt: - # - "PAPER" - # Checks if players try to crash/exploit the server with commands. commands: enabled: true From 18d74395ce4aeec70a1ff7d041106ae48d8d633f Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 16:14:29 -0300 Subject: [PATCH 250/336] fix mapview error on 1.12 --- .../listener/ListenerInitializer.java | 2 +- .../listener/MapInitializeListener.java | 31 +++++++++++ .../listener/PlayerInteractListener.java | 52 ------------------- 3 files changed, 32 insertions(+), 53 deletions(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java delete mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index ea92ca6..ab83962 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -29,7 +29,7 @@ public void register() { pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); - pluginManager.registerEvents(new PlayerInteractListener(moduleManager), plugin); + pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java new file mode 100644 index 0000000..e90f22a --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java @@ -0,0 +1,31 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.MapInitializeEvent; +import org.bukkit.map.MapView; + +import dev._2lstudios.exploitfixer.managers.ModuleManager; + +public class MapInitializeListener implements Listener { + private ModuleManager moduleManager; + + public MapInitializeListener(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + @EventHandler(ignoreCancelled = true) + public void onMapInitialize(MapInitializeEvent event) { + if (moduleManager.getEventsModule().isDisableTracking()) { + MapView mapView = event.getMap(); + + try { + if (mapView.isTrackingPosition()) { + mapView.setTrackingPosition(false); + } + } catch (NoSuchMethodError ex) { + // Some version won't support this method :( + } + } + } +} diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java deleted file mode 100644 index 6bd7a4a..0000000 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java +++ /dev/null @@ -1,52 +0,0 @@ -package dev._2lstudios.exploitfixer.listener; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.MapMeta; -import org.bukkit.map.MapView; - -import dev._2lstudios.exploitfixer.managers.ModuleManager; - -public class PlayerInteractListener implements Listener { - private ModuleManager moduleManager; - - public PlayerInteractListener(ModuleManager moduleManager) { - this.moduleManager = moduleManager; - } - - @EventHandler(ignoreCancelled = true) - public void onPlayerInteract(PlayerInteractEntityEvent event) { - if (moduleManager.getEventsModule().isDisableTracking()) { - Entity rightClicked = event.getRightClicked(); - - if (rightClicked instanceof ItemFrame) { - ItemFrame frame = (ItemFrame) rightClicked; - - if (frame.isEmpty()) { - PlayerInventory inventory = event.getPlayer().getInventory(); - ItemStack itemInHand = inventory.getItem(inventory.getHeldItemSlot()); - - if (itemInHand != null && itemInHand.hasItemMeta()) { - ItemMeta itemMeta = itemInHand.getItemMeta(); - - if (itemMeta instanceof MapMeta) { - MapMeta mapMeta = (MapMeta) itemMeta; - MapView mapView = mapMeta.getMapView(); - - if (mapView.isTrackingPosition()) { - mapView.setTrackingPosition(false); - itemInHand.setItemMeta(mapMeta); - } - } - } - } - } - } - } -} From 38bf7473b57b8a5491825329cbd68239db362d39 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 16:39:17 -0300 Subject: [PATCH 251/336] improvements for map disable tracking --- .../listener/ListenerInitializer.java | 1 + .../listener/MapInitializeListener.java | 2 +- .../listener/PlayerInteractListener.java | 56 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index ab83962..dadc6af 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -29,6 +29,7 @@ public void register() { pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerInteractListener(moduleManager), plugin); pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java index e90f22a..4d7249e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/MapInitializeListener.java @@ -24,7 +24,7 @@ public void onMapInitialize(MapInitializeEvent event) { mapView.setTrackingPosition(false); } } catch (NoSuchMethodError ex) { - // Some version won't support this method :( + // Some versions won't support this method :( } } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java new file mode 100644 index 0000000..fdc660b --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerInteractListener.java @@ -0,0 +1,56 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.MapMeta; +import org.bukkit.map.MapView; + +import dev._2lstudios.exploitfixer.managers.ModuleManager; + +public class PlayerInteractListener implements Listener { + private ModuleManager moduleManager; + + public PlayerInteractListener(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEntityEvent event) { + if (moduleManager.getEventsModule().isDisableTracking()) { + Entity rightClicked = event.getRightClicked(); + + if (rightClicked instanceof ItemFrame) { + ItemFrame frame = (ItemFrame) rightClicked; + + if (frame.isEmpty()) { + PlayerInventory inventory = event.getPlayer().getInventory(); + ItemStack itemInHand = inventory.getItem(inventory.getHeldItemSlot()); + + if (itemInHand != null && itemInHand.hasItemMeta()) { + ItemMeta itemMeta = itemInHand.getItemMeta(); + + if (itemMeta instanceof MapMeta) { + MapMeta mapMeta = (MapMeta) itemMeta; + MapView mapView = mapMeta.getMapView(); + + try { + if (mapView.isTrackingPosition()) { + mapView.setTrackingPosition(false); + itemInHand.setItemMeta(mapMeta); + } + } catch (NoSuchMethodError ex) { + // Some version won't support this method :( + } + } + } + } + } + } + } +} From f5f91e7b9d6e07e7b520c7c73feffbce938f3a39 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 16:39:54 -0300 Subject: [PATCH 252/336] reduce settings packet false positives --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c333fb9..de3728f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -111,7 +111,7 @@ packets: PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.15 - PacketPlayInSettings: 0.5 + PacketPlayInSettings: 0.15 PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 0.1 From e6eb6476aa872b484784634cd76fc508f40e5d97 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 19:42:12 -0300 Subject: [PATCH 253/336] prevent end portal break --- .../listener/ListenerInitializer.java | 1 + .../listener/StructureGrowListener.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index dadc6af..0191b22 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -34,6 +34,7 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new StructureGrowListener(), plugin); } public void unregister() { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java new file mode 100644 index 0000000..9f2a121 --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java @@ -0,0 +1,30 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.world.StructureGrowEvent; + +public class StructureGrowListener implements Listener { + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onStructureGrow(StructureGrowEvent event) { + World world = event.getWorld(); + + for (BlockState blockBefore : event.getBlocks()) { + Block block = world.getBlockAt(blockBefore.getLocation()); + + if (block.getType().name().equals("ENDER_PORTAL_FRAME") + || block.getType().name().equals("END_PORTAL_FRAME")) { + event.setCancelled(true); + } + + if (block.getType() == Material.BEDROCK) { + event.setCancelled(true); + } + } + } +} From 9a7e3af54019cfbcae2ccb4eee7e3cd1f2d2a3e5 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 21:32:42 -0300 Subject: [PATCH 254/336] option for ender portal break --- .../listener/ListenerInitializer.java | 2 +- .../listener/StructureGrowListener.java | 32 ++++++++++++------- .../exploitfixer/modules/EventsModule.java | 6 ++++ src/main/resources/config.yml | 3 ++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 0191b22..a01c231 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -34,7 +34,7 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); - pluginManager.registerEvents(new StructureGrowListener(), plugin); + pluginManager.registerEvents(new StructureGrowListener(moduleManager), plugin); } public void unregister() { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java index 9f2a121..5c5c106 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java @@ -1,6 +1,5 @@ package dev._2lstudios.exploitfixer.listener; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -9,21 +8,32 @@ import org.bukkit.event.Listener; import org.bukkit.event.world.StructureGrowEvent; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; + public class StructureGrowListener implements Listener { + private final NotificationsModule notificationsModule; + private final EventsModule eventsModule; + + StructureGrowListener(final ModuleManager moduleManager) { + this.notificationsModule = moduleManager.getNotificationsModule(); + this.eventsModule = moduleManager.getEventsModule(); + } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) { - World world = event.getWorld(); - - for (BlockState blockBefore : event.getBlocks()) { - Block block = world.getBlockAt(blockBefore.getLocation()); + if (eventsModule.isEnderPortalBreak()) { + World world = event.getWorld(); - if (block.getType().name().equals("ENDER_PORTAL_FRAME") - || block.getType().name().equals("END_PORTAL_FRAME")) { - event.setCancelled(true); - } + for (BlockState blockBefore : event.getBlocks()) { + Block block = world.getBlockAt(blockBefore.getLocation()); - if (block.getType() == Material.BEDROCK) { - event.setCancelled(true); + if (block.getType().name().equals("ENDER_PORTAL_FRAME") + || block.getType().name().equals("END_PORTAL_FRAME")) { + event.setCancelled(true); + notificationsModule.debug("[Events] A mushroom tried to break an ender portal frame."); + } } } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java index c017e09..e549723 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -6,6 +6,7 @@ public class EventsModule implements IModule { private boolean nullChunk; private boolean selfDamage; private boolean disableTracking; + private boolean enderPortalBreak; public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); @@ -13,6 +14,7 @@ public void reload(final IConfiguration configYml) { nullChunk = configYml.getBoolean(name + ".null_chunk", true); selfDamage = configYml.getBoolean(name + ".self_damage", true); disableTracking = configYml.getBoolean(name + ".disable_tracking", true); + enderPortalBreak = configYml.getBoolean(name + ".ender_portal_break", true); } @Override @@ -36,4 +38,8 @@ public boolean isNullChunk() { public boolean isDisableTracking() { return disableTracking; } + + public boolean isEnderPortalBreak() { + return enderPortalBreak; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index de3728f..adef3f0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -31,6 +31,9 @@ events: # Prevents players from damaging themselves and consuming ram. self_damage: true + # Prevents players from breaking ender portals. + ender_portal_break: true + # Prevents maps from tracking fixing many crash exploits disable_tracking: true From fb6e343a7e9632a554fa632230b97eaa64510d56 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Thu, 1 Sep 2022 22:30:24 -0300 Subject: [PATCH 255/336] 1.7.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e114d1..dc5ddc2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.0 + 1.7.1 https://www.spigotmc.org/resources/62842/ From 4c404fac496250f83899b3c1fbdd53b78ba90646 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Fri, 2 Sep 2022 21:13:37 -0300 Subject: [PATCH 256/336] fix 1.8 exception --- .../_2lstudios/exploitfixer/modules/ItemsFixModule.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 9d8bb3e..ff1f41a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -71,8 +71,13 @@ public ItemStack fixItem(final ItemStack item) { // This applies vanilla levels to enchants final boolean applyLevelRestriction = enchantLimit != 0; - if (oldItemMeta.hasCustomModelData()) - newItemMeta.setCustomModelData(oldItemMeta.getCustomModelData()); + try { + if (oldItemMeta.hasCustomModelData()) { + newItemMeta.setCustomModelData(oldItemMeta.getCustomModelData()); + } + } catch (NoSuchMethodError ex) { + // Does not support customModelData + } if (oldItemMeta instanceof EnchantmentStorageMeta) { final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; From 99e3ed8dae0967e0f121fa9674254446449a1e09 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 3 Sep 2022 00:57:55 -0300 Subject: [PATCH 257/336] 1.7.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc5ddc2..8f63f65 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.1 + 1.7.2 https://www.spigotmc.org/resources/62842/ From adb15770852debac38db02913ff0c507c54e724c Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 3 Sep 2022 10:12:23 -0300 Subject: [PATCH 258/336] generate new languages --- .../dev/_2lstudios/exploitfixer/modules/MessagesModule.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index 54b2a99..ec661f0 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -29,15 +29,19 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("en"); defaultLocales.add("es"); defaultLocales.add("fr"); + defaultLocales.add("he"); defaultLocales.add("hu"); defaultLocales.add("it"); + defaultLocales.add("ja"); defaultLocales.add("ko"); + defaultLocales.add("nl"); defaultLocales.add("pl"); defaultLocales.add("pt"); defaultLocales.add("ro"); defaultLocales.add("th"); defaultLocales.add("tr"); defaultLocales.add("zh"); + defaultLocales.add("zhtw"); } public void putSection(final IConfiguration langFile, final Map locale, final String currentPath) { From 82ffcdbd1dbf5a895845bd2b30902003f8b0be7a Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 3 Sep 2022 10:33:35 -0300 Subject: [PATCH 259/336] generate russian language --- .../java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index ec661f0..e7c19b6 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -38,6 +38,7 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("pl"); defaultLocales.add("pt"); defaultLocales.add("ro"); + defaultLocales.add("ru"); defaultLocales.add("th"); defaultLocales.add("tr"); defaultLocales.add("zh"); From 83ec3024908c77cb5de28a4a799ca9ab7c6a9fe6 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sat, 3 Sep 2022 10:58:24 -0300 Subject: [PATCH 260/336] fixed locales not working --- .../dev/_2lstudios/exploitfixer/utils/VersionUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java index 13a2a47..b0cca0e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java @@ -1,5 +1,7 @@ package dev._2lstudios.exploitfixer.utils; +import java.lang.reflect.Method; + import org.bukkit.entity.Player; import org.bukkit.entity.Player.Spigot; @@ -8,12 +10,15 @@ public static String getLocale(final Player player) { String locale; try { - locale = player.getClass().getMethod("getLocale").invoke(player, (Object[]) null).toString(); + locale = player.getClass().getMethod("getLocale").invoke(player).toString(); } catch (final Exception exception) { try { final Spigot spigot = player.spigot(); + final Method getLocaleMethod = spigot.getClass().getMethod("getLocale"); + + getLocaleMethod.setAccessible(true); - locale = spigot.getClass().getMethod("getLocale").invoke(spigot, (Object[]) null).toString(); + locale = getLocaleMethod.invoke(spigot).toString(); } catch (final Exception exception1) { locale = "en"; } From 74fb554b47d83afe79f21dc1a83fe451f18223bc Mon Sep 17 00:00:00 2001 From: linsaftw Date: Sun, 4 Sep 2022 13:29:50 -0300 Subject: [PATCH 261/336] prevent dispenser crashers --- .../listener/BlockDispenseListener.java | 51 +++++++++++++++++++ .../listener/ListenerInitializer.java | 3 +- .../exploitfixer/modules/EventsModule.java | 6 +++ src/main/resources/config.yml | 3 ++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java new file mode 100644 index 0000000..3a91123 --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java @@ -0,0 +1,51 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Directional; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockDispenseEvent; + +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; + +public class BlockDispenseListener implements Listener { + private final NotificationsModule notificationsModule; + private final EventsModule eventsModule; + + BlockDispenseListener(final ModuleManager moduleManager) { + this.notificationsModule = moduleManager.getNotificationsModule(); + this.eventsModule = moduleManager.getEventsModule(); + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onBlockDispense(BlockDispenseEvent event) { + if (eventsModule.isDispenserCrash()) { + final Block block = event.getBlock(); + final Location location = block.getLocation(); + final World world = location.getWorld(); + + if (world != null) { + final int maxHeight = world.getMaxHeight() - 1; + final BlockData blockData = block.getState().getBlockData(); + + if (blockData instanceof Directional) { + final Directional directional = (Directional) blockData; + final BlockFace face = directional.getFacing(); + + if ((location.getY() >= maxHeight && face == BlockFace.UP + || location.getY() <= 1 && face == BlockFace.DOWN)) { + event.setCancelled(true); + notificationsModule.debug("[Events] A dispenser tried to drop objects from invalid locations."); + } + } + } + } + } +} diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index a01c231..cda81ed 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -25,12 +25,13 @@ public void register() { final PluginManager pluginManager = server.getPluginManager(); final ExploitUtil exploitUtil = new ExploitUtil(moduleManager); + pluginManager.registerEvents(new BlockDispenseListener(moduleManager), plugin); pluginManager.registerEvents(new EntityDamageByEntityListener(moduleManager), plugin); + pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PacketReceiveListener(exploitUtil, moduleManager), plugin); pluginManager.registerEvents(new PlayerCommandListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerInteractListener(moduleManager), plugin); - pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java index e549723..8dab11b 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -7,6 +7,7 @@ public class EventsModule implements IModule { private boolean selfDamage; private boolean disableTracking; private boolean enderPortalBreak; + private boolean dispenserCrash; public void reload(final IConfiguration configYml) { final String name = getName().toLowerCase(); @@ -15,6 +16,7 @@ public void reload(final IConfiguration configYml) { selfDamage = configYml.getBoolean(name + ".self_damage", true); disableTracking = configYml.getBoolean(name + ".disable_tracking", true); enderPortalBreak = configYml.getBoolean(name + ".ender_portal_break", true); + dispenserCrash = configYml.getBoolean(name + ".dispenser_crash", true); } @Override @@ -42,4 +44,8 @@ public boolean isDisableTracking() { public boolean isEnderPortalBreak() { return enderPortalBreak; } + + public boolean isDispenserCrash() { + return dispenserCrash; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index adef3f0..786eaa8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -37,6 +37,9 @@ events: # Prevents maps from tracking fixing many crash exploits disable_tracking: true + # Prevents crashing when using dispensers that drop items out of the bounds. + dispenser_crash: true + # Prevents the use of invalid packets to crash the server. packets: enabled: true From c438e7caefcc386a4e97895a8a8d9c436b7c7a48 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 5 Sep 2022 12:52:55 -0300 Subject: [PATCH 262/336] use compiled regex to improve performance --- .../dev/_2lstudios/exploitfixer/modules/CommandsModule.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index f97bc09..2d28e9e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -1,10 +1,13 @@ package dev._2lstudios.exploitfixer.modules; import java.util.Collection; +import java.util.regex.Pattern; import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class CommandsModule implements IPunishmentModule { + private static final Pattern SYNTAX_PATTERN = Pattern.compile("[\\w]{1,}:"); + private Collection commands; private Collection punishments; private String name; @@ -29,7 +32,7 @@ public String getName() { public final boolean isCommand(final String rawMessage) { if (rawMessage != null) { - final String message = rawMessage.replaceAll("[\\w]{1,}:", "").toLowerCase(); + final String message = SYNTAX_PATTERN.matcher(rawMessage).replaceAll("").toLowerCase(); for (final String command : commands) { if (message.startsWith(command)) { From 27474f503204dde8e42d2f6394b903cbb7444b5f Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 5 Sep 2022 16:56:19 -0300 Subject: [PATCH 263/336] limit portal teleports --- .../_2lstudios/exploitfixer/ExploitFixer.java | 20 ++-- .../commands/ExploitFixerCommand.java | 26 ++--- .../exploitfixer/commands/HelpCommand.java | 4 +- .../commands/NotificationsCommand.java | 12 +- .../exploitfixer/commands/ReloadCommand.java | 6 +- .../exploitfixer/commands/StatsCommand.java | 8 +- .../configuration/BukkitConfiguration.java | 24 ++-- .../configuration/IConfiguration.java | 20 ++-- .../exploit/BukkitExploitPlayer.java | 68 +++++------ .../exploitfixer/exploit/ExploitPlayer.java | 19 ++- .../exploitfixer/exploit/Violations.java | 8 +- .../listener/BlockDispenseListener.java | 20 ++-- .../EntityDamageByEntityListener.java | 12 +- .../listener/ListenerInitializer.java | 13 ++- .../listener/PacketDecodeListener.java | 44 +++---- .../listener/PacketReceiveListener.java | 110 +++++++++--------- .../listener/PlayerCommandListener.java | 16 +-- .../listener/PlayerLoginListener.java | 20 ++-- .../listener/PlayerMoveListener.java | 14 +-- .../listener/PlayerQuitListener.java | 10 +- .../listener/PlayerTeleportListener.java | 50 ++++++++ .../listener/StructureGrowListener.java | 11 +- .../managers/ExploitPlayerManager.java | 22 ++-- .../exploitfixer/managers/ModuleManager.java | 34 +++--- .../exploitfixer/modules/CommandsModule.java | 14 +-- .../modules/ConnectionModule.java | 2 +- .../exploitfixer/modules/EventsModule.java | 10 +- .../exploitfixer/modules/IMessagesModule.java | 2 +- .../modules/INotificationsModule.java | 2 +- .../exploitfixer/modules/ItemsFixModule.java | 56 ++++----- .../exploitfixer/modules/MessagesModule.java | 60 +++++----- .../modules/NotificationsModule.java | 52 ++++----- .../exploitfixer/modules/PacketsModule.java | 14 +-- .../tasks/ExploitFixerRepeatingTask.java | 4 +- .../utils/BukkitConfigurationUtil.java | 46 ++++---- .../exploitfixer/utils/ExploitUtil.java | 62 +++++----- .../utils/IConfigurationUtil.java | 8 +- .../exploitfixer/utils/ProtocolUtil.java | 4 +- .../exploitfixer/utils/VersionUtil.java | 10 +- src/main/resources/config.yml | 5 +- 40 files changed, 506 insertions(+), 436 deletions(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java index 210a6e0..3225c7e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java @@ -24,7 +24,7 @@ public static synchronized ExploitFixer getInstance() { return instance; } - public static synchronized void setInstance(final ExploitFixer exploitFixer) { + public static synchronized void setInstance(ExploitFixer exploitFixer) { ExploitFixer.instance = exploitFixer; } @@ -41,7 +41,7 @@ public void onEnable() { createConfigurations(); - final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); + IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); moduleManager = new ModuleManager(configurationUtil, this); moduleManager.reload(configYml); @@ -58,7 +58,7 @@ public void onDisable() { public void reload() { createConfigurations(); - final IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); + IConfiguration configYml = configurationUtil.get("%datafolder%/config.yml"); moduleManager.reload(configYml); @@ -67,8 +67,8 @@ public void reload() { } private boolean checkHamsterAPI() { - final Server server = this.getServer(); - final PluginManager pluginManager = server.getPluginManager(); + Server server = this.getServer(); + PluginManager pluginManager = server.getPluginManager(); return pluginManager.isPluginEnabled("HamsterAPI"); } @@ -78,8 +78,8 @@ private void createConfigurations() { } public void unregister() { - final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); + Server server = this.getServer(); + BukkitScheduler scheduler = server.getScheduler(); scheduler.cancelTasks(this); server.getMessenger().unregisterIncomingPluginChannel(this); @@ -88,9 +88,9 @@ public void unregister() { } private void register() { - final Server server = this.getServer(); - final BukkitScheduler scheduler = server.getScheduler(); - final Logger logger = this.getLogger(); + Server server = this.getServer(); + BukkitScheduler scheduler = server.getScheduler(); + Logger logger = this.getLogger(); getCommand("exploitfixer").setExecutor(new ExploitFixerCommand(this, moduleManager)); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index ef95aed..0c92fb5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -13,12 +13,12 @@ import dev._2lstudios.exploitfixer.modules.MessagesModule; public class ExploitFixerCommand implements CommandExecutor { - private final ExploitFixer exploitFixer; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsModule; - private final ExploitPlayerManager exploitPlayerManager; + private ExploitFixer exploitFixer; + private MessagesModule messagesModule; + private NotificationsModule notificationsModule; + private ExploitPlayerManager exploitPlayerManager; - public ExploitFixerCommand(final ExploitFixer exploitFixer, final ModuleManager moduleManager) { + public ExploitFixerCommand(ExploitFixer exploitFixer, ModuleManager moduleManager) { this.exploitFixer = exploitFixer; this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); @@ -26,10 +26,10 @@ public ExploitFixerCommand(final ExploitFixer exploitFixer, final ModuleManager } @Override - public boolean onCommand(final CommandSender sender, final Command command, final String label, - final String[] args) { - final int length = args.length; - final String lang; + public boolean onCommand(CommandSender sender, Command command, String label, + String[] args) { + int length = args.length; + String lang; if (sender instanceof Player) { lang = VersionUtil.getLocale((Player) sender); @@ -38,19 +38,19 @@ public boolean onCommand(final CommandSender sender, final Command command, fina } if (length < 1 || args[0].equalsIgnoreCase("help")) { - final HelpCommand helpCommand = new HelpCommand(messagesModule, lang); + HelpCommand helpCommand = new HelpCommand(messagesModule, lang); helpCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("reload")) { - final ReloadCommand reloadCommand = new ReloadCommand(exploitFixer, messagesModule, lang); + ReloadCommand reloadCommand = new ReloadCommand(exploitFixer, messagesModule, lang); reloadCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("stats")) { - final StatsCommand statsCommand = new StatsCommand(exploitPlayerManager, messagesModule, lang); + StatsCommand statsCommand = new StatsCommand(exploitPlayerManager, messagesModule, lang); statsCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("notifications")) { - final NotificationsCommand notificationsCommand = new NotificationsCommand(notificationsModule, + NotificationsCommand notificationsCommand = new NotificationsCommand(notificationsModule, messagesModule, lang); notificationsCommand.onCommand(sender, command, label, args); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java index 7f37498..3a4663b 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/HelpCommand.java @@ -7,8 +7,8 @@ import dev._2lstudios.exploitfixer.modules.MessagesModule; public class HelpCommand implements CommandExecutor { - private final MessagesModule messagesModule; - private final String lang; + private MessagesModule messagesModule; + private String lang; public HelpCommand(MessagesModule messagesModule, String lang) { this.messagesModule = messagesModule; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java index 8d17d6f..503a87e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/NotificationsCommand.java @@ -9,22 +9,22 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class NotificationsCommand implements CommandExecutor { - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - private final String lang; + private NotificationsModule notificationsModule; + private MessagesModule messagesModule; + private String lang; - public NotificationsCommand(final NotificationsModule notificationsModule, final MessagesModule messagesModule, final String lang) { + public NotificationsCommand(NotificationsModule notificationsModule, MessagesModule messagesModule, String lang) { this.notificationsModule = notificationsModule; this.messagesModule = messagesModule; this.lang = lang; } @Override - public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { if (sender.hasPermission("exploitfixer.admin") || sender.hasPermission("exploitfixer.notifications")) { - final String playerName = sender.getName(); + String playerName = sender.getName(); if (!notificationsModule.isNotifications(playerName)) { notificationsModule.setNotifications(playerName, true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java index 19dba59..f9d986d 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/ReloadCommand.java @@ -8,9 +8,9 @@ import dev._2lstudios.exploitfixer.modules.MessagesModule; public class ReloadCommand implements CommandExecutor { - private final ExploitFixer exploitFixer; - private final MessagesModule messagesModule; - private final String lang; + private ExploitFixer exploitFixer; + private MessagesModule messagesModule; + private String lang; public ReloadCommand(ExploitFixer exploitFixer, MessagesModule messagesModule, String lang) { this.exploitFixer = exploitFixer; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java index 35826f3..0c0935e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java @@ -8,11 +8,11 @@ import dev._2lstudios.exploitfixer.modules.MessagesModule; public class StatsCommand implements CommandExecutor { - private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; - private final String lang; + private ExploitPlayerManager exploitPlayerManager; + private MessagesModule messagesModule; + private String lang; - public StatsCommand(final ExploitPlayerManager exploitPlayerManager, final MessagesModule messagesModule, final String lang) { + public StatsCommand(ExploitPlayerManager exploitPlayerManager, MessagesModule messagesModule, String lang) { this.exploitPlayerManager = exploitPlayerManager; this.messagesModule = messagesModule; this.lang = lang; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java b/src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java index 2c5c254..c411b60 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/configuration/BukkitConfiguration.java @@ -6,15 +6,15 @@ import org.bukkit.configuration.ConfigurationSection; public class BukkitConfiguration implements IConfiguration { - private final ConfigurationSection configuration; + private ConfigurationSection configuration; - public BukkitConfiguration(final ConfigurationSection configuration) { + public BukkitConfiguration(ConfigurationSection configuration) { this.configuration = configuration; } @Override - public IConfiguration getSection(final String path) { - final Object section = configuration.get(path); + public IConfiguration getSection(String path) { + Object section = configuration.get(path); if (section instanceof ConfigurationSection) { return new BukkitConfiguration((ConfigurationSection) section); @@ -29,7 +29,7 @@ public Collection getKeys() { } @Override - public Collection getStringList(final String path) { + public Collection getStringList(String path) { if (configuration.contains(path)) { return new HashSet<>(configuration.getStringList(path)); } else { @@ -38,7 +38,7 @@ public Collection getStringList(final String path) { } @Override - public String getString(final String path) { + public String getString(String path) { return configuration.getString(path); } @@ -52,32 +52,32 @@ public String getString(String path, String def) { } @Override - public double getDouble(final String path) { + public double getDouble(String path) { return configuration.getDouble(path); } @Override - public long getLong(final String path) { + public long getLong(String path) { return configuration.getLong(path); } @Override - public int getInt(final String path) { + public int getInt(String path) { return configuration.getInt(path); } @Override - public boolean getBoolean(final String path) { + public boolean getBoolean(String path) { return configuration.getBoolean(path); } @Override - public boolean getBoolean(final String path, final boolean def) { + public boolean getBoolean(String path, boolean def) { return configuration.getBoolean(path, def); } @Override - public boolean contains(final String path) { + public boolean contains(String path) { return configuration.contains(path); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java b/src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java index 55ac82c..8d719fe 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/configuration/IConfiguration.java @@ -3,27 +3,27 @@ import java.util.Collection; public interface IConfiguration { - public IConfiguration getSection(final String string); + public IConfiguration getSection(String string); public Collection getKeys(); - public Collection getStringList(final String string); + public Collection getStringList(String string); - public String getString(final String path); + public String getString(String path); - public String getString(final String path, final String def); + public String getString(String path, String def); - public double getDouble(final String path); + public double getDouble(String path); - public long getLong(final String path); + public long getLong(String path); - public int getInt(final String path); + public int getInt(String path); - public boolean getBoolean(final String path); + public boolean getBoolean(String path); - public boolean getBoolean(final String path, final boolean def); + public boolean getBoolean(String path, boolean def); public Object getObject(); - public boolean contains(final String string); + public boolean contains(String string); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index a14040c..9f0a736 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -23,38 +23,38 @@ import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class BukkitExploitPlayer extends ExploitPlayer { - private final Plugin plugin; - private final ExploitPlayerManager exploitPlayerManager; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsModule; + private Plugin plugin; + private ExploitPlayerManager exploitPlayerManager; + private MessagesModule messagesModule; + private NotificationsModule notificationsModule; - public BukkitExploitPlayer(final Plugin plugin, final ModuleManager moduleManager) { + public BukkitExploitPlayer(Plugin plugin, ModuleManager moduleManager) { this.plugin = plugin; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); this.notificationsModule = moduleManager.getNotificationsModule(); } - public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, - final IViolationModule module, final double amount) { + public void addVls(Cancellable event, HamsterPlayer hamsterPlayer, + IViolationModule module, double amount) { addVls(event, null, hamsterPlayer, module, amount); } - public void addVls(final Cancellable event, final PacketWrapper packet, - final HamsterPlayer hamsterPlayer, final IViolationModule module, final double amount) { - final Violations violations = (Violations) module.getViolations(); + public void addVls(Cancellable event, PacketWrapper packet, + HamsterPlayer hamsterPlayer, IViolationModule module, double amount) { + Violations violations = (Violations) module.getViolations(); if (violations != null) { - final Map violationsMap = getViolations(); - final long currentTime = System.currentTimeMillis(); - final long lastViolation = getLastViolation(); + Map violationsMap = getViolations(); + long currentTime = System.currentTimeMillis(); + long lastViolation = getLastViolation(); if (currentTime - lastViolation >= 1000) { clearPunishments(); setLastViolation(currentTime); - for (final IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { - final double vls = violationsMap.get(violationModule) - violationModule.getReduceVls(); + for (IViolationModule violationModule : new HashSet<>(violationsMap.keySet())) { + double vls = violationsMap.get(violationModule) - violationModule.getReduceVls(); if (vls <= 0) { violationsMap.remove(violationModule); @@ -64,7 +64,7 @@ public void addVls(final Cancellable event, final PacketWrapper packet, } } - final double newVls = getViolations(module) + amount; + double newVls = getViolations(module) + amount; violationsMap.put(module, newVls); @@ -72,9 +72,9 @@ public void addVls(final Cancellable event, final PacketWrapper packet, ((Cancellable) event).setCancelled(true); } - for (final int threshold : violations.getViolations()) { + for (int threshold : violations.getViolations()) { if (threshold <= newVls) { - final Collection commands = violations.getCommands(threshold); + Collection commands = violations.getCommands(threshold); punish(module, hamsterPlayer, packet, commands, (int) newVls); } @@ -82,29 +82,29 @@ public void addVls(final Cancellable event, final PacketWrapper packet, } } - public void punish(final IModule module, final HamsterPlayer hamsterPlayer, final PacketWrapper packet, - final Collection punishments, final int newVls) { - final Collection> punishmentsDone = this.getPunishments(); + public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper packet, + Collection punishments, int newVls) { + Collection> punishmentsDone = this.getPunishments(); if (!punishments.isEmpty() && !punishmentsDone.contains(punishments)) { - final Server server = plugin.getServer(); - final CommandSender consoleSender = server.getConsoleSender(); - final BukkitScheduler scheduler = server.getScheduler(); - final Player player = hamsterPlayer.getPlayer(); - final String playerName = player.getName(); + Server server = plugin.getServer(); + CommandSender consoleSender = server.getConsoleSender(); + BukkitScheduler scheduler = server.getScheduler(); + Player player = hamsterPlayer.getPlayer(); + String playerName = player.getName(); - for (final String punishment : punishments) { + for (String punishment : punishments) { if (punishment.equals("kick")) { - final String locale = VersionUtil.getLocale(player); - final String kickMessage = messagesModule.getKickMessage(module, locale); + String locale = VersionUtil.getLocale(player); + String kickMessage = messagesModule.getKickMessage(module, locale); hamsterPlayer.disconnect(kickMessage); hamsterPlayer.closeChannel(); } else if (punishment.equals("notification")) { - final String moduleName = module.getName(); + String moduleName = module.getName(); if (packet != null) { - final PacketType packetType = packet.getType(); + PacketType packetType = packet.getType(); if (packetType != null) { notificationsModule.sendNotification(packetType.toString(), player, newVls); @@ -136,12 +136,12 @@ public void punish(final IModule module, final HamsterPlayer hamsterPlayer, fina exploitPlayerManager.addPunishment(); } } - private int getPing(final Player player) { + private int getPing(Player player) { try { - final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); return (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (final Exception ignored) { + } catch (Exception ignored) { return 0; } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index 63a9b16..ad20588 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -8,9 +8,10 @@ import dev._2lstudios.exploitfixer.modules.IViolationModule; public class ExploitPlayer { - private final Map violations; - private final Collection> punishments; + private Map violations; + private Collection> punishments; private long lastViolation = 0; + private long lastPortalUse = 0; public ExploitPlayer() { this.violations = new HashMap<>(); @@ -29,15 +30,23 @@ public long getLastViolation() { return lastViolation; } - public void setLastViolation(final long lastViolation) { - this.lastViolation = lastViolation; + public void setLastViolation(long lastPortalUse) { + this.lastViolation = lastPortalUse; + } + + public long getLastPortalUse() { + return lastPortalUse; + } + + public void setLastPortalUse(long lastPortalUse) { + this.lastPortalUse = lastPortalUse; } public Map getViolations() { return violations; } - public double getViolations(final IViolationModule module) { + public double getViolations(IViolationModule module) { return violations.getOrDefault(module, 0D); } } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java index 87ac478..6963d99 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/Violations.java @@ -9,18 +9,18 @@ public class Violations { private Map> violations = new HashMap<>(); - public Violations(final IConfiguration configuration) { + public Violations(IConfiguration configuration) { if (configuration != null) { - for (final String key : configuration.getKeys()) { + for (String key : configuration.getKeys()) { try { this.violations.put(Integer.parseInt(key), configuration.getStringList(key)); - } catch (final NumberFormatException ignored) { + } catch (NumberFormatException ignored) { } } } } - public Collection getCommands(final int violations) { + public Collection getCommands(int violations) { return this.violations.getOrDefault(violations, null); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java index 3a91123..0b1ca47 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java @@ -16,10 +16,10 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class BlockDispenseListener implements Listener { - private final NotificationsModule notificationsModule; - private final EventsModule eventsModule; + private NotificationsModule notificationsModule; + private EventsModule eventsModule; - BlockDispenseListener(final ModuleManager moduleManager) { + BlockDispenseListener(ModuleManager moduleManager) { this.notificationsModule = moduleManager.getNotificationsModule(); this.eventsModule = moduleManager.getEventsModule(); } @@ -27,17 +27,17 @@ public class BlockDispenseListener implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockDispense(BlockDispenseEvent event) { if (eventsModule.isDispenserCrash()) { - final Block block = event.getBlock(); - final Location location = block.getLocation(); - final World world = location.getWorld(); + Block block = event.getBlock(); + Location location = block.getLocation(); + World world = location.getWorld(); if (world != null) { - final int maxHeight = world.getMaxHeight() - 1; - final BlockData blockData = block.getState().getBlockData(); + int maxHeight = world.getMaxHeight() - 1; + BlockData blockData = block.getState().getBlockData(); if (blockData instanceof Directional) { - final Directional directional = (Directional) blockData; - final BlockFace face = directional.getFacing(); + Directional directional = (Directional) blockData; + BlockFace face = directional.getFacing(); if ((location.getY() >= maxHeight && face == BlockFace.UP || location.getY() <= 1 && face == BlockFace.DOWN)) { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java index 2a326dd..f85ab56 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/EntityDamageByEntityListener.java @@ -12,24 +12,24 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class EntityDamageByEntityListener implements Listener { - private final NotificationsModule notificationsModule; - private final EventsModule eventsModule; + private NotificationsModule notificationsModule; + private EventsModule eventsModule; - EntityDamageByEntityListener(final ModuleManager moduleManager) { + EntityDamageByEntityListener(ModuleManager moduleManager) { this.notificationsModule = moduleManager.getNotificationsModule(); this.eventsModule = moduleManager.getEventsModule(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) { + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!eventsModule.isSelfDamage()) { return; } - final Entity entity = event.getEntity(); + Entity entity = event.getEntity(); if (entity instanceof Player) { - final Entity damager = event.getDamager(); + Entity damager = event.getDamager(); if (damager instanceof Player && entity == damager) { event.setCancelled(true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index cda81ed..4c2404d 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -9,11 +9,11 @@ import dev._2lstudios.exploitfixer.utils.ExploitUtil; public class ListenerInitializer { - private final Plugin plugin; - private final ModuleManager moduleManager; + private Plugin plugin; + private ModuleManager moduleManager; private boolean registered = false; - public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManager) { + public ListenerInitializer(Plugin plugin, ModuleManager moduleManager) { this.plugin = plugin; this.moduleManager = moduleManager; } @@ -21,9 +21,9 @@ public ListenerInitializer(final Plugin plugin, final ModuleManager moduleManage public void register() { this.registered = true; - final Server server = plugin.getServer(); - final PluginManager pluginManager = server.getPluginManager(); - final ExploitUtil exploitUtil = new ExploitUtil(moduleManager); + Server server = plugin.getServer(); + PluginManager pluginManager = server.getPluginManager(); + ExploitUtil exploitUtil = new ExploitUtil(moduleManager); pluginManager.registerEvents(new BlockDispenseListener(moduleManager), plugin); pluginManager.registerEvents(new EntityDamageByEntityListener(moduleManager), plugin); @@ -35,6 +35,7 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); pluginManager.registerEvents(new StructureGrowListener(moduleManager), plugin); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 3c1b1de..64fdd6f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -17,45 +17,45 @@ public class PacketDecodeListener implements Listener { - private static final String PREFIX = "[Decoder|Data] "; - private static final String PREFIX_OFFLINE = "[Decoder|Offline] "; - private final ExploitUtil exploitUtil; - private final PacketsModule packetsModule; + private static String PREFIX = "[Decoder|Data] "; + private static String PREFIX_OFFLINE = "[Decoder|Offline] "; + private ExploitUtil exploitUtil; + private PacketsModule packetsModule; - PacketDecodeListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { + PacketDecodeListener(ExploitUtil exploitUtil, ModuleManager moduleManager) { this.exploitUtil = exploitUtil; this.packetsModule = moduleManager.getPacketsModule(); } - private String getName(final Player player) { + private String getName(Player player) { if (player == null) { return "unknown"; } return player.getName(); } - private void onPacketDecode(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, - final ByteBuf byteBuf) { + private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Player player, + ByteBuf byteBuf) { if (player != null && player.isOnline()) { - final String playerName = player.getName(); - final double dataVls = packetsModule.getDataVls(); - final double dataVlMultiplier = packetsModule.getDataVlMultiplier(); - final int dataBytes = packetsModule.getDataBytes(); - final int refCnt = byteBuf.refCnt(); - final int capacity = byteBuf.capacity(); + String playerName = player.getName(); + double dataVls = packetsModule.getDataVls(); + double dataVlMultiplier = packetsModule.getDataVlMultiplier(); + int dataBytes = packetsModule.getDataBytes(); + int refCnt = byteBuf.refCnt(); + int capacity = byteBuf.capacity(); if (capacity < 0) { - final String reason = PREFIX + playerName + String reason = PREFIX + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else if (refCnt < 1) { - final String reason = PREFIX + playerName + " sent a packet with invalid refCnt! refCnt: " + String reason = PREFIX + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } else { - final int readableBytes = byteBuf.readableBytes(); + int readableBytes = byteBuf.readableBytes(); String reason = null; if (capacity > dataBytes) { @@ -66,7 +66,7 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster + "/" + dataBytes + " Vls: " + dataVls; } else { if (!(byteBuf instanceof EmptyByteBuf)) { - final int packetId = ProtocolUtil.readVarInt(byteBuf); + int packetId = ProtocolUtil.readVarInt(byteBuf); byteBuf.resetReaderIndex(); @@ -85,20 +85,20 @@ private void onPacketDecode(final Cancellable event, final HamsterPlayer hamster exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } } else if (packetsModule.isOffline()) { - final String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; + String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); } } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPacketDecode(final PacketDecodeEvent event) { + public void onPacketDecode(PacketDecodeEvent event) { if (!packetsModule.isEnabled()) { return; } - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); - final ByteBuf byteBuf = event.getByteBuf().get(); + HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + ByteBuf byteBuf = event.getByteBuf().get(); onPacketDecode(event, hamsterPlayer, hamsterPlayer.getPlayer(), byteBuf); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 3f0f08f..7ff585e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -30,17 +30,17 @@ import java.util.Map.Entry; public class PacketReceiveListener implements Listener { - private final ExploitUtil exploitUtil; - private final ExploitPlayerManager exploitPlayerManager; - private final ItemsFixModule itemsFixModule; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; - private final CommandsModule commandsModule; - private final String version; - private final boolean checkLectern; - private final ItemStack AIR = new ItemStack(Material.AIR); - - PacketReceiveListener(final ExploitUtil exploitUtil, final ModuleManager moduleManager) { + private ExploitUtil exploitUtil; + private ExploitPlayerManager exploitPlayerManager; + private ItemsFixModule itemsFixModule; + private NotificationsModule notificationsModule; + private PacketsModule packetsModule; + private CommandsModule commandsModule; + private String version; + private boolean checkLectern; + private ItemStack AIR = new ItemStack(Material.AIR); + + PacketReceiveListener(ExploitUtil exploitUtil, ModuleManager moduleManager) { this.exploitUtil = exploitUtil; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); @@ -55,23 +55,23 @@ public class PacketReceiveListener implements Listener { || version.startsWith("v1_11") || version.startsWith("v1_10"); } - public void onPacketReceive(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, - final PacketWrapper packetWrapper) { - final PacketType packetType = packetWrapper.getType(); - final String packetName = packetWrapper.getName(); - final String playerName = player.getName(); - final Map strings = packetWrapper.getStrings(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - final double dataVls = packetsModule.getDataVls(); - final Map integers = packetWrapper.getIntegers(); - final InventoryView inventoryView = player.getOpenInventory(); - final double windowClick = packetsModule.getWindowClick(); - final double setCreativeSlot = packetsModule.getSetCreativeSlot(); + public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Player player, + PacketWrapper packetWrapper) { + PacketType packetType = packetWrapper.getType(); + String packetName = packetWrapper.getName(); + String playerName = player.getName(); + Map strings = packetWrapper.getStrings(); + BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + double dataVls = packetsModule.getDataVls(); + Map integers = packetWrapper.getIntegers(); + InventoryView inventoryView = player.getOpenInventory(); + double windowClick = packetsModule.getWindowClick(); + double setCreativeSlot = packetsModule.getSetCreativeSlot(); exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName)); if (packetsModule.isBlacklisted(packetName)) { - final String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; + String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); return; @@ -79,7 +79,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { if (!strings.isEmpty()) { - final String rawMessage = strings.values().iterator().next(); + String rawMessage = strings.values().iterator().next(); if (commandsModule.isCommand(rawMessage)) { exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), @@ -92,30 +92,30 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (packetType == PacketType.PacketPlayInCustomPayload) { if (!strings.isEmpty()) { - final String tag = strings.values().iterator().next(); - final double tagVls = packetsModule.getTagVls(); - final double bookVls = packetsModule.getBookVls(); + String tag = strings.values().iterator().next(); + double tagVls = packetsModule.getTagVls(); + double bookVls = packetsModule.getBookVls(); if (tagVls > 0 && (tag == null || tag.trim().isEmpty())) { - final String reason = "[" + packetName + "|Tag] " + playerName + String reason = "[" + packetName + "|Tag] " + playerName + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); return; } else if (bookVls > 0 && (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen"))) { - final PlayerInventory playerInventory = player.getInventory(); - final ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); + PlayerInventory playerInventory = player.getInventory(); + ItemStack itemInHand = playerInventory.getItem(playerInventory.getHeldItemSlot()); if (itemInHand != null && !itemInHand.getType().toString().contains("BOOK")) { - final String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + " CustomPayload packet without a book in hand!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); return; } } else if (tag.equals("MC|AdvCdm") && !player.isOp()) { - final String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag + String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag + " CustomPayload packet without being op!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); @@ -131,13 +131,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { - final Inventory topInventory = inventoryView.getTopInventory(); + Inventory topInventory = inventoryView.getTopInventory(); if (topInventory.getType().name().equals("LECTERN")) { if (this.checkLectern) { if (version.equals("v1_18_R1")) { if (integers.containsKey("a") && integers.get("a") == 1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName + String reason = "[" + packetName + "|WindowClick] " + playerName + " tried to quick move on a lectern! Added vls: " + windowClick; @@ -146,7 +146,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } else { if (integers.containsKey("b") && integers.get("b") == 1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName + String reason = "[" + packetName + "|WindowClick] " + playerName + " tried to quick move on a lectern! Added vls: " + windowClick; @@ -157,12 +157,12 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - final Inventory bottomInventory = inventoryView.getBottomInventory(); - final boolean containsSlot = integers.containsKey("slot"); + Inventory bottomInventory = inventoryView.getBottomInventory(); + boolean containsSlot = integers.containsKey("slot"); if (containsSlot || integers.containsKey("d")) { - final int slot = containsSlot ? integers.get("slot") : integers.get("d"); - final int maxSlots; + int slot = containsSlot ? integers.get("slot") : integers.get("d"); + int maxSlots; if (bottomInventory.getType() == InventoryType.PLAYER && topInventory.getType() == InventoryType.CRAFTING) { @@ -172,13 +172,13 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } if (slot < 0 && slot != -999 && slot != -1) { - final String reason = "[" + packetName + "|WindowClick] " + playerName + String reason = "[" + packetName + "|WindowClick] " + playerName + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); return; } else if (slot >= maxSlots) { - final String reason = "[" + packetName + "|WindowClick] " + playerName + String reason = "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); @@ -189,7 +189,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (setCreativeSlot > 0 && packetType == PacketType.PacketPlayInSetCreativeSlot && player.getGameMode() != GameMode.CREATIVE) { - final String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); @@ -199,7 +199,7 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster if (dataVls > 0) { if (packetType == PacketType.PacketPlayInUpdateSign && !exploitUtil.checkSign(strings.values().toArray(new String[0]))) { - final String reason = "[" + packetName + "|Data] " + playerName + String reason = "[" + packetName + "|Data] " + playerName + " has sent a too big sign packet! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); @@ -207,20 +207,20 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - final boolean creativeMode = packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled(); + boolean creativeMode = packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled(); - for (final Entry itemsEntry : packetWrapper.getItems().entrySet()) { - final ItemStack item = itemsEntry.getValue(); + for (Entry itemsEntry : packetWrapper.getItems().entrySet()) { + ItemStack item = itemsEntry.getValue(); if (item != null) { if (dataVls > 0 && !exploitUtil.checkItem(item)) { - final String reason = "[" + packetName + "|Data] " + playerName + String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid item! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); return; } else if (creativeMode) { - final String blacklisted = exploitUtil.clearIfBlacklisted(item); + String blacklisted = exploitUtil.clearIfBlacklisted(item); if (blacklisted != null) { packetWrapper.write(itemsEntry.getKey(), AIR); @@ -235,9 +235,9 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } if (dataVls > 0) { - for (final Double val : packetWrapper.getDouble().values()) { + for (Double val : packetWrapper.getDouble().values()) { if (!Double.isFinite(val)) { - final String reason = "[" + packetName + "|Data] " + playerName + String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid double: " + val + "! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); @@ -245,9 +245,9 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } } - for (final Float val : packetWrapper.getFloats().values()) { + for (Float val : packetWrapper.getFloats().values()) { if (!Float.isFinite(val)) { - final String reason = "[" + packetName + "|Data] " + playerName + String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid float: " + val + "! Added vls: " + dataVls; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); @@ -260,12 +260,12 @@ public void onPacketReceive(final Cancellable event, final HamsterPlayer hamster } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPacketReceive(final PacketReceiveEvent event) { + public void onPacketReceive(PacketReceiveEvent event) { if (!packetsModule.isEnabled()) { return; } - final HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); + HamsterPlayer hamsterPlayer = event.getHamsterPlayer(); onPacketReceive(event, hamsterPlayer, hamsterPlayer.getPlayer(), event.getPacket()); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index dbbbe76..176131f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -15,23 +15,23 @@ import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayerManager; public class PlayerCommandListener implements Listener { - private final HamsterPlayerManager hamsterPlayerManager; - private final CommandsModule commandsModule; - private final ExploitPlayerManager exploitPlayerManager; + private HamsterPlayerManager hamsterPlayerManager; + private CommandsModule commandsModule; + private ExploitPlayerManager exploitPlayerManager; - PlayerCommandListener(final ModuleManager moduleManager) { + PlayerCommandListener(ModuleManager moduleManager) { this.hamsterPlayerManager = HamsterAPI.getInstance().getHamsterPlayerManager(); this.commandsModule = moduleManager.getCommandsModule(); this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { - final Player player = event.getPlayer(); - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + public void onPlayerCommand(PlayerCommandPreprocessEvent event) { + Player player = event.getPlayer(); + BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (commandsModule.isEnabled() && commandsModule.isCommand(event.getMessage())) { - final HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); + HamsterPlayer hamsterPlayer = hamsterPlayerManager.get(player); exploitPlayer.punish(commandsModule, hamsterPlayer, null, commandsModule.getPunishments(), 1); event.setCancelled(true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java index ffcf71b..28f3d8a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java @@ -15,25 +15,25 @@ import dev._2lstudios.exploitfixer.modules.MessagesModule; public class PlayerLoginListener implements Listener { - private final NotificationsModule notificationsModule; - private final MessagesModule messagesModule; - private final ConnectionModule connectionModule; + private NotificationsModule notificationsModule; + private MessagesModule messagesModule; + private ConnectionModule connectionModule; - PlayerLoginListener(final ModuleManager moduleManager) { + PlayerLoginListener(ModuleManager moduleManager) { this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onPlayerLogin(final PlayerLoginEvent event) { - final Player player = event.getPlayer(); - final String playerName = player.getName(); - final InetAddress address = event.getAddress(); - final String locale = VersionUtil.getLocale(player); + public void onPlayerLogin(PlayerLoginEvent event) { + Player player = event.getPlayer(); + String playerName = player.getName(); + InetAddress address = event.getAddress(); + String locale = VersionUtil.getLocale(player); if (connectionModule.isNullAddressEnabled() && address == null) { - final String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); + String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java index a1e4bb3..ef7e5d8 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerMoveListener.java @@ -13,23 +13,23 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class PlayerMoveListener implements Listener { - private final NotificationsModule notificationsModule; - private final EventsModule eventsModule; + private NotificationsModule notificationsModule; + private EventsModule eventsModule; - PlayerMoveListener(final ModuleManager moduleManager) { + PlayerMoveListener(ModuleManager moduleManager) { this.notificationsModule = moduleManager.getNotificationsModule(); this.eventsModule = moduleManager.getEventsModule(); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerMove(final PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { if (!eventsModule.isNullChunk()) { return; } - final Location to = event.getTo(); - final World world = to.getWorld(); - final Chunk chunk = to.getChunk(); + Location to = event.getTo(); + World world = to.getWorld(); + Chunk chunk = to.getChunk(); if (chunk == null || !world.isChunkLoaded(chunk)) { event.setCancelled(true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java index 85ec73e..456de01 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerQuitListener.java @@ -10,17 +10,17 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class PlayerQuitListener implements Listener { - private final ExploitPlayerManager exploitPlayerManager; - private final NotificationsModule notificationsModule; + private ExploitPlayerManager exploitPlayerManager; + private NotificationsModule notificationsModule; - PlayerQuitListener(final ModuleManager variables) { + PlayerQuitListener(ModuleManager variables) { this.exploitPlayerManager = variables.getExploitPlayerManager(); this.notificationsModule = variables.getNotificationsModule(); } @EventHandler - public void onPlayerQuit(final PlayerQuitEvent event) { - final Player player = event.getPlayer(); + public void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); exploitPlayerManager.remove(player); notificationsModule.setNotifications(player.getName(), false); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java new file mode 100644 index 0000000..5a60a15 --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java @@ -0,0 +1,50 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; + +public class PlayerTeleportListener implements Listener { + private ExploitPlayerManager exploitPlayerManager; + private NotificationsModule notificationsModule; + private EventsModule eventsModule; + + PlayerTeleportListener(ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + this.notificationsModule = moduleManager.getNotificationsModule(); + this.eventsModule = moduleManager.getEventsModule(); + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerTeleport(PlayerTeleportEvent event) { + if (eventsModule.isPortalCrash()) { + String cause = event.getCause().name(); + + if (cause.equals("END_PORTAL") || cause.equals("END_GATEWAY") || cause.equals("NETHER_PORTAL")) { + Player player = event.getPlayer(); + ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + + if (exploitPlayer != null) { + long currentTime = System.currentTimeMillis(); + long lastPortalUse = currentTime - exploitPlayer.getLastPortalUse(); + + if (lastPortalUse <= 1000) { + event.setCancelled(true); + notificationsModule.debug("[Events] Too fast portal teleport was cancelled."); + } else { + exploitPlayer.setLastPortalUse(currentTime); + } + } + } + } + } +} diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java index 5c5c106..d93186c 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/StructureGrowListener.java @@ -13,10 +13,10 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class StructureGrowListener implements Listener { - private final NotificationsModule notificationsModule; - private final EventsModule eventsModule; + private NotificationsModule notificationsModule; + private EventsModule eventsModule; - StructureGrowListener(final ModuleManager moduleManager) { + StructureGrowListener(ModuleManager moduleManager) { this.notificationsModule = moduleManager.getNotificationsModule(); this.eventsModule = moduleManager.getEventsModule(); } @@ -28,9 +28,10 @@ public void onStructureGrow(StructureGrowEvent event) { for (BlockState blockBefore : event.getBlocks()) { Block block = world.getBlockAt(blockBefore.getLocation()); + String type = block.getType().name(); - if (block.getType().name().equals("ENDER_PORTAL_FRAME") - || block.getType().name().equals("END_PORTAL_FRAME")) { + if (type.equals("ENDER_PORTAL_FRAME") + || type.equals("END_PORTAL_FRAME")) { event.setCancelled(true); notificationsModule.debug("[Events] A mushroom tried to break an ender portal frame."); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java index e5dd601..17123b5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java @@ -11,20 +11,20 @@ import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; public class ExploitPlayerManager { - private final Plugin plugin; - private final Server server; - private final ModuleManager moduleManager; - private final Map exploitPlayers = new HashMap<>(); + private Plugin plugin; + private Server server; + private ModuleManager moduleManager; + private Map exploitPlayers = new HashMap<>(); private int punishments = 0; - ExploitPlayerManager(final Plugin plugin, final Server server, final ModuleManager moduleManager) { + ExploitPlayerManager(Plugin plugin, Server server, ModuleManager moduleManager) { this.plugin = plugin; this.server = server; this.moduleManager = moduleManager; } - public BukkitExploitPlayer get(final UUID uuid) { - final BukkitExploitPlayer exploitPlayer; + public BukkitExploitPlayer get(UUID uuid) { + BukkitExploitPlayer exploitPlayer; if (exploitPlayers.containsKey(uuid)) { exploitPlayer = exploitPlayers.get(uuid); @@ -36,22 +36,22 @@ public BukkitExploitPlayer get(final UUID uuid) { return exploitPlayer; } - public BukkitExploitPlayer get(final Player player) { + public BukkitExploitPlayer get(Player player) { return get(player.getUniqueId()); } - public void remove(final UUID uuid) { + public void remove(UUID uuid) { exploitPlayers.remove(uuid); } - public void remove(final Player player) { + public void remove(Player player) { remove(player.getUniqueId()); } public void reload() { exploitPlayers.clear(); - for (final Player player : server.getOnlinePlayers()) { + for (Player player : server.getOnlinePlayers()) { get(player); } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java index 2e1c7cc..c082cd8 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/managers/ModuleManager.java @@ -17,21 +17,21 @@ import dev._2lstudios.exploitfixer.utils.IConfigurationUtil; public class ModuleManager { - private final Plugin plugin; - private final CommandsModule commandsModule; - private final ConnectionModule connectionModule; - private final EventsModule eventsModule; - private final ItemsFixModule itemsFixModule; - private final MessagesModule messagesModule; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; - private final ExploitPlayerManager exploitPlayerManager; - - public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin plugin) { + private Plugin plugin; + private CommandsModule commandsModule; + private ConnectionModule connectionModule; + private EventsModule eventsModule; + private ItemsFixModule itemsFixModule; + private MessagesModule messagesModule; + private NotificationsModule notificationsModule; + private PacketsModule packetsModule; + private ExploitPlayerManager exploitPlayerManager; + + public ModuleManager(IConfigurationUtil configurationUtil, Plugin plugin) { this.plugin = plugin; - final Server server = plugin.getServer(); - final Logger logger = plugin.getLogger(); + Server server = plugin.getServer(); + Logger logger = plugin.getLogger(); this.commandsModule = new CommandsModule(); this.connectionModule = new ConnectionModule(); @@ -43,9 +43,9 @@ public ModuleManager(final IConfigurationUtil configurationUtil, final Plugin pl this.exploitPlayerManager = new ExploitPlayerManager(plugin, server, this); } - public void reload(final IConfiguration configYml) { + public void reload(IConfiguration configYml) { try { - final File localeFolder = new File(plugin.getDataFolder() + "/locales/"); + File localeFolder = new File(plugin.getDataFolder() + "/locales/"); localeFolder.mkdirs(); @@ -57,8 +57,8 @@ public void reload(final IConfiguration configYml) { this.notificationsModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); - } catch (final NullPointerException exception) { - final NullPointerException newException = new NullPointerException( + } catch (NullPointerException exception) { + NullPointerException newException = new NullPointerException( "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); newException.setStackTrace(exception.getStackTrace()); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index 2d28e9e..db65d78 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -6,14 +6,14 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class CommandsModule implements IPunishmentModule { - private static final Pattern SYNTAX_PATTERN = Pattern.compile("[\\w]{1,}:"); + private static Pattern SYNTAX_PATTERN = Pattern.compile("[\\w]{1,}:"); private Collection commands; private Collection punishments; private String name; private boolean enabled; - public void reload(final IConfiguration configYml) { + public void reload(IConfiguration configYml) { this.name = "Commands"; this.enabled = configYml.getBoolean("commands.enabled"); this.commands = configYml.getStringList("commands.commands"); @@ -21,7 +21,7 @@ public void reload(final IConfiguration configYml) { } @Override - final public boolean isEnabled() { + public boolean isEnabled() { return enabled; } @@ -30,11 +30,11 @@ public String getName() { return name; } - public final boolean isCommand(final String rawMessage) { + public boolean isCommand(String rawMessage) { if (rawMessage != null) { - final String message = SYNTAX_PATTERN.matcher(rawMessage).replaceAll("").toLowerCase(); + String message = SYNTAX_PATTERN.matcher(rawMessage).replaceAll("").toLowerCase(); - for (final String command : commands) { + for (String command : commands) { if (message.startsWith(command)) { return true; } @@ -44,7 +44,7 @@ public final boolean isCommand(final String rawMessage) { return false; } - public final Collection getPunishments() { + public Collection getPunishments() { return punishments; } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java index 34a981c..d7705a1 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ConnectionModule.java @@ -9,7 +9,7 @@ public class ConnectionModule implements IPunishmentModule { private String name; private Collection punishments; - public void reload(final IConfiguration configYml) { + public void reload(IConfiguration configYml) { this.nullAddressEnabled = configYml.getBoolean("connection.null_address"); this.name = "Connection"; this.punishments = configYml.getStringList("connection.punishments"); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java index 8dab11b..22a77e1 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -8,15 +8,17 @@ public class EventsModule implements IModule { private boolean disableTracking; private boolean enderPortalBreak; private boolean dispenserCrash; + private boolean portalCrash; - public void reload(final IConfiguration configYml) { - final String name = getName().toLowerCase(); + public void reload(IConfiguration configYml) { + String name = getName().toLowerCase(); nullChunk = configYml.getBoolean(name + ".null_chunk", true); selfDamage = configYml.getBoolean(name + ".self_damage", true); disableTracking = configYml.getBoolean(name + ".disable_tracking", true); enderPortalBreak = configYml.getBoolean(name + ".ender_portal_break", true); dispenserCrash = configYml.getBoolean(name + ".dispenser_crash", true); + portalCrash = configYml.getBoolean(name + ".portal_crash", true); } @Override @@ -48,4 +50,8 @@ public boolean isEnderPortalBreak() { public boolean isDispenserCrash() { return dispenserCrash; } + + public boolean isPortalCrash() { + return portalCrash; + } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java index ac3127f..b58a269 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/IMessagesModule.java @@ -1,5 +1,5 @@ package dev._2lstudios.exploitfixer.modules; public interface IMessagesModule { - String getString(final String locale, final String path); + String getString(String locale, String path); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java index 721e333..6816cfa 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java @@ -3,5 +3,5 @@ import org.bukkit.entity.Player; public interface INotificationsModule extends IModule { - public void sendNotification(final String check, final Player player, final int violations); + public void sendNotification(String check, Player player, int violations); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index ff1f41a..efd0e83 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -18,18 +18,18 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class ItemsFixModule implements IModule { - private final Plugin plugin; + private Plugin plugin; private boolean enabled; private int enchantLimit; private int maxStackSize; private Collection blacklist; - public ItemsFixModule(final Plugin plugin) { + public ItemsFixModule(Plugin plugin) { this.plugin = plugin; } - public void reload(final IConfiguration configYml) { - final String name = getName().toLowerCase(); + public void reload(IConfiguration configYml) { + String name = getName().toLowerCase(); this.enabled = configYml.getBoolean(name + ".enabled"); this.enchantLimit = configYml.getInt(name + ".enchant_limit"); @@ -59,17 +59,17 @@ public Collection getBlacklist() { return blacklist; } - public ItemStack fixItem(final ItemStack item) { - final Material material = Material.getMaterial(item.getType().name()); - final ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); - final short durability = item.getDurability(); + public ItemStack fixItem(ItemStack item) { + Material material = Material.getMaterial(item.getType().name()); + ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); + short durability = item.getDurability(); if (item.hasItemMeta()) { - final ItemMeta oldItemMeta = item.getItemMeta(); - final String displayName = oldItemMeta.getDisplayName(); - final List lore = oldItemMeta.getLore(); + ItemMeta oldItemMeta = item.getItemMeta(); + String displayName = oldItemMeta.getDisplayName(); + List lore = oldItemMeta.getLore(); // This applies vanilla levels to enchants - final boolean applyLevelRestriction = enchantLimit != 0; + boolean applyLevelRestriction = enchantLimit != 0; try { if (oldItemMeta.hasCustomModelData()) { @@ -80,21 +80,21 @@ public ItemStack fixItem(final ItemStack item) { } if (oldItemMeta instanceof EnchantmentStorageMeta) { - final EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; - final EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; + EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) oldItemMeta; + EnchantmentStorageMeta newEnchantmentStorageMeta = (EnchantmentStorageMeta) newItemMeta; - for (final Entry entry : enchantmentStorageMeta.getStoredEnchants().entrySet()) { - final Enchantment enchantment = entry.getKey(); - final int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); + for (Entry entry : enchantmentStorageMeta.getStoredEnchants().entrySet()) { + Enchantment enchantment = entry.getKey(); + int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); if (enchantLimit > -1 && level > -1) { newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, !applyLevelRestriction); } } } else { - for (final Entry entry : item.getEnchantments().entrySet()) { - final Enchantment enchantment = entry.getKey(); - final int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); + for (Entry entry : item.getEnchantments().entrySet()) { + Enchantment enchantment = entry.getKey(); + int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); if (enchantLimit > -1 && level > -1) { newItemMeta.addEnchant(enchantment, level, !applyLevelRestriction); @@ -103,25 +103,25 @@ public ItemStack fixItem(final ItemStack item) { } if (newItemMeta instanceof BookMeta) { - final BookMeta oldBookMeta = (BookMeta) oldItemMeta; - final BookMeta newBookMeta = (BookMeta) newItemMeta; + BookMeta oldBookMeta = (BookMeta) oldItemMeta; + BookMeta newBookMeta = (BookMeta) newItemMeta; newBookMeta.setTitle(oldBookMeta.getTitle()); newBookMeta.setAuthor(oldBookMeta.getAuthor()); newBookMeta.setPages(oldBookMeta.getPages()); } else if (newItemMeta instanceof SkullMeta) { - final SkullMeta oldSkullMeta = (SkullMeta) oldItemMeta; - final SkullMeta newSkullMeta = (SkullMeta) newItemMeta; + SkullMeta oldSkullMeta = (SkullMeta) oldItemMeta; + SkullMeta newSkullMeta = (SkullMeta) newItemMeta; newSkullMeta.setOwner(oldSkullMeta.getOwner()); } else if (newItemMeta instanceof BannerMeta) { - final BannerMeta oldBannerMeta = (BannerMeta) oldItemMeta; - final BannerMeta newBannerMeta = (BannerMeta) newItemMeta; + BannerMeta oldBannerMeta = (BannerMeta) oldItemMeta; + BannerMeta newBannerMeta = (BannerMeta) newItemMeta; newBannerMeta.setBaseColor(oldBannerMeta.getBaseColor()); } else if (newItemMeta instanceof LeatherArmorMeta) { - final LeatherArmorMeta oldLeatherArmorMeta = (LeatherArmorMeta) oldItemMeta; - final LeatherArmorMeta newLeatherArmorMeta = (LeatherArmorMeta) newItemMeta; + LeatherArmorMeta oldLeatherArmorMeta = (LeatherArmorMeta) oldItemMeta; + LeatherArmorMeta newLeatherArmorMeta = (LeatherArmorMeta) newItemMeta; newLeatherArmorMeta.setColor(oldLeatherArmorMeta.getColor()); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index e7c19b6..e773857 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -11,16 +11,16 @@ import dev._2lstudios.exploitfixer.utils.IConfigurationUtil; public class MessagesModule implements IMessagesModule { - private static final String NOTFOUND_STRING = ""; - private final IConfigurationUtil configurationUtil; - private final Logger logger; - private final String version; - private final Map> locales = new HashMap<>(); - private final Collection defaultLocales = new HashSet<>(); + private static String NOTFOUND_STRING = ""; + private IConfigurationUtil configurationUtil; + private Logger logger; + private String version; + private Map> locales = new HashMap<>(); + private Collection defaultLocales = new HashSet<>(); private String web; private String defaultLocale; - public MessagesModule(final IConfigurationUtil configurationUtil, final Logger logger, final String version) { + public MessagesModule(IConfigurationUtil configurationUtil, Logger logger, String version) { this.configurationUtil = configurationUtil; this.logger = logger; this.version = version; @@ -45,9 +45,9 @@ public MessagesModule(final IConfigurationUtil configurationUtil, final Logger l defaultLocales.add("zhtw"); } - public void putSection(final IConfiguration langFile, final Map locale, final String currentPath) { - for (final String key : langFile.getKeys()) { - final IConfiguration section = langFile.getSection(key); + public void putSection(IConfiguration langFile, Map locale, String currentPath) { + for (String key : langFile.getKeys()) { + IConfiguration section = langFile.getSection(key); if (section != null) { if (currentPath.isEmpty()) { @@ -65,25 +65,25 @@ public void putSection(final IConfiguration langFile, final Map } } - public void reload(final IConfiguration configYml, final File localeFolder) { + public void reload(IConfiguration configYml, File localeFolder) { web = configYml.getString("web", " (Reset ExploitFixer config file)"); defaultLocale = configYml.getString("locale", "en").toLowerCase(); - for (final String locale : defaultLocales) { + for (String locale : defaultLocales) { configurationUtil.create("%datafolder%/locales/" + locale + ".yml", "locales/" + locale + ".yml"); } - for (final File file : localeFolder.listFiles()) { - final String fileName = file.getName(); + for (File file : localeFolder.listFiles()) { + String fileName = file.getName(); try { - final IConfiguration langFile = configurationUtil.get(file.toPath().toString()); - final Map locale = new HashMap<>(); + IConfiguration langFile = configurationUtil.get(file.toPath().toString()); + Map locale = new HashMap<>(); putSection(langFile, locale, ""); locales.put(fileName.substring(0, 2).toLowerCase(), locale); - } catch (final Exception ex) { + } catch (Exception ex) { logger.info( "Wasn't able to load locale " + fileName + " because of a " + ex.getClass().getName() + "!"); } @@ -99,8 +99,8 @@ public String getName() { } @Override - public String getString(final String locale, final String path) { - final String string; + public String getString(String locale, String path) { + String string; if (locales.containsKey(locale)) { string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); @@ -113,47 +113,47 @@ public String getString(final String locale, final String path) { return string.replace("%version%", version).replace("%web%", web).replace('&', '\u00a7'); } - public final String getReload(final String locale) { + public String getReload(String locale) { return getString(locale, "commands.reload"); } - public final String getHelp(final String locale) { + public String getHelp(String locale) { return getString(locale, "commands.help"); } - public final String getUnknown(final String locale) { + public String getUnknown(String locale) { return getString(locale, "commands.error.unknown"); } - public final String getPermission(final String locale) { + public String getPermission(String locale) { return getString(locale, "commands.error.permission"); } - public final String getConsole(final String locale) { + public String getConsole(String locale) { return getString(locale, "commands.error.console"); } - public final String getEnable(final String locale) { + public String getEnable(String locale) { return getString(locale, "commands.notifications.enable"); } - public final String getDisable(final String locale) { + public String getDisable(String locale) { return getString(locale, "commands.notifications.disable"); } - public final String getKickMessage(final IModule module, final String locale) { + public String getKickMessage(IModule module, String locale) { return getString(locale, "modules." + module.getName().toLowerCase() + ".kick_message"); } - public final String getKickMessage(final String module, final String locale) { + public String getKickMessage(String module, String locale) { return getString(locale, "modules." + module.toLowerCase() + ".kick_message"); } - public String getStats(final String locale) { + public String getStats(String locale) { return getString(locale, "commands.stats"); } - public String getMojangDown(final String locale) { + public String getMojangDown(String locale) { return getString(locale, "mojang_down"); } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index 7f3a074..7d04818 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -15,14 +15,14 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class NotificationsModule implements INotificationsModule { - private final Server server; - private final Logger logger; - private final Map packetDebug = new HashMap<>(); - private final Collection notifications = new HashSet<>(); + private Server server; + private Logger logger; + private Map packetDebug = new HashMap<>(); + private Collection notifications = new HashSet<>(); private boolean enabled, debug; private String message; - public NotificationsModule(final Server server, final Logger logger) { + public NotificationsModule(Server server, Logger logger) { this.server = server; this.logger = logger; } @@ -31,7 +31,7 @@ public String getMessage() { return message; } - public void reload(final IConfiguration configYml) { + public void reload(IConfiguration configYml) { this.enabled = configYml.getBoolean("notifications.enabled"); this.debug = configYml.getBoolean("notifications.debug"); this.message = configYml.getString("notifications.message").replace('&', '\u00A7'); @@ -42,7 +42,7 @@ public boolean isEnabled() { return this.enabled; } - public void addPacketDebug(final String packetType) { + public void addPacketDebug(String packetType) { if (this.debug) { packetDebug.put(packetType, packetDebug.getOrDefault(packetType, 0) + 1); } @@ -50,16 +50,16 @@ public void addPacketDebug(final String packetType) { public void debugPackets() { if (this.debug && !packetDebug.isEmpty()) { - final Set> entries = new HashSet<>(packetDebug.entrySet()); - final StringBuilder stringBuilder = new StringBuilder("Received Packets (x%total%): "); + Set> entries = new HashSet<>(packetDebug.entrySet()); + StringBuilder stringBuilder = new StringBuilder("Received Packets (x%total%): "); boolean isFirst = true; int total = 0; packetDebug.clear(); - for (final Entry packetEntry : entries) { - final String packetType = packetEntry.getKey(); - final int amount = packetEntry.getValue(); + for (Entry packetEntry : entries) { + String packetType = packetEntry.getKey(); + int amount = packetEntry.getValue(); if (isFirst) { isFirst = false; @@ -75,13 +75,13 @@ public void debugPackets() { } } - public void debug(final String message) { + public void debug(String message) { if (this.debug) { this.logger.info(message); } } - public final void setNotifications(final String playerName, final boolean input) { + public void setNotifications(String playerName, boolean input) { if (input) { notifications.add(playerName); } else { @@ -89,29 +89,29 @@ public final void setNotifications(final String playerName, final boolean input) } } - public final boolean isNotifications(final String playerName) { + public boolean isNotifications(String playerName) { return notifications.contains(playerName); } - public final boolean isDebug() { + public boolean isDebug() { return debug; } - public final Collection getNotifications() { + public Collection getNotifications() { return notifications; } - public void sendNotification(final String check, final Player exploiterPlayer, final int violations) { + public void sendNotification(String check, Player exploiterPlayer, int violations) { if (isEnabled() && exploiterPlayer != null) { - final int ping = getPing(exploiterPlayer); - final String notification = getMessage().replace("%player%", exploiterPlayer.getName()).replace("%check%", check) + int ping = getPing(exploiterPlayer); + String notification = getMessage().replace("%player%", exploiterPlayer.getName()).replace("%check%", check) .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); - final ConsoleCommandSender console = server.getConsoleSender(); + ConsoleCommandSender console = server.getConsoleSender(); console.sendMessage(notification); - for (final String notificationPlayerName : getNotifications()) { - final Player notificationPlayer = server.getPlayer(notificationPlayerName); + for (String notificationPlayerName : getNotifications()) { + Player notificationPlayer = server.getPlayer(notificationPlayerName); if (notificationPlayer != null) { notificationPlayer.sendMessage(notification); @@ -120,12 +120,12 @@ public void sendNotification(final String check, final Player exploiterPlayer, f } } - private int getPing(final Player player) { + private int getPing(Player player) { try { - final Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); + Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); return (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (final Exception ignored) { + } catch (Exception ignored) { return 0; } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 1be7427..ced6897 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -9,7 +9,7 @@ import dev._2lstudios.exploitfixer.exploit.Violations; public class PacketsModule implements IViolationModule { - private final Map multipliers = new HashMap<>(); + private Map multipliers = new HashMap<>(); private Collection blacklist = new HashSet<>(); private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, @@ -17,9 +17,9 @@ public class PacketsModule implements IViolationModule { private int dataBytesBook, dataBytesSign, dataBytes; private boolean enabled, offline; - public void reload(final IConfiguration configYml) { - final String name = getName().toLowerCase(); - final IConfiguration configurationSection = configYml.getSection(name + ".multipliers"); + public void reload(IConfiguration configYml) { + String name = getName().toLowerCase(); + IConfiguration configurationSection = configYml.getSection(name + ".multipliers"); this.enabled = configYml.getBoolean(name + ".enabled"); this.cancelVls = configYml.getDouble(name + ".cancel_vls"); @@ -39,7 +39,7 @@ public void reload(final IConfiguration configYml) { this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); this.violations = new Violations(configYml.getSection(name + ".violations")); - for (final String key : configurationSection.getKeys()) { + for (String key : configurationSection.getKeys()) { multipliers.put(key, configurationSection.getDouble(key)); } } @@ -69,7 +69,7 @@ public Violations getViolations() { return violations; } - public double getMultiplier(final String packetName) { + public double getMultiplier(String packetName) { return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); } @@ -121,7 +121,7 @@ public boolean isOffline() { return offline; } - public boolean isBlacklisted(final String packetName) { + public boolean isBlacklisted(String packetName) { return blacklist.contains(packetName); } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java b/src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java index fd72453..b07cbb5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/tasks/ExploitFixerRepeatingTask.java @@ -3,10 +3,10 @@ import dev._2lstudios.exploitfixer.modules.NotificationsModule; public class ExploitFixerRepeatingTask implements Runnable { - private final NotificationsModule notificationsModule; + private NotificationsModule notificationsModule; int seconds = 0; - public ExploitFixerRepeatingTask(final NotificationsModule notificationsModule) { + public ExploitFixerRepeatingTask(NotificationsModule notificationsModule) { this.notificationsModule = notificationsModule; } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java index 724fcd7..f7ecdad 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java @@ -14,15 +14,15 @@ import java.util.logging.Logger; public class BukkitConfigurationUtil implements IConfigurationUtil { - private static final String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; - private final String dataFolderPath; - private final String prefix; - private final Logger logger; - private final Plugin plugin; - private final BukkitScheduler scheduler; - private final ClassLoader classLoader; - - public BukkitConfigurationUtil(final Plugin plugin) { + private static String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; + private String dataFolderPath; + private String prefix; + private Logger logger; + private Plugin plugin; + private BukkitScheduler scheduler; + private ClassLoader classLoader; + + public BukkitConfigurationUtil(Plugin plugin) { this.plugin = plugin; this.scheduler = plugin.getServer().getScheduler(); this.logger = plugin.getLogger(); @@ -31,16 +31,16 @@ public BukkitConfigurationUtil(final Plugin plugin) { this.prefix = "[" + plugin.getName() + "]"; } - private void createParentFolder(final File file) { - final File parentFile = file.getParentFile(); + private void createParentFolder(File file) { + File parentFile = file.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } } - public IConfiguration get(final String path) { - final File file = new File(path.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); + public IConfiguration get(String path) { + File file = new File(path.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath)); if (file.exists()) { return new BukkitConfiguration(YamlConfiguration.loadConfiguration(file)); @@ -49,14 +49,14 @@ public IConfiguration get(final String path) { } } - public void create(final String rawPath, final String resourcePath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + public void create(String rawPath, String resourcePath) { + String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); try { - final File configFile = new File(path); + File configFile = new File(path); if (!configFile.exists()) { - final InputStream inputStream = classLoader.getResourceAsStream(resourcePath); + InputStream inputStream = classLoader.getResourceAsStream(resourcePath); createParentFolder(configFile); @@ -68,27 +68,27 @@ public void create(final String rawPath, final String resourcePath) { logger.info(prefix + " File '" + path + "' has been created!"); } - } catch (final IOException e) { + } catch (IOException e) { logger.info(prefix + " Unable to create '" + path + "'!"); } } - public void save(final IConfiguration configuration, final String rawPath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + public void save(IConfiguration configuration, String rawPath) { + String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); scheduler.runTaskAsynchronously(plugin, () -> { try { ((YamlConfiguration) configuration.getObject()).save(path); logger.info(prefix + " File '" + path + "' has been saved!"); - } catch (final IOException e) { + } catch (IOException e) { logger.info(prefix + " Unable to save '" + path + "'!"); } }); } - public void delete(final String rawPath) { - final String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); + public void delete(String rawPath) { + String path = rawPath.replace(DATA_FOLDER_PLACEHOLDER, dataFolderPath); scheduler.runTaskAsynchronously(plugin, () -> { try { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 7bf66e4..5664d3f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -25,26 +25,26 @@ import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; public class ExploitUtil { - private final ExploitPlayerManager exploitPlayerManager; - private final ItemsFixModule itemsFixModule; - private final NotificationsModule notificationsModule; - private final PacketsModule packetsModule; + private ExploitPlayerManager exploitPlayerManager; + private ItemsFixModule itemsFixModule; + private NotificationsModule notificationsModule; + private PacketsModule packetsModule; - public ExploitUtil(final ModuleManager moduleManager) { + public ExploitUtil(ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); } - private boolean checkBlockState(final BlockStateMeta meta) { + private boolean checkBlockState(BlockStateMeta meta) { if (meta.hasBlockState()) { - final BlockState blockState = meta.getBlockState(); + BlockState blockState = meta.getBlockState(); if (blockState instanceof InventoryHolder) { - final InventoryHolder inventoryHolder = (InventoryHolder) blockState; + InventoryHolder inventoryHolder = (InventoryHolder) blockState; - for (final ItemStack item : inventoryHolder.getInventory().getContents()) { + for (ItemStack item : inventoryHolder.getInventory().getContents()) { return checkItem(item); } } @@ -53,14 +53,14 @@ private boolean checkBlockState(final BlockStateMeta meta) { return true; } - private boolean checkBook(final BookMeta meta) { - final String title = meta.getTitle(); + private boolean checkBook(BookMeta meta) { + String title = meta.getTitle(); if (title != null && title.length() > 32) { return false; } - final String author = meta.getAuthor(); + String author = meta.getAuthor(); if (author != null && author.length() > 16) { return false; @@ -70,10 +70,10 @@ private boolean checkBook(final BookMeta meta) { return false; } - final int dataBytesBook = packetsModule.getDataBytesBook(); + int dataBytesBook = packetsModule.getDataBytesBook(); - for (final String page : meta.getPages()) { - final int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; + for (String page : meta.getPages()) { + int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; if (pageBytes > dataBytesBook) { return false; @@ -83,7 +83,7 @@ private boolean checkBook(final BookMeta meta) { return true; } - private boolean checkFirework(final FireworkMeta meta) { + private boolean checkFirework(FireworkMeta meta) { if (meta.getPower() > 3) { return false; } @@ -107,19 +107,19 @@ private boolean checkFirework(final FireworkMeta meta) { return true; } - public boolean checkItem(final ItemStack item) { + public boolean checkItem(ItemStack item) { try { if (item != null && item.hasItemMeta()) { - final ItemMeta itemMeta = item.getItemMeta(); + ItemMeta itemMeta = item.getItemMeta(); if (itemMeta != null) { - final String displayName = itemMeta.getDisplayName(); + String displayName = itemMeta.getDisplayName(); if (displayName != null && displayName.length() > 1536) { return false; } - final List lore = itemMeta.getLore(); + List lore = itemMeta.getLore(); if (lore != null && lore.size() > 64) { return false; @@ -141,14 +141,14 @@ public boolean checkItem(final ItemStack item) { return true; } - public boolean checkSign(final String[] linesString) { - final int dataBytesSign = packetsModule.getDataBytesSign(); + public boolean checkSign(String[] linesString) { + int dataBytesSign = packetsModule.getDataBytesSign(); if (linesString != null && dataBytesSign > 0) { if (linesString.length > 4) { return true; } else { - for (final String line : linesString) { + for (String line : linesString) { if (line.getBytes(StandardCharsets.UTF_8).length > dataBytesSign) { return false; } @@ -159,9 +159,9 @@ public boolean checkSign(final String[] linesString) { return true; } - public String clearIfBlacklisted(final ItemStack itemStack) { - final Collection blacklist = itemsFixModule.getBlacklist(); - final String materialName = itemStack.getType().toString(); + public String clearIfBlacklisted(ItemStack itemStack) { + Collection blacklist = itemsFixModule.getBlacklist(); + String materialName = itemStack.getType().toString(); if (blacklist != null && blacklist.contains(materialName)) { itemStack.setType(Material.AIR); @@ -172,17 +172,17 @@ public String clearIfBlacklisted(final ItemStack itemStack) { return null; } - public void addVls(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, - final double vls) { + public void addVls(Cancellable event, HamsterPlayer hamsterPlayer, Player player, + double vls) { if (vls > 0) { - final BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); exploitPlayer.addVls(event, hamsterPlayer, packetsModule, vls); } } - public void cancelExploit(final Cancellable event, final HamsterPlayer hamsterPlayer, final Player player, - final String reason, final double vls) { + public void cancelExploit(Cancellable event, HamsterPlayer hamsterPlayer, Player player, + String reason, double vls) { notificationsModule.debug(reason); event.setCancelled(true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java index 1e4d570..bd727df 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/IConfigurationUtil.java @@ -3,11 +3,11 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public interface IConfigurationUtil { - public IConfiguration get(final String file); + public IConfiguration get(String file); - public void create(final String file, final String resourcePath); + public void create(String file, String resourcePath); - public void save(final IConfiguration configuration, final String file); + public void save(IConfiguration configuration, String file); - public void delete(final String file); + public void delete(String file); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java index dcf2eb2..e791b3c 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ProtocolUtil.java @@ -3,8 +3,8 @@ import io.netty.buffer.ByteBuf; public class ProtocolUtil { - private static final int SEGMENT_BITS = 0x7F; - private static final int CONTINUE_BIT = 0x80; + private static int SEGMENT_BITS = 0x7F; + private static int CONTINUE_BIT = 0x80; public static int readVarInt(ByteBuf byteBuf) { int value = 0; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java index b0cca0e..51e2bad 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java @@ -6,20 +6,20 @@ import org.bukkit.entity.Player.Spigot; public class VersionUtil { - public static String getLocale(final Player player) { + public static String getLocale(Player player) { String locale; try { locale = player.getClass().getMethod("getLocale").invoke(player).toString(); - } catch (final Exception exception) { + } catch (Exception exception) { try { - final Spigot spigot = player.spigot(); - final Method getLocaleMethod = spigot.getClass().getMethod("getLocale"); + Spigot spigot = player.spigot(); + Method getLocaleMethod = spigot.getClass().getMethod("getLocale"); getLocaleMethod.setAccessible(true); locale = getLocaleMethod.invoke(spigot).toString(); - } catch (final Exception exception1) { + } catch (Exception exception1) { locale = "en"; } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 786eaa8..e1297ca 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,9 @@ events: # Prevents crashing when using dispensers that drop items out of the bounds. dispenser_crash: true + # Prevents portal teleport spam crash + portal_crash: true + # Prevents the use of invalid packets to crash the server. packets: enabled: true @@ -117,7 +120,7 @@ packets: PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.15 - PacketPlayInSettings: 0.15 + PacketPlayInSettings: 0.05 PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 0.1 From f26215db294d382392d2b6d282d36f2d59e9eda1 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 5 Sep 2022 22:01:21 -0300 Subject: [PATCH 264/336] big performance improvements (reflection cache) --- .../exploit/BukkitExploitPlayer.java | 54 +++++++++++++++---- .../exploitfixer/exploit/ExploitPlayer.java | 15 +++++- .../listener/PlayerTeleportListener.java | 1 - .../managers/ExploitPlayerManager.java | 2 +- .../modules/INotificationsModule.java | 4 +- .../modules/NotificationsModule.java | 47 +++++++--------- .../exploitfixer/utils/VersionUtil.java | 24 +++++++-- 7 files changed, 98 insertions(+), 49 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 9f0a736..5c5de0a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -1,8 +1,11 @@ package dev._2lstudios.exploitfixer.exploit; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.Collection; import java.util.HashSet; import java.util.Map; +import java.util.UUID; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -28,7 +31,8 @@ public class BukkitExploitPlayer extends ExploitPlayer { private MessagesModule messagesModule; private NotificationsModule notificationsModule; - public BukkitExploitPlayer(Plugin plugin, ModuleManager moduleManager) { + public BukkitExploitPlayer(Plugin plugin, ModuleManager moduleManager, UUID uuid) { + super(uuid); this.plugin = plugin; this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.messagesModule = moduleManager.getMessagesModule(); @@ -107,16 +111,16 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa PacketType packetType = packet.getType(); if (packetType != null) { - notificationsModule.sendNotification(packetType.toString(), player, newVls); + notificationsModule.sendNotification(packetType.toString(), this, newVls); } else { - notificationsModule.sendNotification(moduleName, player, newVls); + notificationsModule.sendNotification(moduleName, this, newVls); } } else { - notificationsModule.sendNotification(moduleName, player, newVls); + notificationsModule.sendNotification(moduleName, this, newVls); } } else { String check_name = packet != null ? packet.getType().toString() : module.getName(); - int ping = getPing(player); + int ping = getPing(); String replacement_punishment = punishment .replace("%player%", playerName) .replace("%vls%", String.valueOf(newVls)) @@ -136,13 +140,41 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa exploitPlayerManager.addPunishment(); } } - private int getPing(Player player) { - try { - Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); - return (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (Exception ignored) { - return 0; + private Method getHandleMethod = null; + private Field pingField = null; + + public Method getHandleMethod() throws NoSuchMethodException, SecurityException { + return getHandleMethod == null ? getHandleMethod = Player.class.getMethod("getHandle") : getHandleMethod; + } + + public Field getPingField(Object playerHandle) throws NoSuchFieldException, SecurityException { + return pingField == null ? pingField = playerHandle.getClass().getField("ping") : pingField; + } + + public int getPing() { + Player player = plugin.getServer().getPlayer(getUUID()); + + if (player != null && player.isOnline()) { + try { + Object playerHandle = getHandleMethod().invoke(player); + + return (int) getPingField(playerHandle).get(playerHandle); + } catch (Exception ignored) { + // Ignored + } } + + return 0; + } + + public String getName() { + Player player = plugin.getServer().getPlayer(getUUID()); + + if (player != null && player.isOnline()) { + return player.getName(); + } + + return "N/A"; } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index ad20588..6508be4 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -4,16 +4,19 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.UUID; import dev._2lstudios.exploitfixer.modules.IViolationModule; -public class ExploitPlayer { +public abstract class ExploitPlayer { + private UUID uuid; private Map violations; private Collection> punishments; private long lastViolation = 0; private long lastPortalUse = 0; - public ExploitPlayer() { + public ExploitPlayer(UUID uuid) { + this.uuid = uuid; this.violations = new HashMap<>(); this.punishments = new HashSet<>(); } @@ -49,4 +52,12 @@ public Map getViolations() { public double getViolations(IViolationModule module) { return violations.getOrDefault(module, 0D); } + + public UUID getUUID() { + return uuid; + } + + public abstract String getName(); + + public abstract int getPing(); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java index 5a60a15..2edad80 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerTeleportListener.java @@ -5,7 +5,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java index 17123b5..aaf002d 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java @@ -29,7 +29,7 @@ public BukkitExploitPlayer get(UUID uuid) { if (exploitPlayers.containsKey(uuid)) { exploitPlayer = exploitPlayers.get(uuid); } else { - exploitPlayer = new BukkitExploitPlayer(this.plugin, moduleManager); + exploitPlayer = new BukkitExploitPlayer(this.plugin, moduleManager, uuid); exploitPlayers.put(uuid, exploitPlayer); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java index 6816cfa..7f09ae6 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/INotificationsModule.java @@ -1,7 +1,7 @@ package dev._2lstudios.exploitfixer.modules; -import org.bukkit.entity.Player; +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; public interface INotificationsModule extends IModule { - public void sendNotification(String check, Player player, int violations); + public void sendNotification(String check, ExploitPlayer player, int violations); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index 7d04818..aa126cc 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -4,8 +4,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.logging.Logger; import org.bukkit.Server; @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import dev._2lstudios.exploitfixer.configuration.IConfiguration; +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; public class NotificationsModule implements INotificationsModule { private Server server; @@ -101,34 +102,24 @@ public Collection getNotifications() { return notifications; } - public void sendNotification(String check, Player exploiterPlayer, int violations) { - if (isEnabled() && exploiterPlayer != null) { - int ping = getPing(exploiterPlayer); - String notification = getMessage().replace("%player%", exploiterPlayer.getName()).replace("%check%", check) - .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); + public void sendNotification(String check, ExploitPlayer player, int violations) { + if (isEnabled() && player != null) { + int ping = player.getPing(); + String notification = getMessage().replace("%player%", player.getName()).replace("%check%", check) + .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); ConsoleCommandSender console = server.getConsoleSender(); - - console.sendMessage(notification); - - for (String notificationPlayerName : getNotifications()) { - Player notificationPlayer = server.getPlayer(notificationPlayerName); - - if (notificationPlayer != null) { - notificationPlayer.sendMessage(notification); - } - } - } - } - - private int getPing(Player player) { - try { - Object playerHandle = player.getClass().getMethod("getHandle").invoke(player); - - return (int) playerHandle.getClass().getField("ping").get(playerHandle); - } catch (Exception ignored) { - return 0; - } - } + + console.sendMessage(notification); + + for (String notificationPlayerName : getNotifications()) { + Player notificationPlayer = server.getPlayer(notificationPlayerName); + + if (notificationPlayer != null) { + notificationPlayer.sendMessage(notification); + } + } + } + } @Override public String getName() { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java index 51e2bad..6596414 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java @@ -6,19 +6,35 @@ import org.bukkit.entity.Player.Spigot; public class VersionUtil { + private static Method getLocalePlayerMethod = null; + private static Method getLocaleSpigotMethod = null; + + private static Method getLocalePlayerMethod() throws NoSuchMethodException, SecurityException { + return getLocalePlayerMethod == null ? getLocalePlayerMethod = Player.class.getMethod("getLocale") + : getLocalePlayerMethod; + } + + private static Method getLocaleSpigotMethod() throws NoSuchMethodException, SecurityException { + return getLocaleSpigotMethod == null ? getLocaleSpigotMethod = Spigot.class.getMethod("getLocale") + : getLocaleSpigotMethod; + } + public static String getLocale(Player player) { String locale; try { - locale = player.getClass().getMethod("getLocale").invoke(player).toString(); + Method getLocaleMethod = getLocalePlayerMethod(); + + getLocaleMethod.setAccessible(true); + + locale = getLocaleMethod.invoke(player).toString(); } catch (Exception exception) { try { - Spigot spigot = player.spigot(); - Method getLocaleMethod = spigot.getClass().getMethod("getLocale"); + Method getLocaleMethod = getLocaleSpigotMethod(); getLocaleMethod.setAccessible(true); - locale = getLocaleMethod.invoke(spigot).toString(); + locale = getLocaleMethod.invoke(player.spigot()).toString(); } catch (Exception exception1) { locale = "en"; } From 4b54addd1ae628fdb198d4c3c7891b98a5596620 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 5 Sep 2022 23:02:34 -0300 Subject: [PATCH 265/336] increase settings vls a little --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e1297ca..e64513b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -120,7 +120,7 @@ packets: PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.15 - PacketPlayInSettings: 0.05 + PacketPlayInSettings: 0.1 PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 0.1 From 2486253ff7c08ede93b6d39e5eec7701043037ae Mon Sep 17 00:00:00 2001 From: linsaftw Date: Mon, 5 Sep 2022 23:03:39 -0300 Subject: [PATCH 266/336] 1.7.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f63f65..6d71d32 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.2 + 1.7.3 https://www.spigotmc.org/resources/62842/ From c50e0c64a676c014cbd860efb5b34221d2922e5c Mon Sep 17 00:00:00 2001 From: linsaftw Date: Tue, 6 Sep 2022 11:34:37 -0300 Subject: [PATCH 267/336] use reflection util --- .../commands/ExploitFixerCommand.java | 3 +- .../exploit/BukkitExploitPlayer.java | 53 ++++++++++++++----- .../exploitfixer/exploit/ExploitPlayer.java | 2 + .../listener/PlayerLoginListener.java | 9 ++-- .../exploitfixer/utils/ReflectionUtil.java | 32 +++++++++++ .../exploitfixer/utils/VersionUtil.java | 51 ------------------ 6 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java delete mode 100644 src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 0c92fb5..7f2ad97 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -9,7 +9,6 @@ import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.modules.MessagesModule; public class ExploitFixerCommand implements CommandExecutor { @@ -32,7 +31,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, String lang; if (sender instanceof Player) { - lang = VersionUtil.getLocale((Player) sender); + lang = exploitPlayerManager.get((Player) sender).getLocale(); } else { lang = "en"; } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 5c5de0a..e9929f0 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -1,6 +1,5 @@ package dev._2lstudios.exploitfixer.exploit; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Collection; import java.util.HashSet; @@ -16,11 +15,11 @@ import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.modules.IModule; import dev._2lstudios.exploitfixer.modules.IViolationModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; import dev._2lstudios.exploitfixer.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.utils.ReflectionUtil; import dev._2lstudios.hamsterapi.enums.PacketType; import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; @@ -99,7 +98,7 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa for (String punishment : punishments) { if (punishment.equals("kick")) { - String locale = VersionUtil.getLocale(player); + String locale = getLocale(); String kickMessage = messagesModule.getKickMessage(module, locale); hamsterPlayer.disconnect(kickMessage); @@ -141,25 +140,53 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa } } - private Method getHandleMethod = null; - private Field pingField = null; - - public Method getHandleMethod() throws NoSuchMethodException, SecurityException { - return getHandleMethod == null ? getHandleMethod = Player.class.getMethod("getHandle") : getHandleMethod; + public Player getPlayer() { + return plugin.getServer().getPlayer(getUUID()); } - public Field getPingField(Object playerHandle) throws NoSuchFieldException, SecurityException { - return pingField == null ? pingField = playerHandle.getClass().getField("ping") : pingField; + public String getLocale() { + Player player = getPlayer(); + String locale = "en"; + + if (player.isOnline()) { + try { + Method getLocaleMethod = ReflectionUtil.getLocalePlayerMethod(); + + getLocaleMethod.setAccessible(true); + + locale = getLocaleMethod.invoke(player).toString(); + } catch (Exception exception) { + try { + Method getLocaleMethod = ReflectionUtil.getLocaleSpigotMethod(); + + getLocaleMethod.setAccessible(true); + + locale = getLocaleMethod.invoke(player.spigot()).toString(); + } catch (Exception exception1) { + // Ignored + } + } + + if (locale != null && locale.length() > 1) { + locale = locale.substring(0, 2); + } + } + + return locale; } public int getPing() { - Player player = plugin.getServer().getPlayer(getUUID()); + Player player = getPlayer(); if (player != null && player.isOnline()) { try { - Object playerHandle = getHandleMethod().invoke(player); + Method getHandleMethod = ReflectionUtil.getHandleMethod(); + + getHandleMethod.setAccessible(true); + + Object playerHandle = getHandleMethod.invoke(player); - return (int) getPingField(playerHandle).get(playerHandle); + return (int) ReflectionUtil.getPingField(playerHandle).get(playerHandle); } catch (Exception ignored) { // Ignored } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index 6508be4..920c218 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -60,4 +60,6 @@ public UUID getUUID() { public abstract String getName(); public abstract int getPing(); + + public abstract String getLocale(); } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java index 28f3d8a..8b0fa25 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java @@ -8,18 +8,21 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.utils.VersionUtil; import dev._2lstudios.exploitfixer.modules.ConnectionModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; public class PlayerLoginListener implements Listener { + private ExploitPlayerManager exploitPlayerManager; private NotificationsModule notificationsModule; private MessagesModule messagesModule; private ConnectionModule connectionModule; PlayerLoginListener(ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); @@ -30,10 +33,10 @@ public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); String playerName = player.getName(); InetAddress address = event.getAddress(); - String locale = VersionUtil.getLocale(player); if (connectionModule.isNullAddressEnabled() && address == null) { - String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", locale); + ExploitPlayer exploitPlayer = exploitPlayerManager.get(player); + String nullAddressKickMessage = messagesModule.getKickMessage("nulladdress", exploitPlayer.getLocale()); event.setKickMessage(nullAddressKickMessage); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java new file mode 100644 index 0000000..fd5214e --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java @@ -0,0 +1,32 @@ +package dev._2lstudios.exploitfixer.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.bukkit.entity.Player; +import org.bukkit.entity.Player.Spigot; + +public class ReflectionUtil { + private static Method getLocalePlayerMethod = null; + private static Method getLocaleSpigotMethod = null; + private static Method getHandleMethod = null; + private static Field pingField = null; + + public static Method getLocalePlayerMethod() throws NoSuchMethodException, SecurityException { + return getLocalePlayerMethod == null ? getLocalePlayerMethod = Player.class.getMethod("getLocale") + : getLocalePlayerMethod; + } + + public static Method getLocaleSpigotMethod() throws NoSuchMethodException, SecurityException { + return getLocaleSpigotMethod == null ? getLocaleSpigotMethod = Spigot.class.getMethod("getLocale") + : getLocaleSpigotMethod; + } + + public static Method getHandleMethod() throws NoSuchMethodException, SecurityException { + return getHandleMethod == null ? getHandleMethod = Player.class.getMethod("getHandle") : getHandleMethod; + } + + public static Field getPingField(Object playerHandle) throws NoSuchFieldException, SecurityException { + return pingField == null ? pingField = playerHandle.getClass().getField("ping") : pingField; + } +} \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java deleted file mode 100644 index 6596414..0000000 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/VersionUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package dev._2lstudios.exploitfixer.utils; - -import java.lang.reflect.Method; - -import org.bukkit.entity.Player; -import org.bukkit.entity.Player.Spigot; - -public class VersionUtil { - private static Method getLocalePlayerMethod = null; - private static Method getLocaleSpigotMethod = null; - - private static Method getLocalePlayerMethod() throws NoSuchMethodException, SecurityException { - return getLocalePlayerMethod == null ? getLocalePlayerMethod = Player.class.getMethod("getLocale") - : getLocalePlayerMethod; - } - - private static Method getLocaleSpigotMethod() throws NoSuchMethodException, SecurityException { - return getLocaleSpigotMethod == null ? getLocaleSpigotMethod = Spigot.class.getMethod("getLocale") - : getLocaleSpigotMethod; - } - - public static String getLocale(Player player) { - String locale; - - try { - Method getLocaleMethod = getLocalePlayerMethod(); - - getLocaleMethod.setAccessible(true); - - locale = getLocaleMethod.invoke(player).toString(); - } catch (Exception exception) { - try { - Method getLocaleMethod = getLocaleSpigotMethod(); - - getLocaleMethod.setAccessible(true); - - locale = getLocaleMethod.invoke(player.spigot()).toString(); - } catch (Exception exception1) { - locale = "en"; - } - } - - if (locale != null && locale.length() > 1) { - locale = locale.substring(0, 2); - } else { - locale = "en"; - } - - return locale; - } -} \ No newline at end of file From 6c56b9f5300fbde703736e61ce4d3618276f5ef6 Mon Sep 17 00:00:00 2001 From: linsaftw Date: Tue, 6 Sep 2022 11:35:00 -0300 Subject: [PATCH 268/336] 1.7.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6d71d32..ca04b4a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.3 + 1.7.4 https://www.spigotmc.org/resources/62842/ From e09460a44b21e45a56117a8ce7682e9c27e2ad4f Mon Sep 17 00:00:00 2001 From: linsaftw Date: Tue, 6 Sep 2022 12:32:27 -0300 Subject: [PATCH 269/336] properly ignore level restriction --- .../dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index efd0e83..65597ad 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -69,7 +69,7 @@ public ItemStack fixItem(ItemStack item) { String displayName = oldItemMeta.getDisplayName(); List lore = oldItemMeta.getLore(); // This applies vanilla levels to enchants - boolean applyLevelRestriction = enchantLimit != 0; + boolean ignoreLevelRestriction = enchantLimit > 0; try { if (oldItemMeta.hasCustomModelData()) { @@ -88,7 +88,7 @@ public ItemStack fixItem(ItemStack item) { int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); if (enchantLimit > -1 && level > -1) { - newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, !applyLevelRestriction); + newEnchantmentStorageMeta.addStoredEnchant(enchantment, level, ignoreLevelRestriction); } } } else { @@ -97,7 +97,7 @@ public ItemStack fixItem(ItemStack item) { int level = Math.min(entry.getValue(), enchantLimit > 0 ? enchantLimit : 5); if (enchantLimit > -1 && level > -1) { - newItemMeta.addEnchant(enchantment, level, !applyLevelRestriction); + newItemMeta.addEnchant(enchantment, level, ignoreLevelRestriction); } } } From 97b8e5f299977b247764885b9bfb7466ae9551d3 Mon Sep 17 00:00:00 2001 From: Adrian3d04 Date: Tue, 6 Sep 2022 18:45:44 +0000 Subject: [PATCH 270/336] feat: Improved reflection performance with static MethodHandles --- .../exploit/BukkitExploitPlayer.java | 34 +++++------ .../exploitfixer/utils/ReflectionUtil.java | 58 ++++++++++++++----- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index e9929f0..b8eb61a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -1,6 +1,6 @@ package dev._2lstudios.exploitfixer.exploit; -import java.lang.reflect.Method; +import java.lang.invoke.MethodHandle; import java.util.Collection; import java.util.HashSet; import java.util.Map; @@ -149,23 +149,21 @@ public String getLocale() { String locale = "en"; if (player.isOnline()) { - try { - Method getLocaleMethod = ReflectionUtil.getLocalePlayerMethod(); - - getLocaleMethod.setAccessible(true); - - locale = getLocaleMethod.invoke(player).toString(); - } catch (Exception exception) { - try { - Method getLocaleMethod = ReflectionUtil.getLocaleSpigotMethod(); - - getLocaleMethod.setAccessible(true); + MethodHandle getLocaleMethod = ReflectionUtil.getLocalePlayerMethod(); - locale = getLocaleMethod.invoke(player.spigot()).toString(); - } catch (Exception exception1) { - // Ignored + try { + if (getLocaleMethod != null) { + locale = getLocaleMethod.invoke(player).toString(); + } else { + getLocaleMethod = ReflectionUtil.getLocaleSpigotMethod(); + if (getLocaleMethod != null) { + locale = getLocaleMethod.invoke(player.spigot()).toString(); + } } + } catch (Throwable t) { + //ignored } + if (locale != null && locale.length() > 1) { locale = locale.substring(0, 2); @@ -180,14 +178,12 @@ public int getPing() { if (player != null && player.isOnline()) { try { - Method getHandleMethod = ReflectionUtil.getHandleMethod(); - - getHandleMethod.setAccessible(true); + MethodHandle getHandleMethod = ReflectionUtil.getHandleMethod(); Object playerHandle = getHandleMethod.invoke(player); return (int) ReflectionUtil.getPingField(playerHandle).get(playerHandle); - } catch (Exception ignored) { + } catch (Throwable ignored) { // Ignored } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java index fd5214e..bc8cea7 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ReflectionUtil.java @@ -1,32 +1,64 @@ package dev._2lstudios.exploitfixer.utils; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Field; import java.lang.reflect.Method; import org.bukkit.entity.Player; import org.bukkit.entity.Player.Spigot; -public class ReflectionUtil { - private static Method getLocalePlayerMethod = null; - private static Method getLocaleSpigotMethod = null; - private static Method getHandleMethod = null; +public final class ReflectionUtil { + private static final MethodHandle getLocalePlayerMethod = localePlayer(); + private static final MethodHandle getLocaleSpigotMethod = localeSpigot(); + private static final MethodHandle getHandleMethod = handleMethod(); private static Field pingField = null; - public static Method getLocalePlayerMethod() throws NoSuchMethodException, SecurityException { - return getLocalePlayerMethod == null ? getLocalePlayerMethod = Player.class.getMethod("getLocale") - : getLocalePlayerMethod; + private static MethodHandle localePlayer() { + try { + MethodHandles.Lookup lookup = MethodHandles.publicLookup(); + return lookup.findVirtual(Player.class, "getLocale", MethodType.methodType(String.class)); + } catch (NoSuchMethodException | IllegalAccessException e) { + return null; + } } - public static Method getLocaleSpigotMethod() throws NoSuchMethodException, SecurityException { - return getLocaleSpigotMethod == null ? getLocaleSpigotMethod = Spigot.class.getMethod("getLocale") - : getLocaleSpigotMethod; + private static MethodHandle localeSpigot() { + try { + MethodHandles.Lookup lookup = MethodHandles.publicLookup(); + return lookup.findVirtual(Spigot.class, "getLocale", MethodType.methodType(String.class)); + } catch (NoSuchMethodException | IllegalAccessException e) { + return null; + } } - public static Method getHandleMethod() throws NoSuchMethodException, SecurityException { - return getHandleMethod == null ? getHandleMethod = Player.class.getMethod("getHandle") : getHandleMethod; + private static MethodHandle handleMethod() { + MethodHandles.Lookup lookup = MethodHandles.lookup(); + try { + Method method = Player.class.getMethod("getHandle"); + method.setAccessible(true); + return lookup.unreflect(method); + } catch (IllegalAccessException | NoSuchMethodException | SecurityException e) { + return null; + } } - public static Field getPingField(Object playerHandle) throws NoSuchFieldException, SecurityException { + public static MethodHandle getLocalePlayerMethod() { + return getLocalePlayerMethod; + } + + public static MethodHandle getLocaleSpigotMethod() { + return getLocaleSpigotMethod; + } + + public static MethodHandle getHandleMethod() { + return getHandleMethod; + } + + public static Field getPingField(Object playerHandle) throws NoSuchFieldException, SecurityException { return pingField == null ? pingField = playerHandle.getClass().getField("ping") : pingField; } + + private ReflectionUtil() {} } \ No newline at end of file From dbe437fdfab6a13b8830cb95354f78ef4b63db8b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 12 Sep 2022 14:48:16 -0300 Subject: [PATCH 271/336] fix error on 1.12 and lower servers --- .../listener/BlockDispenseListener.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java index 0b1ca47..f668b64 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java @@ -33,17 +33,22 @@ public void onBlockDispense(BlockDispenseEvent event) { if (world != null) { int maxHeight = world.getMaxHeight() - 1; - BlockData blockData = block.getState().getBlockData(); - if (blockData instanceof Directional) { - Directional directional = (Directional) blockData; - BlockFace face = directional.getFacing(); + try { + BlockData blockData = block.getState().getBlockData(); - if ((location.getY() >= maxHeight && face == BlockFace.UP - || location.getY() <= 1 && face == BlockFace.DOWN)) { - event.setCancelled(true); - notificationsModule.debug("[Events] A dispenser tried to drop objects from invalid locations."); + if (blockData instanceof Directional) { + Directional directional = (Directional) blockData; + BlockFace face = directional.getFacing(); + + if ((location.getY() >= maxHeight && face == BlockFace.UP + || location.getY() <= 1 && face == BlockFace.DOWN)) { + event.setCancelled(true); + notificationsModule.debug("[Events] A dispenser tried to drop objects from invalid locations."); + } } + } catch (NoSuchMethodError ex) { + // 1.12.2 and lower doesn't support this } } } From fd69c43fc4311104c0118c2433924b5699a3fc69 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:53:23 -0300 Subject: [PATCH 272/336] 1.7.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ca04b4a..900024f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.4 + 1.7.5 https://www.spigotmc.org/resources/62842/ From 2a07672407b6e1c73f289b584e243e2937fca368 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Nov 2022 01:02:18 +0100 Subject: [PATCH 273/336] Block dispense fix by Rayzs_YT --- .../listener/BlockDispenseListener.java | 33 ++++++++++--------- .../listener/ListenerInitializer.java | 7 +++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java index f668b64..85d2db5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockDispenseListener.java @@ -4,12 +4,12 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Directional; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.modules.EventsModule; @@ -24,7 +24,8 @@ public class BlockDispenseListener implements Listener { this.eventsModule = moduleManager.getEventsModule(); } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + // This listener only runs in 1.12 servers otherwise exception will be thrown + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockDispense(BlockDispenseEvent event) { if (eventsModule.isDispenserCrash()) { Block block = event.getBlock(); @@ -33,22 +34,24 @@ public void onBlockDispense(BlockDispenseEvent event) { if (world != null) { int maxHeight = world.getMaxHeight() - 1; + MaterialData materialData = block.getState().getData(); - try { - BlockData blockData = block.getState().getBlockData(); + if (materialData instanceof Dispenser) { + Dispenser dispenser = (Dispenser) materialData; + BlockFace face = dispenser.getFacing(); + double y = location.getY(); - if (blockData instanceof Directional) { - Directional directional = (Directional) blockData; - BlockFace face = directional.getFacing(); + // Return if it's not a shulker + if (!event.getItem().getType().toString().contains("SHULKER")) { + return; + } - if ((location.getY() >= maxHeight && face == BlockFace.UP - || location.getY() <= 1 && face == BlockFace.DOWN)) { - event.setCancelled(true); - notificationsModule.debug("[Events] A dispenser tried to drop objects from invalid locations."); - } + if ((y >= maxHeight && face == BlockFace.UP + || y <= 1 && face == BlockFace.DOWN)) { + event.setCancelled(true); + notificationsModule + .debug("[Events] A dispenser tried to drop objects from invalid locations."); } - } catch (NoSuchMethodError ex) { - // 1.12.2 and lower doesn't support this } } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 4c2404d..2022da5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -1,5 +1,6 @@ package dev._2lstudios.exploitfixer.listener; +import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; @@ -25,7 +26,11 @@ public void register() { PluginManager pluginManager = server.getPluginManager(); ExploitUtil exploitUtil = new ExploitUtil(moduleManager); - pluginManager.registerEvents(new BlockDispenseListener(moduleManager), plugin); + // Only register this listener on 1.12 + if (Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].startsWith("v1_12")) { + pluginManager.registerEvents(new BlockDispenseListener(moduleManager), plugin); + } + pluginManager.registerEvents(new EntityDamageByEntityListener(moduleManager), plugin); pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); From 01f1e716b975fb658c1b66e5c7f7cadc0087401b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 16 Nov 2022 01:02:56 +0100 Subject: [PATCH 274/336] 1.7.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 900024f..88b452b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.5 + 1.7.6 https://www.spigotmc.org/resources/62842/ From 071c23731554a43990d9cca1418c3acdc01d8636 Mon Sep 17 00:00:00 2001 From: RedstoneFuture Date: Wed, 16 Nov 2022 15:46:26 +0100 Subject: [PATCH 275/336] Adding note about disable_tracking option, small typo --- src/main/resources/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e64513b..baca01e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -34,7 +34,7 @@ events: # Prevents players from breaking ender portals. ender_portal_break: true - # Prevents maps from tracking fixing many crash exploits + # Prevents maps from tracking fixing many crash exploits. (The map will no longer show players their location.) disable_tracking: true # Prevents crashing when using dispensers that drop items out of the bounds. @@ -56,7 +56,7 @@ packets: # Cancels packets if the player sending them is offline. offline: true - # This will check if integers, floats, doubles and items have a invalid size in packets. + # This will check if integers, floats, doubles and items have an invalid size in packets. data: # Vls to add when a packet fails the check. (Set to -1 to disable) vls: 100 From 0ecde1ae06ba747696a1567052d4d33603369b60 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sun, 20 Nov 2022 22:43:54 +0100 Subject: [PATCH 276/336] Properly reset readerindex --- .../_2lstudios/exploitfixer/listener/PacketDecodeListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 64fdd6f..4d5ccc9 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -66,9 +66,10 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play + "/" + dataBytes + " Vls: " + dataVls; } else { if (!(byteBuf instanceof EmptyByteBuf)) { + int oldReaderIndex = byteBuf.readerIndex(); int packetId = ProtocolUtil.readVarInt(byteBuf); - byteBuf.resetReaderIndex(); + byteBuf.readerIndex(oldReaderIndex); if (packetId == 18) { return; From 2af215d7548158c4bece4e3874632584e49538c4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 23 Nov 2022 03:36:14 +0100 Subject: [PATCH 277/336] Improved configuration --- src/main/resources/config.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e64513b..1f4a6b2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -62,7 +62,7 @@ packets: vls: 100 # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 64000 + bytes: 8192 # Maximum amount of bytes allowed per book page. (Set to -1 to disable) bytes_book: 300 @@ -168,21 +168,29 @@ commands: # Commands that are exempt from this server. commands: + # WorldEdit exploit - "//calc" - "//calculate" - "//eval" - "//evaluate" - "//solve" + # HolographicDisplays exploit - "/hd readtext" - "/holo readtext" - "/hologram readtext" - "/holograms readtext" - "/holographicdisplays readtext" + # PermissionsEx exploit - "/pex promote" - "/pex demote" - "/promote" - "/demote" - "/execute" + # Multiverse exploit + - "/mv ^" + - "/mv ^(" + - "/mVhElP <*.*.*.*.*.*.*.>" + - "/${" # Placeholders: %player% punishments: From d7dfa063b3784c7b4183128b22d8c5bbe932fa04 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 23 Nov 2022 03:36:50 +0100 Subject: [PATCH 278/336] 1.7.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88b452b..cb8c2ab 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.6 + 1.7.7 https://www.spigotmc.org/resources/62842/ From 580fc431b608f4fb0b372e2c803806d2651404a9 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 6 Dec 2022 10:03:41 +0000 Subject: [PATCH 279/336] Improved Command Checking --- .../exploitfixer/commands/ExploitFixerCommand.java | 4 +--- .../exploitfixer/exploit/BukkitExploitPlayer.java | 6 +++--- .../dev/_2lstudios/exploitfixer/modules/CommandsModule.java | 2 +- .../dev/_2lstudios/exploitfixer/modules/MessagesModule.java | 2 +- src/main/resources/config.yml | 6 +++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java index 7f2ad97..b1617aa 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/ExploitFixerCommand.java @@ -28,12 +28,10 @@ public ExploitFixerCommand(ExploitFixer exploitFixer, ModuleManager moduleManage public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { int length = args.length; - String lang; + String lang = null; if (sender instanceof Player) { lang = exploitPlayerManager.get((Player) sender).getLocale(); - } else { - lang = "en"; } if (length < 1 || args[0].equalsIgnoreCase("help")) { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index b8eb61a..a4703fa 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -146,9 +146,9 @@ public Player getPlayer() { public String getLocale() { Player player = getPlayer(); - String locale = "en"; + String locale = null; - if (player.isOnline()) { + if (player != null && player.isOnline()) { MethodHandle getLocaleMethod = ReflectionUtil.getLocalePlayerMethod(); try { @@ -161,7 +161,7 @@ public String getLocale() { } } } catch (Throwable t) { - //ignored + // The player is invalid, ignore } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index db65d78..08d3a22 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -6,7 +6,7 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class CommandsModule implements IPunishmentModule { - private static Pattern SYNTAX_PATTERN = Pattern.compile("[\\w]{1,}:"); + private static Pattern SYNTAX_PATTERN = Pattern.compile(".{1,}:"); private Collection commands; private Collection punishments; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index e773857..703983e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -102,7 +102,7 @@ public String getName() { public String getString(String locale, String path) { String string; - if (locales.containsKey(locale)) { + if (locale != null && locales.containsKey(locale)) { string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); } else if (locales.containsKey(defaultLocale)) { string = locales.get(defaultLocale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1f4a6b2..0d16ee7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -188,9 +188,9 @@ commands: - "/execute" # Multiverse exploit - "/mv ^" - - "/mv ^(" - - "/mVhElP <*.*.*.*.*.*.*.>" - - "/${" + - "/mv help <" + - "/mvhelp <" + - "/$" # Placeholders: %player% punishments: From cb1fc5bd146159116ffdf59ff0c12bd22e43d40d Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 6 Dec 2022 10:05:20 +0000 Subject: [PATCH 280/336] 1.7.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cb8c2ab..bb2c221 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.7 + 1.7.8 https://www.spigotmc.org/resources/62842/ From f7f260474e760c5bb8aaef8f155ea9b9d8e87c9d Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 6 Dec 2022 18:44:13 +0000 Subject: [PATCH 281/336] Fix GhostBlock By Fast Break --- src/main/resources/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0d16ee7..932c43f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -110,8 +110,8 @@ packets: PacketPlayInAutoRecipe: 10 PacketPlayInUpdateSign: 5 PacketPlayInAbilities: 0.25 - PacketPlayInArmAnimation: 0.05 - PacketPlayInBlockDig: 0.5 + PacketPlayInArmAnimation: 0.125 + PacketPlayInBlockDig: 0.125 PacketPlayInBlockPlace: 0.5 PacketPlayInCustomPayload: 0.01 PacketPlayInEntityAction: 0.5 From 5f932089e8149053c24ffae778197483e1a137d1 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:00:09 +0000 Subject: [PATCH 282/336] bypass permission for itemsfix module --- .../_2lstudios/exploitfixer/ExploitFixer.java | 2 +- .../exploit/BukkitExploitPlayer.java | 11 +++++ .../listener/PacketReceiveListener.java | 46 +++++++++---------- .../listener/PlayerLoginListener.java | 12 +++++ .../exploitfixer/modules/ItemsFixModule.java | 6 +++ src/main/resources/config.yml | 9 +++- 6 files changed, 60 insertions(+), 26 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java index 3225c7e..00a0f45 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java @@ -8,11 +8,11 @@ import org.bukkit.scheduler.BukkitScheduler; import dev._2lstudios.exploitfixer.commands.ExploitFixerCommand; +import dev._2lstudios.exploitfixer.configuration.IConfiguration; import dev._2lstudios.exploitfixer.listener.ListenerInitializer; import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.tasks.ExploitFixerRepeatingTask; import dev._2lstudios.exploitfixer.utils.BukkitConfigurationUtil; -import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class ExploitFixer extends JavaPlugin { private static ExploitFixer instance; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index a4703fa..6bc18c7 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -30,6 +30,9 @@ public class BukkitExploitPlayer extends ExploitPlayer { private MessagesModule messagesModule; private NotificationsModule notificationsModule; + // Permission to bypass the items fix module + private boolean bypassItemsFix = false; + public BukkitExploitPlayer(Plugin plugin, ModuleManager moduleManager, UUID uuid) { super(uuid); this.plugin = plugin; @@ -200,4 +203,12 @@ public String getName() { return "N/A"; } + + public boolean isBypassItemsFix() { + return bypassItemsFix; + } + + public void setBypassItemsFix(boolean bypassItemsFix) { + this.bypassItemsFix = bypassItemsFix; + } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 7ff585e..14e6ba5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -207,6 +207,28 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } + if (dataVls > 0) { + for (Double val : packetWrapper.getDouble().values()) { + if (!Double.isFinite(val)) { + String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid double: " + val + "! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + for (Float val : packetWrapper.getFloats().values()) { + if (!Float.isFinite(val)) { + String reason = "[" + packetName + "|Data] " + playerName + + " sent an invalid float: " + val + "! Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + } + boolean creativeMode = packetType == PacketType.PacketPlayInSetCreativeSlot && itemsFixModule.isEnabled(); for (Entry itemsEntry : packetWrapper.getItems().entrySet()) { @@ -219,7 +241,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); return; - } else if (creativeMode) { + } else if (creativeMode && !exploitPlayer.isBypassItemsFix()) { String blacklisted = exploitUtil.clearIfBlacklisted(item); if (blacklisted != null) { @@ -234,28 +256,6 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } - if (dataVls > 0) { - for (Double val : packetWrapper.getDouble().values()) { - if (!Double.isFinite(val)) { - String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid double: " + val + "! Added vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - } - - for (Float val : packetWrapper.getFloats().values()) { - if (!Float.isFinite(val)) { - String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid float: " + val + "! Added vls: " + dataVls; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } - } - } - notificationsModule.addPacketDebug(String.valueOf(packetType)); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java index 8b0fa25..bdf5089 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerLoginListener.java @@ -13,6 +13,7 @@ import dev._2lstudios.exploitfixer.managers.ModuleManager; import dev._2lstudios.exploitfixer.modules.NotificationsModule; import dev._2lstudios.exploitfixer.modules.ConnectionModule; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; import dev._2lstudios.exploitfixer.modules.MessagesModule; public class PlayerLoginListener implements Listener { @@ -20,12 +21,14 @@ public class PlayerLoginListener implements Listener { private NotificationsModule notificationsModule; private MessagesModule messagesModule; private ConnectionModule connectionModule; + private ItemsFixModule itemsFixModule; PlayerLoginListener(ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); this.connectionModule = moduleManager.getConnectionModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.messagesModule = moduleManager.getMessagesModule(); + this.itemsFixModule = moduleManager.getItemsFixModule(); } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @@ -45,5 +48,14 @@ public void onPlayerLogin(PlayerLoginEvent event) { if (player.hasPermission("exploitfixer.notifications")) { notificationsModule.setNotifications(playerName, true); } + + // Get the items fix bypass permission + String itemsFixBypassPermission = itemsFixModule.getBypassPermission(); + + // Check if the permission is configured + if (itemsFixBypassPermission != null) { + // Set the player as bypassing items fix check + exploitPlayerManager.get(player).setBypassItemsFix(player.hasPermission(itemsFixBypassPermission)); + } } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 65597ad..4cc407a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -23,6 +23,7 @@ public class ItemsFixModule implements IModule { private int enchantLimit; private int maxStackSize; private Collection blacklist; + private String bypassPermission; public ItemsFixModule(Plugin plugin) { this.plugin = plugin; @@ -35,6 +36,7 @@ public void reload(IConfiguration configYml) { this.enchantLimit = configYml.getInt(name + ".enchant_limit"); this.maxStackSize = configYml.getInt(name + ".max_stack_size"); this.blacklist = configYml.getStringList(name + ".blacklist"); + this.bypassPermission = configYml.getString(name + ".bypass_permission"); } @Override @@ -59,6 +61,10 @@ public Collection getBlacklist() { return blacklist; } + public String getBypassPermission() { + return bypassPermission; + } + public ItemStack fixItem(ItemStack item) { Material material = Material.getMaterial(item.getType().name()); ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c322cdb..7130772 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -143,8 +143,9 @@ packets: - "notification" - "kick" -# Removes custom NBT tags from creative items to prevent harm to your server. -# Negative enchant values will always be removed. +# Removes custom/invalid NBT tags from items to prevent harm to your server. +# This prevents creative mode players from corrupting worlds FOREVER and crashing the server. +# This checks only applies to creative mode players. itemsfix: enabled: true @@ -162,6 +163,10 @@ itemsfix: # - "BARRIER" # - "COMMAND_BLOCK" + # Set a permission for some players to bypass this check. (Uncomment to enable) + # WARNING: Players with this permission can crash and corrupt worlds FOREVER with hacked clients. + #bypass_permission: "exploitfixer.itemsfix.bypass" + # Checks if players try to crash/exploit the server with commands. commands: enabled: true From 5f11f53f8c6dcdfc4f1c3822e1ef75960a86baaf Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:00:40 +0000 Subject: [PATCH 283/336] 1.7.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb2c221..692875b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.8 + 1.7.9 https://www.spigotmc.org/resources/62842/ From d9880d4738fac9d7150049942b67c25b135be03e Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:03:08 -0300 Subject: [PATCH 284/336] Fix command check --- .../listener/PacketReceiveListener.java | 43 ++++++------------- .../exploitfixer/modules/CommandsModule.java | 2 +- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 14e6ba5..c3dc6dd 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -1,17 +1,8 @@ package dev._2lstudios.exploitfixer.listener; -import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; -import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; -import dev._2lstudios.exploitfixer.managers.ModuleManager; -import dev._2lstudios.exploitfixer.modules.CommandsModule; -import dev._2lstudios.exploitfixer.modules.ItemsFixModule; -import dev._2lstudios.exploitfixer.modules.NotificationsModule; -import dev._2lstudios.exploitfixer.modules.PacketsModule; -import dev._2lstudios.exploitfixer.utils.ExploitUtil; -import dev._2lstudios.hamsterapi.enums.PacketType; -import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; -import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; -import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; +import java.util.Map; +import java.util.Map.Entry; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -26,8 +17,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import java.util.Map; -import java.util.Map.Entry; +import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.ItemsFixModule; +import dev._2lstudios.exploitfixer.modules.NotificationsModule; +import dev._2lstudios.exploitfixer.modules.PacketsModule; +import dev._2lstudios.exploitfixer.utils.ExploitUtil; +import dev._2lstudios.hamsterapi.enums.PacketType; +import dev._2lstudios.hamsterapi.events.PacketReceiveEvent; +import dev._2lstudios.hamsterapi.hamsterplayer.HamsterPlayer; +import dev._2lstudios.hamsterapi.wrappers.PacketWrapper; public class PacketReceiveListener implements Listener { private ExploitUtil exploitUtil; @@ -35,7 +35,6 @@ public class PacketReceiveListener implements Listener { private ItemsFixModule itemsFixModule; private NotificationsModule notificationsModule; private PacketsModule packetsModule; - private CommandsModule commandsModule; private String version; private boolean checkLectern; private ItemStack AIR = new ItemStack(Material.AIR); @@ -46,7 +45,6 @@ public class PacketReceiveListener implements Listener { this.itemsFixModule = moduleManager.getItemsFixModule(); this.notificationsModule = moduleManager.getNotificationsModule(); this.packetsModule = moduleManager.getPacketsModule(); - this.commandsModule = moduleManager.getCommandsModule(); this.version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; this.checkLectern = version.equals("v1_18_R1") || version.startsWith("v1_17") || version.startsWith("v1_16") @@ -77,19 +75,6 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play return; } - if (commandsModule.isEnabled() && packetType == PacketType.PacketPlayInTabComplete) { - if (!strings.isEmpty()) { - String rawMessage = strings.values().iterator().next(); - - if (commandsModule.isCommand(rawMessage)) { - exploitPlayer.punish(commandsModule, hamsterPlayer, packetWrapper, commandsModule.getPunishments(), - 1); - event.setCancelled(true); - return; - } - } - } - if (packetType == PacketType.PacketPlayInCustomPayload) { if (!strings.isEmpty()) { String tag = strings.values().iterator().next(); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index 08d3a22..614887a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -6,7 +6,7 @@ import dev._2lstudios.exploitfixer.configuration.IConfiguration; public class CommandsModule implements IPunishmentModule { - private static Pattern SYNTAX_PATTERN = Pattern.compile(".{1,}:"); + private static Pattern SYNTAX_PATTERN = Pattern.compile("[a-z0-9-]{1,}:"); private Collection commands; private Collection punishments; From 21ef21ca3cb9c15993c680c0fa0701d565fb2a16 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sat, 31 Dec 2022 09:12:48 -0300 Subject: [PATCH 285/336] Better Firework Check --- .../_2lstudios/exploitfixer/utils/ExploitUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 5664d3f..796488f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -84,21 +84,29 @@ private boolean checkBook(BookMeta meta) { } private boolean checkFirework(FireworkMeta meta) { - if (meta.getPower() > 3) { - return false; + try { + if (meta.getPower() > 3) { + return false; + } + } catch (NullPointerException ex) { + // Power can sometimes be null } + // Check if it has effects if (meta.hasEffects()) { if (meta.getEffectsSize() > 12) { + // Check for the amount of effects return false; } for (FireworkEffect effect : meta.getEffects()) { if (effect.getColors().size() > 6) { + // Check for too many colors return false; } if (effect.getFadeColors().size() > 6) { + // Check for too many fade colors return false; } } From 435f23294f6ebe8c2d27959aca2cf5c704b1c3bd Mon Sep 17 00:00:00 2001 From: IndianBartonka <68228599+IndianBartonka@users.noreply.github.com> Date: Sun, 1 Jan 2023 19:57:21 +0100 Subject: [PATCH 286/336] Update config.yml --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7130772..e45de57 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -130,7 +130,7 @@ packets: blacklist: - "PacketPlayInAutoRecipe" - # Placeholders: %player%, %vl%, %ping%, %check% + # Placeholders: %player%, %vls%, %ping%, %check% # Commands to run when a player reaches certain violation level. violations: 25: From cfcac4d5a448d65f0c7c9f7b8c827bfc089e3da8 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Sun, 1 Jan 2023 18:23:48 -0300 Subject: [PATCH 287/336] 1.8.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 692875b..4ca3375 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.7.9 + 1.8.0 https://www.spigotmc.org/resources/62842/ From adf8aefde658764ee200c9c290a593d06933ee68 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 2 Jan 2023 13:34:18 -0300 Subject: [PATCH 288/336] Better Debug & Configurable Firework Checks --- .../exploitfixer/enums/CheckItemResult.java | 22 ++++++++ .../listener/PacketReceiveListener.java | 19 ++++--- .../exploitfixer/modules/PacketsModule.java | 7 ++- .../exploitfixer/utils/ExploitUtil.java | 54 ++++++++++--------- src/main/resources/config.yml | 3 ++ 5 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/enums/CheckItemResult.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/enums/CheckItemResult.java b/src/main/java/dev/_2lstudios/exploitfixer/enums/CheckItemResult.java new file mode 100644 index 0000000..6cc4cbf --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/enums/CheckItemResult.java @@ -0,0 +1,22 @@ +package dev._2lstudios.exploitfixer.enums; + +public enum CheckItemResult { + // General Items + INVALID_ITEM, + INVALID_ITEM_NAME, + INVALID_ITEM_LORE, + // Fireworks + INVALID_FIREWORK_POWER, + INVALID_FIREWORK_EFFECTS, + INVALID_FIREWORK_COLORS, + INVALID_FIREWORK_FADE_COLORS, + // Books + INVALID_BOOK_TITLE, + INVALID_BOOK_AUTHOR, + INVALID_BOOK_PAGES, + INVALID_BOOK_SIZE, + // Blocks + INVALID_BLOCK, + // Valid + VALID_ITEM +} diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index c3dc6dd..2bd496f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import dev._2lstudios.exploitfixer.enums.CheckItemResult; import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; @@ -220,13 +221,19 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play ItemStack item = itemsEntry.getValue(); if (item != null) { - if (dataVls > 0 && !exploitUtil.checkItem(item)) { - String reason = "[" + packetName + "|Data] " + playerName - + " sent an invalid item! Added vls: " + dataVls; + if (dataVls > 0) { + CheckItemResult result = exploitUtil.checkItem(item); - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); - return; - } else if (creativeMode && !exploitPlayer.isBypassItemsFix()) { + if (result != CheckItemResult.VALID_ITEM) { + String reason = "[" + packetName + "] " + playerName + + " sent an invalid item! (" + result + ") Added vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + return; + } + } + + if (creativeMode && !exploitPlayer.isBypassItemsFix()) { String blacklisted = exploitUtil.clearIfBlacklisted(item); if (blacklisted != null) { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index ced6897..5411188 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -14,7 +14,7 @@ public class PacketsModule implements IViolationModule { private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, reduceVls, vlMultiplier; - private int dataBytesBook, dataBytesSign, dataBytes; + private int dataBytesBook, dataBytesSign, dataBytes, dataFireworkFlags; private boolean enabled, offline; public void reload(IConfiguration configYml) { @@ -31,6 +31,7 @@ public void reload(IConfiguration configYml) { this.dataBytes = configYml.getInt(name + ".data.bytes"); this.dataBytesBook = configYml.getInt(name + ".data.bytes_book"); this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign"); + this.dataFireworkFlags = configYml.getInt(name + ".data.firework_flags"); this.vlMultiplier = configYml.getDouble(name + ".data.vl_multiplier"); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); @@ -124,4 +125,8 @@ public boolean isOffline() { public boolean isBlacklisted(String packetName) { return blacklist.contains(packetName); } + + public int getDataFireworkFlags() { + return dataFireworkFlags; + } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 796488f..e702d16 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -16,6 +16,7 @@ import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; +import dev._2lstudios.exploitfixer.enums.CheckItemResult; import dev._2lstudios.exploitfixer.exploit.BukkitExploitPlayer; import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; import dev._2lstudios.exploitfixer.managers.ModuleManager; @@ -37,7 +38,7 @@ public ExploitUtil(ModuleManager moduleManager) { this.packetsModule = moduleManager.getPacketsModule(); } - private boolean checkBlockState(BlockStateMeta meta) { + private CheckItemResult checkBlockState(BlockStateMeta meta) { if (meta.hasBlockState()) { BlockState blockState = meta.getBlockState(); @@ -45,29 +46,31 @@ private boolean checkBlockState(BlockStateMeta meta) { InventoryHolder inventoryHolder = (InventoryHolder) blockState; for (ItemStack item : inventoryHolder.getInventory().getContents()) { - return checkItem(item); + if (checkItem(item) != CheckItemResult.VALID_ITEM) { + return CheckItemResult.INVALID_BLOCK; + } } } } - return true; + return CheckItemResult.VALID_ITEM; } - private boolean checkBook(BookMeta meta) { + private CheckItemResult checkBook(BookMeta meta) { String title = meta.getTitle(); if (title != null && title.length() > 32) { - return false; + return CheckItemResult.INVALID_BOOK_TITLE; } String author = meta.getAuthor(); if (author != null && author.length() > 16) { - return false; + return CheckItemResult.INVALID_BOOK_AUTHOR; } if (meta.getPageCount() > 50) { - return false; + return CheckItemResult.INVALID_BOOK_PAGES; } int dataBytesBook = packetsModule.getDataBytesBook(); @@ -76,17 +79,17 @@ private boolean checkBook(BookMeta meta) { int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; if (pageBytes > dataBytesBook) { - return false; + return CheckItemResult.INVALID_BOOK_SIZE; } } - return true; + return CheckItemResult.VALID_ITEM; } - private boolean checkFirework(FireworkMeta meta) { + private CheckItemResult checkFirework(FireworkMeta meta) { try { if (meta.getPower() > 3) { - return false; + return CheckItemResult.INVALID_FIREWORK_POWER; } } catch (NullPointerException ex) { // Power can sometimes be null @@ -94,28 +97,31 @@ private boolean checkFirework(FireworkMeta meta) { // Check if it has effects if (meta.hasEffects()) { - if (meta.getEffectsSize() > 12) { + // Get the allowed flags count + int allowedFlags = packetsModule.getDataFireworkFlags(); + + if (meta.getEffectsSize() > allowedFlags) { // Check for the amount of effects - return false; + return CheckItemResult.INVALID_FIREWORK_EFFECTS; } for (FireworkEffect effect : meta.getEffects()) { - if (effect.getColors().size() > 6) { + if (effect.getColors().size() > allowedFlags) { // Check for too many colors - return false; + return CheckItemResult.INVALID_FIREWORK_COLORS; } - if (effect.getFadeColors().size() > 6) { + if (effect.getFadeColors().size() > allowedFlags) { // Check for too many fade colors - return false; + return CheckItemResult.INVALID_FIREWORK_FADE_COLORS; } } } - return true; + return CheckItemResult.VALID_ITEM; } - public boolean checkItem(ItemStack item) { + public CheckItemResult checkItem(ItemStack item) { try { if (item != null && item.hasItemMeta()) { ItemMeta itemMeta = item.getItemMeta(); @@ -124,13 +130,13 @@ public boolean checkItem(ItemStack item) { String displayName = itemMeta.getDisplayName(); if (displayName != null && displayName.length() > 1536) { - return false; + return CheckItemResult.INVALID_ITEM_NAME; } List lore = itemMeta.getLore(); if (lore != null && lore.size() > 64) { - return false; + return CheckItemResult.INVALID_ITEM_LORE; } if (itemMeta instanceof BookMeta) { @@ -143,10 +149,10 @@ public boolean checkItem(ItemStack item) { } } } catch (IllegalArgumentException ex) { - return false; + return CheckItemResult.INVALID_ITEM; } - return true; + return CheckItemResult.VALID_ITEM; } public boolean checkSign(String[] linesString) { @@ -196,4 +202,4 @@ public void cancelExploit(Cancellable event, HamsterPlayer hamsterPlayer, Player addVls(event, hamsterPlayer, player, vls); } -} +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e45de57..a0de9a9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -70,6 +70,9 @@ packets: # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) bytes_sign: 47 + # Maximum amount of flags allowed per firework. (Set to -1 to disable) + firework_flags: 12 + # This option adds vls per byte received. # Vls to add per byte received. (Set to -1 to disable) vl_multiplier: 0.0001 From adf6e4bd91101b1dd873eeca5e2f5f4a2f80869a Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 3 Jan 2023 00:04:04 -0300 Subject: [PATCH 289/336] Limit Tags Per Packet --- .../listener/PacketDecodeListener.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 4d5ccc9..de0e3b7 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -1,5 +1,8 @@ package dev._2lstudios.exploitfixer.listener; +import java.nio.charset.Charset; +import java.util.regex.Pattern; + import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; @@ -16,9 +19,12 @@ import io.netty.buffer.EmptyByteBuf; public class PacketDecodeListener implements Listener { - private static String PREFIX = "[Decoder|Data] "; private static String PREFIX_OFFLINE = "[Decoder|Offline] "; + + // Pattern for detecting an amount of tags used + private static Pattern tagPattern = Pattern.compile("(.)[{]{64,}(.)"); + private ExploitUtil exploitUtil; private PacketsModule packetsModule; @@ -73,6 +79,18 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play if (packetId == 18) { return; + } else { + // Check if it's a edit book packet + String content = byteBuf.toString(Charset.defaultCharset()); + + byteBuf.readerIndex(oldReaderIndex); + + if (tagPattern.matcher(content).find()) { + reason = PREFIX + playerName + + " sent a packet with too many tags! Vls: " + dataVls; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + } } } @@ -85,7 +103,9 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); } - } else if (packetsModule.isOffline()) { + } else if (packetsModule.isOffline()) + + { String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); From 0fe961fa593cd55d551e2eb3e5f15bbeef8bd851 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 3 Jan 2023 19:52:02 -0300 Subject: [PATCH 290/336] Improved Debug With Vls Categories --- .../exploit/BukkitExploitPlayer.java | 8 ++- .../listener/PacketDecodeListener.java | 12 ++-- .../listener/PacketReceiveListener.java | 28 ++++---- .../exploitfixer/modules/MessagesModule.java | 4 +- .../modules/NotificationsModule.java | 66 ++++++++++++++++--- .../exploitfixer/utils/ExploitUtil.java | 8 +-- 6 files changed, 91 insertions(+), 35 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 6bc18c7..9f5710d 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -47,7 +47,12 @@ public void addVls(Cancellable event, HamsterPlayer hamsterPlayer, } public void addVls(Cancellable event, PacketWrapper packet, - HamsterPlayer hamsterPlayer, IViolationModule module, double amount) { + HamsterPlayer hamsterPlayer, IViolationModule module, double amount) { + addVls(event, packet, hamsterPlayer, module, amount, "Other"); + } + + public void addVls(Cancellable event, PacketWrapper packet, + HamsterPlayer hamsterPlayer, IViolationModule module, double amount, String category) { Violations violations = (Violations) module.getViolations(); if (violations != null) { @@ -73,6 +78,7 @@ public void addVls(Cancellable event, PacketWrapper packet, double newVls = getViolations(module) + amount; violationsMap.put(module, newVls); + notificationsModule.addCategorizedVl(category, amount); if (event instanceof Cancellable && module.getCancelVls() <= newVls) { ((Cancellable) event).setCancelled(true); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index de0e3b7..9c3f132 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -54,12 +54,12 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = PREFIX + playerName + " sent a packet with invalid capacity! capacity: " + capacity + " Vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Bad Capacity"); } else if (refCnt < 1) { String reason = PREFIX + playerName + " sent a packet with invalid refCnt! refCnt: " + refCnt + " Vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Bad Reference Count"); } else { int readableBytes = byteBuf.readableBytes(); String reason = null; @@ -89,26 +89,26 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play reason = PREFIX + playerName + " sent a packet with too many tags! Vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Many Tags"); } } } if (dataVlMultiplier > 0) { - exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier); + exploitUtil.addVls(event, hamsterPlayer, player, capacity * dataVlMultiplier, "Too Much Data"); } return; } - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Too Big Packet"); } } else if (packetsModule.isOffline()) { String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0, "Offline"); } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 2bd496f..ceecb54 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -67,12 +67,12 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play double windowClick = packetsModule.getWindowClick(); double setCreativeSlot = packetsModule.getSetCreativeSlot(); - exploitPlayer.addVls(event, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName)); + exploitPlayer.addVls(event, null, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName), "Packet Rate"); if (packetsModule.isBlacklisted(packetName)) { String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0, "Blacklist"); return; } @@ -86,7 +86,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|Tag] " + playerName + " sent a CustomPayload packet without TAG! Added vls: " + tagVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, tagVls, "Invalid Payload"); return; } else if (bookVls > 0 && (tag.equals("MC|BEdit") || tag.equals("MC|BSign") || tag.equals("MC|BOpen"))) { @@ -97,14 +97,14 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|Book] " + playerName + " tried to send a " + tag + " CustomPayload packet without a book in hand!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls, "Payload No Book"); return; } } else if (tag.equals("MC|AdvCdm") && !player.isOp()) { String reason = "[" + packetName + "|Command Block] " + playerName + " tried to send a " + tag + " CustomPayload packet without being op!"; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, bookVls, "Payload Not Operator"); return; } @@ -127,7 +127,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play + " tried to quick move on a lectern! Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Lectern Crash"); return; } } else { @@ -136,7 +136,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play + " tried to quick move on a lectern! Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Lectern Crash"); return; } } @@ -161,13 +161,13 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|WindowClick] " + playerName + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Invalid Slot"); return; } else if (slot >= maxSlots) { String reason = "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Large/Short Slot"); return; } } @@ -178,7 +178,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot, "Creative Packet No Creative"); return; } @@ -188,7 +188,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|Data] " + playerName + " has sent a too big sign packet! Added vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Too Big Sign"); return; } } @@ -199,7 +199,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid double: " + val + "! Added vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Invalid Double"); return; } } @@ -209,7 +209,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|Data] " + playerName + " sent an invalid float: " + val + "! Added vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Invalid Float"); return; } } @@ -228,7 +228,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "] " + playerName + " sent an invalid item! (" + result + ") Added vls: " + dataVls; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Invalid Item"); return; } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java index 703983e..6ec4129 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/MessagesModule.java @@ -106,8 +106,10 @@ public String getString(String locale, String path) { string = locales.get(locale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); } else if (locales.containsKey(defaultLocale)) { string = locales.get(defaultLocale).getOrDefault(path, NOTFOUND_STRING.replace("%PATH%", path.toUpperCase())); - } else { + } else if (locale != null) { string = NOTFOUND_STRING.replace("%PATH%", locale.toUpperCase()); + } else { + string = NOTFOUND_STRING.replace("%PATH%", ""); } return string.replace("%version%", version).replace("%web%", web).replace('&', '\u00a7'); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index aa126cc..106b1d3 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -23,6 +23,25 @@ public class NotificationsModule implements INotificationsModule { private boolean enabled, debug; private String message; + // Violations done per category + private Map categorizedVls = new HashMap<>(); + + public void clearCategorizedVls() { + this.categorizedVls.clear(); + } + + public Map getCategorizedVls() { + return categorizedVls; + } + + public void addCategorizedVl(String name, double amount) { + if (amount <= 0) { + return; + } + + this.categorizedVls.put(name, this.categorizedVls.getOrDefault(name, 0D) + amount); + } + public NotificationsModule(Server server, Logger logger) { this.server = server; this.logger = logger; @@ -50,25 +69,54 @@ public void addPacketDebug(String packetType) { } public void debugPackets() { - if (this.debug && !packetDebug.isEmpty()) { - Set> entries = new HashSet<>(packetDebug.entrySet()); - StringBuilder stringBuilder = new StringBuilder("Received Packets (x%total%): "); - boolean isFirst = true; + if (!this.debug) { + return; + } + + if (!categorizedVls.isEmpty()) { + StringBuilder stringBuilder = new StringBuilder(); + Set> entries = new HashSet<>(categorizedVls.entrySet()); int total = 0; + stringBuilder.append("Categorized Violations (x%total%):"); + + categorizedVls.clear(); + + for (Entry vlsCategory : entries) { + double value = (double) ((int) (vlsCategory.getValue() * 1000)) / 1000; + + if (value <= 0) { + continue; + } + + if (total++ != 0) { + stringBuilder.append(","); + } + + stringBuilder.append(" " + vlsCategory.getKey() + " " + value); + } + + debug(stringBuilder.toString().replace("%total%", String.valueOf(total))); + } + + int total = 0; + + if (!packetDebug.isEmpty()) { + StringBuilder stringBuilder = new StringBuilder(); + Set> entries = new HashSet<>(packetDebug.entrySet()); + stringBuilder.append("Received Packets (x%total%):"); + packetDebug.clear(); for (Entry packetEntry : entries) { String packetType = packetEntry.getKey(); int amount = packetEntry.getValue(); - if (isFirst) { - isFirst = false; - } else { - stringBuilder.append(", "); + if (total != 0) { + stringBuilder.append(","); } - stringBuilder.append("x").append(amount).append(" ").append(packetType); + stringBuilder.append(" x").append(amount).append(" ").append(packetType); total += amount; } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index e702d16..14643fd 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -187,19 +187,19 @@ public String clearIfBlacklisted(ItemStack itemStack) { } public void addVls(Cancellable event, HamsterPlayer hamsterPlayer, Player player, - double vls) { + double vls, String category) { if (vls > 0) { BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); - exploitPlayer.addVls(event, hamsterPlayer, packetsModule, vls); + exploitPlayer.addVls(event, null, hamsterPlayer, packetsModule, vls, category); } } public void cancelExploit(Cancellable event, HamsterPlayer hamsterPlayer, Player player, - String reason, double vls) { + String reason, double vls, String category) { notificationsModule.debug(reason); event.setCancelled(true); - addVls(event, hamsterPlayer, player, vls); + addVls(event, hamsterPlayer, player, vls, category); } } \ No newline at end of file From 7509b528f15ec8447b38fcc2ea34c61939f775e2 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 3 Jan 2023 20:18:16 -0300 Subject: [PATCH 291/336] Better Configuration Organization --- .../listener/PacketDecodeListener.java | 7 +-- .../exploitfixer/modules/PacketsModule.java | 47 ++++++++++--------- .../exploitfixer/utils/ExploitUtil.java | 6 +-- src/main/resources/config.yml | 30 +++++++----- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 9c3f132..7565641 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -23,7 +23,7 @@ public class PacketDecodeListener implements Listener { private static String PREFIX_OFFLINE = "[Decoder|Offline] "; // Pattern for detecting an amount of tags used - private static Pattern tagPattern = Pattern.compile("(.)[{]{64,}(.)"); + private Pattern tagPattern; private ExploitUtil exploitUtil; private PacketsModule packetsModule; @@ -31,6 +31,7 @@ public class PacketDecodeListener implements Listener { PacketDecodeListener(ExploitUtil exploitUtil, ModuleManager moduleManager) { this.exploitUtil = exploitUtil; this.packetsModule = moduleManager.getPacketsModule(); + this.tagPattern = Pattern.compile("(.)[{]{" + packetsModule.getDataMaxFlags() + ",}(.)"); } private String getName(Player player) { @@ -46,7 +47,7 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play String playerName = player.getName(); double dataVls = packetsModule.getDataVls(); double dataVlMultiplier = packetsModule.getDataVlMultiplier(); - int dataBytes = packetsModule.getDataBytes(); + int dataBytes = packetsModule.getDataMaxSize(); int refCnt = byteBuf.refCnt(); int capacity = byteBuf.capacity(); @@ -85,7 +86,7 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play byteBuf.readerIndex(oldReaderIndex); - if (tagPattern.matcher(content).find()) { + if (packetsModule.getDataMaxFlags() > 0 && tagPattern.matcher(content).find()) { reason = PREFIX + playerName + " sent a packet with too many tags! Vls: " + dataVls; diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 5411188..60c178e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -9,17 +9,17 @@ import dev._2lstudios.exploitfixer.exploit.Violations; public class PacketsModule implements IViolationModule { - private Map multipliers = new HashMap<>(); + private Map rateMultipliers = new HashMap<>(); private Collection blacklist = new HashSet<>(); private Violations violations; private double dataVls, bookVls, tagVls, blockDigVls, blockPlaceVls, setCreativeSlot, windowClick, cancelVls, - reduceVls, vlMultiplier; - private int dataBytesBook, dataBytesSign, dataBytes, dataFireworkFlags; + reduceVls, byteMultiplier; + private int dataMaxSizeBook, dataMaxSizeSign, dataMaxSize, dataMaxFlags, dataMaxFireworkFlags; private boolean enabled, offline; public void reload(IConfiguration configYml) { String name = getName().toLowerCase(); - IConfiguration configurationSection = configYml.getSection(name + ".multipliers"); + IConfiguration rateMultipliersSection = configYml.getSection(name + ".rate_multipliers"); this.enabled = configYml.getBoolean(name + ".enabled"); this.cancelVls = configYml.getDouble(name + ".cancel_vls"); @@ -28,11 +28,12 @@ public void reload(IConfiguration configYml) { this.dataVls = configYml.getDouble(name + ".data.vls"); this.bookVls = configYml.getDouble(name + ".book"); this.tagVls = configYml.getDouble(name + ".tag"); - this.dataBytes = configYml.getInt(name + ".data.bytes"); - this.dataBytesBook = configYml.getInt(name + ".data.bytes_book"); - this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign"); - this.dataFireworkFlags = configYml.getInt(name + ".data.firework_flags"); - this.vlMultiplier = configYml.getDouble(name + ".data.vl_multiplier"); + this.dataMaxSize = configYml.getInt(name + ".data.max_size"); + this.dataMaxSizeBook = configYml.getInt(name + ".data.max_size_book"); + this.dataMaxSizeSign = configYml.getInt(name + ".data.max_size_sign"); + this.dataMaxFlags = configYml.getInt(name + ".data.max_flags"); + this.dataMaxFireworkFlags = configYml.getInt(name + ".data.max_firework_flags"); + this.byteMultiplier = configYml.getDouble(name + ".byte_multiplier"); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); @@ -40,8 +41,8 @@ public void reload(IConfiguration configYml) { this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); this.violations = new Violations(configYml.getSection(name + ".violations")); - for (String key : configurationSection.getKeys()) { - multipliers.put(key, configurationSection.getDouble(key)); + for (String key : rateMultipliersSection.getKeys()) { + rateMultipliers.put(key, rateMultipliersSection.getDouble(key)); } } @@ -71,7 +72,7 @@ public Violations getViolations() { } public double getMultiplier(String packetName) { - return multipliers.getOrDefault(packetName, multipliers.getOrDefault("PacketPlayInOther", 1D)); + return rateMultipliers.getOrDefault(packetName, rateMultipliers.getOrDefault("PacketPlayInOther", 1D)); } public double getWindowClick() { @@ -102,20 +103,20 @@ public double getTagVls() { return tagVls; } - public int getDataBytes() { - return dataBytes; + public int getDataMaxSize() { + return dataMaxSize; } - public int getDataBytesBook() { - return dataBytesBook; + public int getDataMaxSizeBook() { + return dataMaxSizeBook; } - public int getDataBytesSign() { - return dataBytesSign; + public int getDataMaxSizeSign() { + return dataMaxSizeSign; } public double getDataVlMultiplier() { - return vlMultiplier; + return byteMultiplier; } public boolean isOffline() { @@ -126,7 +127,11 @@ public boolean isBlacklisted(String packetName) { return blacklist.contains(packetName); } - public int getDataFireworkFlags() { - return dataFireworkFlags; + public int getDataMaxFireworkFlags() { + return dataMaxFireworkFlags; } + + public int getDataMaxFlags() { + return dataMaxFlags; + } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java index 14643fd..268ae34 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/ExploitUtil.java @@ -73,7 +73,7 @@ private CheckItemResult checkBook(BookMeta meta) { return CheckItemResult.INVALID_BOOK_PAGES; } - int dataBytesBook = packetsModule.getDataBytesBook(); + int dataBytesBook = packetsModule.getDataMaxSizeBook(); for (String page : meta.getPages()) { int pageBytes = page.getBytes(StandardCharsets.UTF_8).length; @@ -98,7 +98,7 @@ private CheckItemResult checkFirework(FireworkMeta meta) { // Check if it has effects if (meta.hasEffects()) { // Get the allowed flags count - int allowedFlags = packetsModule.getDataFireworkFlags(); + int allowedFlags = packetsModule.getDataMaxFireworkFlags(); if (meta.getEffectsSize() > allowedFlags) { // Check for the amount of effects @@ -156,7 +156,7 @@ public CheckItemResult checkItem(ItemStack item) { } public boolean checkSign(String[] linesString) { - int dataBytesSign = packetsModule.getDataBytesSign(); + int dataBytesSign = packetsModule.getDataMaxSizeSign(); if (linesString != null && dataBytesSign > 0) { if (linesString.length > 4) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a0de9a9..cc5e196 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -62,22 +62,21 @@ packets: vls: 100 # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - bytes: 8192 + max_size: 8192 # Maximum amount of bytes allowed per book page. (Set to -1 to disable) - bytes_book: 300 + max_size_book: 300 # Maximum amount of bytes allowed per sign line. (Set to -1 to disable) - bytes_sign: 47 + max_size_sign: 47 - # Maximum amount of flags allowed per firework. (Set to -1 to disable) - firework_flags: 12 + # Maximum amount of flags allowed per packet. (Set to -1 to disable) + max_flags: 64 - # This option adds vls per byte received. - # Vls to add per byte received. (Set to -1 to disable) - vl_multiplier: 0.0001 + # Maximum amount of flags allowed per firework. (Set to -1 to disable) + max_firework_flags: 12 - # Cancels book packets when a book is not in hand + # Cancels book packets when a book is not in hand. (Can sometimes becaused by lag) # Vls to add when a packet fails the check. (Set to -1 to disable) book: 10 @@ -101,11 +100,16 @@ packets: # Vls to add when a packet fails the check. (Set to -1 to disable) set_creative_slot: 100 - # Vls to add when a normal packet is sent by a player. - # This option is made to work as a packet limiter feature. + # This option adds vls per byte received. + # This works as a packet limiter feature. + # Violations to add per byte received. (Set to -1 to disable) + byte_multiplier: 0.0001 + + # Violations to add when a normal packet is received from a player. + # This works as a packet limiter feature. # Unlisted packets are considered as "PacketPlayInOther" by default. - # Remember to take a look at bytes_divider option. - multipliers: + # Remember to take a look at byte_multiplier option. + rate_multipliers: PacketPlayInOther: 0.1 MC|BSign: 4.5 MC|BEdit: 4.5 From 1e497257d0844689008a8f921a3c3ae1215f108d Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:47:26 -0300 Subject: [PATCH 292/336] Apply Cooldown to Shears --- .../exploitfixer/exploit/ExploitPlayer.java | 9 ++++++ .../listener/ListenerInitializer.java | 1 + .../listener/PlayerShearEntityListener.java | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index 920c218..5d11019 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -14,6 +14,7 @@ public abstract class ExploitPlayer { private Collection> punishments; private long lastViolation = 0; private long lastPortalUse = 0; + private long lastShear = 0; public ExploitPlayer(UUID uuid) { this.uuid = uuid; @@ -62,4 +63,12 @@ public UUID getUUID() { public abstract int getPing(); public abstract String getLocale(); + + public boolean hasShearCooldown() { + return System.currentTimeMillis() - lastShear <= 1000; + } + + public void setShearCooldown() { + lastShear = System.currentTimeMillis(); + } } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 2022da5..8c1fbcb 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -40,6 +40,7 @@ public void register() { pluginManager.registerEvents(new PlayerLoginListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerMoveListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); + pluginManager.registerEvents(new PlayerShearEntityListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); pluginManager.registerEvents(new StructureGrowListener(moduleManager), plugin); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java new file mode 100644 index 0000000..21681ae --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java @@ -0,0 +1,30 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerShearEntityEvent; + +import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; +import dev._2lstudios.exploitfixer.managers.ExploitPlayerManager; +import dev._2lstudios.exploitfixer.managers.ModuleManager; + +public class PlayerShearEntityListener implements Listener { + private ExploitPlayerManager exploitPlayerManager; + + public PlayerShearEntityListener(ModuleManager moduleManager) { + this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerShearEntity(PlayerShearEntityEvent event) { + ExploitPlayer exploitPlayer = exploitPlayerManager.get(event.getPlayer()); + + if (exploitPlayer != null) { + if (exploitPlayer.hasShearCooldown()) { + event.setCancelled(true); + } else { + exploitPlayer.setShearCooldown(); + } + } + } +} \ No newline at end of file From 9da5e4e5ac7f201fbd3262d4319a9514db29656b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:47:53 -0300 Subject: [PATCH 293/336] 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4ca3375..42182c2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 1.8.0 + 2.0.0 https://www.spigotmc.org/resources/62842/ From 11110f6c98540b09c1ca12ca99d256dc9ced68ec Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:59:30 -0300 Subject: [PATCH 294/336] Fix double prefix --- .../utils/BukkitConfigurationUtil.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java b/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java index f7ecdad..aaa525c 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/utils/BukkitConfigurationUtil.java @@ -16,7 +16,6 @@ public class BukkitConfigurationUtil implements IConfigurationUtil { private static String DATA_FOLDER_PLACEHOLDER = "%datafolder%"; private String dataFolderPath; - private String prefix; private Logger logger; private Plugin plugin; private BukkitScheduler scheduler; @@ -28,7 +27,6 @@ public BukkitConfigurationUtil(Plugin plugin) { this.logger = plugin.getLogger(); this.classLoader = plugin.getClass().getClassLoader(); this.dataFolderPath = plugin.getDataFolder().toString(); - this.prefix = "[" + plugin.getName() + "]"; } private void createParentFolder(File file) { @@ -66,10 +64,10 @@ public void create(String rawPath, String resourcePath) { configFile.createNewFile(); } - logger.info(prefix + " File '" + path + "' has been created!"); + logger.info("File '" + path + "' has been created!"); } } catch (IOException e) { - logger.info(prefix + " Unable to create '" + path + "'!"); + logger.info("Unable to create '" + path + "'!"); } } @@ -80,9 +78,9 @@ public void save(IConfiguration configuration, String rawPath) { try { ((YamlConfiguration) configuration.getObject()).save(path); - logger.info(prefix + " File '" + path + "' has been saved!"); + logger.info("File '" + path + "' has been saved!"); } catch (IOException e) { - logger.info(prefix + " Unable to save '" + path + "'!"); + logger.info("Unable to save '" + path + "'!"); } }); } @@ -94,9 +92,9 @@ public void delete(String rawPath) { try { Files.delete(new File(path).toPath()); - logger.info(prefix + " File '" + path + "' has been removed!"); + logger.info("File '" + path + "' has been removed!"); } catch (IOException e) { - logger.info(prefix + " Unable to remove '" + path + "'!"); + logger.info("Unable to remove '" + path + "'!"); } }); } From fc4758089386dddce759c08513a96c57530df2c0 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:09:59 -0300 Subject: [PATCH 295/336] Prevent Bow Velocity Crasher --- .../listener/PlayerShearEntityListener.java | 3 ++- .../listener/ProjectileLaunchListener.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/ProjectileLaunchListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java index 21681ae..b1fd8f2 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerShearEntityListener.java @@ -1,6 +1,7 @@ package dev._2lstudios.exploitfixer.listener; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerShearEntityEvent; @@ -15,7 +16,7 @@ public PlayerShearEntityListener(ModuleManager moduleManager) { this.exploitPlayerManager = moduleManager.getExploitPlayerManager(); } - @EventHandler(ignoreCancelled = true) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) public void onPlayerShearEntity(PlayerShearEntityEvent event) { ExploitPlayer exploitPlayer = exploitPlayerManager.get(event.getPlayer()); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ProjectileLaunchListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ProjectileLaunchListener.java new file mode 100644 index 0000000..8ddfcc3 --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ProjectileLaunchListener.java @@ -0,0 +1,22 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.entity.Entity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +public class ProjectileLaunchListener implements Listener { + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) + public void onProjectileLaunch(ProjectileLaunchEvent event) { + Entity entity = event.getEntity(); + + if (entity == null) { + return; + } + + if (entity.getVelocity().lengthSquared() > 15) { + event.setCancelled(true); + } + } +} From 5e7050f31510c033d8372f805e7725ffe767c8c5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:26:14 -0300 Subject: [PATCH 296/336] Packets Bypass Permission --- .../listener/PacketDecodeListener.java | 6 ++++++ .../listener/PacketReceiveListener.java | 18 ++++++++++++++---- .../exploitfixer/modules/PacketsModule.java | 6 ++++++ src/main/resources/config.yml | 4 ++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index 7565641..a0e7d55 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -44,6 +44,12 @@ private String getName(Player player) { private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Player player, ByteBuf byteBuf) { if (player != null && player.isOnline()) { + String bypassPermission = packetsModule.getBypassPermission(); + + if (bypassPermission != null && player.hasPermission(bypassPermission)) { + return; + } + String playerName = player.getName(); double dataVls = packetsModule.getDataVls(); double dataVlMultiplier = packetsModule.getDataVlMultiplier(); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index ceecb54..b685d15 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -56,6 +56,12 @@ public class PacketReceiveListener implements Listener { public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Player player, PacketWrapper packetWrapper) { + String bypassPermission = packetsModule.getBypassPermission(); + + if (bypassPermission != null && player.hasPermission(bypassPermission)) { + return; + } + PacketType packetType = packetWrapper.getType(); String packetName = packetWrapper.getName(); String playerName = player.getName(); @@ -67,7 +73,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play double windowClick = packetsModule.getWindowClick(); double setCreativeSlot = packetsModule.getSetCreativeSlot(); - exploitPlayer.addVls(event, null, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName), "Packet Rate"); + exploitPlayer.addVls(event, null, hamsterPlayer, packetsModule, packetsModule.getMultiplier(packetName), + "Packet Rate"); if (packetsModule.isBlacklisted(packetName)) { String reason = "[" + packetName + "] " + playerName + " sent a Blacklisted packet!"; @@ -127,7 +134,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play + " tried to quick move on a lectern! Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Lectern Crash"); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Lectern Crash"); return; } } else { @@ -136,7 +144,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play + " tried to quick move on a lectern! Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Lectern Crash"); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Lectern Crash"); return; } } @@ -178,7 +187,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|SetCreativeSlot] " + playerName + " sent SET_CREATIVE_SLOT without CREATIVE! Added vls: " + setCreativeSlot; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot, "Creative Packet No Creative"); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, setCreativeSlot, + "Creative Packet No Creative"); return; } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 60c178e..91511d0 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -16,6 +16,7 @@ public class PacketsModule implements IViolationModule { reduceVls, byteMultiplier; private int dataMaxSizeBook, dataMaxSizeSign, dataMaxSize, dataMaxFlags, dataMaxFireworkFlags; private boolean enabled, offline; + private String bypassPermission; public void reload(IConfiguration configYml) { String name = getName().toLowerCase(); @@ -38,6 +39,7 @@ public void reload(IConfiguration configYml) { this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); + this.bypassPermission = configYml.getString(name + ".bypass_permission"); this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); this.violations = new Violations(configYml.getSection(name + ".violations")); @@ -134,4 +136,8 @@ public int getDataMaxFireworkFlags() { public int getDataMaxFlags() { return dataMaxFlags; } + + public String getBypassPermission() { + return bypassPermission; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cc5e196..c32c8dd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -105,6 +105,10 @@ packets: # Violations to add per byte received. (Set to -1 to disable) byte_multiplier: 0.0001 + # Set a permission for some players to bypass this check. (Uncomment to enable) + # WARNING: Players with this permission can crash and corrupt worlds FOREVER with hacked clients. + #bypass_permission: "exploitfixer.packets.bypass" + # Violations to add when a normal packet is received from a player. # This works as a packet limiter feature. # Unlisted packets are considered as "PacketPlayInOther" by default. From 6375e4443d6fe28e878d99d1c5879d7325ddd406 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:29:21 -0300 Subject: [PATCH 297/336] Register new listeners --- .../_2lstudios/exploitfixer/listener/ListenerInitializer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 8c1fbcb..04392b4 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -42,6 +42,7 @@ public void register() { pluginManager.registerEvents(new PlayerQuitListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerShearEntityListener(moduleManager), plugin); pluginManager.registerEvents(new PlayerTeleportListener(moduleManager), plugin); + pluginManager.registerEvents(new ProjectileLaunchListener(), plugin); pluginManager.registerEvents(new StructureGrowListener(moduleManager), plugin); } From 7e0bb1e9b154ceed1612f9507937645f4f22ae37 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:55:22 -0300 Subject: [PATCH 298/336] 2.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 42182c2..fda1416 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.0 + 2.0.1 https://www.spigotmc.org/resources/62842/ From 72af5de718d3d0c326dcc3c4cb85315ec09e358f Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:45:20 -0300 Subject: [PATCH 299/336] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f1e5da3..d2ab7fa 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # ExploitFixer Lightweight and highly customizable Bukkit plugin that fixes Exploits related to invalid Packets. [Requires HamsterAPI to work] + +Download JAR: https://builtbybit.com/resources/exploitfixer-ultimate-anticrasher.26463/ From 30a4742fba36569bf3d79f23e3e71f8177e5300f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sat, 14 Jan 2023 14:40:52 -0300 Subject: [PATCH 300/336] Do Not Check Already Created Items --- .../_2lstudios/exploitfixer/ExploitFixer.java | 4 +- .../listener/PacketReceiveListener.java | 27 +++++++++- .../exploitfixer/modules/ItemsFixModule.java | 49 +++++++++++++++---- src/main/resources/config.yml | 15 ++++-- 4 files changed, 78 insertions(+), 17 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java index 00a0f45..2fff527 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/ExploitFixer.java @@ -84,7 +84,9 @@ public void unregister() { scheduler.cancelTasks(this); server.getMessenger().unregisterIncomingPluginChannel(this); - this.listenerInitializer.unregister(); + if (this.listenerInitializer != null) { + this.listenerInitializer.unregister(); + } } private void register() { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index b685d15..f720be5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -251,8 +251,31 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play notificationsModule.debug( playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); } else { - packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); - notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); + if (itemsFixModule.isWhitelistItems()) { + // Get the slot + int slot = 0; + + if (integers.size() == 1) { + for (int value : integers.values()) { + slot = value; + } + } + + // Get the item by the slot + ItemStack inventoryItem = inventoryView.getItem(slot); + + if (inventoryItem != null && inventoryItem.getType() != Material.AIR) { + // Whitelist already created item + itemsFixModule.setWhitelisted(inventoryItem); + } else if (!itemsFixModule.isWhitelisted(item)) { + // Fix the newly created item + packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); + notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); + } + } else { + packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); + notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); + } } } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java index 4cc407a..83f3365 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/ItemsFixModule.java @@ -1,9 +1,11 @@ package dev._2lstudios.exploitfixer.modules; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map.Entry; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -24,19 +26,32 @@ public class ItemsFixModule implements IModule { private int maxStackSize; private Collection blacklist; private String bypassPermission; + private boolean useGameProfile; + + // Whitelist already created items + private boolean whitelistItems; + private Collection fixed = new HashSet<>(); public ItemsFixModule(Plugin plugin) { this.plugin = plugin; + String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; + this.useGameProfile = + !version.startsWith("v1_17") && !version.startsWith("v1_16") + && !version.startsWith("v1_15") && !version.startsWith("v1_14") + && !version.startsWith("v1_13") && !version.startsWith("v1_12") + && !version.startsWith("v1_11") && !version.startsWith("v1_10") + && !version.startsWith("v1_9") && !version.startsWith("v1_8"); } public void reload(IConfiguration configYml) { - String name = getName().toLowerCase(); - - this.enabled = configYml.getBoolean(name + ".enabled"); - this.enchantLimit = configYml.getInt(name + ".enchant_limit"); - this.maxStackSize = configYml.getInt(name + ".max_stack_size"); - this.blacklist = configYml.getStringList(name + ".blacklist"); - this.bypassPermission = configYml.getString(name + ".bypass_permission"); + String prefix = "creative-items-fix."; + + this.enabled = configYml.getBoolean(prefix + "enabled"); + this.enchantLimit = configYml.getInt(prefix + "enchant-limit"); + this.maxStackSize = configYml.getInt(prefix + "max-stack-size"); + this.blacklist = configYml.getStringList(prefix + "blacklist"); + this.whitelistItems = configYml.getBoolean(prefix + "whitelist-items"); + this.bypassPermission = configYml.getString(prefix + "bypass-permission"); } @Override @@ -46,7 +61,7 @@ public boolean isEnabled() { @Override public String getName() { - return "ItemsFix"; + return "CreativeItemsFix"; } public int getEnchantLimit() { @@ -65,6 +80,18 @@ public String getBypassPermission() { return bypassPermission; } + public void setWhitelisted(ItemStack inventoryItem) { + fixed.add(inventoryItem); + } + + public boolean isWhitelisted(ItemStack item) { + return fixed.contains(item); + } + + public boolean isWhitelistItems() { + return whitelistItems; + } + public ItemStack fixItem(ItemStack item) { Material material = Material.getMaterial(item.getType().name()); ItemMeta newItemMeta = plugin.getServer().getItemFactory().getItemMeta(material); @@ -119,7 +146,11 @@ public ItemStack fixItem(ItemStack item) { SkullMeta oldSkullMeta = (SkullMeta) oldItemMeta; SkullMeta newSkullMeta = (SkullMeta) newItemMeta; - newSkullMeta.setOwner(oldSkullMeta.getOwner()); + if (useGameProfile) { + newSkullMeta.setOwnerProfile(oldSkullMeta.getOwnerProfile()); + } else { + newSkullMeta.setOwner(oldSkullMeta.getOwner()); + } } else if (newItemMeta instanceof BannerMeta) { BannerMeta oldBannerMeta = (BannerMeta) oldItemMeta; BannerMeta newBannerMeta = (BannerMeta) newItemMeta; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c32c8dd..455dac6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -157,17 +157,22 @@ packets: # Removes custom/invalid NBT tags from items to prevent harm to your server. # This prevents creative mode players from corrupting worlds FOREVER and crashing the server. # This checks only applies to creative mode players. -itemsfix: +creative-items-fix: enabled: true # Maximum stack size obtainable with creative packets. (-1 to allow anything) - max_stack_size: 64 + max-stack-size: 64 # Maximum enchant level obtainable with creative packets. # -1 removes all enchants, 0 forces vanilla values - enchant_limit: 0 + enchant-limit: 0 - # List of materials that are unobtainable from Creative. + # Whitelist already created items to improve performance and stability. + # Items created with commands will not be checked when enabled. + # Set to false if your server has already created crasher items. + whitelist-items: true + + # List of materials that are blocked from Creative. blacklist: - "END_PORTAL" - "NETHER_PORTAL" @@ -176,7 +181,7 @@ itemsfix: # Set a permission for some players to bypass this check. (Uncomment to enable) # WARNING: Players with this permission can crash and corrupt worlds FOREVER with hacked clients. - #bypass_permission: "exploitfixer.itemsfix.bypass" + #bypass-permission: "exploitfixer.itemsfix.bypass" # Checks if players try to crash/exploit the server with commands. commands: From 1c96ab1eef810cc9031632f2029eb6ee4069cd07 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:50:09 -0300 Subject: [PATCH 301/336] 2.0.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fda1416..6667cc3 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.1 + 2.0.2 https://www.spigotmc.org/resources/62842/ From 162363fd6254c7b1a667e9d84b72e958ce82a06f Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Sat, 14 Jan 2023 19:29:53 -0300 Subject: [PATCH 302/336] Update README.md --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2ab7fa..967f7d7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ # ExploitFixer -Lightweight and highly customizable Bukkit plugin that fixes Exploits related to invalid Packets. [Requires HamsterAPI to work] -Download JAR: https://builtbybit.com/resources/exploitfixer-ultimate-anticrasher.26463/ +ExploitFixer is a high performance packet filter that prevents many kinds of crashers, laggers and exploits from being used in your Spigot/Paper server. + +## Links + + + +## How To (Server Admins) + +Download a copy of ExploitFixer. [MC-Market](https://builtbybit.com/resources/26463/) + +Install in your Spigot/Paper plugins folder. + +## How To (Compiling From Source) + +To compile FlamePaper, you need [JDK8](https://adoptopenjdk.net/releases.html), [maven](https://maven.apache.org/download.cgi), and an internet connection. + +Clone this repo, run ```mvn clean install``` from *bash*. From ec418ce937954723bc02fb622d0469a85b5a0db4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 16 Jan 2023 16:56:28 -0300 Subject: [PATCH 303/336] Fixed WindowClick Slot Exploit --- .../listener/PacketReceiveListener.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index f720be5..2b8743c 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -152,19 +152,11 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } - Inventory bottomInventory = inventoryView.getBottomInventory(); boolean containsSlot = integers.containsKey("slot"); if (containsSlot || integers.containsKey("d")) { int slot = containsSlot ? integers.get("slot") : integers.get("d"); - int maxSlots; - - if (bottomInventory.getType() == InventoryType.PLAYER - && topInventory.getType() == InventoryType.CRAFTING) { - maxSlots = inventoryView.countSlots() + 4; - } else { - maxSlots = inventoryView.countSlots(); - } + int maxSlots = inventoryView.countSlots();; if (slot < 0 && slot != -999 && slot != -1) { String reason = "[" + packetName + "|WindowClick] " + playerName @@ -172,12 +164,16 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Invalid Slot"); return; - } else if (slot >= maxSlots) { - String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " - + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Large/Short Slot"); - return; + } else { + try { + inventoryView.getItem(slot); + } catch (IndexOutOfBoundsException ex) { + String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Large/Short Slot"); + return; + } } } } From 140a2b8661d182fccf668d3a257288dd0fcaae53 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 16 Jan 2023 16:57:02 -0300 Subject: [PATCH 304/336] 2.0.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6667cc3..5197a10 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.2 + 2.0.3 https://www.spigotmc.org/resources/62842/ From 30af401087bcd74d250d6372c0eaa9822b4709c4 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:12:02 -0300 Subject: [PATCH 305/336] Fixed Lectern Anti-Exploit only working on 1.18 --- .../listener/PacketReceiveListener.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 2b8743c..e199971 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -128,16 +128,14 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play if (topInventory.getType().name().equals("LECTERN")) { if (this.checkLectern) { - if (version.equals("v1_18_R1")) { - if (integers.containsKey("a") && integers.get("a") == 1) { - String reason = "[" + packetName + "|WindowClick] " + playerName - + " tried to quick move on a lectern! Added vls: " - + windowClick; + if (integers.containsKey("a") && integers.get("a") == 1) { + String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, - "Lectern Crash"); - return; - } + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Lectern Crash"); + return; } else { if (integers.containsKey("b") && integers.get("b") == 1) { String reason = "[" + packetName + "|WindowClick] " + playerName From d70a807e834b9e639e21d962dac49f4105c73c63 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:12:23 -0300 Subject: [PATCH 306/336] 2.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5197a10..6c668de 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.3 + 2.0.4 https://www.spigotmc.org/resources/62842/ From 69ec18ba36279f3c755d49c364f6a76d2070f942 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:20:20 -0300 Subject: [PATCH 307/336] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 967f7d7..436d8e0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ExploitFixer is a high performance packet filter that prevents many kinds of crashers, laggers and exploits from being used in your Spigot/Paper server. +You can download the prebuilt jar binaries in the link below. + ## Links From 556945f8e2e9900deb71966dc29279455d848fec Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:39:11 -0300 Subject: [PATCH 308/336] Bypass permission for commands check --- .../exploitfixer/listener/PlayerCommandListener.java | 7 +++++++ .../_2lstudios/exploitfixer/modules/CommandsModule.java | 6 ++++++ .../dev/_2lstudios/exploitfixer/modules/PacketsModule.java | 2 +- src/main/resources/config.yml | 6 +++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index 176131f..d465e4a 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -28,6 +28,13 @@ public class PlayerCommandListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); + + String bypassPermission = commandsModule.getBypassPermission(); + + if (bypassPermission != null && player.hasPermission(bypassPermission)) { + return; + } + BukkitExploitPlayer exploitPlayer = exploitPlayerManager.get(player); if (commandsModule.isEnabled() && commandsModule.isCommand(event.getMessage())) { diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java index 614887a..c154c42 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/CommandsModule.java @@ -12,12 +12,14 @@ public class CommandsModule implements IPunishmentModule { private Collection punishments; private String name; private boolean enabled; + private String bypassPermission; public void reload(IConfiguration configYml) { this.name = "Commands"; this.enabled = configYml.getBoolean("commands.enabled"); this.commands = configYml.getStringList("commands.commands"); this.punishments = configYml.getStringList("commands.punishments"); + this.bypassPermission = configYml.getString("commands.bypass-permission"); } @Override @@ -47,4 +49,8 @@ public boolean isCommand(String rawMessage) { public Collection getPunishments() { return punishments; } + + public String getBypassPermission() { + return bypassPermission; + } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java index 91511d0..3bd17be 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/PacketsModule.java @@ -39,7 +39,7 @@ public void reload(IConfiguration configYml) { this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); - this.bypassPermission = configYml.getString(name + ".bypass_permission"); + this.bypassPermission = configYml.getString(name + ".bypass-permission"); this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); this.violations = new Violations(configYml.getSection(name + ".violations")); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 455dac6..4290185 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -107,7 +107,7 @@ packets: # Set a permission for some players to bypass this check. (Uncomment to enable) # WARNING: Players with this permission can crash and corrupt worlds FOREVER with hacked clients. - #bypass_permission: "exploitfixer.packets.bypass" + #bypass-permission: "exploitfixer.packets.bypass" # Violations to add when a normal packet is received from a player. # This works as a packet limiter feature. @@ -213,6 +213,10 @@ commands: - "/mvhelp <" - "/$" + # Set a permission for some players to bypass this check. (Uncomment to enable) + # WARNING: Players with this permission can crash and corrupt worlds FOREVER with hacked clients. + #bypass-permission: "exploitfixer.commands.bypass" + # Placeholders: %player% punishments: - "notification" From 3a5fc90c11539f91eaf1e8a01a5c16fb7a02976f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:53:46 -0300 Subject: [PATCH 309/336] 2.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c668de..4bfe35e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.4 + 2.0.5 https://www.spigotmc.org/resources/62842/ From dd8034da4be157eca0b7fcedb950b0f739127758 Mon Sep 17 00:00:00 2001 From: GDMgamer3992 <92255872+GDMgmer3992@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:29:59 +0700 Subject: [PATCH 310/336] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 436d8e0..34ca2c3 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ Install in your Spigot/Paper plugins folder. ## How To (Compiling From Source) -To compile FlamePaper, you need [JDK8](https://adoptopenjdk.net/releases.html), [maven](https://maven.apache.org/download.cgi), and an internet connection. +To compile ExploitFixer, you need [JDK8](https://adoptopenjdk.net/releases.html), [maven](https://maven.apache.org/download.cgi), and an internet connection. Clone this repo, run ```mvn clean install``` from *bash*. From 4a63d0a6e2afe76a96cba719509e374e37c729f2 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:21:25 -0300 Subject: [PATCH 311/336] Prevent commands while dead/offline --- .../exploitfixer/listener/PlayerCommandListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index d465e4a..75bef77 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -1,5 +1,6 @@ package dev._2lstudios.exploitfixer.listener; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -29,6 +30,13 @@ public class PlayerCommandListener implements Listener { public void onPlayerCommand(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); + // Commands while offline/dead wont be executed + if (!player.isOnline() || player.isDead()) { + Bukkit.getServer().broadcastMessage(player.getName() + " sent a command while offline"); + event.setCancelled(true); + return; + } + String bypassPermission = commandsModule.getBypassPermission(); if (bypassPermission != null && player.hasPermission(bypassPermission)) { From c8db36216006c95233d2007fe9035dd5cd3acd4e Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:21:50 -0300 Subject: [PATCH 312/336] remove debug message --- .../_2lstudios/exploitfixer/listener/PlayerCommandListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index 75bef77..09a8466 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -32,7 +32,6 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) { // Commands while offline/dead wont be executed if (!player.isOnline() || player.isDead()) { - Bukkit.getServer().broadcastMessage(player.getName() + " sent a command while offline"); event.setCancelled(true); return; } From bb175312de2aeb873191aec346a32af4dd956179 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 20 Jan 2023 22:39:55 -0300 Subject: [PATCH 313/336] 2.0.6 --- pom.xml | 2 +- .../_2lstudios/exploitfixer/listener/PlayerCommandListener.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4bfe35e..e1bffb9 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.5 + 2.0.6 https://www.spigotmc.org/resources/62842/ diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java index 09a8466..540c3e6 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PlayerCommandListener.java @@ -1,6 +1,5 @@ package dev._2lstudios.exploitfixer.listener; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; From 40d97dd2043fc082a7ba4b87d234671ebc21cf6a Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Sun, 22 Jan 2023 11:47:37 -0300 Subject: [PATCH 314/336] Show received packets list --- .../exploit/BukkitExploitPlayer.java | 1 + .../exploitfixer/exploit/ExploitPlayer.java | 30 ++++++++++++++++--- .../listener/PacketReceiveListener.java | 2 +- .../modules/NotificationsModule.java | 12 +++++--- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 9f5710d..80135be 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -61,6 +61,7 @@ public void addVls(Cancellable event, PacketWrapper packet, long lastViolation = getLastViolation(); if (currentTime - lastViolation >= 1000) { + clearPackets(); clearPunishments(); setLastViolation(currentTime); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java index 5d11019..0f2d775 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/ExploitPlayer.java @@ -5,21 +5,23 @@ import java.util.HashSet; import java.util.Map; import java.util.UUID; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import dev._2lstudios.exploitfixer.modules.IViolationModule; public abstract class ExploitPlayer { private UUID uuid; - private Map violations; - private Collection> punishments; + private Map violations = new HashMap<>(); + private Map packets = new ConcurrentHashMap<>(); + private Collection> punishments = new HashSet<>(); + private int packetCount = 0; private long lastViolation = 0; private long lastPortalUse = 0; private long lastShear = 0; public ExploitPlayer(UUID uuid) { this.uuid = uuid; - this.violations = new HashMap<>(); - this.punishments = new HashSet<>(); } public void clearPunishments() { @@ -71,4 +73,24 @@ public boolean hasShearCooldown() { public void setShearCooldown() { lastShear = System.currentTimeMillis(); } + + public void addPacket(String packetName) { + packetCount++; + packets.put(packetName, packets.getOrDefault(packetName, 0) + 1); + } + + public void clearPackets() { + packetCount = 0; + packets.clear(); + } + + public String getPacketsText() { + StringBuilder stringBuilder = new StringBuilder("Received Packets (x" + packetCount + "):"); + + for (Entry packet : packets.entrySet()) { + stringBuilder.append("\n- x" + packet.getValue() + " " + packet.getKey()); + } + + return stringBuilder.toString(); + } } \ No newline at end of file diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index e199971..8297c5f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -11,7 +11,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; @@ -275,6 +274,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } + exploitPlayer.addPacket(String.valueOf(packetType)); notificationsModule.addPacketDebug(String.valueOf(packetType)); } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java index 106b1d3..8b15ad5 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/NotificationsModule.java @@ -9,11 +9,13 @@ import java.util.logging.Logger; import org.bukkit.Server; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import dev._2lstudios.exploitfixer.configuration.IConfiguration; import dev._2lstudios.exploitfixer.exploit.ExploitPlayer; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; public class NotificationsModule implements INotificationsModule { private Server server; @@ -155,15 +157,17 @@ public void sendNotification(String check, ExploitPlayer player, int violations) int ping = player.getPing(); String notification = getMessage().replace("%player%", player.getName()).replace("%check%", check) .replace("%ping%", String.valueOf(ping)).replace("%vls%", String.valueOf(violations)); - ConsoleCommandSender console = server.getConsoleSender(); + String packets = player.getPacketsText(); + TextComponent textNotification = new TextComponent(notification); + textNotification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(packets).create())); - console.sendMessage(notification); + server.getConsoleSender().sendMessage(notification); for (String notificationPlayerName : getNotifications()) { Player notificationPlayer = server.getPlayer(notificationPlayerName); if (notificationPlayer != null) { - notificationPlayer.sendMessage(notification); + notificationPlayer.spigot().sendMessage(textNotification); } } } From 2af2bf58c0fc274439e213b774c62762ea926953 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 23 Jan 2023 15:50:25 -0300 Subject: [PATCH 315/336] 2.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1bffb9..ec6c471 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.6 + 2.0.7 https://www.spigotmc.org/resources/62842/ From bbcc49e71d08ee61f509b2bf5ce66f190284702b Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 26 Jan 2023 17:01:06 -0300 Subject: [PATCH 316/336] Fix error clicking outside Creative inventories --- .../listener/PacketReceiveListener.java | 55 +++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 8297c5f..51152d7 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -153,7 +153,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play if (containsSlot || integers.containsKey("d")) { int slot = containsSlot ? integers.get("slot") : integers.get("d"); - int maxSlots = inventoryView.countSlots();; + int maxSlots = inventoryView.countSlots(); + ; if (slot < 0 && slot != -999 && slot != -1) { String reason = "[" + packetName + "|WindowClick] " + playerName @@ -168,7 +169,8 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play String reason = "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Large/Short Slot"); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Large/Short Slot"); return; } } @@ -244,29 +246,59 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play notificationsModule.debug( playerName + " had a creative item blacklisted by ExploitFixer! (" + blacklisted + ")"); } else { + // Check if whitelist system is enabled if (itemsFixModule.isWhitelistItems()) { - // Get the slot + // Create the slot variable int slot = 0; + // Get the slot from a packet integer if (integers.size() == 1) { for (int value : integers.values()) { slot = value; } } - // Get the item by the slot - ItemStack inventoryItem = inventoryView.getItem(slot); + // Check the slot item and if exists, whitelist it + if (slot != -1 && slot != -999) { + // Check for window click exploit + try { + // Get the item by the slot + ItemStack inventoryItem = inventoryView.getItem(slot); + + if (inventoryItem != null && inventoryItem.getType() != Material.AIR) { + // Whitelist already created item + itemsFixModule.setWhitelisted(inventoryItem); + return; + } + } catch (IndexOutOfBoundsException ex) { + // Window click exploit detected + String reason = "[" + packetName + "|PacketPlayInSetCreativeSlot] " + playerName + + " exceeded max available slots! (" + slot + "/" + + inventoryView.countSlots() + + ") Added vls: " + + windowClick; + + // Cancel and notify + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Large/Short Slot"); + return; + } + } - if (inventoryItem != null && inventoryItem.getType() != Material.AIR) { - // Whitelist already created item - itemsFixModule.setWhitelisted(inventoryItem); - } else if (!itemsFixModule.isWhitelisted(item)) { + // Check if the item is not whitelisted + if (!itemsFixModule.isWhitelisted(item)) { // Fix the newly created item packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); + + // Notify about this notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); + return; } - } else { + } else { // Whitelist system not enabled + // Fix the item packetWrapper.write(itemsEntry.getKey(), itemsFixModule.fixItem(item)); + + // Notify about this notificationsModule.debug(playerName + " had a creative item fixed by ExploitFixer!"); } } @@ -274,7 +306,10 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } + // Add the packet to the player instance to count it exploitPlayer.addPacket(String.valueOf(packetType)); + + // Add the packet to the notifications module to count it notificationsModule.addPacketDebug(String.valueOf(packetType)); } From aa82e31e05a604fe6437ead5dbc332c78f881304 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:26:18 -0300 Subject: [PATCH 317/336] 2.0.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec6c471..8f9269c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.7 + 2.0.8 https://www.spigotmc.org/resources/62842/ From e2ae39fcab00eb434e6ab163a9ec578c83f40879 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:15:27 -0300 Subject: [PATCH 318/336] Better code for Window Click checks --- .../listener/PacketDecodeListener.java | 4 +- .../listener/PacketReceiveListener.java | 84 +++++++++++-------- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java index a0e7d55..b091fdd 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketDecodeListener.java @@ -110,9 +110,7 @@ private void onPacketDecode(Cancellable event, HamsterPlayer hamsterPlayer, Play exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, dataVls, "Too Big Packet"); } - } else if (packetsModule.isOffline()) - - { + } else if (packetsModule.isOffline()) { String reason = PREFIX_OFFLINE + getName(player) + " sent a packet while being offline!"; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, 0, "Offline"); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 51152d7..317a8e9 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -122,21 +122,17 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play } } - if (windowClick > 0 && packetType == PacketType.PacketPlayInWindowClick) { - Inventory topInventory = inventoryView.getTopInventory(); - - if (topInventory.getType().name().equals("LECTERN")) { - if (this.checkLectern) { - if (integers.containsKey("a") && integers.get("a") == 1) { - String reason = "[" + packetName + "|WindowClick] " + playerName - + " tried to quick move on a lectern! Added vls: " - + windowClick; - - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, - "Lectern Crash"); - return; - } else { - if (integers.containsKey("b") && integers.get("b") == 1) { + // Check if Window Click vls is more than 0 + if (windowClick > 0) { + // Check if the packet is Window Click + if (packetType == PacketType.PacketPlayInWindowClick) { + // Get the top inventory + Inventory topInventory = inventoryView.getTopInventory(); + + // Check if the top inventory is lectern + if (topInventory.getType().name().equals("LECTERN")) { + if (this.checkLectern) { + if (integers.containsKey("a") && integers.get("a") == 1) { String reason = "[" + packetName + "|WindowClick] " + playerName + " tried to quick move on a lectern! Added vls: " + windowClick; @@ -144,34 +140,54 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Lectern Crash"); return; + } else { + if (integers.containsKey("b") && integers.get("b") == 1) { + String reason = "[" + packetName + "|WindowClick] " + playerName + + " tried to quick move on a lectern! Added vls: " + + windowClick; + + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Lectern Crash"); + return; + } } } } - } - boolean containsSlot = integers.containsKey("slot"); + // Check if the slot variable is set + boolean containsSlot = integers.containsKey("slot"); - if (containsSlot || integers.containsKey("d")) { - int slot = containsSlot ? integers.get("slot") : integers.get("d"); - int maxSlots = inventoryView.countSlots(); - ; + // Sometimes, d is used as slot + boolean containsD = integers.containsKey("d"); - if (slot < 0 && slot != -999 && slot != -1) { - String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Invalid Slot"); - return; - } else { - try { - inventoryView.getItem(slot); - } catch (IndexOutOfBoundsException ex) { + if (containsSlot || containsD) { + // Get the clicked slot + int slot = containsSlot ? integers.get("slot") : integers.get("d"); + + // Get the maximum slot index + int maxSlots = inventoryView.countSlots() - 1; + + // Check if the slot is less than 0 + // -999 and -1 are legit slots + if (slot < 0 && slot != -999 && slot != -1) { String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, - "Large/Short Slot"); + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Invalid Slot"); return; + } else { + // Try to get an item in that slot + // If this check generates an exception, it means it blocked the exploit + try { + inventoryView.getItem(slot); + } catch (IndexOutOfBoundsException | IllegalArgumentException ex) { + String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Large/Short Slot"); + return; + } } } } From 4fe9400958520b7b21e0d19db87e32e13bca8108 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:46:37 -0300 Subject: [PATCH 319/336] 2.0.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f9269c..755ab10 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ExploitFixer Advanced anti-exploit security plugin for Spigot servers. - 2.0.8 + 2.0.9 https://www.spigotmc.org/resources/62842/ From 17ef0598260a43236b59bd48af40d542731bb535 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 9 Feb 2023 19:18:16 -0300 Subject: [PATCH 320/336] Make uncompilable due to abuse --- pom.xml | 76 --------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 pom.xml diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 755ab10..0000000 --- a/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - 4.0.0 - - dev._2lstudios - ExploitFixer - jar - - ExploitFixer - Advanced anti-exploit security plugin for Spigot servers. - 2.0.9 - https://www.spigotmc.org/resources/62842/ - - - 2LS - UTF-8 - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - 2lstudios - https://ci.2lstudios.dev/plugin/repository/everything/ - - - - - - org.spigotmc - spigot-api - 1.19-R0.1-SNAPSHOT - provided - - - dev._2lstudios - HamsterAPI - 0.2.3 - - - - - ${artifactId} - src/main/java - clean install - - - src/main/resources - true - - plugin.yml - bungee.yml - - - - src/main/resources - - plugin.yml - bungee.yml - - - - - - - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - - - - From baca150c573eedc75a9e9087c04461dea9afb02f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 10 Feb 2023 09:50:46 -0300 Subject: [PATCH 321/336] Fixed errors during Invalid Slot exploit --- .../_2lstudios/exploitfixer/listener/PacketReceiveListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 317a8e9..14a5636 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -180,7 +180,7 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play // If this check generates an exception, it means it blocked the exploit try { inventoryView.getItem(slot); - } catch (IndexOutOfBoundsException | IllegalArgumentException ex) { + } catch (Exception ex) { String reason = "[" + packetName + "|WindowClick] " + playerName + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + windowClick; From aaf3dd95b375c02eb5b412fa97554bd7fab44adf Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:24:14 -0300 Subject: [PATCH 322/336] Fixed detecting -1 and -999 as exploit --- .../listener/PacketReceiveListener.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java index 14a5636..352e93f 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/PacketReceiveListener.java @@ -167,26 +167,29 @@ public void onPacketReceive(Cancellable event, HamsterPlayer hamsterPlayer, Play // Get the maximum slot index int maxSlots = inventoryView.countSlots() - 1; - // Check if the slot is less than 0 // -999 and -1 are legit slots - if (slot < 0 && slot != -999 && slot != -1) { - String reason = "[" + packetName + "|WindowClick] " + playerName - + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " - + windowClick; - exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, "Invalid Slot"); - return; - } else { - // Try to get an item in that slot - // If this check generates an exception, it means it blocked the exploit - try { - inventoryView.getItem(slot); - } catch (Exception ex) { + if (slot != -999 && slot != -1) { + // Check if the slot is negative + if (slot < 0) { String reason = "[" + packetName + "|WindowClick] " + playerName - + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + " sent a slot less than 0 and not [-999 or -1]! Slot: " + slot + " Added vls: " + windowClick; exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, - "Large/Short Slot"); + "Invalid Slot"); return; + } else { + // Try to get an item in that slot + // If this check generates an exception, it means it blocked the exploit + try { + inventoryView.getItem(slot); + } catch (Exception ex) { + String reason = "[" + packetName + "|WindowClick] " + playerName + + " exceeded max available slots! (" + slot + "/" + maxSlots + ") Added vls: " + + windowClick; + exploitUtil.cancelExploit(event, hamsterPlayer, player, reason, windowClick, + "Large/Short Slot"); + return; + } } } } From 9178fe61038b3aabf250516eb7ca8309fff75460 Mon Sep 17 00:00:00 2001 From: Juan Cruz Linsalata <25271111+linsaftw@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:37:19 -0300 Subject: [PATCH 323/336] Change LICENSE to GPLv3 --- LICENSE | 695 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 674 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index ad9b949..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,674 @@ -MIT License - -Copyright (c) 2021 2LStudios - Minecraft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From dc1626c3d3e0eb0cb3bdca9c835f43103a2d99ef Mon Sep 17 00:00:00 2001 From: QuanTrieuPCYT Date: Sat, 11 Feb 2023 11:28:59 +0700 Subject: [PATCH 324/336] ! --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 387d394..c57d668 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .settings .factorypath .classpath -/target \ No newline at end of file +/target +pom.xml From 157ddc757699142776129c1fdaf516360b080a9d Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 14 Feb 2023 18:57:35 -0300 Subject: [PATCH 325/336] 2.1.0 From b33773203a45a981e414ef05f13614db2e4801bb Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Tue, 14 Feb 2023 19:14:37 -0300 Subject: [PATCH 326/336] space pom.xml ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c57d668..96a13c7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .factorypath .classpath /target + pom.xml From 19b3c65f86f4f248ae73e28ad1d8e47ccc7c63d0 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 15 Feb 2023 13:24:14 -0300 Subject: [PATCH 327/336] Fix minecart & shulkers false positives --- src/main/resources/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4290185..27286ba 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -62,7 +62,7 @@ packets: vls: 100 # Maximum amount of bytes allowed per packet. (Set to -1 to disable) - max_size: 8192 + max_size: 12288 # Maximum amount of bytes allowed per book page. (Set to -1 to disable) max_size_book: 300 @@ -127,7 +127,8 @@ packets: PacketPlayInCustomPayload: 0.01 PacketPlayInEntityAction: 0.5 PacketPlayInFlying: 0.25 - PacketPlayInLook: 0.5 + PacketPlayInLook: 0.4 + PacketPlayInSteerVehicle: 0.05 PacketPlayInPositionLook: 0.05 PacketPlayInPosition: 0.2 PacketPlayInSetCreativeSlot: 0.15 @@ -135,7 +136,7 @@ packets: PacketPlayInTabComplete: 0.75 PacketPlayInUseEntity: 0.5 PacketPlayInUseItem: 0.1 - PacketPlayInWindowClick: 0.65 + PacketPlayInWindowClick: 0.45 # These packets will be completely cancelled. blacklist: From f97167aa2081b08c265bf54b8441f46ef3f565be Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 15 Feb 2023 13:25:07 -0300 Subject: [PATCH 328/336] Fix kick messages not showing --- .../dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index 80135be..fa0d16e 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -112,7 +112,6 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa String kickMessage = messagesModule.getKickMessage(module, locale); hamsterPlayer.disconnect(kickMessage); - hamsterPlayer.closeChannel(); } else if (punishment.equals("notification")) { String moduleName = module.getName(); From 05d7d29e3d60749068b5caab103e186df72f3743 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Wed, 15 Feb 2023 13:26:05 -0300 Subject: [PATCH 329/336] 2.1.1 From 50e03322fcdaedf36453c65a8ea906ce07c5089f Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 16 Feb 2023 19:00:37 -0300 Subject: [PATCH 330/336] Fix inventory duplication exploit --- .../listener/BlockBreakListener.java | 30 +++++++++++++++++++ .../listener/ListenerInitializer.java | 1 + .../exploitfixer/modules/EventsModule.java | 6 ++++ src/main/resources/config.yml | 5 +++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/_2lstudios/exploitfixer/listener/BlockBreakListener.java diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockBreakListener.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockBreakListener.java new file mode 100644 index 0000000..3e57cca --- /dev/null +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/BlockBreakListener.java @@ -0,0 +1,30 @@ +package dev._2lstudios.exploitfixer.listener; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; + +import dev._2lstudios.exploitfixer.managers.ModuleManager; +import dev._2lstudios.exploitfixer.modules.EventsModule; + +public class BlockBreakListener implements Listener { + private EventsModule eventsModule; + + BlockBreakListener(ModuleManager moduleManager) { + this.eventsModule = moduleManager.getEventsModule(); + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onBlockBreak(BlockBreakEvent event) { + // Check if enabled + if (eventsModule.isInventoryExploit()) { + // Get the player + Player player = event.getPlayer(); + + // Close the inventory + player.closeInventory(); + } + } +} diff --git a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java index 04392b4..aacbc82 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/listener/ListenerInitializer.java @@ -31,6 +31,7 @@ public void register() { pluginManager.registerEvents(new BlockDispenseListener(moduleManager), plugin); } + pluginManager.registerEvents(new BlockBreakListener(moduleManager), plugin); pluginManager.registerEvents(new EntityDamageByEntityListener(moduleManager), plugin); pluginManager.registerEvents(new MapInitializeListener(moduleManager), plugin); pluginManager.registerEvents(new PacketDecodeListener(exploitUtil, moduleManager), plugin); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java index 22a77e1..877c593 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -9,6 +9,7 @@ public class EventsModule implements IModule { private boolean enderPortalBreak; private boolean dispenserCrash; private boolean portalCrash; + private boolean inventoryExploit; public void reload(IConfiguration configYml) { String name = getName().toLowerCase(); @@ -19,6 +20,7 @@ public void reload(IConfiguration configYml) { enderPortalBreak = configYml.getBoolean(name + ".ender_portal_break", true); dispenserCrash = configYml.getBoolean(name + ".dispenser_crash", true); portalCrash = configYml.getBoolean(name + ".portal_crash", true); + portalCrash = configYml.getBoolean(name + ".inventory_exploit", true); } @Override @@ -54,4 +56,8 @@ public boolean isDispenserCrash() { public boolean isPortalCrash() { return portalCrash; } + + public boolean isInventoryExploit() { + return inventoryExploit; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 27286ba..313d87a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,9 +40,12 @@ events: # Prevents crashing when using dispensers that drop items out of the bounds. dispenser_crash: true - # Prevents portal teleport spam crash + # Prevents portal teleport spam crash. portal_crash: true + # Prevents duplicating items with certain inventory plugins. + inventory_exploit: true + # Prevents the use of invalid packets to crash the server. packets: enabled: true From d3f466bfe44c9f7248ac1e926d4fb4a6646ae7c6 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:00:26 -0300 Subject: [PATCH 331/336] Fixed inventoryExploit config --- .../java/dev/_2lstudios/exploitfixer/modules/EventsModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java index 877c593..d7a4da1 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/modules/EventsModule.java @@ -20,7 +20,7 @@ public void reload(IConfiguration configYml) { enderPortalBreak = configYml.getBoolean(name + ".ender_portal_break", true); dispenserCrash = configYml.getBoolean(name + ".dispenser_crash", true); portalCrash = configYml.getBoolean(name + ".portal_crash", true); - portalCrash = configYml.getBoolean(name + ".inventory_exploit", true); + inventoryExploit = configYml.getBoolean(name + ".inventory_exploit", true); } @Override From fd85693c6a1b3a20c2ec66974704b22554ea77f7 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 20 Feb 2023 15:30:20 -0300 Subject: [PATCH 332/336] Fix incorrect punishment count --- .../_2lstudios/exploitfixer/commands/StatsCommand.java | 2 +- .../exploitfixer/exploit/BukkitExploitPlayer.java | 9 ++++++--- .../exploitfixer/managers/ExploitPlayerManager.java | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java b/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java index 0c0935e..2d6c3a9 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/commands/StatsCommand.java @@ -22,7 +22,7 @@ public StatsCommand(ExploitPlayerManager exploitPlayerManager, MessagesModule me public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender.hasPermission("exploitfixer.admin")) { sender.sendMessage(messagesModule.getStats(lang) - .replace("%players_punished%", String.valueOf(exploitPlayerManager.getPunishments())) + .replace("%players_punished%", String.valueOf(exploitPlayerManager.getKicked())) .replace("%players_cached%", String.valueOf(exploitPlayerManager.getSize()))); } else { sender.sendMessage(messagesModule.getPermission(lang)); diff --git a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java index fa0d16e..60bd953 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/exploit/BukkitExploitPlayer.java @@ -112,6 +112,9 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa String kickMessage = messagesModule.getKickMessage(module, locale); hamsterPlayer.disconnect(kickMessage); + + // When kicked, count as punishment + exploitPlayerManager.addKicked(); } else if (punishment.equals("notification")) { String moduleName = module.getName(); @@ -142,10 +145,10 @@ public void punish(IModule module, HamsterPlayer hamsterPlayer, PacketWrapper pa }); } } + + // Add this punishment as already done to not execute twice + punishmentsDone.add(punishments); } - - punishmentsDone.add(punishments); - exploitPlayerManager.addPunishment(); } } diff --git a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java index aaf002d..02021b0 100644 --- a/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java +++ b/src/main/java/dev/_2lstudios/exploitfixer/managers/ExploitPlayerManager.java @@ -15,7 +15,7 @@ public class ExploitPlayerManager { private Server server; private ModuleManager moduleManager; private Map exploitPlayers = new HashMap<>(); - private int punishments = 0; + private int kicked = 0; ExploitPlayerManager(Plugin plugin, Server server, ModuleManager moduleManager) { this.plugin = plugin; @@ -60,11 +60,11 @@ public int getSize() { return exploitPlayers.size(); } - public int getPunishments() { - return punishments; + public int getKicked() { + return kicked; } - public int addPunishment() { - return punishments++; + public int addKicked() { + return kicked++; } } From 8eb6f511050f46c219f6695ce4f6020f52616ad5 Mon Sep 17 00:00:00 2001 From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:05:51 -0300 Subject: [PATCH 333/336] Better info about offline packet block --- src/main/resources/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 313d87a..303fdfa 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -43,7 +43,7 @@ events: # Prevents portal teleport spam crash. portal_crash: true - # Prevents duplicating items with certain inventory plugins. + # Prevents duplicating items with some inventory plugins. inventory_exploit: true # Prevents the use of invalid packets to crash the server. @@ -57,6 +57,7 @@ packets: reduce_vls: 25 # Cancels packets if the player sending them is offline. + # This prevents duplication with auction house plugins. offline: true # This will check if integers, floats, doubles and items have an invalid size in packets. From 4c09ea2ba856696bccdb1c6c9d70ba16116566af Mon Sep 17 00:00:00 2001 From: Lucia Nishimiya Date: Tue, 21 Feb 2023 23:50:13 -0300 Subject: [PATCH 334/336] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 34ca2c3..15d07e3 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,20 @@ -# ExploitFixer +# AkarinFixerExploit -ExploitFixer is a high performance packet filter that prevents many kinds of crashers, laggers and exploits from being used in your Spigot/Paper server. +AkarinFixerExploit is a high performance packet filter that prevents many kinds of crashers, laggers and exploits from being used in your Spigot/Paper server. You can download the prebuilt jar binaries in the link below. ## Links - +discord +https://discord.gg/PeS8h8eJZJ + +download +https://github.com/LuciaNishimiya/AkarinFixerExploits/releases ## How To (Server Admins) -Download a copy of ExploitFixer. [MC-Market](https://builtbybit.com/resources/26463/) +Download a copy of ExploitFixer. https://github.com/LuciaNishimiya/AkarinFixerExploits/releases Install in your Spigot/Paper plugins folder. From 0aa33670197671af77b1942b7fc23f5612654a99 Mon Sep 17 00:00:00 2001 From: Lucia Nishimiya Date: Tue, 21 Feb 2023 23:54:55 -0300 Subject: [PATCH 335/336] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 15d07e3..2b1b4a1 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,13 @@ https://github.com/LuciaNishimiya/AkarinFixerExploits/releases ## How To (Server Admins) Download a copy of ExploitFixer. https://github.com/LuciaNishimiya/AkarinFixerExploits/releases - Install in your Spigot/Paper plugins folder. +This plugin requires HamsterAPI installed in your Spigot/paper servers. This is a custom High Performance packet listener. +https://www.spigotmc.org/resources/2ls-hamsterapi.78831/updates + + + ## How To (Compiling From Source) To compile ExploitFixer, you need [JDK8](https://adoptopenjdk.net/releases.html), [maven](https://maven.apache.org/download.cgi), and an internet connection. From e2903f5250f5731b0427f8e0895e0c9c3312927a Mon Sep 17 00:00:00 2001 From: Lucia Nishimiya Date: Wed, 22 Feb 2023 00:02:24 -0300 Subject: [PATCH 336/336] Add files via upload --- pom.xml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4287a29 --- /dev/null +++ b/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + + dev._2lstudios + ExploitFixer + jar + + ExploitFixer + Advanced anti-exploit security plugin for Spigot servers. + 2.0.8 + https://www.spigotmc.org/resources/62842/ + + + 2LS + UTF-8 + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + 2lstudios + https://ci.2lstudios.dev/plugin/repository/everything/ + + + jitpack.io + https://jitpack.io + + + + + + org.spigotmc + spigot-api + 1.19-R0.1-SNAPSHOT + provided + + + com.github.2lstudios-mc + HamsterAPI + e3215bcc5a + + + + + ${artifactId} + src/main/java + clean install + + + src/main/resources + true + + plugin.yml + bungee.yml + + + + src/main/resources + + plugin.yml + bungee.yml + + + + + + + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + +