Skip to content

Commit 1af7f1e

Browse files
committed
2.6.0, too many changes to list, will be in release readme
1 parent 41ff3f4 commit 1af7f1e

19 files changed

+49
-29
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ plugins {
2626
// --
2727
// Variables
2828
// --
29-
version = '2.5.6'
29+
version = '2.6.0'
3030
group = 'net.tcpshield.tcpshield'
3131
archivesBaseName = 'TCPShield'
3232

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

100100
// Paper
101101
compileOnly group: 'com.destroystokyo.paper', name: 'paper-api', version: '1.15.2-R0.1-SNAPSHOT'

src/main/java/net/tcpshield/tcpshield/bukkit/BukkitConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ protected void load() throws ConfigLoadException {
6666
try {
6767
loadedConfiguration = YamlConfiguration.loadConfiguration(configFile);
6868

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

7171
this.onlyProxy = loadedConfiguration.getBoolean("only-allow-proxy-connections");
7272
this.timestampValidationMode = loadedConfiguration.getString("timestamp-validation");
7373
this.doDebug = loadedConfiguration.getBoolean("debug-mode");
7474
this.geyser = loadedConfiguration.getBoolean("enable-geyser-support");
75+
this.preferProtocolLib = loadedConfiguration.getBoolean("prefer-protocollib");
7576
} catch (Exception e) {
7677
throw new ConfigLoadException(e);
7778
}

src/main/java/net/tcpshield/tcpshield/bukkit/TCPShieldBukkit.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ public void onEnable() {
2929
debugger = Debugger.createDebugger(this);
3030
packetHandler = new TCPShieldPacketHandler(this);
3131

32-
if (BukkitImplProvider.hasPaperEvent())
32+
// check force plib option -> paper -> plib -> error
33+
if (this.configProvider.preferProtocolLib() && getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
34+
bukkitImpl = new BukkitProtocolLib(this);
35+
} else if (BukkitImplProvider.hasPaperEvent()) {
3336
bukkitImpl = new BukkitPaper(this);
34-
else {
35-
if (getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
36-
getLogger().severe("TCPShield not loading because ProtocolLib is not installed. Either use Paper to enable native compatibility or install ProtocolLib.");
37-
return;
38-
}
39-
37+
} else if (getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
4038
bukkitImpl = new BukkitProtocolLib(this);
39+
} else {
40+
getLogger().severe("TCPShield not loading because ProtocolLib is not installed. Either use Paper to enable native compatibility or install ProtocolLib.");
41+
return;
4142
}
4243

4344
bukkitImpl.load();
@@ -48,6 +49,7 @@ public void onEnable() {
4849
} catch (Exception e) {
4950
throw new InitializationException(e);
5051
}
52+
5153
}
5254

5355

src/main/java/net/tcpshield/tcpshield/bukkit/paper/BukkitPaper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public BukkitPaper(TCPShieldBukkit bukkitPlugin) {
1313
super(bukkitPlugin);
1414
}
1515

16-
1716
@Override
1817
public void load() {
1918
PaperHandshakeHandler packetHandler = new PaperHandshakeHandler(this);

src/main/java/net/tcpshield/tcpshield/bukkit/paper/handler/PaperHandshakeHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public PaperHandshakeHandler(BukkitImplProvider bukkitProvider) {
1919
this.bukkitProvider = bukkitProvider;
2020
}
2121

22-
2322
@EventHandler(priority = EventPriority.LOWEST)
2423
public void onHandshake(PlayerHandshakeEvent e) {
2524
PaperPacket packet = new PaperPacket(e);
@@ -36,6 +35,8 @@ public void onHandshake(PlayerHandshakeEvent e) {
3635
public void onServerPing(PaperServerListPingEvent e) {
3736
if (e.getClient().isLegacy())
3837
e.setCancelled(true);
38+
39+
3940
}
4041

4142
}

src/main/java/net/tcpshield/tcpshield/bukkit/paper/handler/PaperPacket.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public PaperPacket(PlayerHandshakeEvent handshakeEvent) {
1515
this.handshakeEvent = handshakeEvent;
1616
}
1717

18-
1918
@Override
2019
public String getPayloadString() {
2120
return handshakeEvent.getOriginalHandshake();

src/main/java/net/tcpshield/tcpshield/bukkit/paper/handler/PaperPlayer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public PaperPlayer(PlayerHandshakeEvent handshakeEvent) {
1818
this.handshakeEvent = handshakeEvent;
1919
}
2020

21-
2221
/**
2322
* Trys to grab the UUID of the handshake
2423
* @return If found, the corrosponding uuid, if not, unknown

src/main/java/net/tcpshield/tcpshield/bukkit/protocollib/BukkitProtocolLib.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public BukkitProtocolLib(TCPShieldBukkit bukkitPlugin) {
1313
super(bukkitPlugin);
1414
}
1515

16-
1716
@Override
1817
public void load() {
1918
ProtocolLibHandshakeHandler packetHandler = new ProtocolLibHandshakeHandler(this);

src/main/java/net/tcpshield/tcpshield/bukkit/protocollib/handler/ProtocolLibHandshakeHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public ProtocolLibHandshakeHandler(BukkitImplProvider bukkitProvider) {
1919
this.bukkitProvider = bukkitProvider;
2020
}
2121

22-
2322
@Override
2423
public void onPacketReceiving(PacketEvent e) {
2524
ProtocolLibPacket packet = new ProtocolLibPacket(e.getPacket());

src/main/java/net/tcpshield/tcpshield/bukkit/protocollib/handler/ProtocolLibPacket.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public ProtocolLibPacket(PacketContainer packetContainer) {
1717
this.rawPayload = packetContainer.getStrings().read(0);
1818
}
1919

20-
2120
@Override
2221
public String getPayloadString() {
2322
return rawPayload;

src/main/java/net/tcpshield/tcpshield/bukkit/protocollib/handler/ProtocolLibPlayer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.tcpshield.tcpshield.bukkit.protocollib.handler;
22

3-
import com.comphenix.protocol.injector.server.SocketInjector;
4-
import com.comphenix.protocol.injector.server.TemporaryPlayerFactory;
3+
import com.comphenix.protocol.injector.temporary.MinimalInjector;
4+
import com.comphenix.protocol.injector.temporary.TemporaryPlayerFactory;
55
import net.tcpshield.tcpshield.provider.PlayerProvider;
66
import net.tcpshield.tcpshield.util.ReflectionUtil;
77
import net.tcpshield.tcpshield.util.exception.manipulate.PlayerManipulationException;
@@ -34,7 +34,6 @@ public class ProtocolLibPlayer implements PlayerProvider {
3434
}
3535
}
3636

37-
3837
private final Player player;
3938
private String ip;
4039

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

75-
SocketInjector ignored = TemporaryPlayerFactory.getInjectorFromPlayer(player);
74+
MinimalInjector ignored = TemporaryPlayerFactory.getInjectorFromPlayer(player);
7675
Object injector = ReflectionUtil.getObjectInPrivateField(ignored, "injector");
7776
Object networkManager = ReflectionUtil.getObjectInPrivateField(injector, "networkManager");
7877

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

81-
Object channel = ReflectionUtil.getObjectInPrivateField(injector, "originalChannel");
80+
Object channel = ReflectionUtil.getObjectInPrivateField(injector, "wrappedChannel");
8281
ReflectionUtil.setFinalField(channel, ReflectionUtil.getDeclaredField(abstractChannelClass, "remoteAddress"), ip);
8382
} catch (Exception e) {
8483
throw new PlayerManipulationException(e);

src/main/java/net/tcpshield/tcpshield/provider/ConfigProvider.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,36 @@ public abstract class ConfigProvider {
1919
protected String timestampValidationMode = "htpdate";
2020
protected boolean doDebug = true; // Fail-safe default set to true
2121
protected boolean geyser = false;
22+
protected boolean velocityHandlePreLoginEvent = true;
23+
24+
// spigot/paper only option
25+
protected boolean preferProtocolLib;
2226

2327
protected File dataFolder;
2428
protected File configFile;
2529

2630
public boolean isOnlyProxy() {
27-
return onlyProxy;
31+
return this.onlyProxy;
2832
}
2933

3034
public boolean isGeyser() {
31-
return geyser;
35+
return this.geyser;
36+
}
37+
38+
public boolean handlePreLoginEvent() {
39+
return this.velocityHandlePreLoginEvent;
3240
}
3341

3442
public String getTimestampValidationMode() {
3543
return this.timestampValidationMode;
3644
}
3745

3846
public boolean doDebug() {
39-
return doDebug;
47+
return this.doDebug;
48+
}
49+
50+
public boolean preferProtocolLib() {
51+
return this.preferProtocolLib;
4052
}
4153

4254
public File getDataFolder() {

src/main/java/net/tcpshield/tcpshield/velocity/VelocityConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ protected void load() throws ConfigLoadException {
6565
try {
6666
loadedToml = new Toml().read(configFile);
6767

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

7070
this.onlyProxy = loadedToml.getBoolean("only-allow-proxy-connections");
7171
this.timestampValidationMode = loadedToml.getString("timestamp-validation");
7272
this.doDebug = loadedToml.getBoolean("debug-mode");
7373
this.geyser = loadedToml.getBoolean("enable-geyser-support");
74+
this.velocityHandlePreLoginEvent = loadedToml.getBoolean("pre-login-event");
7475
} catch (Exception e) {
7576
throw new ConfigLoadException(e);
7677
}

src/main/java/net/tcpshield/tcpshield/velocity/handler/VelocityHandshakeHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public VelocityHandshakeHandler(TCPShieldPlugin plugin) {
2525
// issues with the verification process.
2626
@Subscribe(order = PostOrder.FIRST)
2727
public void onPreLogin(PreLoginEvent e) {
28+
if (!this.plugin.getConfigProvider().handlePreLoginEvent()) {
29+
return;
30+
}
31+
2832
InboundConnection connection = e.getConnection();
2933
handleEvent(connection, "onPreLogin");
3034
}

src/main/resources/bungee.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: TCPShield
2-
version: 2.5.6
2+
version: 2.6.0
33
main: net.tcpshield.tcpshield.bungee.TCPShieldBungee
44
author: https://tcpshield.com
55
softdepends:

src/main/resources/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ debug-mode = false
99

1010
# Toggle to enable support for Geyser/Floodgate v2
1111
enable-geyser-support = false
12+
13+
# enable handling handshake on PreLoginEvent
14+
pre-login-event = true

src/main/resources/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ debug-mode: false
99

1010
# Toggle to enable support for Geyser/Floodgate v2
1111
enable-geyser-support: false
12+
13+
# Spigot/Paper option only, does not affect bungeecord
14+
prefer-protocollib: true

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: TCPShield
2-
version: 2.5.6
2+
version: 2.6.0
33
main: net.tcpshield.tcpshield.bukkit.TCPShieldBukkit
44
softdepend:
55
- ProtocolLib

src/main/resources/velocity-plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "tcpshield",
33
"name": "TCPShield",
4-
"version": "2.5.6",
4+
"version": "2.6.0",
55
"description": "TCPShield IP parsing capabilities for Velocity",
66
"authors": [
77
"TCPShield"

0 commit comments

Comments
 (0)