Compare commits

...

6 Commits

Author SHA1 Message Date
YouHaveTrouble 727d6c3227 fix default placement 2021-09-02 03:17:36 +02:00
YouHaveTrouble 7e6b793ede bump version 2021-09-02 03:14:16 +02:00
YouHaveTrouble fd893b931d that's one dot too many 2021-09-02 03:12:42 +02:00
YouHaveTrouble 5bcf5bb130 confuse plugin snoopers 2021-09-01 17:59:55 +02:00
YouHaveTrouble 7c33718190 fail early if async suggestions empty 2021-09-01 17:51:45 +02:00
YouHaveTrouble ad599092de fix subcommand completing issues 2021-09-01 17:49:23 +02:00
10 changed files with 25 additions and 23 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.0</version>
<version>2.1.1</version>
</parent>
<artifactId>Bukkit</artifactId>
@@ -48,9 +48,9 @@ public class CommandWhitelistBukkit extends JavaPlugin {
// Use paper's async tab completions if possible
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
getServer().getPluginManager().registerEvents(new AsyncTabCompleteBlockerListener(), this);
} catch (ClassNotFoundException e) {
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
} catch (ClassNotFoundException ignored) {
}
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
PluginCommand command = getCommand("commandwhitelist");
if (command != null) {
@@ -9,21 +9,18 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class AsyncTabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
event.setCompletions(
CommandUtil.filterSuggestions(
event.getBuffer(),
event.getCompletions(),
CommandWhitelistBukkit.getSuggestions(player)
)
);
event.setHandled(true);
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
if (event.getCompletions().isEmpty()) return;
event.setCompletions(CommandUtil.filterSuggestions(buffer, event.getCompletions(), CommandWhitelistBukkit.getSuggestions(player)));
}
}
@@ -7,18 +7,23 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.TabCompleteEvent;
public class TabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onCommandTabComplete(org.bukkit.event.server.TabCompleteEvent event) {
public void onCommandTabComplete(TabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
if (event.getCompletions().isEmpty()) return;
event.setCompletions(
CommandUtil.filterSuggestions(
event.getBuffer(),
event.getCompletions(),
CommandWhitelistBukkit.getSuggestions(player)
buffer,
event.getCompletions(),
CommandWhitelistBukkit.getSuggestions(player)
)
);
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.0</version>
<version>2.1.1</version>
</parent>
<artifactId>Common</artifactId>
@@ -133,7 +133,7 @@ public class ConfigCache {
}
public void saveCWGroup(String id, CWGroup group) {
config.set("groups." + id + ".", group.serialize());
config.set("groups." + id, group.serialize());
saveConfig();
}
@@ -53,7 +53,6 @@ public class CWCommand {
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
List<String> list = new ArrayList<>();
switch (args.length) {
default:
case 0:
case 1:
if ("reload".startsWith(args[0]) && reloadPerm)
@@ -101,8 +100,9 @@ public class CWCommand {
}
return list;
}
default:
return list;
}
return list;
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.0</version>
<version>2.1.1</version>
</parent>
<artifactId>Velocity</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.0</version>
<version>2.1.1</version>
</parent>
<artifactId>Waterfall</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.0</version>
<version>2.1.1</version>
<modules>
<module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module>