Skip to content

Commit

Permalink
Update ChestShopSign validation check
Browse files Browse the repository at this point in the history
The validation check "isLegacyValid" in the ChestShopSign class has been replaced with "isChestShop". Changes were done in the ChestShop, RestrictedSign, and ChestShopSign classes where this method was called. A new validation function "isChestShop" was also added to check if a block is a ChestShop sign.
  • Loading branch information
Feli499 committed Dec 31, 2023
1 parent 65cb039 commit 21c6774
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/Acrobot/ChestShop/Plugins/ChestShop.java
Expand Up @@ -41,7 +41,7 @@ public static boolean canAccess(Player player, Block block) {
if (isSign(block)) {
Sign sign = (Sign) block.getState();

if (!ChestShopSign.isLegacyValid(sign)) {
if (!ChestShopSign.isChestShop(sign)) {
return true;
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java
Expand Up @@ -6,6 +6,8 @@
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -104,6 +106,14 @@ private static boolean isLegacyChestShop(Sign sign) {
return LegacyChestShopSign.isValid(sign);
}

public static boolean isChestShop(Block block) {
BlockState state = block.getState();
if (!(state instanceof Sign))
return false;

return isChestShop((Sign) state);
}

public static boolean isChestShop(Sign sign) {

if (isLegacyChestShop(sign)) {
Expand Down
Expand Up @@ -52,7 +52,7 @@ public static void onSignChange(SignChangeEvent event) {
}
Block connectedSign = event.getBlock().getRelative(BlockFace.DOWN);

if (!Permission.has(player, ADMIN) || !ChestShopSign.isLegacyValid(connectedSign)) {
if (!Permission.has(player, ADMIN) || !ChestShopSign.isChestShop(connectedSign)) {
dropSignAndCancelEvent(event);
return;
}
Expand Down

0 comments on commit 21c6774

Please sign in to comment.