awarp is now an alias of destination and destination permissions

This commit is contained in:
Max Qian 2016-08-02 16:54:15 -07:00
parent fa9c1bdf9e
commit 80fcd96ba7
5 changed files with 34 additions and 94 deletions

View File

@ -10,10 +10,7 @@ commands:
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
awarp:
description: Used to warp to destinations.
aliases: [desti, awarp]
usage: /<command>
permissions:
advancedportals.*:
@ -22,7 +19,8 @@ permissions:
advancedportals.createportal: true
advancedportals.portal: true
advancedportals.build: true
advancedportals.desti.*: true
advancedportals.desti: true
advancedportals.warp.*: true
advancedportals.createportal:
description: Allows you to create portals
default: op
@ -32,10 +30,9 @@ permissions:
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti.*:
advancedportals.desti:
description: Gives access to all desti commands
children:
advancedportals.desti.create: true
advancedportals.desti.create:
description: Allows users to create portal destinations
default: op
advancedportals.warp.*:
description: Access to all warps
default: true

View File

@ -56,7 +56,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
new PluginMessages(this);
new AdvancedPortalsCommand(this);
new DestinationCommand(this);
new WarpCommand(this);
new WarpEffects(this);

View File

@ -108,6 +108,10 @@ public class Destination {
}
public static boolean warp(Player player, String name) {
if (!player.hasPermission("advancedportals.warp.*") && !player.hasPermission("advancedportals.warp." + name)) {
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to warp to " + name + "!");
return false;
}
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
if (config.getConfig().getString(name + ".world") != null) {
Location loc = player.getLocation();

View File

@ -30,7 +30,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
if (args.length > 0) { switch (args[0].toLowerCase()) {
case "create":
if (sender.hasPermission("advancedportals.desti.create")) {
if (sender.hasPermission("advancedportals.desti")) {
if (args.length > 1) {
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
if (posX == null) {
@ -44,29 +44,25 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(PluginMessages.customPrefixFail + " Please state the name of the destination you would like to create!");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to create portals so you cannot give yourself a \u00A7ePortal Region Selector\u00A7c!");
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to create destinations!");
}
break;
case "remove":
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "destinations.yml");
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
if (posX != null) {
Destination.remove(args[1]);
sender.sendMessage(PluginMessages.customPrefixFail + " The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
if (sender.hasPermission("advancedportals.desti")) {
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
if (posX != null) {
Destination.remove(args[1]);
sender.sendMessage(PluginMessages.customPrefixFail + " The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No destination by that name exists.");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No destination by that name exists.");
sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to remove.");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to remove.");
}
break;
case "goto":
case "warp":
if (args.length > 1) {
Destination.warp((Player) sender, args[1]);
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to warp to.");
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to remove destinations!");
}
break;
case "list":
@ -74,6 +70,9 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
for (String desti : config.getConfig().getKeys(false)) message = message + " " + desti;
sender.sendMessage(message);
break;
default:
Destination.warp((Player) sender, args[0]);
break;
}
} else {
PluginMessages.UnknownCommand(sender, command);
@ -85,10 +84,14 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if (sender.hasPermission("AdvancedPortals.CreatePortal")) {
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
for (String string : config.getConfig().getKeys(false)) {
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
autoComplete.add(string);
}
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) {
if (args.length == 1) {
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
autoComplete.addAll(Arrays.asList("create", "remove", "help"));
} else if (args[0].toLowerCase().equals("create")) {
}
}

View File

@ -1,63 +0,0 @@
package com.sekwah.advancedportals.destinations;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.LinkedList;
import java.util.List;
public class WarpCommand implements CommandExecutor, TabCompleter {
@SuppressWarnings("unused")
private AdvancedPortalsPlugin plugin;
public WarpCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
boolean useWarpCommand = !config.getConfig().getBoolean("DisableWarpCommand");
//plugin.getCommand("warp").setExecutor(this);
plugin.getCommand("awarp").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if (args.length > 0) {
Destination.warp((Player) sender, args[0]);
} else {
PluginMessages.UnknownCommand(sender, command);
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
/**if(sender.hasPermission("AdvancedPortals.CreatePortal")){
if(args.length == 1){
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
}
}
Collections.sort(autoComplete);
for(Object result: autoComplete.toArray()){
if(!result.toString().startsWith(args[args.length - 1])){
autoComplete.remove(result);
}
}*/
return autoComplete;
}
}