Skip to content

Commit

Permalink
improve sign parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 27, 2023
1 parent 8c66f2a commit cbb52ce
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.patches;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XTag;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
Expand All @@ -11,17 +12,18 @@
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.HashSet;
import java.util.stream.Collectors;

public class CommandSign implements AnarchyExploitFixesModule, Listener {

private final HashSet<Material> signs = new HashSet<>();
private final HashSet<Material> signs;

public CommandSign() {
shouldEnable();
XTag.SIGNS.getValues().forEach(xMaterial -> {
Material signType = xMaterial.parseMaterial();
if (signType != null) this.signs.add(signType);
});
this.signs = XTag.SIGNS.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(HashSet::new));
AnarchyExploitFixes.getConfiguration().addComment("patches.prevent-command-sign",
"Will have the side effect of players being unable to dye signs in newer versions.");
}
Expand All @@ -47,7 +49,7 @@ public boolean shouldEnable() {
return AnarchyExploitFixes.getConfiguration().getBoolean("patches.prevent-command-sign", false);
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onInteract(PlayerInteractEvent event) {
if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
if (signs.contains(event.getClickedBlock().getType())) {
Expand Down

0 comments on commit cbb52ce

Please sign in to comment.