Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ada83bfe | ||
|
|
8a86f05133 |
No files matched your search
-42
@@ -1,42 +0,0 @@
|
||||
# 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.4</version>
|
||||
<version>2.3.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
@@ -34,11 +34,6 @@
|
||||
<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>
|
||||
@@ -55,6 +50,11 @@
|
||||
<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.21-R0.5-SNAPSHOT</version>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -192,14 +192,14 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-proxy</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -227,14 +227,14 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.26.1</version>
|
||||
<version>4.25.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.26.1</version>
|
||||
<version>4.25.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.11.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -1,14 +1,10 @@
|
||||
package de.rayzs.pat.plugin.system.serverbrand;
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
|
||||
public interface ServerBrand {
|
||||
|
||||
void initializeTask();
|
||||
|
||||
void preparePlayer(Object playerObj);
|
||||
void send(Object playerObj);
|
||||
|
||||
PacketUtils.BrandManipulate createPacket(Object playerObj);
|
||||
|
||||
void initializeTask();
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
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
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.command.commands;
|
||||
package de.rayzs.pat.api.command;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+13
-40
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.system.communication;
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -7,43 +7,16 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class BackendUpdater {
|
||||
|
||||
/**
|
||||
*
|
||||
* I wasn't sure how to call this class, but this class is mainly only
|
||||
* for managing whether PAT is still connected to the proxy or not.
|
||||
* It sends a keep-alive packet and if it doesn't get a response once
|
||||
* the next iteration of the scheduler starts, it will consider itself
|
||||
* 'desynchronized' and sends an IdentityRequest packet to the proxy instead,
|
||||
* restarting the whole process until it gets into a stable connection once more.
|
||||
*
|
||||
*/
|
||||
|
||||
public static BackendUpdater instance;
|
||||
|
||||
public static void initialize() {
|
||||
if (instance != null) {
|
||||
Logger.warning("BackendUpdater already initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
instance = new BackendUpdater();
|
||||
}
|
||||
|
||||
public static BackendUpdater get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
private BackendUpdater() {}
|
||||
|
||||
|
||||
private PATSchedulerTask TASK;
|
||||
private boolean CONNECTED = false,
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean CONNECTED = false,
|
||||
WAITING = false;
|
||||
|
||||
private final long SCHEDULER_PERIOD_TIME = 20 * 10;
|
||||
private static final long SCHEDULER_PERIOD_TIME = 20 * 10;
|
||||
|
||||
public void handle() {
|
||||
public static void handle() {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
@@ -56,21 +29,21 @@ public class BackendUpdater {
|
||||
start();
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
public static void restart() {
|
||||
stop();
|
||||
handle();
|
||||
}
|
||||
|
||||
public void receivedKeepAlivePacket() {
|
||||
public static void receivedKeepAlivePacket() {
|
||||
WAITING = false;
|
||||
CONNECTED = true;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
public static boolean isConnected() {
|
||||
return CONNECTED;
|
||||
}
|
||||
|
||||
private void start() {
|
||||
private static void start() {
|
||||
if (isRunning()) return;
|
||||
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
@@ -99,7 +72,7 @@ public class BackendUpdater {
|
||||
}, 20, SCHEDULER_PERIOD_TIME);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
public static void stop() {
|
||||
disconnect();
|
||||
|
||||
if (isRunning()) {
|
||||
@@ -108,16 +81,16 @@ public class BackendUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
private void disconnect() {
|
||||
private static void disconnect() {
|
||||
CONNECTED = false;
|
||||
WAITING = false;
|
||||
}
|
||||
|
||||
private boolean isRunning() {
|
||||
private static boolean isRunning() {
|
||||
return TASK != null && TASK.isActive();
|
||||
}
|
||||
|
||||
private boolean canRun() {
|
||||
private static boolean canRun() {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return false;
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc;
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
public interface PluginMessageClient {
|
||||
public interface Client {
|
||||
String CHANNEL_NAME = "pat:channel";
|
||||
void reload();
|
||||
void send(CommunicationPackets.PATPacket packet);
|
||||
+87
-95
@@ -1,14 +1,13 @@
|
||||
package de.rayzs.pat.plugin.system.communication;
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.client.impl.BungeeClient;
|
||||
import de.rayzs.pat.plugin.system.communication.client.impl.VelocityClient;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.CommunicationPacketHandler;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
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.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
@@ -19,17 +18,13 @@ public class Communicator {
|
||||
|
||||
private static Communicator instance = null;
|
||||
|
||||
public static void initialize(
|
||||
final PluginMessageClient pluginMessageClient,
|
||||
final CommunicationPacketHandler communicationPacketHandler
|
||||
) {
|
||||
|
||||
public static void initialize(final Client client) {
|
||||
if (instance != null) {
|
||||
Logger.warning("Communicator instance is already initialized!");
|
||||
return;
|
||||
}
|
||||
|
||||
instance = new Communicator(pluginMessageClient, communicationPacketHandler);
|
||||
instance = new Communicator(client);
|
||||
}
|
||||
|
||||
public static Communicator get() {
|
||||
@@ -41,15 +36,6 @@ public class Communicator {
|
||||
|
||||
private Backend2Proxy() {}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Fast and simple solution to simply send frequent used packets to the
|
||||
* proxy without any extra steps.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public static void sendIdentityRequest() {
|
||||
get().send2Proxy(
|
||||
new CommunicationPackets.Backend2Proxy.IdentityRequestPacket(get().getId())
|
||||
@@ -68,13 +54,6 @@ public class Communicator {
|
||||
|
||||
private Proxy2Backend() {}
|
||||
|
||||
/**
|
||||
*
|
||||
* Fast and quick solution to send frequently used packets to
|
||||
* the backend servers without any extra steps.
|
||||
*
|
||||
*/
|
||||
|
||||
// Update commands for all players
|
||||
public static void sendUpdateCommand() {
|
||||
get().send2AllClients(
|
||||
@@ -84,7 +63,7 @@ public class Communicator {
|
||||
|
||||
// Update commands for a certain player.
|
||||
public static void sendUpdateCommand(UUID playerId, String serverName) {
|
||||
final Client clientInfo = get().clients.get(serverName);
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
clientInfo.send(
|
||||
@@ -102,38 +81,38 @@ public class Communicator {
|
||||
|
||||
// Sync data for one server
|
||||
public static void sendDataSync(String serverName) {
|
||||
final Client client = get().clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.send(
|
||||
clientInfo.send(
|
||||
Communicator.get().constructDataSyncPacket()
|
||||
);
|
||||
}
|
||||
|
||||
// Sync data for all registered clients.
|
||||
public static void sendConsoleMessage(String serverName, String message) {
|
||||
final Client client = get().clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.send(
|
||||
clientInfo.send(
|
||||
new CommunicationPackets.Proxy2Backend.ConsoleMessagePacket(message)
|
||||
);
|
||||
}
|
||||
|
||||
public static void sendExecutePlayerCommand(String serverName, UUID playerId, String command) {
|
||||
final Client client = get().clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.send(
|
||||
clientInfo.send(
|
||||
new CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket(playerId, command)
|
||||
);
|
||||
}
|
||||
|
||||
public static void sendExecuteConsoleCommand(String serverName, String command) {
|
||||
final Client client = get().clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.send(
|
||||
clientInfo.send(
|
||||
new CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket(command)
|
||||
);
|
||||
}
|
||||
@@ -143,32 +122,30 @@ public class Communicator {
|
||||
return;
|
||||
}
|
||||
|
||||
final Client client = get().clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.send(
|
||||
clientInfo.send(
|
||||
new CommunicationPackets.Proxy2Backend.NotificationPacket(playerId, command)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final PluginMessageClient pluginMessageClient;
|
||||
private final CommunicationPacketHandler communicationPacketHandler;
|
||||
private final Client client;
|
||||
private final UUID id = UUID.randomUUID();
|
||||
|
||||
// Server name, ClientInfo
|
||||
private final Map<String, Client> clients = new HashMap<>();
|
||||
private final ExpireCache<String, Client> pendingClients = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
private final Map<String, ClientInfo> clients = new HashMap<>();
|
||||
private final ExpireCache<String, ClientInfo> pendingClients = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
private long lastReceivedKeepAliveResponse = System.currentTimeMillis();
|
||||
private long lastSync = System.currentTimeMillis();
|
||||
|
||||
|
||||
private Communicator(final PluginMessageClient pluginMessageClient, final CommunicationPacketHandler communicationPacketHandler) {
|
||||
this.pluginMessageClient = pluginMessageClient;
|
||||
this.communicationPacketHandler = communicationPacketHandler;
|
||||
private Communicator(final Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,65 +156,63 @@ public class Communicator {
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.KeepAlivePacket packet) {
|
||||
final Client client = clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.updateKeepAliveTime();
|
||||
client.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
clientInfo.updateKeepAliveTime();
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityRequestPacket packet) {
|
||||
final Client registeredClient = clients.get(serverName);
|
||||
final ClientInfo registeredClientInfo = clients.get(serverName);
|
||||
|
||||
final boolean exist = registeredClient != null;
|
||||
final boolean same = exist && registeredClient.getId().equals(packet.serverId());
|
||||
final boolean exist = registeredClientInfo != null;
|
||||
final boolean same = exist && registeredClientInfo.getId().equals(packet.serverId());
|
||||
|
||||
if (!same) {
|
||||
final Client client = createClientInstance(packet.serverId(), serverName);
|
||||
final ClientInfo clientInfo = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(packet.serverId(), serverName)
|
||||
: new BungeeClientInfo(packet.serverId(), serverName);
|
||||
|
||||
pendingClients.put(serverName, client);
|
||||
client.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
pendingClients.put(serverName, clientInfo);
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
} else {
|
||||
registeredClient.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
registeredClient.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
registeredClientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
registeredClientInfo.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityResponsePacket packet) {
|
||||
final Client client = pendingClients.get(serverName);
|
||||
final ClientInfo clientInfo = pendingClients.get(serverName);
|
||||
|
||||
if (client != null && client.getId().equals(packet.serverId())) {
|
||||
client.setId(packet.serverId());
|
||||
if (clientInfo != null && clientInfo.getId().equals(packet.serverId())) {
|
||||
clientInfo.setId(packet.serverId());
|
||||
|
||||
|
||||
pendingClients.remove(serverName);
|
||||
clients.put(serverName, client);
|
||||
clients.put(serverName, clientInfo);
|
||||
|
||||
|
||||
client.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
client.send( constructDataSyncPacket() );
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
clientInfo.send( constructDataSyncPacket() );
|
||||
|
||||
client.updateSyncTime();
|
||||
clientInfo.updateSyncTime();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket packet) {
|
||||
final Client client = clients.get(serverName);
|
||||
if (client == null) return;
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null) return;
|
||||
|
||||
client.updateSyncTime();
|
||||
return;
|
||||
clientInfo.updateSyncTime();
|
||||
}
|
||||
|
||||
|
||||
// Handles all packets that can be handled with as pleased inside the CommunicationPacketHandler...
|
||||
communicationPacketHandler.handleReceivedPacket(incomingPacket);
|
||||
}
|
||||
|
||||
// PROXY -> BACKEND
|
||||
@@ -249,7 +224,7 @@ public class Communicator {
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket packet) {
|
||||
|
||||
lastReceivedKeepAliveResponse = System.currentTimeMillis();
|
||||
BackendUpdater.get().receivedKeepAlivePacket();
|
||||
BackendUpdater.receivedKeepAlivePacket();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -265,11 +240,34 @@ public class Communicator {
|
||||
lastSync = System.currentTimeMillis();
|
||||
|
||||
send2Proxy(new CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket());
|
||||
BukkitLoader.handleDataSyncPacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.UpdatePacket packet) {
|
||||
BukkitLoader.handleUpdateCommandsPacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handles all packets that can be handled with as pleased inside the CommunicationPacketHandler...
|
||||
communicationPacketHandler.handleReceivedPacket(incomingPacket);
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.NotificationPacket packet) {
|
||||
BukkitLoader.handleNotificationPacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ConsoleMessagePacket packet) {
|
||||
BukkitLoader.handleConsoleMessagePacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket packet) {
|
||||
BukkitLoader.handlePlayerExecuteCommandPacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket packet) {
|
||||
BukkitLoader.handleConsoleExecuteCommandPacket(packet);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void send2Proxy(CommunicationPackets.PATPacket packet) {
|
||||
@@ -278,16 +276,16 @@ public class Communicator {
|
||||
return;
|
||||
}
|
||||
|
||||
pluginMessageClient.send(packet);
|
||||
client.send(packet);
|
||||
}
|
||||
|
||||
private void send2Client(Client clientInfo, CommunicationPackets.PATPacket packet) {
|
||||
private void send2Client(ClientInfo clientInfo, CommunicationPackets.PATPacket packet) {
|
||||
if (!Reflection.isProxyServer()) {
|
||||
Logger.warning("Cannot send P2B packet as backend!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (clientInfo == null || Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
if (clientInfo == null || Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -300,7 +298,7 @@ public class Communicator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,21 +323,21 @@ public class Communicator {
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.pluginMessageClient.reload();
|
||||
this.client.reload();
|
||||
}
|
||||
|
||||
public UUID getClientId(String serverName) {
|
||||
final Client client = clients.get(serverName);
|
||||
if (client == null) return null;
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null) return null;
|
||||
|
||||
return client.getId();
|
||||
return clientInfo.getId();
|
||||
}
|
||||
|
||||
public boolean hasConnectedClients() {
|
||||
return !clients.isEmpty();
|
||||
}
|
||||
|
||||
public Set<Client> getClients() {
|
||||
public Set<ClientInfo> getClients() {
|
||||
return new HashSet<>(clients.values());
|
||||
}
|
||||
|
||||
@@ -355,10 +353,4 @@ public class Communicator {
|
||||
return lastSync;
|
||||
}
|
||||
|
||||
private Client createClientInstance(UUID id, String serverName) {
|
||||
return Reflection.isVelocityServer()
|
||||
? new VelocityClient(id, serverName)
|
||||
: new BungeeClient(id, serverName);
|
||||
}
|
||||
|
||||
}
|
||||
+11
-3
@@ -1,11 +1,11 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client;
|
||||
package de.rayzs.pat.api.communication.client;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.TimeConverter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class Client {
|
||||
public abstract class ClientInfo {
|
||||
|
||||
private UUID id;
|
||||
private String serverName;
|
||||
@@ -13,7 +13,11 @@ public abstract class Client {
|
||||
private long syncTime = System.currentTimeMillis(),
|
||||
keepAliveTime = System.currentTimeMillis();
|
||||
|
||||
public Client(UUID id, String name) {
|
||||
public ClientInfo(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ClientInfo(UUID id, String name) {
|
||||
this.id = id;
|
||||
this.serverName = name;
|
||||
}
|
||||
@@ -40,6 +44,10 @@ public abstract class Client {
|
||||
keepAliveTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return System.currentTimeMillis() - keepAliveTime > 5000;
|
||||
}
|
||||
|
||||
public String getFormattedSyncTime() {
|
||||
return TimeConverter.calcAndGetTime(syncTime);
|
||||
}
|
||||
+10
-6
@@ -1,16 +1,20 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client.impl;
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeeClient extends Client {
|
||||
public class BungeeClientInfo extends ClientInfo {
|
||||
|
||||
public BungeeClient(UUID id, String name) {
|
||||
public BungeeClientInfo(UUID id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public BungeeClientInfo(UUID id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
@@ -25,7 +29,7 @@ public class BungeeClient extends Client {
|
||||
final ServerInfo serverInfo = ProxyServer.getInstance().getServerInfo(getServerName());
|
||||
|
||||
if (serverInfo != null) {
|
||||
serverInfo.sendData(PluginMessageClient.CHANNEL_NAME, preparedPacket);
|
||||
serverInfo.sendData(Client.CHANNEL_NAME, preparedPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-6
@@ -1,17 +1,21 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client.impl;
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.VelocityPluginMessageClient;
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityClient extends Client {
|
||||
public class VelocityClientInfo extends ClientInfo {
|
||||
|
||||
public VelocityClient(UUID id, String name) {
|
||||
public VelocityClientInfo(UUID id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public VelocityClientInfo(UUID id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
@@ -26,7 +30,7 @@ public class VelocityClient extends Client {
|
||||
final Optional<RegisteredServer> optServer = VelocityLoader.getServer().getServer(getServerName());
|
||||
|
||||
optServer.ifPresent(registeredServer -> {
|
||||
registeredServer.sendPluginMessage(VelocityPluginMessageClient.getIdentifier(), preparedPacket);
|
||||
registeredServer.sendPluginMessage(VelocityClient.getIdentifier(), preparedPacket);
|
||||
});
|
||||
}
|
||||
}
|
||||
+20
-41
@@ -1,54 +1,49 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
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.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class BukkitPluginMessageClient implements PluginMessageClient, PluginMessageListener {
|
||||
public class BukkitClient implements Client, PluginMessageListener {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private boolean registered = false;
|
||||
|
||||
public BukkitPluginMessageClient() {
|
||||
public BukkitClient() {
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
if (registered) {
|
||||
unregister();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!registered) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
|
||||
if (!registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = false;
|
||||
|
||||
SERVER.getMessenger().unregisterIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().unregisterOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
}
|
||||
@@ -62,22 +57,11 @@ public class BukkitPluginMessageClient implements PluginMessageClient, PluginMes
|
||||
}
|
||||
|
||||
|
||||
final Player carrier = selectCarrier();
|
||||
if (carrier == null) {
|
||||
return;
|
||||
try {
|
||||
SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, preparedPacket);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
PATScheduler.execute(() -> {
|
||||
if (!carrier.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
carrier.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, preparedPacket);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}, carrier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,9 +84,4 @@ public class BukkitPluginMessageClient implements PluginMessageClient, PluginMes
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Player selectCarrier() {
|
||||
final Iterator<? extends Player> iterator = SERVER.getOnlinePlayers().iterator();
|
||||
return iterator.hasNext() ? iterator.next() : null;
|
||||
}
|
||||
}
|
||||
+13
-38
@@ -1,7 +1,5 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
@@ -10,50 +8,27 @@ 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;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeePluginMessageClient implements PluginMessageClient, Listener {
|
||||
public class BungeeClient implements Client, Listener {
|
||||
|
||||
private boolean registered;
|
||||
private static final ProxyServer SERVER = ProxyServer.getInstance();
|
||||
|
||||
public BungeePluginMessageClient() {
|
||||
reload();
|
||||
public BungeeClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.registerChannel(CHANNEL_NAME);
|
||||
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
ProxyServer.getInstance().registerChannel(CHANNEL_NAME);
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
ProxyServer.getInstance().unregisterChannel(CHANNEL_NAME);
|
||||
ProxyServer.getInstance().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
public void reload() {}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
+14
-39
@@ -1,58 +1,33 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
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.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
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.*;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityPluginMessageClient implements PluginMessageClient {
|
||||
public class VelocityClient implements Client {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
|
||||
private boolean registered = false;
|
||||
|
||||
public VelocityPluginMessageClient() {
|
||||
reload();
|
||||
public VelocityClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.getChannelRegistrar().register(IDENTIFIER);
|
||||
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
VelocityLoader.getServer().getChannelRegistrar().register(IDENTIFIER);
|
||||
VelocityLoader.getServer().getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
VelocityLoader.getServer().getChannelRegistrar().unregister(IDENTIFIER);
|
||||
VelocityLoader.getServer().getEventManager().unregisterListener(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
public void reload() {}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
@@ -63,7 +38,7 @@ public class VelocityPluginMessageClient implements PluginMessageClient {
|
||||
}
|
||||
|
||||
|
||||
for (RegisteredServer registeredServer : VelocityLoader.getServer().getAllServers()) {
|
||||
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
|
||||
|
||||
try {
|
||||
registeredServer.sendPluginMessage(IDENTIFIER, preparedPacket);
|
||||
@@ -1,14 +1,12 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class PATEvent<T> {
|
||||
|
||||
private final CommandSender player;
|
||||
private final Object senderObj;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PATEvent(CommandSender player) {
|
||||
this.player = player;
|
||||
public PATEvent(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
}
|
||||
|
||||
public abstract void handle(T t);
|
||||
@@ -16,8 +14,8 @@ public abstract class PATEvent<T> {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
public CommandSender getPlayer() {
|
||||
return player;
|
||||
public Object getSenderObj() {
|
||||
return senderObj;
|
||||
}
|
||||
|
||||
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.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -10,11 +10,12 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(player, command, blocked, notify);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ExecuteCommandEvent executeCommandEvent) {
|
||||
if(patEvent instanceof ExecuteCommandEvent) {
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) patEvent;
|
||||
executeCommandEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -22,35 +23,38 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(CommandSender player, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(player, suggestions);
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof FilteredSuggestionEvent filteredSuggestionEvent) {
|
||||
filteredSuggestionEvent.handle(event);
|
||||
if(patEvent instanceof FilteredSuggestionEvent) {
|
||||
FilteredSuggestionEvent filteredSuggestion = (FilteredSuggestionEvent) patEvent;
|
||||
filteredSuggestion.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(CommandSender player, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(player, cursor, completion);
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof FilteredTabCompletionEvent filteredTabCompletionEvent) {
|
||||
filteredTabCompletionEvent.handle(event);
|
||||
if(patEvent instanceof FilteredTabCompletionEvent) {
|
||||
FilteredTabCompletionEvent filteredTabCompletion = (FilteredTabCompletionEvent) patEvent;
|
||||
filteredTabCompletion.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(player, type);
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ServerPlayersChangeEvent serverPlayersChangeEvent) {
|
||||
if(patEvent instanceof ServerPlayersChangeEvent) {
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +66,8 @@ public class PATEventHandler {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof UpdatePluginEvent updatePluginEvent) {
|
||||
if(patEvent instanceof UpdatePluginEvent) {
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
updatePluginEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -70,11 +75,12 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(player, commands, serverBased);
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands, serverBased);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof UpdatePlayerCommandsEvent updatePlayerCommandsEvent) {
|
||||
if(patEvent instanceof UpdatePlayerCommandsEvent) {
|
||||
UpdatePlayerCommandsEvent updatePlayerCommandsEvent = (UpdatePlayerCommandsEvent) patEvent;
|
||||
updatePlayerCommandsEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +92,8 @@ public class PATEventHandler {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(dataSyncPacket, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof SentSyncEvent sentSyncEvent) {
|
||||
if(patEvent instanceof SentSyncEvent) {
|
||||
SentSyncEvent sentSyncEvent = (SentSyncEvent) patEvent;
|
||||
sentSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -98,8 +105,9 @@ public class PATEventHandler {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(dataSyncPacket);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ReceiveSyncEvent receiveSyncEvent) {
|
||||
receiveSyncEvent.handle(event);
|
||||
if(patEvent instanceof ReceiveSyncEvent) {
|
||||
ReceiveSyncEvent proxySyncEvent = (ReceiveSyncEvent) patEvent;
|
||||
proxySyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +124,8 @@ public class PATEventHandler {
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(player, type) {
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
@@ -143,8 +151,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(player, commands, serverBased) {
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(playerObj, commands, serverBased) {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
|
||||
@@ -161,8 +169,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(player, command, blocked, notify) {
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
@@ -170,8 +178,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(player, suggestions) {
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(senderObj, suggestions) {
|
||||
@Override
|
||||
public void handle(FilteredSuggestionEvent event) {
|
||||
|
||||
@@ -179,8 +187,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(CommandSender player, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(player, cursor, completion) {
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(Object senderObj, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(senderObj, cursor, completion) {
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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> {
|
||||
|
||||
@@ -10,15 +9,13 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
super(null);
|
||||
|
||||
this.blocked = false;
|
||||
this.notify = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
super(player);
|
||||
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
super(senderObj);
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
this.notify = notify;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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> {
|
||||
@@ -14,9 +12,8 @@ public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestio
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
super(player);
|
||||
|
||||
public FilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
super(senderObj);
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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> {
|
||||
@@ -12,14 +10,12 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
super(null);
|
||||
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(CommandSender player, String cursor, List<String> completion) {
|
||||
super(player);
|
||||
|
||||
public FilteredTabCompletionEvent(Object senderObj, String cursor, List<String> completion) {
|
||||
super(senderObj);
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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> {
|
||||
|
||||
@@ -13,9 +12,8 @@ public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
|
||||
this.dataSyncPacket = null;
|
||||
}
|
||||
|
||||
public ReceiveSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
super(player);
|
||||
|
||||
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
super(senderObj);
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ 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> {
|
||||
|
||||
@@ -11,14 +10,12 @@ public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
|
||||
public SentSyncEvent() {
|
||||
super(null);
|
||||
|
||||
this.dataSyncPacket = null;
|
||||
this.serverName = null;
|
||||
}
|
||||
|
||||
public SentSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
super(player);
|
||||
|
||||
public SentSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
super(senderObj);
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
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(CommandSender player, Type type) {
|
||||
super(player);
|
||||
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
super(senderObj);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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> {
|
||||
@@ -14,9 +12,8 @@ public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCom
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
super(player);
|
||||
|
||||
public UpdatePlayerCommandsEvent(Object senderObj, List<String> commands, boolean serverBased) {
|
||||
super(senderObj);
|
||||
this.commands = commands;
|
||||
this.serverBased = serverBased;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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> {
|
||||
|
||||
@@ -9,7 +8,7 @@ public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePluginEvent(CommandSender player) {
|
||||
super(player);
|
||||
public UpdatePluginEvent(Object senderObj) {
|
||||
super(senderObj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
+7
-17
@@ -1,10 +1,8 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit;
|
||||
package de.rayzs.pat.api.netty.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;
|
||||
@@ -12,6 +10,7 @@ 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;
|
||||
@@ -24,7 +23,7 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
|
||||
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.isAtLeast(1, 16) ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.getMinor() >= 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<>();
|
||||
@@ -64,15 +63,9 @@ 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);
|
||||
boolean success = inject(player);
|
||||
|
||||
if (!success) {
|
||||
Logger.warning("Both injection methods failed! Please report this back to me on my Discord! (https://www.rayzs.de/discord)");
|
||||
@@ -81,10 +74,7 @@ public class BukkitPacketAnalyzer {
|
||||
return success;
|
||||
|
||||
} catch (Exception exception) {
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -133,7 +123,7 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSender.from(player);
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit;
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
+4
-15
@@ -1,11 +1,10 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
package de.rayzs.pat.api.netty.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;
|
||||
@@ -14,8 +13,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.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -88,17 +87,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
final List<String> tmpSuggestionsList = new ArrayList<>(suggestions);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawInput,
|
||||
tmpSuggestionsList
|
||||
)
|
||||
);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, new ArrayList<>(suggestions));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
suggestions.clear();
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
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);
|
||||
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+10
-15
@@ -1,11 +1,10 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
package de.rayzs.pat.api.netty.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;
|
||||
@@ -17,9 +16,10 @@ 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.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.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,12 +77,11 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
int spaces = 0;
|
||||
if(input.startsWith("/") || is121Packet) {
|
||||
input = input.substring(1);
|
||||
|
||||
if (input.contains(" ")) {
|
||||
input = input.replace("/", "");
|
||||
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);
|
||||
@@ -124,9 +123,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Object suggestion : suggestions)
|
||||
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
|
||||
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
|
||||
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
@@ -159,7 +156,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
|
||||
if (Reflection.isBefore(1, 17)) {
|
||||
if (Reflection.getMinor() < 17) {
|
||||
Field suggestionsField = Reflection.getFieldsByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS).get(0);
|
||||
if (suggestionsField == null) return false;
|
||||
suggestionObj = suggestionsField.get(packetObj);
|
||||
@@ -200,9 +197,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Suggestion suggestion : suggestions.getList())
|
||||
suggestionsAsString.add(suggestion.getText());
|
||||
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
|
||||
if (modifiable) {
|
||||
|
||||
+101
-18
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
@@ -8,11 +8,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -21,6 +21,7 @@ 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,6 +44,7 @@ public class BungeePacketAnalyzer {
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
@@ -101,11 +103,8 @@ public class BungeePacketAnalyzer {
|
||||
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (Exception exception) {
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -156,7 +155,7 @@ public class BungeePacketAnalyzer {
|
||||
if (!ignore) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
@@ -217,7 +216,7 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +229,7 @@ public class BungeePacketAnalyzer {
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
@@ -247,7 +246,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
private PacketDecoder(ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSender.from(player);
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,16 +258,100 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
if (wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
|
||||
if (CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessage.getTag())) {
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (wrapper.packet instanceof Commands response) {
|
||||
} else if (wrapper.packet instanceof Commands) {
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
modifyCommands(player, sender, response);
|
||||
player.unsafe().sendPacket(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);
|
||||
+104
-76
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
package de.rayzs.pat.api.netty.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.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.brand.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.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -32,6 +32,7 @@ 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;
|
||||
@@ -41,6 +42,8 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
|
||||
private static boolean FAILED = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
final String name = "minecraft:ask_server";
|
||||
@@ -60,6 +63,7 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
FAILED = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,49 +89,37 @@ 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 {
|
||||
final Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player);
|
||||
final Object minecraftConnectionObj = Reflection.getMethodsByName(connectedPlayerConnectionClass, "getConnection")
|
||||
.get(0).invoke(connectedPlayerObj);
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player),
|
||||
minecraftConnectionObj = Reflection.getMethodsByName(connectedPlayerConnectionClass, "getConnection").get(0).invoke(connectedPlayerObj);
|
||||
|
||||
|
||||
final Channel channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
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 noSuchElementException) {
|
||||
} catch (NoSuchElementException e) {
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
|
||||
return false;
|
||||
|
||||
} catch (Exception exception) {
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -137,21 +129,16 @@ public class VelocityPacketAnalyzer {
|
||||
public static void uninject(Player player) {
|
||||
VelocityPacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
|
||||
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);
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlayerInput(Player player) {
|
||||
@@ -175,7 +162,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
|
||||
final String serverName = sender.getServerName();
|
||||
String serverName = sender.getServerName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
final ProxyCommandNodeHelper<CommandSource> helper = new ProxyCommandNodeHelper<>(commands.getRootNode());
|
||||
@@ -189,7 +176,7 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
@@ -214,7 +201,7 @@ public class VelocityPacketAnalyzer {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
@@ -224,22 +211,23 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSender.from(player);
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (!(msg instanceof MinecraftPacket packet)) {
|
||||
if (!(msg instanceof MinecraftPacket)) {
|
||||
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");
|
||||
@@ -282,9 +270,8 @@ public class VelocityPacketAnalyzer {
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet instanceof PluginMessagePacket pluginMessagePacket) {
|
||||
if(CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
final PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.get().createBrandPacket(player);
|
||||
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.createBrandPacket(player);
|
||||
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(), brandManipulatePacket.getByteBuf()), promise);
|
||||
return;
|
||||
}
|
||||
@@ -314,9 +301,8 @@ 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;
|
||||
@@ -326,7 +312,6 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
if (cursor.startsWith("/")) {
|
||||
|
||||
if (spaces == 0) {
|
||||
response.getOffers().removeIf(offer -> {
|
||||
String command = offer.getText();
|
||||
@@ -338,35 +323,21 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
});
|
||||
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
|
||||
if (cancelsBeforeHand) {
|
||||
return;
|
||||
}
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
|
||||
final List<String> suggestionsAsString = new ArrayList<>();
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
final FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
suggestionsAsString
|
||||
)
|
||||
);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,12 +345,69 @@ public class VelocityPacketAnalyzer {
|
||||
} else if (packet instanceof AvailableCommandsPacket commands) {
|
||||
|
||||
if (player.getCurrentServer().isPresent()) {
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
|
||||
return;
|
||||
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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
@@ -3,18 +3,18 @@ package de.rayzs.pat.api.storage;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.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.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.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
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;
|
||||
|
||||
@@ -62,6 +62,7 @@ public class Storage {
|
||||
|
||||
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;
|
||||
|
||||
private final static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
|
||||
@@ -173,14 +174,13 @@ public class Storage {
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.get().refreshTask();
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
Communicator.get().reload();
|
||||
BackendUpdater.get().restart();
|
||||
BackendUpdater.restart();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
@@ -191,9 +191,6 @@ public class Storage {
|
||||
Communicator.Proxy2Backend.sendDataSync();
|
||||
}
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
ResponseHandler.update();
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
Storage.getLoader().handleReload();
|
||||
}
|
||||
@@ -206,12 +203,14 @@ public class Storage {
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
boolean isVelocity = Reflection.isVelocityServer();
|
||||
|
||||
if (server != null) {
|
||||
|
||||
Storage.Blacklist.clearServerBlacklists(server);
|
||||
Storage.Blacklist.loadCachedServerBlacklists(server);
|
||||
|
||||
final List<String> associatedServers = getServers()
|
||||
List<String> associatedServers = getServers()
|
||||
.stream()
|
||||
.filter(s -> !s.equals(server) && isServer(server, s))
|
||||
.toList();
|
||||
@@ -221,45 +220,42 @@ public class Storage {
|
||||
Storage.Blacklist.loadCachedServerBlacklists(s);
|
||||
});
|
||||
|
||||
associatedServers.forEach(serverName -> {
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(serverName);
|
||||
final List<String> commands = Blacklist.Collector.collectAllServerCommands(serverName);
|
||||
if (isVelocity) {
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
associatedServers.forEach(s -> {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(s);
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(s));
|
||||
|
||||
final List<String> playerCommands = new ArrayList<>(commands);
|
||||
final List<String> groupCommands = Blacklist.Collector.collectAllPlayerGroupCommands(sender, serverName);
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId, s));
|
||||
|
||||
playerCommands.addAll(groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
if (isVelocity) {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
|
||||
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());
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(playerId));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
|
||||
|
||||
playerCommands.addAll(groupCommands);
|
||||
|
||||
SubArgument.get().getUpdateArgumentsHandler().updatePlayerArguments(sender, playerCommands, serverCommands, groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, false);
|
||||
});
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, false);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GroupManager.clearServerGroupBlacklists();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
if (!Reflection.isVelocityServer()) {
|
||||
BungeePacketAnalyzer.sendCommandsPacket();
|
||||
@@ -272,22 +268,41 @@ public class Storage {
|
||||
getLoader().handleReload();
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
Storage.getLoader().updateCommands();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static void tempCachePlayerToServer(UUID playerId, String server) {
|
||||
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
|
||||
}
|
||||
|
||||
public static String getTempCachedPlayerToServer(UUID playerId, String server) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
public static void getTempCachedPlayerToServer(UUID playerId, String server) {
|
||||
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
|
||||
}
|
||||
|
||||
public static String getCachedPlayerServername(UUID playerId) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
}
|
||||
|
||||
// Quickly updates all player subarguments.
|
||||
public static void quickSubArgumentUpdate(UUID uuid) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(uuid));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
}
|
||||
|
||||
public static PluginLoader getLoader() {
|
||||
return LOADER;
|
||||
}
|
||||
@@ -344,24 +359,23 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
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 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 UpdateSection UPDATE = new UpdateSection();
|
||||
|
||||
@@ -449,62 +463,7 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
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 class Experimental {
|
||||
|
||||
public static void forceCacheReset() {
|
||||
for (Object o : CACHED_SERVER_BLACKLIST.getCache().asMap().keySet()) {
|
||||
@@ -547,7 +506,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);
|
||||
|
||||
private static void loadAll() {
|
||||
public static void loadAll() {
|
||||
CACHED_SERVER_BLACKLIST.clear();
|
||||
SERVER_BLACKLISTS.clear();
|
||||
BLACKLIST.load();
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ 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 {
|
||||
@@ -34,6 +33,6 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
}
|
||||
|
||||
public boolean doesBypass(CommandSender sender) {
|
||||
return !ENABLED || PermissionUtil.hasPermission(sender, "namespace");
|
||||
return !ENABLED || sender.hasPermission("namespace");
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -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, USE_CENTER_VARIABLE;
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST;
|
||||
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.isBefore(1, 12)))
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.getMinor() < 12))
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
@@ -42,7 +42,6 @@ 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 ENABLED;
|
||||
public boolean DISABLED;
|
||||
|
||||
public DisableSyncSection() {
|
||||
super("disable-sync");
|
||||
@@ -16,11 +16,7 @@ public class DisableSyncSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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,6 +4,7 @@ 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 {
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
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 {
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
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 {
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
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,36 +1,30 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
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.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.impl.BukkitClient;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
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.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
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.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.PlaceholderHook;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.*;
|
||||
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.*;
|
||||
@@ -51,15 +45,10 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
|
||||
private final CommandsCache commandsCache = new CommandsCache();
|
||||
private final List<String> offlinePlayerNames = new ArrayList<>();
|
||||
|
||||
private Map<String, Command> commandsMap = null;
|
||||
|
||||
private BukkitAntiTabListener bukkitAntiTabListener = null;
|
||||
|
||||
private static Map<String, Command> commandsMap = null;
|
||||
private PATSchedulerTask updaterTask;
|
||||
|
||||
private final List<String> offlinePlayerNames = new ArrayList<>();
|
||||
private long lastCommandsLoad = -1;
|
||||
|
||||
@Override
|
||||
@@ -95,10 +84,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
new PlaceholderHook().register();
|
||||
|
||||
MessageTranslator.initialize();
|
||||
|
||||
Communicator.initialize(new BukkitPluginMessageClient(), new BukkitCommunicationHandler());
|
||||
BackendUpdater.initialize();
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
bStats.initialize(this);
|
||||
|
||||
PluginManager manager = getServer().getPluginManager();
|
||||
@@ -106,86 +92,57 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
GroupManager.initialize();
|
||||
BukkitPacketAnalyzer.injectAll();
|
||||
} else BackendUpdater.get().handle();
|
||||
} else BackendUpdater.handle();
|
||||
|
||||
manager.registerEvents(new BukkitPlayerListener(), this);
|
||||
manager.registerEvents(new BukkitBlockCommandListener(), this);
|
||||
|
||||
if (Reflection.isAtLeast(1, 13)) {
|
||||
bukkitAntiTabListener = new BukkitAntiTabListener();
|
||||
manager.registerEvents(bukkitAntiTabListener, this);
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
manager.registerEvents(new BukkitAntiTabListener(), this);
|
||||
}
|
||||
|
||||
if (Reflection.isPaper() && Reflection.isAtLeast(1, 12)) {
|
||||
if (Reflection.isPaper() && Reflection.getMinor() >= 12)
|
||||
manager.registerEvents(new PaperServerListPing(), this);
|
||||
}
|
||||
|
||||
registerCommand("proantitab", "pat");
|
||||
startUpdaterTask();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("LuckPerms") != null) {
|
||||
LuckPermsHook.initialize();
|
||||
LuckPermsAdapter.initialize();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
} else {
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerHook.initialize(groupManagerPlugin);
|
||||
GroupManagerAdapter.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null) {
|
||||
ViaVersionHook.initialize();
|
||||
ViaVersionAdapter.initialize();
|
||||
}
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BukkitServerBrand());
|
||||
Communicator.initialize(new BukkitClient());
|
||||
|
||||
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.get().stop();
|
||||
BackendUpdater.stop();
|
||||
BukkitPacketAnalyzer.uninjectAll();
|
||||
MessageTranslator.closeAudiences();
|
||||
}
|
||||
@@ -199,30 +156,6 @@ 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();
|
||||
@@ -254,20 +187,13 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCommandsCache() {
|
||||
commandsCache.reset();
|
||||
}
|
||||
public void updateCommandCache() {}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return commandsCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return Bukkit.getPlayer(playerName) != null;
|
||||
@@ -342,13 +268,6 @@ 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;
|
||||
@@ -361,6 +280,83 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
public static void handleNotificationPacket(CommunicationPackets.Proxy2Backend.NotificationPacket packet) {
|
||||
if (!Storage.SEND_CONSOLE_NOTIFICATION) { return; }
|
||||
|
||||
final Player player = Bukkit.getPlayer(packet.playerId());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", packet.command(),
|
||||
"%server%", Storage.SERVER_NAME,
|
||||
"%world%", player.getWorld().getName());
|
||||
|
||||
Logger.info(notificationMessage);
|
||||
}
|
||||
|
||||
public static void handleUpdateCommandsPacket(CommunicationPackets.Proxy2Backend.UpdatePacket packet) {
|
||||
if (Reflection.getMinor() < 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (packet.forEveryone()) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(packet.playerId());
|
||||
if (player != null) {
|
||||
BukkitAntiTabListener.updateCommands(player);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public static void handlePlayerExecuteCommandPacket(CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket packet) {
|
||||
if (isP2BDisabled()) return;
|
||||
|
||||
final Player player = Bukkit.getPlayer(packet.playerId());
|
||||
if (player == null) return;
|
||||
|
||||
PATScheduler.execute(() -> Bukkit.dispatchCommand(player, packet.command()), player);
|
||||
}
|
||||
|
||||
public static void handleConsoleExecuteCommandPacket(CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket packet) {
|
||||
if (isP2BDisabled()) return;
|
||||
|
||||
PATScheduler.execute(() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), packet.command()), null);
|
||||
}
|
||||
|
||||
public static void handleConsoleMessagePacket(CommunicationPackets.Proxy2Backend.ConsoleMessagePacket packet) {
|
||||
if (isP2BDisabled()) return;
|
||||
|
||||
Logger.info(packet.message());
|
||||
}
|
||||
|
||||
private static boolean isP2BDisabled() {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ALLOW_P2B_ACTIONS) {
|
||||
Logger.warning("P2B actions are currently disabled! You need to enable them manually.");
|
||||
Logger.warning("For that, go to your 'plugins/ProAntiTab/config.yml' file and enable 'handle-through-proxy -> allow-p2b-actions'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void handleDataSyncPacket(CommunicationPackets.Proxy2Backend.DataSyncPacket packet) {
|
||||
Storage.ConfigSections.Messages.PREFIX.PREFIX = packet.messages().prefix();
|
||||
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.ENABLED = packet.autoLowerCase().enabled();
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = packet.unknownCommand().enabled();
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = packet.unknownCommand().message();
|
||||
|
||||
PATEventHandler.callReceiveSyncEvents(packet);
|
||||
}
|
||||
|
||||
public static List<String> getAllCommands() {
|
||||
return new ArrayList<>(commands);
|
||||
}
|
||||
@@ -374,7 +370,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
@@ -393,7 +389,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 : commandsMap.entrySet()) {
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
if (entry.getKey().toLowerCase().contains(":")) {
|
||||
String command = entry.getKey().substring(entry.getKey().lastIndexOf(":") + 1);
|
||||
|
||||
@@ -416,7 +412,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
pluginName = pluginName.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Command> entry : commandsMap.entrySet()) {
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(pluginName.length() + 1);
|
||||
|
||||
@@ -495,6 +491,10 @@ 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 Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
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.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.impl.BungeeClient;
|
||||
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.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.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.command.impl.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.listeners.bungee.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@@ -66,8 +62,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();
|
||||
|
||||
@@ -83,8 +79,10 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (manager.getPlugin("LuckPerms") != null)
|
||||
LuckPermsHook.initialize();
|
||||
LuckPermsAdapter.initialize();
|
||||
|
||||
if(manager.getPlugin("PAPIProxyBridge") != null) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
@@ -97,14 +95,11 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BungeeServerBrand());
|
||||
Communicator.initialize(new BungeePluginMessageClient(), new BungeeCommunicationHandler());
|
||||
Communicator.initialize(new BungeeClient());
|
||||
|
||||
// Reload proxy commands after 1, 5, and 15 seconds.
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
@@ -127,27 +122,6 @@ 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();
|
||||
@@ -157,20 +131,12 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
public void delayedPermissionsReload() {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCommandExist(String command) {
|
||||
return false;
|
||||
@@ -197,17 +163,12 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCommandsCache() {
|
||||
public void updateCommandCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@@ -305,7 +266,7 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -9,36 +8,14 @@ import java.util.UUID;
|
||||
|
||||
public interface PluginLoader {
|
||||
|
||||
void addPermission(String permission);
|
||||
void removePermission(String permission);
|
||||
|
||||
Object getPluginObj();
|
||||
|
||||
void handleReload();
|
||||
boolean doesCommandExist(String command);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
HashMap<String, CommandsCache> getCommandsCacheMap();
|
||||
|
||||
void delayedPermissionsReload();
|
||||
|
||||
void delayedPermissionsReload(CommandSender sender);
|
||||
|
||||
void resetCommandsCache();
|
||||
void updateCommandCache();
|
||||
|
||||
List<String> getServerNames();
|
||||
|
||||
@@ -71,7 +48,6 @@ public interface PluginLoader {
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
* %v = Plugin version
|
||||
* </pre>
|
||||
*/
|
||||
List<String> getFormattedPluginNames(String format);
|
||||
List<String> getPluginNames(String format);
|
||||
}
|
||||
@@ -4,24 +4,23 @@ 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.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.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
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.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.command.impl.VelocityCommand;
|
||||
import de.rayzs.pat.plugin.commands.VelocityCommand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -35,15 +34,13 @@ 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.4",
|
||||
version = "2.3.1",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hides more than just your plugins.",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -93,6 +90,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
Storage.loadAll(true);
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.initialize();
|
||||
|
||||
metricsFactory.make(this, 21638);
|
||||
@@ -105,8 +103,10 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (server.getPluginManager().getPlugin("luckperms").isPresent())
|
||||
LuckPermsHook.initialize();
|
||||
LuckPermsAdapter.initialize();
|
||||
|
||||
if (server.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
@@ -117,14 +117,11 @@ public class VelocityLoader implements PluginLoader {
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
CustomServerBrand.initialize(new VelocityServerBrand());
|
||||
|
||||
Communicator.initialize(new VelocityPluginMessageClient(), new VelocityCommunicationHandler());
|
||||
Communicator.initialize(new VelocityClient());
|
||||
|
||||
VelocityPacketAnalyzer.injectAll();
|
||||
}
|
||||
@@ -133,43 +130,22 @@ 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();
|
||||
resetCommandsCache();
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
public static void delayedPlayerReload(UUID uuid) {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
String serverName = Storage.getLoader().getPlayerServerName(uuid);
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(serverName));
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
commands.addAll(SubArguments.getGroupCommands(uuid, serverName));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, commands, true);
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
@@ -202,20 +178,15 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCommandsCache() {
|
||||
public void updateCommandCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return server.getPlayer(playerName).isPresent();
|
||||
@@ -320,7 +291,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
|
||||
+27
-27
@@ -1,27 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -1,18 +1,18 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.system.converter;
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.system.converter.converters;
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.system.converter.converters;
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.system.converter.converters;
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.system.converter.converters;
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.system.converter.converters;
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -5,9 +5,10 @@ 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.hooks.ViaVersionHook;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -19,13 +20,13 @@ import java.util.*;
|
||||
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
private final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
|
||||
private static final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
|
||||
@@ -45,14 +46,17 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage.getLoader().getBukkitCommandsCacheMap().handleCommands(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands()
|
||||
: BukkitLoader.getAllCommands()
|
||||
);
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (Reflection.isCraftbukkit() && sender != null) {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
} else {
|
||||
PermissionUtil.reloadPermissions(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
@@ -67,8 +71,8 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final List<String> playerCommands = Storage.getLoader().getBukkitCommandsCacheMap().getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, playerCommands);
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
@@ -87,12 +91,57 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean notUpdatablePlayer(UUID uuid) {
|
||||
return Storage.USE_VIAVERSION && Reflection.isAtLeast(1, 16) && ViaVersionHook.getPlayerProtocol(uuid) < 754;
|
||||
public static List<String> getCommands() {
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands() : BukkitLoader.getAllCommands();
|
||||
}
|
||||
|
||||
public void updateCommands(Player player) {
|
||||
private static boolean notUpdatablePlayer(UUID uuid) {
|
||||
return Storage.USE_VIAVERSION && Reflection.getMinor() >= 16 && ViaVersionAdapter.getPlayerProtocol(uuid) < 754;
|
||||
}
|
||||
|
||||
|
||||
// --------------- LUCKPERMS SECTIONS --------------- //
|
||||
|
||||
public static void updateCommands() {
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::updateCommands);
|
||||
}
|
||||
|
||||
public static 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,11 +2,10 @@ 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;
|
||||
@@ -28,7 +27,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onUnknownCommandRecognition(PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final World world = player.getWorld();
|
||||
|
||||
String rawCommand = StringUtils.getFirstArg(event.getMessage()),
|
||||
@@ -52,7 +51,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
@@ -77,8 +76,6 @@ 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) {
|
||||
@@ -161,7 +158,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
player,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -170,17 +167,6 @@ 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;
|
||||
|
||||
@@ -198,30 +184,8 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, 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,41 +1,45 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
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 CommandSender sender = CommandSender.from(player);
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
BackendUpdater.get().handle();
|
||||
BackendUpdater.handle();
|
||||
}
|
||||
|
||||
CustomServerBrand.get().preparePlayer(player);
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (CustomServerBrand.get().isEnabled()) {
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
if (CustomServerBrand.isEnabled()) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
@@ -47,7 +51,9 @@ public class BukkitPlayerListener implements Listener {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
}, 20);
|
||||
|
||||
}
|
||||
@@ -57,25 +63,18 @@ public class BukkitPlayerListener implements Listener {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
if (!BukkitPacketAnalyzer.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
|
||||
));
|
||||
}
|
||||
|
||||
Logger.warning("Failed to inject into player! (" + player.getName() + ")" );
|
||||
player.kickPlayer("Failed to inject player!");
|
||||
}
|
||||
}
|
||||
}, 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()) {
|
||||
@@ -87,11 +86,8 @@ public class BukkitPlayerListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
BukkitPacketAnalyzer.uninject(player.getUniqueId());
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
@@ -102,15 +98,18 @@ public class BukkitPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ 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;
|
||||
@@ -51,9 +52,8 @@ public class PaperServerListPing implements Listener {
|
||||
|
||||
} else {
|
||||
|
||||
final List<String> lines = new ArrayList<>();
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line -> {
|
||||
|
||||
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, "&", "§"
|
||||
);
|
||||
|
||||
lines.add(playerName);
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -78,47 +78,14 @@ public class PaperServerListPing implements Listener {
|
||||
? Arrays.copyOfRange(nameSplit, 0, 30)
|
||||
: nameSplit;
|
||||
|
||||
lines.addAll(Arrays.asList(nameSplit));
|
||||
for (String name : nameSplit) {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(name, RANDOM_UUID));
|
||||
}
|
||||
|
||||
} else {
|
||||
lines.add(playerName);
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,13 +2,14 @@ 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.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.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;
|
||||
@@ -27,7 +28,7 @@ public class BungeeAntiTabListener implements Listener {
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
@@ -79,7 +80,7 @@ public class BungeeAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
event.getSuggestions().clear();
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.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;
|
||||
@@ -31,7 +30,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
|
||||
final ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
@@ -40,7 +39,6 @@ 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)) {
|
||||
@@ -124,7 +122,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
player,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -133,17 +131,6 @@ 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;
|
||||
|
||||
@@ -166,30 +153,8 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getMessage()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ 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 {
|
||||
@@ -45,43 +44,8 @@ public class BungeePingListener implements Listener {
|
||||
List<String> lines = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines();
|
||||
ServerPing.PlayerInfo[] playerInfos = new ServerPing.PlayerInfo[lines.size()];
|
||||
|
||||
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, "");
|
||||
}
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(replaceString(lines.get(i), online, onlineExtend, max), "");
|
||||
}
|
||||
|
||||
serverPing.getPlayers().setSample(playerInfos);
|
||||
|
||||
+13
-16
@@ -1,13 +1,13 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
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 = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.get().isEnabled())
|
||||
if(CustomServerBrand.isEnabled())
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
if (player.isConnected()) CustomServerBrand.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 = CommandSender.from(player);
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
@@ -60,16 +60,13 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
@@ -78,6 +75,6 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ 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;
|
||||
@@ -29,7 +30,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName) || PermissionUtil.hasBypassPermission(sender)) {
|
||||
@@ -37,7 +38,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
@@ -60,7 +61,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
return playerCommands.contains(command.getKey());
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, new ArrayList<>(event.getCommands().keySet()));
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
@@ -20,6 +20,7 @@ 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 {
|
||||
|
||||
@@ -43,7 +44,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender) || event.getSuggestions().isEmpty() || player.getCurrentServer().isEmpty()) {
|
||||
return;
|
||||
@@ -59,7 +60,7 @@ public class VelocityAntiTabListener {
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, serverName);
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, event.getSuggestions());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
@@ -84,7 +85,7 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
+6
-44
@@ -3,10 +3,8 @@ 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.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.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;
|
||||
@@ -15,8 +13,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;
|
||||
|
||||
@@ -43,13 +41,11 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
|
||||
final Player player = (Player) commandSource;
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getCurrentServer().isPresent()
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
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();
|
||||
@@ -140,28 +136,15 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
|
||||
if (!allowed) {
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
player,
|
||||
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;
|
||||
|
||||
@@ -183,31 +166,10 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
|
||||
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getCommand(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getCommand()),
|
||||
false
|
||||
);
|
||||
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, 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;
|
||||
|
||||
+17
-29
@@ -2,12 +2,11 @@ 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.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.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;
|
||||
@@ -16,6 +15,7 @@ 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,19 +33,20 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
final ServerInfo serverInfo = event.getOriginalServer().getServerInfo();
|
||||
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
|
||||
}
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.get().isEnabled())
|
||||
if(CustomServerBrand.isEnabled())
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
if (player.isActive()) CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
@@ -65,22 +66,12 @@ 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)) {
|
||||
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
|
||||
)
|
||||
));
|
||||
}
|
||||
Logger.warning("Second injection for " + player.getUsername() + " failed as well!");
|
||||
player.disconnect(Component.text("Failed to inject player!"));
|
||||
}
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
@@ -91,7 +82,7 @@ public class VelocityConnectionListener {
|
||||
final ServerInfo serverInfo = event.getServer().getServerInfo();
|
||||
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
|
||||
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
@@ -100,16 +91,13 @@ public class VelocityConnectionListener {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
VelocityPacketAnalyzer.uninject(player);
|
||||
|
||||
@@ -5,9 +5,6 @@ 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 {
|
||||
@@ -43,43 +40,9 @@ public class VelocityPingListener {
|
||||
builder.clearSamplePlayers();
|
||||
else if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CUSTOM_PLAYERLIST) {
|
||||
builder.clearSamplePlayers();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line ->
|
||||
builder.samplePlayers(new ServerPing.SamplePlayer(replaceString(line, online, extend, max), RANDOM_UUID))
|
||||
);
|
||||
}
|
||||
|
||||
event.setPing(builder.build());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.logger;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.logger.impl.*;
|
||||
@@ -97,7 +97,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getFormattedPluginNames("%n (%v)")))
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Detected supported plugins:")
|
||||
@@ -145,13 +145,13 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Communicator.get().getLastSync())))
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Communicator.get().getLastSync())))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("synced-server: ");
|
||||
Iterator<Client> iterator = Communicator.get().getClients().iterator();
|
||||
Iterator<ClientInfo> iterator = Communicator.get().getClients().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Client clientInfo = iterator.next();
|
||||
ClientInfo clientInfo = iterator.next();
|
||||
|
||||
builder.append(clientInfo.getServerName())
|
||||
.append(" (")
|
||||
|
||||
+256
-261
@@ -1,261 +1,256 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
package de.rayzs.pat.plugin.process.impl.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.communication.BackendUpdater;
|
||||
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;
|
||||
@@ -35,7 +35,7 @@ public class InfoCommand extends ProCommand {
|
||||
|
||||
|
||||
if (!Reflection.isProxyServer()
|
||||
&& !BackendUpdater.get().isConnected()
|
||||
&& !BackendUpdater.isConnected()
|
||||
&& Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
{
|
||||
syncTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import java.util.*;
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
|
||||
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.communication.client.ClientInfo;
|
||||
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;
|
||||
@@ -31,14 +31,14 @@ public class StatsCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Set<Client> clients = Communicator.get().getClients();
|
||||
final Iterator<Client> iterator = clients.iterator();
|
||||
final Set<ClientInfo> clients = Communicator.get().getClients();
|
||||
final Iterator<ClientInfo> iterator = clients.iterator();
|
||||
|
||||
boolean tmpFound = false;
|
||||
StringBuilder statsBuilder = new StringBuilder();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Client client = iterator.next();
|
||||
ClientInfo client = iterator.next();
|
||||
|
||||
if (!tmpFound) {
|
||||
tmpFound = true;
|
||||
+3
-4
@@ -1,11 +1,10 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+3
-5
@@ -1,11 +1,9 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.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.get().getConverter(converterName);
|
||||
Converter converter = StorageConverter.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.get().getConverters().stream().toList();
|
||||
return StorageConverter.getConverters().stream().toList();
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -34,13 +34,12 @@ public class CreateGroupCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
String groupName = args[0].toLowerCase();
|
||||
String groupName = args[0];
|
||||
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;
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
@@ -58,7 +58,6 @@ 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.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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().getFormattedPluginNames("%n");
|
||||
List<String> pluginNames = Storage.getLoader().getPluginNames("%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().getFormattedPluginNames("%n");
|
||||
final List<String> suggestions = Storage.getLoader().getPluginNames("%n");
|
||||
suggestions.add("*");
|
||||
|
||||
return suggestions;
|
||||
+3
-4
@@ -1,10 +1,9 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
+3
-5
@@ -1,12 +1,10 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.command.commands.local.modify.list;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
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;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.command.commands.local.system;
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.command.commands.local.system;
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
+8
-3
@@ -1,9 +1,14 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
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.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 {
|
||||
+21
-6
@@ -1,9 +1,13 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
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.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.*;
|
||||
|
||||
@@ -23,14 +27,18 @@ public class UpdateCommand extends ProCommand {
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByName(name);
|
||||
|
||||
if (playerObj != null) {
|
||||
CommandSender s = CommandSender.from(playerObj);
|
||||
CommandSender s = CommandSenderHandler.from(playerObj);
|
||||
|
||||
assert s != null;
|
||||
PermissionUtil.reloadPermissions(s);
|
||||
}
|
||||
});
|
||||
|
||||
Storage.getLoader().updateCommands();
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
} else if (Reflection.isProxyServer()) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}
|
||||
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
|
||||
return true;
|
||||
@@ -39,7 +47,7 @@ public class UpdateCommand extends ProCommand {
|
||||
String name = args[0];
|
||||
UUID uuid = Storage.getLoader().getUUIDByName(name);
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
CommandSender targetSender = CommandSender.from(playerObj);
|
||||
CommandSender targetSender = CommandSenderHandler.from(playerObj);
|
||||
|
||||
boolean exist = targetSender != null;
|
||||
|
||||
@@ -54,8 +62,15 @@ public class UpdateCommand extends ProCommand {
|
||||
message = message.replace("%target%", name);
|
||||
|
||||
if (exist) {
|
||||
|
||||
PermissionUtil.reloadPermissions(targetSender);
|
||||
Storage.getLoader().updateCommands(targetSender);
|
||||
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(uuid);
|
||||
} else if (Reflection.isProxyServer()) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(uuid, targetSender.getServerName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.command.commands.server;
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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.command.commands.server;
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.command.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;
|
||||
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user