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
pull/2/head
Joey Hines 2020-01-08 14:38:52 -06:00
parent e56518431e
commit c9c4be387b
3 changed files with 29 additions and 0 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}
}