Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e63836bd11 | ||
|
|
1afd93d296 | ||
|
|
cb44ae50ff | ||
|
|
6ce5c8caaf | ||
|
|
d5b53aecfa | ||
|
|
cc1bb4ec34 | ||
|
|
be9027fa82 | ||
|
|
247b3a1ffd | ||
|
|
356454c66d | ||
|
|
c11cb20917 | ||
|
|
84a7fbafae | ||
|
|
f5acc445e7 | ||
|
|
38142da87e | ||
|
|
4ea2f5cb33 | ||
|
|
8001e5aa8d | ||
|
|
5b4c45dbcc | ||
|
|
fa62e0fae6 | ||
|
|
06e0030f63 | ||
|
|
8441481d10 | ||
|
|
6782635202 | ||
|
|
d061b8967b | ||
|
|
4881fa3c66 | ||
|
|
8e8643bf06 | ||
|
|
18ee04a979 | ||
|
|
0394aaedf4 | ||
|
|
3c62d3c1b9 | ||
|
|
94eff2bf6d | ||
|
|
1f7e6cd77a | ||
|
|
34cba027f9 | ||
|
|
db42fc1295 | ||
|
|
5270a432e9 | ||
|
|
ab052d62b5 | ||
|
|
a878944b33 | ||
|
|
cb349e8abb | ||
|
|
95963b59b8 | ||
|
|
ce1a326f5b | ||
|
|
aef3c3edfc | ||
|
|
4332f677f9 | ||
|
|
298e98b06d | ||
|
|
c419444481 | ||
|
|
3206a616b9 | ||
|
|
3fd9328842 | ||
|
|
e39939598b | ||
|
|
cc02837035 | ||
|
|
0c8b50b32f | ||
|
|
b5833c05b2 | ||
|
|
810ed9982c | ||
|
|
cc470740af | ||
|
|
ed8d5e0cf3 | ||
|
|
161eafeea7 | ||
|
|
b4c54101c9 | ||
|
|
729b1ccf8d | ||
|
|
3f14a091ec | ||
|
|
8282a0147b | ||
|
|
b4628443d4 | ||
|
|
60516283e2 | ||
|
|
b3e622d652 | ||
|
|
1ee5623a80 | ||
|
|
419d1ae508 | ||
|
|
a9eaa531e7 | ||
|
|
ff7e3cd444 | ||
|
|
abb4c5404f | ||
|
|
c804ec51bd | ||
|
|
cc025c52b1 | ||
|
|
c29bab0e84 | ||
|
|
ab74e04a53 | ||
|
|
8713aafc27 | ||
|
|
60e3188990 | ||
|
|
97abf3834b | ||
|
|
7126808d04 | ||
|
|
e3c04135cc | ||
|
|
c70aeefc44 | ||
|
|
3e21d1730c | ||
|
|
903139631d | ||
|
|
3ac2a580b1 | ||
|
|
e83dc9484f | ||
|
|
e908b8699a | ||
|
|
92e1795266 | ||
|
|
2b6f59bc5a | ||
|
|
33081fa953 | ||
|
|
552d97d5f4 | ||
|
|
b633f8728d | ||
|
|
73f8d464b4 | ||
|
|
e546dad6f3 | ||
|
|
fce7a83d98 | ||
|
|
e422af5cb1 | ||
|
|
171106c495 | ||
|
|
400f4d0d55 | ||
|
|
c48f42c421 | ||
|
|
cd56526c01 | ||
|
|
ed4690f23c | ||
|
|
aef18508aa | ||
|
|
ebf07fc9e1 | ||
|
|
2b1f03ddb7 | ||
|
|
516003398d | ||
|
|
dbae642d40 | ||
|
|
fcf84628a2 | ||
|
|
ac93e5c904 | ||
|
|
e6e3c5a9dd | ||
|
|
594972b17a | ||
|
|
b6903a109b | ||
|
|
0837f9d75d | ||
|
|
f928a94b83 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>1.9.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -76,6 +76,13 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.folia</groupId>
|
||||
<artifactId>folia-api</artifactId>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.api.brand.impl.*;
|
||||
|
||||
@@ -12,4 +14,11 @@ public class CustomServerBrand {
|
||||
public static void refreshTask() { SERVER_BRAND.initializeTask(); }
|
||||
public static void preparePlayer(Object playerObj) { SERVER_BRAND.preparePlayer(playerObj); }
|
||||
public static void sendBrandToPlayer(Object playerObj) { SERVER_BRAND.send(playerObj); }
|
||||
|
||||
public static PacketUtils.BrandManipulate createBrandPacket(Object playerObj) { return SERVER_BRAND.createPacket(playerObj); }
|
||||
public static boolean isEnabled() { return Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED; }
|
||||
|
||||
public static boolean isBrandTag(String tag) {
|
||||
return tag.equals("MC|Brand") || tag.equals("minecraft:brand");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
|
||||
public interface ServerBrand {
|
||||
void preparePlayer(Object playerObj);
|
||||
void send(Object playerObj);
|
||||
PacketUtils.BrandManipulate createPacket(Object playerObj);
|
||||
void initializeTask();
|
||||
}
|
||||
@@ -5,6 +5,8 @@ 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 de.rayzs.pat.api.brand.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,7 +21,7 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
private static final List<Player> MODIFIED_BRAND_PLAYERS = new ArrayList<>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static int TASK = -1;
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
|
||||
|
||||
@@ -48,9 +50,9 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(TASK != -1) {
|
||||
Bukkit.getScheduler().cancelTask(TASK);
|
||||
TASK = -1;
|
||||
if(TASK != null && TASK.isActive()) {
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
MODIFIED_BRAND_PLAYERS.clear();
|
||||
}
|
||||
|
||||
@@ -58,12 +60,13 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
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";
|
||||
@@ -115,6 +118,11 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isModified(Player player) {
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED || Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return false;
|
||||
return MODIFIED_BRAND_PLAYERS.contains(player);
|
||||
|
||||
@@ -57,4 +57,17 @@ public class BungeeServerBrand implements ServerBrand {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -80,4 +80,25 @@ public class VelocityServerBrand implements ServerBrand {
|
||||
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,12 +1,12 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BackendUpdater {
|
||||
|
||||
private static int TASK = -1;
|
||||
private static PATSchedulerTask TASK;
|
||||
|
||||
public static void handle() {
|
||||
if(isRunning() || !shouldRun() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
@@ -14,23 +14,22 @@ public class BackendUpdater {
|
||||
}
|
||||
|
||||
public static boolean isRunning() {
|
||||
return TASK != -1;
|
||||
return TASK != null && TASK.isActive();
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
if(TASK != -1) return;
|
||||
if(isRunning()) return;
|
||||
|
||||
TASK = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
if(shouldRun()) Communicator.sendRequest();
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
if (shouldRun()) Communicator.sendRequest();
|
||||
else stop();
|
||||
}, 5, 20);
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
if(TASK == -1) return;
|
||||
|
||||
Bukkit.getScheduler().cancelTask(TASK);
|
||||
TASK = -1;
|
||||
if(TASK == null || !TASK.isActive()) return;
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
}
|
||||
|
||||
private static boolean shouldRun() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.*;
|
||||
import de.rayzs.pat.api.communication.impl.*;
|
||||
@@ -149,6 +150,8 @@ public class Communicator {
|
||||
|
||||
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
|
||||
|
||||
PATEventHandler.callSentSyncEvents(bundle, serverName);
|
||||
}
|
||||
|
||||
public static void sendRequest() {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class PATEvent<T> {
|
||||
|
||||
private final UUID senderUniqueId;
|
||||
private final Object senderObj;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PATEvent(UUID senderUniqueId) {
|
||||
this.senderUniqueId = senderUniqueId;
|
||||
public PATEvent(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
}
|
||||
|
||||
public abstract void handle(T t);
|
||||
@@ -16,9 +14,8 @@ public abstract class PATEvent<T> {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public UUID getSenderUniqueId() {
|
||||
return senderUniqueId;
|
||||
public Object getSenderObj() {
|
||||
return senderObj;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent call(UUID senderUniqueId, String command, boolean blocked) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderUniqueId, command, blocked);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ExecuteCommandEvent) {
|
||||
@@ -20,8 +22,8 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent call(UUID senderUniqueId, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderUniqueId, suggestions);
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof FilteredSuggestionEvent) {
|
||||
@@ -33,8 +35,8 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent call(UUID senderUniqueId, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderUniqueId, 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) {
|
||||
@@ -46,6 +48,71 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ServerPlayersChangeEvent) {
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent callUpdatePluginEvents() {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePluginEvent) {
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
updatePluginEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
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 updatePlayerCommandsEvent = (UpdatePlayerCommandsEvent) patEvent;
|
||||
updatePlayerCommandsEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof SentSyncEvent) {
|
||||
SentSyncEvent sentSyncEvent = (SentSyncEvent) patEvent;
|
||||
sentSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ReceiveSyncEvent) {
|
||||
ReceiveSyncEvent proxySyncEvent = (ReceiveSyncEvent) patEvent;
|
||||
proxySyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void register(PATEvent event) {
|
||||
EVENTS.add(event);
|
||||
}
|
||||
@@ -56,8 +123,53 @@ public class PATEventHandler {
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(UUID senderUniqueId, String command, boolean blocked) {
|
||||
return new ExecuteCommandEvent(senderUniqueId, command, blocked) {
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
return new SentSyncEvent(null, packetBundle, serverName) {
|
||||
@Override
|
||||
public void handle(SentSyncEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.PacketBundle packetBundle) {
|
||||
return new ReceiveSyncEvent(null, packetBundle) {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(playerObj, commands, serverBased) {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent createEmptyUpdatePluginEvent() {
|
||||
return new UpdatePluginEvent(null) {
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked) {
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
@@ -65,8 +177,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(UUID senderUniqueId, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(senderUniqueId, suggestions) {
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(senderObj, suggestions) {
|
||||
@Override
|
||||
public void handle(FilteredSuggestionEvent event) {
|
||||
|
||||
@@ -74,8 +186,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(UUID senderUniqueId, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(senderUniqueId, 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 java.util.UUID;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
|
||||
|
||||
@@ -14,8 +13,8 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(UUID senderUniqueId, String command, boolean blocked) {
|
||||
super(senderUniqueId);
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
|
||||
super(senderObj);
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
}
|
||||
@@ -24,11 +23,6 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSenderUniqueId() {
|
||||
return super.getSenderUniqueId();
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestio
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(UUID senderUniqueId, List<String> suggestions) {
|
||||
super(senderUniqueId);
|
||||
public FilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
super(senderObj);
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,6 @@ public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestio
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSenderUniqueId() {
|
||||
return super.getSenderUniqueId();
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(UUID senderUniqueId, String cursor, List<String> completion) {
|
||||
super(senderUniqueId);
|
||||
public FilteredTabCompletionEvent(Object senderObj, String cursor, List<String> completion) {
|
||||
super(senderObj);
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
@@ -30,11 +30,6 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
return completion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSenderUniqueId() {
|
||||
return super.getSenderUniqueId();
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
|
||||
public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
|
||||
public ReceiveSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
}
|
||||
|
||||
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
|
||||
public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
private final String serverName;
|
||||
|
||||
public SentSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
this.serverName = null;
|
||||
}
|
||||
|
||||
public SentSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
|
||||
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
super(senderObj);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ServerPlayersChangeEvent() {
|
||||
super(null);
|
||||
this.type = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
public enum Type { JOINED, LEFT, UNKNOWN }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCommandsEvent> {
|
||||
|
||||
private List<String> commands;
|
||||
private boolean serverBased;
|
||||
|
||||
public UpdatePlayerCommandsEvent() {
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePlayerCommandsEvent(Object senderObj, List<String> commands, boolean serverBased) {
|
||||
super(senderObj);
|
||||
this.commands = commands;
|
||||
this.serverBased = serverBased;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public boolean isServerBased() {
|
||||
return serverBased;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
|
||||
public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
|
||||
public UpdatePluginEvent() {
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePluginEvent(Object senderObj) {
|
||||
super(senderObj);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ 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;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.entity.Player;
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -13,6 +15,7 @@ import java.util.*;
|
||||
public class BukkitPacketAnalyzer {
|
||||
|
||||
public static final ConcurrentHashMap<UUID, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
private static final ExpireCache<UUID, Object> SENT_PACKET = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.getMinor() >= 16 ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
@@ -27,6 +30,14 @@ public class BukkitPacketAnalyzer {
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.clear();
|
||||
}
|
||||
|
||||
public static void sendPacket(UUID uuid, Object object) {
|
||||
Channel channel = INJECTED_PLAYERS.get(uuid);
|
||||
if(channel == null) return;
|
||||
|
||||
SENT_PACKET.put(uuid, object);
|
||||
channel.pipeline().writeAndFlush(object);
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if(Storage.USE_VELOCITY) return true;
|
||||
|
||||
@@ -92,7 +103,7 @@ public class BukkitPacketAnalyzer {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (packetName.equals("PacketPlayInTabComplete") || packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
if(!PACKET_HANDLER.handleIncomingPacket(player, packetObj)) return;
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj)) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +118,16 @@ public class BukkitPacketAnalyzer {
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
if (packetName.equals("PacketPlayOutTabComplete") || packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
if((packetName.equals("ClientboundCommandSuggestionsPacket") || Reflection.isFoliaServer()) && SENT_PACKET.contains(player.getUniqueId())) {
|
||||
Object newPacketObj = SENT_PACKET.get(uuid);
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, newPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!PACKET_HANDLER.handleOutgoingPacket(player, packetObj)) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -8,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@@ -42,7 +45,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
|
||||
} else return true;
|
||||
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
@@ -69,7 +72,13 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
newResultList.add(s);
|
||||
}
|
||||
} else {
|
||||
if(!cancelsBeforeHand) newResultList.addAll(Arrays.asList(tR));
|
||||
if(!cancelsBeforeHand) {
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), input, Arrays.asList(tR));
|
||||
if(!filteredTabCompletionEvent.isCancelled()) {
|
||||
List<String> suggestions = Arrays.stream(tR).filter(s -> filteredTabCompletionEvent.getCompletion().contains(s)).collect(Collectors.toList());
|
||||
newResultList.addAll(suggestions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
field.set(packetObj, newResultList.toArray(new String[0]));
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import com.mojang.brigadier.suggestion.*;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.api.netty.bukkit.*;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@@ -21,6 +29,12 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
String text = (String) stringField.get(packetObj);
|
||||
if(Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(text)) {
|
||||
MessageTranslator.send(Bukkit.getConsoleSender(), Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getName()));
|
||||
PATScheduler.createScheduler(() -> player.kickPlayer(ChatColor.translateAlternateColorCodes('&', Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get())));
|
||||
return false;
|
||||
}
|
||||
|
||||
BukkitPacketAnalyzer.insertPlayerInput(player, text);
|
||||
return true;
|
||||
}
|
||||
@@ -28,13 +42,15 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
|
||||
Object suggestionObj;
|
||||
|
||||
String input = BukkitPacketAnalyzer.getPlayerInput(player);
|
||||
String rawInput = BukkitPacketAnalyzer.getPlayerInput(player), input = rawInput;
|
||||
if(input == null) return false;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket"),
|
||||
cancelsBeforeHand = false;
|
||||
|
||||
int spaces = 0;
|
||||
if(input.startsWith("/")) {
|
||||
if(input.startsWith("/") || is121Packet) {
|
||||
input = input.replace("/", "");
|
||||
if(input.contains(" ")) {
|
||||
String[] split = input.split(" ");
|
||||
@@ -43,10 +59,60 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
|
||||
}
|
||||
|
||||
if(packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket")) {
|
||||
if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
try {
|
||||
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
suggestions = new ArrayList<>(suggestionsTmp);
|
||||
|
||||
List<Field> intFields = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "int", Reflection.SearchOption.ENDS);
|
||||
int id = (int) intFields.get(0).get(packetObj),
|
||||
start = (int) intFields.get(1).get(packetObj),
|
||||
length = (int) intFields.get(2).get(packetObj);
|
||||
|
||||
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game." + (packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete") ? "PacketPlayOutTabComplete" : "ClientboundCommandSuggestionsPacket"));
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) return false;
|
||||
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
suggestions.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spaces == 0) {
|
||||
suggestions.removeIf(suggestion -> {
|
||||
String command = getSuggestionFromEntry(suggestion);
|
||||
return Storage.Blacklist.isBlocked(player, command);
|
||||
});
|
||||
return true;
|
||||
|
||||
} else {
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
for (Object suggestion : suggestions)
|
||||
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
|
||||
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
Object csO = suggestions.get(i);
|
||||
|
||||
String suggestionAsString = getSuggestionFromEntry(csO);
|
||||
if (!filteredTabCompletionEvent.getCompletion().contains(suggestionAsString))
|
||||
suggestions.remove(csO);
|
||||
}
|
||||
|
||||
suggestions.removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(getSuggestionFromEntry(suggestion)));
|
||||
}
|
||||
|
||||
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
|
||||
.getConstructor(int.class, int.class, int.class, List.class)
|
||||
.newInstance(id, start, length, suggestions);
|
||||
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
return !cancelsBeforeHand;
|
||||
}
|
||||
|
||||
@@ -62,7 +128,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
Suggestions suggestions = (Suggestions) suggestionObj;
|
||||
|
||||
if((input.length() < 1 || cancelsBeforeHand) && Reflection.isWeird()) return false;
|
||||
if((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) return false;
|
||||
if(spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
suggestions.getList().clear();
|
||||
return true;
|
||||
@@ -74,8 +140,32 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
return Storage.Blacklist.isBlocked(player, command);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
for (Suggestion suggestion : suggestions.getList())
|
||||
suggestionsAsString.add(suggestion.getText());
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if(filteredTabCompletionEvent.isCancelled()) suggestions.getList().clear();
|
||||
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(suggestion.getText()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSuggestionFromEntry(Object suggestionObj) {
|
||||
try {
|
||||
List<Field> fields = Reflection.getFieldsByTypeNormal(suggestionObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
if(fields.isEmpty()) return "";
|
||||
|
||||
Field field = fields.get(0);
|
||||
String result = (String) field.get(suggestionObj);
|
||||
field.setAccessible(false);
|
||||
return result;
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -159,7 +164,12 @@ public class BungeePacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wrapper.packet instanceof Commands) {
|
||||
if(wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
|
||||
} else if (wrapper.packet instanceof Commands) {
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
modifyCommands(player, response, commands);
|
||||
player.unsafe().sendPacket(response);
|
||||
@@ -187,7 +197,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
if(!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
final String cursor = playerInput;
|
||||
if(cursor.startsWith("/")) {
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.proxy.crypto.SignedChatCommand;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||
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.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import io.netty.channel.*;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
@@ -20,7 +33,7 @@ public class VelocityPacketAnalyzer {
|
||||
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
private static HashMap<String, CommandsCache> COMMANDS_CACHE_MAP = new HashMap<>();
|
||||
|
||||
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass;
|
||||
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass, signedChatCommandPacketClass;
|
||||
|
||||
public static void injectAll() {
|
||||
VelocityLoader.getServer().getAllPlayers().forEach(VelocityPacketAnalyzer::inject);
|
||||
@@ -109,11 +122,41 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if(packet.getClass().getSimpleName().equals("SignedChatCommand")) {
|
||||
try {
|
||||
if(signedChatCommandPacketClass == null)
|
||||
signedChatCommandPacketClass = Class.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
|
||||
|
||||
Object signedChatCommandPacket = signedChatCommandPacketClass.cast(packet);
|
||||
Field commandField = signedChatCommandPacket.getClass().getField("command");
|
||||
String command = (String) commandField.get(signedChatCommandPacket);
|
||||
|
||||
if(!VelocityBlockCommandListener.handleCommand(player, command))
|
||||
return;
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(packet instanceof UnsignedPlayerCommandPacket) {
|
||||
|
||||
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
|
||||
if(VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()))
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet instanceof TabCompleteRequestPacket) {
|
||||
TabCompleteRequestPacket request = (TabCompleteRequestPacket) msg;
|
||||
if(request.getCommand() != null) {
|
||||
insertPlayerInput(player, request.getCommand());
|
||||
super.channelRead(ctx, msg);
|
||||
|
||||
if(Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(request.getCommand())) {
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getUsername()));
|
||||
player.disconnect(LegacyComponentSerializer.legacyAmpersand().deserialize(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get()));
|
||||
} else {
|
||||
insertPlayerInput(player, request.getCommand());
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
}
|
||||
} else super.channelRead(ctx, msg);
|
||||
}
|
||||
@@ -127,7 +170,15 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if(packet instanceof TabCompleteResponsePacket) {
|
||||
if(packet instanceof PluginMessagePacket) {
|
||||
PluginMessagePacket pluginMessagePacket = (PluginMessagePacket) packet;
|
||||
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;
|
||||
}
|
||||
|
||||
} else if(packet instanceof TabCompleteResponsePacket) {
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
|
||||
|
||||
@@ -143,7 +194,7 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
if(!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
@@ -163,6 +214,12 @@ public class VelocityPacketAnalyzer {
|
||||
});
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), cursor, suggestionsAsString);
|
||||
if(filteredTabCompletionEvent.isCancelled()) return;
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,22 +227,33 @@ public class VelocityPacketAnalyzer {
|
||||
} else if(packet instanceof AvailableCommandsPacket) {
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
AvailableCommandsPacket commands = (AvailableCommandsPacket) packet;
|
||||
if(commands.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
if(!commands.getRootNode().getChildren().isEmpty()) {
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if(!COMMANDS_CACHE_MAP.containsKey(serverName))
|
||||
COMMANDS_CACHE_MAP.put(serverName, new CommandsCache().reverse());
|
||||
CommandsCache commandsCache = COMMANDS_CACHE_MAP.get(serverName);
|
||||
if (!COMMANDS_CACHE_MAP.containsKey(serverName))
|
||||
COMMANDS_CACHE_MAP.put(serverName, new CommandsCache().reverse());
|
||||
CommandsCache commandsCache = COMMANDS_CACHE_MAP.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);
|
||||
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;
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
commands.getRootNode().getChildren().removeIf(command -> command == null || command.getName() == null || playerCommands.contains(command.getName()));
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), 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 -> command == null || command.getName() == null || playerCommands.contains(command.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.api.storage;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.*;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.group.*;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
@@ -33,6 +34,8 @@ public class Storage {
|
||||
loadConfig();
|
||||
loadToken();
|
||||
if(loadBlacklist) Blacklist.loadAll();
|
||||
|
||||
PATEventHandler.callUpdatePluginEvents();
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
@@ -91,6 +94,7 @@ public class Storage {
|
||||
CONFIGURATION = Configurator.get("config"),
|
||||
STORAGE = Configurator.get("storage"),
|
||||
PLACEHOLDERS = Configurator.get("placeholders"),
|
||||
CUSTOM_RESPONSES = Configurator.get("custom-responses"),
|
||||
TOKEN = Configurator.get("token");
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -105,6 +109,7 @@ public class Storage {
|
||||
|
||||
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();
|
||||
@@ -127,6 +132,7 @@ public class Storage {
|
||||
public static InfoSection INFO = new InfoSection();
|
||||
public static NoPermissionSection NO_PERMISSION = new NoPermissionSection();
|
||||
public static NotificationSection NOTIFICATION = new NotificationSection();
|
||||
public static PermsCheckSection PERMS_CHECK = new PermsCheckSection();
|
||||
public static PostDebugSection POST_DEBUG = new PostDebugSection();
|
||||
public static OnlyForProxySection NO_PROXY = new OnlyForProxySection();
|
||||
public static ReloadSection RELOAD = new ReloadSection();
|
||||
@@ -184,7 +190,7 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
private static HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final GeneralBlacklist BLACKLIST = BlacklistCreator.createGeneralBlacklist();
|
||||
private static final IgnoredServersStorage IGNORED_SERVERS = new GeneralIgnoredServers();
|
||||
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
@@ -337,13 +343,22 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server) {
|
||||
return isListed(playerObj, command, intensive, listed, slash, server, false);
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server, boolean instantReturn) {
|
||||
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getAllCommands(server), intensive) && group.hasPermission(playerObj)))
|
||||
return false;
|
||||
|
||||
if(!listed) for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(listed) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
listed = blacklist.isListed(command, intensive, true, slash);
|
||||
if(instantReturn) return listed;
|
||||
|
||||
if(listed) break;
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
|
||||
@@ -366,18 +381,26 @@ public class Storage {
|
||||
if(focusOnBlock && blockedGlobal) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(!focusOnBlock) {
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
if (blockedServer) break;
|
||||
} else {
|
||||
if(blacklist.isBlocked(command, intensive)) return true;
|
||||
if(focusOnBlock && blacklist.isBlocked(command, intensive))
|
||||
return true;
|
||||
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
break;
|
||||
|
||||
/* Former code
|
||||
if (!blacklist.isBlockedIgnorePermission(command, intensive)) {
|
||||
blockedServer = false;
|
||||
break;
|
||||
}
|
||||
|
||||
blockedServer = true;
|
||||
*/
|
||||
}
|
||||
|
||||
blocked = turn ? blockedGlobal && blockedServer : blockedServer || blockedGlobal;
|
||||
if(!blocked
|
||||
&& CACHED_SERVER_BLACKLIST.contains(server)
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).size() == 0)
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).isEmpty())
|
||||
if(turn) blocked = true;
|
||||
|
||||
return blocked;
|
||||
|
||||
@@ -25,6 +25,7 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f info &7to get a few information"
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
@@ -42,6 +43,7 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f info &7to get a few information"
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
|
||||
public class PermsCheckSection extends ConfigStorage {
|
||||
|
||||
public String MESSAGE, PLAYER_MISSING, PLAYER_NOT_ONLINE;
|
||||
|
||||
public PermsCheckSection() {
|
||||
super("perms-check");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, "message", "&7All of &e%player%'s &7PAT-related permission: &e%permissions%").getOrSet();
|
||||
PLAYER_MISSING = new ConfigSectionHelper<String>(this, "player-is-missing", "&cPlease specify the player whose permission you want to check.").getOrSet();
|
||||
PLAYER_NOT_ONLINE = new ConfigSectionHelper<String>(this, "player-not-online", "&c%player% is not online!").getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import java.util.Collections;
|
||||
public class CancelCommandSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
public MultipleMessagesHelper BASE_COMMAND_RESPONSE, SUB_COMMAND_RESPONSE;
|
||||
|
||||
public CancelCommandSection() {
|
||||
super("cancel-blocked-commands");
|
||||
@@ -17,6 +17,7 @@ public class CancelCommandSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message", Collections.singletonList("&cThis sub-argument is blocked!"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PatchExploitSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public ConfigSectionHelper<String> ALERT_MESSAGE, KICK_MESSAGE;
|
||||
|
||||
public PatchExploitSection() {
|
||||
super("patch-exploits");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALERT_MESSAGE = new ConfigSectionHelper<>(this, "alert-message", "%prefix% &4%player% &ctried to crash/lag the server.");
|
||||
KICK_MESSAGE = new ConfigSectionHelper(this, "kick-message", "&cFailed to read packet! Please reconnect.");
|
||||
}
|
||||
|
||||
public boolean isMalicious(String text) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
return text.length() > 256
|
||||
|| text.contains("nbt")
|
||||
&& (StringUtils.countMatches('[', text) > 15 || StringUtils.countMatches('{', text) > 25);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedBaseCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedBaseCommandPlaceholder() { super("message_base_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedCommandPlaceholder extends PlaceholderStorage {
|
||||
public class BlockedSubCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedCommandPlaceholder() { super("message_blocked"); }
|
||||
public BlockedSubCommandPlaceholder() { super("message_sub_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE.getLines());
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -13,11 +14,13 @@ import de.rayzs.pat.plugin.commands.BukkitCommand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.utils.hooks.PlaceholderHook;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import de.rayzs.pat.utils.*;
|
||||
@@ -32,13 +35,14 @@ public class BukkitLoader extends JavaPlugin {
|
||||
private static java.util.logging.Logger logger;
|
||||
private static boolean loaded = false, checkUpdate = false, suggestions = false;
|
||||
private static Map<String, Command> commandsMap = null;
|
||||
private int updaterTaskId;
|
||||
private PATSchedulerTask updaterTask;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +56,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.CURRENT_VERSION = getDescription().getVersion();
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
|
||||
@@ -94,9 +99,10 @@ public class BukkitLoader extends JavaPlugin {
|
||||
ViaVersionAdapter.initialize();
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,15 +134,36 @@ public class BukkitLoader extends JavaPlugin {
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
updaterTaskId = Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, () -> {
|
||||
updaterTask = PATScheduler.createAsyncScheduler(() -> {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
if(result == null) result = "internet";
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
Bukkit.getScheduler().cancelTask(updaterTaskId);
|
||||
if(VersionComparer.isDeveloperVersion()) {
|
||||
updaterTask.cancelTask();
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
|
||||
} else if(!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
updaterTask.cancelTask();
|
||||
checkUpdate = true;
|
||||
|
||||
if(VersionComparer.isUnreleased()) {
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
|
||||
return;
|
||||
}
|
||||
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if(VersionComparer.isOutdated()) {
|
||||
updaterTask.cancelTask();
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if(!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
updaterTask.cancelTask();
|
||||
switch (result) {
|
||||
case "internet":
|
||||
Logger.warning("Failed to build connection to website! (No internet?)");
|
||||
@@ -147,15 +174,6 @@ public class BukkitLoader extends JavaPlugin {
|
||||
case "exception":
|
||||
Logger.warning("Failed to build connection to website! (Outdated java version?)");
|
||||
break;
|
||||
default:
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(!checkUpdate) {
|
||||
checkUpdate = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
}
|
||||
}
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
@@ -178,7 +196,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
|
||||
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
|
||||
BukkitAntiTabListener.setChangeStatus();
|
||||
if(Reflection.getMinor() >= 13) BukkitAntiTabListener.setChangeStatus();
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
}
|
||||
|
||||
@@ -195,13 +213,16 @@ public class BukkitLoader extends JavaPlugin {
|
||||
|
||||
if(!loaded) loaded = true;
|
||||
|
||||
if(Reflection.getMinor() < 16) return;
|
||||
if(Reflection.getMinor() >= 16) {
|
||||
|
||||
if(Storage.USE_VELOCITY)
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
if (Storage.USE_VELOCITY)
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
|
||||
Logger.debug("Force server to load all players tab-completion due to received sync!");
|
||||
BukkitAntiTabListener.handleTabCompletion(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? Storage.Blacklist.getBlacklist().getCommands() : getNotBlockedCommands());
|
||||
Logger.debug("Force server to load all players tab-completion due to received sync!");
|
||||
BukkitAntiTabListener.handleTabCompletion(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? Storage.Blacklist.getBlacklist().getCommands() : getNotBlockedCommands());
|
||||
}
|
||||
|
||||
PATEventHandler.callReceiveSyncEvents(packetBundle);
|
||||
}
|
||||
|
||||
public static boolean doesCommandExist(String command, boolean replace) {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
@@ -33,6 +36,7 @@ public class BungeeLoader extends Plugin {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +49,7 @@ public class BungeeLoader extends Plugin {
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
Storage.CURRENT_VERSION = getDescription().getVersion();
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
|
||||
@@ -82,6 +87,7 @@ public class BungeeLoader extends Plugin {
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,26 +120,58 @@ public class BungeeLoader extends Plugin {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
if(VersionComparer.isDeveloperVersion()) {
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
if (result.equals("unknown")) {
|
||||
Logger.warning("Failed reaching web host! (firewall enabled? website down?)");
|
||||
} else if (result.equals("exception")) {
|
||||
Logger.warning("Failed creating web instance! (outdated java version?)");
|
||||
} else {
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
|
||||
} else if(!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
checkUpdate = true;
|
||||
|
||||
if(VersionComparer.isUnreleased()) {
|
||||
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(!checkUpdate) {
|
||||
checkUpdate = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
checkUpdate = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if(VersionComparer.isOutdated()) {
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if(!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
switch (result) {
|
||||
case "internet":
|
||||
Logger.warning("Failed to build connection to website! (No internet?)");
|
||||
break;
|
||||
case "unknown":
|
||||
Logger.warning("Failed to build connection to website! (Firewall enabled or website down?)");
|
||||
break;
|
||||
case "exception":
|
||||
Logger.warning("Failed to build connection to website! (Outdated java version?)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, 20L, Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
ProxiedPlayer proxiedPlayer = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(proxiedPlayer == null) return null;
|
||||
|
||||
Server server = proxiedPlayer.getServer();
|
||||
if(server == null) return null;
|
||||
|
||||
ServerInfo serverInfo = server.getInfo();
|
||||
if(serverInfo == null) return null;
|
||||
|
||||
return serverInfo.getName();
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.VersionComparer;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
@@ -27,9 +30,9 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "1.8.0",
|
||||
version = "1.9.0",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more then just plugins. Hide almost everything!",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
dependencies = {
|
||||
@Dependency(id = "luckperms", optional = true),
|
||||
@Dependency(id = "papiproxybridge", optional = true)
|
||||
@@ -58,12 +61,14 @@ public class VelocityLoader {
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
|
||||
Reflection.initialize(server);
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
Storage.CURRENT_VERSION = pluginContainer.getDescription().getVersion().get();
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
MessageTranslator.initialize();
|
||||
@@ -96,6 +101,7 @@ public class VelocityLoader {
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@@ -124,25 +130,59 @@ public class VelocityLoader {
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
Storage.NEWER_VERSION = result;
|
||||
if (!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (Storage.NEWER_VERSION.equals("unknown")) {
|
||||
Logger.warning("Failed reaching web host! (firewall enabled? website down?)");
|
||||
} else if (result.equals("exception")) {
|
||||
Logger.warning("Failed creating web instance! (outdated java version?)");
|
||||
} else {
|
||||
Storage.OUTDATED = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
|
||||
if(VersionComparer.isDeveloperVersion()) {
|
||||
updaterTask.cancel();
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using a</gray> <aqua>developer</aqua> <gray>version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.</gray>");
|
||||
|
||||
} else if(!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
updaterTask.cancel();
|
||||
checkUpdate = true;
|
||||
|
||||
if(VersionComparer.isUnreleased()) {
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using an</gray> <yellow>unreleased</yellow> <gray>version of ProAntiTab.</gray>");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(!checkUpdate) {
|
||||
checkUpdate = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines());
|
||||
|
||||
checkUpdate = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines());
|
||||
|
||||
} else if(VersionComparer.isOutdated()) {
|
||||
Storage.OUTDATED = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
|
||||
|
||||
} else if(!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
updaterTask.cancel();
|
||||
switch (result) {
|
||||
case "internet":
|
||||
Logger.warning("[PAT | Proxy] Failed to build connection to website! (No internet?)");
|
||||
break;
|
||||
case "unknown":
|
||||
Logger.warning("[PAT | Proxy] Failed to build connection to website! (Firewall enabled or website down?)");
|
||||
break;
|
||||
case "exception":
|
||||
Logger.warning("[PAT | Proxy] Failed to build connection to website! (Outdated java version?)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).delay(1, TimeUnit.SECONDS).repeat(Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
Optional<Player> optPlayer = server.getPlayer(uuid);
|
||||
if(!optPlayer.isPresent()) return null;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
Optional<ServerConnection> optServer = player.getCurrentServer();
|
||||
if(!optServer.isPresent()) return null;
|
||||
|
||||
ServerConnection server = optServer.get();
|
||||
if(server.getServerInfo() == null) return null;
|
||||
|
||||
return server.getServerInfo().getName();
|
||||
}
|
||||
|
||||
public static ProxyServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(event.getCommands(), player, player.getUniqueId());
|
||||
event.getCommands().clear();
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(uuid, playerCommands);
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
if(filteredSuggestionEvent.isCancelled()) return;
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
|
||||
+19
-15
@@ -43,10 +43,10 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getName(), "%command%", command, "%world%", worldName);
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -59,10 +59,10 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -75,34 +75,36 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || rawCommand.equals("/")) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if(Storage.Blacklist.isListed(command, true)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player, command, false)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -115,19 +117,21 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if (!Storage.Blacklist.isListed(command, false)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
|
||||
+9
-1
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.brand.impl.BukkitServerBrand;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -18,13 +20,16 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
BackendUpdater.handle();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(!BukkitPacketAnalyzer.inject(player)) player.kickPlayer("Failed to inject player!");
|
||||
|
||||
@@ -40,6 +45,8 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
BukkitPacketAnalyzer.uninject(player.getUniqueId());
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
@@ -51,5 +58,6 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
BukkitServerBrand.removeFromModified(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class BungeeAntiTabListener implements Listener {
|
||||
|
||||
event.getSuggestions().removeIf(command -> Storage.Blacklist.isBlocked(player, command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, player.getServer().getInfo().getName()));
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player.getUniqueId(), event.getSuggestions());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
}
|
||||
+21
-20
@@ -40,10 +40,10 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getName(), "%command%", command, "%server%", serverName);
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", rawCommand.replaceFirst("/", ""));
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -56,10 +56,10 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", rawCommand.replaceFirst("/", ""));
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -73,37 +73,39 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
@@ -116,7 +118,8 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,17 +128,15 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(!listed && !serverListed || listed && serverListed && ignored) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
if(executeCommandEvent.isCancelled()) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
return;
|
||||
}
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) Logger.info(notificationMessage);
|
||||
|
||||
+11
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
@@ -18,6 +20,13 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
@@ -41,6 +50,8 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> playerCommands.contains(command.getKey()));
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player.getUniqueId(), 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()) {
|
||||
@@ -50,6 +50,6 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
public static void updateCommands() {
|
||||
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
|
||||
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
||||
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
@@ -24,12 +26,16 @@ public class VelocityAntiTabListener {
|
||||
if(PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
|
||||
event.getSuggestions().removeIf(command -> Storage.Blacklist.isBlocked(player, command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, player.getCurrentServer().get().getServerInfo().getName()));
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onPlayerAvailableCommands(PlayerAvailableCommandsEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if(!COMMANDS_CACHE_MAP.containsKey(serverName))
|
||||
@@ -42,11 +48,19 @@ public class VelocityAntiTabListener {
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
|
||||
if(event.getRootNode().getChildren().size() == 1 && newer
|
||||
&& event.getRootNode().getChild("args") != null
|
||||
&& event.getRootNode().getChild("args").getChildren().isEmpty())
|
||||
return;
|
||||
|
||||
if(event.getRootNode().getChildren().size() == 1 && newer && event.getRootNode().getChild("args") != null) return;
|
||||
event.getRootNode().getChildren().removeIf(command -> command == null || command.getName() == null || playerCommands.contains(command.getName()));
|
||||
}
|
||||
|
||||
public static void updateCommands() {
|
||||
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
|
||||
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
}
|
||||
+145
-17
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.velocity;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
@@ -41,10 +42,10 @@ public class VelocityBlockCommandListener {
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
|
||||
@@ -54,10 +55,10 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
|
||||
@@ -67,13 +68,14 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,23 +84,24 @@ public class VelocityBlockCommandListener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
|
||||
@@ -107,29 +110,154 @@ public class VelocityBlockCommandListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) return;
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, true, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, true, listed, false, serverName);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(!listed && !serverListed || listed && serverListed && ignored) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> server.getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(server.getPlayer(uuid).get(), notificationMessage));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean handleCommand(Player player, String commandSource) {
|
||||
String command = commandSource,
|
||||
serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
boolean blocked = false;
|
||||
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) return false;
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return false;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if (ignored ? !listed && serverListed : serverListed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return blocked;
|
||||
}
|
||||
|
||||
System.out.println(4);
|
||||
|
||||
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, true, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, true, listed, false, serverName);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if (!listed && !serverListed || listed && serverListed && ignored) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
return blocked;
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
@@ -25,6 +27,13 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
@@ -49,8 +58,9 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
VelocityPacketAnalyzer.uninject(player);
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs;
|
||||
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.modules.subargs.events.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.plugin.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SubArgsModule {
|
||||
|
||||
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES;
|
||||
public static HashMap<UUID, Argument> PLAYER_COMMANDS = new HashMap<>();
|
||||
|
||||
public static void initialize() {
|
||||
updateList();
|
||||
updateMessages();
|
||||
updatePlayerNames();
|
||||
|
||||
PATEventHandler.register(new TabCompletion());
|
||||
PATEventHandler.register(new ExecuteCommand());
|
||||
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
|
||||
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
|
||||
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
|
||||
}
|
||||
|
||||
public static void updatePlayerNames() {
|
||||
PLAYER_NAMES = Reflection.isProxyServer()
|
||||
? Reflection.isVelocityServer()
|
||||
? VelocityLoader.getPlayerNames()
|
||||
: BungeeLoader.getPlayerNames()
|
||||
: BukkitLoader.getPlayerNames();
|
||||
}
|
||||
|
||||
public static List<String> getPlayerNames() {
|
||||
return PLAYER_NAMES;
|
||||
}
|
||||
|
||||
public static void updateList() {
|
||||
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
|
||||
|
||||
Argument.clearArguments();
|
||||
GENERAL_LIST.forEach(Argument::buildArguments);
|
||||
SubArgsModule.PLAYER_COMMANDS = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void updateMessages() {
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
Responses.update();
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
if(!Reflection.isProxyServer()) return commands;
|
||||
|
||||
String serverName = Reflection.isVelocityServer() ? VelocityLoader.getServerNameByPlayerUUID(uuid) : BungeeLoader.getServerNameByPlayerUUID(uuid);
|
||||
if(serverName == null) return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
List<Group> groups = new ArrayList<>();
|
||||
|
||||
Group currentGroup;
|
||||
for (String permission : Objects.requireNonNull(PermissionUtil.getPermissions(uuid))) {
|
||||
if(!permission.startsWith("proantitab.group.")) continue;
|
||||
currentGroup = GroupManager.getGroupByName(StringUtils.replaceFirst(permission, "proantitab.group.", ""));
|
||||
if(currentGroup != null && !groups.contains(currentGroup)) groups.add(currentGroup);
|
||||
}
|
||||
|
||||
if(!groups.isEmpty()) {
|
||||
int highestPriority = groups.stream().mapToInt(Group::getPriority).filter(group -> group <= 9999).min().orElse(9999);
|
||||
groups.removeIf(group -> group.getPriority() > highestPriority);
|
||||
for (Group group : groups) commands.addAll(group.getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
|
||||
public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
String command = StringUtils.replaceFirst(event.getCommand(), "/", "");
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(event.getSenderObj(), command.contains(" ") ? command.split(" ")[0] : command))
|
||||
return;
|
||||
|
||||
if(command.contains(" ") && shouldCommandBeBlocked(event, command)) {
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand()), "%command%", event.getCommand());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!event.isBlocked()) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()), "%command%", event.getCommand());
|
||||
}
|
||||
|
||||
private boolean shouldCommandBeBlocked(ExecuteCommandEvent event, String command) {
|
||||
CommandSender sender = new CommandSender(event.getSenderObj());
|
||||
boolean listed = false,
|
||||
turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED,
|
||||
blocked = event.isBlocked(),
|
||||
ignored = false,
|
||||
useFilter = false,
|
||||
tooBig = false;
|
||||
|
||||
String[] split, originCommandSplit, copiedOriginCommandSplit;
|
||||
String tmpCommand;
|
||||
for (String s : SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Argument.getGeneralArgument()).getInputs()) {
|
||||
if(s.contains("%hidden_online_players%")) continue;
|
||||
tmpCommand = command;
|
||||
|
||||
if(s.split(" ")[0].equalsIgnoreCase(tmpCommand.split(" ")[0]))
|
||||
useFilter = true;
|
||||
|
||||
originCommandSplit = tmpCommand.split(" ");
|
||||
split = s.split(" ");
|
||||
int i;
|
||||
|
||||
for(i = 0; i < split.length; i++) {
|
||||
if(!split[i].equals("%online_players%")) continue;
|
||||
|
||||
boolean foundPlayer = false;
|
||||
for (String playerName : SubArgsModule.getPlayerNames()) {
|
||||
if(i >= originCommandSplit.length) continue;
|
||||
if(!playerName.equalsIgnoreCase(originCommandSplit[i])) continue;
|
||||
|
||||
foundPlayer = true;
|
||||
originCommandSplit[i] = "%online_players%";
|
||||
break;
|
||||
}
|
||||
|
||||
if(!foundPlayer) {
|
||||
|
||||
copiedOriginCommandSplit = originCommandSplit.clone();
|
||||
copiedOriginCommandSplit[copiedOriginCommandSplit.length-1] = null;
|
||||
String c = String.join(" ", copiedOriginCommandSplit);
|
||||
|
||||
if(s.startsWith(c)) return turn;
|
||||
}
|
||||
|
||||
tmpCommand = String.join(" ", originCommandSplit);
|
||||
}
|
||||
|
||||
if (!tmpCommand.toLowerCase().startsWith(StringUtils.replaceFirst(s.toLowerCase(), " _-", "")))
|
||||
continue;
|
||||
|
||||
if (!listed) listed = true;
|
||||
if (s.endsWith(" _-")) ignored = true;
|
||||
|
||||
tooBig = originCommandSplit.length > s.replace(" _-", "").split(" ").length;
|
||||
}
|
||||
|
||||
return !(blocked || !useFilter) && turn != listed || ignored && tooBig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
String cursor = StringUtils.replaceFirst(event.getCursor(), "/", "");
|
||||
if (event.getCompletion().isEmpty()) return;
|
||||
|
||||
UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Argument.getGeneralArgument());
|
||||
List<String> possibilities = event.getCompletion(), result = argument.getResult(cursor);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
possibilities = result;
|
||||
if(result.contains("%online_players%")) {
|
||||
possibilities.remove("%online_players%");
|
||||
possibilities.addAll(SubArgsModule.getPlayerNames());
|
||||
}
|
||||
|
||||
if(result.contains("%hidden_online_players%")) {
|
||||
possibilities.remove("%hidden_online_players%");
|
||||
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
|
||||
if(SubArgsModule.getPlayerNames().contains(completion)) return false;
|
||||
return result.contains(completion);
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
if(possibilities.isEmpty()) possibilities.add("///////////");
|
||||
}
|
||||
|
||||
} else {
|
||||
if(result.contains("%online_players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getPlayerNames().contains(possibility));
|
||||
|
||||
possibilities.removeAll(result);
|
||||
}
|
||||
|
||||
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if(possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) return;
|
||||
|
||||
event.setCompletion(possibilities);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommandSender;
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import java.util.*;
|
||||
|
||||
public class UpdateList {
|
||||
|
||||
public static UpdatePluginEvent UPDATE_PLUGIN_EVENT = new UpdatePluginEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
SubArgsModule.updateMessages();
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static ServerPlayersChangeEvent SERVER_PLAYERS_CHANGE_EVENT = new ServerPlayersChangeEvent() {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
SubArgsModule.updatePlayerNames();
|
||||
}
|
||||
};
|
||||
|
||||
public static ReceiveSyncEvent RECEIVE_SYNC_EVENT = new ReceiveSyncEvent() {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static UpdatePlayerCommandsEvent UPDATE_PLAYER_COMMANDS_EVENT = new UpdatePlayerCommandsEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
final UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
final Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, new Argument());
|
||||
|
||||
argument.clearAllArguments();
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
for (String command : event.getCommands())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for(String command : Argument.getGeneralArgument().getInputs())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getGroupCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getServerCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
} else {
|
||||
List<String> groupCommands = SubArgsModule.getGroupCommands(uuid);
|
||||
for (String command : Argument.getGeneralArgument().getInputs()) {
|
||||
if(groupCommands.contains(command)) continue;
|
||||
argument.buildArgumentStacks(command);
|
||||
}
|
||||
}
|
||||
|
||||
SubArgsModule.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -202,6 +202,10 @@ public class CommandProcess {
|
||||
PermissionUtil.reloadPermissions();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
|
||||
return;
|
||||
|
||||
case "perms":
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.PERMS_CHECK.PLAYER_MISSING);
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
@@ -358,9 +362,11 @@ public class CommandProcess {
|
||||
if(!PermissionUtil.hasPermissionWithResponse(sender, "perms")) return;
|
||||
uuid = !Reflection.isProxyServer() ? BukkitLoader.getUUIDByName(sub) : Reflection.isVelocityServer() ? VelocityLoader.getUUIDByName(sub) : BungeeLoader.getUUIDByName(sub);
|
||||
|
||||
if(uuid != null) {
|
||||
sender.sendMessage("§7Permissions from §f" + sub + "§7: §e" + PermissionUtil.getPermissions(uuid));
|
||||
} else sender.sendMessage("§cThis player isn't online!");
|
||||
sender.sendMessage((uuid != null
|
||||
? Storage.ConfigSections.Messages.PERMS_CHECK.MESSAGE.replace("%permissions%", PermissionUtil.getPermissionsAsString(uuid))
|
||||
: Storage.ConfigSections.Messages.PERMS_CHECK.PLAYER_NOT_ONLINE
|
||||
).replace("%player%", sub)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -110,6 +111,7 @@ public class CommandsCache {
|
||||
else
|
||||
Logger.debug("Created list of commands for player with uuid " + uuidSubstring + " with a total of " + playerCommands.size() + " commands!");
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
|
||||
return playerCommands;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,10 @@ public class PacketUtils {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public ByteBuf getByteBuf() {
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@ package de.rayzs.pat.utils;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.*;
|
||||
|
||||
public class Reflection {
|
||||
|
||||
private static boolean legacy, proxy, velocity, paper, weird;
|
||||
private static String versionName, rawVersionName, versionPackageName;
|
||||
private static boolean legacy, proxy, velocity, paper, folia, weird;
|
||||
private static String versionName, fullVersionName, rawVersionName, versionPackageName;
|
||||
private static Version version;
|
||||
private static int major, minor, release;
|
||||
|
||||
@@ -25,6 +25,15 @@ public class Reflection {
|
||||
proxy = false;
|
||||
} catch (Throwable ignored) { proxy = true; }
|
||||
|
||||
if(!proxy) {
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.proxy.VelocityProxy");
|
||||
folia = versionName.toLowerCase().contains("folia");
|
||||
} catch (Throwable throwable) {
|
||||
folia = false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.Metrics");
|
||||
paper = true;
|
||||
@@ -55,6 +64,10 @@ public class Reflection {
|
||||
public static boolean isLegacy() { return legacy; }
|
||||
public static boolean isWeird() { return weird; }
|
||||
|
||||
public static boolean isFoliaServer() {
|
||||
return folia;
|
||||
}
|
||||
|
||||
public static boolean isProxyServer() {
|
||||
return proxy;
|
||||
}
|
||||
@@ -203,6 +216,22 @@ public class Reflection {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Field> getFieldsByTypeNormal(Class<?> clazz, String target, SearchOption type) {
|
||||
List<Field> result = new ArrayList<>(), fieldLists = getFields(clazz);
|
||||
|
||||
for (Field field : fieldLists) {
|
||||
String typeName = field.getType().getTypeName();
|
||||
if(type == SearchOption.CONTAINS && typeName.contains(target)
|
||||
|| type == SearchOption.STARTS && typeName.startsWith(target)
|
||||
|| type == SearchOption.ENDS && typeName.endsWith(target)
|
||||
|| type == SearchOption.EQUALS && typeName.equals(target)) {
|
||||
openAccess(field, true);
|
||||
result.add(field);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Field getFirstFieldByType(Class<?> clazz, String target, SearchOption type) {
|
||||
return getFieldsByType(clazz, target, type).get(0);
|
||||
}
|
||||
@@ -245,7 +274,8 @@ public class Reflection {
|
||||
|
||||
public static Channel getPlayerChannel(Player player) throws Exception {
|
||||
Object channelObject;
|
||||
if(paper && Reflection.isWeird()) {
|
||||
|
||||
if(!folia && paper && Reflection.isWeird()) {
|
||||
Object serverPlayerObj = getMethodsByReturnTypeAndName(player.getClass(), "ServerPlayer", SearchOption.ENDS, "getHandle").get(0).invoke(player),
|
||||
serverGamePacketListenerImplObj = getFieldByName(serverPlayerObj.getClass(), "connection").get(serverPlayerObj),
|
||||
connectionObj = getFieldByName(serverGamePacketListenerImplObj.getClass().getSuperclass(), "connection").get(serverGamePacketListenerImplObj);
|
||||
@@ -310,9 +340,11 @@ public class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void loadVersionName(Object serverObject) throws Exception {
|
||||
versionName = proxy ? ProxyServer.getInstance().getName() : Bukkit.getName();
|
||||
rawVersionName = (String) serverObject.getClass().getMethod("getBukkitVersion").invoke(serverObject);
|
||||
fullVersionName = rawVersionName;
|
||||
rawVersionName = rawVersionName.split("-")[0].replace(".", "_");
|
||||
versionPackageName = serverObject.getClass().getPackage().getName();
|
||||
versionPackageName = versionPackageName.substring(versionPackageName.lastIndexOf('.') + 1);
|
||||
|
||||
@@ -7,7 +7,7 @@ public class StringUtils {
|
||||
|
||||
public static String replaceFirst(String input, String trigger, String replacement) {
|
||||
if (input.contains(trigger)) {
|
||||
String[] split = input.split(trigger);
|
||||
String[] split = input.split(trigger.equals("*") ? "\\*" : trigger);
|
||||
if (split.length >= 1) {
|
||||
int pointAfter = split[0].length() + trigger.length();
|
||||
input = split[0] + replacement + input.substring(pointAfter);
|
||||
@@ -17,6 +17,15 @@ public class StringUtils {
|
||||
return input;
|
||||
}
|
||||
|
||||
public static int countMatches(Character character, String string) {
|
||||
int count = 0;
|
||||
for (char c : string.toCharArray()) {
|
||||
if(character == c) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String replaceTriggers(String input, String replacement, String... triggers) {
|
||||
for (String trigger : triggers) {
|
||||
if(!input.contains(trigger)) continue;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
|
||||
public class VersionComparer {
|
||||
|
||||
private static Version CURRENT_VERSION, NEWEST_VERSION;
|
||||
|
||||
public static void setCurrentVersion(String versionName) {
|
||||
if(CURRENT_VERSION != null && CURRENT_VERSION.getVersionName().equals(versionName)) return;
|
||||
CURRENT_VERSION = new Version(versionName);
|
||||
}
|
||||
|
||||
public static void setNewestVersion(String versionName) {
|
||||
if(NEWEST_VERSION != null && NEWEST_VERSION.getVersionName().equals(versionName)) return;
|
||||
NEWEST_VERSION = new Version(versionName);
|
||||
}
|
||||
|
||||
public static Version getCurrentVersion() {
|
||||
return CURRENT_VERSION;
|
||||
}
|
||||
|
||||
public static Version getNewestVersion() {
|
||||
return NEWEST_VERSION;
|
||||
}
|
||||
|
||||
public static boolean isNewest() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return true;
|
||||
|
||||
return CURRENT_VERSION.isSame(NEWEST_VERSION);
|
||||
}
|
||||
|
||||
public static boolean isUnreleased() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return true;
|
||||
|
||||
return CURRENT_VERSION.isNewer(NEWEST_VERSION);
|
||||
}
|
||||
|
||||
public static boolean isOutdated() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return false;
|
||||
return CURRENT_VERSION.isOlder(NEWEST_VERSION);
|
||||
}
|
||||
|
||||
public static boolean isDeveloperVersion() {
|
||||
return CURRENT_VERSION.getState() == State.DEV;
|
||||
}
|
||||
|
||||
public static class Version {
|
||||
private final String versionName;
|
||||
private int release = -1, major = -1, patch = -1;
|
||||
private State state = State.RELEASE;
|
||||
|
||||
public Version(String version) {
|
||||
this.versionName = version;
|
||||
|
||||
try {
|
||||
String[] versionSplit = version.split("\\.");
|
||||
release = Integer.parseInt(versionSplit[0]);
|
||||
major = Integer.parseInt(versionSplit[1]);
|
||||
|
||||
String patchAsString = versionSplit[2];
|
||||
patchAsString = patchAsString.contains("-") ? patchAsString.split("-")[0] : patchAsString;
|
||||
|
||||
patch = Integer.parseInt(patchAsString);
|
||||
|
||||
if(!version.contains("-")) return;
|
||||
String stateName = version.split("-")[1].toUpperCase();
|
||||
state = State.valueOf(stateName);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
Logger.warning("Failed to read version name! [" + version + "]");
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getVersionName() {
|
||||
return versionName;
|
||||
}
|
||||
|
||||
public boolean isSame(Version version) {
|
||||
return version.getVersionName().equals(versionName);
|
||||
}
|
||||
|
||||
public boolean isNewer(Version comparedVersion) {
|
||||
return !isSame(comparedVersion) && !isOlder(comparedVersion);
|
||||
}
|
||||
|
||||
public boolean isOlder(Version comparedVersion) {
|
||||
if(release > comparedVersion.getRelease()) return false;
|
||||
if(major > comparedVersion.getMajor()) return false;
|
||||
|
||||
return patch < comparedVersion.getPatch();
|
||||
}
|
||||
|
||||
public int getRelease() {
|
||||
return release;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getPatch() {
|
||||
return patch;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public boolean isInvalid() {
|
||||
return release == -1 || major == -1 || patch == -1;
|
||||
}
|
||||
}
|
||||
|
||||
public enum State {
|
||||
RELEASE, DEV, ALPHA, BETA
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,8 @@ public class MessageTranslator {
|
||||
}
|
||||
|
||||
public static void send(Object target, String text, String... replacements) {
|
||||
if(text.isEmpty()) return;
|
||||
|
||||
text = replaceMessageString(target, text, replacements);
|
||||
|
||||
if(text.contains("%no-message%")) return;
|
||||
|
||||
@@ -25,10 +25,16 @@ public class PermissionUtil {
|
||||
setPlayerPermissions(uuid);
|
||||
}
|
||||
|
||||
public static String getPermissions(UUID uuid) {
|
||||
public static String getPermissionsAsString(UUID uuid) {
|
||||
PermissionMap permissionMap = MAP.get(uuid);
|
||||
if(permissionMap == null) return "";
|
||||
return Arrays.toString(permissionMap.getHashedPermissions().toArray());
|
||||
return Arrays.toString(permissionMap.getHashedPermissions().toArray()).replace("[", "").replace("]", "");
|
||||
}
|
||||
|
||||
public static Set<String> getPermissions(UUID uuid) {
|
||||
PermissionMap permissionMap = MAP.get(uuid);
|
||||
if(permissionMap == null) return null;
|
||||
return permissionMap.getHashedPermissions();
|
||||
}
|
||||
|
||||
public static void setPlayerPermissions(UUID uuid) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package de.rayzs.pat.utils.scheduler;
|
||||
|
||||
import de.rayzs.pat.utils.scheduler.impl.*;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class PATScheduler {
|
||||
|
||||
public static PATSchedulerTask createScheduler(Runnable runnable, long time, long period) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(false, runnable, time, period)
|
||||
: new BukkitScheduler().getInstance(false, runnable, time, period);
|
||||
}
|
||||
|
||||
public static PATSchedulerTask createScheduler(Runnable runnable, long time) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(false, runnable, time)
|
||||
: new BukkitScheduler().getInstance(false, runnable, time);
|
||||
}
|
||||
|
||||
public static PATSchedulerTask createScheduler(Runnable runnable) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(false, runnable)
|
||||
: new BukkitScheduler().getInstance(false, runnable);
|
||||
}
|
||||
|
||||
public static PATSchedulerTask createAsyncScheduler(Runnable runnable, long time, long period) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(true, runnable, time, period)
|
||||
: new BukkitScheduler().getInstance(true, runnable, time, period);
|
||||
}
|
||||
|
||||
public static PATSchedulerTask createAsyncScheduler(Runnable runnable, long time) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(true, runnable, time)
|
||||
: new BukkitScheduler().getInstance(true, runnable, time);
|
||||
}
|
||||
|
||||
public static PATSchedulerTask createAsyncScheduler(Runnable runnable) {
|
||||
return Reflection.isFoliaServer()
|
||||
? new FoliaScheduler().getInstance(true, runnable)
|
||||
: new BukkitScheduler().getInstance(true, runnable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package de.rayzs.pat.utils.scheduler;
|
||||
|
||||
public interface PATSchedulerTask {
|
||||
|
||||
PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period);
|
||||
PATSchedulerTask getInstance(boolean async, Runnable runnable, long time);
|
||||
PATSchedulerTask getInstance(boolean async, Runnable runnable);
|
||||
|
||||
boolean isActive();
|
||||
void setTaskId(int taskId);
|
||||
|
||||
void cancelTask();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.rayzs.pat.utils.scheduler.impl;
|
||||
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitScheduler implements PATSchedulerTask {
|
||||
|
||||
private int taskId = -1;
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period) {
|
||||
this.taskId = async
|
||||
? Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), runnable, time, period)
|
||||
: Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitLoader.getPlugin(), runnable, time, period);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time) {
|
||||
this.taskId = async
|
||||
? Bukkit.getScheduler().scheduleAsyncDelayedTask(BukkitLoader.getPlugin(), runnable, time)
|
||||
: Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), runnable, time);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
|
||||
this.taskId = async
|
||||
? Bukkit.getScheduler().scheduleAsyncDelayedTask(BukkitLoader.getPlugin(), runnable)
|
||||
: Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), runnable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return this.taskId != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskId(int taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask() {
|
||||
Bukkit.getScheduler().cancelTask(taskId);
|
||||
this.taskId = -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.rayzs.pat.utils.scheduler.impl;
|
||||
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.papermc.paper.threadedregions.scheduler.*;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class FoliaScheduler implements PATSchedulerTask {
|
||||
|
||||
private static final GlobalRegionScheduler SCHEDULER = Bukkit.getGlobalRegionScheduler();
|
||||
|
||||
private ScheduledTask task;
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period) {
|
||||
this.task = SCHEDULER.runAtFixedRate(BukkitLoader.getPlugin(), __ -> runnable.run(), time, period);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time) {
|
||||
this.task = SCHEDULER.runDelayed(BukkitLoader.getPlugin(), __ -> runnable.run(), time);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
|
||||
this.task = SCHEDULER.run(BukkitLoader.getPlugin(), __ -> runnable.run());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return !this.task.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskId(int taskId) {
|
||||
if(taskId == -1 || taskId == -5) {
|
||||
cancelTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask() {
|
||||
this.task.cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
public class Argument {
|
||||
|
||||
private static final Argument GENERAL = new Argument();
|
||||
|
||||
|
||||
private final List<String> INPUTS = new ArrayList<>();
|
||||
private final HashMap<String, ArgumentStack> ARGUMENT_STACKS = new HashMap<>();
|
||||
|
||||
public static Argument getGeneralArgument() {
|
||||
Argument copiedGeneralArguments = new Argument();
|
||||
GENERAL.getInputs().forEach(copiedGeneralArguments::buildArgumentStacks);
|
||||
return copiedGeneralArguments;
|
||||
}
|
||||
|
||||
public static List<String> getOptions(String input) {
|
||||
return GENERAL.getResult(input);
|
||||
}
|
||||
|
||||
public static void clearArguments() {
|
||||
GENERAL.clearAllArguments();
|
||||
}
|
||||
|
||||
public static void buildArguments(String input) {
|
||||
GENERAL.buildArgumentStacks(input);
|
||||
}
|
||||
|
||||
public static List<String> getAllInputs() {
|
||||
return GENERAL.getInputs();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getInputs() {
|
||||
return INPUTS;
|
||||
}
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
|
||||
if(!entry.getKey().startsWith(firstInputArg)) continue;
|
||||
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void clearAllArguments() {
|
||||
INPUTS.clear();
|
||||
ARGUMENT_STACKS.clear();
|
||||
}
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
if(!input.contains(" ")) return;
|
||||
|
||||
if(!INPUTS.contains(input))
|
||||
INPUTS.add(input);
|
||||
|
||||
boolean first = true;
|
||||
ArgumentStack argumentStack = null;
|
||||
|
||||
for (String s : input.split(" ")) {
|
||||
if(!first) {
|
||||
argumentStack = argumentStack.createAndGetArgumentStack(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
argumentStack = ARGUMENT_STACKS.get(s);
|
||||
if (argumentStack == null) {
|
||||
argumentStack = new ArgumentStack();
|
||||
ARGUMENT_STACKS.put(s, argumentStack);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ArgumentStack {
|
||||
|
||||
private final HashMap<String, ArgumentStack> argumentStacks = new HashMap<>();
|
||||
private final List<String> suggestions = new ArrayList<>();
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String current;
|
||||
while(input.contains(" ")) {
|
||||
current = input.split(" ")[0];
|
||||
input = StringUtils.replaceFirst(input, current, "");
|
||||
input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : argumentStacks.entrySet()) {
|
||||
if(!entry.getKey().startsWith(current)) continue;
|
||||
return entry.getValue().getResult(input);
|
||||
}
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public ArgumentStack createAndGetArgumentStack(String origin) {
|
||||
|
||||
if(!suggestions.contains(origin))
|
||||
suggestions.add(origin);
|
||||
|
||||
if(!argumentStacks.containsKey(origin)) {
|
||||
ArgumentStack argumentStack = new ArgumentStack();
|
||||
argumentStacks.put(origin, argumentStack);
|
||||
return argumentStack;
|
||||
}
|
||||
|
||||
return argumentStacks.get(origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
public class Responses {
|
||||
|
||||
private static List<Response> RESPONSES = new ArrayList<>();
|
||||
|
||||
public static void update() {
|
||||
RESPONSES = new ArrayList<>();
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.getKeys(true).stream().filter(key -> !key.equals("default-message")).forEach(key -> {
|
||||
if(!key.contains(".")) {
|
||||
Response response = new Response(key);
|
||||
RESPONSES.add(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<String> getResponse(String input) {
|
||||
return getResponse(input, Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
|
||||
public static List<String> getResponse(String input, List<String> defaultMessage) {
|
||||
final String finalInput = input.startsWith("/") ? StringUtils.replaceFirst(input, "/", "") : input;
|
||||
|
||||
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
|
||||
for (String trigger : response.triggers)
|
||||
if(trigger.endsWith("*") ? finalInput.startsWith(StringUtils.replace(trigger, "*", "")) : finalInput.equals(trigger))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
return optionalResponse.isPresent() ? optionalResponse.get().message : defaultMessage;
|
||||
}
|
||||
|
||||
private static class Response {
|
||||
|
||||
private final List<String> triggers, message;
|
||||
|
||||
public Response(final String key) {
|
||||
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
|
||||
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
name: ProAntiTab
|
||||
description: Hide more then just plugins. Hide almost everything!
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.0
|
||||
version: 1.9.0
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends:
|
||||
|
||||
@@ -83,8 +83,10 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
@@ -118,6 +120,14 @@ custom-version:
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
# it would be a waste not to provide some simple patches like these. ^^
|
||||
patch-exploits:
|
||||
enabled: true
|
||||
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
|
||||
kick-message: '&cFailed to read packet! Please reconnect.'
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# This feature allows you to customize your server brand you see when you press F3.
|
||||
# Normally there is something like 'Purpur', or 'Spigot'.
|
||||
@@ -191,6 +201,11 @@ reload:
|
||||
loading: '&eReloading all configuration files...'
|
||||
done: '&aSuccessfully reloaded all configuration files!'
|
||||
|
||||
perms-check:
|
||||
message: "&7All of &e%player%'s &7PAT-related permission: &e%permissions%"
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fBUKKIT&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -199,6 +214,7 @@ help:
|
||||
- '&f info &7to get a few information'
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
# example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
# example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -66,8 +66,10 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
custom-plugins:
|
||||
@@ -98,6 +100,14 @@ custom-version:
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
# it would be a waste not to provide some simple patches like these. ^^
|
||||
patch-exploits:
|
||||
enabled: true
|
||||
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
|
||||
kick-message: '&cFailed to read packet! Please reconnect.'
|
||||
|
||||
# This feature allows you to customize your server brand you see when you press F3.
|
||||
# Normally there is something like 'Purpur', or 'Spigot'.
|
||||
# With this feature, you are able to change and even animate it.
|
||||
@@ -175,6 +185,11 @@ reload:
|
||||
loading: '&eReloading all configuration files...'
|
||||
done: '&aSuccessfully reloaded all configuration files!'
|
||||
|
||||
perms-check:
|
||||
message: "&7All of &e%player%'s &7PAT-related permission: &e%permissions%"
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fPROXY&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -183,6 +198,7 @@ help:
|
||||
- '&f info &7to get a few information'
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
# example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
# example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
name: ProAntiTab
|
||||
description: Hide more then just plugins. Hide almost everything!
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.0
|
||||
version: 1.9.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
softdepend:
|
||||
|
||||
Reference in new issue
Block a user