From c9c4be387b8b76ade4b0ba88aadba26f7386ae1d Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Wed, 8 Jan 2020 14:38:52 -0600 Subject: [PATCH] Added dimension support to AddLocationCommand and EditPostCommand + This info is only used internally, but may be displayed in the future + Added function for converting the environment to a dimension string --- .../geoffrey/Commands/AddLocationCommand.java | 4 ++++ .../geoffrey/Commands/EditPosCommand.java | 5 +++++ .../geoffrey/Objects/GeoffreyUtil.java | 20 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java index c492ed0..efa0236 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/AddLocationCommand.java @@ -6,6 +6,7 @@ import com.zerohighdef.geoffrey.Models.GeoffreyLocation; 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; @@ -35,9 +36,12 @@ public class AddLocationCommand extends GeoffreyCommand { Player player = ((Player) sender).getPlayer(); + String dimension = GeoffreyUtil.getGeoffreyDimensionString(player.getWorld().getEnvironment()); + params.put("mc_uuid", ((Player) sender).getUniqueId().toString().replace("-", "")); params.put("x_pos", Integer.toString(player.getLocation().getBlockX())); params.put("z_pos", Integer.toString(player.getLocation().getBlockZ())); + params.put("dimension", dimension); RunCommand(commandName, params, Method.POST , new CommandCallback(sender)); } else { diff --git a/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java b/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java index 916186c..ac87345 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java +++ b/src/main/java/com/zerohighdef/geoffrey/Commands/EditPosCommand.java @@ -6,6 +6,7 @@ import com.zerohighdef.geoffrey.Models.GeoffreyLocation; 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; @@ -32,11 +33,15 @@ public class EditPosCommand extends GeoffreyCommand { } Player player = ((Player) sender).getPlayer(); + + String dimension = GeoffreyUtil.getGeoffreyDimensionString(player.getWorld().getEnvironment()); + String locationName = StringUtils.join(args, " "); params.put("loc_name", locationName); params.put("mc_uuid", ((Player) sender).getUniqueId().toString().replace("-", "")); params.put("x", Integer.toString(player.getLocation().getBlockX())); params.put("z", Integer.toString(player.getLocation().getBlockZ())); + params.put("dimension", dimension); RunCommand("edit_pos", params, Method.POST , new CommandCallback(sender, locationName)); } else { diff --git a/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyUtil.java b/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyUtil.java index 97ff750..48a92b6 100644 --- a/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyUtil.java +++ b/src/main/java/com/zerohighdef/geoffrey/Objects/GeoffreyUtil.java @@ -1,5 +1,7 @@ package com.zerohighdef.geoffrey.Objects; +import org.bukkit.World; + import java.text.ParseException; import java.util.LinkedList; import java.util.List; @@ -46,4 +48,22 @@ public class GeoffreyUtil { return parsedArgs; } + + public static String getGeoffreyDimensionString(World.Environment environment) { + String dim; + if (environment.compareTo(World.Environment.NORMAL) == 0) { + dim = "O"; + } + else if (environment.compareTo(World.Environment.NETHER) == 0) { + dim = "N"; + } + else if (environment.compareTo(World.Environment.THE_END) == 0) { + dim = "E"; + } + else { + dim = null; + } + + return dim; + } }