mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-30 05:53:23 +01:00
Merge branch '1.12' into 1.13
This commit is contained in:
commit
e155b98c96
@ -21,7 +21,7 @@ import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
|
|||||||
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Player.*;
|
import com.Acrobot.ChestShop.Listeners.Player.*;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.CreationFeeGetter;
|
import com.Acrobot.ChestShop.Listeners.PreShopCreation.CreationFeeGetter;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.SignSticker;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.SignSticker;
|
||||||
|
@ -37,14 +37,14 @@ public class Economy {
|
|||||||
CurrencyAddEvent event = new CurrencyAddEvent(BigDecimal.valueOf(amount), name, world);
|
CurrencyAddEvent event = new CurrencyAddEvent(BigDecimal.valueOf(amount), name, world);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
|
||||||
return true;
|
return event.isAdded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean subtract(UUID name, World world, double amount) {
|
public static boolean subtract(UUID name, World world, double amount) {
|
||||||
CurrencySubtractEvent event = new CurrencySubtractEvent(BigDecimal.valueOf(amount), name, world);
|
CurrencySubtractEvent event = new CurrencySubtractEvent(BigDecimal.valueOf(amount), name, world);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
|
||||||
return true;
|
return event.isSubtracted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEnough(UUID name, World world, double amount) {
|
public static boolean hasEnough(UUID name, World world, double amount) {
|
||||||
|
@ -2,6 +2,7 @@ package com.Acrobot.ChestShop.Events;
|
|||||||
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class PreShopCreationEvent extends Event {
|
public class PreShopCreationEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player creator;
|
private Player creator;
|
||||||
@ -30,10 +31,21 @@ public class PreShopCreationEvent extends Event {
|
|||||||
*
|
*
|
||||||
* @return Is event cancelled?
|
* @return Is event cancelled?
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return outcome != CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
return outcome != CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if event is cancelled. This sets a generic {@link CreationOutcome#OTHER};
|
||||||
|
*
|
||||||
|
* @param cancel Cancel the event?
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
outcome = CreationOutcome.OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the outcome of the event
|
* Returns the outcome of the event
|
||||||
*
|
*
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -15,7 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class TransactionEvent extends Event {
|
public class TransactionEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final TransactionType type;
|
private final TransactionType type;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ public class TransactionEvent extends Event {
|
|||||||
|
|
||||||
private final Sign sign;
|
private final Sign sign;
|
||||||
|
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
public TransactionEvent(PreTransactionEvent event, Sign sign) {
|
public TransactionEvent(PreTransactionEvent event, Sign sign) {
|
||||||
this.type = event.getTransactionType();
|
this.type = event.getTransactionType();
|
||||||
|
|
||||||
@ -133,6 +136,16 @@ public class TransactionEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible transaction types
|
* Possible transaction types
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +118,7 @@ public class ReserveListener implements Listener {
|
|||||||
final OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
final OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
if (lastSeen != null && provided()) {
|
if (lastSeen != null && provided()) {
|
||||||
economyAPI.addHoldings(event.getTarget(), event.getAmount(), event.getWorld().getName());
|
event.setAdded(economyAPI.addHoldings(event.getTarget(), event.getAmount(), event.getWorld().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class ReserveListener implements Listener {
|
|||||||
final OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
final OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
if (lastSeen != null && provided()) {
|
if (lastSeen != null && provided()) {
|
||||||
economyAPI.removeHoldings(event.getTarget(), event.getAmount(), event.getWorld().getName());
|
event.setSubtracted(economyAPI.removeHoldings(event.getTarget(), event.getAmount(), event.getWorld().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,8 @@ public class ReserveListener implements Listener {
|
|||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(currencySubtractEvent.getAmount(), event.getReceiver(), event.getWorld());
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(currencySubtractEvent.getAmount(), event.getReceiver(), event.getWorld());
|
||||||
onCurrencyAdd(currencyAddEvent);
|
onCurrencyAdd(currencyAddEvent);
|
||||||
|
|
||||||
|
event.setTransferred(currencyAddEvent.isAdded());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -146,7 +146,8 @@ public class VaultListener implements Listener {
|
|||||||
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
if (lastSeen != null) {
|
if (lastSeen != null) {
|
||||||
provider.depositPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
EconomyResponse response = provider.depositPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
||||||
|
event.setAdded(response.type == EconomyResponse.ResponseType.SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,8 @@ public class VaultListener implements Listener {
|
|||||||
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
if (lastSeen != null) {
|
if (lastSeen != null) {
|
||||||
provider.withdrawPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
EconomyResponse response = provider.withdrawPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
||||||
|
event.setSubtracted(response.type == EconomyResponse.ResponseType.SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +182,8 @@ public class VaultListener implements Listener {
|
|||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(currencySubtractEvent.getAmount(), event.getReceiver(), event.getWorld());
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(currencySubtractEvent.getAmount(), event.getReceiver(), event.getWorld());
|
||||||
onCurrencyAdd(currencyAddEvent);
|
onCurrencyAdd(currencyAddEvent);
|
||||||
|
|
||||||
|
event.setTransferred(currencyAddEvent.isAdded());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -34,6 +34,8 @@ public class ServerAccountCorrector implements Listener {
|
|||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(event.getAmount(), target, event.getWorld());
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(event.getAmount(), target, event.getWorld());
|
||||||
ChestShop.callEvent(currencyAddEvent);
|
ChestShop.callEvent(currencyAddEvent);
|
||||||
|
|
||||||
|
event.setAdded(currencyAddEvent.isAdded());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -54,6 +56,8 @@ public class ServerAccountCorrector implements Listener {
|
|||||||
|
|
||||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(event.getAmount(), target, event.getWorld());
|
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(event.getAmount(), target, event.getWorld());
|
||||||
ChestShop.callEvent(currencySubtractEvent);
|
ChestShop.callEvent(currencySubtractEvent);
|
||||||
|
|
||||||
|
event.setSubtracted(currencySubtractEvent.isSubtracted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
@ -16,33 +16,60 @@ import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.SELL
|
|||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class EconomicModule implements Listener {
|
public class EconomicModule implements Listener {
|
||||||
@EventHandler
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
public static void onBuyTransaction(TransactionEvent event) {
|
public static void onBuyTransaction(TransactionEvent event) {
|
||||||
if (event.getTransactionType() != BUY) {
|
if (event.getTransactionType() != BUY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(
|
||||||
|
BigDecimal.valueOf(event.getPrice()),
|
||||||
event.getOwnerAccount().getUuid(),
|
event.getOwnerAccount().getUuid(),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencyAddEvent); // java.lang.StackOverflowError
|
ChestShop.callEvent(currencyAddEvent);
|
||||||
|
if (!currencyAddEvent.isAdded()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
||||||
ChestShop.callEvent(currencySubtractEvent);
|
ChestShop.callEvent(currencySubtractEvent);
|
||||||
|
if (!currencySubtractEvent.isSubtracted()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
CurrencySubtractEvent currencyResetEvent = new CurrencySubtractEvent(
|
||||||
|
BigDecimal.valueOf(event.getPrice()),
|
||||||
|
event.getOwnerAccount().getUuid(),
|
||||||
|
event.getSign().getWorld());
|
||||||
|
ChestShop.callEvent(currencyResetEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(ignoreCancelled = true)
|
||||||
public static void onSellTransaction(TransactionEvent event) {
|
public static void onSellTransaction(TransactionEvent event) {
|
||||||
if (event.getTransactionType() != SELL) {
|
if (event.getTransactionType() != SELL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(
|
||||||
|
BigDecimal.valueOf(event.getPrice()),
|
||||||
event.getOwnerAccount().getUuid(),
|
event.getOwnerAccount().getUuid(),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencySubtractEvent);
|
ChestShop.callEvent(currencySubtractEvent);
|
||||||
|
if (!currencySubtractEvent.isSubtracted()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
||||||
ChestShop.callEvent(currencyAddEvent);
|
ChestShop.callEvent(currencyAddEvent);
|
||||||
|
if (!currencyAddEvent.isAdded()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
CurrencyAddEvent currencyResetEvent = new CurrencyAddEvent(
|
||||||
|
BigDecimal.valueOf(event.getPrice()),
|
||||||
|
event.getOwnerAccount().getUuid(),
|
||||||
|
event.getSign().getWorld());
|
||||||
|
ChestShop.callEvent(currencyResetEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*/
|
*/
|
||||||
public class EmptyShopDeleter implements Listener {
|
public class EmptyShopDeleter implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onTransaction(TransactionEvent event) {
|
public static void onTransaction(TransactionEvent event) {
|
||||||
if (event.getTransactionType() != TransactionEvent.TransactionType.BUY) {
|
if (event.getTransactionType() != TransactionEvent.TransactionType.BUY) {
|
||||||
return;
|
return;
|
||||||
|
@ -4,6 +4,7 @@ import com.Acrobot.Breeze.Utils.InventoryUtil;
|
|||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -15,7 +16,7 @@ import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.SELL
|
|||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class ItemManager implements Listener {
|
public class ItemManager implements Listener {
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void shopItemRemover(TransactionEvent event) {
|
public static void shopItemRemover(TransactionEvent event) {
|
||||||
if (event.getTransactionType() != BUY) {
|
if (event.getTransactionType() != BUY) {
|
||||||
return;
|
return;
|
||||||
@ -27,7 +28,7 @@ public class ItemManager implements Listener {
|
|||||||
event.getClient().updateInventory();
|
event.getClient().updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void inventoryItemRemover(TransactionEvent event) {
|
public static void inventoryItemRemover(TransactionEvent event) {
|
||||||
if (event.getTransactionType() != SELL) {
|
if (event.getTransactionType() != SELL) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ public class TransactionLogger implements Listener {
|
|||||||
private static final String BUY_MESSAGE = "%1$s bought %2$s for %3$.2f from %4$s at %5$s";
|
private static final String BUY_MESSAGE = "%1$s bought %2$s for %3$.2f from %4$s at %5$s";
|
||||||
private static final String SELL_MESSAGE = "%1$s sold %2$s for %3$.2f to %4$s at %5$s";
|
private static final String SELL_MESSAGE = "%1$s sold %2$s for %3$.2f to %4$s at %5$s";
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public static void onTransaction(final TransactionEvent event) {
|
public static void onTransaction(final TransactionEvent event) {
|
||||||
String template = (event.getTransactionType() == BUY ? BUY_MESSAGE : SELL_MESSAGE);
|
String template = (event.getTransactionType() == BUY ? BUY_MESSAGE : SELL_MESSAGE);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import java.util.UUID;
|
|||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class TransactionMessageSender implements Listener {
|
public class TransactionMessageSender implements Listener {
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public static void onTransaction(TransactionEvent event) {
|
public static void onTransaction(TransactionEvent event) {
|
||||||
if (event.getTransactionType() == TransactionEvent.TransactionType.BUY) {
|
if (event.getTransactionType() == TransactionEvent.TransactionType.BUY) {
|
||||||
sendBuyMessage(event);
|
sendBuyMessage(event);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners.PostShopCreation;
|
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
@ -6,12 +6,13 @@ import com.Acrobot.ChestShop.Configuration.Properties;
|
|||||||
import com.Acrobot.ChestShop.Economy.Economy;
|
import com.Acrobot.ChestShop.Economy.Economy;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencySubtractEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencySubtractEvent;
|
||||||
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -24,8 +25,8 @@ import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
|
|||||||
*/
|
*/
|
||||||
public class CreationFeeGetter implements Listener {
|
public class CreationFeeGetter implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onShopCreation(ShopCreatedEvent event) {
|
public static void onShopCreation(PreShopCreationEvent event) {
|
||||||
double shopCreationPrice = Properties.SHOP_CREATION_PRICE;
|
double shopCreationPrice = Properties.SHOP_CREATION_PRICE;
|
||||||
|
|
||||||
if (shopCreationPrice == 0) {
|
if (shopCreationPrice == 0) {
|
||||||
@ -45,6 +46,12 @@ public class CreationFeeGetter implements Listener {
|
|||||||
CurrencySubtractEvent subtractionEvent = new CurrencySubtractEvent(BigDecimal.valueOf(shopCreationPrice), player);
|
CurrencySubtractEvent subtractionEvent = new CurrencySubtractEvent(BigDecimal.valueOf(shopCreationPrice), player);
|
||||||
ChestShop.callEvent(subtractionEvent);
|
ChestShop.callEvent(subtractionEvent);
|
||||||
|
|
||||||
|
if (!subtractionEvent.isSubtracted()) {
|
||||||
|
event.setOutcome(PreShopCreationEvent.CreationOutcome.NOT_ENOUGH_MONEY);
|
||||||
|
event.setSignLines(new String[4]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (NameManager.getServerEconomyAccount() != null) {
|
if (NameManager.getServerEconomyAccount() != null) {
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(
|
||||||
BigDecimal.valueOf(shopCreationPrice),
|
BigDecimal.valueOf(shopCreationPrice),
|
Loading…
Reference in New Issue
Block a user