mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-25 13:12:51 +02:00
bca38b8a79
No bank support... sorry @jrtc27, it's coming later!
50 lines
1.5 KiB
Java
50 lines
1.5 KiB
Java
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
|
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;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.NOT_ENOUGH_MONEY;
|
|
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;
|
|
}
|
|
|
|
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(BigDecimal.valueOf(shopCreationPrice), player);
|
|
ChestShop.callEvent(currencyCheckEvent);
|
|
|
|
if (!currencyCheckEvent.hasEnough()) {
|
|
event.setOutcome(NOT_ENOUGH_MONEY);
|
|
}
|
|
}
|
|
}
|