garbagemule / MobArena

MobArena plugin for Minecraft
GNU General Public License v3.0
196 stars 150 forks source link

Crossbows dont get the unbreakable flag #544

Closed Aaron2550 closed 5 years ago

Aaron2550 commented 5 years ago

Bug report

Short description

crossbows arent unbreakable like every other item, they break

Reproduction steps

  1. add a crossbow to a class
  2. play with said class
  3. crossbow breaks after a while

Details

Aaron2550 commented 5 years ago

tridents also have this issue

garbagemule commented 5 years ago

Thanks for the bug report!

This sounds pretty plausible, since the way we check if an item should be made unbreakable is by checking if it is an armor type or a weapon type. Crossbows and tridents are new weapons, so they haven't been added to the respective lists.

Unfortunately, crossbows are 1.14 weapons and tridents are 1.13 weapons. This means that if we want to actually fix this problem, we'll have to either leave out crossbows and stay compatible with 1.13, or we'll have to drop support for 1.13 and include crossbows. According to bStats, only about 20% of MobArena servers run 1.14, and a much larger ~43% are sitting on 1.13 still. So dropping support for 1.13 doesn't seem right (yet), but that means we can't solve the crossbow-specific issue this way.

Isn't this problem solved entirely by just using the unbreakable enchantment? Couldn't we solve this problem by not solving it and removing support for the two nodes? They were introduced before the unbreaking enchantment existed (that's how old that feature is!), but are they even necessary anymore?

Aaron2550 commented 5 years ago

youre right, it is solved by giving the unbreaking enchantment. You could also fix it once and for all by giving every item the unbreakable flag, then it would be compatible with all new armors and weapons. (im not sure if that would cause some problems tho)

Nesseley commented 5 years ago

Could make a setting "Enable crossbows: true/false" and "enable trident: true/false" work?

garbagemule commented 5 years ago

I have no clue what adding unbreakable to e.g. a dirt block would do. Or a torch. Maybe something blows up in Minecraft/Spigot. Is that something you could investigate?

Config file settings won't help because the problem exists at compile time.

If the issue is moot with the unbreaking enchantment, then the obvious follow-up issue becomes that of user experience: having to put unbreaking on all items manually in the config file is probably not anyone's definition of fun.

Aaron2550 commented 5 years ago

Is that something you could investigate?

im having router problems and cannot access my server for testing, sorry

a-l-e-x-0-6 commented 5 years ago

you could use getMaxDurability() and check if the item has a max durability above 0, if i remember correctly, blocks and non-tool/armor items always have a max durability of 0, regardless of block data

garbagemule commented 5 years ago

@a-l-e-x-0-6 interesting. Would you be up for programmatically iterating the Material enum, creating an ItemStack for each value, checking if its max durability is greater than 0, then printing the Material enum value if it is? Then we'd have the entire set of values, and we can check if anything is missing, or if there are too many values.

a-l-e-x-0-6 commented 5 years ago

@garbagemule ok, i did that for 1.13.2 only (i don't have time to compile the 1.14 jar to test for 1.14) and it looks like everything is there. BOW CARROT_ON_A_STICK CHAINMAIL_BOOTS CHAINMAIL_CHESTPLATE CHAINMAIL_HELMET CHAINMAIL_LEGGINGS DIAMOND_AXE DIAMOND_BOOTS DIAMOND_CHESTPLATE DIAMOND_HELMET DIAMOND_HOE DIAMOND_LEGGINGS DIAMOND_PICKAXE DIAMOND_SHOVEL DIAMOND_SWORD ELYTRA FISHING_ROD FLINT_AND_STEEL GOLDEN_AXE GOLDEN_BOOTS GOLDEN_CHESTPLATE GOLDEN_HELMET GOLDEN_HOE GOLDEN_LEGGINGS GOLDEN_PICKAXE GOLDEN_SHOVEL GOLDEN_SWORD IRON_AXE IRON_BOOTS IRON_CHESTPLATE IRON_HELMET IRON_HOE IRON_LEGGINGS IRON_PICKAXE IRON_SHOVEL IRON_SWORD LEATHER_BOOTS LEATHER_CHESTPLATE LEATHER_HELMET LEATHER_LEGGINGS SHEARS SHIELD STONE_AXE STONE_HOE STONE_PICKAXE STONE_SHOVEL STONE_SWORD TRIDENT TURTLE_HELMET WOODEN_AXE WOODEN_HOE WOODEN_PICKAXE WOODEN_SHOVEL WOODEN_SWORD maybe FLINT_AND_STEEL is extra.

between there is no need to create a new ItemStack, getMaxDurability() can be used for Material. for (Material material : Material.values()) { if(material.getMaxDurability() > 0) { System.out.print(material); } }