mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Fix center
This commit is contained in:
parent
5d3e096501
commit
5978c9c3c0
7 changed files with 33 additions and 11 deletions
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
|
@ -143,7 +144,7 @@ public class Auto extends SubCommand {
|
|||
if (plotarea.TYPE == 2) {
|
||||
PlotId bot = plotarea.getMin();
|
||||
PlotId top = plotarea.getMax();
|
||||
PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||
PlotId origin = new PlotId(MathMan.average(bot.x, top.x), MathMan.average(bot.y, top.y));
|
||||
PlotId id = new PlotId(0, 0);
|
||||
int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
int max = width * width;
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import java.util.ArrayList;
|
||||
|
@ -130,8 +131,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||
Location[] corners = plot.getCorners();
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setBlock((corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
|
||||
(corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
|
||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||
queue.setBlock(x, dpw.PLOT_HEIGHT,z, blocks[0]);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,7 @@ public class ChunkLoc {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + this.x;
|
||||
result = (prime * result) + this.z;
|
||||
return result;
|
||||
return (x << 16) | (z & 0xFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
|
@ -24,6 +25,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import java.awt.geom.Area;
|
||||
|
@ -948,6 +950,9 @@ public class Plot {
|
|||
* @param value
|
||||
*/
|
||||
public <V> boolean setFlag(Flag<V> flag, Object value) {
|
||||
if (flag == Flags.KEEP && ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.updateExpired(this);
|
||||
}
|
||||
return FlagManager.addPlotFlag(this, flag, value);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1108,7 @@ public class Plot {
|
|||
Location[] corners = getCorners();
|
||||
Location top = corners[0];
|
||||
Location bot = corners[1];
|
||||
Location loc = new Location(this.area.worldname, (top.getX() + bot.getX()) / 2, (top.getY() + bot.getY()) / 2, (top.getZ() + bot.getZ()) / 2);
|
||||
Location loc = new Location(this.area.worldname, MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||
loc.setY(1 + Math.max(WorldUtil.IMP.getHighestBlock(this.area.worldname, loc.getX(), loc.getZ()),
|
||||
getManager().getSignLoc(this.area, this).getY()));
|
||||
return loc;
|
||||
|
|
|
@ -84,8 +84,8 @@ public class BO3Handler {
|
|||
ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
|
||||
int height = cpw.PLOT_HEIGHT;
|
||||
|
||||
int cx = (bot.getX() + top.getX()) / 2;
|
||||
int cz = (bot.getZ() + top.getZ()) / 2;
|
||||
int cx = MathMan.average(bot.getX(), top.getX());
|
||||
int cz = MathMan.average(bot.getZ(), top.getZ());
|
||||
|
||||
HashMap<ChunkLoc, BO3> map = new HashMap<>();
|
||||
|
||||
|
@ -193,6 +193,7 @@ public class BO3Handler {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void upload(final Plot plot, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
||||
if (plot == null) {
|
||||
throw new IllegalArgumentException("Arguments may not be null!");
|
||||
|
@ -250,6 +251,10 @@ public class BO3Handler {
|
|||
public static boolean save(Plot plot, BO3 bo3) {
|
||||
try {
|
||||
File bo3File = bo3.getFile();
|
||||
File parent = bo3File.getParentFile();
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
bo3File.createNewFile();
|
||||
bo3File.getParentFile().mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
|
||||
|
|
|
@ -159,6 +159,10 @@ public class MathMan {
|
|||
return (x << 16) | (y & 0xFFFF);
|
||||
}
|
||||
|
||||
public static final int average(int a, int b) {
|
||||
return (a&b) + (a^b)/2;
|
||||
}
|
||||
|
||||
public static short unpairX(int hash) {
|
||||
return (short) (hash >> 16);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,14 @@ public class ExpireManager {
|
|||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
public void updateExpired(Plot plot) {
|
||||
if (!plotsToDelete.isEmpty() && plotsToDelete.contains(plot)) {
|
||||
if (isExpired(new ArrayDeque<>(tasks), plot).isEmpty()) {
|
||||
plotsToDelete.remove(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmExpiry(final PlotPlayer pp) {
|
||||
if (pp.getMeta("ignoreExpireTask") != null) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue