forked from ChestShop-authors/ChestShop-3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ShopValidator.java
30 lines (25 loc) · 903 Bytes
/
ShopValidator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.Acrobot.ChestShop.Listeners.PreTransaction;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.INVALID_SHOP;
/**
* @author Acrobot
*/
public class ShopValidator implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public static void onCheck(PreTransactionEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getStock() == null) {
event.setCancelled(INVALID_SHOP);
return;
}
if (!ChestShopSign.isAdminShop(event.getSign()) && event.getOwnerInventory() == null) {
event.setCancelled(INVALID_SHOP);
}
}
}