Added missing files from last commit

master
Joey Hines 2019-12-24 17:12:09 -06:00
parent d834c95b00
commit 4804ca5ad4
10 changed files with 211 additions and 25 deletions

View File

@ -137,14 +137,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,98 @@
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.Models.GeoffreyLocation;
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
import org.apache.commons.lang.NumberUtils;
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 AddItemCommand extends GeoffreyCommand{
public AddItemCommand(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 > 3) {
String name[] = Arrays.copyOfRange(args, 3, args.length-1);
params.put("shop_name", StringUtils.join(name, " "));
}
else if (args.length < 3) {
sender.sendMessage(ChatColor.RED + "Too few parameters given.");
return false;
}
Player player = ((Player) sender).getPlayer();
String quantity = args[1];
String diamondPrice = args[2];
try {
Integer.parseInt(quantity);
}
catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Quantity must be an integer value!");
return false;
}
try {
Integer.parseInt(diamondPrice);
}
catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Price must be an integer value!");
return false;
}
params.put("mc_uuid", player.getUniqueId().toString().replace("-", ""));
params.put("item_name", args[0]);
params.put("quantity", quantity);
params.put("diamond_price", diamondPrice);
RunCommand("add_item", params, Method.POST , new CommandCallback(sender));
}
else {
sender.sendMessage(ChatColor.RED + "Console can not add items!");
}
return true;
}
private class CommandCallback extends GeoffreyAPICallback {
CommandCallback(CommandSender sender) {
super(sender);
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.getAsJsonObject());
String msg = ChatColor.GREEN + itemListing.getItemName() + " has been added to your shop.";
commandSender.sendMessage(msg);
}
catch (GeoffreyCommandError e) {
return;
}
}
}
}

View File

