diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c7baa40bc..4d6b89d5b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -9,13 +9,8 @@ - - - - - - - + + @@ -39,108 +34,91 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - + + - - + + - - - - - - + + + - - + + - - - - - - + + + - - + + - - - - - - + + + - - + + - - - - - - + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + @@ -149,7 +127,7 @@ - + @@ -169,7 +147,6 @@ @@ -260,7 +238,6 @@ - @@ -306,28 +283,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -448,137 +370,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -745,7 +536,9 @@ - + + + 1411382351159 @@ -979,11 +772,35 @@ 1413998882732 1413998882732 - - @@ -1006,7 +823,7 @@ - + @@ -1021,12 +838,12 @@ - + - + @@ -1081,12 +898,6 @@ - - - - - - @@ -1106,11 +917,17 @@ - - @@ -1118,20 +935,6 @@ - - - - - - - - - - - - - - @@ -1276,7 +1079,6 @@ - @@ -1326,7 +1128,6 @@ - @@ -1334,7 +1135,6 @@ - @@ -1342,31 +1142,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1377,35 +1152,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1413,7 +1163,6 @@ - @@ -1421,10 +1170,6 @@ - - - - @@ -1432,7 +1177,6 @@ - @@ -1440,9 +1184,6 @@ - - - @@ -1450,10 +1191,6 @@ - - - - @@ -1461,10 +1198,6 @@ - - - - @@ -1472,10 +1205,6 @@ - - - - @@ -1483,10 +1212,7 @@ - - - - + @@ -1508,8 +1234,72 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java index 310f1f720..7ad06128a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot; import org.apache.commons.lang.StringUtils; -import org.bukkit.ChatColor; public class Flag { private AbstractFlag key; @@ -21,8 +20,14 @@ public class Flag { * if you provide inadequate inputs */ public Flag(AbstractFlag key, String value) { - if (!StringUtils.isAlphanumericSpace(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', value)))) { - throw new IllegalArgumentException("Flag must be alphanumerical"); + char[] allowedCharacters = new char[] { + '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', 'ยง' + }; + String tempValue = value; + for(char c : allowedCharacters) + tempValue = tempValue.replace(c, 'c'); + if (!StringUtils.isAlphanumericSpace(tempValue)) { + throw new IllegalArgumentException("Flag must be alphanumerical (colours and some special characters are allowed)"); } if (value.length() > 48) { throw new IllegalArgumentException("Value must be <= 48 characters"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 12e53a0ce..b9984e133 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -9,16 +9,10 @@ package com.intellectualcrafters.plot; import ca.mera.CameraAPI; - import com.intellectualcrafters.plot.Logger.LogLevel; -import com.intellectualcrafters.plot.Settings.Web; import com.intellectualcrafters.plot.commands.Camera; import com.intellectualcrafters.plot.commands.MainCommand; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.database.MySQL; -import com.intellectualcrafters.plot.database.PlotMeConverter; -import com.intellectualcrafters.plot.database.SQLManager; -import com.intellectualcrafters.plot.database.SQLite; +import com.intellectualcrafters.plot.database.*; import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.generator.DefaultPlotManager; @@ -31,10 +25,8 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver; import com.intellectualcrafters.plot.uuid.UUIDSaver; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; - import me.confuser.barapi.BarAPI; import net.milkbowl.vault.economy.Economy; - import org.bukkit.*; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; @@ -718,10 +710,6 @@ public class PlotMain extends JavaPlugin { useEconomy = (economy != null); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L); - if (Web.ENABLED) { - sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us."); - } - try { new SetBlockFast(); PlotHelper.canSetFast = true; @@ -938,6 +926,7 @@ public class PlotMain extends JavaPlugin { Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); + Settings.SCHEMATIC_SAVE_PATH = config.getString("schematic.save_path"); } if (Settings.DEBUG) { Map settings = new HashMap<>(); @@ -945,12 +934,11 @@ public class PlotMain extends JavaPlugin { settings.put("Use Metrics", "" + Settings.METRICS); settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN); settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING); - settings.put("Web Enabled", "" + Web.ENABLED); - settings.put("Web Port", "" + Web.PORT); settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL); settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE); settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR); settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS); + settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH); for (Entry setting : settings.entrySet()) { sendConsoleSenderMessage(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); @@ -1077,9 +1065,6 @@ public class PlotMain extends JavaPlugin { options.put("worldguard.enabled", Settings.WORLDGUARD); options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); - options.put("web.enabled", Web.ENABLED); - options.put("web.directory", "/var/www"); - options.put("web.port", Web.PORT); options.put("metrics", true); options.put("debug", true); options.put("clear.auto.enabled", false); @@ -1096,9 +1081,6 @@ public class PlotMain extends JavaPlugin { if (Settings.DEBUG) { sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } - Web.ENABLED = config.getBoolean("web.enabled"); - Web.PORT = config.getInt("web.port"); - Web.PATH = config.getString("web.directory"); Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); Settings.WORLDGUARD = config.getBoolean("worldguard.enabled"); Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding"); @@ -1106,6 +1088,7 @@ public class PlotMain extends JavaPlugin { Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.MAX_PLOTS = config.getInt("max_plots"); + Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); } public static void createConfiguration(PlotWorld plotworld) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java index 29ff27347..8892a1e5e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java @@ -15,6 +15,7 @@ package com.intellectualcrafters.plot; * @author Empire92 */ public class Settings { + public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics"; public static int MAX_PLOTS = 20; /** * WorldGuard region on claimed plots @@ -70,12 +71,6 @@ public class Settings { public static boolean AUTO_UPDATE = false; } - public static class Web { - public static boolean ENABLED = false; - public static int PORT = 9000; - public static String PATH = "/var/www"; - } - /** * Database settings * diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java index 335e918ca..ff625ddb5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java @@ -1,26 +1,13 @@ package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; - +import com.intellectualcrafters.jnbt.CompoundTag; +import com.intellectualcrafters.plot.*; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.plot.C; -import com.intellectualcrafters.plot.PlayerFunctions; -import com.intellectualcrafters.plot.Plot; -import com.intellectualcrafters.plot.PlotHelper; -import com.intellectualcrafters.plot.PlotId; -import com.intellectualcrafters.plot.PlotMain; -import com.intellectualcrafters.plot.SchematicHandler; -import com.intellectualcrafters.plot.Settings; -import com.intellectualcrafters.plot.UUIDHandler; -import com.intellectualcrafters.plot.database.DBFunc; -import com.sun.org.apache.xerces.internal.impl.xs.identity.ValueStore; +import java.util.HashMap; public class Schematic extends SubCommand { @@ -160,8 +147,7 @@ public class Schematic extends SubCommand { @Override public void run() { PlayerFunctions.sendMessage(plr, "&6ID: "+plot.id); - boolean result = SchematicHandler.save(sch, Settings.Web.PATH+"/"+plot.id.x+","+plot.id.y+","+worldname+", "+owner+".schematic"); - + boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH+"/"+plot.id.x+","+plot.id.y+","+worldname+","+owner+".schematic"); if (!result) { PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c"+plot.id); } @@ -251,8 +237,7 @@ public class Schematic extends SubCommand { @Override public void run() { PlayerFunctions.sendMessage(plr, "&6ID: "+plot.id); - boolean result = SchematicHandler.save(sch, Settings.Web.PATH+"/"+plot.id.x+","+plot.id.y+","+world+","+owner+".schematic"); - + boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH+"/"+plot.id.x+","+plot.id.y+","+world+","+owner+".schematic"); if (!result) { PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c"+plot.id); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index fa2f82e24..2fe1f8f67 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -359,10 +359,24 @@ public class Set extends SubCommand { PlotHelper.adjustWallFilling(plr, plot, new PlotBlock((short) material.getId(), data)); return true; } - StringBuilder builder = new StringBuilder(); - builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); - builder.append(getArgumentList(values)); - PlayerFunctions.sendMessage(plr, builder.toString()); + { + AbstractFlag af = new AbstractFlag(""); + try { + af = new AbstractFlag(args[0].toLowerCase()); + } + catch (Exception e) { + } + if (FlagManager.getFlags().contains(af)) { + StringBuilder a = new StringBuilder(); + if(args.length > 1) { + for(int x = 1; x < args.length; x++) + a.append(" ").append(args[x]); + } + plr.performCommand("plot set flag " + args[0] + a.toString()); + return true; + } + } + PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java index 7b1b9f21b..71de3e21c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -175,6 +175,7 @@ public class PlotListener { } public static void plotExit(Player player, Plot plot) { + player.setAllowFlight(false); { PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); diff --git a/PlotSquared/src/com/intellectualsites/web/IndexHandler.java b/PlotSquared/src/com/intellectualsites/web/IndexHandler.java deleted file mode 100644 index 2eb358ff5..000000000 --- a/PlotSquared/src/com/intellectualsites/web/IndexHandler.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.intellectualsites.web; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.plugin.java.JavaPlugin; -import org.simpleframework.http.Request; -import org.simpleframework.http.Response; -import org.simpleframework.http.core.Container; - -/** - * Created by Citymonstret on 2014-09-20. - */ -public class IndexHandler implements Container { - - private JavaPlugin plugin; - private String title; - - public IndexHandler(JavaPlugin plugin, String title) { - this.plugin = plugin; - this.title = title; - } - - @Override - public void handle(Request request, Response response) { - try { - PrintStream body; - long time; - String coverage; - - body = response.getPrintStream(); - time = System.currentTimeMillis(); - request.getQuery(); - request.getPath(); - - if ((request.getInteger("page")) < 0) { - } - if (((coverage = request.getTarget()) == null) || coverage.equals("/")) { - coverage = "index"; - } - - coverage = coverage.toLowerCase(); - - List list = new ArrayList<>(Arrays.asList(new String[] { "install", "index", "stylesheet" })); - - if (!list.contains(coverage)) { - coverage = "index"; - } - - if (coverage.equals("stylesheet")) { - response.setValue("Content-Type", "text/css"); - response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)"); - response.setDate("Date", time); - response.setDate("Last-Modified", time); - - ResourceHandler stylesheet = - new ResourceHandler("stylesheet", ResourceHandler.FileType.CSS, this.plugin.getDataFolder()); - - String stylesheetHTML = stylesheet.getHTML(); - - stylesheet.done(); - - body.print(stylesheetHTML); - } - else { - response.setValue("Content-Type", "html"); - response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)"); - response.setDate("Date", time); - response.setDate("Last-Modified", time); - - ResourceHandler header = - new ResourceHandler("header", ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); - ResourceHandler footer = - new ResourceHandler("footer", ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); - ResourceHandler cPage = - new ResourceHandler(coverage, ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); - - String headerHTML = header.getHTML().replace("@title", this.title); - String footerHTML = footer.getHTML(); - String cPageHTML = cPage.getHTML(); - - header.done(); - footer.done(); - cPage.done(); - - body.print(headerHTML); - body.print(cPageHTML); - body.print(footerHTML); - } - body.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/PlotSquared/src/com/intellectualsites/web/PlotWeb.java b/PlotSquared/src/com/intellectualsites/web/PlotWeb.java deleted file mode 100644 index fb9260710..000000000 --- a/PlotSquared/src/com/intellectualsites/web/PlotWeb.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.intellectualsites.web; - -import java.net.InetSocketAddress; -import java.net.SocketAddress; - -import org.bukkit.plugin.java.JavaPlugin; -import org.simpleframework.http.core.Container; -import org.simpleframework.http.core.ContainerServer; -import org.simpleframework.transport.Server; -import org.simpleframework.transport.connect.Connection; -import org.simpleframework.transport.connect.SocketConnection; - -import com.intellectualcrafters.plot.PlotMain; - -/** - * Created by Citymonstret on 2014-09-20. - */ -public class PlotWeb { - - // TODO instructions on how to setup and use PlotWeb. - - public static PlotWeb PLOTWEB; - - private String title; - private int port; - private Server server; - private Connection connection; - private Container container; - private SocketAddress address; - - public PlotWeb(String title, int port) { - this.title = title; - this.port = port; - } - - public void start() throws Exception { - this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), this.title); - this.server = new ContainerServer(this.container); - this.connection = new SocketConnection(this.server); - this.address = new InetSocketAddress(this.port); - - this.connection.connect(this.address); - PLOTWEB = this; - } - - public void stop() throws Exception { - this.connection.close(); - PLOTWEB = null; - } -} diff --git a/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java b/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java deleted file mode 100644 index ceb93fbf6..000000000 --- a/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.intellectualsites.web; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; - -/** - * Created by Citymonstret on 2014-09-20. - */ -public class ResourceHandler { - - private File file; - private BufferedReader reader; - - public ResourceHandler(String filePath, FileType fileType, File folder) throws Exception { - if (fileType == FileType.CSS) { - this.file = - new File(folder.toPath().toString() + File.separator + "web" + File.separator + "css" - + File.separator + filePath + "." + fileType.toString()); - } - else { - this.file = - new File(folder.toPath().toString() + File.separator + "web" + File.separator + filePath + "." - + fileType.toString()); - } - } - - public String getHTML() throws Exception { - StringBuilder html = new StringBuilder(); - this.reader = new BufferedReader(new InputStreamReader(new FileInputStream(this.file))); - String line = ""; - while ((line = this.reader.readLine()) != null) { - html.append(line); - } - return html.toString(); - } - - public void done() throws Exception { - this.reader.close(); - } - - public static enum FileType { - CSS("css"), - HTML("html"), - JS("js"); - - private String ext; - - FileType(String ext) { - this.ext = ext; - } - - @Override - public String toString() { - return this.ext; - } - } -} diff --git a/PlotSquared/src/com/intellectualsites/web/Test.java b/PlotSquared/src/com/intellectualsites/web/Test.java deleted file mode 100644 index 3691e3857..000000000 --- a/PlotSquared/src/com/intellectualsites/web/Test.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.intellectualsites.web; - -/** - * Created by Citymonstret on 2014-09-20. - */ -public class Test { - - public static void main(String[] args) { - try { - new PlotWeb("Test", 9000).start(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - -}