Skip to content

Commit

Permalink
2.6.0, too many changes to list, will be in release readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanKeir committed Jun 28, 2022
1 parent 41ff3f4 commit 1af7f1e
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 29 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
// --
// Variables
// --
version = '2.5.6'
version = '2.6.0'
group = 'net.tcpshield.tcpshield'
archivesBaseName = 'TCPShield'

Expand Down Expand Up @@ -95,7 +95,7 @@ repositories {
dependencies {
// Bukkit
compileOnly group: 'org.spigotmc', name: 'spigot-api', version: '1.11-R0.1-SNAPSHOT'
compileOnly group: 'com.comphenix.protocol', name: 'ProtocolLib', version: '4.4.0'
compileOnly group: 'com.comphenix.protocol', name: 'ProtocolLib', version: '5.0.0-SNAPSHOT'

// Paper
compileOnly group: 'com.destroystokyo.paper', name: 'paper-api', version: '1.15.2-R0.1-SNAPSHOT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ protected void load() throws ConfigLoadException {
try {
loadedConfiguration = YamlConfiguration.loadConfiguration(configFile);

checkNodes("only-allow-proxy-connections", "timestamp-validation", "debug-mode");
checkNodes("only-allow-proxy-connections", "timestamp-validation", "debug-mode", "enable-geyser-support", "prefer-protocollib");

this.onlyProxy = loadedConfiguration.getBoolean("only-allow-proxy-connections");
this.timestampValidationMode = loadedConfiguration.getString("timestamp-validation");
this.doDebug = loadedConfiguration.getBoolean("debug-mode");
this.geyser = loadedConfiguration.getBoolean("enable-geyser-support");
this.preferProtocolLib = loadedConfiguration.getBoolean("prefer-protocollib");
} catch (Exception e) {
throw new ConfigLoadException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ public void onEnable() {
debugger = Debugger.createDebugger(this);
packetHandler = new TCPShieldPacketHandler(this);

if (BukkitImplProvider.hasPaperEvent())
// check force plib option -> paper -> plib -> error
if (this.configProvider.preferProtocolLib() && getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
bukkitImpl = new BukkitProtocolLib(this);
} else if (BukkitImplProvider.hasPaperEvent()) {
bukkitImpl = new BukkitPaper(this);
else {
if (getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
getLogger().severe("TCPShield not loading because ProtocolLib is not installed. Either use Paper to enable native compatibility or install ProtocolLib.");
return;
}

} else if (getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
bukkitImpl = new BukkitProtocolLib(this);
} else {
getLogger().severe("TCPShield not loading because ProtocolLib is not installed. Either use Paper to enable native compatibility or install ProtocolLib.");
return;
}

bukkitImpl.load();
Expand All @@ -48,6 +49,7 @@ public void onEnable() {
} catch (Exception e) {
throw new InitializationException(e);
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public BukkitPaper(TCPShieldBukkit bukkitPlugin) {
super(bukkitPlugin);
}


@Override
public void load() {
PaperHandshakeHandler packetHandler = new PaperHandshakeHandler(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public PaperHandshakeHandler(BukkitImplProvider bukkitProvider) {
this.bukkitProvider = bukkitProvider;
}


@EventHandler(priority = EventPriority.LOWEST)
public void onHandshake(PlayerHandshakeEvent e) {
PaperPacket packet = new PaperPacket(e);
Expand All @@ -36,6 +35,8 @@ public void onHandshake(PlayerHandshakeEvent e) {
public void onServerPing(PaperServerListPingEvent e) {
if (e.getClient().isLegacy())
e.setCancelled(true);


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public PaperPacket(PlayerHandshakeEvent handshakeEvent) {
this.handshakeEvent = handshakeEvent;
}


@Override
public String getPayloadString() {
return handshakeEvent.getOriginalHandshake();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public PaperPlayer(PlayerHandshakeEvent handshakeEvent) {
this.handshakeEvent = handshakeEvent;
}


/**
* Trys to grab the UUID of the handshake
* @return If found, the corrosponding uuid, if not, unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public BukkitProtocolLib(TCPShieldBukkit bukkitPlugin) {
super(bukkitPlugin);
}


@Override
public void load() {
ProtocolLibHandshakeHandler packetHandler = new ProtocolLibHandshakeHandler(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public ProtocolLibHandshakeHandler(BukkitImplProvider bukkitProvider) {
this.bukkitProvider = bukkitProvider;
}


@Override
public void onPacketReceiving(PacketEvent e) {
ProtocolLibPacket packet = new ProtocolLibPacket(e.getPacket());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public ProtocolLibPacket(PacketContainer packetContainer) {
this.rawPayload = packetContainer.getStrings().read(0);
}


@Override
public String getPayloadString() {
return rawPayload;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.tcpshield.tcpshield.bukkit.protocollib.handler;

import com.comphenix.protocol.injector.server.SocketInjector;
import com.comphenix.protocol.injector.server.TemporaryPlayerFactory;
import com.comphenix.protocol.injector.temporary.MinimalInjector;
import com.comphenix.protocol.injector.temporary.TemporaryPlayerFactory;
import net.tcpshield.tcpshield.provider.PlayerProvider;
import net.tcpshield.tcpshield.util.ReflectionUtil;
import net.tcpshield.tcpshield.util.exception.manipulate.PlayerManipulationException;
Expand Down Expand Up @@ -34,7 +34,6 @@ public class ProtocolLibPlayer implements PlayerProvider {
}
}


private final Player player;
private String ip;

Expand Down Expand Up @@ -72,13 +71,13 @@ public void setIP(InetSocketAddress ip) throws PlayerManipulationException {
try {
this.ip = ip.getAddress().getHostAddress();

SocketInjector ignored = TemporaryPlayerFactory.getInjectorFromPlayer(player);
MinimalInjector ignored = TemporaryPlayerFactory.getInjectorFromPlayer(player);
Object injector = ReflectionUtil.getObjectInPrivateField(ignored, "injector");
Object networkManager = ReflectionUtil.getObjectInPrivateField(injector, "networkManager");

ReflectionUtil.setFinalField(networkManager, ReflectionUtil.searchFieldByClass(networkManager.getClass(), SocketAddress.class), ip);

Object channel = ReflectionUtil.getObjectInPrivateField(injector, "originalChannel");
Object channel = ReflectionUtil.getObjectInPrivateField(injector, "wrappedChannel");
ReflectionUtil.setFinalField(channel, ReflectionUtil.getDeclaredField(abstractChannelClass, "remoteAddress"), ip);
} catch (Exception e) {
throw new PlayerManipulationException(e);
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/net/tcpshield/tcpshield/provider/ConfigProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,36 @@ public abstract class ConfigProvider {
protected String timestampValidationMode = "htpdate";
protected boolean doDebug = true; // Fail-safe default set to true
protected boolean geyser = false;
protected boolean velocityHandlePreLoginEvent = true;

// spigot/paper only option
protected boolean preferProtocolLib;

protected File dataFolder;
protected File configFile;

public boolean isOnlyProxy() {
return onlyProxy;
return this.onlyProxy;
}

public boolean isGeyser() {
return geyser;
return this.geyser;
}

public boolean handlePreLoginEvent() {
return this.velocityHandlePreLoginEvent;
}

public String getTimestampValidationMode() {
return this.timestampValidationMode;
}

public boolean doDebug() {
return doDebug;
return this.doDebug;
}

public boolean preferProtocolLib() {
return this.preferProtocolLib;
}

public File getDataFolder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ protected void load() throws ConfigLoadException {
try {
loadedToml = new Toml().read(configFile);

checkNodes("only-allow-proxy-connections", "timestamp-validation", "debug-mode");
checkNodes("only-allow-proxy-connections", "timestamp-validation", "debug-mode", "enable-geyser-support", "pre-login-event");

this.onlyProxy = loadedToml.getBoolean("only-allow-proxy-connections");
this.timestampValidationMode = loadedToml.getString("timestamp-validation");
this.doDebug = loadedToml.getBoolean("debug-mode");
this.geyser = loadedToml.getBoolean("enable-geyser-support");
this.velocityHandlePreLoginEvent = loadedToml.getBoolean("pre-login-event");
} catch (Exception e) {
throw new ConfigLoadException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public VelocityHandshakeHandler(TCPShieldPlugin plugin) {
// issues with the verification process.
@Subscribe(order = PostOrder.FIRST)
public void onPreLogin(PreLoginEvent e) {
if (!this.plugin.getConfigProvider().handlePreLoginEvent()) {
return;
}

InboundConnection connection = e.getConnection();
handleEvent(connection, "onPreLogin");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TCPShield
version: 2.5.6
version: 2.6.0
main: net.tcpshield.tcpshield.bungee.TCPShieldBungee
author: https://tcpshield.com
softdepends:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ debug-mode = false

# Toggle to enable support for Geyser/Floodgate v2
enable-geyser-support = false

# enable handling handshake on PreLoginEvent
pre-login-event = true
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ debug-mode: false

# Toggle to enable support for Geyser/Floodgate v2
enable-geyser-support: false

# Spigot/Paper option only, does not affect bungeecord
prefer-protocollib: true
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TCPShield
version: 2.5.6
version: 2.6.0
main: net.tcpshield.tcpshield.bukkit.TCPShieldBukkit
softdepend:
- ProtocolLib
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tcpshield",
"name": "TCPShield",
"version": "2.5.6",
"version": "2.6.0",
"description": "TCPShield IP parsing capabilities for Velocity",
"authors": [
"TCPShield"
Expand Down

0 comments on commit 1af7f1e

Please sign in to comment.