From f02d01d639f67bcabca91ffd490612cc82549350 Mon Sep 17 00:00:00 2001
From: JaTiTV <75247188+JaTiTV@users.noreply.github.com>
Date: Mon, 31 Mar 2025 07:04:37 +0200
Subject: [PATCH] move to 18.0
Development version moved to 18.0.
17.0 Integrated
---
pom.xml | 2 +-
.../pluginMessaging/T2CB_PluginMessageProxyCommand.java | 5 +++++
.../autoResponse/T2CB_API_AutoResponse.java | 5 +++++
.../pluginMessaging/opSecurity/T2CB_API_OpSecurity.java | 5 +++++
.../pluginMessaging/T2CV_PluginMessageProxyCommand.java | 8 ++++++++
.../autoResponse/T2CV_API_AutoResponse.java | 9 +++++++++
.../pluginMessaging/opSecurity/T2CV_API_OpSecurity.java | 8 ++++++++
.../VELOCITY/api/proxyPlayers/T2CV_Players.java | 8 ++++++++
8 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 1cd2996..2c4e858 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.t2code
T2CodeLib
- 17.0_beta-2025-1
+ 18.0_beta-2025-2
diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CB_PluginMessageProxyCommand.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CB_PluginMessageProxyCommand.java
index ef5ff39..742a064 100644
--- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CB_PluginMessageProxyCommand.java
+++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CB_PluginMessageProxyCommand.java
@@ -2,6 +2,7 @@ package net.t2code.t2codelib.BUNGEE.api.pluginMessaging;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
+import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
@@ -15,6 +16,10 @@ public class T2CB_PluginMessageProxyCommand implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_ProxyCommand())) {
+ if (!(event.getSender() instanceof Server)) {
+ ProxyServer.getInstance().getConsole().sendMessage(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
+ return;
+ }
event.setCancelled(true);
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CB_API_AutoResponse.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CB_API_AutoResponse.java
index a9d7f38..b0af41d 100644
--- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CB_API_AutoResponse.java
+++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CB_API_AutoResponse.java
@@ -2,6 +2,7 @@ package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
+import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
@@ -17,6 +18,10 @@ public class T2CB_API_AutoResponse implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_AutoResponse())) {
+ if (!(event.getSender() instanceof Server)) {
+ ProxyServer.getInstance().getConsole().sendMessage(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
+ return;
+ }
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
event.setCancelled(true);
try {
diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CB_API_OpSecurity.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CB_API_OpSecurity.java
index 6fbc8da..27ee383 100644
--- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CB_API_OpSecurity.java
+++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CB_API_OpSecurity.java
@@ -1,6 +1,7 @@
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity;
import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
@@ -14,6 +15,10 @@ public class T2CB_API_OpSecurity implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_OPSecurity())) {
+ if (!(event.getSender() instanceof Server)) {
+ ProxyServer.getInstance().getConsole().sendMessage(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
+ return;
+ }
event.setCancelled(true);
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CV_PluginMessageProxyCommand.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CV_PluginMessageProxyCommand.java
index 8179aa7..25a871b 100644
--- a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CV_PluginMessageProxyCommand.java
+++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CV_PluginMessageProxyCommand.java
@@ -8,6 +8,8 @@ import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
+import com.velocitypowered.api.proxy.ServerConnection;
+import net.kyori.adventure.text.Component;
import net.t2code.t2codelib.util.T2C_Util;
import net.t2code.t2codelib.VELOCITY.api.commands.T2CV_Cmd;
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
@@ -30,6 +32,12 @@ public class T2CV_PluginMessageProxyCommand {
if (event.getIdentifier() != T2CV_Main.bcmd) {
return;
}
+
+ if (!(event.getSource() instanceof ServerConnection)) {
+ T2CV_Main.getLogger().info(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ({})!", event.getSource().toString());
+ return;
+ }
+
ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData());
String channel = stream.readUTF();
String input = stream.readUTF();
diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CV_API_AutoResponse.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CV_API_AutoResponse.java
index e15bc54..11a687b 100644
--- a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CV_API_AutoResponse.java
+++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CV_API_AutoResponse.java
@@ -6,9 +6,12 @@ import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
+import com.velocitypowered.api.proxy.ServerConnection;
+import net.kyori.adventure.text.Component;
import net.t2code.t2codelib.VELOCITY.api.commands.T2CV_Cmd;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
+import net.t2code.t2codelib.util.T2C_Util;
import org.slf4j.Logger;
import java.io.ByteArrayInputStream;
@@ -30,6 +33,12 @@ public class T2CV_API_AutoResponse {
if (event.getIdentifier() != T2CV_Main.aresp) {
return;
}
+
+ if (!(event.getSource() instanceof ServerConnection)) {
+ T2CV_Main.getLogger().info(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ({})!", event.getSource().toString());
+ return;
+ }
+
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CV_API_OpSecurity.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CV_API_OpSecurity.java
index 70e09bc..debd558 100644
--- a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CV_API_OpSecurity.java
+++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CV_API_OpSecurity.java
@@ -5,8 +5,11 @@ package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.ProxyServer;
+import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
+import net.kyori.adventure.text.Component;
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
+import net.t2code.t2codelib.util.T2C_Util;
import org.slf4j.Logger;
import java.io.*;
@@ -27,6 +30,11 @@ public class T2CV_API_OpSecurity {
return;
}
+ if (!(event.getSource() instanceof ServerConnection)) {
+ T2CV_Main.getLogger().info(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ({})!", event.getSource().toString());
+ return;
+ }
+
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
String channel = stream.readUTF();
diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CV_Players.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CV_Players.java
index fb50db8..bfb9538 100644
--- a/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CV_Players.java
+++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CV_Players.java
@@ -10,7 +10,9 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
+import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
+import net.kyori.adventure.text.Component;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2C_BngeePlayersEnum;
import net.t2code.t2codelib.util.T2C_Util;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
@@ -93,6 +95,12 @@ public class T2CV_Players {
if (event.getIdentifier() != T2CV_Main.bonlp) {
return;
}
+
+ if (!(event.getSource() instanceof ServerConnection)) {
+ T2CV_Main.getLogger().info(T2C_Util.getPrefix() +" [Security] §cBlocked unauthorized plugin message from a player ({})!", event.getSource().toString());
+ return;
+ }
+
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {