mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-02-18 19:11:19 +01:00
Fix shop sign getting broken with autofill marker (Fixes #310)
This commit is contained in:
parent
f044938b80
commit
7b978ae022
@ -181,7 +181,7 @@ public class PreShopCreationEvent extends Event implements Cancellable {
|
|||||||
INVALID_PRICE,
|
INVALID_PRICE,
|
||||||
INVALID_QUANTITY,
|
INVALID_QUANTITY,
|
||||||
|
|
||||||
ITEM_AUTOFILL,
|
ITEM_AUTOFILL(false),
|
||||||
|
|
||||||
UNKNOWN_PLAYER,
|
UNKNOWN_PLAYER,
|
||||||
|
|
||||||
@ -202,12 +202,31 @@ public class PreShopCreationEvent extends Event implements Cancellable {
|
|||||||
/**
|
/**
|
||||||
* For plugin use
|
* For plugin use
|
||||||
*/
|
*/
|
||||||
OTHER,
|
OTHER(false),
|
||||||
/**
|
/**
|
||||||
* Break the sign
|
* Break the sign
|
||||||
*/
|
*/
|
||||||
OTHER_BREAK,
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class SignCreate implements Listener {
|
|||||||
PreShopCreationEvent preEvent = new PreShopCreationEvent(event.getPlayer(), sign, lines);
|
PreShopCreationEvent preEvent = new PreShopCreationEvent(event.getPlayer(), sign, lines);
|
||||||
ChestShop.callEvent(preEvent);
|
ChestShop.callEvent(preEvent);
|
||||||
|
|
||||||
if (preEvent.isCancelled() && preEvent.getOutcome() != PreShopCreationEvent.CreationOutcome.OTHER) {
|
if (preEvent.getOutcome().shouldBreakSign()) {
|
||||||
signBlock.breakNaturally();
|
signBlock.breakNaturally();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user