PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
52 stars 21 forks source link

Items Adder API broken with latest Items Adder version. #1781

Closed LukeAppGuy closed 2 years ago

LukeAppGuy commented 2 years ago

Terms

Discord tag (optional)

Holmes#6657

What happened?

I use the Items Adder Java API with a few of my custom written plugins, updating items adder to the latest version on my test server along with the version number in my pom.xml has caused my plugin to fail entirely. I get the following error in the console:

java.lang.ClassCastException: class dev.lone.itemsadder.main.cb cannot be cast to class dev.lone.itemsadder.main.bZ (dev.lone.itemsadder.main.cb and dev.lone.itemsadder.main.bZ are in unnamed module of loader 'ItemsAdder_3.2.0b-beta4.jar' @6e0b2ae3)

I opened a community-help ticket and someone tried to help me resolve the issue although none of their suggestions worked to fix my problem. This seems like a pretty huge issue since it means anyone using the API in their plugin will no longer work.

Steps to reproduce the issue

Use the items adder API with a custom spigot plugin, using any of the API at all gives the error I have posted in this bug report. My dependency in my pom.xml looks like this:

<dependency>
            <groupId>com.github.LoneDev6</groupId>
            <artifactId>api-itemsadder</artifactId>
            <version>3.1.6</version>
            <scope>provided</scope>
</dependency>

I was using 3.0.0 with my plugins for a while but once I updated the API no longer works.

Server version

Current: git-Purpur-1561 (MC: 1.18.1)*

ItemsAdder Version

ItemsAdder version 3.2.0b-beta4

ProtocolLib Version

ProtocolLib version 4.8.0

LoneLibs Version

LoneLibs version 1.0.19

LightAPI Version (optional)

No response

LibsDisguises Version (optional)

No response

FULL server log

latest.log

Error (optional)

18.06 17:53:17 [Server] ERROR Could not pass event PlayerInteractEvent to TavernFarming v1.0.0
18.06 17:53:17 [Server] INFO java.lang.ClassCastException: class dev.lone.itemsadder.main.cv cannot be cast to class dev.lone.itemsadder.main.bZ (dev.lone.itemsadder.main.cv and dev.lone.itemsadder.main.bZ are in unnamed module of loader 'ItemsAdder_3.2.0b-beta4 (1).jar' @4811c2c5)
18.06 17:53:17 [Server] INFO at dev.lone.itemsadder.api.CustomBlock.getOriginal(SourceFile:44) ~[ItemsAdder_3.2.0b-beta4 (1).jar:?]
18.06 17:53:17 [Server] INFO at dev.lone.itemsadder.api.CustomBlock.getInstance(SourceFile:55) ~[ItemsAdder_3.2.0b-beta4 (1).jar:?]
18.06 17:53:17 [Server] INFO at tavern.tavernfarming.TavernFarming.placeCrop(TavernFarming.java:256) ~[TavernFarming-1.0-shaded.jar:?]
18.06 17:53:17 [Server] INFO at tavern.tavernfarming.TavernFarming.onRightClick(TavernFarming.java:312) ~[TavernFarming-1.0-shaded.jar:?]
18.06 17:53:17 [Server] INFO at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor83.execute(Unknown Source) ~[?:?]
18.06 17:53:17 [Server] INFO at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
18.06 17:53:17 [Server] INFO at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
18.06 17:53:17 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:631) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
18.06 17:53:17 [Server] INFO at org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:544) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.server.level.ServerPlayerGameMode.useItemOn(ServerPlayerGameMode.java:544) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.server.network.ServerGamePacketListenerImpl.handleUseItemOn(ServerGamePacketListenerImpl.java:1913) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.handle(ServerboundUseItemOnPacket.java:33) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.a(ServerboundUseItemOnPacket.java:9) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.server.TickTask.run(TickTask.java:18) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1441) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1418) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1411) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1490) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1285) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322) ~[purpur-1.18.1.jar:git-Purpur-1561]
18.06 17:53:17 [Server] INFO at java.lang.Thread.run(Thread.java:833) ~[?:?]

ItemsAdder config.yml

