mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
not much actually changed, but it seems to be working fine now.
This commit is contained in:
parent
8597117d7a
commit
1511db8d12
@ -137,10 +137,9 @@ public class DBFunc {
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Integer id : helpers.keySet()) {
|
for (Integer id : helpers.keySet()) {
|
||||||
for (UUID helper : helpers.get(id)) {
|
for (UUID helper : helpers.get(id)) {
|
||||||
|
|
||||||
stmt.setInt((counter * 2) + 1, id);
|
stmt.setInt((counter * 2) + 1, id);
|
||||||
stmt.setString((counter * 2) + 2, helper.toString());
|
stmt.setString((counter * 2) + 2, helper.toString());
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +213,6 @@ public class DBFunc {
|
|||||||
*/
|
*/
|
||||||
public static void createTables(String database, boolean add_constraint) throws SQLException {
|
public static void createTables(String database, boolean add_constraint) throws SQLException {
|
||||||
boolean mysql = database.equals("mysql");
|
boolean mysql = database.equals("mysql");
|
||||||
|
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
|
|
||||||
if (mysql) {
|
if (mysql) {
|
||||||
@ -236,7 +234,6 @@ public class DBFunc {
|
|||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.executeBatch();
|
stmt.executeBatch();
|
||||||
stmt.clearBatch();
|
stmt.clearBatch();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
@ -4,15 +4,18 @@ import java.io.PrintStream;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
|
||||||
import com.worldcretornica.plotme.PlayerList;
|
import com.worldcretornica.plotme.PlayerList;
|
||||||
import com.worldcretornica.plotme.Plot;
|
import com.worldcretornica.plotme.Plot;
|
||||||
import com.worldcretornica.plotme.PlotManager;
|
import com.worldcretornica.plotme.PlotManager;
|
||||||
@ -30,16 +33,14 @@ public class PlotMeConverter {
|
|||||||
|
|
||||||
public void runAsync() throws Exception {
|
public void runAsync() throws Exception {
|
||||||
|
|
||||||
Bukkit.getOnlineMode();
|
|
||||||
|
|
||||||
final PrintStream stream = new PrintStream("converter_log.txt");
|
final PrintStream stream = new PrintStream("converter_log.txt");
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started");
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started");
|
||||||
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
|
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
|
||||||
HashMap<String, UUID> uuidMap = new HashMap<String, UUID>();
|
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
@ -47,11 +48,27 @@ public class PlotMeConverter {
|
|||||||
// TODO generate configuration based on PlotMe config
|
// TODO generate configuration based on PlotMe config
|
||||||
// - Plugin doesn't display a message if database is not
|
// - Plugin doesn't display a message if database is not
|
||||||
// setup at all
|
// setup at all
|
||||||
|
|
||||||
|
// List<String> names = new ArrayList<String>();
|
||||||
|
// for (Plot plot : plots.values()) {
|
||||||
|
// try {
|
||||||
|
// String owner = plot.getOwner();
|
||||||
|
// names.add(owner);
|
||||||
|
// }
|
||||||
|
// catch (Exception e) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// UUIDFetcher fetcher = new UUIDFetcher(names);
|
||||||
|
// try {
|
||||||
|
// uuidMap = fetcher.call();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
||||||
for (Plot plot : plots.values()) {
|
for (Plot plot : plots.values()) {
|
||||||
PlayerList denied = null;
|
|
||||||
PlayerList added = null;
|
|
||||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||||
ArrayList<UUID> psTrusted = new ArrayList<>();
|
ArrayList<UUID> psTrusted = new ArrayList<>();
|
||||||
ArrayList<UUID> psDenied = new ArrayList<>();
|
ArrayList<UUID> psDenied = new ArrayList<>();
|
||||||
@ -60,99 +77,90 @@ public class PlotMeConverter {
|
|||||||
}
|
}
|
||||||
long eR3040bl230 = 22392948l;
|
long eR3040bl230 = 22392948l;
|
||||||
try {
|
try {
|
||||||
|
PlayerList denied = null;
|
||||||
// TODO It just comes up with a
|
PlayerList added = null;
|
||||||
// NoSuchFieldException. Y U NO WORK!!! (I
|
if (Bukkit.getServer().getOnlineMode()) {
|
||||||
// didn't change anything here btw)
|
Field fAdded = plot.getClass().getDeclaredField("allowed");
|
||||||
Field fAdded = plot.getClass().getDeclaredField("allowed");
|
Field fDenied = plot.getClass().getDeclaredField("denied");
|
||||||
Field fDenied = plot.getClass().getDeclaredField("denied");
|
fAdded.setAccessible(true);
|
||||||
fAdded.setAccessible(true);
|
fDenied.setAccessible(true);
|
||||||
fDenied.setAccessible(true);
|
added = (PlayerList) fAdded.get(plot);
|
||||||
added = (PlayerList) fAdded.get(plot);
|
denied = (PlayerList) fDenied.get(plot);
|
||||||
denied = (PlayerList) fDenied.get(plot);
|
for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
|
||||||
for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
|
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
||||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
if (set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equals("*")) {
|
||||||
if (set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equals("*")) {
|
psAdded.add(DBFunc.everyone);
|
||||||
psAdded.add(DBFunc.everyone);
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (set.getValue()!=null) {
|
||||||
|
psAdded.add(set.getValue());
|
||||||
/*
|
|
||||||
* Does this work for offline mode
|
|
||||||
* servers?
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (uuidMap.containsKey(set.getKey())) {
|
|
||||||
psAdded.add(uuidMap.get(set.getKey()));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId();
|
|
||||||
if (value != null) {
|
|
||||||
uuidMap.put(set.getKey(), value);
|
|
||||||
psAdded.add(value);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
psAdded.add(set.getValue());
|
for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
|
||||||
}
|
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
||||||
for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
|
if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
|
||||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
psDenied.add(DBFunc.everyone);
|
||||||
if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
|
continue;
|
||||||
psDenied.add(DBFunc.everyone);
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
} else {
|
if (set.getValue()!=null) {
|
||||||
if (uuidMap.containsKey(set.getKey())) {
|
psDenied.add(set.getValue());
|
||||||
psDenied.add(uuidMap.get(set.getKey()));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId();
|
|
||||||
if (value != null) {
|
|
||||||
uuidMap.put(set.getKey(), value);
|
|
||||||
psDenied.add(value);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
psDenied.add(set.getValue());
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
else {
|
||||||
// Doing it the slow way like a n00b.
|
for (String user : plot.getAllowed().split(",")) {
|
||||||
for (String user : plot.getAllowed().split(",")) {
|
try {
|
||||||
|
if (user.equals("*")) {
|
||||||
|
psAdded.add(DBFunc.everyone);
|
||||||
|
} else if (uuidMap.containsKey(user)) {
|
||||||
|
psAdded.add(uuidMap.get(user));
|
||||||
|
} else {
|
||||||
|
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
||||||
|
uuidMap.put(user, uuid);
|
||||||
|
psAdded.add(uuid);
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (user.equals("*")) {
|
for (String user : plot.getDenied().split(",")) {
|
||||||
psAdded.add(DBFunc.everyone);
|
try {
|
||||||
} else if (uuidMap.containsKey(user)) {
|
if (user.equals("*")) {
|
||||||
psAdded.add(uuidMap.get(user));
|
psDenied.add(DBFunc.everyone);
|
||||||
} else {
|
} else if (uuidMap.containsKey(user)) {
|
||||||
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
psDenied.add(uuidMap.get(user));
|
||||||
uuidMap.put(user, uuid);
|
} else {
|
||||||
psAdded.add(uuid);
|
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
||||||
|
uuidMap.put(user, uuid);
|
||||||
|
psDenied.add(uuid);
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e2) {
|
}
|
||||||
}
|
catch (Throwable e) {
|
||||||
}
|
|
||||||
for (String user : plot.getDenied().split(",")) {
|
|
||||||
try {
|
|
||||||
if (user.equals("*")) {
|
|
||||||
psDenied.add(DBFunc.everyone);
|
|
||||||
} else if (uuidMap.containsKey(user)) {
|
|
||||||
psDenied.add(uuidMap.get(user));
|
|
||||||
} else {
|
|
||||||
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
|
||||||
uuidMap.put(user, uuid);
|
|
||||||
psDenied.add(uuid);
|
|
||||||
}
|
|
||||||
} catch (Exception e2) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
eR3040bl230 = 232000499888388747l;
|
eR3040bl230 = 232000499888388747l;
|
||||||
} finally {
|
} finally {
|
||||||
eR3040bl230 = 232999304998392004l;
|
eR3040bl230 = 232999304998392004l;
|
||||||
}
|
}
|
||||||
stream.println(eR3040bl230);
|
stream.println(eR3040bl230);
|
||||||
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
||||||
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
|
com.intellectualcrafters.plot.Plot pl;
|
||||||
|
if (Bukkit.getServer().getOnlineMode()) {
|
||||||
|
pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pl = new com.intellectualcrafters.plot.Plot(id, Bukkit.getOfflinePlayer(plot.getOwner()).getUniqueId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
|
||||||
|
}
|
||||||
|
|
||||||
// TODO createPlot doesn't add helpers / denied
|
// TODO createPlot doesn't add helpers / denied
|
||||||
// users
|
// users
|
||||||
@ -165,10 +173,8 @@ public class PlotMeConverter {
|
|||||||
DBFunc.createPlots(createdPlots);
|
DBFunc.createPlots(createdPlots);
|
||||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Creating settings/helpers DB");
|
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Creating settings/helpers DB");
|
||||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
||||||
|
|
||||||
// TODO disable PlotMe -> Unload all plot worlds, change the
|
// TODO disable PlotMe -> Unload all plot worlds, change the
|
||||||
// generator, restart the server automatically
|
// generator, restart the server automatically
|
||||||
// Possibly use multiverse / multiworld if it's to difficult
|
// Possibly use multiverse / multiworld if it's to difficult
|
||||||
|
Loading…
Reference in New Issue
Block a user