GithubHelp home page GithubHelp logo

zerobzerot / antiillegals Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 8.0 517 KB

A spigot plugin for Minecraft servers. Restricts certain block placements and removes illegals from player inventories.

Home Page: https://www.curseforge.com/minecraft/bukkit-plugins/antiillegals

License: MIT License

Java 100.00%
minecraft bukkit anarchy spigot illegal blocks bedrock prevention place restriction

antiillegals's People

Contributors

bierdosenhalter avatar colesium avatar crxyne avatar dependabot[bot] avatar nothub avatar pr3roxdlc avatar soostrator1136 avatar syni0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

antiillegals's Issues

Fix incompatible enchantments

If the target does not have the enchantment, it gains all levels of that enchantment, unless it already has an incompatible enchantment. Enchantments are incompatible if both are in one of the following groups:

  • Sword: Sharpness, Smite, and Bane of Arthropods
  • Tool: Fortune and Silk Touch (as of Java version 1.12.2 you can combine these; the sacrifice item's enchantment is lost)
  • Armor: Protection, Fire Protection, Blast Protection, Projectile Protection
  • Boots: Depth Strider and Frost Walker
  • Bow: Infinity and Mending
  • Crossbow: Multishot and Piercing
  • Trident: Loyalty and Riptide or Channeling and Riptide
  • Books: Silk Touch and Looting or Silk Touch and Luck of the Sea (and all of the above).

Randomly select one enchmantment that remains on the item?

split different parts of anti illegal item checks into separate methods

completely unrelated anti illegal checks should probably be in different methods. this is especially important with the oversized books check, because that is the only part of the itemstack checking method that requires the location parameter. making a method for illegal items separate from a method for books would allow reverting illegal items at other places without needing to check for books at the same time.

add helper methods for checkItemStack

any time checkItemStack is used in Events, it checks if the ItemState returned by the method is ItemState.illegal. this creates a bypass for things like overstacked items when they are picked up from the ground, because in order to fully revert the item, the event needs to be cancelled. because reverting overstacked items only results in ItemState.wasFixed, this is not handled correctly (as well as in other places)

Config for Handling Shulker + Books

By default this plugin kicks all books out of a shulker if there are > 5 books, no matter how big or small they are. It would be nice if we could opt-in to that behavior, or if there was a byte check for book size to prevent book bans.

Limiting shulkers to just 5 books is difficult for book collectors and I am still testing but it seems that m moving shulkers in e-chests can result in deleted books.

Could not pass event InventoryOpenEvent to AntiIllegals v1.0.41

Could not pass event InventoryOpenEvent to AntiIllegals v1.0.41
org.bukkit.event.EventException: null
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callInventoryOpenEvent(CraftEventFactory.java:825) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.EntityPlayer.openContainer(EntityPlayer.java:858) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.BlockChest.interact(BlockChest.java:308) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:550) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1025) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_352]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_352]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:851) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:427) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:775) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_352]
Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
        at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:444) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        at org.zeroBzeroT.antiillegals.AntiIllegals.checkItemStack(AntiIllegals.java:309) ~[?:?]
        at org.zeroBzeroT.antiillegals.AntiIllegals.checkInventory(AntiIllegals.java:114) ~[?:?]
        at org.zeroBzeroT.antiillegals.AntiIllegals.checkItemStack(AntiIllegals.java:322) ~[?:?]
        at org.zeroBzeroT.antiillegals.AntiIllegals.checkInventory(AntiIllegals.java:114) ~[?:?]
        at org.zeroBzeroT.antiillegals.AntiIllegals.checkInventory(AntiIllegals.java:94) ~[?:?]
        at org.zeroBzeroT.antiillegals.Events.onInventoryOpen(Events.java:210) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor3.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Dionysus-"42ce9ca"]
        ... 19 more

add @NotNull and @Nullable annotations

in a lot of places it gets extremely confusing whether the variable you're working with can be null or not. adding annotations like these would remove a lot of mental workload trying to figure out if something can ever be null

use more local variables in Events

there is a lot of copypasted, reused expressions that can easily be stored in local variables. not using them just makes every line impossible to grasp, some lines even go beyond the usual screen width

Add a check for Unbreakables

The code we had for unbreakables deleted some items like beds:

        if (itemStack.getType().isItem() && !itemStack.getType().isEdible() && !itemStack.getType().isBlock()) {
            if (itemStack.getDurability() > itemStack.getType().getMaxDurability() || itemStack.getDurability() < 0 || itemStack.getItemMeta().isUnbreakable()) {
                itemStack.setDurability((short) 0);
                itemStack.getItemMeta().setUnbreakable(false);
                itemStack.setAmount(0);
            }
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.