mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-09 09:59:48 +01:00
plot settings
This commit is contained in:
parent
040045eed5
commit
d4393caaf4
@ -209,10 +209,6 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
*/
|
||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
|
||||
/**
|
||||
* If plotme converter is enabled
|
||||
*/
|
||||
private static boolean CONVERT_PLOTME = enablePlotMe();
|
||||
/**
|
||||
* Return an instance of MySQL
|
||||
*/
|
||||
@ -899,7 +895,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
public static void worldLoad(WorldLoadEvent event) {
|
||||
if (!UUIDHandler.CACHED) {
|
||||
UUIDHandler.cacheAll();
|
||||
if (CONVERT_PLOTME) {
|
||||
if (Settings.CONVERT_PLOTME && Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||
try {
|
||||
new PlotMeConverter(PlotMain.getMain()).runAsync();
|
||||
} catch (final Exception e) {
|
||||
@ -1323,49 +1319,11 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
Logger.add(LogLevel.GENERAL, "Logger enabled");
|
||||
}
|
||||
|
||||
public static boolean enablePlotMe() {
|
||||
if (!Settings.CONVERT_PLOTME) {
|
||||
return false;
|
||||
}
|
||||
File file = new File(new File("").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe-Core.jar");
|
||||
if (file.exists()) {
|
||||
sendConsoleSenderMessage("&b==== Copying 'PlotMe-Core.jar' to 'PlotMe_JAR_relocated' for conversion purposes ===");
|
||||
sendConsoleSenderMessage("&c - If you do not wish to convert, please stop the server now and set 'plotme-convert.enabled' to false");
|
||||
sendConsoleSenderMessage("&3 - Please ignore the below stacktrace...");
|
||||
try {
|
||||
File to = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe_JAR_relocated" + File.separator + "PlotMe-Core.jar");
|
||||
File parent = to.getParentFile();
|
||||
if(!parent.exists()){
|
||||
parent.mkdirs();
|
||||
}
|
||||
to.createNewFile();
|
||||
Files.copy(file, to);
|
||||
file.delete();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch(InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
file = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe.jar");
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* On Load.
|
||||
*/
|
||||
@Override
|
||||
final public void onEnable() {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||
CONVERT_PLOTME = true;
|
||||
}
|
||||
PlotMain.main = this;
|
||||
// Setup the logger mechanics
|
||||
setupLogger();
|
||||
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
||||
public class WE_Anywhere extends SubCommand {
|
||||
|
||||
public WE_Anywhere() {
|
||||
super("weanywhere", "plots.worldedit.bypass", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
||||
super("weanywhere", "plots.admin", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,9 +39,15 @@ public class WE_Anywhere extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PWE.hasMask(plr)) {
|
||||
PWE.removeMask(plr);
|
||||
PlayerFunctions.sendMessage(plr, "&6Removed your WorldEdit mask");
|
||||
PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask");
|
||||
}
|
||||
else {
|
||||
PWE.setMask(plr, plr.getLocation());
|
||||
PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,26 +21,29 @@
|
||||
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.*;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
@ -54,6 +57,7 @@ public class PlotMeConverter {
|
||||
* PlotMain Object
|
||||
*/
|
||||
private final PlotMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -69,48 +73,43 @@ public class PlotMeConverter {
|
||||
|
||||
public void runAsync() throws Exception {
|
||||
// We have to make it wait a couple of seconds
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sendMessage("Conversion has started");
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||
File plotMeFile = new File(dataFolder + "config.yml");
|
||||
final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
||||
int count = 0;
|
||||
|
||||
Connection connection;
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
String password = plotConfig.getString("mySQLpass");
|
||||
String con = plotConfig.getString("mySQLconn").replaceAll("jdbc:mysql://", "");
|
||||
String host = con.split(":")[0];
|
||||
String port = con.split(":")[1].split("/")[0];
|
||||
String database = con.split(":")[1].split("/")[1];
|
||||
MySQL mySQL = new MySQL(PlotMain.getMain(), host, port, database, user, password);
|
||||
connection = mySQL.openConnection();
|
||||
}
|
||||
else {
|
||||
final String user = plotConfig.getString("mySQLuname");
|
||||
final String password = plotConfig.getString("mySQLpass");
|
||||
final String con = plotConfig.getString("mySQLconn");
|
||||
connection = DriverManager.getConnection(con, user, password);
|
||||
} else {
|
||||
connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator + "plots.db").openConnection();
|
||||
}
|
||||
sendMessage("Collecting plot data");
|
||||
ResultSet r;
|
||||
Statement stmt;
|
||||
HashMap<String, Integer> plotSize = new HashMap<>();
|
||||
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
||||
Set<String> worlds = plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
final HashMap<String, Integer> plotSize = new HashMap<>();
|
||||
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
||||
final Set<String> worlds = plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
stmt = connection.createStatement();
|
||||
r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
|
||||
while (r.next()) {
|
||||
count++;
|
||||
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
String name = r.getString("owner");
|
||||
String world = r.getString("world");
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("owner");
|
||||
final String world = r.getString("world");
|
||||
if (!plotSize.containsKey(world)) {
|
||||
int size = r.getInt("topZ") - r.getInt("bottomZ");
|
||||
final int size = r.getInt("topZ") - r.getInt("bottomZ");
|
||||
plotSize.put(world, size);
|
||||
plots.put(world, new HashMap<PlotId, Plot>());
|
||||
}
|
||||
@ -119,27 +118,25 @@ public class PlotMeConverter {
|
||||
if (owner == null) {
|
||||
if (name.equals("*")) {
|
||||
owner = DBFunc.everyone;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendMessage("&cCould not identify owner for plot: " + id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Plot plot = new Plot(id, owner, new ArrayList<UUID>() , new ArrayList<UUID>(), world);
|
||||
final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||
plots.get(world).put(id, plot);
|
||||
}
|
||||
|
||||
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
||||
while (r.next()) {
|
||||
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
String name = r.getString("player");
|
||||
String world = r.getString("world");
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
final String world = r.getString("world");
|
||||
UUID helper = UUIDHandler.getUUID(name);
|
||||
if (helper == null) {
|
||||
if (name.equals("*")) {
|
||||
helper = DBFunc.everyone;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendMessage("&6Could not identify helper for plot: " + id);
|
||||
continue;
|
||||
}
|
||||
@ -151,15 +148,14 @@ public class PlotMeConverter {
|
||||
|
||||
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
||||
while (r.next()) {
|
||||
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
String name = r.getString("player");
|
||||
String world = r.getString("world");
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
final String world = r.getString("world");
|
||||
UUID denied = UUIDHandler.getUUID(name);
|
||||
if (denied == null) {
|
||||
if (name.equals("*")) {
|
||||
denied = DBFunc.everyone;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendMessage("&6Could not identify denied for plot: " + id);
|
||||
continue;
|
||||
}
|
||||
@ -171,7 +167,7 @@ public class PlotMeConverter {
|
||||
|
||||
sendMessage("Collected " + count + " plots from PlotMe");
|
||||
|
||||
for (String world : plots.keySet()) {
|
||||
for (final String world : plots.keySet()) {
|
||||
sendMessage("Copying config for: " + world);
|
||||
try {
|
||||
final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
|
||||
@ -199,11 +195,11 @@ public class PlotMeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (PLOTME_DG_FILE.exists()) {
|
||||
YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||
try {
|
||||
for (String world : plots.keySet()) {
|
||||
for (final String world : plots.keySet()) {
|
||||
final Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + world + ".PathWidth"); //
|
||||
PlotMain.config.set("worlds." + world + ".road.width", pathwidth);
|
||||
|
||||
@ -225,18 +221,16 @@ public class PlotMeConverter {
|
||||
final Integer height = PLOTME_DG_YML.getInt("worlds." + world + ".RoadHeight"); //
|
||||
PlotMain.config.set("worlds." + world + ".road.height", height);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
for (String world : plots.keySet()) {
|
||||
for (final String world : plots.keySet()) {
|
||||
int duplicate = 0;
|
||||
for (Plot plot : plots.get(world).values()) {
|
||||
for (final Plot plot : plots.get(world).values()) {
|
||||
if (!PlotMain.getPlots(world).containsKey(plot.id)) {
|
||||
createdPlots.add(plot);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
duplicate++;
|
||||
}
|
||||
}
|
||||
@ -245,7 +239,6 @@ public class PlotMeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sendMessage("Creating plot DB");
|
||||
DBFunc.createPlots(createdPlots);
|
||||
sendMessage("Creating settings/helpers DB");
|
||||
@ -257,6 +250,10 @@ public class PlotMeConverter {
|
||||
sendMessage(" - &cFailed to save configuration.");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(PlotMain.getMain(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean MV = false;
|
||||
boolean MW = false;
|
||||
|
||||
@ -302,12 +299,15 @@ public class PlotMeConverter {
|
||||
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
|
||||
sendMessage("Conversion has finished");
|
||||
PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
@ -253,10 +253,8 @@ import java.util.Set;
|
||||
if (!isPlotWorld(q)) {
|
||||
if (isPlotWorld(f)) {
|
||||
PWE.removeMask(p);
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
PWE.setMask(p, q);
|
||||
}
|
||||
|
@ -156,6 +156,9 @@ import java.util.Set;
|
||||
|
||||
public ArrayList<PlotComment> getComments(final int tier) {
|
||||
final ArrayList<PlotComment> c = new ArrayList<>();
|
||||
if (this.comments == null) {
|
||||
return c;
|
||||
}
|
||||
for (final PlotComment comment : this.comments) {
|
||||
if (comment.tier == tier) {
|
||||
c.add(comment);
|
||||
|
@ -52,7 +52,9 @@ import org.bukkit.entity.Player;
|
||||
} else {
|
||||
s = PlotMain.worldEdit.getSession(p);
|
||||
}
|
||||
|
||||
if (!PlotMain.isPlotWorld(p.getWorld())) {
|
||||
removeMask(p);
|
||||
}
|
||||
final PlotId id = PlayerFunctions.getPlot(l);
|
||||
if (id != null) {
|
||||
final Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
|
||||
@ -95,6 +97,16 @@ import org.bukkit.entity.Player;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasMask(final Player p) {
|
||||
LocalSession s;
|
||||
if (PlotMain.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotMain.worldEdit.getSession(p);
|
||||
}
|
||||
return !noMask(s);
|
||||
}
|
||||
|
||||
public static boolean noMask(final LocalSession s) {
|
||||
return s.getMask() == null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user