mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Finished setup command
This commit is contained in:
parent
8b50bdd330
commit
e0c5c285bb
@ -29,11 +29,11 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"),
|
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"),
|
||||||
SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"),
|
SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"),
|
||||||
SETUP_INVALID_ARG("&c%s is not a valid argument for step %s"),
|
SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /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"),
|
SETUP_FINISHED("&cFinished setup for world &c%s. To create it, type &6/plots setup create"),
|
||||||
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/p setup {world}&c)"),
|
SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||||
/*
|
/*
|
||||||
* Schematic Stuff
|
* Schematic Stuff
|
||||||
*/
|
*/
|
||||||
|
@ -16,8 +16,11 @@ import com.sk89q.worldedit.blocks.ClothColor.ID;
|
|||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -31,21 +34,6 @@ public class PlotHelper {
|
|||||||
public static boolean canSetFast = false;
|
public static boolean canSetFast = false;
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param blocks
|
|
||||||
* @param blocks_per_second
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public PlotHelper() {
|
|
||||||
try {
|
|
||||||
new SetBlockFast();
|
|
||||||
canSetFast = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
canSetFast = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double calculateNeededTime(double blocks, double blocks_per_second) {
|
private static double calculateNeededTime(double blocks, double blocks_per_second) {
|
||||||
return (blocks / blocks_per_second);
|
return (blocks / blocks_per_second);
|
||||||
}
|
}
|
||||||
@ -740,6 +728,27 @@ public class PlotHelper {
|
|||||||
return new short[] { Short.parseShort(block), 0 };
|
return new short[] { Short.parseShort(block), 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearAllEntities(World world, Plot plot, boolean tile) {
|
||||||
|
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
|
final Location pos2 = getPlotTopLoc(world, plot.id);
|
||||||
|
for (int i = (pos1.getBlockX() / 16) * 16; i < 16+(pos2.getBlockX() / 16) * 16; i += 16) {
|
||||||
|
for (int j = (pos1.getBlockZ() / 16) * 16; j < 16+(pos2.getBlockZ() / 16) * 16; j += 16) {
|
||||||
|
Chunk chunk = world.getChunkAt(i, j);
|
||||||
|
for (Entity entity:chunk.getEntities()) {
|
||||||
|
PlotId id = PlayerFunctions.getPlot(entity.getLocation());
|
||||||
|
if (id!=null && id.equals(plot.id)) {
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tile) {
|
||||||
|
for (BlockState entity:chunk.getTileEntities()) {
|
||||||
|
entity.setRawData((byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a plot
|
* Clear a plot
|
||||||
* @param requester
|
* @param requester
|
||||||
@ -750,10 +759,14 @@ public class PlotHelper {
|
|||||||
// TODO teleport any players underground to the surface
|
// TODO teleport any players underground to the surface
|
||||||
|
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
final World world = requester.getWorld();
|
||||||
|
|
||||||
|
// clear entities:
|
||||||
|
clearAllEntities(world, plot, false);
|
||||||
|
|
||||||
|
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||||
final World world = requester.getWorld();
|
|
||||||
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
final Location pos2 = getPlotTopLoc(world, plot.id);
|
final Location pos2 = getPlotTopLoc(world, plot.id);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import ca.mera.CameraAPI;
|
import ca.mera.CameraAPI;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||||
import com.intellectualcrafters.plot.Settings.Web;
|
import com.intellectualcrafters.plot.Settings.Web;
|
||||||
import com.intellectualcrafters.plot.commands.Camera;
|
import com.intellectualcrafters.plot.commands.Camera;
|
||||||
@ -25,8 +26,10 @@ import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
|||||||
import com.intellectualcrafters.plot.listeners.WorldGuardListener;
|
import com.intellectualcrafters.plot.listeners.WorldGuardListener;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
import me.confuser.barapi.BarAPI;
|
import me.confuser.barapi.BarAPI;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -603,6 +606,14 @@ public class PlotMain extends JavaPlugin {
|
|||||||
if (Web.ENABLED) {
|
if (Web.ENABLED) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us.");
|
sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
new SetBlockFast();
|
||||||
|
PlotHelper.canSetFast = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
PlotHelper.canSetFast = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,9 +92,10 @@ public class WorldGenerator extends ChunkGenerator {
|
|||||||
options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_DEFAULT);
|
options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_DEFAULT);
|
||||||
options.put("worlds." + world + ".schematic.schematics", plotworld.SCHEMATICS);
|
options.put("worlds." + world + ".schematic.schematics", plotworld.SCHEMATICS);
|
||||||
options.put("worlds." + world + ".schematic.specify_on_claim", plotworld.SCHEMATIC_CLAIM_SPECIFY);
|
options.put("worlds." + world + ".schematic.specify_on_claim", plotworld.SCHEMATIC_CLAIM_SPECIFY);
|
||||||
options.put("worlds." + world + ".economy.use", plotworld.USE_ECONOMY);
|
options.put("worlds." + world + ".economy.use", plotworld.USE_ECONOMY); // Access should be static
|
||||||
options.put("worlds." + world + ".economy.prices.claim", plotworld.PLOT_PRICE);
|
options.put("worlds." + world + ".economy.prices.claim", plotworld.PLOT_PRICE); // Access should be static
|
||||||
options.put("worlds." + world + ".economy.prices.merge", plotworld.MERGE_PRICE);
|
options.put("worlds." + world + ".economy.prices.merge", plotworld.MERGE_PRICE); // Access should be static
|
||||||
|
options.put("worlds." + world + ".chat.enabled", PLOT_CHAT_DEFAULT);
|
||||||
for (Entry<String, Object> node : options.entrySet()) {
|
for (Entry<String, Object> node : options.entrySet()) {
|
||||||
if (!config.contains(node.getKey())) {
|
if (!config.contains(node.getKey())) {
|
||||||
config.set(node.getKey(), node.getValue());
|
config.set(node.getKey(), node.getValue());
|
||||||
@ -127,6 +128,7 @@ public class WorldGenerator extends ChunkGenerator {
|
|||||||
this.plotworld.USE_ECONOMY = config.getBoolean("worlds." + world + ".economy.use");
|
this.plotworld.USE_ECONOMY = config.getBoolean("worlds." + world + ".economy.use");
|
||||||
this.plotworld.PLOT_PRICE = config.getDouble("worlds." + world + ".economy.prices.claim");
|
this.plotworld.PLOT_PRICE = config.getDouble("worlds." + world + ".economy.prices.claim");
|
||||||
this.plotworld.MERGE_PRICE = config.getDouble("worlds." + world + ".economy.prices.merge");
|
this.plotworld.MERGE_PRICE = config.getDouble("worlds." + world + ".economy.prices.merge");
|
||||||
|
this.plotworld.PLOT_CHAT = config.getBoolean("worlds." + world + ".chat.enabled");
|
||||||
|
|
||||||
String[] default_flags_string = config.getStringList("worlds." + world + ".flags.default").toArray(new String[0]);
|
String[] default_flags_string = config.getStringList("worlds." + world + ".flags.default").toArray(new String[0]);
|
||||||
Flag[] default_flags = new Flag[default_flags_string.length];
|
Flag[] default_flags = new Flag[default_flags_string.length];
|
||||||
|
@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
*/
|
*/
|
||||||
public class MainCommand implements CommandExecutor {
|
public class MainCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), 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 Reload(), new Merge(), new Unlink(), new Kick() };
|
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), 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 Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
|
||||||
|
|
||||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
|
@ -1,18 +1,46 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.AUTO_MERGE_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.DEFAULT_FLAGS_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.MAIN_BLOCK_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.PLOT_BIOME_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.PLOT_WIDTH_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.ROAD_BLOCK_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.ROAD_HEIGHT_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.ROAD_WIDTH_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_FILE_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.TOP_BLOCK_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.WALL_BLOCK_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.WALL_FILLING_DEFAULT;
|
||||||
|
import static com.intellectualcrafters.plot.PlotWorld.WALL_HEIGHT_DEFAULT;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.WorldGenerator;
|
import com.intellectualcrafters.plot.WorldGenerator;
|
||||||
|
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -28,56 +56,102 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
private Object default_value;
|
private Object default_value;
|
||||||
private String description;
|
private String description;
|
||||||
private Object value = 0;
|
private Object value = 0;
|
||||||
private Class type;
|
private String type;
|
||||||
public SetupStep(String constant, Object default_value, String description, Class type) {
|
private boolean require_previous;
|
||||||
|
public SetupStep(String constant, Object default_value, String description, String type, boolean require_previous) {
|
||||||
this.constant = constant;
|
this.constant = constant;
|
||||||
this.default_value = default_value;
|
this.default_value = default_value;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.require_previous = require_previous;
|
||||||
|
}
|
||||||
|
public boolean getRequire() {
|
||||||
|
return this.require_previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getType() {
|
public boolean setValue(String string) {
|
||||||
if (this.type == Integer.class) {
|
if (!validValue(string)) {
|
||||||
return Integer.class;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.type == Boolean.class) {
|
switch (this.type) {
|
||||||
return Boolean.class;
|
case "integer":
|
||||||
|
value = Integer.parseInt(string);
|
||||||
|
break;
|
||||||
|
case "boolean":
|
||||||
|
value = Boolean.parseBoolean(string);
|
||||||
|
break;
|
||||||
|
case "double":
|
||||||
|
value = Double.parseDouble(string);
|
||||||
|
break;
|
||||||
|
case "float":
|
||||||
|
value = Float.parseFloat(string);
|
||||||
|
break;
|
||||||
|
case "biome":
|
||||||
|
value = Biome.valueOf(string.toUpperCase());
|
||||||
|
break;
|
||||||
|
case "block":
|
||||||
|
value = string;
|
||||||
|
break;
|
||||||
|
case "blocklist":
|
||||||
|
value = string.split(",");
|
||||||
|
break;
|
||||||
|
case "string":
|
||||||
|
value = string;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (this.type == Double.class) {
|
|
||||||
return Double.class;
|
|
||||||
}
|
|
||||||
if (this.type == Float.class) {
|
|
||||||
return Float.class;
|
|
||||||
}
|
|
||||||
if (this.type == String.class) {
|
|
||||||
return String.class;
|
|
||||||
}
|
|
||||||
return Object.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setValue(Object o) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validValue(String string) {
|
public boolean validValue(String string) {
|
||||||
try {
|
try {
|
||||||
if (this.type == Integer.class) {
|
if (this.type.equals("integer")) {
|
||||||
Integer.parseInt(string);
|
Integer.parseInt(string);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.type == Boolean.class) {
|
if (this.type.equals("boolean")) {
|
||||||
Boolean.parseBoolean(string);
|
Boolean.parseBoolean(string);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.type == Double.class) {
|
if (this.type.equals("double")) {
|
||||||
Double.parseDouble(string);
|
Double.parseDouble(string);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.type == Float.class) {
|
if (this.type.equals("float")) {
|
||||||
Float.parseFloat(string);
|
Float.parseFloat(string);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.type == String.class) {
|
if (this.type.equals("biome")) {
|
||||||
|
Biome.valueOf(string.toUpperCase());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.type.equals("block")) {
|
||||||
|
if (string.contains(":")) {
|
||||||
|
String[] split = string.split(":");
|
||||||
|
Short.parseShort(split[0]);
|
||||||
|
Short.parseShort(split[1]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Short.parseShort(string);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.type.equals("blocklist")) {
|
||||||
|
for (String block:string.split(",")) {
|
||||||
|
if (block.contains(":")) {
|
||||||
|
String[] split = block.split(":");
|
||||||
|
Short.parseShort(split[0]);
|
||||||
|
Short.parseShort(split[1]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Short.parseShort(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.type.equals("string")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,34 +179,26 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
private class SetupObject {
|
private class SetupObject {
|
||||||
String world;
|
String world;
|
||||||
int current = 0;
|
int current = 0;
|
||||||
PlotWorld p;
|
|
||||||
/*
|
SetupStep[] step = new SetupStep[] {
|
||||||
ROAD_HEIGHT - Integer
|
new SetupStep("road.height", PlotWorld.ROAD_HEIGHT_DEFAULT, "Height of road", "integer", false),
|
||||||
PLOT_HEIGHT - Integer
|
new SetupStep("plot.height", PlotWorld.PLOT_HEIGHT_DEFAULT, "Height of plot", "integer", false),
|
||||||
WALL_HEIGHT - Integer
|
new SetupStep("wall.height", PlotWorld.WALL_HEIGHT_DEFAULT, "Height of wall", "integer", false),
|
||||||
PLOT_WIDTH - Integer
|
new SetupStep("plot.size", PlotWorld.PLOT_WIDTH_DEFAULT, "Size of plot", "integer", false),
|
||||||
ROAD_WIDTH - Integer
|
new SetupStep("road.width", PlotWorld.ROAD_WIDTH_DEFAULT, "Width of road", "integer", false),
|
||||||
PLOT_BIOME - BIOME
|
new SetupStep("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT, "Plot biome", "biome", false),
|
||||||
MAIN_BLOCK - Block[] (as you can have several blocks, with IDS)
|
new SetupStep("plot.filling", PlotWorld.MAIN_BLOCK_DEFAULT, "Plot filling", "blocklist", false),
|
||||||
TOP_BLOCK - Block[] (as you can have several blocks, with IDS)
|
new SetupStep("plot.floor", PlotWorld.TOP_BLOCK_DEFAULT, "Plot floor", "blocklist", false),
|
||||||
WALL_BLOCK - Block
|
new SetupStep("wall.block", PlotWorld.WALL_BLOCK_DEFAULT, "Wall block", "block", false),
|
||||||
WALL_FILLING - Block
|
new SetupStep("wall.filling", PlotWorld.WALL_FILLING_DEFAULT, "Wall filling", "block", false),
|
||||||
ROAD_STRIPES - Block
|
new SetupStep("road.enable_stripes", PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", "boolean", false),
|
||||||
ROAD_STRIPES_ENABLED - Boolean
|
new SetupStep("road.stripes", PlotWorld.ROAD_STRIPES_DEFAULT, "Road stripes block", "block", true),
|
||||||
ROAD_BLOCK - Block
|
new SetupStep("road.block", PlotWorld.ROAD_BLOCK_DEFAULT, "Road block", "block", false),
|
||||||
PLOT_CHAT - Boolean
|
};
|
||||||
BLOCKS - wtf is this?
|
|
||||||
SCHEMATIC_ON_CLAIM - Boolean
|
|
||||||
SCHEMATIC_FILE - String
|
|
||||||
DEFAULT_FLAGS - String[]
|
|
||||||
*/
|
|
||||||
SetupStep[] step = new SetupStep[] { new SetupStep("road_height", 64, "Height of road", Integer.class) };
|
|
||||||
|
|
||||||
public SetupObject(String world) {
|
public SetupObject(String world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.p = new PlotWorld();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetupStep getNextStep() {
|
public SetupStep getNextStep() {
|
||||||
return this.step[current++];
|
return this.step[current++];
|
||||||
}
|
}
|
||||||
@ -140,6 +206,10 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
public int getCurrent() {
|
public int getCurrent() {
|
||||||
return this.current;
|
return this.current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCurrent(String string) {
|
||||||
|
this.step[current].setValue(string);
|
||||||
|
}
|
||||||
|
|
||||||
public int getMax() {
|
public int getMax() {
|
||||||
return this.step.length;
|
return this.step.length;
|
||||||
@ -150,55 +220,63 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
super("setup", "plots.admin", "Setup a PlotWorld", "/plot setup {world}", "setup", CommandCategory.ACTIONS);
|
super("setup", "plots.admin", "Setup a PlotWorld", "/plot setup {world}", "setup", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* /plot setup {world} <default> - setup a world using default values
|
|
||||||
* (display current default settings)
|
|
||||||
* (use ordinary chat to get/set)
|
|
||||||
* <value> <option> - modify a value
|
|
||||||
* /plot setup create - create the world
|
|
||||||
*
|
|
||||||
* /plot setup {world} <world> - setup a world using the values for an existing world
|
|
||||||
* (display current world settings)
|
|
||||||
* (use ordinary chat to get/set)
|
|
||||||
* <value> <option> - modify a value
|
|
||||||
* /plot setup create - create the world
|
|
||||||
*
|
|
||||||
* /plot setup {world} - setup the world manually
|
|
||||||
* (display current world settings)
|
|
||||||
* (use ordinary chat to set)
|
|
||||||
* <option> - set the current value
|
|
||||||
* back - to go back a step
|
|
||||||
* /plot setup create - create the world
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
if(setupMap.containsKey(plr.getName())) {
|
if(setupMap.containsKey(plr.getName())) {
|
||||||
SetupObject object = setupMap.get(plr.getName());
|
SetupObject object = setupMap.get(plr.getName());
|
||||||
if(object.getCurrent() == object.getMax()) {
|
if(object.getCurrent() == object.getMax()) {
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
|
||||||
|
SetupStep[] steps = object.step;
|
||||||
|
String world = object.world;
|
||||||
|
for (SetupStep step:steps) {
|
||||||
|
PlotMain.config.set("worlds."+world+"."+step.constant, step.value);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PlotMain.config.save(PlotMain.configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
World newWorld = WorldCreator.name(world).generator(new WorldGenerator(world)).createWorld();
|
||||||
|
plr.teleport(newWorld.getSpawnLocation());
|
||||||
|
|
||||||
setupMap.remove(plr.getName());
|
setupMap.remove(plr.getName());
|
||||||
|
|
||||||
// Save stuff to config
|
|
||||||
|
|
||||||
// Generate a world
|
|
||||||
// String name = "{world}";
|
|
||||||
// World world = WorldCreator.name(name).generator(new WorldGenerator(name)).createWorld();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SetupStep step = object.step[object.current];
|
SetupStep step = object.step[object.current];
|
||||||
if(args.length < 1) {
|
if(args.length < 1) {
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getName(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
if (args[0].equalsIgnoreCase("cancel")) {
|
||||||
|
setupMap.remove(plr.getName());
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("back")) {
|
||||||
|
if (object.current>0) {
|
||||||
|
object.current--;
|
||||||
|
step = object.step[object.current];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean valid = step.validValue(args[0]);
|
boolean valid = step.validValue(args[0]);
|
||||||
if(valid) {
|
if(valid) {
|
||||||
sendMessage(plr, C.SETUP_VALID_ARG);
|
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||||
|
step.setValue(args[0]);
|
||||||
object.current++;
|
object.current++;
|
||||||
|
step = object.step[object.current];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
} else {
|
} else {
|
||||||
sendMessage(plr, C.SETUP_INVALID_ARG);
|
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -207,12 +285,19 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String world = args[0];
|
String world = args[0];
|
||||||
if (PlotMain.isPlotWorld(Bukkit.getWorld(world))) {
|
if (StringUtils.isNumeric(args[0])) {
|
||||||
|
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (PlotMain.getWorldSettings(world)!=null) {
|
||||||
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
setupMap.put(plr.getName(), new SetupObject(world));
|
setupMap.put(plr.getName(), new SetupObject(world));
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
|
SetupObject object = setupMap.get(plr.getName());
|
||||||
|
SetupStep step = object.step[object.current];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user