Zrips / CMI

115 stars 97 forks source link

Error with /scavenge #8884

Closed tomhmagic closed 3 months ago

tomhmagic commented 3 months ago

Description of Issue

Console errors when using /scavenge

when an item has enchanted and the error happens, the books remain in the GUI when the error happens the item is removed but no fail message sent

Steps to reproduce: Get diamond swords (enchant if you want to test the book issue) do /scavenge and scavenge a couple of times until error shows

image

image of failed enchanted scavenge

Version Information

[Mon 19:59:06 INFO ] --------------------------------------------------
  [Mon 19:59:06 INFO ] CMI: 9.7.4.2 Velocity CMIB  MySQL-> 9.7.4.1
  [Mon 19:59:06 INFO ] CMILib: 1.5.0.4 
  [Mon 19:59:06 INFO ] Server: Paper(2233) 1.20.6-R0.1-SNAPSHOT-
  [Mon 19:59:06 INFO ] CMI economy: Enabled Vault: 1.7.3-CMI CMI Chat: Disabled 
  [Mon 19:59:06 INFO ] Modules -> 60 enabled 6 disabled: flightCharge, chatBubble, tablist, votifier, headDrop, jail
  [Mon 19:59:06 INFO ] --------------------------------------------------

Errors

- [Mon 19:51:24 ERROR Minecraft] Could not pass event InventoryClickEvent to CMILib v1.5.0.4
java.lang.IllegalArgumentException: Damage cannot be negative
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
    at org.bukkit.craftbukkit.inventory.CraftMetaItem.setDamage(CraftMetaItem.java:1547)
    at org.bukkit.inventory.ItemStack.setDurability(ItemStack.java:270)
    at CMI-9.7.4.2.jar//com.Zrips.CMI.Modules.Scavenger.ScavengeManager$3.click(ScavengeManager.java:388)
    at CMILib1.5.0.4.jar//net.Zrips.CMILib.GUI.GUIManager.processClick(GUIManager.java:275)
    at CMILib1.5.0.4.jar//net.Zrips.CMILib.GUI.GUIListener.onInventoryClick(GUIListener.java:214)
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor292.execute(Unknown Source)
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77)
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
    at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54)
    at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628)
    at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3260)
    at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:69)
    at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:33)
    at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:55)
    at net.minecraft.server.TickTask.run(TickTask.java:18)
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151)
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEven

Relevant Config Sections

Scavenge:
  ItemBreak:
    # Defined percentage for item to break when salvaging it
    # Value can be from 0 to 100, where 100 means that each time player extract enchant, item breaks
    # This can allow player to extract enchantments without breaking item itself
    # Set it to 100 if you want to always break item
    # Keep in mind that broken item will go throw ingredient return process
    # Attention! Items without enchants will have 100% break chance
    Base: 10.0
    # Adds extra chance to break item depending on how many enchants item has
    # In example having base chance of 8% and having this set to 2 while having item with 3 enchants will result into 8+(2*3)=14% chance to break item
    ForEachEnchant: 5.0
    # Adds extra chance to break item depending on enchant level
    # This will take into consideration enchantment max and current levels
    # Having this set to 7.5 means, that enchantment at max level will have 7.5% extra chance to to break item
    # But if you have sharpness 2 which has max level of 5, then only 3% fail chance will be added
    ForEachEnchantLevel: 5.0
    # Defines in percentage a max chance to break item when extracting enchants
    # This can limit chance to particular one in case it gets to 100% and it would always break
    MaxBreakChance: 100.0
    # Value between 0 and 100 which defines extra fail chance when items doesnt have max durability
    # Having this set to 50 will mean that item at 1 left durability will have fail chance increase by 50%
    # Items which are not damaged will not experience any fail chance increase
    BreakDurabilityCheck: 50.0
    # When set to true, items durability will be taken into consideration when extracting ingredients
    # In example if item has 100 max durability and current is at 50, then only half of ingredients will be considered for extraction
    # This doesnt mean that player gets 50% of them, it only means that half of possible ingredients will go throw IngredientReturn process
    DurabilityCheck: true
    IngredientReturn:
      # Defines in percentage a max chance to return ingredients of item if it fails extraction process
      # This will apply for each ingredient that item has
      # Recipe to make that item should exist in database, or it will not return any ingredients
      Base: 25.0
  EnchantExtractionFail:
    # Adds base chance to fail enchantment extraction
    # When enchantment fails, player will not get enchant book with appropriate enchantment
    Base: 20.0
    # Adds extra chance to fail enchantment extraction depending on enchantment level
    # This will take into consideration enchantment max and current levels
    # Having this set to 75 means, that enchantment at max level will have 75% chance to fail extraction process
    # But if you have sharpness 2 which has max level of 5, then only 30% chance to fail will get applied
    # While enchants like Aquaaffinity will always have max fail chance as you can only have it at level 1
    ForEachLevel: 10.0
    # Defines in percentage a max chance to fail enchantment extraction
    # This can limit chance to particular one in case it gets to 100% and it would always fail
    MaxFailChance: 75.0
    LevelLower:
      # Defines a chance lowering enchant level if it fails extraction
      # This is secondary step when extraction fails and will only apply when it does
      # If Enchant is at level 1 already, then player will not get enchanted book at all
      # If you want to avoid lowering level of enchant when it fails extraction, set this to 100
      # If you want to always lower level down when extracting enchantments, then set EnchantExtractionFail.Base to 100 and set this to 100
      Base: 50.0
      # Will adjust level lowering chance depending on enchant level to defined max amount at max level
      # This will mean that higher levels will have higher chance to be lowered
      ForEachLevel: 5.0
      # Will adjust level lower chance depending on enchant level to defined max amount at max level
      MaxChance: 75.0
  Cost:
    # Defined base cost of extraction. Set to 0 if you want to make it free
    Base: 100.0
    # Extra cost which depends on enchantment worth which can be defined with /cmi setenchantworth 
    # This value is in percentage from worth value of that each enchantment and item
    # So if you have base cost of 100, extra cost of 5% and you are trying to extract sharpness 5 which worth is 1000 and item sell hand worth is 100, then you will have to pay 155 for extraction process
    Extra: 5.0
  # List of materials to block from being scavenged
  BlackList:
  - air
  # When set to true, balck list becomes whitelist and will allow scavanging of items defined in a blacklist only
  BlackToWhiteList: false
  # When set to false while player have open scavange UI they will not be able to pickup item from ground
  AllowItemPickups: false
  # When enabled items, likes swords, after being salvagted if they dint broke then their repair cost will be reset so players can enchant it as like its a new one instead of making it to dificult to be enchanted
  ResetRepairCost: true

Relevant Plugins

CMILib: 1.5.0.4

Agreements

Zrips commented 3 months ago

Should be fixed with next update