mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-13 20:42:09 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a453d7999e | ||
|
|
07aad19fec | ||
|
|
1c4213da64 | ||
|
|
5d27e7ee9a | ||
|
|
3805d433f9 | ||
|
|
4d66b8e540 | ||
|
|
9aae436e13 | ||
|
|
406cec7683 | ||
|
|
9360f5d6e4 | ||
|
|
8446537b3b | ||
|
|
d5ed2242c0 | ||
|
|
88dc1887f5 | ||
|
|
9177b3005b | ||
|
|
6940bfb291 | ||
|
|
11f8900140 | ||
|
|
8fd9eb0d2e | ||
|
|
c2a4507697 | ||
|
|
a934eb24f7 | ||
|
|
6d0535819b | ||
|
|
6e5f7cc980 | ||
|
|
f6e77c04fa | ||
|
|
f9a133a1ed | ||
|
|
faa67160d0 | ||
|
|
79e17de03b | ||
|
|
7c67f8d9e4 | ||
|
|
62639961d2 | ||
|
|
8fe56347fc | ||
|
|
38b622b9dc | ||
|
|
dadd9724eb | ||
|
|
ad8406f4a2 | ||
|
|
2f0ee0c278 | ||
|
|
6c48c979d7 | ||
|
|
74dab5fb09 | ||
|
|
b8faadc9ba | ||
|
|
b8964bc843 | ||
|
|
1b8e69da9d | ||
|
|
1a5de85eb9 | ||
|
|
918c901850 | ||
|
|
7104b885d5 | ||
|
|
73d8d70661 | ||
|
|
53ce663032 | ||
|
|
b3d842cac2 | ||
|
|
75089456b2 | ||
|
|
4744ae0037 | ||
|
|
af1e285f8c | ||
|
|
a75a71b6e7 | ||
|
|
7128f7cd74 | ||
|
|
f5191580cf | ||
|
|
fdef5b45b0 | ||
|
|
82a2fb1513 | ||
|
|
7b627dd1b1 | ||
|
|
d247850218 | ||
|
|
c9d91d1d16 | ||
|
|
4173e11105 | ||
|
|
42d5b0b201 | ||
|
|
1baa12e007 | ||
|
|
3e99cb44b2 | ||
|
|
2ecafd5c6c | ||
|
|
ef8b8d619a | ||
|
|
0f88b3f799 | ||
|
|
39301e8622 | ||
|
|
cf77cae518 | ||
|
|
f37bdf4c07 | ||
|
|
f7d44f4085 | ||
|
|
285c8125bd | ||
|
|
7c38083e64 | ||
|
|
b8dde730f5 | ||
|
|
cce9722a66 | ||
|
|
e63836bd11 | ||
|
|
1afd93d296 | ||
|
|
cb44ae50ff | ||
|
|
6ce5c8caaf | ||
|
|
d5b53aecfa | ||
|
|
cc1bb4ec34 | ||
|
|
be9027fa82 | ||
|
|
247b3a1ffd | ||
|
|
356454c66d | ||
|
|
c11cb20917 | ||
|
|
84a7fbafae | ||
|
|
f5acc445e7 | ||
|
|
38142da87e | ||
|
|
4ea2f5cb33 | ||
|
|
8001e5aa8d | ||
|
|
5b4c45dbcc | ||
|
|
fa62e0fae6 | ||
|
|
06e0030f63 | ||
|
|
8441481d10 | ||
|
|
6782635202 | ||
|
|
d061b8967b | ||
|
|
4881fa3c66 | ||
|
|
8e8643bf06 | ||
|
|
18ee04a979 | ||
|
|
0394aaedf4 | ||
|
|
3c62d3c1b9 | ||
|
|
94eff2bf6d | ||
|
|
1f7e6cd77a | ||
|
|
34cba027f9 | ||
|
|
db42fc1295 | ||
|
|
5270a432e9 | ||
|
|
ab052d62b5 | ||
|
|
a878944b33 | ||
|
|
cb349e8abb | ||
|
|
95963b59b8 | ||
|
|
ce1a326f5b | ||
|
|
aef3c3edfc | ||
|
|
4332f677f9 | ||
|
|
298e98b06d | ||
|
|
c419444481 | ||
|
|
3206a616b9 | ||
|
|
3fd9328842 | ||
|
|
e39939598b | ||
|
|
cc02837035 | ||
|
|
0c8b50b32f | ||
|
|
b5833c05b2 | ||
|
|
810ed9982c | ||
|
|
cc470740af | ||
|
|
ed8d5e0cf3 | ||
|
|
161eafeea7 | ||
|
|
b4c54101c9 | ||
|
|
729b1ccf8d | ||
|
|
3f14a091ec | ||
|
|
8282a0147b | ||
|
|
b4628443d4 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>1.8.2</version>
|
||||
<version>1.9.2</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -72,10 +72,23 @@
|
||||
<url>https://repo.william278.net/papiproxybridge</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>skript-releases</id>
|
||||
<name>Skript Repository</name>
|
||||
<url>https://repo.skriptlang.org/releases</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.skriptlang</groupId>
|
||||
<artifactId>Skript</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.folia</groupId>
|
||||
<artifactId>folia-api</artifactId>
|
||||
@@ -220,28 +233,28 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.15.0</version>
|
||||
<version>4.18.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.17.0</version>
|
||||
<version>4.18.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-api</artifactId>
|
||||
<version>4.3.2</version>
|
||||
<version>4.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||
<version>4.3.2</version>
|
||||
<version>4.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.netty.channel.Channel;
|
||||
import de.rayzs.pat.api.brand.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,7 +21,7 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
private static final List<Player> MODIFIED_BRAND_PLAYERS = new ArrayList<>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static int TASK = -1;
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
|
||||
|
||||
@@ -48,9 +50,9 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(TASK != -1) {
|
||||
Bukkit.getScheduler().cancelTask(TASK);
|
||||
TASK = -1;
|
||||
if(TASK != null && TASK.isActive()) {
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
MODIFIED_BRAND_PLAYERS.clear();
|
||||
}
|
||||
|
||||
@@ -58,12 +60,14 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
}, 1, 1);
|
||||
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
TASK = PATScheduler.createAsyncScheduler(() -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
|
||||
|
||||
@@ -101,6 +101,8 @@ public class Communicator {
|
||||
}
|
||||
|
||||
public static void syncData(String serverId) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
|
||||
|
||||
LAST_DATA_UPDATE = System.currentTimeMillis();
|
||||
ClientInfo clientInfo;
|
||||
if(serverId == null) {
|
||||
@@ -151,7 +153,7 @@ public class Communicator {
|
||||
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
|
||||
|
||||
PATEventHandler.call(bundle, serverName);
|
||||
PATEventHandler.callSentSyncEvents(bundle, serverName);
|
||||
}
|
||||
|
||||
public static void sendRequest() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -29,7 +30,7 @@ public class BukkitClient implements Client, PluginMessageListener {
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
|
||||
if(!CommunicationPackets.isPacket(packetObj)) return;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> Communicator.receiveInformation("proxy", packetObj));
|
||||
PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent call(Object senderObj, String command, boolean blocked) {
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -22,7 +22,7 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent call(Object senderObj, List<String> suggestions) {
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -35,7 +35,7 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent call(Object senderObj, String cursor, List<String> completion) {
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -48,7 +48,20 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent call() {
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ServerPlayersChangeEvent) {
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent callUpdatePluginEvents() {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -61,7 +74,7 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent call(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands, serverBased);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -74,7 +87,7 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static SentSyncEvent call(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -87,7 +100,7 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent call(CommunicationPackets.PacketBundle packetBundle) {
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
@@ -110,6 +123,15 @@ public class PATEventHandler {
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
return new SentSyncEvent(null, packetBundle, serverName) {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
|
||||
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
super(senderObj);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ServerPlayersChangeEvent() {
|
||||
super(null);
|
||||
this.type = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
public enum Type { JOINED, LEFT, UNKNOWN }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
this.blocked = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.blocked = cancel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends Event {
|
||||
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
public List<String> getSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends Event {
|
||||
|
||||
private String cursor;
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
return completion;
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
if(packetName.equals("ClientboundCommandSuggestionsPacket") && SENT_PACKET.contains(player.getUniqueId())) {
|
||||
if((packetName.equals("ClientboundCommandSuggestionsPacket") || Reflection.isFoliaServer()) && SENT_PACKET.contains(player.getUniqueId())) {
|
||||
Object newPacketObj = SENT_PACKET.get(uuid);
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, newPacketObj, promise);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -8,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@@ -42,7 +45,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
|
||||
} else return true;
|
||||
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
@@ -69,7 +72,13 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
newResultList.add(s);
|
||||
}
|
||||
} else {
|
||||
if(!cancelsBeforeHand) newResultList.addAll(Arrays.asList(tR));
|
||||
if(!cancelsBeforeHand) {
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), input, Arrays.asList(tR));
|
||||
if(!filteredTabCompletionEvent.isCancelled()) {
|
||||
List<String> suggestions = Arrays.stream(tR).filter(s -> filteredTabCompletionEvent.getCompletion().contains(s)).collect(Collectors.toList());
|
||||
newResultList.addAll(suggestions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
field.set(packetObj, newResultList.toArray(new String[0]));
|
||||
|
||||
@@ -15,7 +15,6 @@ 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 {
|
||||
@@ -60,10 +59,10 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
|
||||
}
|
||||
|
||||
if(is121Packet) {
|
||||
if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
try {
|
||||
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
@@ -74,8 +73,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
start = (int) intFields.get(1).get(packetObj),
|
||||
length = (int) intFields.get(2).get(packetObj);
|
||||
|
||||
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game.ClientboundCommandSuggestionsPacket");
|
||||
|
||||
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game." + (packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete") ? "PacketPlayOutTabComplete" : "ClientboundCommandSuggestionsPacket"));
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) return false;
|
||||
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
|
||||
suggestions.clear();
|
||||
@@ -83,10 +81,6 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
if (spaces == 0) {
|
||||
for (Object suggestion : suggestions) {
|
||||
System.out.println(suggestion);
|
||||
}
|
||||
|
||||
suggestions.removeIf(suggestion -> {
|
||||
String command = getSuggestionFromEntry(suggestion);
|
||||
return Storage.Blacklist.isBlocked(player, command);
|
||||
@@ -98,7 +92,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Object suggestion : suggestions)
|
||||
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.call(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
|
||||
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
@@ -112,11 +106,13 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
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);
|
||||
if(!suggestions.isEmpty()) {
|
||||
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
|
||||
.getConstructor(int.class, int.class, int.class, List.class)
|
||||
.newInstance(id, start, length, suggestions);
|
||||
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
|
||||
}
|
||||
|
||||
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
@@ -152,12 +148,11 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
for (Suggestion suggestion : suggestions.getList())
|
||||
suggestionsAsString.add(suggestion.getText());
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.call(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if(filteredTabCompletionEvent.isCancelled()) suggestions.getList().clear();
|
||||
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(suggestion.getText()));
|
||||
return !suggestions.getList().isEmpty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSuggestionFromEntry(Object suggestionObj) {
|
||||
|
||||
@@ -197,7 +197,8 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
if(!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
final String cursor = playerInput;
|
||||
if(cursor.startsWith("/")) {
|
||||
|
||||
@@ -2,18 +2,24 @@ package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.proxy.crypto.SignedChatCommand;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import io.netty.channel.*;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
@@ -27,7 +33,7 @@ public class VelocityPacketAnalyzer {
|
||||
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
private static HashMap<String, CommandsCache> COMMANDS_CACHE_MAP = new HashMap<>();
|
||||
|
||||
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass;
|
||||
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass, signedChatCommandPacketClass;
|
||||
|
||||
public static void injectAll() {
|
||||
VelocityLoader.getServer().getAllPlayers().forEach(VelocityPacketAnalyzer::inject);
|
||||
@@ -116,6 +122,30 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if(packet.getClass().getSimpleName().equals("SignedChatCommand")) {
|
||||
try {
|
||||
if(signedChatCommandPacketClass == null)
|
||||
signedChatCommandPacketClass = Class.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
|
||||
|
||||
Object signedChatCommandPacket = signedChatCommandPacketClass.cast(packet);
|
||||
Field commandField = signedChatCommandPacket.getClass().getField("command");
|
||||
String command = (String) commandField.get(signedChatCommandPacket);
|
||||
|
||||
if(!VelocityBlockCommandListener.handleCommand(player, command))
|
||||
return;
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(packet instanceof UnsignedPlayerCommandPacket) {
|
||||
|
||||
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
|
||||
if(VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()))
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet instanceof TabCompleteRequestPacket) {
|
||||
TabCompleteRequestPacket request = (TabCompleteRequestPacket) msg;
|
||||
if(request.getCommand() != null) {
|
||||
@@ -153,7 +183,7 @@ public class VelocityPacketAnalyzer {
|
||||
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
String playerInput = getPlayerInput(player), server = player.getCurrentServer().get().getServerInfo().getName();
|
||||
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput, server = player.getCurrentServer().get().getServerInfo().getName();
|
||||
int spaces = 0;
|
||||
|
||||
if(playerInput.contains(" ")) {
|
||||
@@ -164,7 +194,7 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
if(!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
@@ -184,6 +214,14 @@ public class VelocityPacketAnalyzer {
|
||||
});
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawPlayerInput, suggestionsAsString);
|
||||
if(filteredTabCompletionEvent.isCancelled()) return;
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if(response.getOffers().isEmpty()) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Storage {
|
||||
loadToken();
|
||||
if(loadBlacklist) Blacklist.loadAll();
|
||||
|
||||
PATEventHandler.call();
|
||||
PATEventHandler.callUpdatePluginEvents();
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
@@ -94,6 +94,7 @@ public class Storage {
|
||||
CONFIGURATION = Configurator.get("config"),
|
||||
STORAGE = Configurator.get("storage"),
|
||||
PLACEHOLDERS = Configurator.get("placeholders"),
|
||||
CUSTOM_RESPONSES = Configurator.get("custom-responses"),
|
||||
TOKEN = Configurator.get("token");
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -113,6 +114,7 @@ public class Storage {
|
||||
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
|
||||
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
|
||||
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
|
||||
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
|
||||
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
@@ -189,7 +191,7 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
private static HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final GeneralBlacklist BLACKLIST = BlacklistCreator.createGeneralBlacklist();
|
||||
private static final IgnoredServersStorage IGNORED_SERVERS = new GeneralIgnoredServers();
|
||||
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
@@ -251,7 +253,9 @@ public class Storage {
|
||||
|
||||
public static List<GeneralBlacklist> getBlacklists(String server) {
|
||||
final String finalServer = server.toLowerCase();
|
||||
if(CACHED_SERVER_BLACKLIST.contains(finalServer)) return CACHED_SERVER_BLACKLIST.get(finalServer);
|
||||
|
||||
if (CACHED_SERVER_BLACKLIST.contains(finalServer))
|
||||
return CACHED_SERVER_BLACKLIST.get(finalServer);
|
||||
|
||||
List<GeneralBlacklist> blacklists = new ArrayList<>();
|
||||
SERVER_BLACKLISTS.entrySet()
|
||||
@@ -342,13 +346,22 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server) {
|
||||
return isListed(playerObj, command, intensive, listed, slash, server, false);
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server, boolean instantReturn) {
|
||||
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getAllCommands(server), intensive) && group.hasPermission(playerObj)))
|
||||
return false;
|
||||
|
||||
if(!listed) for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(listed) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
listed = blacklist.isListed(command, intensive, true, slash);
|
||||
if(instantReturn) return listed;
|
||||
|
||||
if(listed) break;
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
|
||||
@@ -371,19 +384,21 @@ public class Storage {
|
||||
if(focusOnBlock && blockedGlobal) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(!focusOnBlock) {
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
if (blockedServer) break;
|
||||
} else {
|
||||
if(blacklist.isBlocked(command, intensive)) return true;
|
||||
}
|
||||
if(focusOnBlock && blacklist.isBlocked(command, intensive))
|
||||
return true;
|
||||
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
break;
|
||||
}
|
||||
|
||||
blocked = turn ? blockedGlobal && blockedServer : blockedServer || blockedGlobal;
|
||||
if(!blocked
|
||||
|
||||
// The reason which there's no tab-completion and also why every server-based list needs to exist to avoid this issue.
|
||||
|
||||
if (turn && !blocked
|
||||
&& CACHED_SERVER_BLACKLIST.contains(server)
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).size() == 0)
|
||||
if(turn) blocked = true;
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).isEmpty())
|
||||
blocked = true;
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Collections;
|
||||
public class CancelCommandSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
public MultipleMessagesHelper BASE_COMMAND_RESPONSE, SUB_COMMAND_RESPONSE;
|
||||
|
||||
public CancelCommandSection() {
|
||||
super("cancel-blocked-commands");
|
||||
@@ -17,6 +17,7 @@ public class CancelCommandSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message", Collections.singletonList("&cThis sub-argument is blocked!"));
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.*;
|
||||
|
||||
public class CustomPluginsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
|
||||
public MultipleMessagesHelper MESSAGE, COMMANDS;
|
||||
|
||||
public CustomPluginsSection() {
|
||||
@@ -17,10 +17,18 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins", "bukkit:pl", "bukkit:plugins"));
|
||||
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fPlugins (0):"));
|
||||
}
|
||||
|
||||
public boolean isTabCompletable(String command) {
|
||||
if (!isCommand(command))
|
||||
return false;
|
||||
|
||||
return ALWAYS_TAB_COMPLETABLE;
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
@@ -31,7 +39,7 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
command = command.split(" ")[0];
|
||||
}
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
if (currentCommand.equals(command.toLowerCase()))
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.*;
|
||||
|
||||
public class CustomVersionSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
|
||||
public MultipleMessagesHelper MESSAGE, COMMANDS;
|
||||
|
||||
public CustomVersionSection() {
|
||||
@@ -18,16 +18,24 @@ public class CustomVersionSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "ver", "version", "bukkit:ver", "bukkit:version"));
|
||||
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "about", "ver", "version"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)"));
|
||||
}
|
||||
|
||||
public boolean isTabCompletable(String command) {
|
||||
if (!isCommand(command))
|
||||
return false;
|
||||
|
||||
return ALWAYS_TAB_COMPLETABLE;
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
if (currentCommand.equals(command.toLowerCase()))
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class DisableSyncSection extends ConfigStorage {
|
||||
|
||||
public boolean DISABLED;
|
||||
|
||||
public DisableSyncSection() {
|
||||
super("disable-sync");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.*;
|
||||
|
||||
public class UpdateSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, AUTO_UPDATE_CONFIG;
|
||||
public int PERIOD;
|
||||
public MultipleMessagesHelper OUTDATED, UPDATED;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class UpdateSection extends ConfigStorage {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
PERIOD = new ConfigSectionHelper<Integer>(this, "period", 10000).getOrSet();
|
||||
AUTO_UPDATE_CONFIG = new ConfigSectionHelper<Boolean>(this, "auto-update-config", true).getOrSet();
|
||||
UPDATED = new MultipleMessagesHelper(this, "updated", Collections.singletonList("&aYou are using the newest version! ^^"));
|
||||
OUTDATED = new MultipleMessagesHelper(this, "outdated", Arrays.asList(
|
||||
"&8[&4ProAntiTab&8] &cThere is a new version available! (%newest_version%)",
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedBaseCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedBaseCommandPlaceholder() { super("message_base_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedCommandPlaceholder extends PlaceholderStorage {
|
||||
public class BlockedSubCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedCommandPlaceholder() { super("message_blocked"); }
|
||||
public BlockedSubCommandPlaceholder() { super("message_sub_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE.getLines());
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -17,6 +18,7 @@ import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
@@ -41,6 +43,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,9 +100,11 @@ public class BukkitLoader extends JavaPlugin {
|
||||
ViaVersionAdapter.initialize();
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +198,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
|
||||
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
|
||||
BukkitAntiTabListener.setChangeStatus();
|
||||
if(Reflection.getMinor() >= 13) BukkitAntiTabListener.setChangeStatus();
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
}
|
||||
|
||||
@@ -219,7 +224,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
BukkitAntiTabListener.handleTabCompletion(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? Storage.Blacklist.getBlacklist().getCommands() : getNotBlockedCommands());
|
||||
}
|
||||
|
||||
PATEventHandler.call(packetBundle);
|
||||
PATEventHandler.callReceiveSyncEvents(packetBundle);
|
||||
}
|
||||
|
||||
public static boolean doesCommandExist(String command, boolean replace) {
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.listeners.bungee.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import net.md_5.bungee.api.connection.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -33,6 +37,7 @@ public class BungeeLoader extends Plugin {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +71,9 @@ public class BungeeLoader extends Plugin {
|
||||
manager.registerListener(this, new WaterfallAntiTabListener());
|
||||
|
||||
startUpdaterTask();
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
@@ -83,6 +90,8 @@ public class BungeeLoader extends Plugin {
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,6 +163,19 @@ public class BungeeLoader extends Plugin {
|
||||
}, 20L, Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
ProxiedPlayer proxiedPlayer = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(proxiedPlayer == null) return null;
|
||||
|
||||
Server server = proxiedPlayer.getServer();
|
||||
if(server == null) return null;
|
||||
|
||||
ServerInfo serverInfo = server.getInfo();
|
||||
if(serverInfo == null) return null;
|
||||
|
||||
return serverInfo.getName();
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ 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 com.velocitypowered.api.proxy.ServerConnection;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
@@ -15,20 +16,25 @@ import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.*;
|
||||
import de.rayzs.pat.utils.ConnectionBuilder;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.ConnectionBuilder;
|
||||
import de.rayzs.pat.utils.VersionComparer;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import com.velocitypowered.api.plugin.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.event.*;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "1.8.2",
|
||||
version = "1.9.2",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
dependencies = {
|
||||
@@ -59,6 +65,7 @@ public class VelocityLoader {
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
|
||||
Reflection.initialize(server);
|
||||
ConfigUpdater.initialize();
|
||||
@@ -82,7 +89,9 @@ public class VelocityLoader {
|
||||
server.getEventManager().register(this, new VelocityPingListener(server));
|
||||
|
||||
startUpdaterTask();
|
||||
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
@@ -98,6 +107,8 @@ public class VelocityLoader {
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@@ -165,6 +176,20 @@ public class VelocityLoader {
|
||||
}).delay(1, TimeUnit.SECONDS).repeat(Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
Optional<Player> optPlayer = server.getPlayer(uuid);
|
||||
if(!optPlayer.isPresent()) return null;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
Optional<ServerConnection> optServer = player.getCurrentServer();
|
||||
if(!optServer.isPresent()) return null;
|
||||
|
||||
ServerConnection server = optServer.get();
|
||||
if(server.getServerInfo() == null) return null;
|
||||
|
||||
return server.getServerInfo().getName();
|
||||
}
|
||||
|
||||
public static ProxyServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getCommands().size() == 0) {
|
||||
if(event.getCommands().isEmpty()) {
|
||||
Logger.debug("No available commands to filter! Ignoring rest of the code until at least one command is listed in there.");
|
||||
return;
|
||||
}
|
||||
@@ -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(player, playerCommands);
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
if(filteredSuggestionEvent.isCancelled()) return;
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
|
||||
+10
-11
@@ -43,7 +43,7 @@ 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, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -75,33 +75,32 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || rawCommand.equals("/")) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if(Storage.Blacklist.isListed(command, true)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player, command, false)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
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, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -117,18 +116,18 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if (!Storage.Blacklist.isListed(command, false)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
|
||||
+8
-1
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.brand.impl.BukkitServerBrand;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -18,13 +20,16 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
BackendUpdater.handle();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(!BukkitPacketAnalyzer.inject(player)) player.kickPlayer("Failed to inject player!");
|
||||
|
||||
@@ -40,6 +45,8 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
BukkitPacketAnalyzer.uninject(player.getUniqueId());
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -23,6 +24,9 @@ public class PaperServerListPing implements Listener {
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.HIDE_PLAYERS)
|
||||
event.getPlayerSample().clear();
|
||||
|
||||
if(versionName.contains("%"))
|
||||
PlaceholderReplacer.replace(null, versionName);
|
||||
|
||||
event.setVersion(versionName);
|
||||
}
|
||||
}
|
||||
@@ -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, event.getSuggestions());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -40,7 +40,7 @@ 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, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -73,27 +73,27 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -128,12 +128,12 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(!listed && !serverListed || listed && serverListed && ignored) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
|
||||
+5
-4
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
@@ -18,15 +20,13 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
@@ -50,6 +50,7 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
|
||||
@@ -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, new ArrayList<>(event.getCommands().keySet()));
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
@@ -50,6 +50,6 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
public static void updateCommands() {
|
||||
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
|
||||
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ 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());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,6 @@ public class VelocityAntiTabListener {
|
||||
}
|
||||
|
||||
public static void updateCommands() {
|
||||
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
|
||||
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
}
|
||||
+127
-11
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.velocity;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
@@ -41,7 +42,7 @@ 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, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -54,7 +55,7 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -67,13 +68,13 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
@@ -83,12 +84,12 @@ public class VelocityBlockCommandListener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -97,7 +98,7 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -110,7 +111,7 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
@@ -120,18 +121,18 @@ public class VelocityBlockCommandListener {
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(!listed && !serverListed || listed && serverListed && ignored) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
|
||||
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
if(executeCommandEvent.isCancelled()) return;
|
||||
|
||||
@@ -140,4 +141,119 @@ public class VelocityBlockCommandListener {
|
||||
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> server.getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(server.getPlayer(uuid).get(), notificationMessage));
|
||||
}
|
||||
|
||||
public static boolean handleCommand(Player player, String commandSource) {
|
||||
String command = commandSource,
|
||||
serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
boolean blocked = false;
|
||||
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) return false;
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return false;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if (ignored ? !listed && serverListed : serverListed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, true, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, true, listed, false, serverName);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if (!listed && !serverListed || listed && serverListed && ignored) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
return blocked;
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
@@ -25,15 +27,13 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
}
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
@@ -58,8 +58,9 @@ public class VelocityConnectionListener {
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
VelocityPacketAnalyzer.uninject(player);
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs;
|
||||
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.modules.subargs.events.*;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.plugin.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SubArgsModule {
|
||||
|
||||
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES;
|
||||
public static HashMap<UUID, Argument> PLAYER_COMMANDS = new HashMap<>();
|
||||
|
||||
public static void initialize() {
|
||||
updateList();
|
||||
updateMessages();
|
||||
updatePlayerNames();
|
||||
|
||||
PATEventHandler.register(new TabCompletion());
|
||||
PATEventHandler.register(new ExecuteCommand());
|
||||
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
|
||||
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
|
||||
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
|
||||
}
|
||||
|
||||
public static void updatePlayerNames() {
|
||||
PLAYER_NAMES = Reflection.isProxyServer()
|
||||
? Reflection.isVelocityServer()
|
||||
? VelocityLoader.getPlayerNames()
|
||||
: BungeeLoader.getPlayerNames()
|
||||
: BukkitLoader.getPlayerNames();
|
||||
}
|
||||
|
||||
public static List<String> getPlayerNames() {
|
||||
return PLAYER_NAMES;
|
||||
}
|
||||
|
||||
public static void updateList() {
|
||||
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
|
||||
|
||||
Argument.clearArguments();
|
||||
GENERAL_LIST.forEach(Argument::buildArguments);
|
||||
SubArgsModule.PLAYER_COMMANDS = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void updateMessages() {
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
ResponseHandler.update();
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
if(!Reflection.isProxyServer()) return commands;
|
||||
|
||||
String serverName = Reflection.isVelocityServer() ? VelocityLoader.getServerNameByPlayerUUID(uuid) : BungeeLoader.getServerNameByPlayerUUID(uuid);
|
||||
if(serverName == null) return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
List<Group> groups = new ArrayList<>();
|
||||
|
||||
Group currentGroup;
|
||||
for (String permission : Objects.requireNonNull(PermissionUtil.getPermissions(uuid))) {
|
||||
if(!permission.startsWith("proantitab.group.")) continue;
|
||||
currentGroup = GroupManager.getGroupByName(StringUtils.replaceFirst(permission, "proantitab.group.", ""));
|
||||
if(currentGroup != null && !groups.contains(currentGroup)) groups.add(currentGroup);
|
||||
}
|
||||
|
||||
if(!groups.isEmpty()) {
|
||||
int highestPriority = groups.stream().mapToInt(Group::getPriority).filter(group -> group <= 9999).min().orElse(9999);
|
||||
groups.removeIf(group -> group.getPriority() > highestPriority);
|
||||
for (Group group : groups) commands.addAll(group.getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
|
||||
public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
String command = StringUtils.replaceFirst(event.getCommand(), "/", "");
|
||||
CommandSender sender = new CommandSender(event.getSenderObj());
|
||||
|
||||
/* Removed due to the fact that it is not required after all.
|
||||
if(PermissionUtil.hasBypassPermission(event.getSenderObj(), command.contains(" ") ? command.split(" ")[0] : command))
|
||||
return;
|
||||
*/
|
||||
|
||||
if(command.contains(" ") && shouldCommandBeBlocked(sender, event, command)) {
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), ResponseHandler.getResponse(sender.getUniqueId(), event.getCommand()), "%command%", event.getCommand());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!event.isBlocked()) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), ResponseHandler.getResponse(sender.getUniqueId(), event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()), "%command%", event.getCommand());
|
||||
}
|
||||
|
||||
private boolean shouldCommandBeBlocked(CommandSender sender, ExecuteCommandEvent event, String command) {
|
||||
boolean listed = false,
|
||||
turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED,
|
||||
blocked = event.isBlocked(),
|
||||
ignored = false,
|
||||
useFilter = false,
|
||||
tooBig = false;
|
||||
|
||||
String[] split, originCommandSplit, copiedOriginCommandSplit;
|
||||
String tmpCommand;
|
||||
for (String s : SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Argument.getGeneralArgument()).getInputs()) {
|
||||
if(s.contains("%hidden_online_players%")) continue;
|
||||
tmpCommand = command;
|
||||
|
||||
if(s.split(" ")[0].equalsIgnoreCase(tmpCommand.split(" ")[0]))
|
||||
useFilter = true;
|
||||
|
||||
originCommandSplit = tmpCommand.split(" ");
|
||||
split = s.split(" ");
|
||||
int i;
|
||||
|
||||
for(i = 0; i < split.length; i++) {
|
||||
if(!split[i].equals("%online_players%")) continue;
|
||||
|
||||
boolean foundPlayer = false;
|
||||
for (String playerName : SubArgsModule.getPlayerNames()) {
|
||||
if(i >= originCommandSplit.length) continue;
|
||||
if(!playerName.equalsIgnoreCase(originCommandSplit[i])) continue;
|
||||
|
||||
foundPlayer = true;
|
||||
originCommandSplit[i] = "%online_players%";
|
||||
break;
|
||||
}
|
||||
|
||||
if(!foundPlayer) {
|
||||
|
||||
copiedOriginCommandSplit = originCommandSplit.clone();
|
||||
copiedOriginCommandSplit[copiedOriginCommandSplit.length-1] = null;
|
||||
String c = String.join(" ", copiedOriginCommandSplit);
|
||||
|
||||
if(s.startsWith(c)) return turn;
|
||||
}
|
||||
|
||||
tmpCommand = String.join(" ", originCommandSplit);
|
||||
}
|
||||
|
||||
if (!tmpCommand.toLowerCase().startsWith(StringUtils.replaceFirst(s.toLowerCase(), " _-", "")))
|
||||
continue;
|
||||
|
||||
if (!listed) listed = true;
|
||||
if (s.endsWith(" _-")) ignored = true;
|
||||
|
||||
tooBig = originCommandSplit.length > s.replace(" _-", "").split(" ").length;
|
||||
}
|
||||
|
||||
return !(blocked || !useFilter) && turn != listed || ignored && tooBig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
String cursor = StringUtils.replaceFirst(event.getCursor(), "/", "");
|
||||
if (event.getCompletion().isEmpty()) return;
|
||||
|
||||
UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Argument.getGeneralArgument());
|
||||
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(argument.getResult(cursor));
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
possibilities = result;
|
||||
|
||||
if(result.contains("%online_players%")) {
|
||||
possibilities.remove("%online_players%");
|
||||
possibilities.addAll(SubArgsModule.getPlayerNames());
|
||||
}
|
||||
|
||||
if(result.contains("%hidden_online_players%")) {
|
||||
possibilities.remove("%hidden_online_players%");
|
||||
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
|
||||
if(SubArgsModule.getPlayerNames().contains(completion)) return false;
|
||||
return result.contains(completion);
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
if(possibilities.isEmpty()) possibilities.add("///////////");
|
||||
}
|
||||
|
||||
} else {
|
||||
if(result.contains("%online_players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getPlayerNames().contains(possibility));
|
||||
|
||||
possibilities.removeAll(result);
|
||||
}
|
||||
|
||||
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if(possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) return;
|
||||
|
||||
event.setCompletion(possibilities);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommandSender;
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import java.util.*;
|
||||
|
||||
public class UpdateList {
|
||||
|
||||
public static UpdatePluginEvent UPDATE_PLUGIN_EVENT = new UpdatePluginEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
SubArgsModule.updateMessages();
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static ServerPlayersChangeEvent SERVER_PLAYERS_CHANGE_EVENT = new ServerPlayersChangeEvent() {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
SubArgsModule.updatePlayerNames();
|
||||
}
|
||||
};
|
||||
|
||||
public static ReceiveSyncEvent RECEIVE_SYNC_EVENT = new ReceiveSyncEvent() {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static UpdatePlayerCommandsEvent UPDATE_PLAYER_COMMANDS_EVENT = new UpdatePlayerCommandsEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
final UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
final Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, new Argument());
|
||||
|
||||
argument.clearAllArguments();
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
for (String command : event.getCommands())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for(String command : Argument.getGeneralArgument().getInputs())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getGroupCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getServerCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
} else {
|
||||
List<String> groupCommands = SubArgsModule.getGroupCommands(uuid);
|
||||
for (String command : Argument.getGeneralArgument().getInputs()) {
|
||||
if(groupCommands.contains(command)) continue;
|
||||
argument.buildArgumentStacks(command);
|
||||
}
|
||||
}
|
||||
|
||||
SubArgsModule.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.rayzs.pat.plugin.skript;
|
||||
|
||||
import ch.njol.skript.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.skript.impl.events.ExecuteCommandSkriptEvent;
|
||||
|
||||
public class PATSkriptAddon {
|
||||
|
||||
public static SkriptAddon ADDON;
|
||||
|
||||
public static void initialize(JavaPlugin javaPlugin) {
|
||||
ADDON = Skript.getAddon(javaPlugin);
|
||||
|
||||
Skript.registerEvent("PAT Command Execution", ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class, "if [command] is (blocked|cancelled|not blocked|not cancelled)");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.rayzs.pat.plugin.skript.impl.events;
|
||||
|
||||
import ch.njol.skript.doc.*;
|
||||
import ch.njol.skript.lang.*;
|
||||
import ch.njol.skript.Skript;
|
||||
import org.bukkit.event.Event;
|
||||
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
|
||||
|
||||
@Name("PAT Command Execution")
|
||||
@Description("Fires after a command has been checked by PAT.")
|
||||
public class ExecuteCommandSkriptEvent extends SkriptEvent {
|
||||
|
||||
private boolean triggerOnBlocked;
|
||||
|
||||
static {
|
||||
Skript.registerEvent("PAT Command Execution",
|
||||
ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class,
|
||||
"[if] (blocked|cancelled|not blocked|not cancelled)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Literal<?>[] literals, int matchedPattern, SkriptParser.ParseResult parseResult) {
|
||||
|
||||
// 0 = blocked/cancelled
|
||||
// 1 = not blocked/cancelled
|
||||
triggerOnBlocked = matchedPattern == 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean debug) {
|
||||
return "PAT command execution event " + (triggerOnBlocked ? "(if blocked)" : "(if not blocked)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Event event) {
|
||||
if (event instanceof ExecuteCommandEvent) {
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) event;
|
||||
return executeCommandEvent.isBlocked() == triggerOnBlocked;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,14 @@ import java.util.*;
|
||||
|
||||
public class ArrayUtils {
|
||||
|
||||
public static boolean containsIgnoreCase(List<String> list, String element) {
|
||||
for (String s : list)
|
||||
if(s.equalsIgnoreCase(element))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean compareStringArrays(List<String> listA, List<String> listB) {
|
||||
if(listA == null || listB == null) return false;
|
||||
|
||||
|
||||
@@ -77,7 +77,9 @@ public class CommandsCache {
|
||||
if(filteredCommands == null)
|
||||
return useList ? playerCommands : new LinkedList<>(unfilteredCommands);
|
||||
|
||||
if(useList && !Storage.Blacklist.isOnIgnoredServer(serverName)) playerCommands = new LinkedList<>(filteredCommands);
|
||||
if(useList && !Storage.Blacklist.isOnIgnoredServer(serverName)) {
|
||||
playerCommands = new LinkedList<>(filteredCommands);
|
||||
}
|
||||
|
||||
boolean permitted, bypassNamespace = true, turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
@@ -94,6 +96,16 @@ public class CommandsCache {
|
||||
|
||||
if (playerCommands.contains(command)) continue;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
if (useList)
|
||||
playerCommands.add(command);
|
||||
else
|
||||
playerCommands.remove(command);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
permitted = Reflection.isProxyServer() && serverName != null
|
||||
? !Storage.Blacklist.isBlocked(targetObj, command, !turn, serverName)
|
||||
: !Storage.Blacklist.isBlocked(targetObj, command, !turn, false, false);
|
||||
@@ -111,7 +123,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);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
|
||||
return playerCommands;
|
||||
}
|
||||
|
||||
@@ -130,7 +142,10 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
if(change) return;
|
||||
// Removed to reset the change state. Experimental change though
|
||||
//if(change) return;
|
||||
// Prob. gonna change it to: if (CONNECTED_TO_BUNGEE && change) return;
|
||||
updateChangeState();
|
||||
filteredCommands = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,18 @@ public class ConnectionBuilder {
|
||||
private String url = null, response = null;
|
||||
private List<String> responseList = new ArrayList<>();
|
||||
private Object[] parameters = null;
|
||||
private int timeout = -1;
|
||||
|
||||
public ConnectionBuilder setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConnectionBuilder setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConnectionBuilder setProperties(Object... parameters) {
|
||||
this.parameters = parameters;
|
||||
return this;
|
||||
@@ -24,6 +30,9 @@ public class ConnectionBuilder {
|
||||
String rawUrl = url;
|
||||
URL url = new URL(rawUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
if(timeout != -1) connection.setConnectTimeout(timeout);
|
||||
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
||||
if(parameters != null && parameters.length > 0) {
|
||||
|
||||
@@ -2,15 +2,15 @@ package de.rayzs.pat.utils;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.*;
|
||||
|
||||
public class Reflection {
|
||||
|
||||
private static boolean legacy, proxy, velocity, paper, folia, weird;
|
||||
private static String versionName, rawVersionName, versionPackageName;
|
||||
private static String versionName, fullVersionName, rawVersionName, versionPackageName;
|
||||
private static Version version;
|
||||
private static int major, minor, release;
|
||||
|
||||
@@ -27,8 +27,8 @@ public class Reflection {
|
||||
|
||||
if(!proxy) {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler");
|
||||
folia = true;
|
||||
Class.forName("com.destroystokyo.paper.proxy.VelocityProxy");
|
||||
folia = versionName.toLowerCase().contains("folia");
|
||||
} catch (Throwable throwable) {
|
||||
folia = false;
|
||||
}
|
||||
@@ -56,6 +56,8 @@ public class Reflection {
|
||||
if (proxy) version = Version.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public static String getVersionPackageName() {return versionPackageName;}
|
||||
public static int[] getAges() { return new int[]{major, minor, release}; }
|
||||
public static String getVersionName() { return versionName; }
|
||||
public static String getRawVersionName() { return rawVersionName; }
|
||||
@@ -274,7 +276,8 @@ public class Reflection {
|
||||
|
||||
public static Channel getPlayerChannel(Player player) throws Exception {
|
||||
Object channelObject;
|
||||
if(paper && Reflection.isWeird()) {
|
||||
|
||||
if(folia && minor == 21 && release == 1 || !folia && paper && Reflection.isWeird()) {
|
||||
Object serverPlayerObj = getMethodsByReturnTypeAndName(player.getClass(), "ServerPlayer", SearchOption.ENDS, "getHandle").get(0).invoke(player),
|
||||
serverGamePacketListenerImplObj = getFieldByName(serverPlayerObj.getClass(), "connection").get(serverPlayerObj),
|
||||
connectionObj = getFieldByName(serverGamePacketListenerImplObj.getClass().getSuperclass(), "connection").get(serverGamePacketListenerImplObj);
|
||||
@@ -339,9 +342,11 @@ public class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void loadVersionName(Object serverObject) throws Exception {
|
||||
versionName = proxy ? ProxyServer.getInstance().getName() : Bukkit.getName();
|
||||
rawVersionName = (String) serverObject.getClass().getMethod("getBukkitVersion").invoke(serverObject);
|
||||
fullVersionName = rawVersionName;
|
||||
rawVersionName = rawVersionName.split("-")[0].replace(".", "_");
|
||||
versionPackageName = serverObject.getClass().getPackage().getName();
|
||||
versionPackageName = versionPackageName.substring(versionPackageName.lastIndexOf('.') + 1);
|
||||
@@ -388,7 +393,8 @@ public class Reflection {
|
||||
v_1_18_1, v_1_18_2,
|
||||
v_1_19, v_1_19_1, v_1_19_2, v_1_19_3, v_1_19_4,
|
||||
v_1_20, v_1_20_1, v_1_20_2, v_1_20_3, v_1_20_4, v_1_20_5, v_1_20_6,
|
||||
v_1_21, v_1_21_1, v_1_21_2,
|
||||
v_1_21, v_1_21_1, v_1_21_2, v_1_21_3, v_1_21_4,
|
||||
v_1_22, v_1_22_1, v_1_22_2
|
||||
}
|
||||
|
||||
public enum SearchOption { CONTAINS, EQUALS, ENDS, STARTS }
|
||||
|
||||
@@ -7,7 +7,7 @@ public class StringUtils {
|
||||
|
||||
public static String replaceFirst(String input, String trigger, String replacement) {
|
||||
if (input.contains(trigger)) {
|
||||
String[] split = input.split(trigger);
|
||||
String[] split = input.split(trigger.equals("*") ? "\\*" : trigger);
|
||||
if (split.length >= 1) {
|
||||
int pointAfter = split[0].length() + trigger.length();
|
||||
input = split[0] + replacement + input.substring(pointAfter);
|
||||
@@ -17,6 +17,26 @@ public class StringUtils {
|
||||
return input;
|
||||
}
|
||||
|
||||
public static String replaceLast(String input, String trigger, String replacement) {
|
||||
if (input.contains(trigger)) {
|
||||
String[] split = input.split(trigger.equals("*") ? "\\*" : trigger);
|
||||
if (split.length >= 1) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
String current;
|
||||
int i;
|
||||
for(i = 0; i < split.length; i++) {
|
||||
current = split[i];
|
||||
result.append(current);
|
||||
if(i < split.length -1) result.append(" ");
|
||||
}
|
||||
|
||||
input = result.toString();
|
||||
} else input = input.replace(trigger, replacement);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static int countMatches(Character character, String string) {
|
||||
int count = 0;
|
||||
for (char c : string.toCharArray()) {
|
||||
@@ -26,6 +46,27 @@ public class StringUtils {
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String replaceElementsFromString(String input, List<String> targets, String replacement) {
|
||||
final String[] args = input.split(" ");
|
||||
final StringBuilder result = new StringBuilder();
|
||||
final int max = args.length;
|
||||
|
||||
String part;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
part = args[i];
|
||||
|
||||
if(ArrayUtils.containsIgnoreCase(targets, part))
|
||||
part = replacement;
|
||||
|
||||
result.append(part);
|
||||
if(i < args.length -1) result.append(" ");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String replaceTriggers(String input, String replacement, String... triggers) {
|
||||
for (String trigger : triggers) {
|
||||
if(!input.contains(trigger)) continue;
|
||||
|
||||
@@ -86,8 +86,8 @@ public class VersionComparer {
|
||||
}
|
||||
|
||||
public boolean isOlder(Version comparedVersion) {
|
||||
if(release < comparedVersion.getRelease()) return true;
|
||||
if(major < comparedVersion.getMajor()) return true;
|
||||
if(release > comparedVersion.getRelease()) return false;
|
||||
if(major > comparedVersion.getMajor()) return false;
|
||||
|
||||
return patch < comparedVersion.getPatch();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LuckPermsAdapter {
|
||||
Map<String, Boolean> permissions = getPermissions(uuid);
|
||||
if(permissions == null) return false;
|
||||
|
||||
return permissions.size() > 0;
|
||||
return !permissions.isEmpty();
|
||||
}
|
||||
|
||||
public static void setPermissions(UUID uuid) {
|
||||
@@ -67,9 +67,10 @@ public class LuckPermsAdapter {
|
||||
|
||||
|
||||
permissions.forEach((permission, permitted) -> {
|
||||
if(permission.startsWith("proantitab.") || permission.equals("*")) PermissionUtil.setPermission(uuid, permission, permitted);
|
||||
}
|
||||
);
|
||||
if(permission.startsWith("proantitab.") || permission.equals("*"))
|
||||
PermissionUtil.setPermission(uuid, permission, permitted);
|
||||
|
||||
});
|
||||
|
||||
if(Reflection.isProxyServer()) {
|
||||
if(Reflection.isVelocityServer()) VelocityAntiTabListener.updateCommands();
|
||||
@@ -95,11 +96,14 @@ public class LuckPermsAdapter {
|
||||
|
||||
if (event.isUser() && event.getTarget() instanceof User) {
|
||||
User user = (User) event.getTarget();
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
if(Reflection.isVelocityServer())
|
||||
PermissionUtil.reloadPermissions(user.getUniqueId());
|
||||
}
|
||||
else BukkitAntiTabListener.luckpermsNetworkUserSync(user.getUniqueId());
|
||||
PermissionUtil.reloadPermissions(user.getUniqueId());
|
||||
|
||||
} else BukkitAntiTabListener.luckpermsNetworkUserSync(user.getUniqueId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package de.rayzs.pat.utils.configuration.updater;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
@@ -13,7 +15,18 @@ public class ConfigUpdater {
|
||||
private static boolean LOADED = false;
|
||||
|
||||
public static void initialize() {
|
||||
NEWEST_CONFIG_INPUT = new ConnectionBuilder().setUrl("https://raw.githubusercontent.com/RayzsYT/ProAntiTab/main/src/main/resources/files/"
|
||||
try {
|
||||
boolean autoUpdateConfig = (boolean) Configurator.get("config").getOrSet("updater.auto-update-config", true);
|
||||
|
||||
if (autoUpdateConfig) {
|
||||
LOADED = false;
|
||||
return;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("Failed to find section 'updater.auto-config-updater' in config.yml!");
|
||||
}
|
||||
|
||||
NEWEST_CONFIG_INPUT = new ConnectionBuilder().setTimeout(2000).setUrl("https://raw.githubusercontent.com/RayzsYT/ProAntiTab/main/src/main/resources/files/"
|
||||
+ (Reflection.isProxyServer() ? "proxy" : "bukkit")
|
||||
+ "-config.yml").connect().getResponseList();
|
||||
|
||||
@@ -38,7 +51,7 @@ public class ConfigUpdater {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> fileInput = new LinkedList<>(Arrays.asList("# WARNING: This file is auto generated with to solely purpose to be used as comparison!", " ", " "));
|
||||
List<String> fileInput = new LinkedList<>(Arrays.asList("# WARNING: This file is auto generated and its solely purpose is to be used as comparison!", " ", " "));
|
||||
fileInput.addAll(NEWEST_CONFIG_INPUT);
|
||||
|
||||
try {
|
||||
|
||||
@@ -89,6 +89,8 @@ public class MessageTranslator {
|
||||
}
|
||||
|
||||
public static void send(Object target, String text, String... replacements) {
|
||||
if(text.isEmpty()) return;
|
||||
|
||||
text = replaceMessageString(target, text, replacements);
|
||||
|
||||
if(text.contains("%no-message%")) return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.utils.permission;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionMap {
|
||||
|
||||
@@ -20,7 +21,7 @@ public class PermissionMap {
|
||||
}
|
||||
|
||||
public Set<String> getHashedPermissions() {
|
||||
return permissionMap.keySet();
|
||||
return permissionMap.keySet().stream().filter(permissionMap::get).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
||||
@@ -48,10 +48,12 @@ public class PermissionUtil {
|
||||
|
||||
public static void setPermission(UUID uuid, String permission, boolean permitted) {
|
||||
PermissionMap permissionMap;
|
||||
|
||||
if(!MAP.containsKey(uuid)) {
|
||||
permissionMap = new PermissionMap(uuid);
|
||||
MAP.put(uuid, permissionMap);
|
||||
} else permissionMap = MAP.get(uuid);
|
||||
|
||||
permissionMap.setState(permission, permitted);
|
||||
}
|
||||
|
||||
@@ -62,7 +64,9 @@ public class PermissionUtil {
|
||||
|
||||
if(targetObj instanceof CommandSender) sender = (CommandSender) targetObj;
|
||||
else sender = new CommandSender(targetObj);
|
||||
|
||||
if(sender.isConsole()) return true;
|
||||
|
||||
uuid = sender.getUniqueId();
|
||||
|
||||
if(!MAP.containsKey(uuid)) {
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package de.rayzs.pat.utils.response;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ResponseHandler {
|
||||
|
||||
private static List<Response> RESPONSES = new ArrayList<>();
|
||||
|
||||
public static void update() {
|
||||
RESPONSES = new ArrayList<>();
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.getKeys(true).stream().filter(key -> !key.equals("default-message")).forEach(key -> {
|
||||
if(!key.contains(".")) {
|
||||
Response response = new Response(key);
|
||||
RESPONSES.add(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<String> getResponse(UUID uuid, String input) {
|
||||
return getResponse(uuid, input, Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
|
||||
public static List<String> getResponse(UUID uuid, String input, List<String> defaultMessage) {
|
||||
final String finalInput = input.startsWith("/") ? StringUtils.replaceFirst(input, "/", "") : input;
|
||||
|
||||
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
|
||||
for (String trigger : response.triggers)
|
||||
if(trigger.endsWith("*") ? finalInput.startsWith(StringUtils.replace(trigger, "*", "")) : finalInput.equals(trigger))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if(uuid != null && optionalResponse.isPresent()) {
|
||||
optionalResponse.get().executeAction(uuid);
|
||||
return optionalResponse.get().message;
|
||||
}
|
||||
|
||||
return defaultMessage;
|
||||
}
|
||||
|
||||
private static class Response {
|
||||
|
||||
private final List<String> triggers, message, actions;
|
||||
|
||||
public Response(final String key) {
|
||||
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
|
||||
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
|
||||
this.actions = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".actions", new ArrayList<>());
|
||||
}
|
||||
|
||||
public void executeAction(UUID uuid) {
|
||||
String[] split;
|
||||
for (String action : actions) {
|
||||
if(!action.contains("::")) {
|
||||
Logger.warning("! Could not recognise action: " + action);
|
||||
Logger.warning(" > Syntax does not match at all. Have you used the splitters (::) correctly?");
|
||||
continue;
|
||||
}
|
||||
|
||||
split = action.split("::");
|
||||
|
||||
switch (split[0].toLowerCase()) {
|
||||
case "effect":
|
||||
if(Reflection.isProxyServer()) {
|
||||
Logger.warning("! Could not execute action: " + action);
|
||||
Logger.warning(" > Effect cannot be added on the proxy side!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(split.length != 4) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 4 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > effect::potionEffect::duration::amplifier");
|
||||
Logger.warning(" > e.g: effect::BLINDNESS::100::1");
|
||||
continue;
|
||||
}
|
||||
|
||||
int duration, amplifier;
|
||||
|
||||
try {
|
||||
duration = Integer.parseInt(split[2]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Duration " + split[2].toUpperCase() + " is not a valid integer! (e.g: 1)");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
amplifier = Integer.parseInt(split[3]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Amplifier " + split[3].toUpperCase() + " is not a valid integer! (e.g: 1)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ActionHandler.addPotionEffect(action, uuid, split[1].toUpperCase(), duration, amplifier);
|
||||
continue;
|
||||
|
||||
case "title":
|
||||
if(split.length != 6) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 6 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > title::title::subtitle::fadeIn::stay::fadeOut");
|
||||
Logger.warning(" > e.g: title::My title::My subtitle::300::3000::300");
|
||||
continue;
|
||||
}
|
||||
|
||||
int fadeIn, stay, fadeOut;
|
||||
|
||||
try {
|
||||
fadeIn = Integer.parseInt(split[3]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Fade-In " + split[3].toUpperCase() + " is not a valid integer! (e.g: 300)");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
stay = Integer.parseInt(split[4]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Stay " + split[4].toUpperCase() + " is not a valid integer! (e.g: 3000)");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
fadeOut = Integer.parseInt(split[5]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Fade-Out " + split[5].toUpperCase() + " is not a valid integer! (e.g: 300)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ActionHandler.sendTitle(action, uuid, split[1], split[2], fadeIn, stay, fadeOut);
|
||||
continue;
|
||||
|
||||
case "sound":
|
||||
|
||||
if(Reflection.isProxyServer()) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Sounds cannot be played on the proxy side!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(split.length != 4) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 4 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > sound::soundName::volume::pitch");
|
||||
Logger.warning(" > e.g: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0");
|
||||
continue;
|
||||
}
|
||||
|
||||
float volume, pitch;
|
||||
|
||||
try {
|
||||
volume = Float.parseFloat(split[2]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Volume " + split[2].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
pitch = Float.parseFloat(split[3]);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Pitch " + split[3].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ActionHandler.playSound(action, uuid, split[1].toUpperCase(), volume, pitch);
|
||||
continue;
|
||||
|
||||
case "console":
|
||||
if(split.length == 1) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 1 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > console::command");
|
||||
Logger.warning(" > e.g: console::say Hello world!");
|
||||
}
|
||||
|
||||
ActionHandler.executeConsoleCommand(action, uuid, split[1]);
|
||||
|
||||
case "actionbar":
|
||||
if(split.length == 1) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 1 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > actionbar::text");
|
||||
Logger.warning(" > e.g: actionbar::I like COOKIES");
|
||||
}
|
||||
|
||||
ActionHandler.sendActionbar(action, uuid, split[1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package de.rayzs.pat.utils.response.action;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Action {
|
||||
|
||||
void executeConsoleCommand(String action, UUID uuid, String command);
|
||||
void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut);
|
||||
void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier);
|
||||
void playSound(String action, UUID uuid, String soundName, float volume, float pitch);
|
||||
void sendActionbar(String action, UUID uuid, String text);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.rayzs.pat.utils.response.action;
|
||||
|
||||
import de.rayzs.pat.utils.response.action.impl.*;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ActionHandler {
|
||||
|
||||
private static final Action ACTION = Reflection.isProxyServer() ? Reflection.isVelocityServer() ? new VelocityAction() : new BungeeAction() : Reflection.getMinor() <= 16 ? new OldBukkitAction() : new ModernBukkitAction();
|
||||
|
||||
public static void initialize() {}
|
||||
|
||||
public static void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
ACTION.executeConsoleCommand(action, uuid, command);
|
||||
}
|
||||
public static void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
ACTION.sendTitle(action, uuid, title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
public static void addPotionEffect(String action, UUID uuid, String potionEffectType, int duration, int amplifier) {
|
||||
ACTION.addPotionEffect(action, uuid, potionEffectType, duration, amplifier);
|
||||
}
|
||||
|
||||
public static void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
ACTION.playSound(action, uuid, soundName, volume, pitch);
|
||||
}
|
||||
|
||||
public static void sendActionbar(String action, UUID uuid, String text) {
|
||||
ACTION.sendActionbar(action, uuid, text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeeAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(player != null) command = command.replace("%player%", player.getName());
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
Title titleObj = ProxyServer.getInstance().createTitle();
|
||||
titleObj.title(TextComponent.fromLegacyText(StringUtils.replace(title, "&", "§", "%player%", player.getName())));
|
||||
titleObj.subTitle(TextComponent.fromLegacyText(StringUtils.replace(subTitle, "&", "§", "%player%", player.getName())));
|
||||
titleObj.fadeIn(fadeIn);
|
||||
titleObj.stay(stay);
|
||||
titleObj.fadeOut(fadeOut);
|
||||
player.sendTitle(titleObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.replace(text, "%player%", player.getName())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ModernBukkitAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null) command = command.replace("%player%", player.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
|
||||
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
PotionEffectType potionEffectType = null;
|
||||
try {
|
||||
potionEffectType = PotionEffectType.getByName(potionEffectTypeName);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
if(potionEffectType == null) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The effect \"" + potionEffectTypeName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing effect:");
|
||||
Logger.warning(" > BLINDNESS, REGENERATION");
|
||||
return;
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(potionEffectType, duration, amplifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
try {
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing sound effect:");
|
||||
Logger.warning(" > ENTITY_ENDER_DRAGON_GROWL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OldBukkitAction implements Action {
|
||||
|
||||
private String versionPackage = null;
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null) command = command.replace("%player%", player.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
|
||||
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.sendTitle(title, subTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
PotionEffectType potionEffectType = null;
|
||||
try {
|
||||
potionEffectType = PotionEffectType.getByName(potionEffectTypeName);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
if(potionEffectType == null) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The effect \"" + potionEffectTypeName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing effect:");
|
||||
Logger.warning(" > BLINDNESS, REGENERATION");
|
||||
return;
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(potionEffectType, duration, amplifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
try {
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing sound effect:");
|
||||
Logger.warning(" > ENTITY_ENDER_DRAGON_GROWL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) return;
|
||||
|
||||
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
|
||||
|
||||
try {
|
||||
if(versionPackage == null)
|
||||
versionPackage = Reflection.getVersionPackageName();
|
||||
|
||||
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Constructor<?> constructor = (Objects.<Class<?>>requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".PacketPlayOutChat"))).getConstructor(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"), byte.class);
|
||||
Object iChatBaseComponent = (Objects.requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"))).getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + text + "\"}");
|
||||
Object actionbarPacket = constructor.newInstance(iChatBaseComponent, (byte) 2);
|
||||
Object playerConnection = entityPlayer.getClass().getField("playerConnection").get(entityPlayer);
|
||||
playerConnection.getClass().getMethod("sendPacket", Class.forName("net.minecraft.server." + versionPackage + ".Packet")).invoke(playerConnection, actionbarPacket);
|
||||
|
||||
} catch (ClassNotFoundException
|
||||
| NoSuchMethodException
|
||||
| IllegalAccessException
|
||||
| InvocationTargetException
|
||||
| NoSuchFieldException
|
||||
| InstantiationException exception) {
|
||||
Logger.warning("! Failed to run action: " + action);
|
||||
Logger.warning(" > Actionbars are not supported in this server version!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
import java.time.*;
|
||||
|
||||
public class VelocityAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
if (optPlayer.isPresent()) command = command.replace("%player%", optPlayer.get().getUsername());
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(VelocityLoader.getServer().getConsoleCommandSource(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
if(!optPlayer.isPresent()) return;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
Title titleObj = Title.title(
|
||||
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(title, "%player%", player.getUsername()))),
|
||||
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(subTitle, "%player%", player.getUsername()))),
|
||||
Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut))
|
||||
);
|
||||
|
||||
player.showTitle(titleObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
if(!optPlayer.isPresent()) return;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
player.sendActionBar(MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(text, "%player%", player.getUsername()))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
public class Argument {
|
||||
|
||||
private static final Argument GENERAL = new Argument();
|
||||
|
||||
private final List<String> INPUTS = new ArrayList<>();
|
||||
private final HashMap<String, ArgumentStack> ARGUMENT_STACKS = new HashMap<>();
|
||||
|
||||
public static Argument getGeneralArgument() {
|
||||
Argument copiedGeneralArguments = new Argument();
|
||||
GENERAL.getInputs().forEach(copiedGeneralArguments::buildArgumentStacks);
|
||||
return copiedGeneralArguments;
|
||||
}
|
||||
|
||||
public static List<String> getOptions(String input) {
|
||||
return GENERAL.getResult(input);
|
||||
}
|
||||
|
||||
public static void clearArguments() {
|
||||
GENERAL.clearAllArguments();
|
||||
}
|
||||
|
||||
public static void buildArguments(String input) {
|
||||
GENERAL.buildArgumentStacks(input);
|
||||
}
|
||||
|
||||
public static List<String> getAllInputs() {
|
||||
return GENERAL.getInputs();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getInputs() {
|
||||
return INPUTS;
|
||||
}
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
|
||||
if(!entry.getKey().equals(firstInputArg)) continue;
|
||||
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
|
||||
if(!entry.getKey().startsWith(firstInputArg)) continue;
|
||||
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void clearAllArguments() {
|
||||
INPUTS.clear();
|
||||
ARGUMENT_STACKS.clear();
|
||||
}
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
if(!input.contains(" ")) return;
|
||||
|
||||
if(!INPUTS.contains(input))
|
||||
INPUTS.add(input);
|
||||
|
||||
boolean first = true;
|
||||
ArgumentStack argumentStack = null;
|
||||
|
||||
for (String s : input.split(" ")) {
|
||||
if(!first) {
|
||||
argumentStack = argumentStack.createAndGetArgumentStack(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
argumentStack = ARGUMENT_STACKS.get(s);
|
||||
if (argumentStack == null) {
|
||||
argumentStack = new ArgumentStack();
|
||||
ARGUMENT_STACKS.put(s, argumentStack);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ArgumentStack {
|
||||
|
||||
private final HashMap<String, ArgumentStack> argumentStacks = new HashMap<>();
|
||||
private final List<String> suggestions = new ArrayList<>();
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String current;
|
||||
while(input.contains(" ")) {
|
||||
current = input.split(" ")[0];
|
||||
|
||||
if(suggestions.contains("%online_players%"))
|
||||
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%online_players%");
|
||||
if(suggestions.contains("%hidden_online_players%"))
|
||||
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
|
||||
|
||||
input = StringUtils.replaceFirst(input, current, "");
|
||||
input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : argumentStacks.entrySet()) {
|
||||
if(!entry.getKey().startsWith(current)) continue;
|
||||
|
||||
if(entry.getKey().contains("%online_players%"))
|
||||
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%online_players%");
|
||||
if(entry.getKey().contains("%hidden_online_players%"))
|
||||
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
|
||||
|
||||
return entry.getValue().getResult(input);
|
||||
}
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public ArgumentStack createAndGetArgumentStack(String origin) {
|
||||
|
||||
if(!suggestions.contains(origin))
|
||||
suggestions.add(origin);
|
||||
|
||||
if(!argumentStacks.containsKey(origin)) {
|
||||
ArgumentStack argumentStack = new ArgumentStack();
|
||||
argumentStacks.put(origin, argumentStack);
|
||||
return argumentStack;
|
||||
}
|
||||
|
||||
return argumentStacks.get(origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.2
|
||||
version: 1.9.2
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends:
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
updater:
|
||||
enabled: true
|
||||
period: 10000
|
||||
auto-update-config: true
|
||||
updated:
|
||||
- '&8[&2PAT &7| &2Bukkit&8] &aYou are using the newest version! ^^'
|
||||
outdated:
|
||||
@@ -83,18 +84,23 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
custom-plugins:
|
||||
enabled: true
|
||||
|
||||
# If this is set to true, the command will always be tab-completable,
|
||||
# even if the command is supposed to be blocked
|
||||
always-tab-completable: false
|
||||
|
||||
commands:
|
||||
- pl
|
||||
- plugins
|
||||
- bukkit:pl
|
||||
- bukkit:plugins
|
||||
message:
|
||||
- '&fPlugins (0):'
|
||||
|
||||
@@ -102,12 +108,16 @@ custom-plugins:
|
||||
# Here you can customize your own fake '/version' command.
|
||||
custom-version:
|
||||
enabled: true
|
||||
|
||||
# If this is set to true, the command will always be tab-completable,
|
||||
# even if the command is supposed to be blocked
|
||||
always-tab-completable: false
|
||||
|
||||
commands:
|
||||
- icanhasbukkit
|
||||
- about
|
||||
- version
|
||||
- ver
|
||||
- icanhasbukkit
|
||||
- bukkit:ver
|
||||
- bukkit:version
|
||||
message:
|
||||
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
|
||||
|
||||
@@ -119,8 +129,8 @@ 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. ^^
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
# it would be a waste not to provide some simple patches like these. ^^
|
||||
patch-exploits:
|
||||
enabled: true
|
||||
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# What are these action section at each block?
|
||||
# This is an additional feature to make your responses much more alive.
|
||||
# Example actions that can be used are the following:
|
||||
# Execute console command:
|
||||
# Syntax: console::command
|
||||
# Example: console::say %player% is an evil player
|
||||
# Send actionbar:
|
||||
# Syntax: actionbar::text
|
||||
# Example: actionbar::&cThis is not cool %player%!
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
# Play sound:
|
||||
# Syntax: sound::soundName::volume::pitch
|
||||
# Example: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0
|
||||
# Give potion effect:
|
||||
# Syntax: effect::potionEffect::duration::amplifier
|
||||
# Example: effect::BLINDNESS::45::1
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
#example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "effect::BLINDNESS::45::1"
|
||||
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
|
||||
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
|
||||
# - "actionbar::&cNop, sorry %player%"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
#example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "effect::BLINDNESS::45::1"
|
||||
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
|
||||
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
|
||||
# - "actionbar::&cNop, sorry %player%"
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
updater:
|
||||
enabled: true
|
||||
period: 10000
|
||||
auto-update-config: true
|
||||
updated:
|
||||
- '&8[&2PAT &7| &2Proxy&8] &aYou are using the newest version! ^^'
|
||||
outdated:
|
||||
@@ -19,6 +20,13 @@ updater:
|
||||
- '&8[&4PAT &7| &4Proxy&8] &cGet the newest version here:'
|
||||
- '&8[&4PAT &7| &4Proxy&8] &ehttps://www.rayzs.de/products/proantitab/page'
|
||||
|
||||
# If this value is set to 'true', the proxy won't communicate with the backend servers anymore.
|
||||
# In other words, the backend servers won't receive any updates from the proxy about the storage.yml.
|
||||
# It's here to prevent any unnecessary communication between the proxy and the backend servers, if PAT is being used on the proxy alone.
|
||||
# For why this can be the case, read the following: https://github.com/RayzsYT/ProAntiTab/wiki/FAQ#can-i-install-pat-just-on-my-proxy-server
|
||||
# It is NOT recommended to enable this option, unless you know what you are doing.
|
||||
disable-sync: false
|
||||
|
||||
# This is a very necessary feature if you have way too many commands to block and instead decide
|
||||
# to whitelist specific commands.
|
||||
# Enabling this will disable ALL commands except for those that are in the (group-)list.
|
||||
@@ -66,29 +74,38 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
custom-plugins:
|
||||
enabled: true
|
||||
|
||||
# If this is set to true, the command will always be tab-completable,
|
||||
# even if the command is supposed to be blocked
|
||||
always-tab-completable: false
|
||||
|
||||
commands:
|
||||
- pl
|
||||
- plugins
|
||||
- bukkit:pl
|
||||
- bukkit:plugins
|
||||
message:
|
||||
- '&fPlugins (0):'
|
||||
|
||||
# Here you can customize your own fake '/version' command.
|
||||
custom-version:
|
||||
enabled: true
|
||||
|
||||
# If this is set to true, the command will always be tab-completable,
|
||||
# even if the command is supposed to be blocked
|
||||
always-tab-completable: false
|
||||
|
||||
commands:
|
||||
- icanhasbukkit
|
||||
- about
|
||||
- version
|
||||
- ver
|
||||
- icanhasbukkit
|
||||
- bukkit:ver
|
||||
- bukkit:version
|
||||
message:
|
||||
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
|
||||
|
||||
@@ -99,8 +116,8 @@ 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. ^^
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
# it would be a waste not to provide some simple patches like these. ^^
|
||||
patch-exploits:
|
||||
enabled: true
|
||||
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# What are these action section at each block?
|
||||
# This is an additional feature to make your responses much more alive.
|
||||
# Example actions that can be used are the following:
|
||||
# Execute console command:
|
||||
# Syntax: console::command
|
||||
# Example: console::send %player% fallback
|
||||
# Send actionbar:
|
||||
# Syntax: actionbar::text
|
||||
# Example: actionbar::&cThis is not cool %player%!
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
#example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "title::Hey!::You can't do that %player%!::30::3000::30"
|
||||
# - "actionbar::Nop, sorry %player%"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
#example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "title::Hey!::You can't do that %player%!::30::3000::30"
|
||||
# - "actionbar::Nop, sorry %player%"
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -2,8 +2,9 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.2
|
||||
version: 1.9.2
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
softdepend:
|
||||
|
||||
Reference in new issue
Block a user