forked from Geoffrey/Geoffrey-MC-Plugin
Added missing file (again)
parent
845630ce9b
commit
4cf8400347
|
@ -0,0 +1,76 @@
|
||||||
|
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.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.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AddOwnerCommand extends GeoffreyCommand {
|
||||||
|
|
||||||
|
public AddOwnerCommand(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 > 1) {
|
||||||
|
String name[] = Arrays.copyOfRange(args, 1, args.length);
|
||||||
|
params.put("location_name", StringUtils.join(name, " "));
|
||||||
|
Player player = ((Player) sender).getPlayer();
|
||||||
|
|
||||||
|
params.put("mc_uuid", player.getUniqueId().toString().replace("-", ""));
|
||||||
|
params.put("new_owner_name", args[0]);
|
||||||
|
RunCommand("add_owner", params, Method.POST , new CommandCallback(sender, args[0]));
|
||||||
|
}
|
||||||
|
else if (args.length < 2) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Too few parameters given.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Console can not add residents!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CommandCallback extends GeoffreyAPICallback {
|
||||||
|
String new_owner_name;
|
||||||
|
|
||||||
|
CommandCallback(CommandSender sender, String new_owner_name) {
|
||||||
|
super(sender);
|
||||||
|
errors.put("OwnerNotFoundError", "Ain't no one in this darn database named " + new_owner_name + "!");
|
||||||
|
errors.put("IsOwnerError", new_owner_name + " is already an owner, stop having amosia.");
|
||||||
|
errors.put("LocationLookUpError", "You do not have a location by that name you ding dong goober.");
|
||||||
|
this.new_owner_name = new_owner_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(String s) {
|
||||||
|
try {
|
||||||
|
JsonElement json = parseJSON(s);
|
||||||
|
GeoffreyLocation location = new GeoffreyLocation(json.getAsJsonObject());
|
||||||
|
|
||||||
|
String msg = ChatColor.GREEN + new_owner_name + " has been added as an owner of " + location.getLocationName();
|
||||||
|
commandSender.sendMessage(msg);
|
||||||
|
}
|
||||||
|
catch (GeoffreyCommandError e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,6 +44,9 @@ public final class GeoffreyMC extends JavaPlugin {
|
||||||
|
|
||||||
AddResidentCommand addResidentCommand = new AddResidentCommand(this);
|
AddResidentCommand addResidentCommand = new AddResidentCommand(this);
|
||||||
this.getCommand("geoffrey_add_resident").setExecutor(addResidentCommand);
|
this.getCommand("geoffrey_add_resident").setExecutor(addResidentCommand);
|
||||||
|
|
||||||
|
AddOwnerCommand addOwnerCommand = new AddOwnerCommand(this);
|
||||||
|
this.getCommand("geoffrey_add_owner").setExecutor(addOwnerCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,15 @@ commands:
|
||||||
permission: geoffrey.add
|
permission: geoffrey.add
|
||||||
usage: /add_item [item name] [amount per price] [price] [shop name]
|
usage: /add_item [item name] [amount per price] [price] [shop name]
|
||||||
geoffrey_add_resident:
|
geoffrey_add_resident:
|
||||||
description: Adds a resident to a tow
|
description: Adds a resident to a town
|
||||||
aliases: [add_resident]
|
aliases: [add_resident]
|
||||||
permission: geoffrey.add
|
permission: geoffrey.add
|
||||||
usage: /add_resident [resident Name] [town name]
|
usage: /add_resident [resident name] [town name]
|
||||||
|
geoffrey_add_owner:
|
||||||
|
description: Adds a new owner to a location
|
||||||
|
aliases: [add_owner]
|
||||||
|
permission: geoffrey.add
|
||||||
|
usage: /add_owner [new owner name] [location name]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
add:
|
add:
|
||||||
|
|
Loading…
Reference in New Issue