Hi,
I have a NullPointerException in the console why I call a method in a class with eco.withdraw... (vault)
I don't know why because in other class like my listener it's work...
Can you help me please ? Thank's a lot
I have a NullPointerException in the console why I call a method in a class with eco.withdraw... (vault)
I don't know why because in other class like my listener it's work...
Code:
[12:54:30 ERROR]: Could not pass event InventoryClickEvent to PickaxeTestYML v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1891) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_211]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_211]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
Caused by: java.lang.NullPointerException
at fr.clems.pickaxe.Anvil.anvilUSE(Anvil.java:49) ~[?:?]
at fr.clems.pickaxe.EventListener.onClickInventory(EventListener.java:154) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_211]
at org.bukkit
Code:
public class Main extends JavaPlugin {
public static Economy economy = null;
private Book book = new Book(this);
private Gui gui = new Gui(this);
private Anvil anvil = new Anvil(this);
@Override
public void onEnable() {
setupEconomy();
getConfig().options().copyDefaults(true);
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new EventListener(this), this);
getCommand("efficiency").setExecutor(new Commands(this));
getCommand("fortune").setExecutor(new Commands(this));
getCommand("unbreaking").setExecutor(new Commands(this));
getCommand("set").setExecutor(new CommandsAdmin());
}
public void onDisable() {
}
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}
}
Code:
private FileConfiguration config;
private Main main;
private Economy eco;
public Anvil(Main main) {
this.main = main;
this.config = main.getConfig();
this.eco = Main.economy;
}
public void anvilUSE(Player p) {
p.getInventory().getItem(0).setDurability((short) 0);
eco.withdrawPlayer(p, 1000);
System.out.println("test");
}
Code:
if(nameItem.equalsIgnoreCase("§aRepair")) {
new Anvil().anvilUSE(p);
}
Can you help me please ? Thank's a lot
