mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-02-16 02:11:18 +01:00
Fix issues with new 1.20 back side of signs
This basically blocks any text on the backside of a sign if the front is a valid shop and with that also fixes an issue where valid shop sign syntax was detected on back side sign changes.
This commit is contained in:
parent
f3cf4cd96e
commit
d426492561
@ -82,6 +82,7 @@ public class Messages {
|
||||
public static Message INVALID_SHOP_PRICE;
|
||||
public static Message INVALID_SHOP_QUANTITY;
|
||||
public static Message CANNOT_ACCESS_THE_CHEST;
|
||||
public static Message CANNOT_CHANGE_SIGN_BACKSIDE;
|
||||
|
||||
public static Message SELL_PRICE_HIGHER_THAN_BUY_PRICE;
|
||||
public static Message SELL_PRICE_ABOVE_MAX;
|
||||
|
@ -3,6 +3,7 @@ package com.Acrobot.ChestShop.Listeners.Block;
|
||||
import com.Acrobot.Breeze.Utils.BlockUtil;
|
||||
import com.Acrobot.Breeze.Utils.StringUtil;
|
||||
import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
||||
import com.Acrobot.ChestShop.Listeners.Block.Break.SignBreak;
|
||||
@ -11,6 +12,7 @@ import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
@ -22,6 +24,17 @@ import static com.Acrobot.ChestShop.Permission.OTHER_NAME_DESTROY;
|
||||
*/
|
||||
public class SignCreate implements Listener {
|
||||
|
||||
private static boolean HAS_SIGN_SIDES;
|
||||
|
||||
static {
|
||||
try {
|
||||
SignChangeEvent.class.getMethod("getSide");
|
||||
HAS_SIGN_SIDES = true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
HAS_SIGN_SIDES = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public static void onSignChange(SignChangeEvent event) {
|
||||
Block signBlock = event.getBlock();
|
||||
@ -32,6 +45,14 @@ public class SignCreate implements Listener {
|
||||
|
||||
Sign sign = (Sign) signBlock.getState();
|
||||
|
||||
if (HAS_SIGN_SIDES && event.getSide() != Side.FRONT) {
|
||||
if (ChestShopSign.isValid(sign)) {
|
||||
event.setCancelled(true);
|
||||
Messages.CANNOT_CHANGE_SIGN_BACKSIDE.sendWithPrefix(event.getPlayer());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChestShopSign.isValid(event.getLines()) && !NameManager.canUseName(event.getPlayer(), OTHER_NAME_DESTROY, ChestShopSign.getOwner(event.getLines()))) {
|
||||
event.setCancelled(true);
|
||||
sign.update();
|
||||
|
@ -81,6 +81,7 @@ INVALID_SHOP_DETECTED: "The shop cannot be used!"
|
||||
INVALID_SHOP_PRICE: "The shop has an invalid price!"
|
||||
INVALID_SHOP_QUANTITY: "The shop has an invalid quantity!"
|
||||
CANNOT_ACCESS_THE_CHEST: "You don't have permissions to access this chest!"
|
||||
CANNOT_CHANGE_SIGN_BACKSIDE: "You can't change the back side of a shop sign!"
|
||||
|
||||
SELL_PRICE_HIGHER_THAN_BUY_PRICE: "Sell price is above the buy price!"
|
||||
SELL_PRICE_ABOVE_MAX: "Sell price %price is above maximum %maxprice!"
|
||||
|
Loading…
Reference in New Issue
Block a user