metrics: true
update-checker: true
disable-plugin-loading-messages_DONT_ASK_ME_FOR_SUPPORT_IF_YOU_SET_TRUE__THANKS: false
resource-pack:
  hosting:
    no-host:
      enabled: false
    auto-external-host:
      enabled: false
    self-host:
      enabled: true
      server-ip: 51.195.188.128
      pack-port: 7454
    external-host:
      enabled: false
      url: https://www.dropbox.com/s/805itf5syr3uw67/pack.zip?dl=0
      skip-url-file-type-check___DONT_ASK_HELP_IF_SET_TRUE: false
  apply-on-join: true
  kick-player-on-decline: false
  kick-player-on-fail: false
  delay-ticks: 1
  notify-other-plugins-interfering: true
  title:
    enabled: true
  protect-player:
    black-screen: true
    hide-hud: true
    cancel-movement: true
    lock-player: true
  command:
    usage-cooldown-seconds: 60
  custom-font:
    enabled: false
    name: ipaexg.ttf
    shift: '[0,0]'
    size: 11.0
    oversample: 2.0
  thin-font:
    enabled: false
  zip:
    protect-file-from-unzip:
      enabled: true
      extreme: true
    compress-png-files: true
    compress-json-files: true
    overwrite-vanilla-models: false
    overwrite-vanilla-lang-json: false
    generate-custom-armors-textures:
      vanilla_1_17: true
      optifine: false
    disable-overwrite-leather-armor-layers-textures: false
    fix_transparent_noteblocks__disable-for-more-performance: false
    ignore-files-ext:
    - db
    - yml
    - xcf
    - html
  items:
    CustomModelData-starting-value:
      ALL: 10000
      DIAMOND: 11000
config_files:
  lang: en
  dictionaries-lang: en
  extract-default-resources: false
  extract-default-configs: true
  legacy_pack: false
blocks:
  light-api: true
  fix-liquids-flow: true
  fix-floating-blocks: false
  fix-glitched-blocks:
    enabled: true
    only-new-chunks: false
    search-also-in-these-biomes:
      enabled: false
      biomes:
      - BEACH
      - BIRCH_FOREST
      - BIRCH_FOREST_HILLS
      - FOREST
      - MOUNTAINS
      - MOUNTAIN_EDGE
      - GRAVELLY_MOUNTAINS
      - PLAINS
      - RIVER
  cancel-break-wrong-tool:
    enabled: true
    send-actionbar: false
  campfire:
    unlit-on-place: true
    allow-any-item: true
  disable-REAL: false
  disable-REAL_TRANSPARENT: false
  disable-REAL_NOTE: false
  disable-REAL_WIRE: false
  disable-FIRE: false
items:
  fix-show-attack-and-damage-as-lore: true
  give_death_location_maps: false
  hide-custom-durability-lore: false
liquids:
  enabled: true
huds:
  enabled: true
mobs:
  disable-MOB-behaviour__DISABLE_AT_YOUR_OWN_RISK: false
font_images:
  chat:
    enabled: true
    doublecheck-permission__disable-for-more-performance: false
    add-hover-suggestion: true
  command:
    enabled: true
    commandblocks: true
    excluded:
    - home
    - sethome
    - tpa
  sign:
    enabled: true
  book:
    enabled: true
  anvil:
    enabled: true
  inventory-title:
    enabled: true
  tab-header-footer:
    enabled: true
  vault-prefix-suffix:
    enabled: true
    update-every-ticks: 1200
  scoreboard-teams:
    enabled: false
    update-every-ticks: 3600
  player-display-name:
    enabled: true
    update-every-ticks: 1200
  replace-in-customitems-name-and-lore: true
effects:
  hide-scoreboard-numbers: false
  text-effects:
    enabled: true
    replace-in-customitems-name-and-lore: true
    chat:
      enabled: true
    sign:
      enabled: true
    book:
      enabled: true
    anvil:
      enabled: true
    tab-header-footer:
      enabled: true
entities:
  max-furniture-vehicles-per-chunk: 100
  allow-removing-old-furnitures_2_3_11: false
  custom-entitites:
    enabled: true
    interval-rendering-packets-ticks: 1
    emotes: false
    optimized-packets: true
recipes:
  hide-vanilla-unrecognized-recipe-errors: true
  fix-packet-too-large-kick: false
  custom-recipes:
    unlock:
      all-on-join: false
      on-pickup:
        any: false
        ingredients: true
  remove-vanilla-recipes:
    enabled: true
    list:
      DIAMOND_SWORD: false
      IRON_INGOT: false
