Add a method to get the color message from a string in the util.

This commit is contained in:
graywolf336 2013-12-06 10:28:03 -06:00
parent 7d0f96cfba
commit 3159d30aff

View File

@ -1,38 +1,43 @@
package com.graywolf336.jail; package com.graywolf336.jail;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class Util { public class Util {
/** Checks if the first {@link Vector} is inside the other two. */ /** Checks if the first {@link Vector} is inside the other two. */
public static boolean isInsideAB(Vector point, Vector first, Vector second) { public static boolean isInsideAB(Vector point, Vector first, Vector second) {
boolean x = isInside(point.getBlockX(), first.getBlockX(), second.getBlockX()); boolean x = isInside(point.getBlockX(), first.getBlockX(), second.getBlockX());
boolean y = isInside(point.getBlockY(), first.getBlockY(), second.getBlockY()); boolean y = isInside(point.getBlockY(), first.getBlockY(), second.getBlockY());
boolean z = isInside(point.getBlockZ(), first.getBlockZ(), second.getBlockZ()); boolean z = isInside(point.getBlockZ(), first.getBlockZ(), second.getBlockZ());
return x && y && z; return x && y && z;
} }
/** /**
* Checks if two numbers are inside a point, or something. * Checks if two numbers are inside a point, or something.
* <p /> * <p />
* *
* @param loc The location. * @param loc The location.
* @param first The first point * @param first The first point
* @param second The second point * @param second The second point
* @return True if they are inside, false if not. * @return True if they are inside, false if not.
*/ */
private static boolean isInside(int loc, int first, int second) { private static boolean isInside(int loc, int first, int second) {
int point1 = 0; int point1 = 0;
int point2 = 0; int point2 = 0;
if (first < second) { if (first < second) {
point1 = first; point1 = first;
point2 = second; point2 = second;
} else { } else {
point2 = first; point2 = first;
point1 = second; point1 = second;
} }
return (point1 <= loc) && (loc <= point2); return (point1 <= loc) && (loc <= point2);
} }
}
/** Returns a colorful message from the color codes. */
public static String getColorfulMessage(String message) {
return message.replaceAll("(?i)&([0-9abcdefklmnor])", "\u00A7$1");
}
}