Added a function to the main plugin class for other plugins to hook into, which will get the BorderData for a specified world. The other plugin can then access all available functions such as checking an X/Z position to see if it's inside the border, or getting a corrected (and safe) position inside the border.

This commit is contained in:
Brettflan 2011-06-07 06:08:21 -05:00
parent 2fb1b9dd7a
commit ce7a14c36b
2 changed files with 14 additions and 0 deletions

View File

@ -123,6 +123,10 @@ public class BorderData
return false; // Apparently outside, then
}
}
public boolean insideBorder(double xLoc, double zLoc)
{
return insideBorder(xLoc, zLoc, Config.ShapeRound());
}
public Location correctedPosition(Location loc, boolean round)
{
@ -164,6 +168,10 @@ public class BorderData
return new Location(loc.getWorld(), Math.floor(xLoc) + 0.5, yLoc, Math.floor(zLoc) + 0.5, loc.getYaw(), loc.getPitch());
}
public Location correctedPosition(Location loc)
{
return correctedPosition(loc, Config.ShapeRound());
}
//these material IDs are acceptable for places to teleport player; breathable blocks and water
private static LinkedHashSet<Integer> acceptableBlocks = new LinkedHashSet<Integer>(Arrays.asList(

View File

@ -41,4 +41,10 @@ public class WorldBorder extends JavaPlugin
System.out.println( desc.getName() + " version " + desc.getVersion() + " shutting down" );
Config.StopBorderTimer();
}
// for other plugins to hook into
public BorderData GetWorldBorder(String worldName)
{
return Config.Border(worldName);
}
}