mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 19:54:43 +02:00
Removed web and fixed the flag sutff
This commit is contained in:
@ -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;
|
||||
@ -945,8 +933,6 @@ 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);
|
||||
@ -1077,9 +1063,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 +1079,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");
|
||||
|
@ -70,12 +70,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
|
||||
*
|
||||
|
@ -366,13 +366,13 @@ public class Set extends SubCommand {
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
if (FlagManager.getFlags().contains(af) || ((PlotMain.worldGuardListener != null) && PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) {
|
||||
if (FlagManager.getFlags().contains(af)) {
|
||||
StringBuilder a = new StringBuilder();
|
||||
if(args.length > 1) {
|
||||
for(int x = 1; x < args.length; x++)
|
||||
a.append(" " + args[x]);
|
||||
a.append(" ").append(args[x]);
|
||||
}
|
||||
plr.performCommand("plot set flag " + args[0] + args);
|
||||
plr.performCommand("plot set flag " + args[0] + a.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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<String> 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user