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
master
Joey Hines 2019-12-24 17:12:09 -06:00
parent d834c95b00
commit f92a0c98bf
8 changed files with 39 additions and 25 deletions

View File

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

View File

@ -5,6 +5,7 @@ import com.zerohighdef.geoffrey.GeoffreyMC;
import com.zerohighdef.geoffrey.Models.GeoffreyLocation; import com.zerohighdef.geoffrey.Models.GeoffreyLocation;
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback; import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError; import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -28,7 +29,7 @@ public class AddLocationCommand extends GeoffreyCommand{
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
if (args.length > 0) { if (args.length > 0) {
params.put("name", String.join(" ", args)); params.put("name", StringUtils.join(args, " "));
} }
Player player = ((Player) sender).getPlayer(); Player player = ((Player) sender).getPlayer();

View File

@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
import com.zerohighdef.geoffrey.GeoffreyMC; import com.zerohighdef.geoffrey.GeoffreyMC;
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback; import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError; import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0) { if (args.length > 0) {
String locationName = String.join(" ", args); String locationName = StringUtils.join(args, " ");
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put("search", locationName); params.put("search", locationName);

View File

@ -27,7 +27,6 @@ public class RegisterCommand extends GeoffreyCommand{
Player player = ((Player) sender).getPlayer(); Player player = ((Player) sender).getPlayer();
params.put("player_name", player.getName()); params.put("player_name", player.getName());
params.put("discord_uuid", "");
RunCommand("register", params, Method.POST , new CommandCallback(sender)); 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.GeoffreyMC;
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback; import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError; import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0) { if (args.length > 0) {
String item = String.join(" ", args); String item = StringUtils.join(args, " ");
String commandName; String commandName;
if (command.getName().contains("price")) { if (command.getName().contains("price")) {

View File

@ -1,9 +1,6 @@
package com.zerohighdef.geoffrey; package com.zerohighdef.geoffrey;
import com.zerohighdef.geoffrey.Commands.AddLocationCommand; import com.zerohighdef.geoffrey.Commands.*;
import com.zerohighdef.geoffrey.Commands.FindCommand;
import com.zerohighdef.geoffrey.Commands.RegisterCommand;
import com.zerohighdef.geoffrey.Commands.SellingCommand;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -41,6 +38,12 @@ public final class GeoffreyMC extends JavaPlugin {
RegisterCommand registerCommand = new RegisterCommand(this); RegisterCommand registerCommand = new RegisterCommand(this);
this.getCommand("geoffrey_register").setExecutor(registerCommand); 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 xyz.etztech.core.web.ICallback;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.logging.Logger;
public abstract class GeoffreyAPICallback implements ICallback { public abstract class GeoffreyAPICallback implements ICallback {
protected CommandSender commandSender; protected CommandSender commandSender;
protected HashMap<String, String> errors = new HashMap<>(); protected HashMap<String, String> errors = new HashMap<>();
private Logger log = Logger.getLogger( "Minecraft" );
public GeoffreyAPICallback(CommandSender commandSender) { public GeoffreyAPICallback(CommandSender commandSender) {
@ -40,6 +41,9 @@ public abstract class GeoffreyAPICallback implements ICallback {
if (errors.containsKey(error)) { if (errors.containsKey(error)) {
errorMessage = errors.get(error); errorMessage = errors.get(error);
} }
else {
log.info("[Geoffrey] " + object.get("error").getAsString() + " " + object.get("error_message").getAsString());
}
commandSender.sendMessage(ChatColor.RED + errorMessage); commandSender.sendMessage(ChatColor.RED + errorMessage);
throw new GeoffreyCommandError(); throw new GeoffreyCommandError();

View File

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