Fix shop sign getting broken with autofill marker (Fixes #310)

This commit is contained in:
Phoenix616 2020-05-13 23:13:56 +01:00
parent f044938b80
commit 7b978ae022
2 changed files with 23 additions and 4 deletions

View File

@ -181,7 +181,7 @@ public class PreShopCreationEvent extends Event implements Cancellable {
INVALID_PRICE,
INVALID_QUANTITY,
ITEM_AUTOFILL,
ITEM_AUTOFILL(false),
UNKNOWN_PLAYER,
@ -202,12 +202,31 @@ public class PreShopCreationEvent extends Event implements Cancellable {
/**
* For plugin use
*/
OTHER,
OTHER(false),
/**
* Break the sign
*/
OTHER_BREAK,
SHOP_CREATED_SUCCESSFULLY
SHOP_CREATED_SUCCESSFULLY(false);
private final boolean breakSign;
CreationOutcome() {
this.breakSign = true;
}
CreationOutcome(boolean breakSign) {
this.breakSign = breakSign;
}
/**
* Get whether or not this outcome should result in the shop sign getting broken
*
* @return Whether or not the shop sign gets broken
*/
public boolean shouldBreakSign() {
return breakSign;
}
}
}

View File

@ -47,7 +47,7 @@ public class SignCreate implements Listener {
PreShopCreationEvent preEvent = new PreShopCreationEvent(event.getPlayer(), sign, lines);
ChestShop.callEvent(preEvent);
if (preEvent.isCancelled() && preEvent.getOutcome() != PreShopCreationEvent.CreationOutcome.OTHER) {
if (preEvent.getOutcome().shouldBreakSign()) {
signBlock.breakNaturally();
return;
}