Skip to content

Commit 38964a5

Browse files
committed
8.6.1
XMaterial Fixed DRAGON_HEAD in pre-1.13 Fixed ink sacks matching black dye in pre-1.13 Fixed spawn eggs for pre-1.13 XPotion Fixed initialization error. Fixed INSTANT_DAMAGE potion on 1.8
1 parent d8359cb commit 38964a5

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: java
22
install: true
3-
# Hoping it uses JDK 17+ for it to compile 1.18 classes.
3+
# Should always use the latest JDK
44
jdk: openjdk17
55
script: mvn install -Dgpg.skip=true -Dmaven.javadoc.skip=true -B -ntp

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.cryptomorin</groupId>
88
<artifactId>XSeries</artifactId>
9-
<version>8.6.0.0.1</version>
9+
<version>8.6.1</version>
1010

1111
<name>XSeries</name>
1212
<description>A set of utilities for Minecraft plugins</description>

src/main/java/com/cryptomorin/xseries/XMaterial.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import org.bukkit.Bukkit;
3232
import org.bukkit.Material;
3333
import org.bukkit.inventory.ItemStack;
34+
import org.bukkit.inventory.meta.ItemMeta;
35+
import org.bukkit.inventory.meta.SpawnEggMeta;
3436

3537
import javax.annotation.Nonnull;
3638
import javax.annotation.Nullable;
@@ -163,7 +165,7 @@ public enum XMaterial {
163165
BLACK_CARPET(15, "CARPET"),
164166
BLACK_CONCRETE(15, "CONCRETE"),
165167
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
166-
BLACK_DYE("INK_SACK", "INK_SAC"),
168+
BLACK_DYE,
167169
BLACK_GLAZED_TERRACOTTA,
168170
BLACK_SHULKER_BOX,
169171
BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
@@ -465,7 +467,7 @@ public enum XMaterial {
465467
DONKEY_SPAWN_EGG(32, "MONSTER_EGG"),
466468
DRAGON_BREATH("DRAGONS_BREATH"),
467469
DRAGON_EGG,
468-
DRAGON_HEAD("SKULL", "SKULL_ITEM"),
470+
DRAGON_HEAD(5, "SKULL", "SKULL_ITEM"),
469471
DRAGON_WALL_HEAD(5, "SKULL", "SKULL_ITEM"),
470472
DRIED_KELP,
471473
DRIED_KELP_BLOCK,
@@ -1682,11 +1684,21 @@ public static XMaterial matchXMaterial(@Nonnull ItemStack item) {
16821684
String material = item.getType().name();
16831685
byte data = (byte) (Data.ISFLAT || item.getType().getMaxDurability() > 0 ? 0 : item.getDurability());
16841686

1687+
if (!Data.ISFLAT && item.hasItemMeta() && material.equals("MONSTER_EGG")) {
1688+
ItemMeta meta = item.getItemMeta();
1689+
if (meta instanceof SpawnEggMeta) {
1690+
SpawnEggMeta egg = (SpawnEggMeta) meta;
1691+
material = egg.getSpawnedType().name() + "_SPAWN_EGG";
1692+
}
1693+
}
1694+
16851695
// Check FILLED_MAP enum for more info.
16861696
//if (!Data.ISFLAT && item.hasItemMeta() && item.getItemMeta() instanceof org.bukkit.inventory.meta.MapMeta) return FILLED_MAP;
16871697

1688-
return matchDefinedXMaterial(material, data)
1689-
.orElseThrow(() -> new IllegalArgumentException("Unsupported material from item: " + material + " (" + data + ')'));
1698+
// No orElseThrow, I don't want to deal with all that final variable bullshit.
1699+
Optional<XMaterial> result = matchDefinedXMaterial(material, data);
1700+
if (result.isPresent()) return result.get();
1701+
throw new IllegalArgumentException("Unsupported material from item: " + material + " (" + data + ')');
16901702
}
16911703

16921704
/**

src/main/java/com/cryptomorin/xseries/XPotion.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public enum XPotion {
6969
FAST_DIGGING("HASTE", "SUPER_PICK", "DIGFAST", "DIG_SPEED", "QUICK_MINE", "SHARP"),
7070
FIRE_RESISTANCE("FIRE_RESIST", "RESIST_FIRE", "FIRE_RESISTANCE"),
7171
GLOWING("GLOW", "SHINE", "SHINY"),
72-
HARM("INJURE", "DAMAGE", "HARMING", "INFLICT"),
72+
HARM("INJURE", "DAMAGE", "HARMING", "INFLICT", "INSTANT_DAMAGE"),
7373
HEAL("HEALTH", "INSTA_HEAL", "INSTANT_HEAL", "INSTA_HEALTH", "INSTANT_HEALTH"),
7474
HEALTH_BOOST("BOOST_HEALTH", "BOOST", "HP"),
7575
HERO_OF_THE_VILLAGE("HERO", "VILLAGE_HERO"),
@@ -117,7 +117,9 @@ public enum XPotion {
117117
private static final XPotion[] POTIONEFFECTTYPE_MAPPING = new XPotion[VALUES.length + 1];
118118

119119
static {
120-
for (XPotion pot : VALUES) POTIONEFFECTTYPE_MAPPING[pot.type.getId()] = pot;
120+
for (XPotion pot : VALUES)
121+
if (pot.type != null) //noinspection deprecation
122+
POTIONEFFECTTYPE_MAPPING[pot.type.getId()] = pot;
121123
}
122124

123125
private final PotionEffectType type;
@@ -194,6 +196,7 @@ public static Optional<XPotion> matchXPotion(@Nonnull String potion) {
194196
* @throws IllegalArgumentException may be thrown as an unexpected exception.
195197
* @since 1.0.0
196198
*/
199+
@SuppressWarnings("deprecation")
197200
@Nonnull
198201
public static XPotion matchXPotion(@Nonnull PotionEffectType type) {
199202
Objects.requireNonNull(type, "Cannot match XPotion of a null potion effect type");

src/main/java/com/cryptomorin/xseries/XTag.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,14 +1999,6 @@ private static XMaterial[] findAllCorals(boolean alive, boolean block, boolean f
19991999
return list.toArray(new XMaterial[0]);
20002000
}
20012001

2002-
private static XMaterial[] filterCorals(String name) {
2003-
List<XMaterial> list = new ArrayList<>();
2004-
for (XMaterial value : CORALS.values) {
2005-
if (value.name().contains(name)) list.add(value);
2006-
}
2007-
return list.toArray(new XMaterial[0]);
2008-
}
2009-
20102002
/**
20112003
* Checks if this Material is an obtainable item. "Obtainable items" are simply materials that can be displayed in your GUI.
20122004
* This method is mainly designed to support pre-1.13, servers using 1.13 and above will directly have their materials checked with {@link Material#isItem()}

src/test/XSeriesTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import com.cryptomorin.xseries.ReflectionUtils;
2-
import com.cryptomorin.xseries.XMaterial;
3-
import com.cryptomorin.xseries.XPotion;
4-
import com.cryptomorin.xseries.XSound;
5-
import com.cryptomorin.xseries.XTag;
1+
import com.cryptomorin.xseries.*;
62
import com.cryptomorin.xseries.particles.ParticleDisplay;
73
import org.bukkit.Location;
84
import org.bukkit.Material;

0 commit comments

Comments
 (0)