Including mockito prevents testing deps from shading

This commit is contained in:
fullwall 2022-06-08 12:48:58 +08:00
parent c75b4422ea
commit 2a6a69d8be
4 changed files with 192 additions and 188 deletions

View File

@ -1,189 +1,200 @@
<!-- Citizens build file -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.30-SNAPSHOT</version>
</parent>
<artifactId>citizens-main</artifactId>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.30-SNAPSHOT</version>
</parent>
<artifactId>citizens-main</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.19-R0.1-SNAPSHOT</craftbukkit.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
<citizensapi.version>${project.version}</citizensapi.version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.19-R0.1-SNAPSHOT</craftbukkit.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
<citizensapi.version>${project.version}</citizensapi.version>
<worldguard.version>7.0.4</worldguard.version>
</properties>
<powermock.version>1.4.12</powermock.version>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>everything</id>
<url>https://repo.citizensnpcs.co</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>everything</id>
<url>https://repo.citizensnpcs.co</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${craftbukkit.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
<version>3.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>${citizensapi.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>${placeholderapi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${craftbukkit.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
<version>3.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>${citizensapi.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>${placeholderapi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>${worldguard.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencies>
<url>http://www.citizensnpcs.co</url>
<ciManagement>
<system>jenkins</system>
<url>http://ci.citizensnpcs.co</url>
</ciManagement>
<scm>
<connection>scm:git:git://github.com/CitizensDev/Citizens2.git</connection>
<developerConnection>scm:git:git:@github.com:CitizensDev/Citizens2.git</developerConnection>
<url>https://github.com/CitizensDev/Citizens2/tree/master/</url>
</scm>
<build>
<defaultGoal>clean package install javadoc:javadoc</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<url>http://www.citizensnpcs.co</url>
<ciManagement>
<system>jenkins</system>
<url>http://ci.citizensnpcs.co</url>
</ciManagement>
<scm>
<connection>scm:git:git://github.com/CitizensDev/Citizens2.git</connection>
<developerConnection>scm:git:git:@github.com:CitizensDev/Citizens2.git</developerConnection>
<url>https://github.com/CitizensDev/Citizens2/tree/master/</url>
</scm>
<build>
<defaultGoal>clean package install javadoc:javadoc</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>plugin.yml</include>
<include>*.properties</include>
</includes>
</resource>
</resources>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>plugin.yml</include>
<include>*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>net.citizensnpcs:citizensapi</artifact>
<includes>
<include>**</include>
</includes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>gnu.trove</pattern>
<shadedPattern>lib.trove</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>net.citizensnpcs.util.metrics</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>net.citizensnpcs:citizensapi</artifact>
<includes>
<include>**</include>
</includes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>gnu.trove</pattern>
<shadedPattern>lib.trove</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>net.citizensnpcs.util.metrics</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<source>8</source>
<author>false</author>
<doclint>none</doclint>
<links>
<link>https://hub.spigotmc.org/javadocs/spigot</link>
</links>
<includeDependencySources>true</includeDependencySources>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<source>8</source>
<author>false</author>
<doclint>none</doclint>
<links>
<link>https://hub.spigotmc.org/javadocs/spigot</link>
</links>
<includeDependencySources>true</includeDependencySources>
<dependencySourceIncludes>
<dependencySourceInclude>net.citizensnpcs:citizensapi</dependencySourceInclude>
</dependencySourceIncludes>
<excludePackageNames>net.citizensnpcs.commands</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</project>
<dependencySourceIncludes>
<dependencySourceInclude>net.citizensnpcs:citizensapi</dependencySourceInclude>
</dependencySourceIncludes>
<excludePackageNames>net.citizensnpcs.commands</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -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 + '.');

View File

@ -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) {

View File

@ -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();
}
}