mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 727d6c3227 | |||
| 7e6b793ede | |||
| fd893b931d | |||
| 5bcf5bb130 | |||
| 7c33718190 | |||
| ad599092de |
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Bukkit</artifactId>
|
<artifactId>Bukkit</artifactId>
|
||||||
|
|||||||
+2
-2
@@ -48,9 +48,9 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
// Use paper's async tab completions if possible
|
// Use paper's async tab completions if possible
|
||||||
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
|
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
|
||||||
getServer().getPluginManager().registerEvents(new AsyncTabCompleteBlockerListener(), this);
|
getServer().getPluginManager().registerEvents(new AsyncTabCompleteBlockerListener(), this);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
|
||||||
}
|
}
|
||||||
|
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
||||||
|
|
||||||
PluginCommand command = getCommand("commandwhitelist");
|
PluginCommand command = getCommand("commandwhitelist");
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
|
|||||||
+6
-9
@@ -9,21 +9,18 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
|
||||||
public class AsyncTabCompleteBlockerListener implements Listener {
|
public class AsyncTabCompleteBlockerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
|
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
if (!(event.getSender() instanceof Player)) return;
|
||||||
Player player = (Player) event.getSender();
|
Player player = (Player) event.getSender();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
event.setCompletions(
|
String buffer = event.getBuffer();
|
||||||
CommandUtil.filterSuggestions(
|
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
|
||||||
event.getBuffer(),
|
if (event.getCompletions().isEmpty()) return;
|
||||||
event.getCompletions(),
|
event.setCompletions(CommandUtil.filterSuggestions(buffer, event.getCompletions(), CommandWhitelistBukkit.getSuggestions(player)));
|
||||||
CommandWhitelistBukkit.getSuggestions(player)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
event.setHandled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -7,18 +7,23 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.TabCompleteEvent;
|
||||||
|
|
||||||
public class TabCompleteBlockerListener implements Listener {
|
public class TabCompleteBlockerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCommandTabComplete(org.bukkit.event.server.TabCompleteEvent event) {
|
public void onCommandTabComplete(TabCompleteEvent event) {
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
if (!(event.getSender() instanceof Player)) return;
|
||||||
Player player = (Player) event.getSender();
|
Player player = (Player) event.getSender();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
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(
|
event.setCompletions(
|
||||||
CommandUtil.filterSuggestions(
|
CommandUtil.filterSuggestions(
|
||||||
event.getBuffer(),
|
buffer,
|
||||||
event.getCompletions(),
|
event.getCompletions(),
|
||||||
CommandWhitelistBukkit.getSuggestions(player)
|
CommandWhitelistBukkit.getSuggestions(player)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Common</artifactId>
|
<artifactId>Common</artifactId>
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveCWGroup(String id, CWGroup group) {
|
public void saveCWGroup(String id, CWGroup group) {
|
||||||
config.set("groups." + id + ".", group.serialize());
|
config.set("groups." + id, group.serialize());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,6 @@ public class CWCommand {
|
|||||||
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
default:
|
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
if ("reload".startsWith(args[0]) && reloadPerm)
|
if ("reload".startsWith(args[0]) && reloadPerm)
|
||||||
@@ -101,8 +100,9 @@ public class CWCommand {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Velocity</artifactId>
|
<artifactId>Velocity</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Waterfall</artifactId>
|
<artifactId>Waterfall</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1.1</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>CommandWhitelistCommon</module>
|
<module>CommandWhitelistCommon</module>
|
||||||
<module>CommandWhitelistBukkit</module>
|
<module>CommandWhitelistBukkit</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user