Имею такой код:
Консоль пишет:
То есть строка double money = eco.getBalance(p); неверная. Что я делаю не так?
UPD. В классе прописана строка private static Economy eco;
Java:
@Override
public void onEnable() {
super.onEnable();
Bukkit.getPluginManager().registerEvents(new AdminShop(), this);
this.getCommand("adminshop").setExecutor(new AdminShop());
AdminShop.init();
getLogger().info(ChatColor.AQUA + "Successfully enabled.");
}
Java:
@EventHandler
public void shopuse(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
Inventory i = e.getClickedInventory();
p.sendMessage("1");
if (!i.getTitle().equals(ChatColor.DARK_GREEN + "Админшоп SapphireLife")) return;
p.sendMessage("2");
e.setCancelled(true);
int slot = e.getSlot();
double amount;
double money = eco.getBalance(p);
p.sendMessage("3");
if (slot == 21) {
p.sendMessage("4");
amount = 50;
if (money < amount) {
double req = amount - money;
p.sendMessage(ChatColor.RED + "Вам не хватает " + req + " монет для покупки этого предмета.");
return;
}
eco.withdrawPlayer(p, 50);
p.sendMessage("5");
}
}
public static void init() {
Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
}
Консоль пишет:
Java:
org.bukkit.event.EventException: null
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:69) ~[EventExecutor$2.class:git-CatServer-1.12.2-3440193]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[RegisteredListener.class:git-CatServer-1.12.2-3440193]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:503) [SimplePluginManager.class:git-CatServer-1.12.2-3440193]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:488) [SimplePluginManager.class:git-CatServer-1.12.2-3440193]
at net.minecraft.network.NetHandlerPlayServer.func_147351_a(NetHandlerPlayServer.java:2113) [pa.class:?]
at net.minecraft.network.play.client.CPacketClickWindow.func_148833_a(CPacketClickWindow.java:38) [lf.class:?]
at net.minecraft.network.play.client.CPacketClickWindow.func_148833_a(CPacketClickWindow.java:12) [lf.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_241]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_241]
at net.minecraft.util.Util.func_181617_a(Util.java:50) [h.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:845) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:472) [nz.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:782) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:636) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
Caused by: java.lang.NullPointerException
at com.baroness.AdminShop.shopuse(AdminShop.java:61) ~[?:?]
at catserver.server.executor.asm.generated.GeneratedEventExecutor16.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:67) ~[EventExecutor$2.class:git-CatServer-1.12.2-3440193]
... 15 more
То есть строка double money = eco.getBalance(p); неверная. Что я делаю не так?
Объединено
UPD. В классе прописана строка private static Economy eco;