mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Add optional world offset
This commit is contained in:
parent
ffdee2507d
commit
8a4e19ab40
@ -50,26 +50,26 @@ public class MusicSubcommand extends SubCommand {
|
||||
sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
||||
public boolean onClick(int index) {
|
||||
PlotItemStack item = getItem(index);
|
||||
int id = item.id == 7 ? 0 : item.id;
|
||||
if (id == 0) {
|
||||
FlagManager.removePlotFlag(plot, "music");
|
||||
}
|
||||
else {
|
||||
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("music"), id));
|
||||
}
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotListener.manager.plotEntry(player, plot);
|
||||
}
|
||||
}, 1);
|
||||
close();
|
||||
return false;
|
||||
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
||||
public boolean onClick(int index) {
|
||||
PlotItemStack item = getItem(index);
|
||||
int id = item.id == 7 ? 0 : item.id;
|
||||
if (id == 0) {
|
||||
FlagManager.removePlotFlag(plot, "music");
|
||||
}
|
||||
else {
|
||||
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("music"), id));
|
||||
}
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotListener.manager.plotEntry(player, plot);
|
||||
}
|
||||
};
|
||||
}, 1);
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
int index = 0;
|
||||
for (int i = 2256; i < 2268; i++) {
|
||||
String name = "&r&6" + BlockManager.manager.getClosestMatchingName(new PlotBlock((short) i, (byte) 0));
|
||||
|
@ -527,7 +527,7 @@ public enum C {
|
||||
C(final String d, final boolean prefix, String cat) {
|
||||
this.d = d;
|
||||
if (this.s == null) {
|
||||
this.s = "";
|
||||
this.s = d;
|
||||
}
|
||||
this.prefix = prefix;
|
||||
this.cat = cat.toLowerCase();
|
||||
|
@ -161,11 +161,11 @@ public class LikePlotMeConverter {
|
||||
connector.copyConfig(plotConfig, world, actualWorldName);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
plotCount += entry.getValue().size();
|
||||
|
@ -48,22 +48,17 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
if (!config.contains("plot.height")) {
|
||||
PS.log(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||
}
|
||||
super.loadConfiguration(config);
|
||||
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
|
||||
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ','));
|
||||
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||
this.ROAD_WIDTH = config.getInt("road.width");
|
||||
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||
this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
||||
this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH);
|
||||
}
|
||||
|
||||
public ClassicPlotWorld(final String worldname) {
|
||||
|
@ -171,8 +171,8 @@ public class HybridGen extends PlotGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
int sx = (short) ((this.X) % this.size);
|
||||
int sz = (short) ((this.Z) % this.size);
|
||||
int sx = (short) ((this.X - this.plotworld.ROAD_OFFSET_X) % this.size);
|
||||
int sz = (short) ((this.Z - this.plotworld.ROAD_OFFSET_Z) % this.size);
|
||||
if (sx < 0) {
|
||||
sx += this.size;
|
||||
}
|
||||
@ -182,6 +182,7 @@ public class HybridGen extends PlotGenerator {
|
||||
|
||||
if (region != null) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
final int absX = ((sx + x) % this.size);
|
||||
for (short z = 0; z < 16; z++) {
|
||||
if (biomes != null) {
|
||||
biomes.setBiome(x, z, this.biome);
|
||||
@ -191,7 +192,6 @@ public class HybridGen extends PlotGenerator {
|
||||
setBlock(x, y, z, this.filling);
|
||||
}
|
||||
setBlock(x, this.plotheight, z, this.plotfloors);
|
||||
final int absX = ((sx + x) % this.size);
|
||||
final int absZ = ((sz + z) % this.size);
|
||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||
@ -207,15 +207,15 @@ public class HybridGen extends PlotGenerator {
|
||||
}
|
||||
|
||||
for (short x = 0; x < 16; x++) {
|
||||
final int absX = ((sx + x) % this.size);
|
||||
final boolean gx = absX > this.pathWidthLower;
|
||||
final boolean lx = absX < this.pathWidthUpper;
|
||||
for (short z = 0; z < 16; z++) {
|
||||
if (biomes != null) {
|
||||
biomes.setBiome(x, z, this.biome);
|
||||
}
|
||||
final int absX = ((sx + x) % this.size);
|
||||
final int absZ = ((sz + z) % this.size);
|
||||
final boolean gx = absX > this.pathWidthLower;
|
||||
final boolean gz = absZ > this.pathWidthLower;
|
||||
final boolean lx = absX < this.pathWidthUpper;
|
||||
final boolean lz = absZ < this.pathWidthUpper;
|
||||
// inside plot
|
||||
if (gx && gz && lx && lz) {
|
||||
|
@ -62,22 +62,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
if (!config.contains("plot.height")) {
|
||||
PS.log(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||
}
|
||||
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
|
||||
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ','));
|
||||
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||
this.ROAD_WIDTH = config.getInt("road.width");
|
||||
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||
this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
||||
this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH);
|
||||
super.loadConfiguration(config);
|
||||
if ((this.ROAD_WIDTH % 2) == 0) {
|
||||
this.PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
@ -100,7 +85,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
final Schematic schem1 = SchematicHandler.manager.getSchematic(schem1Str);
|
||||
final Schematic schem2 = SchematicHandler.manager.getSchematic(schem2Str);
|
||||
final Schematic schem3 = SchematicHandler.manager.getSchematic(schem3Str);
|
||||
final int shift = (int) Math.floor(this.ROAD_WIDTH / 2);
|
||||
final int shift = (int) this.ROAD_WIDTH / 2;
|
||||
int oddshift = 0;
|
||||
if ((this.ROAD_WIDTH % 2) != 0) {
|
||||
oddshift = 1;
|
||||
|
@ -113,8 +113,8 @@ public class HybridPop extends PlotPopulator {
|
||||
public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) {
|
||||
PS.get().getPlotManager(world.getName());
|
||||
|
||||
int sx = (short) ((this.X) % this.size);
|
||||
int sz = (short) ((this.Z) % this.size);
|
||||
int sx = (short) ((this.X - this.plotworld.ROAD_OFFSET_X) % this.size);
|
||||
int sz = (short) ((this.Z - this.plotworld.ROAD_OFFSET_Z) % this.size);
|
||||
if (sx < 0) {
|
||||
sx += this.size;
|
||||
}
|
||||
|
@ -26,14 +26,16 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int x = dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
return new Location(plotworld.worldname, x, 256, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
z -= dpw.ROAD_OFFSET_Z;
|
||||
int pathWidthLower;
|
||||
int end;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
@ -81,6 +83,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
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;
|
||||
@ -173,8 +177,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int x = dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
return new Location(plotworld.worldname, x, 1, z);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,12 @@ import com.intellectualcrafters.plot.PS;
|
||||
public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
public static int PLOT_WIDTH_DEFAULT = 42;
|
||||
public static int ROAD_WIDTH_DEFAULT = 7;
|
||||
public static int ROAD_OFFSET_X_DEFAULT = 0;
|
||||
public static int ROAD_OFFSET__Z_DEFAULT = 0;
|
||||
public int PLOT_WIDTH;
|
||||
public int ROAD_WIDTH;
|
||||
public int ROAD_OFFSET_X;
|
||||
public int ROAD_OFFSET_Z;
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
@ -16,6 +20,8 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
}
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.ROAD_WIDTH = config.getInt("road.width");
|
||||
this.ROAD_OFFSET_X = config.getInt("road.offset.x");
|
||||
this.ROAD_OFFSET_Z = config.getInt("road.offset.z");
|
||||
this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,6 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
int i2 = i1 + (z * width);
|
||||
for (int x = 0; x < width; x++) {
|
||||
final int index = i2 + x;
|
||||
|
||||
Block block = worldObj.getBlockAt(sx + x, sy + y, sz + z);
|
||||
int id = block.getTypeId();
|
||||
switch(id) {
|
||||
|
Loading…
Reference in New Issue
Block a user