summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-07-17 00:46:07 +0100
committerKHobbits <rob@khobbits.co.uk>2012-07-17 00:46:07 +0100
commit66ae1d5b9405ffa7dcf82f5ec96d944c088d937c (patch)
treead291252bd36977e6603a5f298d42937623481c7
parentada077fead0c757615ea88c7451cccc6219fa3ac (diff)
downloadEssentials-66ae1d5b9405ffa7dcf82f5ec96d944c088d937c.tar
Essentials-66ae1d5b9405ffa7dcf82f5ec96d944c088d937c.tar.gz
Essentials-66ae1d5b9405ffa7dcf82f5ec96d944c088d937c.tar.lz
Essentials-66ae1d5b9405ffa7dcf82f5ec96d944c088d937c.tar.xz
Essentials-66ae1d5b9405ffa7dcf82f5ec96d944c088d937c.zip
Try to do a little better when searching for safe teleport locations.
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java50
1 files changed, 41 insertions, 9 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 112477ecb..6982c00d8 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -215,10 +215,11 @@ public class Util
{
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
}
-
+
Calendar max = new GregorianCalendar();
max.add(Calendar.YEAR, 10);
- if (c.after(max)) {
+ if (c.after(max))
+ {
return max.getTimeInMillis();
}
return c.getTimeInMillis();
@@ -295,12 +296,14 @@ public class Util
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
+ final int oy = y;
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
+ y = oy;
break;
}
}
@@ -310,10 +313,38 @@ public class Util
y += 1;
if (y >= world.getHighestBlockYAt(x, z))
{
- x += 1;
+ x -= 3;
+ z -= 3;
+ y = oy + 4;
break;
}
}
+
+ while (isBlockUnsafe(world, x, y, z))
+ {
+ y -= 1;
+ if (y + 4 < oy)
+ {
+ System.out.println("Lets inc x");
+ x += 1;
+ y = oy + 4;
+ if (x - 3 > loc.getBlockX())
+ {
+ System.out.println("Lets inc z");
+ x = loc.getBlockX() - 3;
+ z += 1;
+ if (z - 3 > loc.getBlockZ())
+ {
+ System.out.println("Time to give up");
+ x = loc.getBlockX() + 4;
+ z = loc.getBlockZ();
+ y = world.getHighestBlockYAt(x, z);
+ break;
+ }
+ }
+ }
+ }
+
while (isBlockUnsafe(world, x, y, z))
{
y -= 1;
@@ -321,7 +352,7 @@ public class Util
{
x += 1;
y = world.getHighestBlockYAt(x, z);
- if (x - 32 > loc.getBlockX())
+ if (x - 48 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
}
@@ -510,15 +541,16 @@ public class Util
}
return buf.toString();
}
-
- public static String lastCode(final String input) {
+
+ public static String lastCode(final String input)
+ {
int pos = input.lastIndexOf("ยง");
- if (pos == -1 || (pos + 1) == input.length()) {
+ if (pos == -1 || (pos + 1) == input.length())
+ {
return "";
}
- return input.substring(pos, pos + 2);
+ return input.substring(pos, pos + 2);
}
-
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");