我正在为我的服务器开发一个用于 KitPvP 部分的插件。
现在我正在添加MoneyPerKill
,但遇到了问题。
我的代码是:
package com.lobbyist.junk.kitpvp;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.RegisteredServiceProvider;
public class MoneyPerKill implements Listener {
public static Economy econ = null;
@EventHandler
public void onPlayerDeathEvent(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
EconomyResponse r = econ.depositPlayer(killer, 10.00);
if (r.transactionSuccess()) {
killer.sendMessage(ChatColor.GOLD + "You recieved $10 for killing" + player.getDisplayName());
}
}
}
在我的主要课程Main.java
中,我还注册了这些事件。
在Main.java
我有:
public static Economy econ = null;
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
econ = economyProvider.getProvider();
}
return (econ != null);
}
问题是当他们杀死一个玩家时它并没有给杀手钱。