Bug fixes

This commit is contained in:
boy0001 2014-10-11 19:05:50 +11:00
parent 6c1527f41c
commit 6b028988b3
13 changed files with 194 additions and 155 deletions

View File

@ -94,7 +94,12 @@ public class Configuration {
@Override @Override
public Object parseString(String string) { public Object parseString(String string) {
return Biome.valueOf(string.toUpperCase()); for (Biome biome:Biome.values()) {
if (biome.name().equals(string.toUpperCase())) {
return biome;
}
}
return Biome.FOREST;
} }
@Override @Override

View File

@ -10,7 +10,7 @@ public class ConfigurationNode {
private String constant; private String constant;
private Object default_value; private Object default_value;
private String description; private String description;
private Object value = 0; private Object value;
private SettingValue type; private SettingValue type;
public ConfigurationNode(String constant, Object default_value, public ConfigurationNode(String constant, Object default_value,
@ -22,8 +22,8 @@ public class ConfigurationNode {
this.type = type; this.type = type;
} }
public String getType() { public SettingValue getType() {
return this.type.getType(); return this.type;
} }
public boolean isValid(String string) { public boolean isValid(String string) {

View File

@ -66,7 +66,7 @@ public class ConsoleColors {
.replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)) .replaceAll("&n", fromChatColor(ChatColor.UNDERLINE))
.replaceAll("&o", fromChatColor(ChatColor.ITALIC)) .replaceAll("&o", fromChatColor(ChatColor.ITALIC))
.replaceAll("&r", fromChatColor(ChatColor.RESET)); .replaceAll("&r", fromChatColor(ChatColor.RESET));
return input + ConsoleColor.RESET.toString(); return input + "\u001B[0m";
} }
public static String fromChatColor(ChatColor color) { public static String fromChatColor(ChatColor color) {

View File

@ -4,7 +4,11 @@ import org.bukkit.generator.ChunkGenerator;
public abstract class PlotGenerator extends ChunkGenerator { public abstract class PlotGenerator extends ChunkGenerator {
public abstract PlotWorld getPlotWorld(); public PlotGenerator(String world) {
PlotMain.loadWorld(world, this);
}
public abstract PlotWorld getNewPlotWorld(String world);
public abstract PlotManager getPlotManager(); public abstract PlotManager getPlotManager();
} }

View File

@ -118,7 +118,7 @@ public class PlotHelper {
if (ly) { if (ly) {
if (!plot.settings.getMerged(1) if (!plot.settings.getMerged(1)
|| !plot.settings.getMerged(2)) { || !plot.settings.getMerged(2)) {
manager.createRoadSouthEast(plotworld, plot); manager.removeRoadSouthEast(plotworld, plot);
} }
} }
if (!plot.settings.getMerged(1)) { if (!plot.settings.getMerged(1)) {
@ -165,13 +165,13 @@ public class PlotHelper {
if (!lesserPlot.settings.getMerged(2)) { if (!lesserPlot.settings.getMerged(2)) {
lesserPlot.settings.setMerged(2, true); lesserPlot.settings.setMerged(2, true);
greaterPlot.settings.setMerged(0, true); greaterPlot.settings.setMerged(0, true);
manager.createRoadSouth(plotworld, lesserPlot); manager.removeRoadSouth(plotworld, lesserPlot);
} }
} else { } else {
if (!lesserPlot.settings.getMerged(1)) { if (!lesserPlot.settings.getMerged(1)) {
lesserPlot.settings.setMerged(1, true); lesserPlot.settings.setMerged(1, true);
greaterPlot.settings.setMerged(3, true); greaterPlot.settings.setMerged(3, true);
manager.createRoadSouth(plotworld, lesserPlot); manager.removeRoadEast(plotworld, lesserPlot);
} }
} }
} }

View File

@ -55,6 +55,8 @@ import com.intellectualcrafters.plot.database.PlotMeConverter;
import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent;
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import com.intellectualcrafters.plot.generator.WorldGenerator; import com.intellectualcrafters.plot.generator.WorldGenerator;
import com.intellectualcrafters.plot.listeners.PlayerEvents; import com.intellectualcrafters.plot.listeners.PlayerEvents;
import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEditListener;
@ -1132,6 +1134,65 @@ public class PlotMain extends JavaPlugin {
} }
} }
public static void loadWorld(String world, ChunkGenerator generator) {
if (getWorldSettings(world)!=null) {
return;
}
Set<String> worlds;
if (config.contains("worlds")) {
worlds = config.getConfigurationSection("worlds").getKeys(false);
} else {
worlds = new HashSet<String>();
}
if (generator!=null && generator instanceof PlotGenerator) {
sendConsoleSenderMessage(C.PREFIX.s()
+ "&aDetected world load for '" + world + "'.");
PlotGenerator plotgen = (PlotGenerator) generator;
PlotWorld plotworld = plotgen.getNewPlotWorld(world);
PlotManager manager = plotgen.getPlotManager();
if (!config.contains("worlds." + world)) {
config.createSection("worlds." + world);
}
plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world));
plotworld.loadDefaultConfiguration(config.getConfigurationSection("worlds." + world));
try {
config.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
addPlotWorld(world, plotworld, manager);
} else {
if (worlds.contains(world)) {
sendConsoleSenderMessage("&cWorld '"
+ world
+ "' in settings.yml is not using PlotSquared generator!");
PlotWorld plotworld = new DefaultPlotWorld(world);
PlotManager manager = new DefaultPlotManager();
if (!config.contains("worlds." + world)) {
config.createSection("worlds." + world);
}
plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world));
plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world));
try {
config.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
addPlotWorld(world, plotworld, manager);
}
}
}
/** /**
* Adds an external world as a recognized PlotSquared world - The PlotWorld * Adds an external world as a recognized PlotSquared world - The PlotWorld
* class created is based off the configuration in the settings.yml - Do not * class created is based off the configuration in the settings.yml - Do not
@ -1144,39 +1205,8 @@ public class PlotMain extends JavaPlugin {
if (world == null) { if (world == null) {
return; return;
} }
Set<String> worlds;
if (config.contains("worlds")) {
worlds = config.getConfigurationSection("worlds").getKeys(false);
} else {
worlds = new HashSet<String>();
}
ChunkGenerator generator = world.getGenerator(); ChunkGenerator generator = world.getGenerator();
if (generator instanceof PlotGenerator) { loadWorld(world.getName(), generator);
sendConsoleSenderMessage(C.PREFIX.s()
+ "&aDetected world load for '" + world.getName() + "'.");
PlotGenerator plotgen = (PlotGenerator) generator;
PlotWorld plotworld = plotgen.getPlotWorld();
PlotManager manager = plotgen.getPlotManager();
config.createSection("worlds." + world.getName());
plotworld.saveConfiguration(config
.getConfigurationSection("worlds." + world.getName()));
plotworld.loadConfiguration(config
.getConfigurationSection("worlds." + world.getName()));
addPlotWorld(world.getName(), plotworld, manager);
} else {
if (worlds.contains(world.getName())) {
sendConsoleSenderMessage("&cWorld '"
+ world.getName()
+ "' in settings.yml is not using PlotSquared generator!");
}
}
} }
/** /**

View File

@ -86,6 +86,7 @@ import static org.bukkit.Material.getMaterial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
@ -164,13 +165,11 @@ public abstract class PlotWorld {
/** /**
* When a world is created, the following method will be called for each * When a world is created, the following method will be called for each
* node set in the configuration - You may ignore this if you generator does
* not support configuration, or if you want to implement your own methods
* *
* @param key * @param key
* @param value * @param value
*/ */
public void loadConfiguration(ConfigurationSection config) { public void loadDefaultConfiguration(ConfigurationSection config) {
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config
@ -186,26 +185,32 @@ public abstract class PlotWorld {
this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.SELL_PRICE = config.getDouble("economy.prices.sell");
this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.PLOT_CHAT = config.getBoolean("chat.enabled");
this.DEFAULT_FLAGS = config.getStringList("flags.default"); this.DEFAULT_FLAGS = config.getStringList("flags.default");
loadConfiguration(config);
} }
public abstract void loadConfiguration(ConfigurationSection config);
public void saveConfiguration(ConfigurationSection config) { public void saveConfiguration(ConfigurationSection config) {
/* /*
* Saving core plotworld settings * Saving core plotworld settings
*/ */
config.set("natural_mob_spawning", this.MOB_SPAWNING);
config.set("plot.auto_merge", this.AUTO_MERGE); HashMap<String, Object> options = new HashMap<String, Object>();
config.set("plot.biome", this.PLOT_BIOME.name());
config.set("schematic.on_claim", this.SCHEMATIC_ON_CLAIM); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
config.set("schematic.file", this.SCHEMATIC_FILE); options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
config.set("schematic.specify_on_claim", this.SCHEMATIC_CLAIM_SPECIFY); options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
config.set("schematic.schematics", this.SCHEMATICS); options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
config.set("economy.use", this.USE_ECONOMY); options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
config.set("economy.prices.claim", this.PLOT_PRICE); options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
config.set("economy.prices.merge", this.MERGE_PRICE); options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT);
config.set("economy.prices.sell", this.SELL_PRICE); options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT);
config.set("chat.enabled", this.PLOT_CHAT); options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT);
config.set("flags.default", this.DEFAULT_FLAGS); options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
ConfigurationNode[] settings = getSettingNodes(); ConfigurationNode[] settings = getSettingNodes();
@ -213,7 +218,13 @@ public abstract class PlotWorld {
* Saving generator specific settings * Saving generator specific settings
*/ */
for (ConfigurationNode setting : settings) { for (ConfigurationNode setting : settings) {
config.set(setting.getConstant(), setting.getValue()); options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue()));
}
for (String option:options.keySet()) {
if (!config.contains(option)) {
config.set(option, options.get(option));
}
} }
} }

View File

@ -11,12 +11,16 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.uuid.NameFetcher; import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.UUIDFetcher; import com.intellectualcrafters.plot.uuid.UUIDFetcher;
public class UUIDHandler { public class UUIDHandler {
private static ConcurrentHashMap<String, UUID> uuidMap = new ConcurrentHashMap<>(); private static boolean online = Bukkit.getServer().getOnlineMode();
private static BiMap<String, UUID> uuidMap = HashBiMap.create();
public static boolean uuidExists(UUID uuid) { public static boolean uuidExists(UUID uuid) {
return uuidMap.containsValue(uuid); return uuidMap.containsValue(uuid);
@ -41,15 +45,15 @@ public class UUIDHandler {
public void run() { public void run() {
OfflinePlayer[] offlinePlayers = Bukkit OfflinePlayer[] offlinePlayers = Bukkit
.getOfflinePlayers(); .getOfflinePlayers();
int lenght = offlinePlayers.length; int length = offlinePlayers.length;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
String name; String name;
UUID uuid; UUID uuid;
for (OfflinePlayer player : offlinePlayers) { for (OfflinePlayer player : offlinePlayers) {
name = player.getName();
uuid = player.getUniqueId(); uuid = player.getUniqueId();
if (!uuidExists(uuid)) { if (!uuidExists(uuid)) {
name = player.getName();
add(name, uuid); add(name, uuid);
} }
} }
@ -58,7 +62,7 @@ public class UUIDHandler {
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6"
+ time + time
+ "&cms, &6" + "&cms, &6"
+ lenght + length
+ " &cUUID's were cached" + " &cUUID's were cached"
+ " and there is now a grand total of &6" + " and there is now a grand total of &6"
+ uuidMap.size() + " &ccached."); + uuidMap.size() + " &ccached.");
@ -82,7 +86,7 @@ public class UUIDHandler {
if ((uuid = getUuidOfflinePlayer(name)) != null) { if ((uuid = getUuidOfflinePlayer(name)) != null) {
return uuid; return uuid;
} }
if (Bukkit.getOnlineMode()) { if (online) {
try { try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name)); UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name); uuid = fetcher.call().get(name);
@ -102,12 +106,7 @@ public class UUIDHandler {
* @return * @return
*/ */
private static String loopSearch(UUID uuid) { private static String loopSearch(UUID uuid) {
for (Map.Entry<String, UUID> entry : uuidMap.entrySet()) { return uuidMap.inverse().get(uuid);
if (entry.getValue().equals(uuid)) {
return entry.getKey();
}
}
return "";
} }
/** /**
@ -126,7 +125,7 @@ public class UUIDHandler {
if ((name = getNameOfflinePlayer(uuid)) != null) { if ((name = getNameOfflinePlayer(uuid)) != null) {
return name; return name;
} }
if (Bukkit.getOnlineMode()) { if (online) {
try { try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid)); NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid); name = fetcher.call().get(uuid);
@ -204,11 +203,7 @@ public class UUIDHandler {
* @return * @return
*/ */
private static UUID getUuidOfflinePlayer(String name) { private static UUID getUuidOfflinePlayer(String name) {
OfflinePlayer player = Bukkit.getOfflinePlayer(name); UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
if (player == null || !player.hasPlayedBefore()) {
return null;
}
UUID uuid = player.getUniqueId();
add(name, uuid); add(name, uuid);
return uuid; return uuid;
} }

View File

@ -94,7 +94,7 @@ public class Setup extends SubCommand implements Listener {
ConfigurationNode step = object.step[object.current]; ConfigurationNode step = object.step[object.current];
if (args.length < 1) { if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} else { } else {
@ -108,12 +108,12 @@ public class Setup extends SubCommand implements Listener {
object.current--; object.current--;
step = object.step[object.current]; step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} else { } else {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} }
@ -130,14 +130,14 @@ public class Setup extends SubCommand implements Listener {
} }
step = object.step[object.current]; step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} else { } else {
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], sendMessage(plr, C.SETUP_INVALID_ARG, args[0],
step.getConstant()); step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} }
@ -186,7 +186,7 @@ public class Setup extends SubCommand implements Listener {
} }
PlotWorld plotworld; PlotWorld plotworld;
if (generator instanceof PlotGenerator) { if (generator instanceof PlotGenerator) {
plotworld = ((PlotGenerator) generator).getPlotWorld(); plotworld = ((PlotGenerator) generator).getNewPlotWorld(world);
} }
else { else {
plotworld = new DefaultPlotWorld(world); plotworld = new DefaultPlotWorld(world);
@ -197,7 +197,7 @@ public class Setup extends SubCommand implements Listener {
SetupObject object = setupMap.get(plr.getName()); SetupObject object = setupMap.get(plr.getName());
ConfigurationNode step = object.step[object.current]; ConfigurationNode step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(), step.getDescription(), step.getType().getType(),
step.getDefaultValue() + ""); step.getDefaultValue() + "");
return true; return true;
} }

View File

@ -94,16 +94,16 @@ public class Unlink extends SubCommand {
new PlotId(x, y); new PlotId(x, y);
if (lx) { if (lx) {
manager.removeRoadEast(plotworld, plot); manager.createRoadEast(plotworld, plot);
if (ly) { if (ly) {
manager.removeRoadSouthEast(plotworld, plot); manager.createRoadSouthEast(plotworld, plot);
} }
} }
if (ly) { if (ly) {
manager.removeRoadSouth(plotworld, plot); manager.createRoadSouth(plotworld, plot);
} }
} }

View File

@ -729,8 +729,8 @@ public class DefaultPlotManager extends PlotManager {
int sx = pos2.getBlockX(); int sx = pos2.getBlockX();
int ex = (sx + dpw.ROAD_WIDTH); int ex = (sx + dpw.ROAD_WIDTH);
int sz = pos1.getBlockZ() - 1; int sz = pos1.getBlockZ();
int ez = pos2.getBlockZ() + 2; int ez = pos2.getBlockZ() + 1;
PlotHelper.setSimpleCuboid(w, PlotHelper.setSimpleCuboid(w,
new Location(w, sx, new Location(w, sx,
@ -756,8 +756,8 @@ public class DefaultPlotManager extends PlotManager {
int sz = pos2.getBlockZ(); int sz = pos2.getBlockZ();
int ez = (sz + dpw.ROAD_WIDTH); int ez = (sz + dpw.ROAD_WIDTH);
int sx = pos1.getBlockX() - 1; int sx = pos1.getBlockX();
int ex = pos2.getBlockX() + 2; int ex = pos2.getBlockX() + 1;
PlotHelper.setSimpleCuboid(w, PlotHelper.setSimpleCuboid(w,
new Location(w, sx, new Location(w, sx,

View File

@ -62,7 +62,7 @@ public class DefaultPlotWorld extends PlotWorld {
public static int ROAD_WIDTH_DEFAULT = 7; public static int ROAD_WIDTH_DEFAULT = 7;
/** /**
* Plot biome * Plot main block
*/ */
public PlotBlock[] MAIN_BLOCK; public PlotBlock[] MAIN_BLOCK;
/** /**
@ -87,7 +87,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default wall block: 44 * Default wall block: 44
*/ */
public static String WALL_BLOCK_DEFAULT = "44:0"; public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
/** /**
* Wall filling * Wall filling
@ -143,30 +143,30 @@ public class DefaultPlotWorld extends PlotWorld {
public ConfigurationNode[] getSettingNodes() { public ConfigurationNode[] getSettingNodes() {
// TODO return a set of configuration nodes (used for setup command) // TODO return a set of configuration nodes (used for setup command)
return new ConfigurationNode[] { return new ConfigurationNode[] {
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT,
"Plot height", Configuration.INTEGER, true), "Plot height", Configuration.INTEGER, true),
new ConfigurationNode("plot.width", this.PLOT_WIDTH, new ConfigurationNode("plot.width", DefaultPlotWorld.PLOT_WIDTH_DEFAULT,
"Plot width", Configuration.INTEGER, true), "Plot width", Configuration.INTEGER, true),
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT,
"Plot block", Configuration.BLOCKLIST, true), "Plot block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.floor", this.TOP_BLOCK, new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT,
"Plot floor block", Configuration.BLOCKLIST, true), "Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("wall.block", this.WALL_BLOCK, new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT,
"Top wall block", Configuration.BLOCK, true), "Top wall block", Configuration.BLOCK, true),
new ConfigurationNode("road.width", this.ROAD_WIDTH, new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT,
"Road width", Configuration.INTEGER, true), "Road width", Configuration.INTEGER, true),
new ConfigurationNode("road.height", this.ROAD_HEIGHT, new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT,
"Road height", Configuration.INTEGER, true), "Road height", Configuration.INTEGER, true),
new ConfigurationNode("road.enable_stripes", new ConfigurationNode("road.enable_stripes",
this.ROAD_STRIPES_ENABLED, "Enable road stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes",
Configuration.BOOLEAN, true), Configuration.BOOLEAN, true),
new ConfigurationNode("road.block", this.ROAD_BLOCK, new ConfigurationNode("road.block", DefaultPlotWorld.ROAD_BLOCK_DEFAULT,
"Road block", Configuration.BLOCK, true), "Road block", Configuration.BLOCK, true),
new ConfigurationNode("road.stripes", this.ROAD_STRIPES, new ConfigurationNode("road.stripes", DefaultPlotWorld.ROAD_STRIPES_DEFAULT,
"Road stripe block", Configuration.BLOCK, true), "Road stripe block", Configuration.BLOCK, true),
new ConfigurationNode("wall.filling", this.WALL_FILLING, new ConfigurationNode("wall.filling", DefaultPlotWorld.WALL_FILLING_DEFAULT,
"Wall filling block", Configuration.BLOCK, true), "Wall filling block", Configuration.BLOCK, true),
new ConfigurationNode("wall.height", this.WALL_HEIGHT, new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT,
"Wall height", Configuration.INTEGER, true), }; "Wall height", Configuration.INTEGER, true), };
} }
@ -177,7 +177,6 @@ public class DefaultPlotWorld extends PlotWorld {
*/ */
@Override @Override
public void loadConfiguration(ConfigurationSection config) { public void loadConfiguration(ConfigurationSection config) {
this.PLOT_HEIGHT = config.getInt("plot.height"); this.PLOT_HEIGHT = config.getInt("plot.height");
this.PLOT_WIDTH = config.getInt("plot.width"); this.PLOT_WIDTH = config.getInt("plot.width");
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST

View File

@ -44,19 +44,19 @@ public class WorldGenerator extends PlotGenerator {
/* /*
* Some generator specific variables (implementation dependent) * Some generator specific variables (implementation dependent)
*/ */
int plotsize; final int plotsize;
int pathsize; final int pathsize;
PlotBlock wall; final PlotBlock wall;
PlotBlock wallfilling; final PlotBlock wallfilling;
PlotBlock floor1; final PlotBlock floor1;
PlotBlock floor2; final PlotBlock floor2;
int size; final int size;
Biome biome; final Biome biome;
int roadheight; final int roadheight;
int wallheight; final int wallheight;
int plotheight; final int plotheight;
PlotBlock[] plotfloors; final PlotBlock[] plotfloors;
PlotBlock[] filling; final PlotBlock[] filling;
/* /*
* Return the plot manager for this type of generator, or create one * Return the plot manager for this type of generator, or create one
@ -66,13 +66,14 @@ public class WorldGenerator extends PlotGenerator {
if (manager == null) { if (manager == null) {
manager = new DefaultPlotManager(); manager = new DefaultPlotManager();
} }
return null; return manager;
} }
// return the PlotWorld // return the PlotWorld
@Override @Override
public PlotWorld getPlotWorld() { public PlotWorld getNewPlotWorld(String world) {
this.plotworld = new DefaultPlotWorld(world);
return this.plotworld; return this.plotworld;
} }
@ -104,19 +105,17 @@ public class WorldGenerator extends PlotGenerator {
* inside the loop - You don't have to use this this method, but you may * inside the loop - You don't have to use this this method, but you may
* find it useful. * find it useful.
*/ */
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
PlotBlock block) {
for (int x = x1; x < x2; x++) { for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) { for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) { for (int y = y1; y < y2; y++) {
setBlock(this.result, x, y, z, block.data); setBlock(this.result, x, y, z, block.id);
} }
} }
} }
} }
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
int z2, PlotBlock[] blocks) {
if (blocks.length == 1) { if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]); setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]);
} else { } else {
@ -145,9 +144,9 @@ public class WorldGenerator extends PlotGenerator {
* Initialize variables, and create plotworld object used in calculations * Initialize variables, and create plotworld object used in calculations
*/ */
public WorldGenerator(String world) { public WorldGenerator(String world) {
this.plotworld = new DefaultPlotWorld(world); super(world);
this.plotsize = this.plotworld.PLOT_WIDTH; this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH; this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK; this.floor1 = this.plotworld.ROAD_BLOCK;
@ -197,8 +196,10 @@ public class WorldGenerator extends PlotGenerator {
* like to learn how to make a world generator * like to learn how to make a world generator
*/ */
@Override @Override
public short[][] generateExtBlockSections(World world, Random random, public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) {
int cx, int cz, BiomeGrid biomes) {
int maxY = world.getMaxHeight();
this.result = new short[maxY / 16][];
final int prime = 31; final int prime = 31;
int h = 1; int h = 1;
@ -206,16 +207,12 @@ public class WorldGenerator extends PlotGenerator {
h = (prime * h) + cz; h = (prime * h) + cz;
this.state = h; this.state = h;
int maxY = world.getMaxHeight();
this.result = new short[maxY / 16][];
double pathWidthLower; double pathWidthLower;
if ((this.pathsize % 2) == 0) { if ((this.pathsize % 2) == 0) {
pathWidthLower = Math.floor(this.pathsize / 2) - 1; pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else { } else {
pathWidthLower = Math.floor(this.pathsize / 2); pathWidthLower = Math.floor(this.pathsize / 2);
} }
cx = (cx % this.size) + (8 * this.size); cx = (cx % this.size) + (8 * this.size);
cz = (cz % this.size) + (8 * this.size); cz = (cz % this.size) + (8 * this.size);
int absX = (int) ((((cx * 16) + 16) - pathWidthLower - 1) + (8 * this.size)); int absX = (int) ((((cx * 16) + 16) - pathWidthLower - 1) + (8 * this.size));
@ -240,7 +237,6 @@ public class WorldGenerator extends PlotGenerator {
} }
// ROAD (0/24) The following is an inefficient placeholder as it is too // ROAD (0/24) The following is an inefficient placeholder as it is too
// much work to finish it // much work to finish it
if ((this.pathsize > 16) if ((this.pathsize > 16)
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& !((roadStartX < 16) && (roadStartZ < 16)) && !((roadStartX < 16) && (roadStartZ < 16))
@ -248,7 +244,6 @@ public class WorldGenerator extends PlotGenerator {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1); setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
return this.result; return this.result;
} }
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
int start = Math.max((16 - plotMinZ - this.pathsize) + 1, int start = Math.max((16 - plotMinZ - this.pathsize) + 1,
(16 - roadStartZ) + 1); (16 - roadStartZ) + 1);