mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 02:08:27 +01:00
Simplify teleportation permissions
This commit is contained in:
parent
b188f0d4af
commit
23a434054f
@ -794,11 +794,7 @@ public final class SubCommand extends BukkitCommand {
|
||||
}
|
||||
}
|
||||
} else if (args.length > 0 && (args[0].equalsIgnoreCase("tp") || args[0].equalsIgnoreCase("teleport"))) {
|
||||
if (sender.hasPermission("subservers.request")) {
|
||||
executeTeleport(sender, label, args);
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.request"));
|
||||
}
|
||||
executeTeleport(sender, label, args);
|
||||
} else if (sender.hasPermission("subservers.interface") && sender instanceof Player) {
|
||||
plugin.gui.getRenderer((Player) sender).newUI();
|
||||
} else {
|
||||
@ -809,20 +805,20 @@ public final class SubCommand extends BukkitCommand {
|
||||
}
|
||||
private void executeTeleport(CommandSender sender, String label, String[] args) {
|
||||
if (args.length > ((sender instanceof Player)?1:2)) {
|
||||
String select = args[(args.length > 2)?2:1];
|
||||
plugin.api.getServer(select, server -> {
|
||||
if (server != null) {
|
||||
if (permits(server, sender, "subservers.server.%.*", "subservers.server.%.teleport")) {
|
||||
if (sender.hasPermission("subservers.teleport")) {
|
||||
String select = args[(args.length > 2)?2:1];
|
||||
plugin.api.getServer(select, server -> {
|
||||
if (server != null) {
|
||||
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) {
|
||||
Player target = (args.length > 2)?Bukkit.getPlayer(args[1]):null;
|
||||
if (target != null || args.length == 2) {
|
||||
if (target == null || target == sender || permits(server, sender, "subservers.server.%.*", "subservers.server.%.teleport-others")) {
|
||||
if (target == null || target == sender || sender.hasPermission("subservers.teleport-others")) {
|
||||
if (target == null) target = (Player) sender;
|
||||
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Teleport").replace("$str$", target.getName()));
|
||||
plugin.pmc(target, "Connect", server.getName());
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.server." + server.getName() + ".teleport-others"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.teleport-others"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Unknown-Player").replace("$str$", args[1]));
|
||||
@ -831,12 +827,12 @@ public final class SubCommand extends BukkitCommand {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Teleport.Not-Running").replace("$str$", server.getName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Select-Permission").replace("$str$", server.getName()));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", select));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", select));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.teleport"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Usage").replace("$str$", label.toLowerCase() + " " + args[0].toLowerCase() + " " + ((sender instanceof Player)?"[Player]":"<Player>") + " <Server>"));
|
||||
}
|
||||
|
@ -6,70 +6,63 @@ softdepend: [TitleManager, PlaceholderAPI]
|
||||
website: "https://github.com/ME1312/SubServers-2"
|
||||
#commands:
|
||||
# subservers:
|
||||
# description: 'The SubServers Command'
|
||||
# usage: '/subservers is currently unavailable'
|
||||
# description: "The SubServers Command"
|
||||
# usage: "/subservers is currently unavailable"
|
||||
# subserver:
|
||||
# description: 'The SubServers Command'
|
||||
# usage: '/subserver is currently unavailable'
|
||||
# description: "The SubServers Command"
|
||||
# usage: "/subserver is currently unavailable"
|
||||
# sub:
|
||||
# description: 'The SubServers Command'
|
||||
# usage: '/sub is currently unavailable'
|
||||
# description: "The SubServers Command"
|
||||
# usage: "/sub is currently unavailable"
|
||||
permissions:
|
||||
subservers.*:
|
||||
description: 'Grants Access to to Everything in SubServers.Client'
|
||||
description: "Access everything in SubServers.Client"
|
||||
default: op
|
||||
children:
|
||||
subservers.interface:
|
||||
description: 'Grants Access to the SubServers Interface'
|
||||
description: "Access to the SubServers Interface"
|
||||
default: op
|
||||
subservers.command:
|
||||
description: 'Grants Access to the SubServers Command'
|
||||
description: "Access to the SubServers Command"
|
||||
default: op
|
||||
children:
|
||||
subservers.teleport:
|
||||
description: "Access to SubServers' Teleport Command"
|
||||
default: op
|
||||
subservers.teleport-others:
|
||||
description: "Access to Teleport other players using the Teleport Command"
|
||||
default: op
|
||||
subservers.host.*:
|
||||
description: 'Grants Access to all Host Actions on all Hosts'
|
||||
description: "Access to all Host Actions on all Hosts"
|
||||
default: op
|
||||
children:
|
||||
subservers.host.*.*:
|
||||
description: 'Grants Access to all Host Actions on all Hosts'
|
||||
description: "Access to all Host Actions on all Hosts"
|
||||
default: op
|
||||
children:
|
||||
subservers.host.*.create:
|
||||
description: 'Grants Access to Create a SubServer on all Hosts'
|
||||
description: "Access to Create a Subserver on all Hosts"
|
||||
default: op
|
||||
subservers.subserver.*:
|
||||
description: 'Grants Access to all SubServer Actions on all SubServers'
|
||||
description: "Access to all Subserver Actions on all Subservers"
|
||||
default: op
|
||||
children:
|
||||
subservers.subserver.*.*:
|
||||
description: 'Grants Access to all SubServer Actions on all SubServers'
|
||||
description: "Access to all Subserver Actions on all Subservers"
|
||||
default: op
|
||||
children:
|
||||
subservers.subserver.*.start:
|
||||
description: 'Grants Access to Start all SubServers'
|
||||
description: "Access to Start all Subservers"
|
||||
default: op
|
||||
subservers.subserver.*.stop:
|
||||
description: 'Grants Access to Stop all SubServers'
|
||||
description: "Access to Stop all Subservers"
|
||||
default: op
|
||||
subservers.subserver.*.terminate:
|
||||
description: 'Grants Access to Terminate all SubServers'
|
||||
description: "Access to Terminate all Subservers"
|
||||
default: op
|
||||
subservers.subserver.*.command:
|
||||
description: 'Grants Access to Send Commands to all SubServers'
|
||||
description: "Access to Send Commands to all Subservers"
|
||||
default: op
|
||||
subservers.subserver.*.update:
|
||||
description: 'Grants Access to Update all SubServers'
|
||||
default: op
|
||||
subservers.server.*:
|
||||
description: 'Grants Access to Server Actions on all Servers'
|
||||
default: op
|
||||
children:
|
||||
subservers.server.*.*:
|
||||
description: 'Grants Access to Server Actions on all Servers'
|
||||
default: op
|
||||
children:
|
||||
subservers.server.*.teleport:
|
||||
description: 'Grants Access to Teleport to any Server'
|
||||
default: op
|
||||
subservers.server.*.teleport-others:
|
||||
description: 'Grants Access to Teleport Others to any Server'
|
||||
description: "Access to Update all Subservers"
|
||||
default: op
|
@ -1136,7 +1136,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
|
||||
public final class TELEPORT implements CommandExecutor {
|
||||
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
|
||||
if (canRun(sender, true) && (sender.hasPermission("subservers.command") || sender.hasPermission("subservers.request"))) {
|
||||
if (canRun(sender, true)) {
|
||||
Optional<String> p = args.getOne(Text.of("Player"));
|
||||
Optional<String> s = args.getOne(Text.of("Server"));
|
||||
if (!s.isPresent()) {
|
||||
@ -1146,20 +1146,20 @@ public final class SubCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (s.isPresent() && (p.isPresent() || sender instanceof Player)) {
|
||||
String name = (p.isPresent())?p.get():null;
|
||||
String select = s.get();
|
||||
plugin.api.getServer(select, server -> {
|
||||
if (server != null) {
|
||||
if (permits(server, sender, "subservers.server.%.*", "subservers.server.%.teleport")) {
|
||||
if (sender.hasPermission("subservers.command") || sender.hasPermission("subservers.teleport")) {
|
||||
String name = (p.isPresent())?p.get():null;
|
||||
String select = s.get();
|
||||
plugin.api.getServer(select, server -> {
|
||||
if (server != null) {
|
||||
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) {
|
||||
Value<Boolean> msg = new Container<>(false);
|
||||
Callback<Player> action = target -> {
|
||||
if (target == sender || permits(server, sender, "subservers.server.%.*", "subservers.server.%.teleport-others")) {
|
||||
if (target == sender || sender.hasPermission("subservers.teleport-others")) {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Teleport").replace("$str$", target.getName())));
|
||||
plugin.pmc(target, "Connect", server.getName());
|
||||
} else if (!msg.value()) {
|
||||
msg.value(true);
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.server." + server.getName() + ".teleport-others")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.teleport-others")));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1184,13 +1184,14 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Teleport.Not-Running").replace("$str$", server.getName())));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Select-Permission").replace("$str$", server.getName())));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", select)));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", select)));
|
||||
}
|
||||
});
|
||||
return CommandResult.builder().successCount(1).build();
|
||||
});
|
||||
return CommandResult.builder().successCount(1).build();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.teleport")));
|
||||
return CommandResult.builder().successCount(0).build();
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Generic.Usage").replace("$str$", "/sub teleport " + ((sender instanceof Player)?"[Player]":"<Player>") + " <Server>")));
|
||||
return CommandResult.builder().successCount(0).build();
|
||||
|
Loading…
Reference in New Issue
Block a user