Skip to content

Commit

Permalink
Added #shulker_box tag to target all shulker box types (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed May 11, 2024
1 parent e61b8a4 commit 377a6f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/net/coreprotect/command/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class CommandHandler implements CommandExecutor {
private static CommandHandler instance;
private static ConcurrentHashMap<String, Boolean> versionAlert = new ConcurrentHashMap<>();
protected static Set<Material> naturalBlocks = BlockGroup.NATURAL_BLOCKS;
protected static Set<Material> shulkerBlocks = BlockGroup.SHULKER_BOXES;

public static CommandHandler getInstance() {
if (instance == null) {
Expand Down Expand Up @@ -282,6 +283,11 @@ else if (next == 5 || argument.startsWith("e:") || argument.startsWith("exclude:
excluded.put(block, false);
}
}
else if (i3.equals("#shulker_box")) {
for (Material block : shulkerBlocks) {
excluded.put(block, false);
}
}
else {
Material i3_material = Util.getType(i3);
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
Expand Down Expand Up @@ -311,6 +317,11 @@ else if (i3_material != null) {
excluded.put(block, false);
}
}
else if (argument.equals("#shulker_box")) {
for (Material block : shulkerBlocks) {
excluded.put(block, false);
}
}
else {
Material iMaterial = Util.getType(argument);
if (iMaterial != null && (iMaterial.isBlock() || argAction.contains(4))) {
Expand Down Expand Up @@ -359,7 +370,7 @@ else if (next == 5 || argument.startsWith("e:") || argument.startsWith("exclude:
String[] i2 = argument.split(",");
for (String i3 : i2) {
boolean isBlock = false;
if (i3.equals("#natural")) {
if (i3.equals("#natural") || i3.equals("#shulker_box")) {
isBlock = true;
}
else {
Expand Down Expand Up @@ -387,7 +398,7 @@ else if (next == 5 || argument.startsWith("e:") || argument.startsWith("exclude:
}
else {
boolean isBlock = false;
if (argument.equals("#natural")) {
if (argument.equals("#natural") || argument.equals("#shulker_box")) {
isBlock = true;
}
else {
Expand Down Expand Up @@ -633,6 +644,9 @@ else if (next == 4 || argument.startsWith("i:") || argument.startsWith("include:
if (i3.equals("#natural")) {
restricted.addAll(naturalBlocks);
}
else if (i3.equals("#shulker_box")) {
restricted.addAll(shulkerBlocks);
}
else {
Material i3_material = Util.getType(i3);
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
Expand Down Expand Up @@ -665,6 +679,9 @@ else if (i3_material != null) {
if (argument.equals("#natural")) {
restricted.addAll(naturalBlocks);
}
else if (argument.equals("#shulker_box")) {
restricted.addAll(shulkerBlocks);
}
else {
Material material = Util.getType(argument);
if (material != null && (material.isBlock() || argAction.contains(4))) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/coreprotect/command/TabHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ else if ((sender.hasPermission("coreprotect.lookup") || sender.hasPermission("co
materialList.add(add.name().toLowerCase(Locale.ROOT));
}

// add custom tags
materialList.add("#natural");
materialList.add("#shulker_box");

materials = new ArrayList<>(materialList);
}

Expand Down

0 comments on commit 377a6f5

Please sign in to comment.