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

29 lines
955 B
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-15 21:33:00 +01:00
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
2013-01-15 21:33:00 +01:00
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.INVALID_QUANTITY;
/**
* @author Acrobot
*/
public class QuantityChecker implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public static void onPreShopCreation(PreShopCreationEvent event) {
int amount = -1;
try {
amount = ChestShopSign.getQuantity(event.getSignLines());
} catch (NumberFormatException ignored) {} // not a quantity on the line
2013-01-15 21:33:00 +01:00
if (amount < 1 || amount > Properties.MAX_SHOP_AMOUNT) {
2013-01-15 21:33:00 +01:00
event.setOutcome(INVALID_QUANTITY);
}
}
}