Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.8.2</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();
|
||||
}
|
||||
@@ -115,6 +115,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.call(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 call(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 call(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 call(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,58 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent call() {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePluginEvent) {
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
updatePluginEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent call(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 call(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 call(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 +110,44 @@ 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 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 +155,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 +164,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,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") && 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,13 +1,22 @@
|
||||
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.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@@ -21,6 +30,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 +43,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(" ");
|
||||
@@ -46,7 +63,63 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
}
|
||||
|
||||
if(packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket")) {
|
||||
if(is121Packet) {
|
||||
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.ClientboundCommandSuggestionsPacket");
|
||||
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) return false;
|
||||
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
suggestions.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spaces == 0) {
|
||||
for (Object suggestion : suggestions) {
|
||||
System.out.println(suggestion);
|
||||
}
|
||||
|
||||
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.call(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 +135,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 +147,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.call(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);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
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.util.concurrent.ConcurrentHashMap;
|
||||
@@ -9,7 +13,10 @@ 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 de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import io.netty.channel.*;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
@@ -112,8 +119,14 @@ public class VelocityPacketAnalyzer {
|
||||
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 +140,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;
|
||||
|
||||
@@ -170,22 +191,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.call();
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
@@ -105,6 +108,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 +131,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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,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,7 +34,7 @@ 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() {
|
||||
@@ -52,6 +54,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.CURRENT_VERSION = getDescription().getVersion();
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
|
||||
@@ -128,15 +131,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 +171,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);
|
||||
@@ -195,13 +210,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.call(packetBundle);
|
||||
}
|
||||
|
||||
public static boolean doesCommandExist(String command, boolean replace) {
|
||||
|
||||
@@ -45,6 +45,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);
|
||||
|
||||
@@ -114,21 +115,40 @@ 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);
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
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 +28,9 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "1.8.0",
|
||||
version = "1.8.2",
|
||||
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)
|
||||
@@ -64,6 +65,7 @@ public class VelocityLoader {
|
||||
|
||||
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();
|
||||
@@ -124,20 +126,40 @@ 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();
|
||||
|
||||
@@ -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.call(player, playerCommands);
|
||||
if(filteredSuggestionEvent.isCancelled()) return;
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
|
||||
+18
-14
@@ -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.call(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.call(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);
|
||||
@@ -80,29 +80,31 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if(Storage.Blacklist.isListed(command, true)) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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.call(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.call(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.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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);
|
||||
|
||||
@@ -51,5 +51,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.call(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
}
|
||||
+19
-18
@@ -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.call(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.call(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);
|
||||
@@ -78,7 +78,8 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
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.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,23 +88,24 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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.call(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.call(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.call(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.call(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);
|
||||
|
||||
+10
@@ -18,6 +18,15 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
|
||||
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
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,7 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
|
||||
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.call(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
@@ -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.call(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,7 +48,15 @@ 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()));
|
||||
}
|
||||
|
||||
|
||||
+24
-16
@@ -41,10 +41,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.call(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 +54,10 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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);
|
||||
@@ -73,7 +73,8 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
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.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,23 +83,24 @@ public class VelocityBlockCommandListener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
PATEventHandler.call(player.getUniqueId(), rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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.call(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 +109,35 @@ 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.call(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.call(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.call(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player.getUniqueId(), rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,15 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
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")) {
|
||||
|
||||
@@ -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.call(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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.*;
|
||||
|
||||
public class Reflection {
|
||||
|
||||
private static boolean legacy, proxy, velocity, paper, weird;
|
||||
private static boolean legacy, proxy, velocity, paper, folia, weird;
|
||||
private static String versionName, 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("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler");
|
||||
folia = true;
|
||||
} 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);
|
||||
}
|
||||
|
||||
@@ -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 true;
|
||||
if(major < comparedVersion.getMajor()) return true;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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.8.2
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends:
|
||||
|
||||
@@ -118,6 +118,14 @@ custom-version:
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interact with Tab-Completion and their packets directly,
|
||||
# it would be a shame to not use it then to also block some exploits, while being at it. ^^
|
||||
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 +199,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 +212,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'
|
||||
|
||||
@@ -98,6 +98,14 @@ custom-version:
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interact with Tab-Completion and their packets directly,
|
||||
# it would be a shame to not use it then to also block some exploits, while being at it. ^^
|
||||
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 +183,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 +196,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'
|
||||
|
||||
@@ -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.8.2
|
||||
api-version: 1.13
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
|
||||
Reference in new issue
Block a user