parent
f59072d534
commit
7ecdb7b283
|
@ -43,7 +43,7 @@ public class AddOwnerCommand extends GeoffreyCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add residents!");
|
sender.sendMessage(ChatColor.RED + "Console can not add owners!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class AddResourceCommand extends GeoffreyCommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add items!");
|
sender.sendMessage(ChatColor.RED + "Console can not add resources!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class AddTunnelCommand extends GeoffreyCommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add items!");
|
sender.sendMessage(ChatColor.RED + "Console can not add tunnels!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DeleteCommand extends GeoffreyCommand {
|
||||||
RunCommand("delete", params, Method.POST , new CommandCallback(sender, locationNmae));
|
RunCommand("delete", params, Method.POST , new CommandCallback(sender, locationNmae));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add locations!");
|
sender.sendMessage(ChatColor.RED + "Console can not delete locations!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class DeleteItemCommand extends GeoffreyCommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add items!");
|
sender.sendMessage(ChatColor.RED + "Console can not remove items!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class DeleteResourceCommand extends GeoffreyCommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add items!");
|
sender.sendMessage(ChatColor.RED + "Console can not remove reosurces!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class EditNameCommand extends GeoffreyCommand {
|
||||||
RunCommand("edit_name", params, Method.POST , new CommandCallback(sender, oldLocationName, newLocationName));
|
RunCommand("edit_name", params, Method.POST , new CommandCallback(sender, oldLocationName, newLocationName));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(ChatColor.RED + "Console can not add locations!");
|
sender.sendMessage(ChatColor.RED + "Console can not edit locations!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -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<String, String> params = new HashMap<String, String>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,6 +67,9 @@ public final class GeoffreyMC extends JavaPlugin {
|
||||||
|
|
||||||
EditNameCommand editNameCommand = new EditNameCommand(this);
|
EditNameCommand editNameCommand = new EditNameCommand(this);
|
||||||
this.getCommand("geoffrey_edit_name").setExecutor(editNameCommand);
|
this.getCommand("geoffrey_edit_name").setExecutor(editNameCommand);
|
||||||
|
|
||||||
|
EditPosCommand editPosCommand = new EditPosCommand(this);
|
||||||
|
this.getCommand("geoffrey_edit_pos").setExecutor(editPosCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,11 @@ commands:
|
||||||
aliases: [edit_name]
|
aliases: [edit_name]
|
||||||
permission: geoffrey.add
|
permission: geoffrey.add
|
||||||
usage: /edit_name [new name] [old name]
|
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:
|
permissions:
|
||||||
add:
|
add:
|
||||||
|
|
Loading…
Reference in New Issue