Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8883db
commit 557f6dc
Showing
5 changed files
with
129 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
plugin/src/main/java/com/denizenscript/denizen/utilities/VanillaTagHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.denizenscript.denizen.utilities; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.Tag; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
||
public class VanillaTagHelper { | ||
|
||
public static HashMap<Material, HashSet<String>> tagsByMaterial = new HashMap<>(); | ||
|
||
public static HashMap<String, HashSet<Material>> tagsByKey = new HashMap<>(); | ||
|
||
static void addTag(Tag<Material> tag) { | ||
tagsByKey.computeIfAbsent(tag.getKey().getKey(), (k) -> new HashSet<>()).addAll(tag.getValues()); | ||
for (Material mat : tag.getValues()) { | ||
tagsByMaterial.computeIfAbsent(mat, (k) -> new HashSet<>()).add(tag.getKey().getKey()); | ||
} | ||
} | ||
|
||
static { | ||
for (Tag<Material> tag : Bukkit.getTags("blocks", Material.class)) { | ||
addTag(tag); | ||
} | ||
/*for (Tag<Material> tag : Bukkit.getTags("fluids", Material.class)) { | ||
addTag(tag); | ||
}*/ // Temporarily exclude fluids due to spigot bug | ||
for (Tag<Material> tag : Bukkit.getTags("items", Material.class)) { | ||
addTag(tag); | ||
} | ||
} | ||
} |