2013-01-15 21:33:00 +01:00
|
|
|
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
|
|
|
|
2013-07-13 23:14:10 +02:00
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
2013-01-15 21:33:00 +01:00
|
|
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
2013-07-13 23:14:10 +02:00
|
|
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
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-07-13 23:14:10 +02:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
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) {
|
2019-04-25 19:44:22 +02:00
|
|
|
BigDecimal shopCreationPrice = Properties.SHOP_CREATION_PRICE;
|
2013-01-15 21:33:00 +01:00
|
|
|
|
2019-04-25 19:44:22 +02:00
|
|
|
if (shopCreationPrice.compareTo(BigDecimal.ZERO) == 0) {
|
2013-01-15 21:33:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ChestShopSign.isAdminShop(event.getSignLine(NAME_LINE))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (Permission.has(player, NOFEE)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-25 19:44:22 +02:00
|
|
|
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(shopCreationPrice, player);
|
2013-07-13 23:14:10 +02:00
|
|
|
ChestShop.callEvent(currencyCheckEvent);
|
|
|
|
|
|
|
|
if (!currencyCheckEvent.hasEnough()) {
|
2013-01-24 22:35:28 +01:00
|
|
|
event.setOutcome(NOT_ENOUGH_MONEY);
|
|
|
|
}
|
2013-01-15 21:33:00 +01:00
|
|
|
}
|
|
|
|
}
|