mirror of
https://github.com/PryPurity/WorldBorder.git
synced 2024-10-02 04:37:30 +02:00
Merge branch 'master' of github.com:Brettflan/WorldBorder
This commit is contained in:
commit
f9d89034b4
@ -321,7 +321,33 @@ public class BorderData
|
|||||||
private double getSafeY(World world, int X, int Y, int Z, boolean flying)
|
private double getSafeY(World world, int X, int Y, int Z, boolean flying)
|
||||||
{
|
{
|
||||||
// artificial height limit of 127 added for Nether worlds since CraftBukkit still incorrectly returns 255 for their max height, leading to players sent to the "roof" of the Nether
|
// artificial height limit of 127 added for Nether worlds since CraftBukkit still incorrectly returns 255 for their max height, leading to players sent to the "roof" of the Nether
|
||||||
final int limTop = (world.getEnvironment() == World.Environment.NETHER) ? 125 : world.getMaxHeight() - 2;
|
final boolean isNether = world.getEnvironment() == World.Environment.NETHER;
|
||||||
|
int limTop = isNether ? 125 : world.getMaxHeight() - 2;
|
||||||
|
final int highestBlockBoundary = Math.min(world.getHighestBlockYAt(X, Z) + 1, limTop);
|
||||||
|
|
||||||
|
// if Y is larger than the world can be and user can fly, return Y - Unless we are in the Nether, we might not want players on the roof
|
||||||
|
if (flying && Y > limTop && !isNether)
|
||||||
|
return (double) Y;
|
||||||
|
|
||||||
|
// make sure Y values are within the boundaries of the world.
|
||||||
|
if (Y > limTop)
|
||||||
|
{
|
||||||
|
if (isNether)
|
||||||
|
Y = limTop; // because of the roof, the nether can not rely on highestBlockBoundary, so limTop has to be used
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flying)
|
||||||
|
Y = limTop;
|
||||||
|
else
|
||||||
|
Y = highestBlockBoundary; // there will never be a save block to stand on for Y values > highestBlockBoundary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Y < limBot)
|
||||||
|
Y = limBot;
|
||||||
|
|
||||||
|
// for non Nether worlds we don't need to check upwards to the world-limit, it is enough to check up to the highestBlockBoundary, unless player is flying
|
||||||
|
if (!isNether && !flying)
|
||||||
|
limTop = highestBlockBoundary;
|
||||||
// Expanding Y search method adapted from Acru's code in the Nether plugin
|
// Expanding Y search method adapted from Acru's code in the Nether plugin
|
||||||
|
|
||||||
for(int y1 = Y, y2 = Y; (y1 > limBot) || (y2 < limTop); y1--, y2++){
|
for(int y1 = Y, y2 = Y; (y1 > limBot) || (y2 < limTop); y1--, y2++){
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.wimbli.WorldBorder.Events;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.wimbli.WorldBorder.WorldFillTask;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Maximvdw on 12.01.2016.
|
||||||
|
*/
|
||||||
|
public class WorldBorderFillStartEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private WorldFillTask fillTask;
|
||||||
|
|
||||||
|
public WorldBorderFillStartEvent(WorldFillTask worldFillTask)
|
||||||
|
{
|
||||||
|
this.fillTask = worldFillTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldFillTask getFillTask(){
|
||||||
|
return this.fillTask;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.wimbli.WorldBorder.Events;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.wimbli.WorldBorder.WorldTrimTask;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Maximvdw on 12.01.2016.
|
||||||
|
*/
|
||||||
|
public class WorldBorderTrimStartEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private WorldTrimTask trimTask;
|
||||||
|
|
||||||
|
public WorldBorderTrimStartEvent(WorldTrimTask trimTask)
|
||||||
|
{
|
||||||
|
this.trimTask = trimTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldTrimTask getTrimTask(){
|
||||||
|
return this.trimTask;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.wimbli.WorldBorder.Events.WorldBorderFillFinishedEvent;
|
import com.wimbli.WorldBorder.Events.WorldBorderFillFinishedEvent;
|
||||||
|
import com.wimbli.WorldBorder.Events.WorldBorderFillStartEvent;
|
||||||
|
|
||||||
|
|
||||||
public class WorldFillTask implements Runnable
|
public class WorldFillTask implements Runnable
|
||||||
@ -117,6 +118,7 @@ public class WorldFillTask implements Runnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.readyToGo = true;
|
this.readyToGo = true;
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderFillStartEvent(this));
|
||||||
}
|
}
|
||||||
// for backwards compatibility
|
// for backwards compatibility
|
||||||
public WorldFillTask(Server theServer, Player player, String worldName, int fillDistance, int chunksPerRun, int tickFrequency)
|
public WorldFillTask(Server theServer, Player player, String worldName, int fillDistance, int chunksPerRun, int tickFrequency)
|
||||||
@ -383,7 +385,7 @@ public class WorldFillTask implements Runnable
|
|||||||
private void reportProgress()
|
private void reportProgress()
|
||||||
{
|
{
|
||||||
lastReport = Config.Now();
|
lastReport = Config.Now();
|
||||||
double perc = ((double)(reportTotal + reportNum) / (double)reportTarget) * 100;
|
double perc = getPercentageCompleted();
|
||||||
if (perc > 100) perc = 100;
|
if (perc > 100) perc = 100;
|
||||||
sendMessage(reportNum + " more chunks processed (" + (reportTotal + reportNum) + " total, ~" + Config.coord.format(perc) + "%" + ")");
|
sendMessage(reportNum + " more chunks processed (" + (reportTotal + reportNum) + " total, ~" + Config.coord.format(perc) + "%" + ")");
|
||||||
reportTotal += reportNum;
|
reportTotal += reportNum;
|
||||||
@ -467,4 +469,31 @@ public class WorldFillTask implements Runnable
|
|||||||
{
|
{
|
||||||
return forceLoad;
|
return forceLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the percentage completed for the fill task.
|
||||||
|
*
|
||||||
|
* @return Percentage
|
||||||
|
*/
|
||||||
|
public double getPercentageCompleted() {
|
||||||
|
return ((double) (reportTotal + reportNum) / (double) reportTarget) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount of chunks completed for the fill task.
|
||||||
|
*
|
||||||
|
* @return Number of chunks processed.
|
||||||
|
*/
|
||||||
|
public int getChunksCompleted() {
|
||||||
|
return reportTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total amount of chunks that need to be generated for the fill task.
|
||||||
|
*
|
||||||
|
* @return Number of chunks that need to be processed.
|
||||||
|
*/
|
||||||
|
public int getChunksTotal() {
|
||||||
|
return reportTarget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.wimbli.WorldBorder.Events.WorldBorderTrimFinishedEvent;
|
import com.wimbli.WorldBorder.Events.WorldBorderTrimFinishedEvent;
|
||||||
|
import com.wimbli.WorldBorder.Events.WorldBorderTrimStartEvent;
|
||||||
|
|
||||||
|
|
||||||
public class WorldTrimTask implements Runnable
|
public class WorldTrimTask implements Runnable
|
||||||
@ -88,6 +89,7 @@ public class WorldTrimTask implements Runnable
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
this.readyToGo = true;
|
this.readyToGo = true;
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderTrimStartEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaskID(int ID)
|
public void setTaskID(int ID)
|
||||||
@ -389,7 +391,7 @@ public class WorldTrimTask implements Runnable
|
|||||||
private void reportProgress()
|
private void reportProgress()
|
||||||
{
|
{
|
||||||
lastReport = Config.Now();
|
lastReport = Config.Now();
|
||||||
double perc = ((double)(reportTotal) / (double)reportTarget) * 100;
|
double perc = getPercentageCompleted();
|
||||||
sendMessage(reportTrimmedRegions + " entire region(s) and " + reportTrimmedChunks + " individual chunk(s) trimmed so far (" + Config.coord.format(perc) + "% done" + ")");
|
sendMessage(reportTrimmedRegions + " entire region(s) and " + reportTrimmedChunks + " individual chunk(s) trimmed so far (" + Config.coord.format(perc) + "% done" + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,4 +402,31 @@ public class WorldTrimTask implements Runnable
|
|||||||
if (notifyPlayer != null)
|
if (notifyPlayer != null)
|
||||||
notifyPlayer.sendMessage("[Trim] " + text);
|
notifyPlayer.sendMessage("[Trim] " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the percentage completed for the trim task.
|
||||||
|
*
|
||||||
|
* @return Percentage
|
||||||
|
*/
|
||||||
|
public double getPercentageCompleted() {
|
||||||
|
return ((double) (reportTotal) / (double) reportTarget) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount of chunks completed for the trim task.
|
||||||
|
*
|
||||||
|
* @return Number of chunks processed.
|
||||||
|
*/
|
||||||
|
public int getChunksCompleted() {
|
||||||
|
return reportTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total amount of chunks that need to be trimmed for the trim task.
|
||||||
|
*
|
||||||
|
* @return Number of chunks that need to be processed.
|
||||||
|
*/
|
||||||
|
public int getChunksTotal() {
|
||||||
|
return reportTarget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user