Compatibility changes for Portals directions.

This commit is contained in:
Eric Stokes 2011-07-24 16:30:56 -06:00
parent 61e917a60f
commit d9530061ff

View File

@ -1,13 +1,28 @@
package com.onarandombox.utils; package com.onarandombox.utils;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockFace;
public class LocationManipulation { public class LocationManipulation {
private static Map<String, Integer> orientationInts = new HashMap<String, Integer>();
static {
orientationInts.put("n", 0);
orientationInts.put("nw", 45);
orientationInts.put("w", 90);
orientationInts.put("sw", 135);
orientationInts.put("s", 180);
orientationInts.put("se", 225);
orientationInts.put("e", 270);
orientationInts.put("ne", 315);
}
/** /**
* Convert a Location into a Colon separated string to allow us to store it in text. * Convert a Location into a Colon separated string to allow us to store it in text.
* *
* @param location * @param location
* @return * @return
*/ */
@ -23,7 +38,7 @@ public class LocationManipulation {
/** /**
* Convert a String to a Location. * Convert a String to a Location.
* *
* @param world * @param world
* @param xStr * @param xStr
* @param yStr * @param yStr
@ -44,7 +59,7 @@ public class LocationManipulation {
/** /**
* Convert a Location to XYZ Coordinates. * Convert a Location to XYZ Coordinates.
* *
* @param l * @param l
* @return * @return
*/ */
@ -58,7 +73,7 @@ public class LocationManipulation {
/** /**
* Return the NESW Direction a Location is facing. * Return the NESW Direction a Location is facing.
* *
* @param location * @param location
* @return * @return
*/ */
@ -86,4 +101,11 @@ public class LocationManipulation {
return dir; return dir;
} }
public static float getYaw(String orientation) {
if (orientationInts.containsKey(orientation)) {
return (orientationInts.get(orientation) + 90) % 360;
}
return 0;
}
} }