Add compatibility for new sign-editing in 1.20
This allows editing of signs if you hold a sign in hand but block any other interaction.
This commit is contained in:
parent
6602be68e3
commit
7203ec17cd
|
@ -82,7 +82,7 @@ public class PlayerInteract implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSign(block) || player.getInventory().getItemInMainHand().getType().name().contains("SIGN")) // Blocking accidental sign edition
|
if (!isSign(block))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Sign sign = (Sign) getState(block, false);
|
Sign sign = (Sign) getState(block, false);
|
||||||
|
@ -94,6 +94,7 @@ public class PlayerInteract implements Listener {
|
||||||
if (ChestShopSign.hasPermission(player, OTHER_NAME_CREATE, sign)) {
|
if (ChestShopSign.hasPermission(player, OTHER_NAME_CREATE, sign)) {
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
if (!MaterialUtil.isEmpty(item)) {
|
if (!MaterialUtil.isEmpty(item)) {
|
||||||
|
event.setCancelled(true);
|
||||||
String itemCode;
|
String itemCode;
|
||||||
try {
|
try {
|
||||||
itemCode = ItemUtil.getSignName(item);
|
itemCode = ItemUtil.getSignName(item);
|
||||||
|
@ -113,8 +114,6 @@ public class PlayerInteract implements Listener {
|
||||||
sign.setLine(i, line != null ? line : "");
|
sign.setLine(i, line != null ? line : "");
|
||||||
}
|
}
|
||||||
sign.update();
|
sign.update();
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Messages.NO_ITEM_IN_HAND.sendWithPrefix(player);
|
Messages.NO_ITEM_IN_HAND.sendWithPrefix(player);
|
||||||
|
@ -127,7 +126,10 @@ public class PlayerInteract implements Listener {
|
||||||
|
|
||||||
if (!AccessToggle.isIgnoring(player) && ChestShopSign.canAccess(player, sign) && !ChestShopSign.isAdminShop(sign)) {
|
if (!AccessToggle.isIgnoring(player) && ChestShopSign.canAccess(player, sign) && !ChestShopSign.isAdminShop(sign)) {
|
||||||
if (Properties.IGNORE_ACCESS_PERMS || ChestShopSign.isOwner(player, sign)) {
|
if (Properties.IGNORE_ACCESS_PERMS || ChestShopSign.isOwner(player, sign)) {
|
||||||
if ((player.getInventory().getItemInMainHand().getType().name().endsWith("DYE")
|
if (player.getInventory().getItemInMainHand().getType().name().contains("SIGN") && action == RIGHT_CLICK_BLOCK) {
|
||||||
|
// Allow editing of sign (if supported)
|
||||||
|
return;
|
||||||
|
} else if ((player.getInventory().getItemInMainHand().getType().name().endsWith("DYE")
|
||||||
|| player.getInventory().getItemInMainHand().getType().name().endsWith("INK_SAC"))
|
|| player.getInventory().getItemInMainHand().getType().name().endsWith("INK_SAC"))
|
||||||
&& action == RIGHT_CLICK_BLOCK) {
|
&& action == RIGHT_CLICK_BLOCK) {
|
||||||
if (Properties.SIGN_DYING) {
|
if (Properties.SIGN_DYING) {
|
||||||
|
@ -147,6 +149,10 @@ public class PlayerInteract implements Listener {
|
||||||
}
|
}
|
||||||
// don't allow owners or people with access to buy/sell at this shop
|
// don't allow owners or people with access to buy/sell at this shop
|
||||||
Messages.TRADE_DENIED_ACCESS_PERMS.sendWithPrefix(player);
|
Messages.TRADE_DENIED_ACCESS_PERMS.sendWithPrefix(player);
|
||||||
|
if (action == RIGHT_CLICK_BLOCK) {
|
||||||
|
// don't allow editing
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue