New world types (buggy)

This commit is contained in:
boy0001 2015-02-08 10:44:53 +11:00
parent 88357a261b
commit 04876b5d58
21 changed files with 553 additions and 298 deletions

View File

@ -49,7 +49,6 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
@ -70,6 +69,7 @@ import com.intellectualcrafters.plot.commands.Cluster;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.WE_Anywhere; import com.intellectualcrafters.plot.commands.WE_Anywhere;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
@ -84,7 +84,6 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.flag.FlagValue;
import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.ForceFieldListener;
import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.InventoryListener;
@ -94,6 +93,7 @@ import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEditListener;
import com.intellectualcrafters.plot.listeners.WorldGuardListener; import com.intellectualcrafters.plot.listeners.WorldGuardListener;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
@ -186,6 +186,7 @@ public class PlotMain extends JavaPlugin implements Listener {
*/ */
public static boolean useEconomy = false; public static boolean useEconomy = false;
private static PlotMain main = null; private static PlotMain main = null;
private static boolean LOADING_WORLD = false;
/** /**
* MySQL Object * MySQL Object
*/ */
@ -932,11 +933,10 @@ public class PlotMain extends JavaPlugin implements Listener {
final PlotManager plotManager; final PlotManager plotManager;
final String path = "worlds." + world; final String path = "worlds." + world;
if ((generator != null) && (generator instanceof PlotGenerator)) { if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) {
plotGenerator = (PlotGenerator) generator; plotGenerator = (PlotGenerator) generator;
plotWorld = plotGenerator.getNewPlotWorld(world); plotWorld = plotGenerator.getNewPlotWorld(world);
plotManager = plotGenerator.getPlotManager(); plotManager = plotGenerator.getPlotManager();
if (!world.equals("CheckingPlotSquaredGenerator")) { if (!world.equals("CheckingPlotSquaredGenerator")) {
sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - generator: &7" + plotGenerator.getClass().getName()); sendConsoleSenderMessage(C.PREFIX.s() + "&3 - generator: &7" + plotGenerator.getClass().getName());
@ -957,38 +957,62 @@ public class PlotMain extends JavaPlugin implements Listener {
addPlotWorld(world, plotWorld, plotManager); addPlotWorld(world, plotWorld, plotManager);
PlotHelper.setupBorder(world); PlotHelper.setupBorder(world);
} else { } else {
if (worlds.contains(world)) { if (!worlds.contains(world)) {
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!"); return;
}
plotWorld = new HybridPlotWorld(world); if (!LOADING_WORLD) {
plotManager = new HybridPlotManager(); LOADING_WORLD = true;
try {
String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
Plugin gen_plugin = gen_string == null ? null : Bukkit.getPluginManager().getPlugin(gen_string);
if (gen_plugin != null && gen_plugin.isEnabled()) {
gen_plugin.getDefaultWorldGenerator(world, "");
}
else {
new HybridGen(world);
}
}
catch (Exception e) {
System.out.print("ERRRRRRRRRRRRRR 6");
e.printStackTrace();
LOADING_WORLD = false;
removePlotWorld(world);
}
finally {
LOADING_WORLD = false;
}
}
else {
PlotGenerator gen_class = (PlotGenerator) generator;
plotWorld = gen_class.getNewPlotWorld(world);
plotManager = gen_class.getPlotManager();
if (!config.contains(path)) { if (!config.contains(path)) {
config.createSection(path); config.createSection(path);
} }
plotWorld.TYPE = 2;
// TODO Augment the world generation with a custom populator plotWorld.TERRAIN = 0;
PlotWorld.REQUIRE_CLAIM_IN_CLUSTER_DEFAULT = true;
plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.saveConfiguration(config.getConfigurationSection(path));
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
PlotWorld.REQUIRE_CLAIM_IN_CLUSTER_DEFAULT = false;
try { try {
config.save(configFile); config.save(configFile);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (plotWorld.REQUIRE_CLUSTER) { if (plotWorld.TYPE == 2 && !Settings.ENABLE_CLUSTERS) {
if (ClusterManager.getClusters(world).size() > 0) { sendConsoleSenderMessage("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please enable plot custers or delete this world from your settings.yml!");
HybridGen gen = new HybridGen(world); return;
gen.plotworld = (HybridPlotWorld) plotWorld;
for (PlotCluster cluster : ClusterManager.getClusters(world)) {
new AugmentedPopulator(world, gen, cluster);
} }
}
}
// Now add it :p
addPlotWorld(world, plotWorld, plotManager); addPlotWorld(world, plotWorld, plotManager);
if (plotWorld.TYPE == 2) {
if (ClusterManager.getClusters(world).size() > 0) {
for (PlotCluster cluster : ClusterManager.getClusters(world)) {
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
}
}
}
else if (plotWorld.TYPE == 1) {
new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
}
} }
} }
} }
@ -1193,6 +1217,98 @@ public class PlotMain extends JavaPlugin implements Listener {
*/ */
@Override @Override
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
if (id != null && id.length() > 0) {
// save configuration
String[] split = id.split(",");
HybridPlotWorld plotworld = new HybridPlotWorld(world);
int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT;
int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT;
int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT;
PlotBlock[] floor = HybridPlotWorld.TOP_BLOCK_DEFAULT;
PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT;
PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT;
PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT;
for (String element : split) {
String[] pair = element.split("=");
if (pair.length != 2) {
sendConsoleSenderMessage("&cNo value provided for: &7" + element);
return null;
}
String key = pair[0].toLowerCase();
String value = pair[1];
try {
switch (key) {
case "s":
case "size": {
HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
break;
}
case "g":
case "gap": {
HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
break;
}
case "h":
case "height": {
HybridPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
HybridPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
HybridPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
break;
}
case "f":
case "floor": {
HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
break;
}
case "m":
case "main": {
HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
break;
}
case "w":
case "wall": {
HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
break;
}
case "b":
case "border": {
HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
break;
}
default: {
sendConsoleSenderMessage("&cKey not found: &7" + element);
return null;
}
}
}
catch (Exception e) {
e.printStackTrace();
sendConsoleSenderMessage("&cInvalid value: &7" + value + " in arg " + element);
return null;
}
}
try {
String root = "worlds." + world;
if (!config.contains(root)) {
config.createSection(root);
}
plotworld.saveConfiguration(config.getConfigurationSection(root));
HybridPlotWorld.PLOT_HEIGHT_DEFAULT = height;
HybridPlotWorld.ROAD_HEIGHT_DEFAULT = height;
HybridPlotWorld.WALL_HEIGHT_DEFAULT = height;
HybridPlotWorld.TOP_BLOCK_DEFAULT = floor;
HybridPlotWorld.MAIN_BLOCK_DEFAULT = main;
HybridPlotWorld.WALL_BLOCK_DEFAULT = border;
HybridPlotWorld.WALL_FILLING_DEFAULT = wall;
HybridPlotWorld.PLOT_WIDTH_DEFAULT = width;
HybridPlotWorld.ROAD_WIDTH_DEFAULT = gap;
}
catch (Exception e) {
e.printStackTrace();
}
}
return new HybridGen(world); return new HybridGen(world);
} }

View File

@ -161,7 +161,7 @@ public class Auto extends SubCommand {
} }
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
if (plotworld.REQUIRE_CLUSTER) { if (plotworld.TYPE == 2) {
Location loc = plr.getLocation(); Location loc = plr.getLocation();
Plot plot = PlotHelper.getCurrentPlot(loc); Plot plot = PlotHelper.getCurrentPlot(loc);
if (plot == null) { if (plot == null) {

View File

@ -26,7 +26,6 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotCluster;
@ -185,7 +183,7 @@ public class Cluster extends SubCommand {
} }
} }
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld()); PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
if (plotworld.REQUIRE_CLUSTER) { if (plotworld.TYPE == 2) {
ArrayList<Plot> toRemove = new ArrayList<>(); ArrayList<Plot> toRemove = new ArrayList<>();
for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) { for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) {
PlotCluster other = ClusterManager.getCluster(plot); PlotCluster other = ClusterManager.getCluster(plot);
@ -198,7 +196,7 @@ public class Cluster extends SubCommand {
} }
} }
DBFunc.delete(cluster); DBFunc.delete(cluster);
if (plotworld.REQUIRE_CLUSTER) { if (plotworld.TYPE == 2) {
for (Iterator<BlockPopulator> iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) { for (Iterator<BlockPopulator> iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) {
BlockPopulator populator = iterator.next(); BlockPopulator populator = iterator.next();
if (populator instanceof AugmentedPopulator) { if (populator instanceof AugmentedPopulator) {

View File

@ -34,14 +34,8 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
public class DebugFixFlags extends SubCommand { public class DebugFixFlags extends SubCommand {

View File

@ -0,0 +1,328 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.util.PlayerFunctions;
public class DebugSetup extends SubCommand {
public final static Map<String, SetupObject> setupMap = new HashMap<>();
public HashMap<String, PlotGenerator> generators = new HashMap<>();
public DebugSetup() {
super("debugsetup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.DEBUG, true);
}
private class SetupObject {
int current = 0;
int setup_index = 0;
String world = null;
String generator = null;
int type = 0;
int terrain = 0;
ConfigurationNode[] step = null;
}
public void updateGenerators() {
if (generators.size() > 0) {
return;
}
String testWorld = "CheckingPlotSquaredGenerator";
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.isEnabled()) {
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
if (generator != null) {
PlotMain.removePlotWorld(testWorld);
final String name = plugin.getDescription().getName();
if (generator instanceof PlotGenerator) {
generators.put(name, (PlotGenerator) generator);
}
}
}
}
}
@Override
public boolean execute(final Player plr, final String... args) {
// going through setup
String name = plr.getName();
if (!setupMap.containsKey(name)) {
SetupObject object = new SetupObject();
setupMap.put(name, object);
updateGenerators();
String prefix = "\n&8 - &7";
sendMessage(plr, C.SETUP_INIT);
PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
return false;
}
if (args.length == 1) {
if (args[0].equalsIgnoreCase("cancel")) {
setupMap.remove(plr.getName());
PlayerFunctions.sendMessage(plr, "&aCancelled setup");
return false;
}
if (args[0].equalsIgnoreCase("back")) {
SetupObject object = setupMap.get(plr.getName());
if (object.setup_index > 0) {
object.setup_index--;
ConfigurationNode node = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
return false;
}
else if (object.current > 0 ){
object.current--;
}
}
}
SetupObject object = setupMap.get(name);
int index = object.current;
switch(index) {
case 0: { // choose generator
if (args.length != 1 || !generators.containsKey(args[0])) {
String prefix = "\n&8 - &7";
PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
sendMessage(plr, C.SETUP_INIT);
return false;
}
object.generator = args[0];
object.current++;
PlayerFunctions.sendMessage(plr, "&6What world type do you want?"
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
+ "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
break;
}
case 1: { // choose world type
List<String> types = Arrays.asList(new String[] {"default", "augmented", "partial"});
if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!"
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
+ "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
return false;
}
object.type = types.indexOf(args[0].toLowerCase());
if (object.type == 0) {
object.current++;
if (object.step == null) {
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
}
ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
}
else {
PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?"
+ "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
}
object.current++;
break;
}
case 2: { // Choose terrain
List<String> terrain = Arrays.asList(new String[] {"none", "ore", "all"});
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!"
+ "\n&8 - &2NONE&8 - &7No terrain at all"
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
return false;
}
object.terrain = terrain.indexOf(args[0].toLowerCase());
object.current++;
if (object.step == null) {
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
}
ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
break;
}
case 3: { // world setup
if (object.setup_index == object.step.length) {
PlayerFunctions.sendMessage(plr, "&6What do you want your world to be called?");
object.setup_index = 0;
object.current++;
return true;
}
ConfigurationNode step = object.step[object.setup_index];
if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return false;
}
final boolean valid = step.isValid(args[0]);
if (valid) {
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
step.setValue(args[0]);
object.setup_index++;
if (object.setup_index == object.step.length) {
execute(plr, args);
return false;
}
step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return false;
} else {
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return false;
}
}
case 4: {
if (args.length != 1) {
PlayerFunctions.sendMessage(plr, "&cYou need to choose a world name!");
return false;
}
if (Bukkit.getWorld(args[0]) != null) {
PlayerFunctions.sendMessage(plr, "&cThat world name is already taken!");
}
object.world = args[0];
setupMap.remove(plr.getName());
World world = setupWorld(object);
try {
plr.teleport(world.getSpawnLocation());
}
catch (Exception e) {
plr.sendMessage("&cAn error occured. See console for more information");
e.printStackTrace();
}
sendMessage(plr, C.SETUP_FINISHED, object.world);
setupMap.remove(plr.getName());
}
}
/*
* 0.0 normal hybrid no clusters
* 0.1 normal hybrid with clusters
* 0.2 normal hybrid require clusters
* 1.0 augmented whole world
* 1.1 augmented whole world with ore
* 1.2 augmented whole world with terrain
* 2.1 augmented partial world
* 2.2 augmented partial world with ore
* 2.3 augmented partial world with terrain
* 3.0 no generation + normal manager
*
* generator.TYPE: PlotSquared, augmented, partial
* generator.TERRAIN
*
* WORLD.TYPE: hybrid, augmented, partial
* if (augmented/partial)
* WORLD.TERRAIN:
*
*
* types (0, 1, 2, 3)
* 0: no options
* 1:
*
*
* - return null
* - schedule task to create world later
* - externalize multiverse/world hooks to separate class
* - create vanilla world
* - add augmented populator
* - add config option type
* - Work on heirarchy for setting nodes so you don't need to provide irrelevent info (world setup)
* - use code from setup command for world arguments (above) so that it persists
* - work on plot clearing for augmented plot worlds (terrain) (heads, banners, paintings, animals, inventoryhandler)
* - make a generic clear function for any generator
* - clean up plotmanager class (remove unnecessary methods)
* - make simple plot manager which can be used by external generators (don't make abstract)
* - plugins will override any of it's methods
* - make heirarchy of generators of increasing abstraction:
* = totally abstract (circle plots, moving plots, no tesselation)
* = tessellating generator
* = grid generator
* = square generator
* = square plot generator (must have plot section and road section) (plot height, road height)
* = hybrid generator
*
* - All will support whole world augmentation
* - Only grid will support partial plot worlds
*
*/
return false;
}
public World setupWorld(SetupObject object) {
// Configuration
final ConfigurationNode[] steps = object.step;
final String world = object.world;
for (final ConfigurationNode step : steps) {
PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue());
}
if (object.type != 0) {
PlotMain.config.set("worlds." + world + "." + "generator.type", object.type);
PlotMain.config.set("worlds." + world + "." + "generator.terrain", object.terrain);
PlotMain.config.set("worlds." + world + "." + "generator.plugin", object.generator);
}
try {
PlotMain.config.save(PlotMain.configFile);
} catch (final IOException e) {
e.printStackTrace();
}
if (object.type == 0) {
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.generator);
} else {
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator);
} else {
WorldCreator wc = new WorldCreator(object.world);
wc.generator(object.generator);
wc.environment(Environment.NORMAL);
World newWorld = Bukkit.createWorld(wc);
}
}
}
else {
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
} else {
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
} else {
Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL));
}
}
}
return Bukkit.getWorld(object.world);
}
}

View File

@ -34,7 +34,6 @@ import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.InfoInventory;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;

View File

@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
*/ */
public static final String MAIN_PERMISSION = "plots.use"; public static final String MAIN_PERMISSION = "plots.use";
private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags() }; private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSetup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags() };
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() { public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
{ {

View File

@ -27,21 +27,15 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
@ -51,7 +45,6 @@ import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
public class Trim extends SubCommand { public class Trim extends SubCommand {

View File

@ -130,11 +130,11 @@ public enum C {
/* /*
* Setup Stuff * Setup Stuff
*/ */
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld\n&6Additional commands:\n&c - &6/plot setup <value>\n&c - &6/plot setup back\n&c - &6/plot setup cancel"), SETUP_INIT("&6Usage: &7/plot setup <value>"),
SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_STEP("&7[&6Step %s&7] &6%s &cExpecting: &6%s&c, Default: &6%s&c>"),
SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: &6/plot setup cancel"), SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: &6/plot setup cancel"),
SETUP_VALID_ARG("&cValue &6%s &cset for step %s"), SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"), SETUP_FINISHED("&6Finished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"),
SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"),
SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/plot setup &l<world>&6 <generator>&c)\n&6Additional commands:\n&c - &6/plot setup <value>\n&c - &6/plot setup back\n&c - &6/plot setup cancel"), SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/plot setup &l<world>&6 <generator>&c)\n&6Additional commands:\n&c - &6/plot setup <value>\n&c - &6/plot setup back\n&c - &6/plot setup cancel"),
SETUP_MISSING_GENERATOR("&cYou need to specify a generator (&6/plot setup <world> &l<generator>&r&c)\n&6Additional commands:\n&c - &6/plot setup <value>\n&c - &6/plot setup back\n&c - &6/plot setup cancel"), SETUP_MISSING_GENERATOR("&cYou need to specify a generator (&6/plot setup <world> &l<generator>&r&c)\n&6Additional commands:\n&c - &6/plot setup <value>\n&c - &6/plot setup back\n&c - &6/plot setup cancel"),
@ -161,7 +161,7 @@ public enum C {
/* /*
* Core Stuff * Core Stuff
*/ */
PREFIX("&c[&6&lPlot&c] "), PREFIX("&c[&6&Plot&c] "),
ENABLED("&6PlotSquared is now enabled"), ENABLED("&6PlotSquared is now enabled"),
EXAMPLE_MESSAGE("&cThis is an example message &k!!!"), EXAMPLE_MESSAGE("&cThis is an example message &k!!!"),
/* /*

View File

@ -37,7 +37,6 @@ import java.util.UUID;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
@ -49,7 +48,6 @@ import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotClusterId;
import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;

View File

@ -1,6 +1,5 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.HashSet;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -13,10 +12,9 @@ import org.bukkit.generator.BlockPopulator;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.object.BlockWrapper; import com.intellectualcrafters.plot.object.BlockWrapper;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
@ -27,6 +25,9 @@ public class AugmentedPopulator extends BlockPopulator {
public final PlotManager manager; public final PlotManager manager;
public final PlotGenerator generator; public final PlotGenerator generator;
public final PlotCluster cluster; public final PlotCluster cluster;
public final boolean p;
public final boolean b;
public final boolean o;
private final int bx; private final int bx;
private final int bz; private final int bz;
@ -46,25 +47,37 @@ public class AugmentedPopulator extends BlockPopulator {
} }
} }
public AugmentedPopulator(String world, PlotGenerator generator, PlotCluster cluster) { public AugmentedPopulator(String world, PlotGenerator generator, PlotCluster cluster, boolean p, boolean b) {
this.cluster = cluster; this.cluster = cluster;
this.generator = generator; this.generator = generator;
this.plotworld = PlotMain.getWorldSettings(world); this.plotworld = PlotMain.getWorldSettings(world);
this.manager = generator.getPlotManager(); this.manager = generator.getPlotManager();
this.p = p;
this.b = b;
this.o = this.plotworld.TERRAIN == 1 || this.plotworld.TERRAIN == 2;
World bukkitWorld = Bukkit.getWorld(world); World bukkitWorld = Bukkit.getWorld(world);
Location b = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); if (cluster != null) {
Location t = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1); Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1);
this.bx = b.getBlockX(); this.bx = bl.getBlockX();
this.bz = b.getBlockZ(); this.bz = bl.getBlockZ();
this.tx = t.getBlockX(); this.tx = tl.getBlockX();
this.tz = t.getBlockZ(); this.tz = tl.getBlockZ();
}
else {
this.bx = Integer.MIN_VALUE;
this.bz = Integer.MIN_VALUE;
this.tx = Integer.MAX_VALUE;
this.tz = Integer.MAX_VALUE;
}
// Add the populator // Add the populator
if (this.plotworld.CLUSTER_ORE) { if (this.o) {
bukkitWorld.getPopulators().add(0, this); bukkitWorld.getPopulators().add(0, this);
} }
else { else {
@ -73,7 +86,7 @@ public class AugmentedPopulator extends BlockPopulator {
} }
@Override @Override
public void populate(final World world, final Random rand, Chunk chunk) { public void populate(final World world, final Random rand, final Chunk chunk) {
final int X = chunk.getX(); final int X = chunk.getX();
final int Z = chunk.getZ(); final int Z = chunk.getZ();
final int x = X << 4; final int x = X << 4;
@ -100,12 +113,15 @@ public class AugmentedPopulator extends BlockPopulator {
else { else {
check = false; check = false;
} }
if (this.plotworld.CLUSTER_ORE) { if (this.o) {
chunk.load(true);
populateBlocks(world, rand, X, Z, x, z, check); populateBlocks(world, rand, X, Z, x, z, check);
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
populateBiome(world, x, z); populateBiome(world, x, z);
chunk.unload();
chunk.load();
} }
}, 20); }, 20);
} }
@ -119,20 +135,24 @@ public class AugmentedPopulator extends BlockPopulator {
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
chunk.load(true);
populateBlocks(world, rand, X, Z, x, z, check); populateBlocks(world, rand, X, Z, x, z, check);
chunk.unload();
chunk.load();
} }
}, 40 + rand.nextInt(10)); }, 40 + rand.nextInt(40));
} }
} }
private void populateBiome(World world, int x, int z) { private void populateBiome(World world, int x, int z) {
if (this.b) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
world.setBiome(x + i, z + j, plotworld.PLOT_BIOME); world.setBiome(x + i, z + j, plotworld.PLOT_BIOME);
} }
} }
} }
}
private void populateBlocks(World world, Random rand, int X, int Z, int x, int z, boolean check) { private void populateBlocks(World world, Random rand, int X, int Z, int x, int z, boolean check) {
short[][] result = generator.generateExtBlockSections(world, rand, X, Z, null); short[][] result = generator.generateExtBlockSections(world, rand, X, Z, null);
@ -143,8 +163,13 @@ public class AugmentedPopulator extends BlockPopulator {
if (blockInfo == null) { if (blockInfo == null) {
continue; continue;
} }
int xx = x + blockInfo.x;
int zz = z + blockInfo.z;
if (p && manager.getPlotIdAbs(plotworld, new Location(world, xx, 0, zz)) != null) {
continue;
}
PlotBlock plotblock = new PlotBlock((short) blockInfo.id, (byte) 0 ); PlotBlock plotblock = new PlotBlock((short) blockInfo.id, (byte) 0 );
Block block = world.getBlockAt(x + blockInfo.x, blockInfo.y, z + blockInfo.z); Block block = world.getBlockAt(xx, blockInfo.y, zz);
PlotHelper.setBlock(block, plotblock); PlotHelper.setBlock(block, plotblock);
} }
} }

View File

@ -90,7 +90,6 @@ public class HybridGen extends PlotGenerator {
*/ */
public HybridGen(final String world) { public HybridGen(final String world) {
super(world); super(world);
if (this.plotworld == null) { if (this.plotworld == null) {
this.plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world); this.plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world);
} }
@ -165,7 +164,9 @@ public class HybridGen extends PlotGenerator {
*/ */
@Override @Override
public PlotWorld getNewPlotWorld(final String world) { public PlotWorld getNewPlotWorld(final String world) {
if (this.plotworld == null) {
this.plotworld = new HybridPlotWorld(world); this.plotworld = new HybridPlotWorld(world);
}
return this.plotworld; return this.plotworld;
} }

View File

@ -48,40 +48,40 @@ public class HybridPlotWorld extends PlotWorld {
/** /**
* Default Road Height: 64 * Default Road Height: 64
*/ */
public final static int ROAD_HEIGHT_DEFAULT = 64; public static int ROAD_HEIGHT_DEFAULT = 64;
/** /**
* Default plot height: 64 * Default plot height: 64
*/ */
public final static int PLOT_HEIGHT_DEFAULT = 64; public static int PLOT_HEIGHT_DEFAULT = 64;
/** /**
* Default Wall Height: 64 * Default Wall Height: 64
*/ */
public final static int WALL_HEIGHT_DEFAULT = 64; public static int WALL_HEIGHT_DEFAULT = 64;
/** /**
* Default plot width: 32 * Default plot width: 32
*/ */
public final static int PLOT_WIDTH_DEFAULT = 32; public static int PLOT_WIDTH_DEFAULT = 32;
/** /**
* Default road width: 7 * Default road width: 7
*/ */
public final static int ROAD_WIDTH_DEFAULT = 7; public static int ROAD_WIDTH_DEFAULT = 7;
/** /**
* Default main block: 1 * Default main block: 1
*/ */
public final static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) }; public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
/** /**
* Default top blocks: {"2"} * Default top blocks: {"2"}
*/ */
public final static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) }; public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
/** /**
* Default wall block: 44 * Default wall block: 44
*/ */
public final static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0); public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1); public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
/** /**
* Default wall filling: 1 * Default wall filling: 1
*/ */
public final static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0); public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
/** /**
* Default road block: 155 * Default road block: 155
*/ */

