diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/AddOwnerCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/AddOwnerCommand.java index 477b728..b9683ec 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/AddOwnerCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/AddOwnerCommand.java @@ -43,7 +43,7 @@ public class AddOwnerCommand extends GeoffreyCommand { } } else { - sender.sendMessage(ChatColor.RED + "Console can not add residents!"); + sender.sendMessage(ChatColor.RED + "Console can not add owners!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/AddResourceCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/AddResourceCommand.java index 63f8090..bcdbf1c 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/AddResourceCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/AddResourceCommand.java @@ -57,7 +57,7 @@ public class AddResourceCommand extends GeoffreyCommand { } else { - sender.sendMessage(ChatColor.RED + "Console can not add items!"); + sender.sendMessage(ChatColor.RED + "Console can not add resources!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/AddTunnelCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/AddTunnelCommand.java index 99a0d30..487b52d 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/AddTunnelCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/AddTunnelCommand.java @@ -58,7 +58,7 @@ public class AddTunnelCommand extends GeoffreyCommand { } else { - sender.sendMessage(ChatColor.RED + "Console can not add items!"); + sender.sendMessage(ChatColor.RED + "Console can not add tunnels!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteCommand.java index 71157ee..f5311e2 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteCommand.java @@ -39,7 +39,7 @@ public class DeleteCommand extends GeoffreyCommand { RunCommand("delete", params, Method.POST , new CommandCallback(sender, locationNmae)); } else { - sender.sendMessage(ChatColor.RED + "Console can not add locations!"); + sender.sendMessage(ChatColor.RED + "Console can not delete locations!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteItemCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteItemCommand.java index 4ceaa81..68247ee 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteItemCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteItemCommand.java @@ -58,7 +58,7 @@ public class DeleteItemCommand extends GeoffreyCommand { } else { - sender.sendMessage(ChatColor.RED + "Console can not add items!"); + sender.sendMessage(ChatColor.RED + "Console can not remove items!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteResourceCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteResourceCommand.java index c71dac3..53aada9 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteResourceCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/DeleteResourceCommand.java @@ -61,7 +61,7 @@ public class DeleteResourceCommand extends GeoffreyCommand { } else { - sender.sendMessage(ChatColor.RED + "Console can not add items!"); + sender.sendMessage(ChatColor.RED + "Console can not remove reosurces!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/EditNameCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/EditNameCommand.java index 9caa4f4..e23e44a 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/EditNameCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/EditNameCommand.java @@ -53,7 +53,7 @@ public class EditNameCommand extends GeoffreyCommand { RunCommand("edit_name", params, Method.POST , new CommandCallback(sender, oldLocationName, newLocationName)); } else { - sender.sendMessage(ChatColor.RED + "Console can not add locations!"); + sender.sendMessage(ChatColor.RED + "Console can not edit locations!"); } return true; diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java new file mode 100644 index 0000000..916186c --- /dev/null +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java @@ -0,0 +1,70 @@ +package com.zerohighdef.geoffrey.Commands; + +import com.google.gson.JsonElement; +import com.zerohighdef.geoffrey.GeoffreyMC; +import com.zerohighdef.geoffrey.Models.GeoffreyLocation; +import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback; +import com.zerohighdef.geoffrey.Objects.GeoffreyCommand; +import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError; +import org.apache.commons.lang.StringUtils; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +public class EditPosCommand extends GeoffreyCommand { + public EditPosCommand(GeoffreyMC plugin) { + super(plugin); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if ((sender instanceof Player)) { + Map params = new HashMap(); + + if (args.length == 0) { + sender.sendMessage(ChatColor.RED + "Location name required!"); + return false; + } + + Player player = ((Player) sender).getPlayer(); + String locationName = StringUtils.join(args, " "); + params.put("loc_name", locationName); + params.put("mc_uuid", ((Player) sender).getUniqueId().toString().replace("-", "")); + params.put("x", Integer.toString(player.getLocation().getBlockX())); + params.put("z", Integer.toString(player.getLocation().getBlockZ())); + RunCommand("edit_pos", params, Method.POST , new CommandCallback(sender, locationName)); + } + else { + sender.sendMessage(ChatColor.RED + "Console can not add locations!"); + } + + return true; + } + + private class CommandCallback extends GeoffreyAPICallback { + + CommandCallback(CommandSender sender, String locationName) { + super(sender); + errors.put("LocationLookUpError", "You do not have a location by the name " + locationName + "."); + } + + @Override + public void invoke(String s) { + try { + JsonElement json = parseJSON(s); + + GeoffreyLocation location = new GeoffreyLocation(json.getAsJsonObject()); + String msg = ChatColor.GREEN + location.getLocationName() + " has been moved!"; + commandSender.sendMessage(msg); + } + catch (GeoffreyCommandError e) { + return; + } + } + } +} diff --git a/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java b/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java index ce648ac..8bf988e 100644 --- a/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java +++ b/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java @@ -67,6 +67,9 @@ public final class GeoffreyMC extends JavaPlugin { EditNameCommand editNameCommand = new EditNameCommand(this); this.getCommand("geoffrey_edit_name").setExecutor(editNameCommand); + + EditPosCommand editPosCommand = new EditPosCommand(this); + this.getCommand("geoffrey_edit_pos").setExecutor(editPosCommand); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5095682..4acf84f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -96,6 +96,11 @@ commands: aliases: [edit_name] permission: geoffrey.add usage: /edit_name [new name] [old name] + geoffrey_edit_pos: + description: Moves a location to your current position in Geoffrey + aliases: [edit_pos] + permission: geoffrey.add + usage: /edit_pos [location name] permissions: add: