mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
feat(bukkit): 处理op命令导致的权限变更
This commit is contained in:
@@ -258,19 +258,19 @@ public class BukkitFontManager extends AbstractFontManager implements Listener {
|
||||
}
|
||||
|
||||
private void processOpCommand(CommandSender sender, String command) {
|
||||
if (!sender.hasPermission("minecraft.command.op")) return;
|
||||
if (!sender.hasPermission("minecraft.command.deop")) return;
|
||||
String input = command.startsWith("/") ? command.substring(1) : command;
|
||||
int firstSpaceIndex = input.indexOf(' ');
|
||||
String cmdPart = (firstSpaceIndex == -1) ? input : input.substring(0, firstSpaceIndex);
|
||||
String argPart = (firstSpaceIndex == -1) ? "" : input.substring(firstSpaceIndex + 1).trim();
|
||||
int lastColonIndex = cmdPart.lastIndexOf(':');
|
||||
if (lastColonIndex != -1 && !cmdPart.substring(0, lastColonIndex).equals("minecraft")) return;
|
||||
String cmd = lastColonIndex == -1 ? cmdPart : cmdPart.substring(lastColonIndex + 1);
|
||||
cmd = cmd.toLowerCase();
|
||||
if (!cmd.equals("op") && !cmd.equals("deop")) return;
|
||||
this.plugin.scheduler().asyncLater(
|
||||
() -> {
|
||||
if (!sender.hasPermission("minecraft.command.op")) return;
|
||||
if (!sender.hasPermission("minecraft.command.deop")) return;
|
||||
String input = command.startsWith("/") ? command.substring(1) : command;
|
||||
int firstSpaceIndex = input.indexOf(' ');
|
||||
String cmdPart = (firstSpaceIndex == -1) ? input : input.substring(0, firstSpaceIndex);
|
||||
String argPart = (firstSpaceIndex == -1) ? "" : input.substring(firstSpaceIndex + 1).trim();
|
||||
int lastColonIndex = cmdPart.lastIndexOf(':');
|
||||
if (lastColonIndex != -1 && !cmdPart.substring(0, lastColonIndex).equals("minecraft")) return;
|
||||
String cmd = lastColonIndex == -1 ? cmdPart : cmdPart.substring(lastColonIndex + 1);
|
||||
cmd = cmd.toLowerCase();
|
||||
if (!cmd.equals("op") && !cmd.equals("deop")) return;
|
||||
int nextSpaceIndex = argPart.indexOf(' ');
|
||||
String targetName = (nextSpaceIndex == -1) ? argPart : argPart.substring(0, nextSpaceIndex);
|
||||
if (targetName.isEmpty()) return;
|
||||
|
||||
Reference in New Issue
Block a user