Compare commits
7 commits
693d03efaf
...
32c1881d95
| Author | SHA1 | Date | |
|---|---|---|---|
| 32c1881d95 | |||
| 23acc54f16 | |||
| b177d41ea8 | |||
| bc9bacebb3 | |||
| 829b6ebebd | |||
| df77c315a7 | |||
| 04f9fe30ae |
7 changed files with 36 additions and 64 deletions
|
|
@ -30,14 +30,6 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
|
|
@ -59,7 +51,7 @@
|
|||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>authlib</artifactId>
|
||||
<version>6.0.54</version>
|
||||
<version>6.0.58</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@ import java.io.File;
|
|||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
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 {
|
||||
protected final Path dataDirectory;
|
||||
|
|
@ -35,8 +32,6 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
|||
protected final Language language = new Language();
|
||||
protected final SqlAdapter sqlAdapter = createSqlAdapter();
|
||||
|
||||
private ExecutorService singleThreadExecutor;
|
||||
|
||||
public BukkitPreparedPlugin() {
|
||||
super();
|
||||
dataDirectory = getDataFolder().toPath();
|
||||
|
|
@ -178,10 +173,6 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
|||
closeSqlAdapter();
|
||||
defaultConfig.clear();
|
||||
|
||||
if (singleThreadExecutor != null) {
|
||||
singleThreadExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
BukkitUtils.unregisterCommandIf(command -> command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin() == this);
|
||||
}
|
||||
|
||||
|
|
@ -195,18 +186,4 @@ public abstract class BukkitPreparedPlugin extends BukkitPlugin implements Liste
|
|||
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,7 +54,12 @@ class BukkitReflectionUtils {
|
|||
private static class ModernGameProfileConsumer implements GameProfileConsumer {
|
||||
private final Class<?> __ResolvableProfile_CLASS = ReflectionUtils.getType("net.minecraft.world.item.component.ResolvableProfile");
|
||||
private final Constructor<?> __ResolvableProfile_CONSTRUCTOR;
|
||||
protected final Method __setProfile__CraftMetaSkull__METHOD = ReflectionUtils.getMethod(__ResolvableProfile_CLASS, "setProfile", __ResolvableProfile_CLASS);
|
||||
protected final Method __setProfile__CraftMetaSkull__METHOD = ReflectionUtils.methodSearcher()
|
||||
.type(__CraftMetaSkull__CLASS)
|
||||
.methodOf("setProfile")
|
||||
.parameters(__ResolvableProfile_CLASS)
|
||||
.returns(void.class)
|
||||
.search();
|
||||
|
||||
ModernGameProfileConsumer() {
|
||||
Constructor<?> resolvableConstructor;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import org.zhdev.reflection.MethodSearcher;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Enumeration;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -25,6 +27,12 @@ public class ReflectionUtils {
|
|||
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) {
|
||||
if (required.length != parameters.length) {
|
||||
return false;
|
||||
|
|
@ -174,6 +182,22 @@ 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) {
|
||||
for (Enumeration<JarEntry> entry = jarFile.entries(); entry.hasMoreElements(); ) {
|
||||
JarEntry jarEntry = entry.nextElement();
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@
|
|||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.42.0.0</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.220</version>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.2.0</version>
|
||||
<scope>compile</scope>
|
||||
<version>9.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
26
pom.xml
26
pom.xml
|
|
@ -52,32 +52,6 @@
|
|||
<target>8</target>
|
||||
</configuration>
|
||||
</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>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.2-SNAPSHOT</version>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue