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