debug:
  items:
    log-files-loading: false
    log-items-loading: false
    log-items-loading-disabled: false
    log-font-images-loading: false
    log-huds-loading: false
    log-attribute-modifiers-loading: false
    log-warnings: false
    log-loots-loading: false
    log-loots-loading-disabled: false
    log-armors-loading: false
  recipes:
    log-recipes-loading: false
    log-recipes-loading-disabled: false
    log-recipes-removed-vanilla: false
    log-fix-packet-too-large: false
    log-recipes-unknown-item: false
  resource-pack:
    log-extract-default-resources: false
    log-not-extract-default-resources-already-exist: false
  blocks:
    log-save: false
    log-save-on-unload: false
    log-mined-unknown-blocks: true
  worlds-populators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-populators: false
    log-loading-no-world: true
    log-generation: false
  trees-populators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-populators: false
    log-loading-no-world: true
    log-generation: false
  surface-decorators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-decorators: false
    log-loading-no-world: true
    log-generation: false
  player-stats:
    log-save: false
  performance:
    loading-ms: true
  huds:
    log-triggers: false
  other:
    log-dictionaries-loading: false
    log-liquids-loading: false
    log-minecraft_lang_overwrite-loading: false
  categories:
    log-total-loaded: true
    log-single-loaded: false
    log-single-loaded-overwrite: false
    log-single-skip: false
    log-icon-failed-load: false
  entities:
    log-files-loading: false
    log-entities-loading: false
    log-entities-loading-disabled: false
  cave-decorators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-decorators: false
    log-loading-no-world: true
    log-generation: false
loots:
  allow-loots-drop-from-spawners-using-silk-touch: false

Problematic items yml configuration file (optional)

No response

Other files, you can drag and drop them here to upload. (optional)

No response

Screenshots/Videos (you can drag and drop files or paste links)

No response

LoneDev6 commented 2 years ago

Let me see your plugin code. tavern.tavernfarming.TavernFarming.placeCrop(TavernFarming.java:256

Are you trying to place an item which is not a seed or which is not a block? Let me also see the item YML configuration.

luke-devs commented 2 years ago

@LoneDev6

The code that is causing that error is this:

public void placeCrop(Player player, Block farmland, String crop){
        player.sendMessage(ChatColor.GREEN + "DEBUG - " + ChatColor.GRAY + "Placed a custom crop seed.");

        //Setup persistent block data namespace keys and block id.
        String blockID = UUID.randomUUID().toString();
        PersistentDataContainer customBlockData = new CustomBlockData(farmland, this);
        NamespacedKey growthStage = new NamespacedKey(this, "growthStage");
        NamespacedKey cropType = new NamespacedKey(this, "crop");
        NamespacedKey id = new NamespacedKey(this, "id");

        //Save block id, crop type and growth stage (usually starts at 1)
        customBlockData.set(growthStage, PersistentDataType.STRING, "1");
        customBlockData.set(cropType, PersistentDataType.STRING, crop);
        customBlockData.set(id, PersistentDataType.STRING, blockID);

        //Place the custom crop block on the farmland that the player interacted with.
        CustomBlock customBlock = CustomBlock.getInstance(crop);
        customBlock.place(farmland.getLocation());

        World w = player.getWorld();
        w.playSound(player.getLocation(), "minecraft:item.crop.plant", SoundCategory.BLOCKS, 1f, 1f);
        player.sendMessage(w.getName());
        cropLocations.getConfig().set("Locations." + blockID + ".world", w.getName());
        cropLocations.getConfig().set("Locations." + blockID + ".age", 0);
        cropLocations.getConfig().set("Locations." + blockID + ".x", customBlock.getBlock().getLocation().getX());
        cropLocations.getConfig().set("Locations." + blockID + ".y", customBlock.getBlock().getLocation().getY());
        cropLocations.getConfig().set("Locations." + blockID + ".z", customBlock.getBlock().getLocation().getZ());
        cropLocations.saveConfig();
    }

Also the line "256" specifically is this:

CustomBlock customBlock = CustomBlock.getInstance(crop);

This is working 100% fine in previous versions, its nothing to do with the item since that hasn't changed either. Its just a an item with an NBT tag, when the user right clicks farmland with that special seed-item it summons a custom Items Adder block at the farmland. As I say it was working fine until I updated so I'm unsure of what could cause this.

LoneDev6 commented 2 years ago

I really doubt it. It seems you're trying to call CustomBlock#getInstance(String namespacedId) on an item instead of a block, this is what the error is reporting. You can use this only if the item is a custom block.

I just tested and it works fine.

CustomBlock customBlock = CustomBlock.getInstance("iasurvival:ruby_block");