mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-09-27 14:52:59 +02:00
Fixed permissions surrounding /portal warp
This commit is contained in:
parent
6c9eeb06d0
commit
4012e9bc01
@ -62,39 +62,45 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerInventory inventory = player.getInventory();
|
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 (sender.hasPermission("advancedportals.portal")) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
switch (args[0].toLowerCase()) {
|
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":
|
case "disablebeacon":
|
||||||
boolean DISABLE_BEACON = config.getConfig().getBoolean("DisableGatewayBeam", true);
|
if (player.hasPermission("advancedportals.build")) {
|
||||||
if (player.hasPermission("advancedportals.build") && DISABLE_BEACON) {
|
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
sender.sendMessage(PluginMessages.customPrefixFail
|
sender.sendMessage(PluginMessages.customPrefixFail
|
||||||
+ " You need to specify a portal to replace the blocks.");
|
+ " 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;
|
break;
|
||||||
case "wand":
|
case "wand":
|
||||||
case "selector":
|
case "selector":
|
||||||
@ -847,11 +843,14 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||||
LinkedList<String> autoComplete = new LinkedList<String>();
|
LinkedList<String> autoComplete = new LinkedList<String>();
|
||||||
|
if(args.length == 1 && (sender.hasPermission("advancedportals.warp"))) {
|
||||||
|
autoComplete.add("warp");
|
||||||
|
}
|
||||||
if (sender.hasPermission("advancedportals.createportal")) {
|
if (sender.hasPermission("advancedportals.createportal")) {
|
||||||
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
|
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
|
||||||
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command",
|
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command",
|
||||||
"selector", "show", "gatewayblock", "endportalblock", "variables", "wand", "disablebeacon", "remove", "rename",
|
"selector", "show", "gatewayblock", "endportalblock", "variables", "wand", "disablebeacon", "remove", "rename",
|
||||||
"help", "bukkitpage", "helppage", "warp"));
|
"help", "bukkitpage", "helppage"));
|
||||||
} else if (args[0].toLowerCase().equals("create")) {
|
} else if (args[0].toLowerCase().equals("create")) {
|
||||||
|
|
||||||
boolean hasName = false;
|
boolean hasName = false;
|
||||||
@ -936,7 +935,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (args.length == 2 && (args[0].equalsIgnoreCase("warp"))) {
|
if (args.length == 2 && (args[0].equalsIgnoreCase("warp"))) {
|
||||||
for (AdvancedPortal portal : Portal.portals) {
|
for (AdvancedPortal portal : Portal.portals) {
|
||||||
String perm = portal.getArg("permission");
|
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());
|
autoComplete.add(portal.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ public class Portal {
|
|||||||
return false;
|
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) {
|
if (blockSpectatorMode && player.getGameMode() == GameMode.SPECTATOR) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
@ -419,7 +419,8 @@ public class Portal {
|
|||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
|
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
|
||||||
failSound(player, portal);
|
failSound(player, portal);
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +431,8 @@ public class Portal {
|
|||||||
int time = (joinCooldownDelay - diff);
|
int time = (joinCooldownDelay - diff);
|
||||||
player.sendMessage(ChatColor.RED + "There is " + ChatColor.YELLOW + time + ChatColor.RED + (time == 1 ? " second" : " seconds") + " join cooldown protection left.");
|
player.sendMessage(ChatColor.RED + "There is " + ChatColor.YELLOW + time + ChatColor.RED + (time == 1 ? " second" : " seconds") + " join cooldown protection left.");
|
||||||
failSound(player, portal);
|
failSound(player, portal);
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
joinCooldown.remove(player.getName());
|
joinCooldown.remove(player.getName());
|
||||||
@ -451,7 +453,8 @@ public class Portal {
|
|||||||
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + time + ChatColor.RED
|
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + time + ChatColor.RED
|
||||||
+ (time == 1 ? " second" : " seconds") + " until attempting to enter this portal again.");
|
+ (time == 1 ? " second" : " seconds") + " until attempting to enter this portal again.");
|
||||||
failSound(player, portal);
|
failSound(player, portal);
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,7 +512,8 @@ public class Portal {
|
|||||||
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
|
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
|
||||||
warped = Destination.warp(player, portal.getDestiation(), hasMessage);
|
warped = Destination.warp(player, portal.getDestiation(), hasMessage);
|
||||||
if (!warped) {
|
if (!warped) {
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -518,7 +522,8 @@ public class Portal {
|
|||||||
+ "\u00A7c The portal you are trying to use doesn't have a destination!");
|
+ "\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 "
|
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!");
|
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
failSound(player, portal);
|
failSound(player, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,4 +697,8 @@ public class Portal {
|
|||||||
public static int getPortalProtectionRadius() {
|
public static int getPortalProtectionRadius() {
|
||||||
return portalProtectionRadius;
|
return portalProtectionRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean activate(Player player, AdvancedPortal portal) {
|
||||||
|
return activate(player, portal, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,55 +5,58 @@ author: sekwah41
|
|||||||
description: An advanced portals plugin for bukkit.
|
description: An advanced portals plugin for bukkit.
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
advancedportals:
|
advancedportals:
|
||||||
description: The main command for the advanced portals
|
description: The main command for the advanced portals
|
||||||
aliases: [portals, aportals, portal, ap]
|
aliases: [portals, aportals, portal, ap]
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
destination:
|
destination:
|
||||||
description: Can be used to access portal destinations.
|
description: Can be used to access portal destinations.
|
||||||
aliases: [desti]
|
aliases: [desti]
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
permissions:
|
permissions:
|
||||||
advancedportals.*:
|
advancedportals.*:
|
||||||
description: Gives access to all commands
|
description: Gives access to all commands
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
advancedportals.createportal: true
|
advancedportals.createportal: true
|
||||||
advancedportals.portal: true
|
advancedportals.portal: true
|
||||||
advancedportals.build: true
|
advancedportals.build: true
|
||||||
advancedportals.desti: true
|
advancedportals.desti: true
|
||||||
advancedportals.createportal:
|
advancedportals.createportal:
|
||||||
description: Allows you to create portals
|
description: Allows you to create portals
|
||||||
default: op
|
default: op
|
||||||
advancedportals.createportal.commandlevel.*:
|
advancedportals.createportal.commandlevel.*:
|
||||||
description: Gives access to all level raisers
|
description: Gives access to all level raisers
|
||||||
default: false
|
default: false
|
||||||
children:
|
children:
|
||||||
advancedportals.createportal.commandlevel.op: true
|
advancedportals.createportal.commandlevel.op: true
|
||||||
advancedportals.createportal.commandlevel.bungee: true
|
advancedportals.createportal.commandlevel.bungee: true
|
||||||
advancedportals.createportal.commandlevel.perms: true
|
advancedportals.createportal.commandlevel.perms: true
|
||||||
advancedportals.createportal.commandlevel.console: true
|
advancedportals.createportal.commandlevel.console: true
|
||||||
advancedportals.createportal.commandlevel.op:
|
advancedportals.createportal.commandlevel.op:
|
||||||
description: Allows you to run portal commands as op
|
description: Allows you to run portal commands as op
|
||||||
default: false
|
default: false
|
||||||
advancedportals.createportal.commandlevel.perms:
|
advancedportals.createportal.commandlevel.perms:
|
||||||
description: Allows you to run portal commands with * permission
|
description: Allows you to run portal commands with * permission
|
||||||
default: false
|
default: false
|
||||||
advancedportals.createportal.commandlevel.bungee:
|
advancedportals.createportal.commandlevel.bungee:
|
||||||
description: Allows you to run portal commands through bungee
|
description: Allows you to run portal commands through bungee
|
||||||
default: false
|
default: false
|
||||||
advancedportals.createportal.commandlevel.console:
|
advancedportals.createportal.commandlevel.console:
|
||||||
description: Executes command in the console
|
description: Executes command in the console
|
||||||
default: false
|
default: false
|
||||||
advancedportals.portal:
|
advancedportals.portal:
|
||||||
description: Allows use of portal commands
|
description: Allows use of portal commands
|
||||||
default: op
|
default: op
|
||||||
advancedportals.build:
|
advancedportals.build:
|
||||||
description: Allows you to build in the portal regions
|
description: Allows you to build in the portal regions
|
||||||
default: op
|
default: op
|
||||||
advancedportals.desti:
|
advancedportals.desti:
|
||||||
description: Gives access to all desti commands
|
description: Gives access to all desti commands
|
||||||
default: op
|
default: op
|
||||||
advancedportals.warp.*:
|
advancedportals.warp:
|
||||||
description: Access to all warps
|
description: Access to the warp command
|
||||||
default: op
|
default: op
|
||||||
|
advancedportals.warp.*:
|
||||||
|
description: Access to all warps
|
||||||
|
default: op
|
||||||
|
Loading…
Reference in New Issue
Block a user