Compare commits
No commits in common. "32c1881d95d03bdb0de62ba79a22d775e895e8fa" and "693d03efaf9deb02f34402606d49400b7a45ead8" have entirely different histories.
32c1881d95
...
693d03efaf
7 changed files with 64 additions and 36 deletions
|
|
@ -30,6 +30,14 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.googlecode.json-simple</groupId>
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
<artifactId>json-simple</artifactId>
|
<artifactId>json-simple</artifactId>
|
||||||
|
|
@ -51,7 +59,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mojang</groupId>
|
<groupId>com.mojang</groupId>
|
||||||
<artifactId>authlib</artifactId>
|
<artifactId>authlib</artifactId>
|
||||||
<version>6.0.58</version>
|
<version>6.0.54</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Listener, PreparedPlugin {
|
public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Listener, PreparedPlugin {
|
||||||
protected final Path dataDirectory;
|
protected final Path dataDirectory;
|
||||||
|
|
@ -32,6 +35,8 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
||||||
protected final Language language = new Language();
|
protected final Language language = new Language();
|
||||||
protected final SqlAdapter sqlAdapter = createSqlAdapter();
|
protected final SqlAdapter sqlAdapter = createSqlAdapter();
|
||||||
|
|
||||||
|
private ExecutorService singleThreadExecutor;
|
||||||
|
|
||||||
public BukkitPreparedPlugin() {
|
public BukkitPreparedPlugin() {
|
||||||
super();
|
super();
|
||||||
dataDirectory = getDataFolder().toPath();
|
dataDirectory = getDataFolder().toPath();
|
||||||
|
|
@ -173,6 +178,10 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
||||||
closeSqlAdapter();
|
closeSqlAdapter();
|
||||||
defaultConfig.clear();
|
defaultConfig.clear();
|
||||||
|
|
||||||
|
if (singleThreadExecutor != null) {
|
||||||
|
singleThreadExecutor.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
BukkitUtils.unregisterCommandIf(command -> command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin() == this);
|
BukkitUtils.unregisterCommandIf(command -> command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin() == this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,4 +195,18 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
||||||
disable();
|
disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runTaskSeparately(Runnable runnable) {
|
||||||
|
if (singleThreadExecutor == null) {
|
||||||
|
singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
singleThreadExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
|
runnable.run();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
getLogger().log(Level.SEVERE, "Unhandled exception while running separated task", throwable);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,7 @@ class BukkitReflectionUtils {
|
||||||
private static class ModernGameProfileConsumer implements GameProfileConsumer {
|
private static class ModernGameProfileConsumer implements GameProfileConsumer {
|
||||||
private final Class<?> __ResolvableProfile_CLASS = ReflectionUtils.getType("net.minecraft.world.item.component.ResolvableProfile");
|
private final Class<?> __ResolvableProfile_CLASS = ReflectionUtils.getType("net.minecraft.world.item.component.ResolvableProfile");
|
||||||
private final Constructor<?> __ResolvableProfile_CONSTRUCTOR;
|
private final Constructor<?> __ResolvableProfile_CONSTRUCTOR;
|
||||||
protected final Method __setProfile__CraftMetaSkull__METHOD = ReflectionUtils.methodSearcher()
|
protected final Method __setProfile__CraftMetaSkull__METHOD = ReflectionUtils.getMethod(__ResolvableProfile_CLASS, "setProfile", __ResolvableProfile_CLASS);
|
||||||
.type(__CraftMetaSkull__CLASS)
|
|
||||||
.methodOf("setProfile")
|
|
||||||
.parameters(__ResolvableProfile_CLASS)
|
|
||||||
.returns(void.class)
|
|
||||||
.search();
|
|
||||||
|
|
||||||
ModernGameProfileConsumer() {
|
ModernGameProfileConsumer() {
|
||||||
Constructor<?> resolvableConstructor;
|
Constructor<?> resolvableConstructor;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ import org.zhdev.reflection.MethodSearcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
@ -27,12 +25,6 @@ public class ReflectionUtils {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Constructor<?> getConstructor0(Class<?> type, Class<?>... parameterTypes) throws NoSuchMethodException {
|
|
||||||
Constructor<?> constructor = type.getDeclaredConstructor(parameterTypes);
|
|
||||||
constructor.setAccessible(true);
|
|
||||||
return constructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean compareParameters(Class<?>[] required, Class<?>... parameters) {
|
private static boolean compareParameters(Class<?>[] required, Class<?>... parameters) {
|
||||||
if (required.length != parameters.length) {
|
if (required.length != parameters.length) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -182,22 +174,6 @@ public class ReflectionUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Constructor<?> getConstructor(Class<?> type, Class<?>... parameterTypes) throws NoSuchMethodError {
|
|
||||||
try {
|
|
||||||
return getConstructor0(type, parameterTypes);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new NoSuchMethodError(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object newInstance(Constructor<?> constructor, Object... args) throws NoSuchMethodError {
|
|
||||||
try {
|
|
||||||
return constructor.newInstance(args);
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void forEachClass(ClassLoader loader, JarFile jarFile, String packageName, Consumer<Class<?>> consumer) {
|
public static void forEachClass(ClassLoader loader, JarFile jarFile, String packageName, Consumer<Class<?>> consumer) {
|
||||||
for (Enumeration<JarEntry> entry = jarFile.entries(); entry.hasMoreElements(); ) {
|
for (Enumeration<JarEntry> entry = jarFile.entries(); entry.hasMoreElements(); ) {
|
||||||
JarEntry jarEntry = entry.nextElement();
|
JarEntry jarEntry = entry.nextElement();
|
||||||
|
|
|
||||||
|
|
@ -23,19 +23,19 @@
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>3.42.0.0</version>
|
<version>3.42.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>2.2.220</version>
|
<version>2.2.220</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<version>9.2.0</version>
|
<version>8.2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
26
pom.xml
26
pom.xml
|
|
@ -52,6 +52,32 @@
|
||||||
<target>8</target>
|
<target>8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
<configuration>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/**</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.velocitypowered</groupId>
|
<groupId>com.velocitypowered</groupId>
|
||||||
<artifactId>velocity-api</artifactId>
|
<artifactId>velocity-api</artifactId>
|
||||||
<version>3.4.0-SNAPSHOT</version>
|
<version>3.1.2-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue