Solved vault help

Discussion in 'Spigot Plugin Development' started by Vrsd12, May 20, 2017.

  1. Hi, can someone tell me what's wrong with this?

    @EventHandler
    public void onPickup(final PlayerPickupItemEvent e) {
    final Player p = e.getPlayer();
    final ItemStack item = e.getItem().getItemStack();
    final Material itemType = item.getType();
    if (itemType.equals((Object)Material.SKULL_ITEM)) {
    economy.depositPlayer(p.getName(), 100); //error//
    }
    }

    Code (Text):
    Could not pass event PlayerPickupItemEvent to MobsDeath v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityItem.d(EntityItem.java:314) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityHuman.d(EntityHuman.java:448) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityHuman.m(EntityHuman.java:439) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.t_(EntityLiving.java:1487) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityHuman.t_(EntityHuman.java:173) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityPlayer.l(EntityPlayer.java:285) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:382) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPositionLook.a(SourceFile:18) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_131]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_131]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.NullPointerException
            at me.gabri.Main.onPickup(Main.java:522) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[Spigot1.8.jar:git-Spigot-db6de12-18fbb24]
            ... 21 more
    >
     
  2. I'm not experienced with Vault so I'm not sure what the problem is but why is everything final? Why is Material.SKULL_ITEM casted to Object? You can do item.getType() or even e.getItem().getItemStack().getType() instead of making a new variable for each step.
     
  3. The economy variable is null, can you show the code where you inizialize it?
     
  4. economy.depositPlayer(p.getName(), 100);
    If you get an NPE on that line, that means that the variable "economy" is null.
    Why do you use the deprecated method Economy#depositPlayer(String, Double) instead of Economy#depositPlayer(Player, Double)?
     
  5. Code (Text):
        private boolean setupEconomy() {
            if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            final RegisteredServiceProvider<Economy> rsp = (RegisteredServiceProvider<Economy>)this.getServer().getServicesManager().getRegistration((Class)Economy.class);
            if (rsp == null) {
                return false;
            }
            Main.economy = (Economy)rsp.getProvider();
            return Main.economy != null;
        }  
     
  6. Well, have you tried to debug and see if the #setupEconomy method runs successfully or not? Also, do you have a economy plugin installed on your server?
     
  7. [18:08:44 INFO]: [Vault] Enabled Version 1.5.6-b49
    [18:08:44 INFO]: [MobsDeath] Enabling MobsDeath v1.0
    @Override
    public void onEnable(){
    setupEconomy();
     
  8. Sorry but did you read what i said? Does the #setupEconomy method return true or false when your run in? If it return false is something wrong.. Also again, do you have a economy plugin (not VAULT) installed on your server?
     
  9. I already understand I need another plugin that uses vault
     
  10. *implements Vault Economy
     
  11. Do you have a economy plugin installed or not? Is the problem solved?
    "Does the #setupEconomy method return true or false when your run in? If it return false is something wrong.."
     
  12. ready
    thanks guys