General Bug and Typo Fixes
Removed ReflectionUtil logic that caused issues. Added cancel call in Paper implementation to fix Paper issues. Upgraded minimum Java version to 11 and added checks to make sure the plugin is ran properly. Fixed old/invalid links in README. (Merged PR's of other users)
This commit is contained in:
1 parent
eb8663f5b8
commit
ad2a29de0f
9 files changed
+61
-42
No files matched your search
@@ -11,7 +11,7 @@ TCPShield is compatible with Spigot / CraftBukkit, BungeeCord and Velocity.
|
||||
When using Spigot / CraftBukkit, [ProtocolLib](https://github.com/aadnk/ProtocolLib) needs to be installed.
|
||||
|
||||
### Setup
|
||||
Setting up the plugin is easy as pie. Please follow [these](https://docs.tcpshield.com/onboarding/tcpshield-plugin) guidelines.
|
||||
Setting up the plugin is easy as pie. Please follow [these](https://docs.tcpshield.com/panel/tcpshield-plugin) guidelines.
|
||||
|
||||
### Compiling
|
||||
In order to compile TCPShield, [install Gradle](https://docs.gradle.org/current/userguide/installation.html) and run the following command in the project folder:
|
||||
@@ -22,7 +22,7 @@ gradle build
|
||||
The dependencies should install themselves automatically. After the build has finished, the compiled jar file can be found under `/build/libs`.
|
||||
|
||||
### Support
|
||||
See [Contact](https://docs.tcpshield.com/about-us)
|
||||
See [Contact](https://tcpshield.com/#contact)
|
||||
|
||||
### Contributors
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ sourceSets {
|
||||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
sourceCompatibility = targetCompatibility = '11' // Will switch to Java 16 in a future release
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
|
||||
@@ -34,4 +34,18 @@ public interface TCPShieldPlugin {
|
||||
*/
|
||||
Debugger getDebugger();
|
||||
|
||||
|
||||
/**
|
||||
* Default initialization of TCPShield, called after interface defaults are set
|
||||
*/
|
||||
default void initialization() {
|
||||
String jvmVersion = System.getProperty("java.version");
|
||||
|
||||
// Java 11 check/warning (Will eventually force Java 16 without warning)
|
||||
String[] versionParts = jvmVersion.split("\\.");
|
||||
int baseVersion = Integer.parseInt(versionParts[0]);
|
||||
if (baseVersion < 11) // Java 8, and below, starts with 1, but since we are using Java 11 we can ignore sub values
|
||||
this.getDebugger().warn("The Java version you are running is outdated for TCPShield and may cause issues. Update to atleast Java 11. Your version: Java %s", jvmVersion);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public class TCPShieldBukkit extends JavaPlugin implements TCPShieldPlugin {
|
||||
}
|
||||
|
||||
bukkitImpl.load();
|
||||
|
||||
initialization();
|
||||
} catch (Exception e) {
|
||||
throw new InitializationException(e);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class PaperPlayer implements PlayerProvider {
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
handshakeEvent.setCancelled(false); // Caused issues with newer versions of Paper (Thanks https://github.com/realDragonium)
|
||||
handshakeEvent.setFailMessage("Connection failed. Please try again or contract an administrator.");
|
||||
handshakeEvent.setFailed(true);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class TCPShieldBungee extends Plugin implements TCPShieldPlugin, Listener
|
||||
|
||||
PluginManager pluginManager = this.getProxy().getPluginManager();
|
||||
pluginManager.registerListener(this, new BungeeHandshakeHandler(this));
|
||||
|
||||
initialization();
|
||||
} catch (Exception e) {
|
||||
throw new InitializationException(e);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ import com.google.common.collect.Table;
|
||||
import net.tcpshield.tcpshield.util.exception.phase.ReflectionException;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A util for reflection and manipulation
|
||||
@@ -20,7 +16,7 @@ public class ReflectionUtil {
|
||||
*/
|
||||
private static final Table<Class<?>, String, Field> CACHED_FIELDS_BY_NAME = HashBasedTable.create();
|
||||
private static final Table<Class<?>, Class<?>, Field> CACHED_FIELDS_BY_CLASS = HashBasedTable.create();
|
||||
private static Field modifiersField;
|
||||
// private static Field modifiersField;
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,31 +40,33 @@ public class ReflectionUtil {
|
||||
public static void setFinalField(Object object, Field field, Object value) throws ReflectionException {
|
||||
field.setAccessible(true);
|
||||
|
||||
if (Modifier.isFinal(field.getModifiers())) {
|
||||
if (modifiersField == null) {
|
||||
try {
|
||||
modifiersField = getDeclaredField(Field.class, "modifiers");
|
||||
} catch (ReflectionException e) { // workaround for when searching for the modifiers field on Java 12 or higher
|
||||
try {
|
||||
Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
|
||||
getDeclaredFields0.setAccessible(true);
|
||||
// Removed due to complications with Velocity (Thanks https://github.com/AoElite)
|
||||
|
||||
Field[] fields = (Field[]) getDeclaredFields0.invoke(Field.class, false);
|
||||
modifiersField = Arrays.stream(fields).filter(modifier -> modifier.getName().equals("modifiers")).findFirst().orElseThrow(() -> new ReflectionException("Could not find the modifiers field"));
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e2) {
|
||||
throw new ReflectionException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
modifiersField.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionException(e);
|
||||
}
|
||||
}
|
||||
// if (Modifier.isFinal(field.getModifiers())) {
|
||||
// if (modifiersField == null) {
|
||||
// try {
|
||||
// modifiersField = getDeclaredField(Field.class, "modifiers");
|
||||
// } catch (ReflectionException e) { // workaround for when searching for the modifiers field on Java 12 or higher
|
||||
// try {
|
||||
// Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
|
||||
// getDeclaredFields0.setAccessible(true);
|
||||
//
|
||||
// Field[] fields = (Field[]) getDeclaredFields0.invoke(Field.class, false);
|
||||
// modifiersField = Arrays.stream(fields).filter(modifier -> modifier.getName().equals("modifiers")).findFirst().orElseThrow(() -> new ReflectionException("Could not find the modifiers field"));
|
||||
// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e2) {
|
||||
// throw new ReflectionException(e2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// modifiersField.setAccessible(true);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
// } catch (IllegalAccessException e) {
|
||||
// throw new ReflectionException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
setField(object, field, value);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public class TCPShieldVelocity implements TCPShieldPlugin {
|
||||
packetHandler = new TCPShieldPacketHandler(this);
|
||||
|
||||
server.getEventManager().register(this, new VelocityHandshakeHandler(this));
|
||||
|
||||
initialization();
|
||||
} catch (Exception exception) {
|
||||
throw new InitializationException(exception);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"id":"tcpshield",
|
||||
"name":"TCPShield",
|
||||
"version":"2.5",
|
||||
"description":"TCPShield IP parsing capabilities for Velocity",
|
||||
"authors":[
|
||||
"TCPShield"
|
||||
],
|
||||
"dependencies":[
|
||||
"id":"tcpshield",
|
||||
"name":"TCPShield",
|
||||
"version":"2.5",
|
||||
"description":"TCPShield IP parsing capabilities for Velocity",
|
||||
"authors":[
|
||||
"TCPShield"
|
||||
],
|
||||
"dependencies":[
|
||||
|
||||
],
|
||||
"main":"net.tcpshield.tcpshield.velocity.TCPShieldVelocity"
|
||||
],
|
||||
"main":"net.tcpshield.tcpshield.velocity.TCPShieldVelocity"
|
||||
}
|
||||
Reference in new issue
Block a user