Skip to content

Commit 8cd0d44

Browse files
committed
Fixed MaterialUtils matching of Materials in different mc versions
1 parent e1f4df9 commit 8cd0d44

File tree

1 file changed

+31
-35
lines changed
  • MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper

1 file changed

+31
-35
lines changed

MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/MaterialUtils.java

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ public class MaterialUtils {
2929

3030
private static final Set<Material> WALL_SIGNS = new HashSet<Material>() {
3131
{
32-
add(getMat("WALL_SIGN"));
33-
add(getMat("ACACIA_WALL_SIGN"));
34-
add(getMat("BIRCH_WALL_SIGN"));
35-
add(getMat("DARK_OAK_WALL_SIGN"));
36-
add(getMat("JUNGLE_WALL_SIGN"));
37-
add(getMat("OAK_WALL_SIGN"));
38-
add(getMat("SPRUCE_WALL_SIGN"));
39-
add(getMat("WARPED_WALL_SIGN"));
40-
add(getMat("CRIMSON_WALL_SIGN"));
32+
add(getMaterial("WALL_SIGN"));
33+
add(getMaterial("ACACIA_WALL_SIGN"));
34+
add(getMaterial("BIRCH_WALL_SIGN"));
35+
add(getMaterial("DARK_OAK_WALL_SIGN"));
36+
add(getMaterial("JUNGLE_WALL_SIGN"));
37+
add(getMaterial("OAK_WALL_SIGN"));
38+
add(getMaterial("SPRUCE_WALL_SIGN"));
39+
add(getMaterial("WARPED_WALL_SIGN"));
40+
add(getMaterial("CRIMSON_WALL_SIGN"));
4141
}
4242
};
4343

4444
public static final Set<Material> BASIC_SIGNS = new HashSet<Material>() {
4545
{
46-
add(getMat("SIGN"));
47-
add(getMat("STANDING_SIGN"));
48-
add(getMat("ACACIA_SIGN"));
49-
add(getMat("BIRCH_SIGN"));
50-
add(getMat("DARK_OAK_SIGN"));
51-
add(getMat("JUNGLE_SIGN"));
52-
add(getMat("OAK_SIGN"));
53-
add(getMat("SPRUCE_SIGN"));
54-
add(getMat("WARPED_SIGN"));
55-
add(getMat("CRIMSON_SIGN"));
46+
add(getMaterial("SIGN"));
47+
add(getMaterial("STANDING_SIGN"));
48+
add(getMaterial("ACACIA_SIGN"));
49+
add(getMaterial("BIRCH_SIGN"));
50+
add(getMaterial("DARK_OAK_SIGN"));
51+
add(getMaterial("JUNGLE_SIGN"));
52+
add(getMaterial("OAK_SIGN"));
53+
add(getMaterial("SPRUCE_SIGN"));
54+
add(getMaterial("WARPED_SIGN"));
55+
add(getMaterial("CRIMSON_SIGN"));
5656
}
5757
};
5858

@@ -65,16 +65,16 @@ public class MaterialUtils {
6565

6666
public static final Set<Material> DOORS = new HashSet<Material>() {
6767
{
68-
add(getMat("WOODEN_DOOR"));
69-
add(getMat("ACACIA_DOOR"));
70-
add(getMat("BIRCH_DOOR"));
71-
add(getMat("DARK_OAK_DOOR"));
72-
add(getMat("JUNGLE_DOOR"));
73-
add(getMat("SPRUCE_DOOR"));
74-
add(getMat("OAK_DOOR"));
75-
add(getMat("WOOD_DOOR"));
76-
add(getMat("WARPED_DOOR"));
77-
add(getMat("CRIMSON_DOOR"));
68+
add(getMaterial("WOODEN_DOOR"));
69+
add(getMaterial("ACACIA_DOOR"));
70+
add(getMaterial("BIRCH_DOOR"));
71+
add(getMaterial("DARK_OAK_DOOR"));
72+
add(getMaterial("JUNGLE_DOOR"));
73+
add(getMaterial("SPRUCE_DOOR"));
74+
add(getMaterial("OAK_DOOR"));
75+
add(getMaterial("WOOD_DOOR"));
76+
add(getMaterial("WARPED_DOOR"));
77+
add(getMaterial("CRIMSON_DOOR"));
7878
}
7979
};
8080

@@ -86,11 +86,7 @@ public static boolean isDoor(Material mat) {
8686
return DOORS.contains(mat);
8787
}
8888

89-
private static Material getMat(String name) {
90-
Material material = Material.getMaterial(name.toUpperCase());
91-
if(material == null) {
92-
material = XMaterial.OAK_SIGN.parseMaterial();
93-
}
94-
return material;
89+
private static Material getMaterial(String name) {
90+
return XMaterial.matchXMaterial(name.toUpperCase()).orElse(XMaterial.OAK_DOOR).get();
9591
}
9692
}

0 commit comments

Comments
 (0)