forked from Geoffrey/Geoffrey-MC-Plugin
parent
d764c31208
commit
e56518431e
|
@ -60,7 +60,7 @@ public class AddLocationCommand extends GeoffreyCommand {
|
|||
JsonElement json = parseJSON(s);
|
||||
|
||||
GeoffreyLocation location = new GeoffreyLocation(json.getAsJsonObject());
|
||||
String msg = ChatColor.GREEN + location.getLocationName() + " has been added to Geoffrey";
|
||||
String msg = ChatColor.GREEN + location.getLocationName() + " has been added to Geoffrey.";
|
||||
commandSender.sendMessage(msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class AddOwnerCommand extends GeoffreyCommand {
|
|||
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();
|
||||
String msg = ChatColor.GREEN + new_owner_name + " has been added as an owner of " + location.getLocationName() + ".";
|
||||
commandSender.sendMessage(msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class AddResidentCommand extends GeoffreyCommand {
|
|||
try {
|
||||
JsonElement json = parseJSON(s);
|
||||
|
||||
String msg = ChatColor.GREEN + newResidentName + "has been added to your town";
|
||||
String msg = ChatColor.GREEN + newResidentName + "has been added to your town.";
|
||||
commandSender.sendMessage(msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class AddTunnelCommand extends GeoffreyCommand {
|
|||
|
||||
CommandCallback(CommandSender sender, String tunnelDirection) {
|
||||
super(sender);
|
||||
errors.put("InvalidTunnelError", tunnelDirection + " is not a valid tunnel direction ya gub");
|
||||
errors.put("InvalidTunnelError", tunnelDirection + " is not a valid tunnel direction ya gub.");
|
||||
errors.put("LocationLookUpError", "You do not have a location by that name, goober.");
|
||||
errors.put("EntryNameNotUniqueError", "You have more than one location. Please specify a name, dingus.");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class EditNameCommand extends GeoffreyCommand {
|
|||
|
||||
CommandCallback(CommandSender sender, String oldLocationName, String newLocationName) {
|
||||
super(sender);
|
||||
errors.put("EntryNameNotUniqueError", "A location is already called " + newLocationName + " you ding dong goober");
|
||||
errors.put("EntryNameNotUniqueError", "A location is already called " + newLocationName + " you ding dong goober.");
|
||||
errors.put("LocationLookUpError", "You do not have a location by the name " + oldLocationName + " you ding dong goober.");
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FindCommand extends GeoffreyCommand {
|
|||
|
||||
CommandCallback(CommandSender sender, String locationName) {
|
||||
super(sender);
|
||||
errors.put("LocationLookUpError", "There are no locations that match " + locationName);
|
||||
errors.put("LocationLookUpError", "There are no locations that match " + locationName + ".");
|
||||
this.locationName = locationName;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FindFarmCommand extends GeoffreyCommand {
|
|||
CommandCallback(CommandSender sender, String resourceName) {
|
||||
super(sender);
|
||||
this.resourceName = resourceName;
|
||||
errors.put("ResourceNotFoundError", "No farms found that produce " + this.resourceName);
|
||||
errors.put("ResourceNotFoundError", "No farms found that produce " + this.resourceName + ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,7 @@ public class InfoCommand extends GeoffreyCommand {
|
|||
|
||||
CommandCallback(CommandSender sender, String locationName) {
|
||||
super(sender);
|
||||
errors.put("LocationLookUpError", "There are no locations that match " + locationName);
|
||||
errors.put("LocationLookUpError", "There are no locations that match " + locationName + ".");
|
||||
this.locationName = locationName;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class LocationsCommand extends GeoffreyCommand {
|
|||
RunCommand("me", params, Method.GET, new CommandCallback(sender));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "Console does not have locations ");
|
||||
sender.sendMessage(ChatColor.RED + "Console cannot have locations.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class RemoveResidentCommand extends GeoffreyCommand {
|
|||
try {
|
||||
JsonElement json = parseJSON(s);
|
||||
|
||||
String msg = ChatColor.GREEN + residentName + "has been removed from your town";
|
||||
String msg = ChatColor.GREEN + residentName + "has been removed from your town.";
|
||||
commandSender.sendMessage(msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package com.zerohighdef.geoffrey.Commands;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.zerohighdef.geoffrey.GeoffreyMC;
|
||||
import com.zerohighdef.geoffrey.Models.GeoffreyItemListing;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyCommand;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyUtil;
|
||||
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.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RestockCommand extends GeoffreyCommand {
|
||||
public RestockCommand(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>();
|
||||
List<String> parsedArgs;
|
||||
|
||||
try {
|
||||
parsedArgs = GeoffreyUtil.parseArgs(args);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parsedArgs.size() > 1) {
|
||||
String name = StringUtils.join(parsedArgs.subList(1, parsedArgs.size()), " ");
|
||||
params.put("shop_name", name);
|
||||
}
|
||||
else if (parsedArgs.size() < 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Too few parameters given.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = ((Player) sender).getPlayer();
|
||||
|
||||
String itemName = parsedArgs.get(0);
|
||||
|
||||
|
||||
params.put("mc_uuid", player.getUniqueId().toString().replace("-", ""));
|
||||
params.put("item_name", itemName);
|
||||
RunCommand("restock", params, Method.POST , new CommandCallback(sender, itemName));
|
||||
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "Console can not restock items!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class CommandCallback extends GeoffreyAPICallback {
|
||||
|
||||
CommandCallback(CommandSender sender, String itemName) {
|
||||
super(sender);
|
||||
errors.put( "ItemNotFound", "that shop does not have " + itemName + " in its inventory");
|
||||
errors.put("LocationLookUpError", "You do not have a shop by that name, goober.");
|
||||
errors.put("EntryNameNotUniqueError", "You have more than one location. Please specify a name, dingus.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String s) {
|
||||
try {
|
||||
JsonElement json = parseJSON(s);
|
||||
|
||||
GeoffreyItemListing itemListing = new GeoffreyItemListing(json.getAsJsonArray().get(0).getAsJsonObject());
|
||||
String msg = ChatColor.GREEN + itemListing.getItemName() + " has been restocked!";
|
||||
commandSender.sendMessage(msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.zerohighdef.geoffrey.Commands;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.zerohighdef.geoffrey.GeoffreyMC;
|
||||
import com.zerohighdef.geoffrey.Models.GeoffreyTunnel;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyCommand;
|
||||
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TunnelCommand extends GeoffreyCommand {
|
||||
public TunnelCommand(GeoffreyMC plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (args.length > 0) {
|
||||
String playerName = args[0];
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
|
||||
params.put("player_name", playerName);
|
||||
RunCommand("tunnel", params, Method.GET, new CommandCallback(sender, playerName));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "You must specify a player name.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private class CommandCallback extends GeoffreyAPICallback {
|
||||
private String playerName;
|
||||
|
||||
CommandCallback(CommandSender sender, String playerName) {
|
||||
super(sender);
|
||||
errors.put("LocationLookUpError", playerName + " has no tunnels.");
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String s) {
|
||||
try {
|
||||
JsonElement json = parseJSON(s);
|
||||
StringBuilder tunnelList = new StringBuilder();
|
||||
|
||||
for (JsonElement jsonElement: json.getAsJsonArray()) {
|
||||
GeoffreyTunnel tunnel = new GeoffreyTunnel(jsonElement.getAsJsonObject());
|
||||
tunnelList.append(tunnel.getLocationName());
|
||||
tunnelList.append(": ");
|
||||
tunnelList.append(tunnel.getTunnelLocationString());
|
||||
tunnelList.append("\n");
|
||||
}
|
||||
|
||||
String msg = ChatColor.BOLD + playerName + " has the following tunnels:\n" + ChatColor.RESET + tunnelList.toString();
|
||||
commandSender.sendMessage(ChatColor.GREEN + msg);
|
||||
}
|
||||
catch (GeoffreyCommandError e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -89,6 +89,12 @@ public final class GeoffreyMC extends JavaPlugin {
|
|||
|
||||
RemoveResidentCommand removeResidentCommand = new RemoveResidentCommand(this);
|
||||
this.getCommand("geoffrey_remove_resident").setExecutor(removeResidentCommand);
|
||||
|
||||
RestockCommand restockCommand = new RestockCommand(this);
|
||||
this.getCommand("geoffrey_restock").setExecutor(restockCommand);
|
||||
|
||||
TunnelCommand tunnelCommand = new TunnelCommand(this);
|
||||
this.getCommand("geoffrey_tunnel").setExecutor(tunnelCommand);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -134,6 +134,16 @@ commands:
|
|||
aliases: [remove_resident]
|
||||
permission: geoffrey.add
|
||||
usage: /remove_resident [resident name] [town name]
|
||||
geoffrey_restock:
|
||||
description: Restocks an item in your shop
|
||||
aliases: [restock]
|
||||
permission: geoffrey.add
|
||||
usage: /restock [item name] [shop name]
|
||||
geoffrey_tunnel:
|
||||
description: Displays all the tunnels a player owns
|
||||
aliases: [tunnel]
|
||||
permission: geoffrey.search
|
||||
usage: /tunnel [player name]
|
||||
|
||||
permissions:
|
||||
add:
|
||||
|
|
Loading…
Reference in New Issue