Remove Util#parseLocation

This commit is contained in:
fullwall 2013-07-14 13:47:57 +08:00
parent ff50cd761d
commit e21d6daf48
3 changed files with 3 additions and 38 deletions

View File

@ -333,8 +333,9 @@ public class NPCCommands {
}
if (args.hasValueFlag("at")) {
spawnLoc = Util.parseLocation(args.getSenderLocation(), args.getFlag("at"));
spawnLoc = CommandContext.parseLocation(args.getSenderLocation(), args.getFlag("at"));
}
if (spawnLoc == null) {
npc.destroy();
throw new CommandException(Messages.INVALID_SPAWN_LOCATION);

View File

@ -57,7 +57,7 @@ public class LinearWaypointProvider implements WaypointProvider {
return null;
} else if (args.hasValueFlag("at")) {
try {
Location location = Util.parseLocation(player.getLocation(), args.getFlag("at"));
Location location = CommandContext.parseLocation(player.getLocation(), args.getFlag("at"));
waypoints.add(new Waypoint(location));
} catch (CommandException e) {
Messaging.sendError(player, e.getMessage());

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.util;
import java.util.Random;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.event.NPCCollisionEvent;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
@ -10,7 +9,6 @@ import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -19,7 +17,6 @@ import org.bukkit.util.Vector;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
public class Util {
// Static class for small (emphasis small) utility methods
@ -131,39 +128,6 @@ public class Util {
return false;
}
public static Location parseLocation(Location currentLocation, String flag) throws CommandException {
String[] parts = Iterables.toArray(Splitter.on(':').split(flag), String.class);
if (parts.length > 0) {
String worldName = currentLocation != null ? currentLocation.getWorld().getName() : "";
int x = 0, y = 0, z = 0;
float yaw = 0F, pitch = 0F;
switch (parts.length) {
case 6:
pitch = Float.parseFloat(parts[5]);
case 5:
yaw = Float.parseFloat(parts[4]);
case 4:
worldName = parts[3];
case 3:
x = Integer.parseInt(parts[0]);
y = Integer.parseInt(parts[1]);
z = Integer.parseInt(parts[2]);
break;
default:
throw new CommandException(Messages.INVALID_SPAWN_LOCATION);
}
World world = Bukkit.getWorld(worldName);
if (world == null)
throw new CommandException(Messages.INVALID_SPAWN_LOCATION);
return new Location(world, x, y, z, yaw, pitch);
} else {
Player search = Bukkit.getPlayerExact(flag);
if (search == null)
throw new CommandException(Messages.PLAYER_NOT_FOUND_FOR_SPAWN);
return search.getLocation();
}
}
public static String prettyEnum(Enum<?> e) {
return e.name().toLowerCase().replace('_', ' ');
}