From 2a6a69d8beb3447abf0d9f082c487f25511d3e54 Mon Sep 17 00:00:00 2001 From: fullwall Date: Wed, 8 Jun 2022 12:48:58 +0800 Subject: [PATCH] Including mockito prevents testing deps from shading --- main/pom.xml | 351 +++++++++--------- .../citizensnpcs/commands/NPCCommands.java | 18 +- .../main/java/net/citizensnpcs/trait/Age.java | 10 +- .../main/java/net/citizensnpcs/util/NMS.java | 1 - 4 files changed, 192 insertions(+), 188 deletions(-) diff --git a/main/pom.xml b/main/pom.xml index bb09d5b47..6e2f4aa1d 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -1,189 +1,200 @@ - - 4.0.0 - - net.citizensnpcs - citizens-parent - 2.0.30-SNAPSHOT - - citizens-main + + 4.0.0 + + net.citizensnpcs + citizens-parent + 2.0.30-SNAPSHOT + + citizens-main - - UTF-8 - 1.19-R0.1-SNAPSHOT - 2.10.9 - ${project.version} + + UTF-8 + 1.19-R0.1-SNAPSHOT + 2.10.9 + ${project.version} 7.0.4 - + 1.4.12 + - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - everything - https://repo.citizensnpcs.co - - - jitpack.io - https://jitpack.io - - false - - - - placeholderapi - http://repo.extendedclip.com/content/repositories/placeholderapi/ - - - sk89q-repo - https://maven.enginehub.org/repo/ - - + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + everything + https://repo.citizensnpcs.co + + + jitpack.io + https://jitpack.io + + false + + + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + + + sk89q-repo + https://maven.enginehub.org/repo/ + + - - - org.spigotmc - spigot - ${craftbukkit.version} - jar - provided - - - net.sf.trove4j - trove4j - 3.0.3 - compile - - - net.citizensnpcs - citizensapi - ${citizensapi.version} - jar - compile - - - me.clip - placeholderapi - ${placeholderapi.version} - provided - - - com.github.MilkBowl - VaultAPI - 1.7 - provided - + + + org.spigotmc + spigot + ${craftbukkit.version} + jar + provided + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito + ${powermock.version} + test + + + net.sf.trove4j + trove4j + 3.0.3 + compile + + + net.citizensnpcs + citizensapi + ${citizensapi.version} + jar + compile + + + me.clip + placeholderapi + ${placeholderapi.version} + provided + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + com.sk89q.worldguard worldguard-bukkit ${worldguard.version} provided - + - http://www.citizensnpcs.co - - jenkins - http://ci.citizensnpcs.co - - - scm:git:git://github.com/CitizensDev/Citizens2.git - scm:git:git:@github.com:CitizensDev/Citizens2.git - https://github.com/CitizensDev/Citizens2/tree/master/ - - - clean package install javadoc:javadoc - ${basedir}/src/main/java + http://www.citizensnpcs.co + + jenkins + http://ci.citizensnpcs.co + + + scm:git:git://github.com/CitizensDev/Citizens2.git + scm:git:git:@github.com:CitizensDev/Citizens2.git + https://github.com/CitizensDev/Citizens2/tree/master/ + + + clean package install javadoc:javadoc + ${basedir}/src/main/java - - - . - true - ${basedir}/src/main/resources - - plugin.yml - *.properties - - - + + + . + true + ${basedir}/src/main/resources + + plugin.yml + *.properties + + + - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + - - org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - package - - shade - - - true - false - - - net.citizensnpcs:citizensapi - - ** - - - - - - gnu.trove - lib.trove - - - org.bstats - net.citizensnpcs.util.metrics - - - - - - + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + true + false + + + net.citizensnpcs:citizensapi + + ** + + + + + + gnu.trove + lib.trove + + + org.bstats + net.citizensnpcs.util.metrics + + + + + + - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - 8 - false - none - - https://hub.spigotmc.org/javadocs/spigot - - true + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + 8 + false + none + + https://hub.spigotmc.org/javadocs/spigot + + true - - net.citizensnpcs:citizensapi - - net.citizensnpcs.commands - - - - - + + net.citizensnpcs:citizensapi + + net.citizensnpcs.commands + + + + + \ No newline at end of file diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 48ae0cb3e..ac22fde08 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -159,7 +159,8 @@ public class NPCCommands { max = 2, permission = "citizens.npc.age") public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException { - if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie))) + if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie) + && !npc.getEntity().getType().name().equals("TADPOLE"))) throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName()); Age trait = npc.getOrAddTrait(Age.class); boolean toggleLock = args.hasFlag('l'); @@ -570,13 +571,8 @@ public class NPCCommands { int age = 0; if (args.hasFlag('b')) { - if (!Ageable.class.isAssignableFrom(type.getEntityClass())) { - Messaging.sendErrorTr(sender, Messages.MOBTYPE_CANNOT_BE_AGED, - type.name().toLowerCase().replace("_", "-")); - } else { - age = -24000; - msg += " as a baby"; - } + age = -24000; + msg += " as a baby"; } if (args.hasFlag('s')) { npc.data().set(NPC.SILENT_METADATA, true); @@ -649,10 +645,8 @@ public class NPCCommands { msg += " with templates " + builder.toString(); } - // Set age after entity spawns - if (npc.getEntity() instanceof Ageable) { - npc.getOrAddTrait(Age.class).setAge(age); - } + npc.getOrAddTrait(Age.class).setAge(age); + selector.select(sender, npc); history.add(sender, new CreateNPCHistoryItem(npc)); Messaging.send(sender, msg + '.'); diff --git a/main/src/main/java/net/citizensnpcs/trait/Age.java b/main/src/main/java/net/citizensnpcs/trait/Age.java index f3aead041..eaa2658dc 100644 --- a/main/src/main/java/net/citizensnpcs/trait/Age.java +++ b/main/src/main/java/net/citizensnpcs/trait/Age.java @@ -2,6 +2,7 @@ package net.citizensnpcs.trait; import org.bukkit.command.CommandSender; import org.bukkit.entity.Ageable; +import org.bukkit.entity.Tadpole; import org.bukkit.entity.Zombie; import net.citizensnpcs.api.persistence.Persist; @@ -52,6 +53,9 @@ public class Age extends Trait implements Toggleable { } else if (npc.getEntity() instanceof Zombie) { ((Zombie) npc.getEntity()).setBaby(age < 0); ageable = null; + } else if (npc.getEntity().getType().name().equals("TADPOLE")) { + ((Tadpole) npc.getEntity()).setAge(age); + ageable = null; } else { ageable = null; } @@ -66,11 +70,7 @@ public class Age extends Trait implements Toggleable { public void setAge(int age) { this.age = age; - if (isAgeable()) { - ageable.setAge(age); - } else if (npc.getEntity() instanceof Zombie) { - ((Zombie) npc.getEntity()).setBaby(age < 0); - } + onSpawn(); } public void setLocked(boolean locked) { diff --git a/main/src/main/java/net/citizensnpcs/util/NMS.java b/main/src/main/java/net/citizensnpcs/util/NMS.java index 2922e2541..74bc12568 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMS.java +++ b/main/src/main/java/net/citizensnpcs/util/NMS.java @@ -402,7 +402,6 @@ public class NMS { } ADD_OPENS.invoke(GET_MODULE.invoke(from), from.getPackage().getName(), GET_MODULE.invoke(to)); } catch (Exception e) { - e.printStackTrace(); } }