Solved New Configuration, need help

Discussion in 'Plugin Development' started by xDjBomber, Feb 25, 2014.

Thread Status:
Not open for further replies.
  1. Code:
    String helmetPath = "Helmet";
    getConfig().addDefault(helmetPath, Material.IRON_HELMET);
     
    ItemStack helmet = this.plugin.getConfig().getItemStack("Helmet");
    p.getInventory().setHelmet(helmet);
    I tryed to make it new, so cause it's not longer numeric (integer) - What to do here? Gives me some Console Errors, and shows in the config:

    Helmet: !!org.bukkit.Material 'IRON_HELMET'
     
  2. Offline

    clienthax

    you could store the material name and then do getMaterial(name)
     

  3. Example how to use the new config? o.o

    I don't know much about the new config system.. :(
     
  4. Offline

    Alshain01

    Your not writing an ItemStack, your writing a Material.

    getConfig().addDefault(helmetPath, new ItemStack(Material.IRON_HELMET));
     

  5. Code:
        Helmet:
          ==: org.bukkit.inventory.ItemStack
          type: IRON_HELMET
    Now it looks like this..

    Code:
    String helmetPath = "Helmet";
    getConfig().addDefault(helmetPath, new ItemStack (Material.IRON_HELMET));

    Try to give the player the helmet like this:

    Code:
    ItemStack helmet = this.plugin.getConfig().getItemStack("Helmet");
    p.getInventory().setHelmet(helmet);
     
  6. Offline

    Alshain01

    @xDjBomberWas there a question in there?

    The only thing I see different is your YAML path. Change to
    Code:java
    1. String helmetPath = "EasyPVP.PVPArmor.Helmet";
     

  7. No, not change (just changed in this thread, YAML Path is correct in the plugin source)

    The question was, how to give him the item? :confused:

    Code:
    ItemStack helmet = this.plugin.getConfig().getItemStack("Helmet");
    I think this isn't works, i have always errors in the console, and the config.yml shows me false informations

    Like this:

    Code:
     
    Helmet:
    ==: org.bukkit.inventory.ItemStack //<--- What is that?
    type: IRON_HELMET
    Console ERRORS:
    Show Spoiler

    2014-02-25 20:26:47 [SEVERE] java.util.zip.ZipException: invalid code lengths set
    2014-02-25 20:26:47 [SEVERE]at java.util.zip.InflaterInputStream.read(Unknown Source)
    2014-02-25 20:26:47 [SEVERE]at java.io.BufferedInputStream.fill(Unknown Source)
    2014-02-25 20:26:47 [SEVERE]at java.io.BufferedInputStream.read(Unknown Source)
    2014-02-25 20:26:47 [SEVERE]at java.io.DataInputStream.readByte(Unknown Source)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.NBTBase.b(SourceFile:93)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.NBTBase.a(SourceFile:89)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.NBTCompressedStreamTools.a(SourceFile:75)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ChunkRegionLoader.loadChunk(ChunkRegionLoader.java:80)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ChunkRegionLoader.a(ChunkRegionLoader.java:45)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ChunkProviderServer.loadChunk(ChunkProviderServer.java:176)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:105)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:84)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.f(MinecraftServer.java:287)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.a(MinecraftServer.java:252)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.DedicatedServer.init(DedicatedServer.java:152)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:393)
    2014-02-25 20:26:47 [SEVERE]at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
     
  8. Offline

    Alshain01

    The config.yml is correct, that's how an ItemStack looks when serialized.

    I don't see anything in the error that would indicate that problem is coming from your plugin.
     
  9. OP

    Okay, works - But:

    Giving me Helmet, chestplate, leggings, boots AND 2 (???) Iron Swords..

    Code:
      if ((e.getAction() == Action.RIGHT_CLICK_BLOCK) && (
      (e.getClickedBlock().getType() == Material.SIGN) || (e.getClickedBlock().getType() == Material.SIGN_POST) || (e.getClickedBlock().getType() == Material.WALL_SIGN))) 
      {
    Think the error comes from here (?)

    PlayerInteractEventErrors:
    Show Spoiler

    Could not pass event PlayerInteractEvent to EasyPVP v1.1
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
    at org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:190)
    at net.minecraft.server.v1_6_R3.PlayerInteractManager.interact(PlayerInteractManager.java:373)
    at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java:630)
    at net.minecraft.server.v1_6_R3.Packet15Place.handle(SourceFile:58)
    at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296)
    at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java:116)
    at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
    at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:30)
    at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:592)
    at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:227)
    at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:488)
    at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:421)
    at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    Caused by: java.lang.IllegalArgumentException: Item cannot be null
    at org.apache.commons.lang.Validate.noNullElements(Validate.java:410)
    at org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory.addItem(CraftInventory.java:268)
    at me.BOMBER.EasyPVP.PlayerListener.OnPlayerInteract(PlayerListener.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
    ... 16 more
     
  10. Offline

    Traks

    What's on line 74 of PlayerListener? (Please upload it to pastebin or some other text hosting site)
     

  11. Code:
    p.getInventory().addItem(Potion1);
    <- This
     
  12. Offline

    Alshain01

    I'm going to guess Potion1 is null. Either that or p is null, but educated guess that p = event.getPlayer() so probably Potion1 is null.
     

  13. Oh, thank you so much, works fine now (commented the potions out)

    How to give a player some potions? Like EXP Bottles etc.?

    But isn't important now, thank you..
     
Thread Status:
Not open for further replies.

Share This Page