Add message for NPCPayListener

This commit is contained in:
fullwall 2012-08-16 00:08:36 +08:00
parent 2fceea7d23
commit e393f2d38b

View File

@ -2,8 +2,11 @@ package net.citizensnpcs;
import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.event.PlayerCreateNPCEvent; import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
import net.citizensnpcs.util.Messaging;
import net.citizensnpcs.util.StringHelper;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -21,7 +24,7 @@ public class NPCPayListener implements Listener {
public void onPlayerCreateNPC(PlayerCreateNPCEvent event) { public void onPlayerCreateNPC(PlayerCreateNPCEvent event) {
String name = event.getCreator().getName(); String name = event.getCreator().getName();
boolean hasAccount = provider.hasAccount(name); boolean hasAccount = provider.hasAccount(name);
if (!hasAccount) if (!hasAccount || event.getCreator().hasPermission("citizens.npc.ignore-cost"))
return; return;
double cost = Setting.NPC_COST.asDouble(); double cost = Setting.NPC_COST.asDouble();
boolean hasEnough = provider.has(name, cost); boolean hasEnough = provider.has(name, cost);
@ -31,5 +34,7 @@ public class NPCPayListener implements Listener {
return; return;
} }
provider.bankWithdraw(name, cost); provider.bankWithdraw(name, cost);
Messaging.sendF(event.getCreator(), ChatColor.GREEN + "Withdrew %s for your NPC.",
StringHelper.wrap(provider.format(cost)));
} }
} }