Compare commits
91
Commits
v2.3.0
...
backend-recode
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
737bc51d8f | ||
|
|
37bee3750c | ||
|
|
3f7a2687e6 | ||
|
|
cd195d7e21 | ||
|
|
daae025e9b | ||
|
|
52e53a377a | ||
|
|
423c9c1519 | ||
|
|
b09e81143c | ||
|
|
df27433ee3 | ||
|
|
76b95ecd84 | ||
|
|
f182ff4449 | ||
|
|
d5cb2c4f8e | ||
|
|
3f8442b50c | ||
|
|
45c4ca512b | ||
|
|
7a9e854bf1 | ||
|
|
9a5247b0fe | ||
|
|
2b904200aa | ||
|
|
04063e092e | ||
|
|
940c4c79bd | ||
|
|
4241db903c | ||
|
|
09236cdcb7 | ||
|
|
67c7b29827 | ||
|
|
72db0706b9 | ||
|
|
8a47cdacc7 | ||
|
|
91a45d99a9 | ||
|
|
f9c62ad123 | ||
|
|
22a8e11a11 | ||
|
|
24c1ca4273 | ||
|
|
93fd59e3d0 | ||
|
|
e40750297e | ||
|
|
100aee8e27 | ||
|
|
d79a6a46da | ||
|
|
37c563cacb | ||
|
|
3d3263bd3a | ||
|
|
e5017c051b | ||
|
|
dd2d5b574e | ||
|
|
67091db586 | ||
|
|
7cb72f89ee | ||
|
|
03925fe529 | ||
|
|
868c92bc42 | ||
|
|
9ee7d85805 | ||
|
|
4e3c245fb1 | ||
|
|
5beebc2273 | ||
|
|
6c7f078270 | ||
|
|
836e192f4b | ||
|
|
f447cf69d3 | ||
|
|
d06b723adc | ||
|
|
f8617cf1b9 | ||
|
|
8630a6f74c | ||
|
|
424d892091 | ||
|
|
9aaef6e297 | ||
|
|
e749760136 | ||
|
|
7f2f3c54ba | ||
|
|
24f2c867c6 | ||
|
|
e7f3288fb7 | ||
|
|
2221062e98 | ||
|
|
430f5ee9e6 | ||
|
|
cd1a7cf312 | ||
|
|
002cdc64ef | ||
|
|
3d59686ba4 | ||
|
|
f6c72b9d0e | ||
|
|
d72d419044 | ||
|
|
c71a3a4002 | ||
|
|
02b70ed324 | ||
|
|
01d0a53049 | ||
|
|
c700ca6abb | ||
|
|
d9cba6c010 | ||
|
|
a6ed66cf1e | ||
|
|
4f5b7ad3fb | ||
|
|
962ea8b719 | ||
|
|
35e4d0b5aa | ||
|
|
497fe5ef98 | ||
|
|
0508387db1 | ||
|
|
1ff7c419ef | ||
|
|
612eda685c | ||
|
|
7fc7b571a3 | ||
|
|
5cce86bf8d | ||
|
|
7621d815ac | ||
|
|
81495e3478 | ||
|
|
5c591d3a5b | ||
|
|
f1c225b718 | ||
|
|
ca7a098cfa | ||
|
|
b2fbba8455 | ||
|
|
ae6300c43c | ||
|
|
cb62734da5 | ||
|
|
04a2e4ea54 | ||
|
|
2969469605 | ||
|
|
25a0f7a742 | ||
|
|
d2f6c3336e | ||
|
|
d2c7e00639 | ||
|
|
e23fb19c98 |
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
bin/
|
||||
target/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# eclipse
|
||||
.settings
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# intellij
|
||||
.idea/
|
||||
|
||||
# other
|
||||
*.iml
|
||||
run/
|
||||
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>2.3.4</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
@@ -34,6 +34,11 @@
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.helpch.at/releases/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||
@@ -50,11 +55,6 @@
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -192,14 +192,14 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-proxy</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -227,14 +227,14 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.25.0</version>
|
||||
<version>4.26.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.25.0</version>
|
||||
<version>4.26.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.5</version>
|
||||
<version>2.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.api.brand.impl.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class CustomServerBrand {
|
||||
|
||||
public static final String CHANNEL_NAME = Reflection.getMinor() < 13 ? "MC|Brand" : "minecraft:brand";
|
||||
private static final ServerBrand SERVER_BRAND = Reflection.isVelocityServer() ? new VelocityServerBrand() : Reflection.isProxyServer() ? new BungeeServerBrand() : new BukkitServerBrand();
|
||||
|
||||
public static void initialize() { refreshTask(); }
|
||||
public static void refreshTask() { SERVER_BRAND.initializeTask(); }
|
||||
public static void preparePlayer(Object playerObj) { SERVER_BRAND.preparePlayer(playerObj); }
|
||||
public static void sendBrandToPlayer(Object playerObj) { SERVER_BRAND.send(playerObj); }
|
||||
|
||||
public static PacketUtils.BrandManipulate createBrandPacket(Object playerObj) { return SERVER_BRAND.createPacket(playerObj); }
|
||||
public static boolean isEnabled() { return Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED; }
|
||||
|
||||
public static boolean isBrandTag(String tag) {
|
||||
return tag.equals("MC|Brand") || tag.equals("minecraft:brand");
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.lang.reflect.*;
|
||||
import org.bukkit.*;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false, NO_PREP_CHANNELS = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
|
||||
if (Reflection.isWeird()) {
|
||||
|
||||
NO_PREP_CHANNELS = Reflection.getMinor() >= 22 || (Reflection.getMinor() == 21 && Reflection.getRelease() >= 7);
|
||||
|
||||
if (brandPayloadClass == null)
|
||||
brandPayloadClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.BrandPayload");
|
||||
|
||||
if (clientBoundCustomPacketPayloadPacketClass == null)
|
||||
clientBoundCustomPacketPayloadPacketClass = Reflection.getClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket");
|
||||
|
||||
if (customPacketPayloadPacketClass == null)
|
||||
customPacketPayloadPacketClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.CustomPacketPayload");
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(this::preparePlayer);
|
||||
if (!INITIALIZED)
|
||||
try {
|
||||
Method method = Reflection.getMethodsByParameterAndName(SERVER.getMessenger(), "addToOutgoing", Plugin.class, String.class).get(0);
|
||||
Reflection.invokeMethode(method, SERVER.getMessenger(), BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME);
|
||||
INITIALIZED = true;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(TASK != null && TASK.isActive()) {
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, 1);
|
||||
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = PATScheduler.createAsyncScheduler(() -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) {
|
||||
if(!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
if (NO_PREP_CHANNELS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Field channelsField = Reflection.getFieldByName(player.getClass(), "channels");
|
||||
Set<String> channels = (Set<String>) channelsField.get(player);
|
||||
channels.add(CustomServerBrand.CHANNEL_NAME);
|
||||
Reflection.closeAccess(channelsField);
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if(!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
Player player = (Player) playerObj;
|
||||
String playerName = player.getName(), displayName = player.getDisplayName(), worldName = player.getWorld().getName(),
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%displayname%", displayName).replace("%world%", worldName);
|
||||
|
||||
if(!Reflection.isWeird()) {
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(MessageTranslator.replaceMessage(player, customBrand));
|
||||
player.sendPluginMessage(BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME, serverBrand.getBytes());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Channel channel = BukkitPacketAnalyzer.INJECTED_PLAYERS.get(player.getUniqueId());
|
||||
if(channel == null) return;
|
||||
|
||||
Object brandPayloadObj = brandPayloadClass.getDeclaredConstructor(String.class).newInstance(MessageTranslator.replaceMessage(player, customBrand)),
|
||||
customPacketPayloadPacket = clientBoundCustomPacketPayloadPacketClass.getDeclaredConstructor(customPacketPayloadPacketClass).newInstance(brandPayloadObj);
|
||||
|
||||
channel.pipeline().writeAndFlush(customPacketPayloadPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import net.md_5.bungee.api.connection.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BungeeServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = BungeeLoader.getPlugin().getProxy();
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
public BungeeServerBrand() { }
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
if(TASK != null) TASK.cancel();
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get())) + "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) { }
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if(server != null) serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand);
|
||||
String brand = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
player.sendData(brand, serverBrand.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return null;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if(server != null) serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.lang.reflect.Method;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static Class<?> pluginMessagePacketClass, minecraftConnectionClass, connectedPlayerConnectionClass;
|
||||
private static Method connectionMethod;
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
if(TASK != null) TASK.cancel();
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(pluginMessagePacketClass == null)
|
||||
pluginMessagePacketClass = Reflection.getClass("com.velocitypowered.proxy.protocol.packet.PluginMessagePacket");
|
||||
|
||||
if(minecraftConnectionClass == null)
|
||||
minecraftConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.MinecraftConnection");
|
||||
|
||||
if(connectedPlayerConnectionClass == null)
|
||||
connectedPlayerConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
|
||||
if(connectionMethod == null)
|
||||
connectionMethod = Reflection.getMethodByName(connectedPlayerConnectionClass, "getConnection");
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().buildTask(VelocityLoader.getInstance(), () -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get())) + "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
}).repeat(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) { }
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
try {
|
||||
Player player = (Player) playerObj;
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player),
|
||||
minecraftConnectionObj = connectionMethod.invoke(connectedPlayerObj);
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
if(serverConnection.isPresent()) serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%", String.valueOf(player.getPing()));
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand, false);
|
||||
String brand = player.getProtocolVersion().getProtocol() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
Object pluginMessagePacket = pluginMessagePacketClass.getConstructor(String.class, ByteBuf.class).newInstance(brand, serverBrand.getByteBuf());
|
||||
Reflection.getMethodsByParameterAndName(minecraftConnectionObj, "write", Object.class).get(0).invoke(minecraftConnectionObj, pluginMessagePacket);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return null;
|
||||
|
||||
try {
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
|
||||
if(serverConnection.isPresent()) serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%", String.valueOf(player.getPing()));
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand, false);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BackendUpdater {
|
||||
|
||||
private static PATSchedulerTask TASK;
|
||||
|
||||
public static void handle() {
|
||||
if(isRunning() || !shouldRun() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
start();
|
||||
}
|
||||
|
||||
public static boolean isRunning() {
|
||||
return TASK != null && TASK.isActive();
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
if(isRunning() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
if (shouldRun())
|
||||
Communicator.sendRequest();
|
||||
else
|
||||
stop();
|
||||
}, 5, 20);
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
if(TASK == null || !TASK.isActive()) return;
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
}
|
||||
|
||||
private static boolean shouldRun() {
|
||||
int onlinePlayerSize = Bukkit.getOnlinePlayers().size();
|
||||
return onlinePlayerSize >= 1;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
public interface Client {
|
||||
String CHANNEL_NAME = "pat:channel";
|
||||
void send(Object packet);
|
||||
}
|
||||
@@ -1,274 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.BungeeClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.VelocityClientInfo;
|
||||
import de.rayzs.pat.api.communication.impl.BukkitClient;
|
||||
import de.rayzs.pat.api.communication.impl.BungeeClient;
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.TinyGroup;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class Communicator {
|
||||
|
||||
private static final Client CLIENT =
|
||||
Reflection.isVelocityServer() ? new VelocityClient()
|
||||
: Reflection.isProxyServer() ? new BungeeClient()
|
||||
: new BukkitClient();
|
||||
|
||||
private static final UUID SERVER_ID = UUID.randomUUID();
|
||||
|
||||
public static final List<ClientInfo> CLIENTS = new ArrayList<>();
|
||||
|
||||
public static int SERVER_DATA_SYNC_COUNT = 0;
|
||||
public static long LAST_DATA_UPDATE = System.currentTimeMillis(),
|
||||
LAST_SENT_REQUEST = 0,
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
|
||||
public static void sendPacket(Object packet) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
|
||||
CLIENT.send(packet);
|
||||
}
|
||||
|
||||
public static void sendPacket(ClientInfo clientInfo, Object packet) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(packet));
|
||||
}
|
||||
|
||||
public static void receiveInformation(String serverName, Object packet) {
|
||||
ClientInfo client = getClientByName(serverName);
|
||||
|
||||
if (packet instanceof CommunicationPackets.RequestPacket requestPacket) {
|
||||
if (!requestPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
if (client == null) {
|
||||
client = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(requestPacket.getServerId(), serverName)
|
||||
: new BungeeClientInfo(requestPacket.getServerId(), serverName);
|
||||
|
||||
CLIENTS.add(client);
|
||||
}
|
||||
|
||||
if (!client.compareId(requestPacket.getServerId()))
|
||||
client.setId(requestPacket.getServerId());
|
||||
|
||||
syncData(client.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.NotificationPacket notificationPacket) {
|
||||
if (!notificationPacket.isToken(Storage.TOKEN) || Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitLoader.handleNotificationPacket(notificationPacket);
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.UpdateCommandsPacket updateCommandsPacket) {
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
BukkitLoader.handleUpdateCommandsPacket(updateCommandsPacket);
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket permissionResetPacket) {
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
if (!permissionResetPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
if (permissionResetPacket.hasTarget())
|
||||
PermissionUtil.setPlayerPermissions(permissionResetPacket.getTargetUUID());
|
||||
else
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.BackendDataPacket backendDataPacket) {
|
||||
if (!backendDataPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
Storage.SERVER_NAME = backendDataPacket.getServerName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.FeedbackPacket feedbackPacket) {
|
||||
if (!feedbackPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
String serverId = feedbackPacket.getServerId();
|
||||
|
||||
if (client == null) {
|
||||
client = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(feedbackPacket.getServerId(), serverName)
|
||||
: new BungeeClientInfo(feedbackPacket.getServerId(), serverName);
|
||||
|
||||
CLIENTS.add(client);
|
||||
}
|
||||
|
||||
if (!client.compareId(feedbackPacket.getServerId()))
|
||||
client.setId(feedbackPacket.getServerId());
|
||||
|
||||
if (client.hasSentFeedback())
|
||||
return;
|
||||
|
||||
client.setFeedback(true);
|
||||
client.syncTime();
|
||||
SERVER_DATA_SYNC_COUNT++;
|
||||
|
||||
CommunicationPackets.BackendDataPacket backendDataPacket = new CommunicationPackets.BackendDataPacket(Storage.TOKEN, serverId, serverName);
|
||||
sendPacket(client, backendDataPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.PacketBundle packetBundle) {
|
||||
if (!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString()))
|
||||
return;
|
||||
|
||||
Storage.USE_VELOCITY = packetBundle.isVelocity();
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
BukkitLoader.synchronize(packetBundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncData() {
|
||||
syncData(null);
|
||||
}
|
||||
|
||||
public static void syncData(String serverId) {
|
||||
if (!Reflection.isProxyServer() || Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
return;
|
||||
|
||||
LAST_DATA_UPDATE = System.currentTimeMillis();
|
||||
ClientInfo clientInfo;
|
||||
|
||||
if(serverId == null) {
|
||||
SERVER_DATA_SYNC_COUNT = 0;
|
||||
CLIENTS.forEach(currentClient -> syncData(currentClient.getId()));
|
||||
return;
|
||||
|
||||
} else {
|
||||
clientInfo = getClientById(serverId);
|
||||
|
||||
if (clientInfo != null)
|
||||
clientInfo.setFeedback(false);
|
||||
|
||||
SERVER_DATA_SYNC_COUNT = Math.max(0, SERVER_DATA_SYNC_COUNT -1);
|
||||
}
|
||||
|
||||
CommunicationPackets.CommandsPacket commandsPacket = new CommunicationPackets.CommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket;
|
||||
CommunicationPackets.PacketBundle bundle;
|
||||
List<String> commands = new ArrayList<>();
|
||||
String tempServerName = "";
|
||||
|
||||
if (clientInfo != null && clientInfo.getName() != null) {
|
||||
tempServerName = clientInfo.getName();
|
||||
|
||||
if (!Storage.Blacklist.isIgnoredServer(tempServerName))
|
||||
commands.addAll(Storage.Blacklist.getBlacklist().getCommands());
|
||||
|
||||
List<GeneralBlacklist> serverBlacklists = Storage.Blacklist.getServerBlacklists(clientInfo.getName());
|
||||
serverBlacklists.stream().filter(serverBlacklist ->
|
||||
serverBlacklist != null && serverBlacklist.getCommands() != null
|
||||
).forEach(serverBlacklist ->
|
||||
commands.addAll(serverBlacklist.getCommands())
|
||||
);
|
||||
}
|
||||
|
||||
final String serverName = tempServerName;
|
||||
List<TinyGroup> groups = new ArrayList<>();
|
||||
|
||||
TinyGroup tinyGroup;
|
||||
for (Group group : GroupManager.getGroups()) {
|
||||
if (groups.stream().anyMatch(cTG -> cTG.getGroupName().equals(group.getGroupName())))
|
||||
continue;
|
||||
|
||||
tinyGroup = new TinyGroup(group.getGroupName(), group.getPriority(), group.getAllCommands(serverName));
|
||||
for (GroupBlacklist groupBlacklist : group.getAllServerGroupBlacklist(serverName))
|
||||
tinyGroup.addAll(groupBlacklist.getCommands());
|
||||
|
||||
groups.add(tinyGroup);
|
||||
}
|
||||
|
||||
groupsPacket = new CommunicationPackets.GroupsPacket(groups);
|
||||
commandsPacket.setTurnBlacklistToWhitelist(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
commandsPacket.setCommands(commands);
|
||||
|
||||
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
|
||||
|
||||
PATEventHandler.callSentSyncEvents(bundle, serverName);
|
||||
}
|
||||
|
||||
public static void sendRequest() {
|
||||
if(System.currentTimeMillis() - LAST_SENT_REQUEST >= 5000) {
|
||||
LAST_SENT_REQUEST = System.currentTimeMillis();
|
||||
sendPacket(new CommunicationPackets.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPermissionReset() {
|
||||
if (Reflection.isProxyServer()) {
|
||||
sendPacket(new CommunicationPackets.ForcePermissionResetPacket(Storage.TOKEN));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendNotificationPacket(CommandSender targetSender, String displayedCommand) {
|
||||
if (!Storage.ConfigSections.Settings.FORWARD_CONSOLE_NOTIFICATIONS.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String serverName = targetSender.getServerName();
|
||||
|
||||
for (ClientInfo client : CLIENTS) {
|
||||
if (client.getName().equalsIgnoreCase(serverName)) {
|
||||
sendPacket(client, new CommunicationPackets.NotificationPacket(Storage.TOKEN, targetSender.getUniqueId(), displayedCommand));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendUpdateCommand() {
|
||||
if (Reflection.isProxyServer()) {
|
||||
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendUpdateCommand(UUID targetUUID) {
|
||||
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN, targetUUID));
|
||||
}
|
||||
|
||||
public static void sendFeedback() {
|
||||
sendPacket(new CommunicationPackets.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
|
||||
public static Client getClient() {
|
||||
return CLIENT;
|
||||
}
|
||||
|
||||
public static ClientInfo getClientById(String id) {
|
||||
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.compareId(id)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ClientInfo getClientByName(String name) {
|
||||
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client;
|
||||
|
||||
import de.rayzs.pat.utils.TimeConverter;
|
||||
|
||||
public abstract class ClientInfo {
|
||||
|
||||
private String id, name;
|
||||
|
||||
private boolean sentFeedback = false;
|
||||
private long syncTime = System.currentTimeMillis();
|
||||
|
||||
public ClientInfo(String serverId) {
|
||||
this.id = serverId;
|
||||
}
|
||||
|
||||
public ClientInfo(String serverId, String name) {
|
||||
this.id = serverId;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public abstract void sendBytes(byte[] bytes);
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setId(String serverId) {
|
||||
this.id = serverId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean compareId(String id) {
|
||||
return this.id.equals(id);
|
||||
}
|
||||
|
||||
public void syncTime() {
|
||||
syncTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getSyncTime() {
|
||||
return TimeConverter.calcAndGetTime(syncTime);
|
||||
}
|
||||
|
||||
public void setFeedback(boolean state) {
|
||||
this.sentFeedback = state;
|
||||
}
|
||||
|
||||
public boolean hasSentFeedback() {
|
||||
return sentFeedback;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class BungeeClientInfo extends ClientInfo {
|
||||
|
||||
public BungeeClientInfo(String serverId) {
|
||||
super(serverId);
|
||||
}
|
||||
|
||||
public BungeeClientInfo(String serverId, String name) {
|
||||
super(serverId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBytes(byte[] bytes) {
|
||||
try {
|
||||
ProxyServer server = BungeeLoader.getPlugin().getProxy();
|
||||
|
||||
server.getServers().entrySet().stream().filter(entry ->
|
||||
entry.getKey().equalsIgnoreCase(getName())
|
||||
).forEach(entry ->
|
||||
entry.getValue().sendData(Client.CHANNEL_NAME, bytes)
|
||||
);
|
||||
|
||||
} catch (NoClassDefFoundError exception) {
|
||||
Logger.warning("Failed to send data to backend servers! :c");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
|
||||
public class VelocityClientInfo extends ClientInfo {
|
||||
|
||||
public VelocityClientInfo(String serverId) {
|
||||
super(serverId);
|
||||
}
|
||||
|
||||
public VelocityClientInfo(String serverId, String name) {
|
||||
super(serverId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBytes(byte[] bytes) {
|
||||
VelocityLoader.getServer().getAllServers().stream().filter(server ->
|
||||
server.getServerInfo().getName().equalsIgnoreCase(getName())
|
||||
).forEach(server ->
|
||||
server.sendPluginMessage(VelocityClient.getIdentifier(), bytes)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.*;
|
||||
|
||||
public class BukkitClient implements Client, PluginMessageListener {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
|
||||
public BukkitClient() {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
try {
|
||||
|
||||
SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||
|
||||
if (!channel.equals(CHANNEL_NAME))
|
||||
return;
|
||||
|
||||
try {
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class BungeeClient implements Client, Listener {
|
||||
|
||||
private static final ProxyServer SERVER = ProxyServer.getInstance();
|
||||
|
||||
public BungeeClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.registerChannel(CHANNEL_NAME);
|
||||
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
|
||||
|
||||
try {
|
||||
|
||||
serverInfo.sendData(CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME))
|
||||
return;
|
||||
|
||||
try {
|
||||
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
Server server = (Server) event.getSender();
|
||||
Communicator.receiveInformation(server.getInfo().getName(), packetObj);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
|
||||
public class VelocityClient implements Client {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
|
||||
|
||||
public VelocityClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.getChannelRegistrar().register(IDENTIFIER);
|
||||
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
|
||||
|
||||
try {
|
||||
|
||||
registeredServer.sendPluginMessage(IDENTIFIER, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (event.getIdentifier() != IDENTIFIER)
|
||||
return;
|
||||
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
ServerConnection server = (ServerConnection) event.getSource();
|
||||
Communicator.receiveInformation(server.getServerInfo().getName(), packetObj);
|
||||
}
|
||||
|
||||
public static MinecraftChannelIdentifier getIdentifier() {
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class PATEvent<T> {
|
||||
|
||||
private final Object senderObj;
|
||||
private final CommandSender player;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PATEvent(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
public PATEvent(CommandSender player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public abstract void handle(T t);
|
||||
@@ -14,8 +16,8 @@ public abstract class PATEvent<T> {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
public Object getSenderObj() {
|
||||
return senderObj;
|
||||
public CommandSender getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -10,12 +10,11 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(player, command, blocked, notify);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ExecuteCommandEvent) {
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) patEvent;
|
||||
if (patEvent instanceof ExecuteCommandEvent executeCommandEvent) {
|
||||
executeCommandEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -23,38 +22,35 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(CommandSender player, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(player, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof FilteredSuggestionEvent) {
|
||||
FilteredSuggestionEvent filteredSuggestion = (FilteredSuggestionEvent) patEvent;
|
||||
filteredSuggestion.handle(event);
|
||||
if (patEvent instanceof FilteredSuggestionEvent filteredSuggestionEvent) {
|
||||
filteredSuggestionEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(CommandSender player, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(player, cursor, completion);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof FilteredTabCompletionEvent) {
|
||||
FilteredTabCompletionEvent filteredTabCompletion = (FilteredTabCompletionEvent) patEvent;
|
||||
filteredTabCompletion.handle(event);
|
||||
if (patEvent instanceof FilteredTabCompletionEvent filteredTabCompletionEvent) {
|
||||
filteredTabCompletionEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(player, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ServerPlayersChangeEvent) {
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
if (patEvent instanceof ServerPlayersChangeEvent serverPlayersChangeEvent) {
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -66,8 +62,7 @@ public class PATEventHandler {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePluginEvent) {
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
if (patEvent instanceof UpdatePluginEvent updatePluginEvent) {
|
||||
updatePluginEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -75,12 +70,11 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands, serverBased);
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(player, commands, serverBased);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePlayerCommandsEvent) {
|
||||
UpdatePlayerCommandsEvent updatePlayerCommandsEvent = (UpdatePlayerCommandsEvent) patEvent;
|
||||
if (patEvent instanceof UpdatePlayerCommandsEvent updatePlayerCommandsEvent) {
|
||||
updatePlayerCommandsEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -88,12 +82,11 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(dataSyncPacket, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof SentSyncEvent) {
|
||||
SentSyncEvent sentSyncEvent = (SentSyncEvent) patEvent;
|
||||
if (patEvent instanceof SentSyncEvent sentSyncEvent) {
|
||||
sentSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -101,13 +94,12 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(dataSyncPacket);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ReceiveSyncEvent) {
|
||||
ReceiveSyncEvent proxySyncEvent = (ReceiveSyncEvent) patEvent;
|
||||
proxySyncEvent.handle(event);
|
||||
if (patEvent instanceof ReceiveSyncEvent receiveSyncEvent) {
|
||||
receiveSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,8 +116,8 @@ public class PATEventHandler {
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(player, type) {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
@@ -133,8 +125,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
return new SentSyncEvent(null, packetBundle, serverName) {
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
return new SentSyncEvent(null, dataSyncPacket, serverName) {
|
||||
@Override
|
||||
public void handle(SentSyncEvent event) {
|
||||
|
||||
@@ -142,8 +134,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.PacketBundle packetBundle) {
|
||||
return new ReceiveSyncEvent(null, packetBundle) {
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
return new ReceiveSyncEvent(null, dataSyncPacket) {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
|
||||
@@ -151,8 +143,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(playerObj, commands, serverBased) {
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(player, commands, serverBased) {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
|
||||
@@ -169,8 +161,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(player, command, blocked, notify) {
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
@@ -178,8 +170,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(senderObj, suggestions) {
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(player, suggestions) {
|
||||
@Override
|
||||
public void handle(FilteredSuggestionEvent event) {
|
||||
|
||||
@@ -187,8 +179,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(Object senderObj, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(senderObj, cursor, completion) {
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(CommandSender player, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(player, cursor, completion) {
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
|
||||
|
||||
@@ -9,13 +10,15 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
super(null);
|
||||
|
||||
this.blocked = false;
|
||||
this.notify = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
super(senderObj);
|
||||
public ExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
super(player);
|
||||
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
this.notify = notify;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestionEvent> {
|
||||
@@ -12,8 +14,9 @@ public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestio
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
super(senderObj);
|
||||
public FilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
super(player);
|
||||
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCompletionEvent> {
|
||||
@@ -10,12 +12,14 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
super(null);
|
||||
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Object senderObj, String cursor, List<String> completion) {
|
||||
super(senderObj);
|
||||
public FilteredTabCompletionEvent(CommandSender player, String cursor, List<String> completion) {
|
||||
super(player);
|
||||
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
@@ -2,22 +2,24 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
|
||||
|
||||
public ReceiveSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
this.dataSyncPacket = null;
|
||||
}
|
||||
|
||||
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
public ReceiveSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
super(player);
|
||||
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
return dataSyncPacket;
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,24 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
|
||||
private final String serverName;
|
||||
|
||||
public SentSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
|
||||
this.dataSyncPacket = null;
|
||||
this.serverName = null;
|
||||
}
|
||||
|
||||
public SentSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
public SentSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
super(player);
|
||||
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@@ -24,7 +27,7 @@ public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
return dataSyncPacket;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
super(senderObj);
|
||||
public ServerPlayersChangeEvent(CommandSender player, Type type) {
|
||||
super(player);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCommandsEvent> {
|
||||
@@ -12,8 +14,9 @@ public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCom
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePlayerCommandsEvent(Object senderObj, List<String> commands, boolean serverBased) {
|
||||
super(senderObj);
|
||||
public UpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
super(player);
|
||||
|
||||
this.commands = commands;
|
||||
this.serverBased = serverBased;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
|
||||
@@ -8,7 +9,7 @@ public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePluginEvent(Object senderObj) {
|
||||
super(senderObj);
|
||||
public UpdatePluginEvent(CommandSender player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
this.blocked = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.blocked = cancel;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends Event {
|
||||
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
public List<String> getSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends Event {
|
||||
|
||||
private String cursor;
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
return completion;
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,18 @@ package de.rayzs.pat.api.storage;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.messages.*;
|
||||
import de.rayzs.pat.api.storage.config.settings.*;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -60,14 +60,11 @@ public class Storage {
|
||||
|
||||
public static final List<UUID> NOTIFY_PLAYERS = new ArrayList<>();
|
||||
|
||||
public static String TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static String TOKEN = "", CENSORED_TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static boolean OUTDATED = false, SEND_CONSOLE_NOTIFICATION = true;
|
||||
public static Object PLUGIN_OBJECT;
|
||||
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
|
||||
public static long LAST_SYNC = System.currentTimeMillis();
|
||||
|
||||
public static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
|
||||
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false;
|
||||
|
||||
private final static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
|
||||
private static PermissionPlugin PERMISSION_PLUGIN = PermissionPlugin.NONE;
|
||||
|
||||
public static void initialize(PluginLoader loader, String currentVersion) {
|
||||
@@ -83,6 +80,7 @@ public class Storage {
|
||||
PERMISSION_PLUGIN = permissionPlugin;
|
||||
}
|
||||
|
||||
|
||||
public static void broadcastPermissionsPluginNotice() {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
return;
|
||||
@@ -101,9 +99,9 @@ public class Storage {
|
||||
loadToken();
|
||||
|
||||
if (TOKEN != null && !TOKEN.isEmpty()) {
|
||||
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 3);
|
||||
String censoredTokenDisplay = "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
|
||||
Logger.info("Token found! (" + censoredTokenDisplay + ")");
|
||||
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 2);
|
||||
CENSORED_TOKEN = TOKEN.charAt(0) + "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
|
||||
Logger.info("Token found! (" + CENSORED_TOKEN + ")");
|
||||
}
|
||||
|
||||
if (loadBlacklist) Blacklist.loadAll();
|
||||
@@ -175,19 +173,27 @@ public class Storage {
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
CustomServerBrand.get().refreshTask();
|
||||
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.start();
|
||||
Communicator.get().reload();
|
||||
BackendUpdater.get().restart();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
Communicator.Proxy2Backend.sendDataSync();
|
||||
}
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
ResponseHandler.update();
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
Storage.getLoader().handleReload();
|
||||
}
|
||||
@@ -200,14 +206,12 @@ public class Storage {
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
boolean isVelocity = Reflection.isVelocityServer();
|
||||
|
||||
if (server != null) {
|
||||
|
||||
Storage.Blacklist.clearServerBlacklists(server);
|
||||
Storage.Blacklist.loadCachedServerBlacklists(server);
|
||||
|
||||
List<String> associatedServers = getServers()
|
||||
final List<String> associatedServers = getServers()
|
||||
.stream()
|
||||
.filter(s -> !s.equals(server) && isServer(server, s))
|
||||
.toList();
|
||||
@@ -217,77 +221,71 @@ public class Storage {
|
||||
Storage.Blacklist.loadCachedServerBlacklists(s);
|
||||
});
|
||||
|
||||
if (isVelocity) {
|
||||
associatedServers.forEach(serverName -> {
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(serverName);
|
||||
final List<String> commands = Blacklist.Collector.collectAllServerCommands(serverName);
|
||||
|
||||
associatedServers.forEach(s -> {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(s);
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(s));
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId, s));
|
||||
final List<String> playerCommands = new ArrayList<>(commands);
|
||||
final List<String> groupCommands = Blacklist.Collector.collectAllPlayerGroupCommands(sender, serverName);
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
playerCommands.addAll(groupCommands);
|
||||
|
||||
SubArgument.get().getUpdateArgumentsHandler().updatePlayerArguments(sender, playerCommands, commands, groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
Storage.Blacklist.Experimental.forceCacheReset();
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
|
||||
if (isVelocity) {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(playerId));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
|
||||
final List<String> serverCommands = Storage.Blacklist.Collector.collectAllServerCommands(sender.getServerName());
|
||||
final List<String> playerCommands = new ArrayList<>(serverCommands);
|
||||
final List<String> groupCommands = Storage.Blacklist.Collector.collectAllPlayerGroupCommands(sender, sender.getServerName());
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, false);
|
||||
});
|
||||
}
|
||||
playerCommands.addAll(groupCommands);
|
||||
|
||||
SubArgument.get().getUpdateArgumentsHandler().updatePlayerArguments(sender, playerCommands, serverCommands, groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
GroupManager.clearServerGroupBlacklists();
|
||||
Communicator.syncData();
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
Communicator.sendPermissionReset();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
|
||||
if (!Reflection.isVelocityServer()) {
|
||||
BungeePacketAnalyzer.sendCommandsPacket();
|
||||
Communicator.sendUpdateCommand();
|
||||
}
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
return;
|
||||
}
|
||||
|
||||
getLoader().handleReload();
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
if (Reflection.getMinor() < 13) {
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
final List<String> commands = new ArrayList<>(Blacklist.BLACKLIST.getCommands());
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
} else {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
}
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
Storage.getLoader().updateCommands();
|
||||
}
|
||||
|
||||
// Quickly updates all player subarguments.
|
||||
public static void quickSubArgumentUpdate(UUID uuid) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(uuid));
|
||||
public static void tempCachePlayerToServer(UUID playerId, String server) {
|
||||
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
|
||||
}
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
public static String getTempCachedPlayerToServer(UUID playerId, String server) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
}
|
||||
|
||||
public static String getCachedPlayerServername(UUID playerId) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
}
|
||||
|
||||
public static PluginLoader getLoader() {
|
||||
@@ -346,23 +344,24 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
public static AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
public static PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
|
||||
public static CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
|
||||
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
|
||||
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
|
||||
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
|
||||
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
|
||||
public static ForwardConsoleNotificationAlertsSection FORWARD_CONSOLE_NOTIFICATIONS = new ForwardConsoleNotificationAlertsSection();
|
||||
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static UpdateGroupsPerWorldSection UPDATE_GROUPS_PER_WORLD = new UpdateGroupsPerWorldSection();
|
||||
public static UpdateGroupsPerServerSection UPDATE_GROUPS_PER_SERVER = new UpdateGroupsPerServerSection();
|
||||
public static final AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static final AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static final BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static final HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
public static final InjectionFailedSection INJECTION_FAILED = new InjectionFailedSection();
|
||||
public static final PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
|
||||
public static final CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
|
||||
public static final CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
|
||||
public static final CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
|
||||
public static final CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
|
||||
public static final DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
|
||||
public static final ForwardConsoleNotificationAlertsSection FORWARD_CONSOLE_NOTIFICATIONS = new ForwardConsoleNotificationAlertsSection();
|
||||
public static final CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static final CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static final TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static final BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static final UpdateGroupsPerWorldSection UPDATE_GROUPS_PER_WORLD = new UpdateGroupsPerWorldSection();
|
||||
public static final UpdateGroupsPerServerSection UPDATE_GROUPS_PER_SERVER = new UpdateGroupsPerServerSection();
|
||||
|
||||
public static UpdateSection UPDATE = new UpdateSection();
|
||||
|
||||
@@ -450,7 +449,62 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
public static class Experimental {
|
||||
public static class Collector {
|
||||
|
||||
|
||||
/**
|
||||
* Collects all commands from the global section and
|
||||
* that certain server.
|
||||
*
|
||||
* @param serverName Target server name.
|
||||
* @return List of collected commands.
|
||||
*/
|
||||
public static List<String> collectAllServerCommands(String serverName) {
|
||||
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
|
||||
if (!Reflection.isProxyServer())
|
||||
return commands;
|
||||
|
||||
if (serverName == null)
|
||||
return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getServerBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all available commands for a player
|
||||
* based on the PAT groups the player is in.
|
||||
*
|
||||
* @param sender Target player.
|
||||
* @param serverName Target server name.
|
||||
* @return List of collected commands.
|
||||
*/
|
||||
public static List<String> collectAllPlayerGroupCommands(CommandSender sender, String serverName) {
|
||||
final List<String> commands = new ArrayList<>();
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if (serverName == null) {
|
||||
groups.forEach(group -> commands.addAll(group.getCommands()));
|
||||
return commands;
|
||||
}
|
||||
|
||||
groups.forEach(group -> {
|
||||
commands.addAll(group.getCommands());
|
||||
|
||||
group.getBlacklistServerNames(serverName).forEach(s -> {
|
||||
commands.addAll(group.getCommands(s));
|
||||
});
|
||||
});
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Experimental {
|
||||
|
||||
public static void forceCacheReset() {
|
||||
for (Object o : CACHED_SERVER_BLACKLIST.getCache().asMap().keySet()) {
|
||||
@@ -493,7 +547,7 @@ public class Storage {
|
||||
// Temporary list for all servers (e.g: server-1)
|
||||
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
|
||||
public static void loadAll() {
|
||||
private static void loadAll() {
|
||||
CACHED_SERVER_BLACKLIST.clear();
|
||||
SERVER_BLACKLISTS.clear();
|
||||
BLACKLIST.load();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class InfoSection extends ConfigStorage {
|
||||
|
||||
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED;
|
||||
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED, SYNC_WAITING;
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public InfoSection() {
|
||||
@@ -20,6 +21,11 @@ public class InfoSection extends ConfigStorage {
|
||||
VERSION_UPDATED = new ConfigSectionHelper<String>(this, "version.updated", "&aLatest version").getOrSet();
|
||||
VERSION_OUTDATED = new ConfigSectionHelper<String>(this, "version.outdated", "&cOutdated (%newest_version%)").getOrSet();
|
||||
SYNC_TIME = new ConfigSectionHelper<String>(this, "proxy-sync.time", "&e%time%").getOrSet();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
SYNC_WAITING = new ConfigSectionHelper<String>(this, "proxy-sync.waiting", "&cWaiting to establish connection...").getOrSet();
|
||||
}
|
||||
|
||||
SYNC_DISABLED = new ConfigSectionHelper<String>(this, "proxy-sync.disabled", "&cDisabled").getOrSet();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message",
|
||||
@@ -28,6 +34,7 @@ public class InfoSection extends ConfigStorage {
|
||||
, "&7 Version: &e%current_version%"
|
||||
, "&7 Status: %version_status%"
|
||||
, "&7 Last sync with proxy: &e%sync_time%"
|
||||
, "&7 Last received alive packet: %last_alive_response%"
|
||||
, "&7 Proxy sync-token: &e%token%"
|
||||
, "&7 Proxy-received server name: &e%sync_server_name%"
|
||||
)
|
||||
|
||||
@@ -18,12 +18,17 @@ public class StatsSection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NO_SERVER = new ConfigSectionHelper<String>(this, "no-server", "&cNone!").getOrSet();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "message.splitter", "&7, ").getOrSet();
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(%updated%)").getOrSet();
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(&a%last_alive_response% &8/ &2%updated%&8)").getOrSet();
|
||||
STATISTIC = new MultipleMessagesHelper(this, "message.statistic", Arrays.asList(
|
||||
"&7Last sync sent to &f%server_count% &7servers. &8&o(%last_sync_time% ago)",
|
||||
"&7Format: &eserver (last alive packet / last sync packet)",
|
||||
"&7Last sync sent to &f%server_count% &7server(s) &e%last_sync_time% &7ago:",
|
||||
"&7Sent to servers: &f%servers%"
|
||||
));
|
||||
}
|
||||
|
||||
-3
@@ -17,9 +17,6 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package de.rayzs.pat.api.storage.config.settings;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
@@ -33,6 +34,6 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
}
|
||||
|
||||
public boolean doesBypass(CommandSender sender) {
|
||||
return !ENABLED || sender.hasPermission("namespace");
|
||||
return !ENABLED || PermissionUtil.hasPermission(sender, "namespace");
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -10,7 +10,7 @@ import java.util.Arrays;
|
||||
|
||||
public class CustomProtocolPingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST;
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST, USE_CENTER_VARIABLE;
|
||||
public String PROTOCOL;
|
||||
|
||||
public MultipleMessagesHelper PLAYERLIST;
|
||||
@@ -25,7 +25,7 @@ public class CustomProtocolPingSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.getMinor() < 12))
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.isBefore(1, 12)))
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
@@ -42,6 +42,7 @@ public class CustomProtocolPingSection extends ConfigStorage {
|
||||
"&8> &7Using &fProAntiTab"
|
||||
));
|
||||
|
||||
USE_CENTER_VARIABLE = PLAYERLIST.getLines().stream().anyMatch(l -> l.startsWith("%center%"));
|
||||
|
||||
|
||||
if (HIDE_PLAYERS && USE_CUSTOM_PLAYERLIST) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class DisableSyncSection extends ConfigStorage {
|
||||
|
||||
public boolean DISABLED;
|
||||
public boolean ENABLED;
|
||||
|
||||
public DisableSyncSection() {
|
||||
super("disable-sync");
|
||||
@@ -16,7 +16,11 @@ public class DisableSyncSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -6,7 +6,7 @@ import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class HandleThroughProxySection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALLOW_P2B_ACTIONS;
|
||||
|
||||
public boolean LOAD_FROM_ENV;
|
||||
public String ENV_NAME;
|
||||
@@ -20,11 +20,13 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if(Reflection.isProxyServer()) return;
|
||||
if (Reflection.isProxyServer()) return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
|
||||
|
||||
ALLOW_P2B_ACTIONS = new ConfigSectionHelper<Boolean>(this, "allow-p2b-actions", false).getOrSet();
|
||||
|
||||
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class InjectionFailedSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED, SUPPRESS_EXCEPTIONS;
|
||||
public String KICK_MESSAGE, CONSOLE_MESSAGE;
|
||||
|
||||
public InjectionFailedSection() {
|
||||
super("injection-failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "kick-on-failure", true).getOrSet();
|
||||
SUPPRESS_EXCEPTIONS = new ConfigSectionHelper<Boolean>(this, "suppress-exceptions", false).getOrSet();
|
||||
KICK_MESSAGE = new ConfigSectionHelper<String>(this, "kick-message", "&cInjection process failed! Please reconnect.").getOrSet();
|
||||
CONSOLE_MESSAGE = new ConfigSectionHelper<String>(this, "console-message", "&cInjection process failed! (%player%)").getOrSet();
|
||||
}
|
||||
}
|
||||
-1
@@ -4,7 +4,6 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsReversedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsSortedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.utils.adapter.GroupManagerAdapter;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.BukkitCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.BukkitPluginMessageClient;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.BukkitServerBrand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.hooks.GroupManagerHook;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.TinyGroup;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.plugin.commands.BukkitCommand;
|
||||
import de.rayzs.pat.utils.hooks.ViaVersionHook;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.plugin.command.impl.BukkitCommand;
|
||||
import de.rayzs.pat.utils.hooks.PlaceholderHook;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
@@ -45,11 +51,15 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
private static boolean loaded = false, suggestions = false;
|
||||
private static Map<String, Command> commandsMap = null;
|
||||
private PATSchedulerTask updaterTask;
|
||||
|
||||
private final CommandsCache commandsCache = new CommandsCache();
|
||||
private final List<String> offlinePlayerNames = new ArrayList<>();
|
||||
|
||||
private Map<String, Command> commandsMap = null;
|
||||
|
||||
private BukkitAntiTabListener bukkitAntiTabListener = null;
|
||||
|
||||
private PATSchedulerTask updaterTask;
|
||||
private long lastCommandsLoad = -1;
|
||||
|
||||
@Override
|
||||
@@ -71,8 +81,9 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
loadCommandMap();
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(getServer());
|
||||
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
@@ -84,68 +95,97 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
new PlaceholderHook().register();
|
||||
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
|
||||
Communicator.initialize(new BukkitPluginMessageClient(), new BukkitCommunicationHandler());
|
||||
BackendUpdater.initialize();
|
||||
|
||||
bStats.initialize(this);
|
||||
|
||||
PluginManager manager = getServer().getPluginManager();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
loaded = true;
|
||||
GroupManager.initialize();
|
||||
BukkitPacketAnalyzer.injectAll();
|
||||
} else BackendUpdater.handle();
|
||||
} else BackendUpdater.get().handle();
|
||||
|
||||
manager.registerEvents(new BukkitPlayerListener(), this);
|
||||
manager.registerEvents(new BukkitBlockCommandListener(), this);
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
suggestions = true;
|
||||
manager.registerEvents(new BukkitAntiTabListener(), this);
|
||||
if (Reflection.isAtLeast(1, 13)) {
|
||||
bukkitAntiTabListener = new BukkitAntiTabListener();
|
||||
manager.registerEvents(bukkitAntiTabListener, this);
|
||||
}
|
||||
|
||||
if (Reflection.isPaper() && Reflection.getMinor() >= 12)
|
||||
if (Reflection.isPaper() && Reflection.isAtLeast(1, 12)) {
|
||||
manager.registerEvents(new PaperServerListPing(), this);
|
||||
}
|
||||
|
||||
registerCommand("proantitab", "pat");
|
||||
startUpdaterTask();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("LuckPerms") != null) {
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
} else {
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerAdapter.initialize(groupManagerPlugin);
|
||||
GroupManagerHook.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null)
|
||||
ViaVersionAdapter.initialize();
|
||||
|
||||
if (Storage.USE_SIMPLECLOUD) {
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null) {
|
||||
ViaVersionHook.initialize();
|
||||
}
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArguments.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BukkitServerBrand());
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Storage.reload();
|
||||
loadAllCommands();
|
||||
});
|
||||
|
||||
|
||||
for (final ProCommand command : CommandProcess.getCommands()) {
|
||||
addPermission(command.getName());
|
||||
}
|
||||
|
||||
for (final Group group : GroupManager.getGroups()) {
|
||||
addPermission("group." + group.getGroupName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(String permission) {
|
||||
permission = "proantitab." + permission;
|
||||
|
||||
final PluginManager manager = getServer().getPluginManager();
|
||||
if (manager.getPermission(permission) == null) {
|
||||
manager.addPermission(new Permission(permission));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {
|
||||
final PluginManager manager = getServer().getPluginManager();
|
||||
final Permission perm = manager.getPermission("proantitab." + permission);
|
||||
|
||||
if (perm != null) manager.removePermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.get().stop();
|
||||
BukkitPacketAnalyzer.uninjectAll();
|
||||
MessageTranslator.closeAudiences();
|
||||
}
|
||||
@@ -159,6 +199,30 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
if (bukkitAntiTabListener == null) return;
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
bukkitAntiTabListener.updateCommands(player);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
final Player player = Bukkit.getPlayer(sender.getUniqueId());
|
||||
|
||||
if (bukkitAntiTabListener != null) {
|
||||
assert player != null;
|
||||
bukkitAntiTabListener.updateCommands(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReload() {
|
||||
loadAllCommands();
|
||||
@@ -190,13 +254,20 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {}
|
||||
public void resetCommandsCache() {
|
||||
commandsCache.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return commandsCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return Bukkit.getPlayer(playerName) != null;
|
||||
@@ -271,6 +342,13 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}, 40);
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
@@ -283,107 +361,6 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
public static void handleNotificationPacket(CommunicationPackets.NotificationPacket packet) {
|
||||
if (!Storage.SEND_CONSOLE_NOTIFICATION) { return; }
|
||||
|
||||
final Player player = Bukkit.getPlayer(packet.getTargetUUID());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", packet.getDisplayedCommand(),
|
||||
"%server%", Storage.SERVER_NAME,
|
||||
"%world%", player.getWorld().getName());
|
||||
|
||||
Logger.info(notificationMessage);
|
||||
}
|
||||
|
||||
public static void handleUpdateCommandsPacket(CommunicationPackets.UpdateCommandsPacket packet) {
|
||||
|
||||
if (!packet.hasTargetUUID()) {
|
||||
Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(packet.getTargetUUID());
|
||||
if (player != null && Reflection.getMinor() >= 13) {
|
||||
player.updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
public static void synchronize(CommunicationPackets.PacketBundle packetBundle) {
|
||||
Storage.LAST_SYNC = System.currentTimeMillis();
|
||||
Communicator.sendFeedback();
|
||||
|
||||
CommunicationPackets.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
|
||||
CommunicationPackets.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
|
||||
CommunicationPackets.NamespaceCommandsPacket namespaceCommandsPacket = packetBundle.getNamespaceCommandsPacket();
|
||||
CommunicationPackets.MessagePacket messagePacket = packetBundle.getMessagePacket();
|
||||
|
||||
boolean updatedList = false;
|
||||
|
||||
if (!messagePacket.getBaseBlockedMessage().getLines().isEmpty())
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE = messagePacket.getBaseBlockedMessage();
|
||||
|
||||
if (!messagePacket.getSubBlockedMessage().getLines().isEmpty())
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE = messagePacket.getSubBlockedMessage();
|
||||
|
||||
if (!messagePacket.getPrefix().isEmpty())
|
||||
Storage.ConfigSections.Messages.PREFIX.PREFIX = messagePacket.getPrefix();
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED != namespaceCommandsPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED = namespaceCommandsPacket.isEnabled();
|
||||
|
||||
if (commandsPacket.getCommands() == null || commandsPacket.getCommands().isEmpty())
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
|
||||
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
|
||||
updatedList = true;
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED != commandsPacket.turnBlacklistToWhitelistEnabled())
|
||||
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED = commandsPacket.turnBlacklistToWhitelistEnabled();
|
||||
|
||||
Map<String, List<String>> cpyCache = new HashMap<>();
|
||||
GroupManager.getGroups().forEach(group -> {
|
||||
cpyCache.put(group.getGroupName(), group.getCommands());
|
||||
});
|
||||
|
||||
GroupManager.clearAllGroups();
|
||||
|
||||
for (TinyGroup group : groupsPacket.getGroups()) {
|
||||
List<String> currentExistingList = cpyCache.get(group.getGroupName());
|
||||
if (
|
||||
!updatedList
|
||||
&& currentExistingList != null
|
||||
&& !ArrayUtils.compareStringArrays(currentExistingList, group.getCommands())
|
||||
) {
|
||||
updatedList = true;
|
||||
}
|
||||
|
||||
GroupManager.setGroup(group.getGroupName(), group.getPriority(), group.getCommands());
|
||||
}
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = unknownCommandPacket.getMessage();
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED != unknownCommandPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = unknownCommandPacket.isEnabled();
|
||||
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13 && updatedList) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
}
|
||||
|
||||
PATEventHandler.callReceiveSyncEvents(packetBundle);
|
||||
}
|
||||
|
||||
public static List<String> getAllCommands() {
|
||||
return new ArrayList<>(commands);
|
||||
}
|
||||
@@ -397,7 +374,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames(String format) {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
@@ -416,7 +393,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
for (Map.Entry<String, Command> entry : commandsMap.entrySet()) {
|
||||
if (entry.getKey().toLowerCase().contains(":")) {
|
||||
String command = entry.getKey().substring(entry.getKey().lastIndexOf(":") + 1);
|
||||
|
||||
@@ -439,7 +416,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
pluginName = pluginName.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
for (Map.Entry<String, Command> entry : commandsMap.entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(pluginName.length() + 1);
|
||||
|
||||
@@ -518,14 +495,6 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
|
||||
}
|
||||
|
||||
public static Map<String, Command> getCommandsMap() {
|
||||
return commandsMap;
|
||||
}
|
||||
|
||||
public static boolean useSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
@@ -533,8 +502,4 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
public static java.util.logging.Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,25 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.BungeeCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.BungeePluginMessageClient;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.BungeeServerBrand;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.command.impl.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.listeners.bungee.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@@ -50,11 +55,10 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(getProxy());
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
@@ -62,8 +66,8 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
Storage.loadAll(true);
|
||||
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.initialize();
|
||||
|
||||
bStats.initialize(this);
|
||||
PluginManager manager = ProxyServer.getInstance().getPluginManager();
|
||||
|
||||
@@ -79,32 +83,29 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (manager.getPlugin("LuckPerms") != null)
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
|
||||
if(manager.getPlugin("PAPIProxyBridge") != null) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
Logger.info("Successfully hooked into PAPIProxyBridge!");
|
||||
}
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArguments.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BungeeServerBrand());
|
||||
Communicator.initialize(new BungeePluginMessageClient(), new BungeeCommunicationHandler());
|
||||
|
||||
// Reload proxy commands after 1, 5, and 15 seconds.
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
|
||||
@@ -126,6 +127,27 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReload() {
|
||||
BungeePacketAnalyzer.loadProxyCommands();
|
||||
@@ -135,9 +157,17 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
public void delayedPermissionsReload() {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
|
||||
Communicator.sendRequest();
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions(sender.getUniqueId());
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@@ -167,18 +197,23 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCommandsCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerServerName(UUID uuid) {
|
||||
final String cachedServerName = Storage.TEMP_PLAYER_SERVER_CACHE.get(uuid);
|
||||
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
|
||||
if (cachedServerName != null) {
|
||||
return cachedServerName;
|
||||
}
|
||||
@@ -270,7 +305,7 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames(String format) {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -8,14 +9,36 @@ import java.util.UUID;
|
||||
|
||||
public interface PluginLoader {
|
||||
|
||||
void addPermission(String permission);
|
||||
void removePermission(String permission);
|
||||
|
||||
Object getPluginObj();
|
||||
|
||||
void handleReload();
|
||||
boolean doesCommandExist(String command);
|
||||
|
||||
HashMap<String, CommandsCache> getCommandsCacheMap();
|
||||
/**
|
||||
* Updates commands for all players.
|
||||
* Requires PAT sync on proxy for it to work!
|
||||
* Non-proxy servers do not require anything additionally.
|
||||
*/
|
||||
void updateCommands();
|
||||
|
||||
/**
|
||||
* Updates commands for a certain player.
|
||||
* Requires PAT sync on proxy for it to work!
|
||||
* Non-proxy servers do not require anything additionally.
|
||||
*/
|
||||
void updateCommands(CommandSender sender);
|
||||
|
||||
HashMap<String, CommandsCache> getPerServerCommandsCacheMap();
|
||||
CommandsCache getBukkitCommandsCacheMap();
|
||||
|
||||
void delayedPermissionsReload();
|
||||
|
||||
void updateCommandCache();
|
||||
void delayedPermissionsReload(CommandSender sender);
|
||||
|
||||
void resetCommandsCache();
|
||||
|
||||
List<String> getServerNames();
|
||||
|
||||
@@ -48,6 +71,7 @@ public interface PluginLoader {
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
* %v = Plugin version
|
||||
* </pre>
|
||||
*/
|
||||
List<String> getPluginNames(String format);
|
||||
List<String> getFormattedPluginNames(String format);
|
||||
}
|
||||
@@ -4,22 +4,24 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.VelocityCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.VelocityPluginMessageClient;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.VelocityServerBrand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.commands.VelocityCommand;
|
||||
import de.rayzs.pat.plugin.command.impl.VelocityCommand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -33,13 +35,15 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.3.0",
|
||||
version = "2.3.4",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hides more than just your plugins.",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -79,17 +83,16 @@ public class VelocityLoader implements PluginLoader {
|
||||
Configurator.createResourcedFile("files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile("files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(server);
|
||||
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
Storage.initialize(this, pluginContainer.getDescription().getVersion().get());
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.initialize();
|
||||
|
||||
metricsFactory.make(this, 21638);
|
||||
@@ -102,29 +105,26 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
server.getScheduler().buildTask(this, () -> Communicator.syncData()).delay(5, TimeUnit.SECONDS).schedule();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (server.getPluginManager().getPlugin("luckperms").isPresent())
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
|
||||
if (server.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
Logger.info("Successfully hooked into PAPIProxyBridge!");
|
||||
}
|
||||
|
||||
if (Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArguments.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
CustomServerBrand.initialize(new VelocityServerBrand());
|
||||
|
||||
Communicator.initialize(new VelocityPluginMessageClient(), new VelocityCommunicationHandler());
|
||||
|
||||
VelocityPacketAnalyzer.injectAll();
|
||||
}
|
||||
@@ -133,22 +133,43 @@ public class VelocityLoader implements PluginLoader {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
resetCommandsCache();
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public static void delayedPlayerReload(UUID uuid) {
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
String serverName = Storage.getLoader().getPlayerServerName(uuid);
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(serverName));
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
commands.addAll(SubArguments.getGroupCommands(uuid, serverName));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, commands, true);
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
@@ -181,15 +202,20 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {
|
||||
public void resetCommandsCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return server.getPlayer(playerName).isPresent();
|
||||
@@ -221,7 +247,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public String getPlayerServerName(UUID uuid) {
|
||||
final String cachedServerName = Storage.TEMP_PLAYER_SERVER_CACHE.get(uuid);
|
||||
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
|
||||
if (cachedServerName != null) {
|
||||
return cachedServerName;
|
||||
}
|
||||
@@ -294,7 +320,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames(String format) {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
|
||||
+261
-256
@@ -1,256 +1,261 @@
|
||||
package de.rayzs.pat.plugin.process;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.info.*;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.*;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListGroupsCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListPrioritiesCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.NotifyCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.PostDebugCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.ReloadCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.UpdateCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServAddCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServClearCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServRemoveCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.list.ServListCommand;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandProcess {
|
||||
|
||||
private static final List<ProCommand> COMMANDS = new ArrayList<>();
|
||||
|
||||
public static void initialize() {
|
||||
COMMANDS.add(new SetPriorityCommand());
|
||||
COMMANDS.add(new NotifyCommand());
|
||||
|
||||
COMMANDS.add(new AddCommand());
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new ConvertCommand());
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
COMMANDS.add(new ExtractCommand());
|
||||
}
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
COMMANDS.add(new ListCommand());
|
||||
COMMANDS.add(new ListGroupsCommand());
|
||||
COMMANDS.add(new ListPrioritiesCommand());
|
||||
|
||||
COMMANDS.add(new StatsCommand());
|
||||
COMMANDS.add(new InfoCommand());
|
||||
COMMANDS.add(new PermsCommand());
|
||||
|
||||
COMMANDS.add(new PostDebugCommand());
|
||||
COMMANDS.add(new UpdateCommand());
|
||||
COMMANDS.add(new ReloadCommand());
|
||||
|
||||
// PROXY
|
||||
COMMANDS.add(new ServListCommand());
|
||||
|
||||
COMMANDS.add(new ServAddCommand());
|
||||
COMMANDS.add(new ServRemoveCommand());
|
||||
COMMANDS.add(new ServClearCommand());
|
||||
}
|
||||
|
||||
public static void handleCommand(Object senderObj, String[] args, String label) {
|
||||
CommandSender sender = CommandSenderHandler.from(senderObj);
|
||||
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, "use"))
|
||||
return;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
Storage.ConfigSections.Messages.HELP.MESSAGE.getLines().forEach(line -> {
|
||||
sender.sendMessage(line.replace("%label%", label));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String commandName = args[0];
|
||||
String[] commandArgs = new String[] {};
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
|
||||
if (args.length > 2) {
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return cmd.isCommand(servCommandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && !cmd.isProxyOnly() || Reflection.isProxyServer() && !cmd.isServerCommand())
|
||||
return cmd.isCommand(commandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<String> handleTabComplete(Object senderObj, String[] args) {
|
||||
CommandSender sender = CommandSenderHandler.from(senderObj);
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (!PermissionUtil.hasPermission(sender, "use"))
|
||||
return result;
|
||||
|
||||
if (args.length <= 1) {
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
result.addAll(Arrays.asList("serv", "server"));
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly())
|
||||
return false;
|
||||
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
String commandName = StringUtils.getFirstArg(args[0]);
|
||||
String[] commandArgs;
|
||||
Optional<ProCommand> optCommand;
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
|
||||
return false;
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[] {};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand()) {
|
||||
return cmd.isCommand(servCommandName) && PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
}
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
} else {
|
||||
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[]{};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly() || cmd.isServerCommand()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cmd.isCommand(commandName);
|
||||
}).findFirst();
|
||||
}
|
||||
|
||||
if (optCommand.isPresent()) {
|
||||
ProCommand command = optCommand.get();
|
||||
|
||||
if (PermissionUtil.hasPermission(sender, command.getName())) {
|
||||
List<String> cmdCompletions = command.tabComplete(sender, commandArgs);
|
||||
result.addAll(cmdCompletions != null ? cmdCompletions : List.of());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result.stream().filter(suggestion -> {
|
||||
|
||||
if (args.length == 0)
|
||||
return true;
|
||||
|
||||
String command = args[Math.max(0, args.length-1)].toLowerCase();
|
||||
suggestion = suggestion.toLowerCase();
|
||||
|
||||
if (command.startsWith("\"")) {
|
||||
command = command.length() == 1 ? "" : command.substring(1);
|
||||
}
|
||||
|
||||
return suggestion.startsWith(command);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.InfoCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.PermsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.StatsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.*;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListGroupsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListPrioritiesCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.NotifyCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.PostDebugCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.ReloadCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.UpdateCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServAddCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServClearCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServRemoveCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.list.ServListCommand;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandProcess {
|
||||
|
||||
private static final List<ProCommand> COMMANDS = new ArrayList<>();
|
||||
|
||||
public static void initialize() {
|
||||
COMMANDS.add(new SetPriorityCommand());
|
||||
COMMANDS.add(new NotifyCommand());
|
||||
|
||||
COMMANDS.add(new AddCommand());
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new ConvertCommand());
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
COMMANDS.add(new ExtractCommand());
|
||||
}
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
COMMANDS.add(new ListCommand());
|
||||
COMMANDS.add(new ListGroupsCommand());
|
||||
COMMANDS.add(new ListPrioritiesCommand());
|
||||
|
||||
COMMANDS.add(new StatsCommand());
|
||||
COMMANDS.add(new InfoCommand());
|
||||
COMMANDS.add(new PermsCommand());
|
||||
|
||||
COMMANDS.add(new PostDebugCommand());
|
||||
COMMANDS.add(new UpdateCommand());
|
||||
COMMANDS.add(new ReloadCommand());
|
||||
|
||||
// PROXY
|
||||
COMMANDS.add(new ServListCommand());
|
||||
|
||||
COMMANDS.add(new ServAddCommand());
|
||||
COMMANDS.add(new ServRemoveCommand());
|
||||
COMMANDS.add(new ServClearCommand());
|
||||
}
|
||||
|
||||
public static void handleCommand(Object senderObj, String[] args, String label) {
|
||||
CommandSender sender = CommandSender.from(senderObj);
|
||||
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, "use"))
|
||||
return;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
Storage.ConfigSections.Messages.HELP.MESSAGE.getLines().forEach(line -> {
|
||||
sender.sendMessage(line.replace("%label%", label));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String commandName = args[0];
|
||||
String[] commandArgs = new String[] {};
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
|
||||
if (args.length > 2) {
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return cmd.isCommand(servCommandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && !cmd.isProxyOnly() || Reflection.isProxyServer() && !cmd.isServerCommand())
|
||||
return cmd.isCommand(commandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<String> handleTabComplete(Object senderObj, String[] args) {
|
||||
CommandSender sender = CommandSender.from(senderObj);
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (!PermissionUtil.hasPermission(sender, "use"))
|
||||
return result;
|
||||
|
||||
if (args.length <= 1) {
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
result.addAll(Arrays.asList("serv", "server"));
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly())
|
||||
return false;
|
||||
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
String commandName = StringUtils.getFirstArg(args[0]);
|
||||
String[] commandArgs;
|
||||
Optional<ProCommand> optCommand;
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
|
||||
return false;
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[] {};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand()) {
|
||||
return cmd.isCommand(servCommandName) && PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
}
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
} else {
|
||||
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[]{};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly() || cmd.isServerCommand()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cmd.isCommand(commandName);
|
||||
}).findFirst();
|
||||
}
|
||||
|
||||
if (optCommand.isPresent()) {
|
||||
ProCommand command = optCommand.get();
|
||||
|
||||
if (PermissionUtil.hasPermission(sender, command.getName())) {
|
||||
List<String> cmdCompletions = command.tabComplete(sender, commandArgs);
|
||||
result.addAll(cmdCompletions != null ? cmdCompletions : List.of());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result.stream().filter(suggestion -> {
|
||||
|
||||
if (args.length == 0)
|
||||
return true;
|
||||
|
||||
String command = args[Math.max(0, args.length-1)].toLowerCase();
|
||||
suggestion = suggestion.toLowerCase();
|
||||
|
||||
if (command.startsWith("\"")) {
|
||||
command = command.length() == 1 ? "" : command.substring(1);
|
||||
}
|
||||
|
||||
return suggestion.startsWith(command);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public static List<ProCommand> getCommands() {
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.api.command;
|
||||
package de.rayzs.pat.plugin.command.commands;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -0,0 +1,64 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoCommand extends ProCommand {
|
||||
|
||||
public InfoCommand() {
|
||||
super(
|
||||
"info",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
String message = StringUtils.getStringList(Storage.ConfigSections.Messages.INFO.MESSAGE.getLines(), "\n");
|
||||
|
||||
String syncTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
|
||||
Reflection.isProxyServer()
|
||||
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()))
|
||||
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
|
||||
|
||||
String lastAlivePacketTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
|
||||
Reflection.isProxyServer()
|
||||
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()))
|
||||
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
|
||||
|
||||
|
||||
if (!Reflection.isProxyServer()
|
||||
&& !BackendUpdater.get().isConnected()
|
||||
&& Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
{
|
||||
syncTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
|
||||
lastAlivePacketTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
|
||||
}
|
||||
|
||||
|
||||
final String versionStatus = Storage.OUTDATED
|
||||
? Storage.ConfigSections.Messages.INFO.VERSION_OUTDATED
|
||||
: Storage.ConfigSections.Messages.INFO.VERSION_UPDATED;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%sync_time%", syncTime,
|
||||
"%last_alive_response%", lastAlivePacketTime,
|
||||
"%version_status%", versionStatus
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import java.util.*;
|
||||
+21
-16
@@ -1,13 +1,15 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class StatsCommand extends ProCommand {
|
||||
|
||||
@@ -29,26 +31,28 @@ public class StatsCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
final int length = Communicator.CLIENTS.size() - 1;
|
||||
boolean tmpFound = false;
|
||||
final Set<Client> clients = Communicator.get().getClients();
|
||||
final Iterator<Client> iterator = clients.iterator();
|
||||
|
||||
boolean tmpFound = false;
|
||||
StringBuilder statsBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < Communicator.CLIENTS.size(); i++) {
|
||||
ClientInfo client = Communicator.CLIENTS.get(i);
|
||||
while (iterator.hasNext()) {
|
||||
Client client = iterator.next();
|
||||
|
||||
if (!client.hasSentFeedback())
|
||||
continue;
|
||||
|
||||
if (!tmpFound)
|
||||
if (!tmpFound) {
|
||||
tmpFound = true;
|
||||
}
|
||||
|
||||
statsBuilder.append(StringUtils.replace(Storage.ConfigSections.Messages.STATS.SERVER,
|
||||
"%updated%", client.getSyncTime(), "%servername%", client.getName()
|
||||
"%updated%", client.getFormattedSyncTime(),
|
||||
"%servername%", client.getServerName(),
|
||||
"%last_alive_response%", client.getFormattedLastReceivedKeepAlivePacketTime()
|
||||
));
|
||||
|
||||
if (i <= length)
|
||||
if (iterator.hasNext()) {
|
||||
statsBuilder.append(Storage.ConfigSections.Messages.STATS.SPLITTER);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean found = tmpFound;
|
||||
@@ -56,8 +60,9 @@ public class StatsCommand extends ProCommand {
|
||||
Storage.ConfigSections.Messages.STATS.STATISTIC.getLines().forEach(message -> {
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%server_count%", String.valueOf(Communicator.SERVER_DATA_SYNC_COUNT),
|
||||
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.LAST_DATA_UPDATE),
|
||||
"%server_count%", String.valueOf(Communicator.get().getClients().size()),
|
||||
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()),
|
||||
"%last_alive_response_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()),
|
||||
"%servers%", found ? statsBuilder.toString() : Storage.ConfigSections.Messages.STATS.NO_SERVER
|
||||
);
|
||||
|
||||
+4
-3
@@ -1,10 +1,11 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+5
-3
@@ -1,9 +1,11 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ConvertCommand extends ProCommand {
|
||||
return false;
|
||||
|
||||
String converterName = args[0];
|
||||
Converter converter = StorageConverter.getConverter(converterName);
|
||||
Converter converter = StorageConverter.get().getConverter(converterName);
|
||||
if (converter == null) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
|
||||
"%converter%", converterName)
|
||||
@@ -46,6 +46,6 @@ public class ConvertCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return StorageConverter.getConverters().stream().toList();
|
||||
return StorageConverter.get().getConverters().stream().toList();
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -34,12 +34,13 @@ public class CreateGroupCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
String groupName = args[0];
|
||||
String groupName = args[0].toLowerCase();
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
boolean registered = group != null;
|
||||
|
||||
if (!registered) {
|
||||
GroupManager.registerGroup(groupName);
|
||||
Storage.getLoader().addPermission("group." + groupName);
|
||||
} else groupName = group.getGroupName();
|
||||
|
||||
String message = registered ? Storage.ConfigSections.Messages.GROUP.ALREADY_EXIST : Storage.ConfigSections.Messages.GROUP.CREATE;
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
@@ -58,6 +58,7 @@ public class DeleteGroupCommand extends ProCommand {
|
||||
}
|
||||
|
||||
GroupManager.unregisterGroup(groupName);
|
||||
Storage.getLoader().removePermission("group." + group.getGroupName());
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
|
||||
String message = registered ? Storage.ConfigSections.Messages.GROUP.DELETE : Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST;
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
@@ -88,7 +88,7 @@ public class ExtractCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> pluginNames = Storage.getLoader().getPluginNames("%n");
|
||||
List<String> pluginNames = Storage.getLoader().getFormattedPluginNames("%n");
|
||||
boolean pluginFound = false, all = pluginName.equalsIgnoreCase("*");
|
||||
|
||||
for (String name : pluginNames) {
|
||||
@@ -136,7 +136,7 @@ public class ExtractCommand extends ProCommand {
|
||||
final int length = args.length;
|
||||
|
||||
if (length <= 1) {
|
||||
final List<String> suggestions = Storage.getLoader().getPluginNames("%n");
|
||||
final List<String> suggestions = Storage.getLoader().getFormattedPluginNames("%n");
|
||||
suggestions.add("*");
|
||||
|
||||
return suggestions;
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListCommand extends ProCommand {
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
+3
-8
@@ -1,14 +1,9 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand extends ProCommand {
|
||||
+6
-16
@@ -1,12 +1,9 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -26,16 +23,14 @@ public class UpdateCommand extends ProCommand {
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByName(name);
|
||||
|
||||
if (playerObj != null) {
|
||||
CommandSender s = CommandSenderHandler.from(playerObj);
|
||||
CommandSender s = CommandSender.from(playerObj);
|
||||
|
||||
assert s != null;
|
||||
PermissionUtil.reloadPermissions(s);
|
||||
}
|
||||
});
|
||||
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
}
|
||||
Storage.getLoader().updateCommands();
|
||||
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
|
||||
return true;
|
||||
@@ -44,7 +39,7 @@ public class UpdateCommand extends ProCommand {
|
||||
String name = args[0];
|
||||
UUID uuid = Storage.getLoader().getUUIDByName(name);
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
CommandSender targetSender = CommandSenderHandler.from(playerObj);
|
||||
CommandSender targetSender = CommandSender.from(playerObj);
|
||||
|
||||
boolean exist = targetSender != null;
|
||||
|
||||
@@ -59,13 +54,8 @@ public class UpdateCommand extends ProCommand {
|
||||
message = message.replace("%target%", name);
|
||||
|
||||
if (exist) {
|
||||
|
||||
PermissionUtil.reloadPermissions(targetSender);
|
||||
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(uuid);
|
||||
}
|
||||
|
||||
Storage.getLoader().updateCommands(targetSender);
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server.list;
|
||||
package de.rayzs.pat.plugin.command.commands.server.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+27
-27
@@ -1,27 +1,27 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.*;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
if(commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
CommandProcess.handleCommand(player, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandProcess.handleCommand(commandSender, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.*;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
CommandProcess.handleCommand(player, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandProcess.handleCommand(commandSender, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.*;
|
||||
|
||||
public class BungeeCommand extends Command implements TabExecutor {
|
||||
|
||||
public BungeeCommand(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
CommandProcess.handleCommand(commandSender, strings, "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.*;
|
||||
|
||||
public class BungeeCommand extends Command implements TabExecutor {
|
||||
|
||||
public BungeeCommand(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
CommandProcess.handleCommand(commandSender, strings, "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -1,18 +1,18 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements SimpleCommand {
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return CommandProcess.handleTabComplete(invocation.source(), invocation.arguments());
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements SimpleCommand {
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return CommandProcess.handleTabComplete(invocation.source(), invocation.arguments());
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.plugin.converter.converters.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
public class StorageConverter {
|
||||
|
||||
private StorageConverter() {}
|
||||
|
||||
private static final Map<String, Converter> converters = new HashMap<>();
|
||||
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
if (!converters.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerConverter(new AdvancedPlHideConverter());
|
||||
registerConverter(new CommandWhitelistConverter());
|
||||
registerConverter(new PluginHiderPlus());
|
||||
registerConverter(new PlHideFree());
|
||||
registerConverter(new PlHidePro());
|
||||
}
|
||||
|
||||
public static Set<String> getConverters() {
|
||||
return converters.keySet();
|
||||
}
|
||||
|
||||
public static Converter getConverter(@NotNull String name) {
|
||||
return converters.get(name);
|
||||
}
|
||||
|
||||
public static void registerConverter(@NotNull Converter converter) {
|
||||
if (!converter.exists()) return;
|
||||
|
||||
converters.putIfAbsent(converter.getPluginName(), converter);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,9 @@ import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.utils.hooks.ViaVersionHook;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -20,17 +19,17 @@ import java.util.*;
|
||||
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
|
||||
private static final List<UUID> knownOperators = new ArrayList<>();
|
||||
private final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
|
||||
if (Storage.USE_VELOCITY) {
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,25 +41,18 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BukkitLoader.isLoaded()) {
|
||||
event.getCommands().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCommands().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
Storage.getLoader().getBukkitCommandsCacheMap().handleCommands(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands()
|
||||
: BukkitLoader.getAllCommands()
|
||||
);
|
||||
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
PermissionUtil.reloadPermissions(player.getUniqueId());
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
@@ -75,8 +67,8 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
final List<String> playerCommands = Storage.getLoader().getBukkitCommandsCacheMap().getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
@@ -95,57 +87,12 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getCommands() {
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands() : BukkitLoader.getAllCommands();
|
||||
}
|
||||
|
||||
private static boolean notUpdatablePlayer(UUID uuid) {
|
||||
return Storage.USE_VIAVERSION && Reflection.getMinor() >= 16 && ViaVersionAdapter.getPlayerProtocol(uuid) < 754;
|
||||
return Storage.USE_VIAVERSION && Reflection.isAtLeast(1, 16) && ViaVersionHook.getPlayerProtocol(uuid) < 754;
|
||||
}
|
||||
|
||||
|
||||
// --------------- LUCKPERMS SECTIONS --------------- //
|
||||
|
||||
public static void updateCommands() {
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::updateCommands);
|
||||
}
|
||||
|
||||
public static void updateCommands(Player player) {
|
||||
if (Reflection.getMinor() >= 13 && !notUpdatablePlayer(player.getUniqueId()))
|
||||
public void updateCommands(Player player) {
|
||||
if (!notUpdatablePlayer(player.getUniqueId()))
|
||||
player.updateCommands();
|
||||
}
|
||||
|
||||
|
||||
// --------------- UPDATE SECTIONS --------------- //
|
||||
|
||||
public static void handleTabCompletion() {
|
||||
COMMANDS_CACHE.reset();
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::handleTabCompletion);
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleTabCompletion(player, getCommands());
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player) {
|
||||
handleTabCompletion(player, getCommands());
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player, List<String> commands) {
|
||||
if (notUpdatablePlayer(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
List<String> dummy = new ArrayList<>(commands);
|
||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player, dummy);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
updateCommands(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,11 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -27,7 +28,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onUnknownCommandRecognition(PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final World world = player.getWorld();
|
||||
|
||||
String rawCommand = StringUtils.getFirstArg(event.getMessage()),
|
||||
@@ -51,7 +52,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
@@ -76,6 +77,8 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
worldName = world.getName();
|
||||
|
||||
command = command.substring(1);
|
||||
final String commandWithArguments = command;
|
||||
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
@@ -158,7 +161,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
sender,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -167,6 +170,17 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
sender.getServerName(),
|
||||
event.getMessage(),
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()
|
||||
), "%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
@@ -184,8 +198,30 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
sender.getServerName(),
|
||||
event.getMessage()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,41 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
BackendUpdater.handle();
|
||||
BackendUpdater.get().handle();
|
||||
}
|
||||
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
CustomServerBrand.get().preparePlayer(player);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (CustomServerBrand.isEnabled()) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
if (CustomServerBrand.get().isEnabled()) {
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
@@ -51,9 +47,7 @@ public class BukkitPlayerListener implements Listener {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
}, 20);
|
||||
|
||||
}
|
||||
@@ -63,18 +57,25 @@ public class BukkitPlayerListener implements Listener {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Failed to inject into player! (" + player.getName() + ")" );
|
||||
player.kickPlayer("Failed to inject player!");
|
||||
|
||||
if (Storage.ConfigSections.Settings.INJECTION_FAILED.ENABLED) {
|
||||
|
||||
Logger.info(MessageTranslator.replaceMessage(
|
||||
sender,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.CONSOLE_MESSAGE
|
||||
));
|
||||
|
||||
player.kickPlayer(MessageTranslator.replaceMessage(
|
||||
sender,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.KICK_MESSAGE
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Update sub arguments for <1.12.2 servers.
|
||||
if (Reflection.getMinor() < 13) {
|
||||
Storage.quickSubArgumentUpdate(uuid);
|
||||
}
|
||||
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
@@ -86,8 +87,11 @@ public class BukkitPlayerListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
BukkitPacketAnalyzer.uninject(player.getUniqueId());
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
@@ -98,18 +102,15 @@ public class BukkitPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import org.bukkit.profile.PlayerTextures;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.plaf.BorderUIResource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -52,8 +51,9 @@ public class PaperServerListPing implements Listener {
|
||||
|
||||
} else {
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line -> {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
|
||||
for (String line : Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines()) {
|
||||
if (line.contains("%players%")) {
|
||||
List<String> playerNames = Storage.getLoader().getOnlinePlayerNames();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PaperServerListPing implements Listener {
|
||||
"%players%", currentPlayerName, "&", "§"
|
||||
);
|
||||
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
lines.add(playerName);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -78,14 +78,47 @@ public class PaperServerListPing implements Listener {
|
||||
? Arrays.copyOfRange(nameSplit, 0, 30)
|
||||
: nameSplit;
|
||||
|
||||
for (String name : nameSplit) {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(name, RANDOM_UUID));
|
||||
}
|
||||
|
||||
lines.addAll(Arrays.asList(nameSplit));
|
||||
} else {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
lines.add(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CENTER_VARIABLE) {
|
||||
|
||||
int biggestLine = 0;
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = replaceString(lines.get(i), online, onlineExtend, max);
|
||||
lines.set(i, line);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
biggestLine = Math.max(biggestLine, Math.max(0, line.length() - 8));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
int length = Math.max(0, line.length() - 8);
|
||||
int diff = biggestLine - length;
|
||||
|
||||
int left = diff / 2;
|
||||
int right = diff - left;
|
||||
|
||||
line = " ".repeat(left)
|
||||
+ line.substring(8)
|
||||
+ " ".repeat(right);
|
||||
|
||||
lines.set(i, line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lines.forEach(line -> {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(line, RANDOM_UUID));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
@@ -28,7 +27,7 @@ public class BungeeAntiTabListener implements Listener {
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
@@ -80,7 +79,7 @@ public class BungeeAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
event.getSuggestions().clear();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -30,7 +31,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
|
||||
final ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
@@ -39,8 +40,13 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
final String commandWithArguments = command;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (Communicator.get().hasConnectedClients() && Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(command)) {
|
||||
command = command.toLowerCase();
|
||||
}
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
|
||||
@@ -52,7 +58,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
@@ -76,7 +82,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
@@ -118,7 +124,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
sender,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -127,10 +133,21 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getMessage(),
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()
|
||||
), "%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
@@ -149,8 +166,30 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getMessage()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import de.rayzs.pat.plugin.*;
|
||||
import net.md_5.bungee.event.*;
|
||||
import net.md_5.bungee.api.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeePingListener implements Listener {
|
||||
@@ -44,8 +45,43 @@ public class BungeePingListener implements Listener {
|
||||
List<String> lines = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines();
|
||||
ServerPing.PlayerInfo[] playerInfos = new ServerPing.PlayerInfo[lines.size()];
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(replaceString(lines.get(i), online, onlineExtend, max), "");
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CENTER_VARIABLE) {
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = replaceString(lines.get(i), online, onlineExtend, max);
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(line, "");
|
||||
}
|
||||
|
||||
} else {
|
||||
List<String> cpyLines = new ArrayList<>(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines());
|
||||
|
||||
int biggestLine = 0;
|
||||
for (int i = 0; i < cpyLines.size(); i++) {
|
||||
String line = replaceString(cpyLines.get(i), online, onlineExtend, max);
|
||||
cpyLines.set(i, line);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
biggestLine = Math.max(biggestLine, Math.max(0, line.length() - 8));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cpyLines.size(); i++) {
|
||||
String line = cpyLines.get(i);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
int length = Math.max(0, line.length() - 8);
|
||||
int diff = biggestLine - length;
|
||||
|
||||
int left = diff / 2;
|
||||
int right = diff - left;
|
||||
|
||||
line = " ".repeat(left)
|
||||
+ line.substring(8)
|
||||
+ " ".repeat(right);
|
||||
}
|
||||
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(line, "");
|
||||
}
|
||||
}
|
||||
|
||||
serverPing.getPlayers().setSample(playerInfos);
|
||||
|
||||
+16
-13
@@ -1,13 +1,13 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -22,14 +22,14 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
if(CustomServerBrand.get().isEnabled())
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
if (player.isConnected()) CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
@@ -50,7 +50,7 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
BungeePacketAnalyzer.inject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
@@ -60,13 +60,16 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
@@ -75,6 +78,6 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -30,7 +29,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName) || PermissionUtil.hasBypassPermission(sender)) {
|
||||
@@ -38,7 +37,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
@@ -61,7 +60,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
return playerCommands.contains(command.getKey());
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, new ArrayList<>(event.getCommands().keySet()));
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
public class VelocityAntiTabListener {
|
||||
|
||||
@@ -44,7 +43,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender) || event.getSuggestions().isEmpty() || player.getCurrentServer().isEmpty()) {
|
||||
return;
|
||||
@@ -60,7 +59,7 @@ public class VelocityAntiTabListener {
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, serverName);
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
@@ -85,7 +84,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
+53
-10
@@ -3,8 +3,10 @@ package de.rayzs.pat.plugin.listeners.velocity;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
@@ -13,8 +15,8 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.api.event.*;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,12 +43,19 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
|
||||
final Player player = (Player) commandSource;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final String serverName = player.getCurrentServer().isPresent()
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
final String command = StringUtils.getFirstArg(event.getCommand());
|
||||
final String commandWithArguments = event.getCommand().startsWith("/") ? event.getCommand().substring(1) : event.getCommand();
|
||||
|
||||
String tmpCommand = StringUtils.getFirstArg(event.getCommand());
|
||||
if (Communicator.get().hasConnectedClients() && Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(tmpCommand)) {
|
||||
tmpCommand = tmpCommand.toLowerCase();
|
||||
}
|
||||
|
||||
final String command = tmpCommand;
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return event;
|
||||
@@ -63,7 +72,7 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
@@ -87,7 +96,7 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
@@ -131,19 +140,32 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
|
||||
if (!allowed) {
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
sender,
|
||||
event.getCommand(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getCommand(),
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()
|
||||
), "%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return event;
|
||||
|
||||
Communicator.sendNotificationPacket(sender, displayCommand);
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(consoleSender, notificationMessage);
|
||||
@@ -161,10 +183,31 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
|
||||
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, false);
|
||||
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getCommand(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getCommand()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getCommand()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
+31
-19
@@ -2,11 +2,12 @@ package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@@ -15,7 +16,6 @@ import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -33,20 +33,19 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
sender.updateSenderObject(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
final ServerInfo serverInfo = event.getOriginalServer().getServerInfo();
|
||||
if (serverInfo != null) Storage.TEMP_PLAYER_SERVER_CACHE.put(player.getUniqueId(), serverInfo.getName());
|
||||
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
|
||||
}
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
if(CustomServerBrand.get().isEnabled())
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
if (player.isActive()) CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
@@ -66,12 +65,22 @@ public class VelocityConnectionListener {
|
||||
if (!VelocityPacketAnalyzer.isInjected(player)) {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Attempting delayed injection for " + player.getUsername());
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Second injection for " + player.getUsername() + " failed as well!");
|
||||
player.disconnect(Component.text("Failed to inject player!"));
|
||||
if (Storage.ConfigSections.Settings.INJECTION_FAILED.ENABLED) {
|
||||
|
||||
Logger.info(MessageTranslator.replaceMessage(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.CONSOLE_MESSAGE
|
||||
));
|
||||
|
||||
player.disconnect(Component.text(
|
||||
MessageTranslator.replaceMessage(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.KICK_MESSAGE
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
@@ -80,9 +89,9 @@ public class VelocityConnectionListener {
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
final ServerInfo serverInfo = event.getServer().getServerInfo();
|
||||
if (serverInfo != null) Storage.TEMP_PLAYER_SERVER_CACHE.put(player.getUniqueId(), serverInfo.getName());
|
||||
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
|
||||
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
@@ -91,13 +100,16 @@ public class VelocityConnectionListener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
VelocityPacketAnalyzer.uninject(player);
|
||||
|
||||
@@ -5,6 +5,9 @@ import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityPingListener {
|
||||
@@ -40,9 +43,43 @@ public class VelocityPingListener {
|
||||
builder.clearSamplePlayers();
|
||||
else if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CUSTOM_PLAYERLIST) {
|
||||
builder.clearSamplePlayers();
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line ->
|
||||
builder.samplePlayers(new ServerPing.SamplePlayer(replaceString(line, online, extend, max), RANDOM_UUID))
|
||||
);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CENTER_VARIABLE) {
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line ->
|
||||
builder.samplePlayers(new ServerPing.SamplePlayer(replaceString(line, online, extend, max), RANDOM_UUID))
|
||||
);
|
||||
|
||||
} else {
|
||||
List<String> cpyLines = new ArrayList<>(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines());
|
||||
|
||||
int biggestLine = 0;
|
||||
for (int i = 0; i < cpyLines.size(); i++) {
|
||||
String line = replaceString(cpyLines.get(i), online, extend, max);
|
||||
cpyLines.set(i, line);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
biggestLine = Math.max(biggestLine, Math.max(0, line.length() - 8));
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : cpyLines) {
|
||||
if (line.startsWith("%center%")) {
|
||||
int length = Math.max(0, line.length() - 8);
|
||||
int diff = biggestLine - length;
|
||||
|
||||
int left = diff / 2;
|
||||
int right = diff - left;
|
||||
|
||||
line = " ".repeat(left)
|
||||
+ line.substring(8)
|
||||
+ " ".repeat(right);
|
||||
}
|
||||
|
||||
builder.samplePlayers(new ServerPing.SamplePlayer(line, RANDOM_UUID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
event.setPing(builder.build());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.logger;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.logger.impl.*;
|
||||
@@ -22,9 +22,9 @@ public class Logger {
|
||||
private static final String LOG_HEADER;
|
||||
|
||||
static {
|
||||
final String software = Reflection.isProxyServer()
|
||||
? Reflection.isVelocityServer() ? "Velocity" : "Bungeecord"
|
||||
: (Reflection.isPaper() ? "Paper" : Reflection.isFoliaServer() ? "Folia" : "Spigot/Bukkit");
|
||||
final String software = Reflection.getSoftware().isProxySoftware()
|
||||
? Reflection.getSoftware().toString()
|
||||
: Reflection.getVersionName();
|
||||
|
||||
final String version = Reflection.isProxyServer() ? "" : " " + Reflection.getRawVersionName().replace("_", ".");
|
||||
|
||||
@@ -82,6 +82,12 @@ public class Logger {
|
||||
private static String createInfo() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
builder.append("Detected Software-API: ")
|
||||
.append(Reflection.getSoftware().toString())
|
||||
.append("\n\n");
|
||||
}
|
||||
|
||||
builder.append("Updated: ")
|
||||
.append(!Storage.OUTDATED)
|
||||
.append("\n\n");
|
||||
@@ -90,18 +96,8 @@ public class Logger {
|
||||
.append(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? "WHITELIST" : "BLACKLIST")
|
||||
.append("\n");
|
||||
|
||||
builder.append("Detected Software-API: ");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append(Reflection.isPaper() ? "Waterfall" : Reflection.isVelocityServer() ? "Velocity" : "Bungeecord");
|
||||
} else {
|
||||
builder.append(Reflection.isFoliaServer() ? "Folia" : Reflection.isPaper() ? "Paper" : "Spigot");
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
|
||||
builder.append("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
|
||||
.append(String.join("\n ", Storage.getLoader().getFormattedPluginNames("%n (%v)")))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Detected supported plugins:")
|
||||
@@ -131,7 +127,11 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Storage.LAST_SYNC) : "Deactivated")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Communicator.get().getLastSync()) : "Deactivated")
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-alive-response-packet: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()) : "Deactivated")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
@@ -145,13 +145,22 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Storage.LAST_SYNC)))
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Communicator.get().getLastSync())))
|
||||
.append("\n\n");
|
||||
|
||||
for (ClientInfo client : Communicator.CLIENTS) {
|
||||
builder.append("synced-server: ")
|
||||
.append(client.getName() + " (" + client.getSyncTime() + ")")
|
||||
.append(", ");
|
||||
builder.append("synced-server: ");
|
||||
Iterator<Client> iterator = Communicator.get().getClients().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Client clientInfo = iterator.next();
|
||||
|
||||
builder.append(clientInfo.getServerName())
|
||||
.append(" (")
|
||||
.append(clientInfo.getFormattedLastReceivedKeepAlivePacketTime() + " / " + clientInfo.getFormattedSyncTime())
|
||||
.append(")");
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
builder.append("\n\n");
|
||||
|
||||
+19
-13
@@ -1,8 +1,10 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers.LegacyPacketHandler;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers.ModernCommandsNodeHandler;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers.ModernPacketHandler;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.netty.bukkit.handlers.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
@@ -10,7 +12,6 @@ import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -23,7 +24,7 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
|
||||
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.getMinor() >= 16 ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.isAtLeast(1, 16) ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
private static final BukkitPacketHandler COMMANDS_NODE_HANDLER = new ModernCommandsNodeHandler();
|
||||
|
||||
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
@@ -63,22 +64,27 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
channel.pipeline().addBefore(BukkitPacketAnalyzer.PIPELINE_NAME, BukkitPacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.put(player.getUniqueId(), channel);
|
||||
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
// Switching injection method since some versions of Leaf
|
||||
// seem to be using different logging variants.
|
||||
// It's implemented this way since some Leaf forks might have
|
||||
// changed the compilation and therefore the variables again.
|
||||
|
||||
Reflection.toggleInjectionMethod();
|
||||
final boolean success = inject(player);
|
||||
|
||||
Logger.info("Injection failed. Switching to secondary injection method.");
|
||||
boolean success = inject(player);
|
||||
|
||||
if (success) {
|
||||
Logger.info("Secondary injection method was successful.");
|
||||
} else {
|
||||
Logger.warning("Secondary injection method failed!");
|
||||
if (!success) {
|
||||
Logger.warning("Both injection methods failed! Please report this back to me on my Discord! (https://www.rayzs.de/discord)");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -127,7 +133,7 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
this.sender = CommandSender.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
+15
-4
@@ -1,10 +1,11 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -13,8 +14,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -87,7 +88,17 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, new ArrayList<>(suggestions));
|
||||
final List<String> tmpSuggestionsList = new ArrayList<>(suggestions);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawInput,
|
||||
tmpSuggestionsList
|
||||
)
|
||||
);
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
suggestions.clear();
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,7 +16,7 @@ public class ModernCommandsNodeHandler implements BukkitPacketHandler {
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
final BukkitCommandNodeHelper helper = new BukkitCommandNodeHelper(packetObj);
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+17
-12
@@ -1,10 +1,11 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -16,10 +17,9 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
@@ -77,11 +77,12 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
int spaces = 0;
|
||||
if(input.startsWith("/") || is121Packet) {
|
||||
input = input.replace("/", "");
|
||||
if(input.contains(" ")) {
|
||||
input = input.substring(1);
|
||||
|
||||
if (input.contains(" ")) {
|
||||
String[] split = input.split(" ");
|
||||
spaces = split.length;
|
||||
if(spaces > 0) input = split[0];
|
||||
if (spaces > 0) input = split[0];
|
||||
}
|
||||
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, input);
|
||||
@@ -105,7 +106,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird())
|
||||
return false;
|
||||
|
||||
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
if (spaces >= 1 && cancelsBeforeHand) {
|
||||
suggestions.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -123,7 +124,9 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Object suggestion : suggestions)
|
||||
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
|
||||
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
@@ -156,7 +159,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
|
||||
if (Reflection.getMinor() < 17) {
|
||||
if (Reflection.isBefore(1, 17)) {
|
||||
Field suggestionsField = Reflection.getFieldsByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS).get(0);
|
||||
if (suggestionsField == null) return false;
|
||||
suggestionObj = suggestionsField.get(packetObj);
|
||||
@@ -178,7 +181,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
if(spaces >= 1 && cancelsBeforeHand) {
|
||||
suggestions.getList().clear();
|
||||
return true;
|
||||
}
|
||||
@@ -197,7 +200,9 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Suggestion suggestion : suggestions.getList())
|
||||
suggestionsAsString.add(suggestion.getText());
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
|
||||
if (modifiable) {
|
||||
|
||||
+22
-100
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
@@ -8,10 +8,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -20,7 +21,6 @@ import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
@@ -43,7 +43,6 @@ public class BungeePacketAnalyzer {
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
@@ -102,8 +101,11 @@ public class BungeePacketAnalyzer {
|
||||
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -154,7 +156,7 @@ public class BungeePacketAnalyzer {
|
||||
if (!ignore) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
@@ -215,16 +217,20 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCommandsPacket() {
|
||||
if (!Communicator.get().hasConnectedClients()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
@@ -241,7 +247,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
private PacketDecoder(ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
this.sender = CommandSender.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -253,100 +259,16 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
if (wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
|
||||
if (CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessage.getTag())) {
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (wrapper.packet instanceof Commands) {
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
} else if (wrapper.packet instanceof Commands response) {
|
||||
modifyCommands(player, sender, response);
|
||||
|
||||
player.unsafe().sendPacket(response);
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("damn");
|
||||
|
||||
if (!Storage.Blacklist.isDisabledServer(serverName) && player.getPendingConnection().getVersion() < 754) {
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
System.out.println("Further!");
|
||||
System.out.println("Got: " + PLAYER_INPUT_CACHE.get(player.getUniqueId()));
|
||||
|
||||
if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
|
||||
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
|
||||
server = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("NETTY -> " + playerInput);
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
|
||||
if (cursor.startsWith("/")) {
|
||||
if (spaces == 0) {
|
||||
List<String> suggestions = new ArrayList<>(response.getCommands());
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
setPluginCommands();
|
||||
|
||||
Storage.Blacklist.getServerBlacklists(server).forEach(blacklist -> blacklist.getCommands().stream().filter(command -> !suggestions.contains("/" + command)).forEach(command -> {
|
||||
if (BungeePacketAnalyzer.PLUGIN_COMMANDS.contains(command))
|
||||
suggestions.add("/" + command);
|
||||
}));
|
||||
|
||||
BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command -> !suggestions.contains(command)).forEach(command -> {
|
||||
if (command.startsWith("/"))
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.Blacklist.canPlayerAccessTab(player, command, server)) {
|
||||
suggestions.add("/" + command);
|
||||
}
|
||||
});
|
||||
|
||||
suggestions.stream().filter(suggestion -> suggestion.startsWith(cursor) && !response.getCommands().contains(suggestion)).forEach(command -> response.getCommands().add(command));
|
||||
|
||||
} else {
|
||||
BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command -> !suggestions.contains(command)).forEach(suggestions::add);
|
||||
|
||||
suggestions.removeIf(command -> {
|
||||
if (command.startsWith("/"))
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, server);
|
||||
});
|
||||
|
||||
response.getCommands().clear();
|
||||
suggestions.forEach(command -> response.getCommands().add(command));
|
||||
}
|
||||
|
||||
if (response.getCommands().isEmpty())
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (cancelsBeforeHand)
|
||||
return;
|
||||
}
|
||||
|
||||
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
+76
-104
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
@@ -14,14 +14,14 @@ import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -32,7 +32,6 @@ import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -42,8 +41,6 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
|
||||
private static boolean FAILED = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
final String name = "minecraft:ask_server";
|
||||
@@ -63,7 +60,6 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
FAILED = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,37 +85,49 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
|
||||
if(connectedPlayerConnectionClass == null)
|
||||
if (connectedPlayerConnectionClass == null) {
|
||||
connectedPlayerConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
}
|
||||
|
||||
if(minecraftConnectionClass == null)
|
||||
if (minecraftConnectionClass == null) {
|
||||
minecraftConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.MinecraftConnection");
|
||||
|
||||
Channel channel;
|
||||
}
|
||||
|
||||
try {
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player),
|
||||
minecraftConnectionObj = Reflection.getMethodsByName(connectedPlayerConnectionClass, "getConnection").get(0).invoke(connectedPlayerObj);
|
||||
final Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player);
|
||||
final Object minecraftConnectionObj = Reflection.getMethodsByName(connectedPlayerConnectionClass, "getConnection")
|
||||
.get(0).invoke(connectedPlayerObj);
|
||||
|
||||
channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
|
||||
final Channel channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
|
||||
if (channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getUsername() + "! Channel is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME)) {
|
||||
uninject(player);
|
||||
}
|
||||
|
||||
|
||||
channel.pipeline().addBefore(
|
||||
VelocityPacketAnalyzer.HANDLER_NAME,
|
||||
VelocityPacketAnalyzer.PIPELINE_NAME,
|
||||
new PacketDecoder(player)
|
||||
);
|
||||
|
||||
channel.pipeline().addBefore(VelocityPacketAnalyzer.HANDLER_NAME, VelocityPacketAnalyzer.PIPELINE_NAME, new PacketDecoder(player));
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (NoSuchElementException e) {
|
||||
} catch (NoSuchElementException noSuchElementException) {
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -129,16 +137,21 @@ public class VelocityPacketAnalyzer {
|
||||
public static void uninject(Player player) {
|
||||
VelocityPacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
|
||||
if(VelocityPacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
Channel channel = VelocityPacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
if(channel != null) {
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
channel.eventLoop().submit(() -> {
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
if (pipeline.names().contains(VelocityPacketAnalyzer.PIPELINE_NAME)) pipeline.remove(VelocityPacketAnalyzer.PIPELINE_NAME);
|
||||
});
|
||||
}
|
||||
final Channel channel = VelocityPacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
|
||||
if (channel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
|
||||
channel.eventLoop().submit(() -> {
|
||||
final ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (pipeline.names().contains(VelocityPacketAnalyzer.PIPELINE_NAME)) {
|
||||
pipeline.remove(VelocityPacketAnalyzer.PIPELINE_NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getPlayerInput(Player player) {
|
||||
@@ -162,7 +175,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
|
||||
String serverName = sender.getServerName();
|
||||
final String serverName = sender.getServerName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
final ProxyCommandNodeHelper<CommandSource> helper = new ProxyCommandNodeHelper<>(commands.getRootNode());
|
||||
@@ -176,7 +189,7 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
@@ -201,7 +214,7 @@ public class VelocityPacketAnalyzer {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
@@ -211,23 +224,22 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
this.sender = CommandSender.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (!(msg instanceof MinecraftPacket)) {
|
||||
if (!(msg instanceof MinecraftPacket packet)) {
|
||||
super.channelRead(ctx, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet.getClass().getSimpleName().equals("SignedChatCommand")) {
|
||||
|
||||
try {
|
||||
if (signedChatCommandPacketClass == null)
|
||||
if (signedChatCommandPacketClass == null) {
|
||||
signedChatCommandPacketClass = Class.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
|
||||
}
|
||||
|
||||
Object signedChatCommandPacket = signedChatCommandPacketClass.cast(packet);
|
||||
Field commandField = signedChatCommandPacket.getClass().getField("command");
|
||||
@@ -270,8 +282,9 @@ public class VelocityPacketAnalyzer {
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet instanceof PluginMessagePacket pluginMessagePacket) {
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.createBrandPacket(player);
|
||||
if(CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
final PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.get().createBrandPacket(player);
|
||||
|
||||
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(), brandManipulatePacket.getByteBuf()), promise);
|
||||
return;
|
||||
}
|
||||
@@ -301,8 +314,9 @@ public class VelocityPacketAnalyzer {
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
@@ -312,6 +326,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
if (cursor.startsWith("/")) {
|
||||
|
||||
if (spaces == 0) {
|
||||
response.getOffers().removeIf(offer -> {
|
||||
String command = offer.getText();
|
||||
@@ -323,21 +338,35 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
});
|
||||
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
if (cancelsBeforeHand) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> suggestionsAsString = new ArrayList<>();
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawPlayerInput, suggestionsAsString);
|
||||
final FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
suggestionsAsString
|
||||
)
|
||||
);
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if (response.getOffers().isEmpty()) return;
|
||||
if (response.getOffers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,69 +374,12 @@ public class VelocityPacketAnalyzer {
|
||||
} else if (packet instanceof AvailableCommandsPacket commands) {
|
||||
|
||||
if (player.getCurrentServer().isPresent()) {
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
|
||||
if (!FAILED) {
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if(!commands.getRootNode().getChildren().isEmpty()) {
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
commands.getRootNode().getChildren().stream().filter(command -> command != null && command.getName() != null).forEach(command -> commandsAsString.add(command.getName()));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1 && newer
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
&& commands.getRootNode().getChild("args").getChildren().isEmpty()) {
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
commands.getRootNode().getChildren().removeIf(command -> {
|
||||
if (command == null || command.getName() == null)
|
||||
return true;
|
||||
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
@@ -1,47 +0,0 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoCommand extends ProCommand {
|
||||
|
||||
public InfoCommand() {
|
||||
super(
|
||||
"info",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
String message = StringUtils.getStringList(Storage.ConfigSections.Messages.INFO.MESSAGE.getLines(), "\n");
|
||||
|
||||
String syncTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || Reflection.isProxyServer()
|
||||
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Reflection.isProxyServer()
|
||||
? Communicator.LAST_DATA_UPDATE : Communicator.LAST_BUKKIT_SYNC))
|
||||
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
|
||||
|
||||
String versionStatus = Storage.OUTDATED
|
||||
? Storage.ConfigSections.Messages.INFO.VERSION_OUTDATED
|
||||
: Storage.ConfigSections.Messages.INFO.VERSION_UPDATED;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%sync_time%", syncTime,
|
||||
"%version_status%", versionStatus
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
package de.rayzs.pat.plugin.subarguments;
|
||||
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.subarguments.events.ExecuteCommand;
|
||||
import de.rayzs.pat.plugin.subarguments.events.TabCompletion;
|
||||
import de.rayzs.pat.plugin.subarguments.events.UpdateList;
|
||||
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SubArguments {
|
||||
|
||||
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES, ONLINE_PLAYERS;
|
||||
public static HashMap<UUID, Arguments> PLAYER_COMMANDS = new HashMap<>();
|
||||
|
||||
public static void initialize() {
|
||||
updateList();
|
||||
updateMessages();
|
||||
updatePlayerNames();
|
||||
|
||||
PATEventHandler.register(new TabCompletion());
|
||||
PATEventHandler.register(new ExecuteCommand());
|
||||
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
|
||||
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
|
||||
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
|
||||
}
|
||||
|
||||
public static void updatePlayerNames() {
|
||||
PLAYER_NAMES = Storage.getLoader().getPlayerNames();
|
||||
ONLINE_PLAYERS = Storage.getLoader().getOnlinePlayerNames();
|
||||
}
|
||||
|
||||
public static List<String> getPlayerNames() {
|
||||
return PLAYER_NAMES;
|
||||
}
|
||||
|
||||
public static List<String> getOnlinePlayerNames() {
|
||||
return ONLINE_PLAYERS;
|
||||
}
|
||||
|
||||
public static void updateList() {
|
||||
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
|
||||
|
||||
Arguments.ARGUMENTS.clearArguments();
|
||||
|
||||
GENERAL_LIST.forEach(command -> Arguments.ARGUMENTS.buildArgumentStacks(command));
|
||||
SubArguments.PLAYER_COMMANDS = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void updateMessages() {
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
ResponseHandler.update();
|
||||
}
|
||||
|
||||
public static void handleCommandNode(UUID uuid, ProxyCommandNodeHelper helper) {
|
||||
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
Arguments arguments = PLAYER_COMMANDS.get(uuid);
|
||||
if (arguments == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> inputs = source.getAllInputs();
|
||||
|
||||
if (turn) {
|
||||
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
|
||||
helper.removeIf(allEntries::contains);
|
||||
}
|
||||
|
||||
final int length = inputs.size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String input;
|
||||
|
||||
try {
|
||||
input = inputs.get(i);
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
break;
|
||||
}
|
||||
|
||||
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
|
||||
|
||||
if (!negated) {
|
||||
|
||||
if (turn) helper.add(input, true);
|
||||
else helper.removeSubArguments(input);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
if (type == Storage.Blacklist.BlockType.CHAT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
|
||||
|
||||
if (turn) helper.removeSubArguments(input);
|
||||
else helper.add(input, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleCommandNode(UUID uuid, BukkitCommandNodeHelper helper) throws Exception {
|
||||
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
Arguments arguments = PLAYER_COMMANDS.get(uuid);
|
||||
if (arguments == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> inputs = new ArrayList<>(source.getAllInputs());
|
||||
final List<String> argumentsList = new ArrayList<>();
|
||||
|
||||
final int length = inputs.size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String input;
|
||||
|
||||
try {
|
||||
input = inputs.get(i);
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
if (type == Storage.Blacklist.BlockType.CHAT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
|
||||
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
|
||||
|
||||
if (!negated) {
|
||||
|
||||
if (turn) argumentsList.add(input);
|
||||
else helper.removeSubArguments(input);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (turn) helper.removeSubArguments(input);
|
||||
else argumentsList.add(input);
|
||||
}
|
||||
|
||||
if (argumentsList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
helper.spareRecursively(argumentsList);
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
return getServerCommands(Storage.getLoader().getPlayerServerName(uuid));
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(String serverName) {
|
||||
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
|
||||
if (!Reflection.isProxyServer())
|
||||
return commands;
|
||||
|
||||
if (serverName == null)
|
||||
return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getServerBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid) {
|
||||
return getGroupCommands(uuid, null);
|
||||
}
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid, String serverName) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
List<Group> groups;
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
CommandSender sender = CommandSenderHandler.from(uuid);
|
||||
groups = GroupManager.getPlayerGroups(sender);
|
||||
} else {
|
||||
groups = GroupManager.getPlayerGroups(uuid);
|
||||
}
|
||||
|
||||
if (serverName == null) {
|
||||
groups.forEach(group -> commands.addAll(group.getCommands()));
|
||||
return commands;
|
||||
}
|
||||
|
||||
groups.forEach(group -> {
|
||||
|
||||
commands.addAll(group.getCommands());
|
||||
|
||||
List<String> associatedServerNames = group.getBlacklistServerNames(serverName);
|
||||
|
||||
associatedServerNames.forEach(s -> {
|
||||
commands.addAll(group.getCommands(s));
|
||||
});
|
||||
|
||||
});
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static String replacePlaceholders(String input) {
|
||||
String[] split = input.split(" ");
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
|
||||
boolean number = NumberUtils.isDigit(split[i]),
|
||||
online = Storage.getLoader().isPlayerOnline(s),
|
||||
general = Storage.getLoader().doesPlayerExist(s);
|
||||
|
||||
if (number) {
|
||||
split[i] = "%numbers%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online && general) {
|
||||
split[i] = "%both_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online) {
|
||||
split[i] = "%online_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (general)
|
||||
split[i] = "%players%";
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user