View File

@ -30,7 +30,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;

View File

@ -81,7 +81,8 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldInitEvent;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.commands.Setup; import com.intellectualcrafters.plot.commands.Setup;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
@ -109,7 +110,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onWorldLoad(final WorldLoadEvent event) { public static void onWorldInit(final WorldInitEvent event) {
PlotMain.loadWorld(event.getWorld()); PlotMain.loadWorld(event.getWorld());
} }
@ -518,7 +519,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void MobSpawn(final CreatureSpawnEvent event) { public static void MobSpawn(final CreatureSpawnEvent event) {
System.out.print(1);
final World world = event.getLocation().getWorld(); final World world = event.getLocation().getWorld();
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
return; return;

View File

@ -32,9 +32,7 @@ import org.bukkit.Location;
import org.bukkit.WeatherType; import org.bukkit.WeatherType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
@ -45,13 +43,11 @@ import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.AbstractTitle;
import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.sk89q.worldguard.protection.flags.BooleanFlag;
/** /**
* @author Citymonstret * @author Citymonstret
@ -91,7 +87,7 @@ import com.sk89q.worldguard.protection.flags.BooleanFlag;
public static boolean isPlotArea(Location location) { public static boolean isPlotArea(Location location) {
PlotWorld plotworld = PlotMain.getWorldSettings(location.getWorld()); PlotWorld plotworld = PlotMain.getWorldSettings(location.getWorld());
if (Settings.ENABLE_CLUSTERS && plotworld.REQUIRE_CLUSTER) { if (plotworld.TYPE == 2) {
return ClusterManager.getCluster(location) != null; return ClusterManager.getCluster(location) != null;
} }
return true; return true;

View File

@ -4,8 +4,6 @@ import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
public class PlotCluster { public class PlotCluster {

View File

@ -60,8 +60,6 @@ public abstract class PlotWorld {
public final static boolean SPAWN_CUSTOM_DEFAULT = true; public final static boolean SPAWN_CUSTOM_DEFAULT = true;
public final static boolean SPAWN_BREEDING_DEFAULT = false; public final static boolean SPAWN_BREEDING_DEFAULT = false;
public final static boolean WORLD_BORDER_DEFAULT = false; public final static boolean WORLD_BORDER_DEFAULT = false;
public static boolean REQUIRE_CLAIM_IN_CLUSTER_DEFAULT = false;
public static boolean CLUSTER_GEN_ORE_DEFAULT = true;
// are plot clusters enabled // are plot clusters enabled
// require claim in cluster // require claim in cluster
@ -69,200 +67,7 @@ public abstract class PlotWorld {
// TODO make this configurable // TODO make this configurable
// make non static and static_default_valu + add config option // make non static and static_default_valu + add config option
public static List<Material> BLOCKS; /* public static List<Material> BLOCKS;
* =
* new
* ArrayList
* <
* >
* (
* Arrays
* .
* asList
* (
* new
* Material
* [
* ]
* {
* ACACIA_STAIRS
* ,
* BEACON
* ,
* BEDROCK
* ,
* BIRCH_WOOD_STAIRS
* ,
* BOOKSHELF
* ,
* BREWING_STAND
* ,
* BRICK
* ,
* BRICK_STAIRS
* ,
* BURNING_FURNACE
* ,
* CAKE_BLOCK
* ,
* CAULDRON
* ,
* CLAY_BRICK
* ,
* CLAY
* ,
* COAL_BLOCK
* ,
* COAL_ORE
* ,
* COBBLE_WALL
* ,
* COBBLESTONE
* ,
* COBBLESTONE_STAIRS
* ,
* COMMAND
* ,
* DARK_OAK_STAIRS
* ,
* DAYLIGHT_DETECTOR
* ,
* DIAMOND_ORE
* ,
* DIAMOND_BLOCK
* ,
* DIRT
* ,
* DISPENSER
* ,
* DROPPER
* ,
* EMERALD_BLOCK
* ,
* EMERALD_ORE
* ,
* ENCHANTMENT_TABLE
* ,
* ENDER_PORTAL_FRAME
* ,
* ENDER_STONE
* ,
* FURNACE
* ,
* GLOWSTONE
* ,
* GOLD_ORE
* ,
* GOLD_BLOCK
* ,
* GRASS
* ,
* GRAVEL
* ,
* GLASS
* ,
* HARD_CLAY
* ,
* HAY_BLOCK
* ,
* HUGE_MUSHROOM_1
* ,
* HUGE_MUSHROOM_2
* ,
* IRON_BLOCK
* ,
* IRON_ORE
* ,
* JACK_O_LANTERN
* ,
* JUKEBOX
* ,
* JUNGLE_WOOD_STAIRS
* ,
* LAPIS_BLOCK
* ,
* LAPIS_ORE
* ,
* LEAVES
* ,
* LEAVES_2
* ,
* LOG
* ,
* LOG_2
* ,
* MELON_BLOCK
* ,
* MOB_SPAWNER
* ,
* MOSSY_COBBLESTONE
* ,
* MYCEL
* ,
* NETHER_BRICK
* ,
* NETHER_BRICK_STAIRS
* ,
* NETHERRACK
* ,
* NOTE_BLOCK
* ,
* OBSIDIAN
* ,
* PACKED_ICE
* ,
* PUMPKIN
* ,
* QUARTZ_BLOCK
* ,
* QUARTZ_ORE
* ,
* QUARTZ_STAIRS
* ,
* REDSTONE_BLOCK
* ,
* SANDSTONE
* ,
* SAND
* ,
* SANDSTONE_STAIRS
* ,
* SMOOTH_BRICK
* ,
* SMOOTH_STAIRS
* ,
* SNOW_BLOCK
* ,
* SOUL_SAND
* ,
* SPONGE
* ,
* SPRUCE_WOOD_STAIRS
* ,
* STONE
* ,
* WOOD
* ,
* WOOD_STAIRS
* ,
* WORKBENCH
* ,
* WOOL
* ,
* getMaterial
* (
* 44
* )
* ,
* getMaterial
* (
* 126
* )
* }
* )
* )
* ;
*/
static { static {
BLOCKS = new ArrayList<>(); BLOCKS = new ArrayList<>();
@ -293,8 +98,8 @@ public abstract class PlotWorld {
public boolean SPAWN_CUSTOM; public boolean SPAWN_CUSTOM;
public boolean SPAWN_BREEDING; public boolean SPAWN_BREEDING;
public boolean WORLD_BORDER; public boolean WORLD_BORDER;
public boolean REQUIRE_CLUSTER = false; public int TYPE = 0;
public boolean CLUSTER_ORE; public int TERRAIN = 0;
public PlotWorld(final String worldname) { public PlotWorld(final String worldname) {
this.worldname = worldname; this.worldname = worldname;
@ -307,8 +112,10 @@ public abstract class PlotWorld {
*/ */
public void loadDefaultConfiguration(final ConfigurationSection config) { public void loadDefaultConfiguration(final ConfigurationSection config) {
if (Settings.ENABLE_CLUSTERS) { if (Settings.ENABLE_CLUSTERS) {
this.REQUIRE_CLUSTER = config.getBoolean("cluster.require-claim-in-cluster"); if (config.contains("generator.terrain")) {
this.CLUSTER_ORE = config.getBoolean("cluster.generate-ores"); this.TERRAIN = config.getInt("generator.terrain");
this.TYPE = config.getInt("generator.type");
}
} }
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");
@ -373,9 +180,9 @@ public abstract class PlotWorld {
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT); options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT); options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT); options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT);
if (Settings.ENABLE_CLUSTERS) { if (Settings.ENABLE_CLUSTERS && this.TYPE != 0) {
options.put("cluster.require-claim-in-cluster", PlotWorld.REQUIRE_CLAIM_IN_CLUSTER_DEFAULT); options.put("generator.terrain", this.TERRAIN);
options.put("cluster.generate-ores", PlotWorld.CLUSTER_GEN_ORE_DEFAULT); options.put("generator.type", this.TYPE);
} }
final ConfigurationNode[] settings = getSettingNodes(); final ConfigurationNode[] settings = getSettingNodes();
/* /*

View File

@ -15,7 +15,6 @@ import org.bukkit.generator.BlockPopulator;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
@ -287,7 +286,7 @@ public class ClusterManager {
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (populator == null || plotworld.CLUSTER_ORE) { if (populator == null || plotworld.TYPE == 0) {
world.regenerateChunk(chunk.getX(), chunk.getZ()); world.regenerateChunk(chunk.getX(), chunk.getZ());
chunk.unload(); chunk.unload();
chunk.load(); chunk.load();

View File

@ -148,7 +148,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
} }
final PlotWorld plotworld = PlotMain.getWorldSettings(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world);
PlotId id = manager.getPlotId(plotworld, loc); PlotId id = manager.getPlotId(plotworld, loc);
if (id!=null && plotworld.REQUIRE_CLUSTER) { if (id!=null && plotworld.TYPE != 0) {
if (ClusterManager.getCluster(world, id) == null) { if (ClusterManager.getCluster(world, id) == null) {
return null; return null;
} }

View File

@ -88,6 +88,10 @@ import com.intellectualcrafters.plot.object.PlotWorld;
} }
} }
public static void createWorld(String world, String generator) {
}
public static PlotId parseId(String arg) { public static PlotId parseId(String arg) {
try { try {
String[] split = arg.split(";"); String[] split = arg.split(";");