PacketBookFixer 1.03

Prevent damage to the server by posting too many book packages!

  1. BlondeCow
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    PACKETBOOKFIXER

    The modified book package is an add-on that prevents the malicious behavior of block packages.

    INFO
    • Client will discard the players on the server shortly after creating a lag on the server, not to remove any harmful packets sent by the sender.
    • Plugin prevents harmful packets and block packets sent to the server.
    COMPATIBILITY
    • PacketBookFixer uses ProtocolLib
    • Spigot forks such as PaperSpigot are also compatible.
    • Your server must be running Java 8 or later
    CLIENT




    Code (Java):
    package me.packetbookfixer;

    import java.io.IOException;
    import java.util.concurrent.TimeUnit;
    import java.util.logging.Level;

    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;

    import com.comphenix.protocol.PacketType;
    import com.comphenix.protocol.ProtocolLibrary;
    import com.comphenix.protocol.events.ListenerPriority;
    import com.comphenix.protocol.events.PacketAdapter;
    import com.comphenix.protocol.events.PacketEvent;
    import com.comphenix.protocol.wrappers.nbt.NbtCompound;
    import com.comphenix.protocol.wrappers.nbt.NbtFactory;
    import com.comphenix.protocol.wrappers.nbt.NbtList;
    import com.google.common.cache.Cache;
    import com.google.common.cache.CacheBuilder;

    import me.packetbookfixer.utils.Util;


    public class PacketBookFixer extends JavaPlugin {
     
        public static PacketBookFixer instance;
        private Cache<String, Integer> ignore = CacheBuilder.newBuilder().concurrencyLevel(2).initialCapacity(20).expireAfterWrite(550, TimeUnit.MILLISECONDS).build();
        @Override
        public void onEnable() {
            if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null)
            {
                Bukkit.getLogger().info("§4 ProtocolLib §cbulunamadı.");
              return;
            }
            ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.LOWEST, PacketType.Play.Client.BLOCK_PLACE) {
                public void onPacketReceiving(final PacketEvent event) {
                    if (event.getPlayer() == null) {
                        event.setCancelled(true);
                        return;
                    }
                    Integer attemps = ignore.getIfPresent(event.getPlayer().getName().toLowerCase());
                    if (attemps != null && attemps >= 2) {
                        if (attemps >= 100) {
                            plugin.getLogger().log(Level.INFO, "§6Crash §cistemcisi tespit edildi.", event.getPlayer().getName());
                            Util.forceKick(event.getPlayer());
                        } else {
                            Util.kickPlayer(event.getPlayer(), null);
                        }
                        event.setCancelled(true);
                        return;
                    }
                 
                    ItemStack stack = event.getPacket().getItemModifier().readSafely(0);
                    if (stack == null || stack.getType() != Material.WRITTEN_BOOK) {
                        return;
                    }

                    ItemStack inHand = event.getPlayer().getItemInHand();
                    if (inHand == null || inHand.getType() != Material.WRITTEN_BOOK) {
                        event.setCancelled(true);
                        Util.forceKick(event.getPlayer());
                        plugin.getLogger().log(Level.INFO, "§6Crash §cistemcisi tespit edildi.", event.getPlayer().getName());
                        return;
                    }
                    try {
                        checkNbtTags(stack);
                    } catch (IOException e) {
                        event.setCancelled(true);
                        Util.forceKick(event.getPlayer());
                        plugin.getLogger().log(Level.INFO, "§6Crash §cistemcisi tespit edildi.", event.getPlayer().getName());
                        return;
                    }
                    ignore.put(event.getPlayer().getName().toLowerCase(), attemps == null ? 0 : attemps + 1);
                }
             
            });
            Bukkit.getLogger().info("PacketBookFixer Aktif !");
            Bukkit.getLogger().info("§4Discord : §cBlondeCow#5145 - #Turkiye1760");
        }

         private void checkNbtTags(ItemStack itemStack) throws IOException {
            NbtCompound root = (NbtCompound) NbtFactory.fromItemTag(itemStack);
            if (root == null) {
                throw new IOException("NBT etiketi yok");
            } else if (!root.containsKey("pages")) {
                throw new IOException("NBT bileşik bulunamadı");
            } else {
                NbtList<String> pages = root.getList("pages");
                if (pages.size() > 50) {
                    throw new IOException("Çok fazla sayfa");
                }
                for (String page : pages) {
                    if (page.length() > 320) {
                        throw new IOException("Çok uzun bir sayfa");
                    }
                }
            }
        }
        public static PacketBookFixer getPlugin() {
            return PacketBookFixer.instance;
        }
            @Override
            public void onDisable() {
                Bukkit.getLogger().info("PacketBookFixer devredışı !");
                ProtocolLibrary.getProtocolManager().removePacketListeners(this);
                ignore.invalidateAll();
                ignore = null;
            }
        }

Recent Updates

  1. Config added
  2. Contact information
  3. Brief information

Recent Reviews

  1. _Obliviate_
    _Obliviate_
    5/5,
    Version: 1.03
    Perfect, thanks! (and i m sorry for my badwords..) .
  2. FireToggle
    FireToggle
    5/5,
    Version: 1.03
    Good, but. The plugin don’t supports aternos.org servers. My server crashes in 3-4 minutes, please FIX it, because I can't find another plugin who don't kick the players, he lost them connection at the moment when the player start sending packages to the server, other plugins are slower.
    Thanks !
    1. BlondeCow
      Author's Response
      Minecraft 1.8.8 spigot and ProtocolLib will work correctly with.
  3. canayaz
    canayaz
    5/5,
    Version: 1.03
    80 karakter bir yorum için fazla değil mi yahu nasıl dolduralım burayı :D ......
  4. over_brave
    over_brave
    4/5,
    Version: 1.03
    1.13'dede aynı sıkıntı var mıdır ? Sonuçta yeni bir sürüm ve bundada böyle bir açık olması saçma geliyor.
  5. Salim159
    Salim159
    5/5,
    Version: 1.02
    Türk bozar türk fixler kardeş.................................................................
  6. Ufuk58
    Ufuk58
    5/5,
    Version: 1.0
    New method new fix. Tested and approved. Working correctly. Thanks for PacketBookFixer.