@ -5,6 +5,7 @@ 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;
@ -28,7 +29,7 @@ public class AddLocationCommand extends GeoffreyCommand{
Map<String, String> params = new HashMap<String, String>();
if (args.length > 0) {
params.put("name", String.join(" ", args));
params.put("name", StringUtils.join(args, " "));
}
Player player = ((Player) sender).getPlayer();

View File

@ -0,0 +1,74 @@
package com.zerohighdef.geoffrey.Commands;
import com.google.gson.JsonElement;
import com.zerohighdef.geoffrey.GeoffreyMC;
import com.zerohighdef.geoffrey.Models.GeoffreyPlayer;
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 AddResidentCommand extends GeoffreyCommand {
public AddResidentCommand(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("town_name", StringUtils.join(name, " "));
Player player = ((Player) sender).getPlayer();
params.put("mc_uuid", player.getUniqueId().toString().replace("-", ""));
params.put("new_resident_name", args[0]);
RunCommand("add_resident", 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 {
CommandCallback(CommandSender sender, String new_resident_name) {
super(sender);
errors.put("ResidentNotFoundError", "Ain't no one in this darn database named" + new_resident_name + "you goob");
errors.put("IsResidentError", new_resident_name + " is already a resident, stop having amosia.");
errors.put("LocationLookUpError", "You do not have a town by that name you ding dong goober.");
}
@Override
public void invoke(String s) {
try {
JsonElement json = parseJSON(s);
GeoffreyPlayer player = new GeoffreyPlayer(json.getAsJsonObject());
String msg = ChatColor.GREEN + player.getUsername() + "has been added to your town";
commandSender.sendMessage(msg);
}
catch (GeoffreyCommandError e) {
return;
}
}
}
}

View File

@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
import com.zerohighdef.geoffrey.GeoffreyMC;
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;
@ -21,7 +22,7 @@ public class FindCommand extends GeoffreyCommand {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0) {
String locationName = String.join(" ", args);
String locationName = StringUtils.join(args, " ");
Map<String, String> params = new HashMap<String, String>();
params.put("search", locationName);

View File

@ -27,7 +27,6 @@ public class RegisterCommand extends GeoffreyCommand{
Player player = ((Player) sender).getPlayer();
params.put("player_name", player.getName());
params.put("discord_uuid", "");
RunCommand("register", params, Method.POST , new CommandCallback(sender));
}

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import com.zerohighdef.geoffrey.GeoffreyMC;
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;
@ -22,7 +23,7 @@ public class SellingCommand extends GeoffreyCommand {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0) {
String item = String.join(" ", args);
String item = StringUtils.join(args, " ");
String commandName;
if (command.getName().contains("price")) {

View File

@ -1,9 +1,6 @@
package com.zerohighdef.geoffrey;
import com.zerohighdef.geoffrey.Commands.AddLocationCommand;
import com.zerohighdef.geoffrey.Commands.FindCommand;
import com.zerohighdef.geoffrey.Commands.RegisterCommand;
import com.zerohighdef.geoffrey.Commands.SellingCommand;
import com.zerohighdef.geoffrey.Commands.*;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
@ -41,6 +38,12 @@ public final class GeoffreyMC extends JavaPlugin {
RegisterCommand registerCommand = new RegisterCommand(this);
this.getCommand("geoffrey_register").setExecutor(registerCommand);
AddItemCommand addItemCommand = new AddItemCommand(this);
this.getCommand("geoffrey_add_item").setExecutor(addItemCommand);
AddResidentCommand addResidentCommand = new AddResidentCommand(this);
this.getCommand("geoffrey_add_resident").setExecutor(addResidentCommand);
}
}

View File

@ -12,11 +12,12 @@ import org.bukkit.command.CommandSender;
import xyz.etztech.core.web.ICallback;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
public abstract class GeoffreyAPICallback implements ICallback {
protected CommandSender commandSender;
protected HashMap<String, String> errors = new HashMap<>();
private Logger log = Logger.getLogger( "Minecraft" );
public GeoffreyAPICallback(CommandSender commandSender) {
@ -40,6 +41,9 @@ public abstract class GeoffreyAPICallback implements ICallback {
if (errors.containsKey(error)) {
errorMessage = errors.get(error);
}
else {
log.info("[Geoffrey] " + object.get("error").getAsString() + " " + object.get("error_message").getAsString());
}
commandSender.sendMessage(ChatColor.RED + errorMessage);
throw new GeoffreyCommandError();

View File

@ -7,52 +7,65 @@ commands:
geoffrey_find:
description: Finds a location in Geoffrey
aliases: [find, find_location]
usage: /find [location name]
geoffrey_selling:
description: Finds an item for sale in Geoffrey
aliases: [selling]
usage: /selling [item name]
geoffrey_selling_price:
description: Finds an item for sale in Geoffrey, sorted by price
aliases: [selling_price]
usage: /selling_price [item name]
geoffrey_add_base:
description: Adds a base to Geoffrey
aliases: [add_base]
permission: geoffrey.add
usage: Adds a base at your current location to Geoffrey
usage: /add_base [base name]
geoffrey_add_shop:
description: Adds a shop to Geoffrey
aliases: [add_shop]
permission: geoffrey.add
usage: Adds a shop at your current location to Geoffrey
usage: /add_shop [shop name]
geoffrey_add_farm:
description: Adds a public farm to Geoffrey
aliases: [add_farm]
permission: geoffrey.add
usage: Adds a farm at your current location to Geoffrey
usage: /add_farm [farm name]
geoffrey_add_attraction:
description: Adds an attraction to Geoffrey
aliases: [add_attraction]
permission: geoffrey.add
usage: Adds an attraction at your current location to Geoffrey
usage: /add_attraction [attraction name]
geoffrey_add_town:
description: Adds a town to Geoffrey
aliases: [add_town]
permission: geoffrey.add
usage: Adds a town at your current location to Geoffrey
usage: /add_town [town name]
geoffrey_add_market:
description: Adds a market to Geoffrey
aliases: [add_market]
permission: geoffrey.add
usage: Adds a market at your current location to Geoffrey
usage: /add_market [market name]
geoffrey_register:
description: Registers a player for Geoffrey
aliases: [register]
permission: geoffrey.register
usage: Registers you in Geoffrey
usage: /register
geoffrey_add_item:
description: Adds an item to a shop in Geoffrey
aliases: [add_item]
permission: geoffrey.add
usage: /add_item [item name] [amount per price] [price] [shop name]
geoffrey_add_resident:
description: Adds a resident to a tow
aliases: [add_resident]
permission: geoffrey.add
usage: /add_resident [resident Name] [town name]
permissions:
add:
description: Permission to add things to Geoffrey
default: false
register:
description: Permission to register in Geoffrey
description: Permission to register for Geoffrey
default: false