mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 11:44:42 +02:00
Potential fixes
Fixes #712 Fixes #711 Fixes #707 Fixes #705 Fixes #702 Fixes #698 Fixes #697 Fixes #694 Fixes #717
This commit is contained in:
@ -90,7 +90,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
public class PS {
|
||||
|
||||
// protected static:
|
||||
public static PS instance;
|
||||
private static PS instance;
|
||||
|
||||
// private final:
|
||||
private final HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -32,23 +31,18 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
aliases = { "rgar" },
|
||||
usage = "/plot regenallroads <world>",
|
||||
usage = "/plot regenallroads <world> [height]",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.regenallroads")
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
public RegenAllRoads() {
|
||||
requiredArguments = new Argument[] { Argument.String };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
int height = 0;
|
||||
@ -60,6 +54,9 @@ public class RegenAllRoads extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
final String name = args[0];
|
||||
final PlotManager manager = PS.get().getPlotManager(name);
|
||||
|
@ -31,7 +31,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update PlotSquared",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
|
@ -90,6 +90,7 @@ public enum C {
|
||||
PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned", "static.permissions"),
|
||||
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
|
||||
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
|
||||
/*
|
||||
* Static console
|
||||
*/
|
||||
|
@ -575,9 +575,9 @@ public class SQLManager implements AbstractDB {
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||
stmt.setInt((i * 5) + 1, plot.id.x);
|
||||
stmt.setInt((i * 5) + 2, plot.id.y);
|
||||
try {
|
||||
try {
|
||||
stmt.setString((i * 5) + 3, plot.owner.toString());
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception e) {
|
||||
stmt.setString((i * 5) + 3, everyone.toString());
|
||||
}
|
||||
stmt.setString((i * 5) + 4, plot.world);
|
||||
|
@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
/**
|
||||
* A plot manager with a square grid layout, with square shaped plots
|
||||
@ -93,83 +92,87 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotWorld plotworld, int x, final int y, int z) {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
z -= dpw.ROAD_OFFSET_Z;
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
final int end;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
pathWidthLower = -1;
|
||||
end = dpw.PLOT_WIDTH;
|
||||
} else {
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
||||
} else {
|
||||
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
||||
try {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
z -= dpw.ROAD_OFFSET_Z;
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
final int end;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
pathWidthLower = -1;
|
||||
end = dpw.PLOT_WIDTH;
|
||||
} else {
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
||||
} else {
|
||||
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
||||
}
|
||||
end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
}
|
||||
int dx;
|
||||
int dz;
|
||||
int rx;
|
||||
int rz;
|
||||
if (x < 0) {
|
||||
dx = (x / size);
|
||||
rx = size + (x % size);
|
||||
} else {
|
||||
dx = (x / size) + 1;
|
||||
rx = (x % size);
|
||||
}
|
||||
if (z < 0) {
|
||||
dz = (z / size);
|
||||
rz = size + (z % size);
|
||||
} else {
|
||||
dz = (z / size) + 1;
|
||||
rz = (z % size);
|
||||
}
|
||||
PlotId id = new PlotId(dx, dz);
|
||||
boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
|
||||
int hash = MainUtil.hash(merged);
|
||||
// Not merged, and no need to check if it is
|
||||
if (hash == 0) {
|
||||
return id;
|
||||
}
|
||||
Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||
// Not merged, and standing on road
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
switch (hash) {
|
||||
case 8:
|
||||
// north
|
||||
return plot.getMerged(0) ? id : null;
|
||||
case 4:
|
||||
// east
|
||||
return plot.getMerged(1) ? id : null;
|
||||
case 2:
|
||||
// south
|
||||
return plot.getMerged(2) ? id : null;
|
||||
case 1:
|
||||
// west
|
||||
return plot.getMerged(3) ? id : null;
|
||||
case 12:
|
||||
// northest
|
||||
return plot.getMerged(4) ? id : null;
|
||||
case 6:
|
||||
// southeast
|
||||
return plot.getMerged(5) ? id : null;
|
||||
case 3:
|
||||
// southwest
|
||||
return plot.getMerged(6) ? id : null;
|
||||
case 9:
|
||||
// northwest
|
||||
return plot.getMerged(7) ? id : null;
|
||||
}
|
||||
PS.debug("invalid location: " + merged);
|
||||
} catch (Exception e) {
|
||||
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
|
||||
}
|
||||
int dx;
|
||||
int dz;
|
||||
int rx;
|
||||
int rz;
|
||||
if (x < 0) {
|
||||
dx = (x / size);
|
||||
rx = size + (x % size);
|
||||
} else {
|
||||
dx = (x / size) + 1;
|
||||
rx = (x % size);
|
||||
}
|
||||
if (z < 0) {
|
||||
dz = (z / size);
|
||||
rz = size + (z % size);
|
||||
} else {
|
||||
dz = (z / size) + 1;
|
||||
rz = (z % size);
|
||||
}
|
||||
PlotId id = new PlotId(dx, dz);
|
||||
boolean[] merged = new boolean[] {(rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower)};
|
||||
int hash = MainUtil.hash(merged);
|
||||
// Not merged, and no need to check if it is
|
||||
if (hash == 0) {
|
||||
return id;
|
||||
}
|
||||
Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||
// Not merged, and standing on road
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
switch (hash) {
|
||||
case 8:
|
||||
// north
|
||||
return plot.getMerged(0) ? id : null;
|
||||
case 4:
|
||||
// east
|
||||
return plot.getMerged(1) ? id : null;
|
||||
case 2:
|
||||
// south
|
||||
return plot.getMerged(2) ? id : null;
|
||||
case 1:
|
||||
// west
|
||||
return plot.getMerged(3) ? id : null;
|
||||
case 12:
|
||||
// northest
|
||||
return plot.getMerged(4) ? id : null;
|
||||
case 6:
|
||||
// southeast
|
||||
return plot.getMerged(5) ? id : null;
|
||||
case 3:
|
||||
// southwest
|
||||
return plot.getMerged(6) ? id : null;
|
||||
case 9:
|
||||
// northwest
|
||||
return plot.getMerged(7) ? id : null;
|
||||
}
|
||||
PS.debug("invalid location: " + merged);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMeta(final String key) {
|
||||
meta.remove(key);
|
||||
public Object deleteMeta(final String key) {
|
||||
return meta.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1013,7 +1013,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeDenied(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getDenied())) {
|
||||
result = result || PlotHandler.removeDenied(this, other);
|
||||
@ -1029,7 +1029,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeTrusted(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getTrusted())) {
|
||||
result = result || PlotHandler.removeTrusted(this, other);
|
||||
@ -1045,7 +1045,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeMember(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getMembers())) {
|
||||
result = result || PlotHandler.removeMember(this, other);
|
||||
|
@ -80,10 +80,8 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
* - metadata is session only
|
||||
* - deleting other plugin's metadata may cause issues
|
||||
* @param key
|
||||
*/
|
||||
public void deleteMeta(final String key) {
|
||||
if (meta != null) {
|
||||
meta.remove(key);
|
||||
*/
|
||||
public Object deleteMeta(final String key) {
|
||||
return meta.remove(key);
|
||||
}
|
||||
|
||||
|
@ -107,12 +107,11 @@ public abstract class ChunkManager {
|
||||
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
|
||||
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final String directory = PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final File folder = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region");
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
if (regionFiles == null) {
|
||||
throw new RuntimeException("Could not find worlds folder.");
|
||||
throw new RuntimeException("Could not find worlds folder: " + folder + " ? (no read access?)");
|
||||
}
|
||||
for (final File file : regionFiles) {
|
||||
final String name = file.getName();
|
||||
|
@ -563,6 +563,9 @@ public class MainUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isPlotAreaAbs(final Location location) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld());
|
||||
if (plotworld == null) {
|
||||
@ -586,6 +589,9 @@ public class MainUtil {
|
||||
return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null;
|
||||
}
|
||||
|
||||
public static boolean isPlotArea(final Plot plot) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
if (plotworld.TYPE == 2) {
|
||||
|
Reference in New Issue
Block a user