Skip to content

Commit 93f7285

Browse files
committed
Remove unused NMS modules; misc. cleanup
1 parent b29cf43 commit 93f7285

265 files changed

Lines changed: 260 additions & 20064 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

COMPILING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This project depends on NMS, which shouldn't be redistributed. This means you'll have to build some of the dependencies yourself. (TODO: a script/tool for this would be handy)
44

55
How to compile:
6-
1. Use BuildTools normally and create a (remapped when supported) jar for every NMS version UC depends on. At the time of writing, the versions are: 1.8, 1.8.3, 1.8.8, 1.9.2, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.3, 1.16.4, 1.17.1\*, and 1.18.1\*. Dropping some of these versions is being considered.
6+
1. Use BuildTools normally and create a (remapped when supported) jar for every NMS version UC depends on. At the time of writing, the versions are: 1.8.8, 1.12.2, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.3, 1.16.4, 1.17.1\*, and 1.18.1\*.
77
2. Download [SpecialSource](https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.11.0/SpecialSource-1.11.0-shaded.jar) and put it at `tooling/specialsource/SpecialSource.jar` in the UC folder.
88
3. Open a shell in the UC folder, and run `./gradlew clean obfuscate`. Using tasks `build` or `jar` will not produce a jar that works with 1.17 and up because of the new mappings. `clean` is sometimes required for some reason.
99
4. The built UC jar is at `build/libs/UltraCosmetics-<version>-RELEASE.jar`. Do NOT use the other jar that ends in `-obf.jar`, it won't work.

core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private void registerListeners() {
307307
pluginManager.registerEvents(new MainListener(), this);
308308
pluginManager.registerEvents(new EntitySpawningManager(), this);
309309

310-
if (UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_9_R1)) {
310+
if (UltraCosmeticsData.get().getServerVersion().offhandAvailable()) {
311311
pluginManager.registerEvents(new PlayerSwapItemListener(this), this);
312312
}
313313

core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,14 @@ void initModule() {
140140
}
141141

142142
boolean checkServerVersion() {
143+
String versionString = Bukkit.getServer().getClass().getPackage().getName();
143144
String mcVersion;
144145
try {
145-
mcVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
146+
mcVersion = versionString.split("\\.")[3];
146147
} catch (ArrayIndexOutOfBoundsException e) {
147-
// TODO: maybe just disable the plugin if this happens? I'm not sure why selecting
148-
// the earliest available module when version can't be determined is a good option
149-
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "Unable to determine server version. Please report this error.");
150-
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "UC will attempt to continue using NMS " + ServerVersion.earliest().getName() + ", but you will probably experience issues.");
151-
setServerVersion(ServerVersion.earliest());
152-
return true;
148+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "Unable to determine server version. Please report this error.");
149+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "Version string: " + versionString);
150+
return false;
153151
}
154152

155153
ServerVersion serverVersion;
@@ -158,7 +156,7 @@ boolean checkServerVersion() {
158156
serverVersion = ServerVersion.valueOf(mcVersion);
159157
} catch (IllegalArgumentException exc) {
160158
ultraCosmetics.getSmartLogger().write("This NMS version isn't supported. (" + mcVersion + ")!");
161-
System.out.println("----------------------------\n\nULTRACOSMETICS CAN ONLY RUN ON " + ServerVersion.earliest().getName() + " through " + ServerVersion.latest().getName() + "!\n\n----------------------------");
159+
System.out.println("----------------------------\n\nULTRACOSMETICS CAN ONLY RUN ON " + ServerVersion.earliest().getName() + " or " + ServerVersion.v1_12_R1.getName() + " through " + ServerVersion.latest().getName() + "!\n\n----------------------------");
162160
Bukkit.getPluginManager().disablePlugin(ultraCosmetics);
163161
return false;
164162
}

core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/Gadget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public void onPlayerInteract(final PlayerInteractEvent event) {
370370
return;
371371
if (event.getAction() == Action.PHYSICAL)
372372
return;
373-
if (UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_9_R1)) {
373+
if (UltraCosmeticsData.get().getServerVersion().offhandAvailable()) {
374374
if (event.getHand() != null && event.getHand() == EquipmentSlot.OFF_HAND) {
375375
return;
376376
}

core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/GadgetDiscoBall.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void onUpdate() {
7676
if (armorStand != null && armorStand.isValid() && running) {
7777
armorStand.setHeadPose(armorStand.getHeadPose().add(0, 0.2, 0));
7878

79-
if (UltraCosmeticsData.get().getServerVersion().compareTo(ServerVersion.v1_9_R1) < 0) {
79+
if (UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_8_R3) {
8080
armorStand.setHelmet(ItemFactory.createColored("STAINED_GLASS", (byte) r.nextInt(15), " "));
8181
}
8282

core/src/main/java/be/isach/ultracosmetics/cosmetics/type/CosmeticType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public T equip(UltraPlayer player, UltraCosmetics ultraCosmetics) {
5757
}
5858

5959
public boolean isEnabled() {
60-
return !(this == GadgetType.valueOf("etherealpearl") && (UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_11_R1 || UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_12_R1))
60+
return !(this == GadgetType.valueOf("etherealpearl") && UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_12_R1)
6161
&& SettingsManager.getConfig().getBoolean(category.getConfigPath() + "." + configName + ".Enabled") && UltraCosmeticsData.get().getServerVersion().isAtLeast(baseVersion);
6262
}
6363

core/src/main/java/be/isach/ultracosmetics/cosmetics/type/MorphType.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,10 @@ public static void register() {
8888
new MorphType("ultracosmetics.morphs.mooshroom", "Mooshroom", UCMaterial.RED_MUSHROOM, DisguiseType.MUSHROOM_COW, "&7&oMoooo!", MorphMooshroom.class, ServerVersion.earliest());
8989
new MorphType("ultracosmetics.morphs.villager", "Villager", UCMaterial.EMERALD, DisguiseType.VILLAGER, "&7&oHmmmmmmmmm", MorphVillager.class, ServerVersion.earliest());
9090

91-
if (serverVersion.isAtLeast(ServerVersion.v1_9_R1)) {
92-
new MorphType("ultracosmetics.morphs.witch", "Witch", UCMaterial.POISONOUS_POTATO, getDisguiseType("WITCH"), "&7&oMuahahahahaha", MorphWitch.class, ServerVersion.v1_9_R1);
93-
}
94-
if (serverVersion.isAtLeast(ServerVersion.v1_10_R1)) {
95-
new MorphType("ultracosmetics.morphs.polarbear", "PolarBear", UCMaterial.SNOW_BLOCK, getDisguiseType("POLAR_BEAR"), "&7&oI prefer cold areas", MorphPolarBear.class, ServerVersion.v1_10_R1);
96-
}
97-
if (serverVersion.isAtLeast(ServerVersion.v1_11_R1)) {
98-
new MorphType("ultracosmetics.morphs.llama", "Llama", UCMaterial.RED_WOOL, getDisguiseType("LLAMA"), "&7&oNeed me to carry anything?", MorphLlama.class, ServerVersion.v1_11_R1);
99-
}
10091
if (serverVersion.isAtLeast(ServerVersion.v1_12_R1)) {
92+
new MorphType("ultracosmetics.morphs.witch", "Witch", UCMaterial.POISONOUS_POTATO, getDisguiseType("WITCH"), "&7&oMuahahahahaha", MorphWitch.class, ServerVersion.v1_12_R1);
93+
new MorphType("ultracosmetics.morphs.polarbear", "PolarBear", UCMaterial.SNOW_BLOCK, getDisguiseType("POLAR_BEAR"), "&7&oI prefer cold areas", MorphPolarBear.class, ServerVersion.v1_12_R1);
94+
new MorphType("ultracosmetics.morphs.llama", "Llama", UCMaterial.RED_WOOL, getDisguiseType("LLAMA"), "&7&oNeed me to carry anything?", MorphLlama.class, ServerVersion.v1_12_R1);
10195
new MorphType("ultracosmetics.morphs.parrot", "Parrot", UCMaterial.COOKIE, getDisguiseType("PARROT"), "&7&oPolly want a cracker?", MorphParrot.class, ServerVersion.v1_12_R1);
10296
}
10397

core/src/main/java/be/isach/ultracosmetics/cosmetics/type/PetType.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,9 @@ public static void register() {
9696
new PetType("ultracosmetics.pets.villager", "Villager", UCMaterial.EMERALD, "&7&oHmmmmmmmmm", EntityType.VILLAGER, PetVillager.class, ServerVersion.earliest());
9797
new PetType("ultracosmetics.pets.bat", "Bat", UCMaterial.COAL, "&7&oI prefer dark areas", EntityType.BAT, PetBat.class, ServerVersion.earliest());
9898

99-
if (serverVersion.isAtLeast(ServerVersion.v1_10_R1)) {
100-
new PetType("ultracosmetics.pets.polarbear", "PolarBear", UCMaterial.SNOW_BLOCK, "&7&oI prefer cold areas", GetForVersion.entityType("POLAR_BEAR"), PetPolarBear.class, ServerVersion.v1_10_R1);
101-
}
102-
if (serverVersion.isAtLeast(ServerVersion.v1_11_R1)) {
103-
new PetType("ultracosmetics.pets.llama", "Llama", UCMaterial.RED_WOOL, "&7&oNeed me to carry anything?", GetForVersion.entityType("LLAMA"), PetLlama.class, ServerVersion.v1_11_R1);
104-
}
10599
if (serverVersion.isAtLeast(ServerVersion.v1_12_R1)) {
100+
new PetType("ultracosmetics.pets.polarbear", "PolarBear", UCMaterial.SNOW_BLOCK, "&7&oI prefer cold areas", GetForVersion.entityType("POLAR_BEAR"), PetPolarBear.class, ServerVersion.v1_12_R1);
101+
new PetType("ultracosmetics.pets.llama", "Llama", UCMaterial.RED_WOOL, "&7&oNeed me to carry anything?", GetForVersion.entityType("LLAMA"), PetLlama.class, ServerVersion.v1_12_R1);
106102
new PetType("ultracosmetics.pets.parrot", "Parrot", UCMaterial.COOKIE, "&7&oPolly want a cracker?", GetForVersion.entityType("PARROT"), PetParrot.class, ServerVersion.v1_12_R1);
107103
}
108104

core/src/main/java/be/isach/ultracosmetics/treasurechests/TreasureChest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,7 @@ public void forceOpen(int delay) {
381381
this.items.add(entity);
382382
final String nameas = this.randomGenerator.getName();
383383
Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () ->
384-
spawnHologram(b.getLocation().clone().add(0.5D, UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_9_R1 ?
385-
-0.7 : 0.3D, 0.5D), nameas), 15L);
384+
spawnHologram(b.getLocation().clone().add(0.5D, 0.3D, 0.5D), nameas), 15L);
386385

387386
this.chestsLeft -= 1;
388387
this.chestsToRemove.add(b);
@@ -427,10 +426,6 @@ public void onBreakBlock(BlockBreakEvent event) {
427426
}
428427

429428
private void spawnHologram(Location location, String s) {
430-
if (UltraCosmeticsData.get().getServerVersion().compareTo(ServerVersion.v1_9_R1) > 0
431-
&& UltraCosmeticsData.get().getServerVersion().compareTo(ServerVersion.v1_11_R1) < 0) {
432-
location.setY(location.getY() - 1);
433-
}
434429
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.valueOf("ARMOR_STAND"));
435430
armorStand.setSmall(true);
436431
armorStand.setVisible(false);
@@ -466,8 +461,7 @@ public void onInter(final PlayerInteractEvent event) {
466461
this.items.add(itemEntity);
467462
final String nameas = this.randomGenerator.getName();
468463
Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () ->
469-
spawnHologram(event.getClickedBlock().getLocation().add(0.5D, UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_9_R1 ?
470-
-0.7 : 0.3D, 0.5D), nameas), 15L);
464+
spawnHologram(event.getClickedBlock().getLocation().add(0.5D, 0.3D, 0.5D), nameas), 15L);
471465

472466
this.chestsLeft -= 1;
473467
this.chests.remove(event.getClickedBlock());

core/src/main/java/be/isach/ultracosmetics/util/ItemFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static void fillInventory(Inventory inventory) {
107107
}
108108

109109
public static Material fromId(int id) {
110-
if (UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_13_R1)) {
110+
if (UltraCosmeticsData.get().getServerVersion().is113()) {
111111
return UCMaterial.matchUCMaterial(id, (byte) 0).parseMaterial();
112112
} else {
113113
for (Material m : EnumSet.allOf(Material.class)) {

0 commit comments

Comments
 (0)