mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-13 12:41:58 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7fd9dd42a | ||
|
|
acd8e9291a | ||
|
|
50c80fc708 | ||
|
|
bb02672085 | ||
|
|
f2e7efeaa6 | ||
|
|
aa0863e726 | ||
|
|
71cec6933f | ||
|
|
c2d407cd62 | ||
|
|
61adaa19db | ||
|
|
4c1cc0683d | ||
|
|
ce3b42af38 | ||
|
|
61c204ade0 | ||
|
|
e13fae6e67 | ||
|
|
31e4c3caa4 | ||
|
|
bccb77667d | ||
|
|
4ab0791740 | ||
|
|
a9afbad0a2 | ||
|
|
d625212ac1 | ||
|
|
ee23b2d47e | ||
|
|
30714d5b7d | ||
|
|
07734f70bb | ||
|
|
367d0cec7e |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<version>2.0.6</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -72,25 +72,10 @@
|
||||
<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>
|
||||
|
||||
@@ -10,8 +10,8 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ExecuteCommandEvent) {
|
||||
@@ -169,8 +169,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked) {
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
|
||||
@@ -5,18 +5,24 @@ import de.rayzs.pat.api.event.PATEvent;
|
||||
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
private boolean blocked, notify;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
super(null);
|
||||
this.blocked = false;
|
||||
this.notify = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
super(senderObj);
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
public void setDoesNotify(boolean notify) {
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
@@ -27,6 +33,10 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public boolean doesNotify() {
|
||||
return notify;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
@@ -37,10 +37,13 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
private static boolean loaded = false, checkUpdate = false, suggestions = false;
|
||||
private static boolean loaded = false, suggestions = false;
|
||||
private static Map<String, Command> commandsMap = null;
|
||||
private PATSchedulerTask updaterTask;
|
||||
|
||||
private final List<String> offlinePlayerNames = new ArrayList<>(List.of(Bukkit.getOfflinePlayers()))
|
||||
.stream().map(OfflinePlayer::getName).toList();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Configurator.createResourcedFile("files\\bukkit-config.yml", "config.yml", false);
|
||||
@@ -61,7 +64,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
|
||||
@@ -158,7 +161,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerExist(String playerName) {
|
||||
return getOfflinePlayerNames().contains(playerName);
|
||||
return ArrayUtils.containsIgnoreCase(getPlayerNames(), playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,15 +191,14 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public List<String> getOfflinePlayerNames() {
|
||||
return new ArrayList<>(List.of(Bukkit.getOfflinePlayers())).stream().map(OfflinePlayer::getName).toList();
|
||||
return offlinePlayerNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerNames() {
|
||||
List<String> playerNames = new ArrayList<>();
|
||||
List<String> playerNames = new ArrayList<>(offlinePlayerNames);
|
||||
|
||||
playerNames.addAll(getOnlinePlayerNames());
|
||||
playerNames.addAll(getOfflinePlayerNames());
|
||||
|
||||
return playerNames;
|
||||
}
|
||||
@@ -219,41 +221,13 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
updaterTask = PATScheduler.createAsyncScheduler(() -> {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
if (result == null)
|
||||
result = "/";
|
||||
|
||||
if (!result.equals("/")) {
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (VersionComparer.isDeveloperVersion()) {
|
||||
updaterTask.cancelTask();
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
|
||||
} else if (!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
updaterTask.cancelTask();
|
||||
checkUpdate = true;
|
||||
|
||||
if (VersionComparer.isUnreleased()) {
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
|
||||
return;
|
||||
}
|
||||
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if (VersionComparer.isOutdated()) {
|
||||
updaterTask.cancelTask();
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
}
|
||||
} else {
|
||||
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
|
||||
}
|
||||
if (VersionComparer.get().computeComparison())
|
||||
updaterTask.cancelTask();
|
||||
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
|
||||
@@ -226,43 +226,14 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
updaterTask = getProxy().getScheduler().schedule(this, () -> {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
if (result == null)
|
||||
result = "/";
|
||||
if (VersionComparer.get().computeComparison())
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
|
||||
if (!result.equals("/")) {
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if(VersionComparer.isDeveloperVersion()) {
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
|
||||
} else if(!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
getProxy().getScheduler().cancel(updaterTask);
|
||||
checkUpdate = true;
|
||||
|
||||
if(VersionComparer.isUnreleased()) {
|
||||
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
|
||||
return;
|
||||
}
|
||||
|
||||
checkUpdate = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
} else if(VersionComparer.isOutdated()) {
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
|
||||
}
|
||||
}, 20L, Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.3",
|
||||
version = "2.0.6",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -85,7 +85,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
Storage.initialize(this, pluginContainer.getDescription().getVersion().get());
|
||||
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
MessageTranslator.initialize();
|
||||
@@ -271,59 +271,13 @@ public class VelocityLoader implements PluginLoader {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
|
||||
updaterTask = server.getScheduler().buildTask(this, () -> {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
if (result == null)
|
||||
result = "/";
|
||||
if (VersionComparer.get().computeComparison())
|
||||
updaterTask.cancel();
|
||||
|
||||
if (!result.equals("/")) {
|
||||
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (VersionComparer.isDeveloperVersion()) {
|
||||
updaterTask.cancel();
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using a</gray> <aqua>developer</aqua> <gray>version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.</gray>");
|
||||
|
||||
} else if (!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
|
||||
updaterTask.cancel();
|
||||
checkUpdate = true;
|
||||
|
||||
if (VersionComparer.isUnreleased()) {
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using an</gray> <yellow>unreleased</yellow> <gray>version of ProAntiTab.</gray>");
|
||||
return;
|
||||
}
|
||||
|
||||
checkUpdate = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines());
|
||||
|
||||
} else if (VersionComparer.isOutdated()) {
|
||||
Storage.OUTDATED = true;
|
||||
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
|
||||
}
|
||||
}).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;
|
||||
}
|
||||
|
||||
@@ -86,12 +86,17 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
@@ -108,7 +113,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
+15
-2
@@ -5,10 +5,12 @@ import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
@@ -30,10 +32,21 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
if(CustomServerBrand.isEnabled())
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(!BukkitPacketAnalyzer.inject(player)) player.kickPlayer("Failed to inject player!");
|
||||
if(!BukkitPacketAnalyzer.inject(player)) {
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Failed to inject into player! (" + player.getName() + ")" );
|
||||
player.kickPlayer("Failed to inject player!");
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
|
||||
}
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
Bukkit.getScheduler().runTaskLater(BukkitLoader.getPlugin(), () -> {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
|
||||
}
|
||||
|
||||
@@ -51,12 +51,17 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
@@ -76,7 +81,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
+7
-3
@@ -56,12 +56,16 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), true);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getCommand(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return event;
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
@@ -79,7 +83,7 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false);
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
|
||||
|
||||
@@ -124,4 +124,36 @@ public class SubArgsModule {
|
||||
});
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static String replacePlaceholders(String input) {
|
||||
String[] split = input.split(" ");
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
|
||||
boolean number = NumberUtils.isDigit(split[i]),
|
||||
online = Storage.getLoader().isPlayerOnline(s),
|
||||
general = Storage.getLoader().doesPlayerExist(s);
|
||||
|
||||
if (number) {
|
||||
split[i] = "%numbers%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online && general) {
|
||||
split[i] = "%both_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online) {
|
||||
split[i] = "%online_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (general)
|
||||
split[i] = "%players%";
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
event.setDoesNotify(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,6 +56,7 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
event.setDoesNotify(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +92,9 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
|
||||
final String unmodifiable = command;
|
||||
if (commands.stream().noneMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(StringUtils.getFirstArg(unmodifiable)))) {
|
||||
final String firstArgUnmodifiable = StringUtils.getFirstArg(unmodifiable);
|
||||
|
||||
if (commands.stream().noneMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(firstArgUnmodifiable))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,10 +106,13 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
return c;
|
||||
}).toList();
|
||||
|
||||
List<String> placeholderCommands = commands.stream().filter(s -> s.contains("%")).toList();
|
||||
List<String> placeholderCommands = commands.stream().filter(s ->
|
||||
StringUtils.getFirstArg(s).equalsIgnoreCase(firstArgUnmodifiable) && s.contains("%")
|
||||
).toList();
|
||||
|
||||
if (!placeholderCommands.isEmpty())
|
||||
command = replacePlaceholders(command, placeholderCommands);
|
||||
if (!placeholderCommands.isEmpty()) {
|
||||
command = SubArgsModule.replacePlaceholders(command);
|
||||
}
|
||||
|
||||
String cpyCommand;
|
||||
for (String c : commands) {
|
||||
@@ -139,36 +146,4 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
return turn == listed;
|
||||
}
|
||||
|
||||
private String replacePlaceholders(String input, List<String> abnormalCommands) {
|
||||
String[] split = input.split(" ");
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
|
||||
boolean number = NumberUtils.isDigit(split[i]),
|
||||
online = Storage.getLoader().isPlayerOnline(s),
|
||||
general = Storage.getLoader().doesPlayerExist(s);
|
||||
|
||||
if (number) {
|
||||
split[i] = "%numbers%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online && general) {
|
||||
split[i] = "%both_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (online) {
|
||||
split[i] = "%online_players%";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (general)
|
||||
split[i] = "%players%";
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,10 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
if (result.contains("%numbers%")) {
|
||||
possibilities.remove("%numbers%");
|
||||
possibilities.addAll(possibilities.stream().filter(NumberUtils::isDigit).toList());
|
||||
possibilities.addAll(event.getCompletion().stream().filter(NumberUtils::isDigit).toList());
|
||||
|
||||
if (possibilities.isEmpty())
|
||||
possibilities.add("///////////");
|
||||
}
|
||||
|
||||
if (result.contains("%players%")) {
|
||||
@@ -67,7 +70,8 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
return result.contains(completion);
|
||||
}).toList());
|
||||
|
||||
if (possibilities.isEmpty()) possibilities.add("///////////");
|
||||
if (possibilities.isEmpty())
|
||||
possibilities.add("///////////");
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -85,7 +89,9 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
}
|
||||
|
||||
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if(possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) return;
|
||||
if (possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCompletion(possibilities);
|
||||
}
|
||||
|
||||
@@ -37,16 +37,21 @@ public class ConnectionBuilder {
|
||||
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
||||
|
||||
if(parameters != null && parameters.length > 0) {
|
||||
|
||||
Object firstParam = null, secondParam = null;
|
||||
for (Object parameter : parameters) {
|
||||
if(firstParam == null) firstParam = parameter;
|
||||
else if(secondParam == null) secondParam = parameter;
|
||||
else {
|
||||
connection.setRequestProperty((String) firstParam, (String) secondParam);
|
||||
firstParam = null;
|
||||
secondParam = null;
|
||||
|
||||
if (firstParam == null) {
|
||||
firstParam = parameter;
|
||||
continue;
|
||||
}
|
||||
|
||||
secondParam = parameter;
|
||||
|
||||
connection.setRequestProperty((String) firstParam, (String) secondParam);
|
||||
firstParam = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,121 +1,179 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class VersionComparer {
|
||||
|
||||
private static Version CURRENT_VERSION, NEWEST_VERSION;
|
||||
public enum VersionState { NEWER, UPDATED, OUTDATED }
|
||||
|
||||
public static void setCurrentVersion(String versionName) {
|
||||
if(CURRENT_VERSION != null && CURRENT_VERSION.getVersionName().equals(versionName)) return;
|
||||
CURRENT_VERSION = new Version(versionName);
|
||||
private static final VersionComparer instance = new VersionComparer();
|
||||
|
||||
public static VersionComparer get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void setNewestVersion(String versionName) {
|
||||
if(NEWEST_VERSION != null && NEWEST_VERSION.getVersionName().equals(versionName))
|
||||
private VersionComparer() {}
|
||||
|
||||
private final List<String> ignoreVersions = Arrays.asList("1.9.1", "1.9.2");
|
||||
private final String versionUrl = "https://www.rayzs.de/proantitab/api/version.php";
|
||||
|
||||
private final int versionLength = 3;
|
||||
|
||||
private Version currentVersion, newestVersion;
|
||||
private VersionState versionState = VersionState.UPDATED;
|
||||
|
||||
private boolean shouldAnnounce = true;
|
||||
|
||||
|
||||
public boolean computeComparison() {
|
||||
String result = new ConnectionBuilder().setUrl(versionUrl)
|
||||
.setProperties("ProAntiTab", "4454")
|
||||
.connect()
|
||||
.getResponse();
|
||||
|
||||
if (result == null)
|
||||
result = "/";
|
||||
|
||||
if (result.equals("/")) {
|
||||
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
|
||||
return false;
|
||||
}
|
||||
|
||||
Storage.NEWER_VERSION = result;
|
||||
VersionComparer.get().setNewestVersion(Storage.NEWER_VERSION);
|
||||
|
||||
if (VersionComparer.get().isNewer()) {
|
||||
if (shouldAnnounce) {
|
||||
shouldAnnounce = false;
|
||||
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (VersionComparer.get().isUpdated()) {
|
||||
if (shouldAnnounce) {
|
||||
shouldAnnounce = false;
|
||||
|
||||
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (VersionComparer.get().isOutdated()) {
|
||||
|
||||
if (shouldAnnounce) {
|
||||
shouldAnnounce = false;
|
||||
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCurrentVersion(String version) {
|
||||
if (version == null)
|
||||
return;
|
||||
|
||||
NEWEST_VERSION = new Version(versionName);
|
||||
currentVersion = new Version(version);
|
||||
}
|
||||
|
||||
public static Version getCurrentVersion() {
|
||||
return CURRENT_VERSION;
|
||||
public void setNewestVersion(String version) {
|
||||
if (version == null)
|
||||
return;
|
||||
|
||||
if (ignoreVersions.contains(version))
|
||||
return;
|
||||
|
||||
newestVersion = new Version(version);
|
||||
compute();
|
||||
}
|
||||
|
||||
public static Version getNewestVersion() {
|
||||
return NEWEST_VERSION;
|
||||
public VersionState getVersionState() {
|
||||
return versionState;
|
||||
}
|
||||
|
||||
public static boolean isNewest() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return true;
|
||||
|
||||
return CURRENT_VERSION.isSame(NEWEST_VERSION);
|
||||
public boolean isUpdated() {
|
||||
return versionState == VersionState.UPDATED;
|
||||
}
|
||||
|
||||
public static boolean isUnreleased() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return true;
|
||||
|
||||
return CURRENT_VERSION.isNewer(NEWEST_VERSION);
|
||||
public boolean isOutdated() {
|
||||
return versionState == VersionState.OUTDATED;
|
||||
}
|
||||
|
||||
public static boolean isOutdated() {
|
||||
if(CURRENT_VERSION == null || NEWEST_VERSION == null) return false;
|
||||
return CURRENT_VERSION.isOlder(NEWEST_VERSION);
|
||||
public boolean isNewer() {
|
||||
return versionState == VersionState.NEWER;
|
||||
}
|
||||
|
||||
public static boolean isDeveloperVersion() {
|
||||
return CURRENT_VERSION.getState() == State.DEV;
|
||||
}
|
||||
private void compute() {
|
||||
if (currentVersion == null || newestVersion == null)
|
||||
return;
|
||||
|
||||
public static class Version {
|
||||
private final String versionName;
|
||||
private int release = -1, major = -1, patch = -1;
|
||||
private State state = State.RELEASE;
|
||||
int[] crntNum = currentVersion.getVersionNums();
|
||||
int[] newNum = newestVersion.getVersionNums();
|
||||
|
||||
public Version(String version) {
|
||||
this.versionName = version;
|
||||
for (int i = 0; i < versionLength; i++) {
|
||||
|
||||
try {
|
||||
String[] versionSplit = version.split("\\.");
|
||||
release = Integer.parseInt(versionSplit[0]);
|
||||
major = Integer.parseInt(versionSplit[1]);
|
||||
|
||||
String patchAsString = versionSplit[2];
|
||||
patchAsString = patchAsString.contains("-") ? patchAsString.split("-")[0] : patchAsString;
|
||||
|
||||
patch = Integer.parseInt(patchAsString);
|
||||
|
||||
if(!version.contains("-")) return;
|
||||
String stateName = version.split("-")[1].toUpperCase();
|
||||
state = State.valueOf(stateName);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
Logger.warning("Failed to read version name! [" + version + "]");
|
||||
throwable.printStackTrace();
|
||||
if (crntNum[i] > newNum[i]) {
|
||||
versionState = VersionState.NEWER;
|
||||
return;
|
||||
}
|
||||
|
||||
if (crntNum[i] < newNum[i]) {
|
||||
versionState = VersionState.OUTDATED;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class Version {
|
||||
|
||||
private final int[] versionNums = new int[versionLength];
|
||||
private final String versionString;
|
||||
|
||||
|
||||
public Version(String versionString) {
|
||||
this.versionString = versionString;
|
||||
setVersionNums();
|
||||
}
|
||||
|
||||
public String getVersionName() {
|
||||
return versionName;
|
||||
return versionString;
|
||||
}
|
||||
|
||||
public boolean isSame(Version version) {
|
||||
return version.getVersionName().equals(versionName);
|
||||
public int[] getVersionNums() {
|
||||
return versionNums;
|
||||
}
|
||||
|
||||
public boolean isNewer(Version comparedVersion) {
|
||||
return !isSame(comparedVersion) && !isOlder(comparedVersion);
|
||||
private void setVersionNums() {
|
||||
|
||||
if (!versionString.contains("."))
|
||||
return;
|
||||
|
||||
String[] details = versionString.split("\\.");
|
||||
for (int i = 0; i < details.length; i++) {
|
||||
if (i >= versionLength)
|
||||
break;
|
||||
|
||||
String detailString = details[i];
|
||||
|
||||
if (!NumberUtils.isDigit(detailString))
|
||||
continue;
|
||||
|
||||
int detail = Integer.parseInt(detailString);
|
||||
versionNums[i] = detail;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOlder(Version comparedVersion) {
|
||||
if(release > comparedVersion.getRelease()) return false;
|
||||
if(major > comparedVersion.getMajor()) return false;
|
||||
|
||||
return patch < comparedVersion.getPatch();
|
||||
}
|
||||
|
||||
public int getRelease() {
|
||||
return release;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getPatch() {
|
||||
return patch;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public boolean isInvalid() {
|
||||
return release == -1 || major == -1 || patch == -1;
|
||||
}
|
||||
}
|
||||
|
||||
public enum State {
|
||||
RELEASE, DEV, ALPHA, BETA
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ResponseHandler {
|
||||
|
||||
@@ -23,12 +24,61 @@ public class ResponseHandler {
|
||||
});
|
||||
}
|
||||
|
||||
public static String replaceArgsVariables(String input, String command) {
|
||||
if (!input.contains(" "))
|
||||
return input;
|
||||
|
||||
String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[]{command};
|
||||
String[] split = input.split(" ");
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String part = split[i];
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%")))
|
||||
continue;
|
||||
|
||||
part = part.substring(part.indexOf('[') + 1, part.lastIndexOf(']'));
|
||||
|
||||
int length = commandSplit.length, fromIndex, toIndex;
|
||||
|
||||
if (part.contains("-")) {
|
||||
String[] indexSplit = part.split("-");
|
||||
|
||||
fromIndex = Integer.parseInt(indexSplit[0]) - 1;
|
||||
toIndex = Integer.parseInt(indexSplit[1]);
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
}
|
||||
|
||||
if (fromIndex < 0 || toIndex > length) {
|
||||
Logger.warning("Custom response contains an error! (" + input + ")");
|
||||
Logger.warning("Out of bounds! (Input: " + input + ", Possible: " + (length > 1 ? "1-" : "") + length + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
String replacement;
|
||||
|
||||
if (fromIndex == toIndex) {
|
||||
replacement = commandSplit[fromIndex - 1];
|
||||
} else {
|
||||
replacement = String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex));;
|
||||
}
|
||||
|
||||
split[i] = replacement;
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
}
|
||||
|
||||
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 String finalInput = input.startsWith("/") && input.length() > 1
|
||||
? input.substring(1)
|
||||
: input;
|
||||
|
||||
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
|
||||
for (String trigger : response.triggers)
|
||||
@@ -39,8 +89,11 @@ public class ResponseHandler {
|
||||
}).findFirst();
|
||||
|
||||
if (uuid != null && optionalResponse.isPresent()) {
|
||||
optionalResponse.get().executeAction(uuid);
|
||||
return optionalResponse.get().message;
|
||||
optionalResponse.get().executeAction(uuid, finalInput);
|
||||
|
||||
return new ArrayList<>(optionalResponse.get().message)
|
||||
.stream().map(s -> replaceArgsVariables(s, finalInput))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return defaultMessage;
|
||||
@@ -56,7 +109,7 @@ public class ResponseHandler {
|
||||
this.actions = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".actions", new ArrayList<>());
|
||||
}
|
||||
|
||||
public void executeAction(UUID uuid) {
|
||||
public void executeAction(UUID uuid, String command) {
|
||||
String[] split;
|
||||
|
||||
for (String action : actions) {
|
||||
@@ -142,7 +195,7 @@ public class ResponseHandler {
|
||||
continue;
|
||||
}
|
||||
|
||||
ActionHandler.sendTitle(action, uuid, split[1], split[2], fadeIn, stay, fadeOut);
|
||||
ActionHandler.sendTitle(action, uuid, command, split[1], split[2], fadeIn, stay, fadeOut);
|
||||
continue;
|
||||
|
||||
case "sound":
|
||||
@@ -192,7 +245,7 @@ public class ResponseHandler {
|
||||
Logger.warning(" > e.g: console::say Hello world!");
|
||||
}
|
||||
|
||||
ActionHandler.executeConsoleCommand(action, uuid, split[1]);
|
||||
ActionHandler.executeConsoleCommand(action, uuid, command, split[1]);
|
||||
|
||||
case "execute":
|
||||
if (split.length == 1) {
|
||||
@@ -203,7 +256,7 @@ public class ResponseHandler {
|
||||
Logger.warning(" > e.g: execute::help");
|
||||
}
|
||||
|
||||
ActionHandler.executePlayerCommand(action, uuid, split[1]);
|
||||
ActionHandler.executePlayerCommand(action, uuid, command, split[1]);
|
||||
|
||||
case "actionbar":
|
||||
if (split.length == 1) {
|
||||
@@ -214,7 +267,7 @@ public class ResponseHandler {
|
||||
Logger.warning(" > e.g: actionbar::I like COOKIES");
|
||||
}
|
||||
|
||||
ActionHandler.sendActionbar(action, uuid, split[1]);
|
||||
ActionHandler.sendActionbar(action, uuid, command, split[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.util.UUID;
|
||||
|
||||
public interface Action {
|
||||
|
||||
void executeConsoleCommand(String action, UUID uuid, String command);
|
||||
void executePlayerCommand(String action, UUID uuid, String command);
|
||||
void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut);
|
||||
void executeConsoleCommand(String action, UUID uuid, String command, String message);
|
||||
void executePlayerCommand(String action, UUID uuid, String command, String message);
|
||||
void sendTitle(String action, UUID uuid, String command, 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);
|
||||
void sendActionbar(String action, UUID uuid, String command, String message);
|
||||
|
||||
}
|
||||
@@ -6,20 +6,23 @@ 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();
|
||||
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 executeConsoleCommand(String action, UUID uuid, String command, String message) {
|
||||
ACTION.executeConsoleCommand(action, uuid, command, message);
|
||||
}
|
||||
|
||||
public static void executePlayerCommand(String action, UUID uuid, String command) {
|
||||
ACTION.executePlayerCommand(action, uuid, command);
|
||||
public static void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
ACTION.executePlayerCommand(action, uuid, command, message);
|
||||
}
|
||||
|
||||
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 sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
ACTION.sendTitle(action, uuid, command, title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
public static void addPotionEffect(String action, UUID uuid, String potionEffectType, int duration, int amplifier) {
|
||||
@@ -30,7 +33,7 @@ public class ActionHandler {
|
||||
ACTION.playSound(action, uuid, soundName, volume, pitch);
|
||||
}
|
||||
|
||||
public static void sendActionbar(String action, UUID uuid, String text) {
|
||||
ACTION.sendActionbar(action, uuid, text);
|
||||
public static void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
ACTION.sendActionbar(action, uuid, command, message);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ 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.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -14,28 +15,32 @@ import java.util.UUID;
|
||||
public class BungeeAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command, String message) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
command = command.replace("%player%", player.getName());
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), command);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command) {
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
command = command.replace("%player%", player.getName());
|
||||
message = command.replace("%player%", player.getName());
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, command);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
@@ -58,12 +63,13 @@ public class BungeeAction implements Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.replace(text, "%player%", player.getName())));
|
||||
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.replace(message, "%player%", player.getName())));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ 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.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -17,35 +18,39 @@ import java.util.UUID;
|
||||
public class ModernBukkitAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
command = command.replace("%player%", player.getName());
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
if (command.contains("%"))
|
||||
command = PlaceholderReplacer.replace(player, command);
|
||||
if (message.contains("%"))
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command) {
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if(player != null)
|
||||
command = command.replace("%player%", player.getName());
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
if (command.contains("%"))
|
||||
command = PlaceholderReplacer.replace(player, command);
|
||||
if (message.contains("%"))
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
|
||||
if (player != null)
|
||||
Bukkit.dispatchCommand(player, command);
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
@@ -98,14 +103,15 @@ public class ModernBukkitAction implements Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
|
||||
message = PlaceholderReplacer.replace(player, StringUtils.replace(message, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text));
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
@@ -21,33 +22,40 @@ public class OldBukkitAction implements Action {
|
||||
private String versionPackage = null;
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null) command = command.replace("%player%", player.getName());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (command.contains("%"))
|
||||
command = PlaceholderReplacer.replace(player, command);
|
||||
if(player != null)
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
if (message.contains("%"))
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command) {
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
command = command.replace("%player%", player.getName());
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
if (command.contains("%"))
|
||||
command = PlaceholderReplacer.replace(player, command);
|
||||
if (message.contains("%"))
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
|
||||
if (player != null)
|
||||
Bukkit.dispatchCommand(player, command);
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
|
||||
@@ -98,13 +106,14 @@ public class OldBukkitAction implements Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
|
||||
message = PlaceholderReplacer.replace(player, StringUtils.replace(message, "&", "§", "%player%", player.getName()));
|
||||
|
||||
try {
|
||||
if (versionPackage == null)
|
||||
@@ -112,7 +121,7 @@ public class OldBukkitAction implements Action {
|
||||
|
||||
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 iChatBaseComponent = (Objects.requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"))).getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + message + "\"}");
|
||||
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);
|
||||
@@ -123,6 +132,7 @@ public class OldBukkitAction implements Action {
|
||||
| InvocationTargetException
|
||||
| NoSuchFieldException
|
||||
| InstantiationException exception) {
|
||||
|
||||
Logger.warning("! Failed to run action: " + action);
|
||||
Logger.warning(" > Actionbars are not supported in this server version!");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
@@ -14,22 +15,33 @@ import java.time.*;
|
||||
public class VelocityAction implements Action {
|
||||
|
||||
@Override
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command) {
|
||||
public void executeConsoleCommand(String action, UUID uuid, String command, String message) {
|
||||
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);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (optPlayer.isPresent())
|
||||
message = message.replace("%player%", optPlayer.get().getUsername());
|
||||
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(VelocityLoader.getServer().getConsoleCommandSource(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command) {
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
if (optPlayer.isPresent()) command = command.replace("%player%", optPlayer.get().getUsername());
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(optPlayer.get(), command);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (optPlayer.isPresent())
|
||||
message = command.replace("%player%", optPlayer.get().getUsername());
|
||||
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(optPlayer.get(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (!optPlayer.isPresent()) return;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
@@ -51,11 +63,14 @@ public class VelocityAction implements Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String text) {
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
if (!optPlayer.isPresent()) return;
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (!optPlayer.isPresent())
|
||||
return;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
player.sendActionBar(MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(text, "%player%", player.getUsername()))));
|
||||
player.sendActionBar(MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(message, "%player%", player.getUsername()))));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,9 @@ public class ArgumentBuilder {
|
||||
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : source.ARGUMENT_STACKS.entrySet()) {
|
||||
if(!entry.getKey().equals(firstInputArg)) continue;
|
||||
if (!entry.getKey().equals(firstInputArg))
|
||||
continue;
|
||||
|
||||
return source.ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
|
||||
}
|
||||
|
||||
@@ -31,7 +33,8 @@ public class ArgumentBuilder {
|
||||
}
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
if(!input.contains(" ")) return;
|
||||
if (!input.contains(" "))
|
||||
return;
|
||||
|
||||
if(!source.INPUTS.contains(input))
|
||||
source.INPUTS.add(input);
|
||||
@@ -40,7 +43,7 @@ public class ArgumentBuilder {
|
||||
ArgumentStack argumentStack = null;
|
||||
|
||||
for (String s : input.split(" ")) {
|
||||
if(!first) {
|
||||
if (!first) {
|
||||
argumentStack = argumentStack.createAndGetArgumentStack(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.3
|
||||
version: 2.0.6
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -32,6 +32,15 @@
|
||||
# Syntax: effect::potionEffect::duration::amplifier
|
||||
# Example: effect::BLINDNESS::45::1
|
||||
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example for all blocked commands.
|
||||
|
||||
@@ -26,6 +26,15 @@
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example for all blocked commands.
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.3
|
||||
version: 2.0.6
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user