From f92a0c98bfe96b86cfc702b65cd7a69b6d9e54b5 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Tue, 24 Dec 2019 17:12:09 -0600 Subject: [PATCH] Added add_item and add_resident commands + better logging + Added error logging to console + Re-did plugin.yml to have a usage for each command + Handle multiple word location names better --- pom.xml | 8 ----- .../geoffrey/Commands/AddLocationCommand.java | 3 +- .../geoffrey/Commands/FindCommand.java | 3 +- .../geoffrey/Commands/RegisterCommand.java | 1 - .../geoffrey/Commands/SellingCommand.java | 3 +- .../com/zerohighdef/geoffrey/GeoffreyMC.java | 11 ++++--- .../geoffrey/Objects/GeoffreyAPICallback.java | 6 +++- src/main/resources/plugin.yml | 29 ++++++++++++++----- 8 files changed, 39 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 4b94a85..40c7685 100644 --- a/pom.xml +++ b/pom.xml @@ -137,14 +137,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - \ No newline at end of file diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java index 502d64c..57c0b77 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java @@ -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 params = new HashMap(); if (args.length > 0) { - params.put("name", String.join(" ", args)); + params.put("name", StringUtils.join(args, " ")); } Player player = ((Player) sender).getPlayer(); diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/FindCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/FindCommand.java index 7286f7c..ce51e6d 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/FindCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/FindCommand.java @@ -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 params = new HashMap(); params.put("search", locationName); diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/RegisterCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/RegisterCommand.java index 0ac3e36..7e72c4a 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/RegisterCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/RegisterCommand.java @@ -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)); } diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/SellingCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/SellingCommand.java index 50d83e4..b4321b2 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/SellingCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/SellingCommand.java @@ -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")) { diff --git a/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java b/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java index bfa5e9d..cdfb8db 100644 --- a/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java +++ b/src/main/java/com/zerohighdef/geoffrey/GeoffreyMC.java @@ -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); } } diff --git a/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyAPICallback.java b/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyAPICallback.java index f4fe7d5..1c2628a 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyAPICallback.java +++ b/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyAPICallback.java @@ -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 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(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b805fa5..f41a323 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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