Well, started working on something totally uneeded... /p setup {world}

Fixed SQLite errors.
This commit is contained in:
Sauilitired 2014-09-26 22:53:42 +02:00
parent 241a70e648
commit ebe636047f
6 changed files with 613 additions and 347 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,16 @@ import org.bukkit.ChatColor;
* *
*/ */
public enum C { public enum C {
/*
* Setup Stuff
*/
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"),
SETUP_STEP("&cStep &6%s&c: %s"),
SETUP_INVALID_ARG("&c%s is not a valid argument for step %s"),
SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
SETUP_FINISHED("&cFinished setup for world &c%s"),
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)"),
/* /*
* Schematic Stuff * Schematic Stuff
*/ */

View File

@ -32,7 +32,7 @@ public class FlagManager {
* Get an AbstractFlag by a string * Get an AbstractFlag by a string
* Returns null if flag does not exist * Returns null if flag does not exist
* @param string * @param string
* @return AbstractFkag * @return AbstractFlag
*/ */
public static AbstractFlag getFlag(String string) { public static AbstractFlag getFlag(String string) {
for (AbstractFlag flag : flags) { for (AbstractFlag flag : flags) {
@ -54,6 +54,7 @@ public class FlagManager {
public static AbstractFlag getFlag(String string, boolean create) { public static AbstractFlag getFlag(String string, boolean create) {
if ((getFlag(string) == null) && create) { if ((getFlag(string) == null) && create) {
AbstractFlag flag = new AbstractFlag(string); AbstractFlag flag = new AbstractFlag(string);
addFlag(flag);
return flag; return flag;
} }
return getFlag(string); return getFlag(string);

View File

@ -1,11 +1,11 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import java.util.Random;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import java.util.Random;
/** /**
* TODO recode this class Fuck you PlotMe! * TODO recode this class Fuck you PlotMe!
* *

View File

@ -0,0 +1,129 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Citymonstret on 2014-09-26.
*/
public class Setup extends SubCommand implements Listener {
public static Map<String, SetupObject> setupMap = new HashMap<>();
/*
ROAD_HEIGHT
PLOT_HEIGHT
WALL_HEIGHT
PLOT_WIDTH
ROAD_WIDTH
PLOT_BIOME
MAIN_BLOCK
TOP_BLOCK
WALL_BLOCK
WALL_FILLING
ROAD_STRIPES
ROAD_STRIPES_ENABLED
ROAD_BLOCK
PLOT_CHAT
BLOCKS
SCHEMATIC_ON_CLAIM
SCHEMATIC_FILE
DEFAULT_FLAGS
*/
private static class SetupStep {
private String constant;
private Object default_value;
private String description;
private Object value = 0;
public SetupStep(String constant, Object default_value, String description) {
this.constant = constant;
this.default_value = default_value;
this.description = description;
}
public boolean setValue(Object o) {
}
public Object getValue() {
return this.value;
}
public String getConstant() {
return this.constant;
}
public Object getDefaultValue() {
return this.default_value;
}
public String getDescription() {
return this.description;
}
}
private static class SetupObject {
private String world;
private int current = 0;
private SetupStep[] step = new SetupStep[] {
new SetupStep("road_height", 64, "Height of road")
};
public SetupObject(String world) {
this.world = world;
PlotWorld p = new PlotWorld();
}
public SetupStep getNextStep() {
return this.step[current++];
}
public int getMax() {
return this.step.length;
}
}
public Setup() {
super("setup", "plots.admin", "Setup a PlotWorld", "/plot setup {world}", "setup", CommandCategory.ACTIONS);
}
@Override
public boolean execute(Player plr, String... args) {
if(args.length < 1) {
sendMessage(plr, C.SETUP_MISSING_WORLD);
return true;
}
String world = args[0];
if(PlotMain.isPlotWorld(Bukkit.getWorld(world))) {
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
return true;
}
setupMap.put(plr.getName(), new SetupObject(world));
sendMessage(plr, C.SETUP_INIT);
return true;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if(!setupMap.containsKey(player.getName())) {
return;
}
event.setCancelled(true);
SetupObject object = setupMap.get(player.getName());
}
}

View File

@ -229,7 +229,7 @@ public class DBFunc {
rs = data.getColumns(null, null, "plot_settings", "merged"); rs = data.getColumns(null, null, "plot_settings", "merged");
if (!rs.next()) { if (!rs.next()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL"); statement.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
statement.executeBatch(); statement.executeBatch();
statement.close(); statement.close();
} }
@ -267,9 +267,6 @@ public class DBFunc {
flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), ""); flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), "");
} }
} }
ArrayList<UUID> helpers = plotHelpers(id); ArrayList<UUID> helpers = plotHelpers(id);
ArrayList<UUID> denied = plotDenied(id); ArrayList<UUID> denied = plotDenied(id);
// boolean changeTime = ((Short) settings.get("custom_time") == // boolean changeTime = ((Short) settings.get("custom_time") ==
@ -281,7 +278,12 @@ public class DBFunc {
// boolean rain = // boolean rain =
// Integer.parseInt(settings.get("rain").toString()) == 1 ? true // Integer.parseInt(settings.get("rain").toString()) == 1 ? true
// : false; // : false;
boolean rain = (int) settings.get("rain") == 1 ? true : false; boolean rain;
try {
rain = (int) settings.get("rain") == 1 ? true : false;
} catch(Exception e) {
rain = false;
}
String alias = (String) settings.get("alias"); String alias = (String) settings.get("alias");
if ((alias == null) || alias.equalsIgnoreCase("NEW")) { if ((alias == null) || alias.equalsIgnoreCase("NEW")) {
alias = ""; alias = "";