Fixed permissions surrounding /portal warp

This commit is contained in:
Sekwah 2020-06-21 03:18:26 +01:00
parent 6c9eeb06d0
commit 4012e9bc01
3 changed files with 111 additions and 98 deletions

View File

@ -62,39 +62,45 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
Player player = (Player) sender;
PlayerInventory inventory = player.getInventory();
if(args.length > 0) {
if(args[0].equalsIgnoreCase("warp") && player.hasPermission("advancedportals.warp")) {
if (args.length == 2 && (player.hasPermission("advancedportals.warp.*")
|| player.hasPermission("advancedportals.warp." + args[1]))) {
AdvancedPortal portal = Portal.getPortal(args[1]);
if(portal == null) {
sender.sendMessage(PluginMessages.customPrefixFail
+ " Could not find a portal with that name");
}
else {
if (portal.inPortal.contains(player.getUniqueId()))
return true;
WarpEvent warpEvent = new WarpEvent(player, portal);
plugin.getServer().getPluginManager().callEvent(warpEvent);
if (!warpEvent.isCancelled()) {
Portal.activate(player, portal, false);
return true;
}
}
} else if (args.length == 1 && player.hasPermission("advancedportals.warp")) {
sendMenu(player, "Help Menu: Warp",
"\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name");
}
else {
sender.sendMessage(PluginMessages.customPrefixFail
+ " You do not have permission to perform that command");
}
return true;
}
}
if (sender.hasPermission("advancedportals.portal")) {
if (args.length > 0) {
switch (args[0].toLowerCase()) {
case "warp":
if (args.length == 2 && (player.hasPermission("advancedportals.warp.*") || player.hasPermission("advancedportals.warp." + args[1]))) {
AdvancedPortal portal = Portal.getPortal(args[1]);
if(portal == null) {
sender.sendMessage(PluginMessages.customPrefixFail
+ " Could not find a portal with that name");
}
else {
if (portal.inPortal.contains(player.getUniqueId()))
return true;
WarpEvent warpEvent = new WarpEvent(player, portal);
plugin.getServer().getPluginManager().callEvent(warpEvent);
if (!warpEvent.isCancelled()) {
Portal.activate(player, portal);
}
}
} else if (args.length == 1 && player.hasPermission("advancedportals.portal.warp")) {
sendMenu(player, "Help Menu: Warp",
"\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name");
}
else {
sender.sendMessage(PluginMessages.customPrefixFail
+ " You do not have permission");
}
break;
case "disablebeacon":
boolean DISABLE_BEACON = config.getConfig().getBoolean("DisableGatewayBeam", true);
if (player.hasPermission("advancedportals.build") && DISABLE_BEACON) {
if (player.hasPermission("advancedportals.build")) {
if(args.length == 1) {
sender.sendMessage(PluginMessages.customPrefixFail
+ " You need to specify a portal to replace the blocks.");
@ -113,16 +119,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
}
}
else {
if(DISABLE_BEACON) {
}
else {
}
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission " +
"to do that." + " Needed: \u00A7eadvancedportals.build");
}
break;
case "wand":
case "selector":
@ -847,11 +843,14 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if(args.length == 1 && (sender.hasPermission("advancedportals.warp"))) {
autoComplete.add("warp");
}
if (sender.hasPermission("advancedportals.createportal")) {
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command",
"selector", "show", "gatewayblock", "endportalblock", "variables", "wand", "disablebeacon", "remove", "rename",
"help", "bukkitpage", "helppage", "warp"));
"help", "bukkitpage", "helppage"));
} else if (args[0].toLowerCase().equals("create")) {
boolean hasName = false;
@ -936,7 +935,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (args.length == 2 && (args[0].equalsIgnoreCase("warp"))) {
for (AdvancedPortal portal : Portal.portals) {
String perm = portal.getArg("permission");
if (perm == null || sender.hasPermission(perm)) {
if ((perm == null || sender.hasPermission(perm))
&& (sender.hasPermission("advancedportals.warp.*")
|| sender.hasPermission("advancedportals.warp." + portal.getName()))) {
autoComplete.add(portal.getName());
}
}

View File

@ -405,7 +405,7 @@ public class Portal {
return false;
}
public static boolean activate(Player player, AdvancedPortal portal) {
public static boolean activate(Player player, AdvancedPortal portal, boolean doKnockback) {
if (blockSpectatorMode && player.getGameMode() == GameMode.SPECTATOR) {
player.sendMessage(
@ -419,7 +419,8 @@ public class Portal {
player.sendMessage(
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
failSound(player, portal);
throwPlayerBack(player);
if(doKnockback)
throwPlayerBack(player);
return false;
}
@ -430,7 +431,8 @@ public class Portal {
int time = (joinCooldownDelay - diff);
player.sendMessage(ChatColor.RED + "There is " + ChatColor.YELLOW + time + ChatColor.RED + (time == 1 ? " second" : " seconds") + " join cooldown protection left.");
failSound(player, portal);
throwPlayerBack(player);
if(doKnockback)
throwPlayerBack(player);
return false;
}
joinCooldown.remove(player.getName());
@ -451,7 +453,8 @@ public class Portal {
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + time + ChatColor.RED
+ (time == 1 ? " second" : " seconds") + " until attempting to enter this portal again.");
failSound(player, portal);
throwPlayerBack(player);
if(doKnockback)
throwPlayerBack(player);
return false;
}
}
@ -509,7 +512,8 @@ public class Portal {
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
warped = Destination.warp(player, portal.getDestiation(), hasMessage);
if (!warped) {
throwPlayerBack(player);
if(doKnockback)
throwPlayerBack(player);
}
}
} else {
@ -518,7 +522,8 @@ public class Portal {
+ "\u00A7c The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.getName() + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
throwPlayerBack(player);
if(doKnockback)
throwPlayerBack(player);
failSound(player, portal);
}
}
@ -692,4 +697,8 @@ public class Portal {
public static int getPortalProtectionRadius() {
return portalProtectionRadius;
}
public static boolean activate(Player player, AdvancedPortal portal) {
return activate(player, portal, true);
}
}

View File

@ -5,55 +5,58 @@ author: sekwah41
description: An advanced portals plugin for bukkit.
api-version: 1.13
commands:
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal, ap]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal, ap]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
permissions:
advancedportals.*:
description: Gives access to all commands
default: op
children:
advancedportals.createportal: true
advancedportals.portal: true
advancedportals.build: true
advancedportals.desti: true
advancedportals.createportal:
description: Allows you to create portals
default: op
advancedportals.createportal.commandlevel.*:
description: Gives access to all level raisers
default: false
children:
advancedportals.createportal.commandlevel.op: true
advancedportals.createportal.commandlevel.bungee: true
advancedportals.createportal.commandlevel.perms: true
advancedportals.createportal.commandlevel.console: true
advancedportals.createportal.commandlevel.op:
description: Allows you to run portal commands as op
default: false
advancedportals.createportal.commandlevel.perms:
description: Allows you to run portal commands with * permission
default: false
advancedportals.createportal.commandlevel.bungee:
description: Allows you to run portal commands through bungee
default: false
advancedportals.createportal.commandlevel.console:
description: Executes command in the console
default: false
advancedportals.portal:
description: Allows use of portal commands
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti:
description: Gives access to all desti commands
default: op
advancedportals.warp.*:
description: Access to all warps
default: op
advancedportals.*:
description: Gives access to all commands
default: op
children:
advancedportals.createportal: true
advancedportals.portal: true
advancedportals.build: true
advancedportals.desti: true
advancedportals.createportal:
description: Allows you to create portals
default: op
advancedportals.createportal.commandlevel.*:
description: Gives access to all level raisers
default: false
children:
advancedportals.createportal.commandlevel.op: true
advancedportals.createportal.commandlevel.bungee: true
advancedportals.createportal.commandlevel.perms: true
advancedportals.createportal.commandlevel.console: true
advancedportals.createportal.commandlevel.op:
description: Allows you to run portal commands as op
default: false
advancedportals.createportal.commandlevel.perms:
description: Allows you to run portal commands with * permission
default: false
advancedportals.createportal.commandlevel.bungee:
description: Allows you to run portal commands through bungee
default: false
advancedportals.createportal.commandlevel.console:
description: Executes command in the console
default: false
advancedportals.portal:
description: Allows use of portal commands
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti:
description: Gives access to all desti commands
default: op
advancedportals.warp:
description: Access to the warp command
default: op
advancedportals.warp.*:
description: Access to all warps
default: op