mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-09 17:27:38 +01:00
Fix maven so it compiles
This commit is contained in:
parent
471076cbe1
commit
669cbcd142
@ -3,7 +3,7 @@
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0-ALPHA-16w38a</version>
|
||||
</parent>
|
||||
|
@ -37,8 +37,8 @@ public abstract class ViaListener implements Listener {
|
||||
* @return The UserConnection
|
||||
*/
|
||||
protected UserConnection getUserConnection(@NonNull UUID uuid) {
|
||||
if (!plugin.isPorted(uuid)) return null;
|
||||
return plugin.getConnection(uuid);
|
||||
if (!Via.getAPI().isPorted(uuid)) return null;
|
||||
return Via.getManager().getConnection(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ public class ViaVersion {
|
||||
|
||||
public static void setInstance(ViaVersionPlugin plugin) {
|
||||
Validate.isTrue(instance == null, "Instance is already set");
|
||||
ViaVersion.instance = plugin;
|
||||
ViaVersion.instance = (ViaVersionAPI) plugin.getApi();
|
||||
ViaVersion.config = plugin.getConf();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.platform.ViaInjector;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
||||
@ -23,12 +24,11 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
private List<Pair<Field, Object>> injectedLists = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
public void inject() throws Exception {
|
||||
try {
|
||||
Object connection = getServerConnection();
|
||||
if (connection == null) {
|
||||
getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
|
||||
return;
|
||||
throw new Exception("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
|
||||
}
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
@ -40,7 +40,11 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
public synchronized void handleAdd(Object o) {
|
||||
synchronized (this) {
|
||||
if (o instanceof ChannelFuture) {
|
||||
injectChannelFuture((ChannelFuture) o);
|
||||
try {
|
||||
injectChannelFuture((ChannelFuture) o);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,12 +65,12 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Unable to inject ViaVersion, please post these details on our GitHub and ensure you're using a compatible server version.");
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().severe("Unable to inject ViaVersion, please post these details on our GitHub and ensure you're using a compatible server version.");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void injectChannelFuture(ChannelFuture future) {
|
||||
private void injectChannelFuture(ChannelFuture future) throws Exception {
|
||||
try {
|
||||
ChannelHandler bootstrapAcceptor = future.channel().pipeline().first();
|
||||
try {
|
||||
@ -87,8 +91,8 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("We failed to inject ViaVersion, have you got late-bind enabled with something else?");
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().severe("We failed to inject ViaVersion, have you got late-bind enabled with something else?");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +127,7 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerProtocolVersion() {
|
||||
public int getServerProtocolVersion() throws Exception {
|
||||
try {
|
||||
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
|
||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||
@ -164,9 +168,9 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// We couldn't work it out... We'll just use ping and hope for the best...
|
||||
throw new Exception("Failed to get server", e);
|
||||
}
|
||||
throw new Exception("Failed to get server");
|
||||
}
|
||||
|
||||
public static Object getServerConnection() throws Exception {
|
||||
@ -188,7 +192,7 @@ public class BukkitViaInjector implements ViaInjector {
|
||||
public static void patchLists() throws Exception {
|
||||
Object connection = getServerConnection();
|
||||
if (connection == null) {
|
||||
getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
|
||||
Via.getPlatform().getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
|
||||
return;
|
||||
}
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0-ALPHA-16w38a</version>
|
||||
</parent>
|
||||
|
@ -3,7 +3,7 @@
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0-ALPHA-16w38a</version>
|
||||
</parent>
|
||||
@ -11,5 +11,4 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>viaversion-common</artifactId>
|
||||
|
||||
</project>
|
@ -44,8 +44,13 @@ public class ViaManager {
|
||||
if (platform.getConf().isCheckForUpdates())
|
||||
UpdateUtil.sendUpdateMessage();
|
||||
// Inject
|
||||
// TODO: Get errors
|
||||
injector.inject();
|
||||
try {
|
||||
injector.inject();
|
||||
} catch (Exception e) {
|
||||
getPlatform().getLogger().severe("ViaVersion failed to inject:");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
// Mark as injected
|
||||
System.setProperty("ViaVersion", getPlatform().getPluginVersion());
|
||||
// If successful
|
||||
@ -58,9 +63,15 @@ public class ViaManager {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void onServerLoaded() {
|
||||
// Load Server Protocol
|
||||
ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion();
|
||||
try {
|
||||
ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion();
|
||||
} catch (Exception e) {
|
||||
getPlatform().getLogger().severe("ViaVersion failed to get the server protocol!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Check if there are any pipes to this version
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
|
||||
getPlatform().getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL));
|
||||
@ -81,7 +92,12 @@ public class ViaManager {
|
||||
public void destroy() {
|
||||
// Uninject
|
||||
getPlatform().getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting.");
|
||||
injector.uninject();
|
||||
try {
|
||||
injector.uninject();
|
||||
} catch (Exception e) {
|
||||
getPlatform().getLogger().severe("ViaVersion failed to uninject:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addPortedClient(UserConnection info) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package us.myles.ViaVersion.api.platform;
|
||||
|
||||
public interface ViaInjector {
|
||||
public void inject();
|
||||
public void inject() throws Exception;
|
||||
|
||||
public void uninject();
|
||||
public void uninject() throws Exception;
|
||||
|
||||
public int getServerProtocolVersion();
|
||||
public int getServerProtocolVersion() throws Exception;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ProtocolRegistry {
|
||||
|
||||
if (Via.getPlatform().isPluginEnabled()) {
|
||||
protocol.registerListeners();
|
||||
protocol.registerProviders(Via.getManager().getProviders());
|
||||
protocol.register(Via.getManager().getProviders());
|
||||
refreshVersions();
|
||||
} else {
|
||||
registerList.add(protocol);
|
||||
@ -110,7 +110,7 @@ public class ProtocolRegistry {
|
||||
public static void onServerLoaded() {
|
||||
for (Protocol protocol : registerList) {
|
||||
protocol.registerListeners();
|
||||
protocol.registerProviders(Via.getManager().getProviders());
|
||||
protocol.register(Via.getManager().getProviders());
|
||||
}
|
||||
registerList.clear();
|
||||
}
|
||||
|
11
jar/pom.xml
11
jar/pom.xml
@ -35,17 +35,6 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!-- Maven Java Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>${jdkVersion}</source>
|
||||
<target>${jdkVersion}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Libs Shading and Relocation -->
|
||||
<plugin>
|
||||
<!--Relocate all lib we use in order to fix class loading errors if we use different versions
|
||||
|
18
pom.xml
18
pom.xml
@ -30,7 +30,8 @@
|
||||
<projectEncoding>UTF-8</projectEncoding>
|
||||
<project.build.sourceEncoding>${projectEncoding}</project.build.sourceEncoding>
|
||||
<project.build.outputEncoding>${projectEncoding}</project.build.outputEncoding>
|
||||
<jdkVersion>1.7</jdkVersion>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@ -61,7 +62,6 @@
|
||||
<version>1.16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Javassist (Bytecode Library) -->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
@ -114,4 +114,18 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Maven Java Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
Loading…
Reference in New Issue
Block a user