Skip to content

Commit 3646858

Browse files
committed
v8.7.0
XMaterial Fixed YELLOW_GLAZED_TERRACOTTA, SILVER_GLAZED_TERRACOTTA, END_STONE_BRICK_STAIRS and a lot slabs for outdated servers. Fixed potion / splash potion checks in 1.8.8 XEntity Added support for two illager methods. Patrol leader and join raid. All options that represent a color are named to "color" and all options that represent a variant/type are renamed to variant. All the "type" options are now renamed to "variant" XItemStack They now support editing itemstacks rather than constructing them from scratch. The "glow" option will now automatically enable HIDE_ENCHANTS flag. Removed \n single line support for lore. If you genuinely want to break line just use a simple list. There's no reason to use \n instead. It no longer translates colors automatically. It'll use the passed function translator instead. ActionBar Added a format for configuring ActionBar time from the message string itself. Note that you need to use the new method (which is just plugin,player,string) for this to work. ReflectionUtils Fixed a version detection error in 1.13
1 parent a9324ac commit 3646858

File tree

6 files changed

+246
-132
lines changed

6 files changed

+246
-132
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
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.2</version>
9+
<version>8.7.0</version>
1010

1111
<name>XSeries</name>
1212
<description>A set of utilities for Minecraft plugins</description>
@@ -63,7 +63,7 @@
6363

6464
<properties>
6565
<!-- Latest version -->
66-
<spigotVersion>1.18.1-R0.1-SNAPSHOT</spigotVersion>
66+
<spigotVersion>1.18.2-R0.1-SNAPSHOT</spigotVersion>
6767
</properties>
6868

6969
<dependencies>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@ public final class ReflectionUtils {
6767
String found = null;
6868
for (Package pack : Package.getPackages()) {
6969
String name = pack.getName();
70-
if (name.startsWith("org.bukkit.craftbukkit.v") // .v because there are other packages.
71-
// As a protection for forge+bukkit implementation that tend to mix versions.
72-
// The real CraftPlayer should exist in the package.
73-
// Note: Doesn't seem to function properly. Will need to separate the version
74-
// handler for NMS and CraftBukkit for softwares like catmc.
75-
&& name.endsWith("entity")) {
70+
71+
// .v because there are other packages.
72+
if (name.startsWith("org.bukkit.craftbukkit.v")) {
7673
found = pack.getName().split("\\.")[3];
7774

7875
// Just a final guard to make sure it finds this important class.
76+
// As a protection for forge+bukkit implementation that tend to mix versions.
77+
// The real CraftPlayer should exist in the package.
78+
// Note: Doesn't seem to function properly. Will need to separate the version
79+
// handler for NMS and CraftBukkit for softwares like catmc.
7980
try {
8081
Class.forName("org.bukkit.craftbukkit." + found + ".entity.CraftPlayer");
8182
break;

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

Lines changed: 84 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public static Entity edit(@Nonnull Entity entity, @Nonnull ConfigurationSection
317317
if (sheared) sheep.setSheared(true);
318318
} else if (living instanceof Rabbit) {
319319
Rabbit rabbit = (Rabbit) living;
320-
rabbit.setRabbitType(Enums.getIfPresent(Rabbit.Type.class, config.getString("rabbit-type")).or(Rabbit.Type.WHITE));
320+
rabbit.setRabbitType(Enums.getIfPresent(Rabbit.Type.class, config.getString("color")).or(Rabbit.Type.WHITE));
321321
} else if (living instanceof Bat) {
322322
Bat bat = (Bat) living;
323323
if (!config.getBoolean("awake")) bat.setAwake(false);
@@ -340,73 +340,23 @@ public static Entity edit(@Nonnull Entity entity, @Nonnull ConfigurationSection
340340
} else if (XMaterial.supports(12)) {
341341
if (living instanceof Parrot) {
342342
Parrot parrot = (Parrot) living;
343-
parrot.setVariant(Enums.getIfPresent(Parrot.Variant.class, config.getString("variant")).or(Parrot.Variant.RED));
344-
} else if (XMaterial.supports(13)) {
345-
if (living instanceof Husk) {
346-
Husk husk = (Husk) living;
347-
husk.setConversionTime(config.getInt("conversion-time"));
348-
} else if (living instanceof Vex) {
349-
Vex vex = (Vex) living;
350-
vex.setCharging(config.getBoolean("charging"));
351-
} else if (living instanceof PufferFish) {
352-
PufferFish pufferFish = (PufferFish) living;
353-
pufferFish.setPuffState(config.getInt("puff-state"));
354-
} else if (living instanceof TropicalFish) {
355-
TropicalFish tropicalFish = (TropicalFish) living;
356-
tropicalFish.setBodyColor(Enums.getIfPresent(DyeColor.class, config.getString("color")).or(DyeColor.WHITE));
357-
tropicalFish.setPattern(Enums.getIfPresent(TropicalFish.Pattern.class, config.getString("pattern")).or(TropicalFish.Pattern.BETTY));
358-
tropicalFish.setPatternColor(Enums.getIfPresent(DyeColor.class, config.getString("pattern-color")).or(DyeColor.WHITE));
359-
} else if (living instanceof EnderDragon) {
360-
EnderDragon dragon = (EnderDragon) living;
361-
dragon.setPhase(Enums.getIfPresent(EnderDragon.Phase.class, config.getString("phase")).or(EnderDragon.Phase.ROAR_BEFORE_ATTACK));
362-
} else if (living instanceof Phantom) {
363-
Phantom phantom = (Phantom) living;
364-
phantom.setSize(config.getInt("size"));
365-
} else if (XMaterial.supports(14)) {
366-
if (living instanceof Cat) {
367-
Cat cat = (Cat) living;
368-
cat.setCatType(Enums.getIfPresent(Cat.Type.class, config.getString("cat-type")).or(Cat.Type.TABBY));
369-
cat.setCollarColor(Enums.getIfPresent(DyeColor.class, config.getString("color")).or(DyeColor.GREEN));
370-
} else if (living instanceof Fox) {
371-
Fox fox = (Fox) living;
372-
fox.setCrouching(config.getBoolean("crouching"));
373-
fox.setSleeping(config.getBoolean("sleeping"));
374-
fox.setFoxType(Enums.getIfPresent(Fox.Type.class, config.getString("type")).or(Fox.Type.RED));
375-
} else if (living instanceof Panda) {
376-
Panda panda = (Panda) living;
377-
panda.setHiddenGene(Enums.getIfPresent(Panda.Gene.class, config.getString("hidden-gene")).or(Panda.Gene.PLAYFUL));
378-
panda.setMainGene(Enums.getIfPresent(Panda.Gene.class, config.getString("main-gene")).or(Panda.Gene.NORMAL));
379-
} else if (living instanceof MushroomCow) {
380-
MushroomCow mooshroom = (MushroomCow) living;
381-
mooshroom.setVariant(Enums.getIfPresent(MushroomCow.Variant.class, config.getString("variant")).or(MushroomCow.Variant.RED));
382-
} else if (XMaterial.supports(15)) {
383-
if (living instanceof Bee) {
384-
Bee bee = (Bee) living;
385-
// Anger time ticks.
386-
bee.setAnger(config.getInt("anger") * 20);
387-
bee.setHasNectar(config.getBoolean("nectar"));
388-
bee.setHasStung(config.getBoolean("stung"));
389-
bee.setCannotEnterHiveTicks(config.getInt("disallow-hive") * 20);
390-
} else if (XMaterial.supports(16)) {
391-
if (living instanceof Hoglin) {
392-
Hoglin hoglin = (Hoglin) living;
393-
hoglin.setConversionTime(config.getInt("conversation") * 20);
394-
hoglin.setImmuneToZombification(config.getBoolean("zombification-immunity"));
395-
hoglin.setIsAbleToBeHunted(config.getBoolean("can-be-hunted"));
396-
} else if (living instanceof Piglin) {
397-
// Idk why Spigot did this...
398-
Piglin piglin = (Piglin) living;
399-
piglin.setConversionTime(config.getInt("conversation") * 20);
400-
piglin.setImmuneToZombification(config.getBoolean("zombification-immunity"));
401-
} else if (living instanceof Strider) {
402-
Strider strider = (Strider) living;
403-
strider.setShivering(config.getBoolean("shivering"));
404-
}
405-
406-
if (XMaterial.supports(17)) handleSeventeen(entity, config);
407-
}
408-
}
343+
parrot.setVariant(Enums.getIfPresent(Parrot.Variant.class, config.getString("color")).or(Parrot.Variant.RED));
344+
}
345+
346+
if (XMaterial.supports(13)) thirteen(entity, config);
347+
if (XMaterial.supports(14)) fourteen(entity, config);
348+
if (XMaterial.supports(15)) {
349+
if (living instanceof Bee) {
350+
Bee bee = (Bee) living;
351+
// Anger time ticks.
352+
bee.setAnger(config.getInt("anger") * 20);
353+
bee.setHasNectar(config.getBoolean("nectar"));
354+
bee.setHasStung(config.getBoolean("stung"));
355+
bee.setCannotEnterHiveTicks(config.getInt("disallow-hive") * 20);
409356
}
357+
358+
if (XMaterial.supports(16)) sixteen(entity, config);
359+
if (XMaterial.supports(17)) seventeen(entity, config);
410360
}
411361
}
412362
}
@@ -429,10 +379,76 @@ public static Entity edit(@Nonnull Entity entity, @Nonnull ConfigurationSection
429379
return entity;
430380
}
431381

382+
private static void fourteen(Entity entity, ConfigurationSection config) {
383+
if (entity instanceof Raider) {
384+
// Illagers were added in 1.11 but the concept of raids and patrols were added in 1.14
385+
Raider raider = (Raider) entity;
386+
if (config.isSet("can-join-raid")) raider.setCanJoinRaid(config.getBoolean("can-join-raid"));
387+
if (config.isSet("is-patrol-leader")) raider.setCanJoinRaid(config.getBoolean("is-patrol-leader"));
388+
} else if (entity instanceof Cat) {
389+
Cat cat = (Cat) entity;
390+
cat.setCatType(Enums.getIfPresent(Cat.Type.class, config.getString("variant")).or(Cat.Type.TABBY));
391+
cat.setCollarColor(Enums.getIfPresent(DyeColor.class, config.getString("color")).or(DyeColor.GREEN));
392+
} else if (entity instanceof Fox) {
393+
Fox fox = (Fox) entity;
394+
fox.setCrouching(config.getBoolean("crouching"));
395+
fox.setSleeping(config.getBoolean("sleeping"));
396+
fox.setFoxType(Enums.getIfPresent(Fox.Type.class, config.getString("color")).or(Fox.Type.RED));
397+
} else if (entity instanceof Panda) {
398+
Panda panda = (Panda) entity;
399+
panda.setHiddenGene(Enums.getIfPresent(Panda.Gene.class, config.getString("hidden-gene")).or(Panda.Gene.PLAYFUL));
400+
panda.setMainGene(Enums.getIfPresent(Panda.Gene.class, config.getString("main-gene")).or(Panda.Gene.NORMAL));
401+
} else if (entity instanceof MushroomCow) {
402+
MushroomCow mooshroom = (MushroomCow) entity;
403+
mooshroom.setVariant(Enums.getIfPresent(MushroomCow.Variant.class, config.getString("color")).or(MushroomCow.Variant.RED));
404+
}
405+
}
406+
407+
private static void thirteen(Entity entity, ConfigurationSection config) {
408+
if (entity instanceof Husk) {
409+
Husk husk = (Husk) entity;
410+
husk.setConversionTime(config.getInt("conversion-time"));
411+
} else if (entity instanceof Vex) {
412+
Vex vex = (Vex) entity;
413+
vex.setCharging(config.getBoolean("charging"));
414+
} else if (entity instanceof PufferFish) {
415+
PufferFish pufferFish = (PufferFish) entity;
416+
pufferFish.setPuffState(config.getInt("puff-state"));
417+
} else if (entity instanceof TropicalFish) {
418+
TropicalFish tropicalFish = (TropicalFish) entity;
419+
tropicalFish.setBodyColor(Enums.getIfPresent(DyeColor.class, config.getString("color")).or(DyeColor.WHITE));
420+
tropicalFish.setPattern(Enums.getIfPresent(TropicalFish.Pattern.class, config.getString("pattern")).or(TropicalFish.Pattern.BETTY));
421+
tropicalFish.setPatternColor(Enums.getIfPresent(DyeColor.class, config.getString("pattern-color")).or(DyeColor.WHITE));
422+
} else if (entity instanceof EnderDragon) {
423+
EnderDragon dragon = (EnderDragon) entity;
424+
dragon.setPhase(Enums.getIfPresent(EnderDragon.Phase.class, config.getString("phase")).or(EnderDragon.Phase.ROAR_BEFORE_ATTACK));
425+
} else if (entity instanceof Phantom) {
426+
Phantom phantom = (Phantom) entity;
427+
phantom.setSize(config.getInt("size"));
428+
}
429+
}
430+
431+
private static void sixteen(Entity entity, ConfigurationSection config) {
432+
if (entity instanceof Hoglin) {
433+
Hoglin hoglin = (Hoglin) entity;
434+
hoglin.setConversionTime(config.getInt("conversation") * 20);
435+
hoglin.setImmuneToZombification(config.getBoolean("zombification-immunity"));
436+
hoglin.setIsAbleToBeHunted(config.getBoolean("can-be-hunted"));
437+
} else if (entity instanceof Piglin) {
438+
// Idk why Spigot did this...
439+
Piglin piglin = (Piglin) entity;
440+
piglin.setConversionTime(config.getInt("conversation") * 20);
441+
piglin.setImmuneToZombification(config.getBoolean("zombification-immunity"));
442+
} else if (entity instanceof Strider) {
443+
Strider strider = (Strider) entity;
444+
strider.setShivering(config.getBoolean("shivering"));
445+
}
446+
}
447+
432448
/**
433449
* AXOLOTL - GLOW_ITEM_FRAME - GLOW_SQUID - GOAT - MARKER
434450
*/
435-
private static boolean handleSeventeen(Entity entity, ConfigurationSection config) {
451+
private static boolean seventeen(Entity entity, ConfigurationSection config) {
436452
if (entity instanceof Axolotl) {
437453
Axolotl axolotl = (Axolotl) entity;
438454
String variantStr = config.getString("variant");

0 commit comments

Comments
 (0)