ChestShop-3/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/MoneyChecker.java

44 lines
1.3 KiB
Java
Raw Normal View History

2013-01-15 21:33:00 +01:00
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
import com.Acrobot.ChestShop.Configuration.Properties;
2013-01-24 22:35:28 +01:00
import com.Acrobot.ChestShop.Economy.Economy;
2013-01-15 21:33:00 +01:00
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
2013-01-24 22:35:28 +01:00
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.NOT_ENOUGH_MONEY;
2013-01-15 21:33:00 +01:00
import static com.Acrobot.ChestShop.Permission.NOFEE;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
/**
* @author Acrobot
*/
public class MoneyChecker implements Listener {
@EventHandler
public static void onPreShopCreation(PreShopCreationEvent event) {
double shopCreationPrice = Properties.SHOP_CREATION_PRICE;
if (shopCreationPrice == 0) {
return;
}
if (ChestShopSign.isAdminShop(event.getSignLine(NAME_LINE))) {
return;
}
Player player = event.getPlayer();
if (Permission.has(player, NOFEE)) {
return;
}
2013-01-24 22:35:28 +01:00
if (!Economy.hasEnough(player.getName(), shopCreationPrice)) {
event.setOutcome(NOT_ENOUGH_MONEY);
}
2013-01-15 21:33:00 +01:00
}
}