AthionPlots -> PlotSquared converter

This commit is contained in:
boy0001 2015-05-14 19:45:14 +10:00
parent 710b62fbf5
commit f3777bd8c5
6 changed files with 217 additions and 77 deletions

View File

@ -78,7 +78,7 @@ import com.intellectualcrafters.plot.commands.plugin;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector; import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
import com.intellectualcrafters.plot.database.plotme.PlotMeConverter; import com.intellectualcrafters.plot.database.plotme.LikePlotMeConverter;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
@ -429,10 +429,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
TaskManager.runTaskLaterAsync(new Runnable() { TaskManager.runTaskLaterAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
new PlotMeConverter().run(new ClassicPlotMeConnector()); if (!(new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector()))) {
new LikePlotMeConverter("AthionPlots").run(new ClassicPlotMeConnector());
}
} }
}, 20); }, 20);
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) { if (Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null) {
return true; return true;
} }
return false; return false;

View File

@ -209,8 +209,7 @@ public class SQLManager implements AbstractDB {
createTiers(helpers, "helpers"); createTiers(helpers, "helpers");
createTiers(trusted, "trusted"); createTiers(trusted, "trusted");
createTiers(denied, "denied"); createTiers(denied, "denied");
TaskManager.runTaskLater(whenDone, 60);
TaskManager.runTaskLater(whenDone, 20);
} }
catch (SQLException e) { catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
@ -364,7 +363,7 @@ public class SQLManager implements AbstractDB {
e2.printStackTrace(); e2.printStackTrace();
PlotSquared.log("&6[WARN] " + "Could not bulk save!"); PlotSquared.log("&6[WARN] " + "Could not bulk save!");
try { try {
for (final T obj : subList) { for (final T obj : subList) {
try { try {
stmt = connection.prepareStatement(mod.getCreateSQL()); stmt = connection.prepareStatement(mod.getCreateSQL());
mod.setSQL(stmt, obj); mod.setSQL(stmt, obj);
@ -392,19 +391,17 @@ public class SQLManager implements AbstractDB {
@Override @Override
public String getCreateSQLite(int size) { public String getCreateSQLite(int size) {
return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ", 10); return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position`", 10);
} }
@Override @Override
public String getCreateSQL() { public String getCreateSQL() {
return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"; return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)";
// return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`flags`,`merged`,`position`) VALUES(?,?,?,?,?,?,?,?,?,?)";
} }
@Override @Override
public void setMySQL(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException { public void setMySQL(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException {
// stmt.setInt((i * 1) + 1, id.id);
// `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position`
stmt.setInt((i * 10) + 1, pair.id ); // id stmt.setInt((i * 10) + 1, pair.id ); // id
stmt.setNull((i * 10) + 2, 4); // biome stmt.setNull((i * 10) + 2, 4); // biome
stmt.setNull((i * 10) + 3, 4); // rain stmt.setNull((i * 10) + 3, 4); // rain
@ -451,16 +448,48 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setSQLite(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException { public void setSQLite(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException {
stmt.setInt((i * 10) + 1, pair.id ); stmt.setInt((i * 10) + 1, pair.id ); // id
stmt.setNull((i * 10) + 2, 4); stmt.setNull((i * 10) + 2, 4); // biome
stmt.setNull((i * 10) + 3, 4); stmt.setNull((i * 10) + 3, 4); // rain
stmt.setNull((i * 10) + 4, 4); stmt.setNull((i * 10) + 4, 4); // custom_time
stmt.setNull((i * 10) + 5, 4); stmt.setNull((i * 10) + 5, 4); // time
stmt.setNull((i * 10) + 6, 4); stmt.setNull((i * 10) + 6, 4); // deny_entry
stmt.setNull((i * 10) + 7, 4); if (pair.settings.getAlias().equals("")) {
stmt.setNull((i * 10) + 8, 4); stmt.setNull((i * 10) + 7, 4);
stmt.setNull((i * 10) + 9, 4); }
stmt.setString((i * 10) + 10, "DEFAULT"); else {
stmt.setString((i * 10) + 7, pair.settings.getAlias());
}
if (pair.settings.flags == null) {
stmt.setNull((i * 10) + 8, 4);
}
else {
final StringBuilder flag_string = new StringBuilder();
int k = 0;
for (final Flag flag : pair.settings.flags) {
if (k != 0) {
flag_string.append(",");
}
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
}
stmt.setString((i * 10) + 8, flag_string.toString());
}
boolean[] merged = pair.settings.getMerged();
int n = 0;
for (int j = 0; j < 4; ++j) {
n = (n << 1) + (merged[j] ? 1 : 0);
}
stmt.setInt((i * 10) + 9, n);
BlockLoc loc = pair.settings.getPosition();
String position;
if (loc.y == 0) {
position = "DEFAULT";
}
else {
position = loc.x + "," + loc.y + "," + loc.z;
}
stmt.setString((i * 10) + 10, position);
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
public abstract class APlotMeConnector { public abstract class APlotMeConnector {
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder); public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException; public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
} }

View File

@ -9,6 +9,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -17,16 +18,22 @@ import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class ClassicPlotMeConnector extends APlotMeConnector { public class ClassicPlotMeConnector extends APlotMeConnector {
private String plugin;
@Override @Override
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) { public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
this.plugin = plugin.toLowerCase();
try { try {
if (plotConfig.getBoolean("usemySQL")) { if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname"); final String user = plotConfig.getString("mySQLuname");
@ -41,25 +48,99 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
catch (SQLException | ClassNotFoundException e) {} catch (SQLException | ClassNotFoundException e) {}
return null; return null;
} }
public void setMerged(HashMap<String, HashMap<PlotId, boolean[]>> merges, String world, PlotId id, int direction) {
HashMap<PlotId, boolean[]> plots = merges.get(world);
PlotId id2;
switch (direction) {
case 0: {
id2 = new PlotId(id.x, id.y);
break;
}
case 1: {
id2 = new PlotId(id.x, id.y);
break;
}
case 2: {
id2 = new PlotId(id.x, id.y);
break;
}
case 3: {
id2 = new PlotId(id.x, id.y);
break;
}
default: {
return;
}
}
boolean[] merge1;
boolean[] merge2;
if (plots.containsKey(id)) {
merge1 = plots.get(id);
}
else {
merge1 = new boolean[]{false, false, false, false};
}
if (plots.containsKey(id2)) {
merge2 = plots.get(id2);
}
else {
merge2 = new boolean[]{false, false, false, false};
}
merge1[direction] = true;
merge2[(direction + 2) % 4] = true;
plots.put(id, merge1);
plots.put(id2, merge1);
}
@Override @Override
public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException { public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException {
ResultSet r; ResultSet r;
PreparedStatement stmt; PreparedStatement stmt;
final HashMap<String, Integer> plotSize = new HashMap<>(); final HashMap<String, Integer> plotWidth = new HashMap<>();
final HashMap<String, Integer> roadWidth = new HashMap<>();
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>(); final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
stmt = connection.prepareStatement("SELECT * FROM `plotmePlots`"); final HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Plots`");
r = stmt.executeQuery(); r = stmt.executeQuery();
boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); boolean checkUUID = DBFunc.hasColumn(r, "ownerid");
boolean merge = !plugin.equals("plotme");
while (r.next()) { while (r.next()) {
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
final String name = r.getString("owner"); final String name = r.getString("owner");
final String world = PlotMeConverter.getWorld(r.getString("world")); final String world = LikePlotMeConverter.getWorld(r.getString("world"));
if (!plotSize.containsKey(world)) { if (!plots.containsKey(world)) {
final int size = r.getInt("topZ") - r.getInt("bottomZ"); int plot = PlotSquared.config.getInt("worlds." + world + ".plot.size");
plotSize.put(world, size); int path = PlotSquared.config.getInt("worlds." + world + ".road.width");
plotWidth.put(world, plot);
roadWidth.put(world, path);
plots.put(world, new HashMap<PlotId, Plot>()); plots.put(world, new HashMap<PlotId, Plot>());
if (merge) {
merges.put(world, new HashMap<PlotId,boolean[]>());
}
}
if (merge) {
int tx = r.getInt("topX");
int tz = r.getInt("topZ");
int bx = r.getInt("bottomX");
int bz = r.getInt("bottomZ");
int path = roadWidth.get(world);
int plot = plotWidth.get(world);
Location top = getPlotTopLocAbs(path, plot, id);
Location bot = getPlotBottomLocAbs(path, plot, id);
if (tx > top.getX()) {
setMerged(merges, world, id, 1);
}
if (tz > top.getZ()) {
setMerged(merges, world, id, 2);
}
if (bx < bot.getX()) {
setMerged(merges, world, id, 3);
}
if (bz > bot.getZ()) {
setMerged(merges, world, id, 0);
}
} }
UUID owner = UUIDHandler.getUUID(name); UUID owner = UUIDHandler.getUUID(name);
if (owner == null) { if (owner == null) {
@ -94,19 +175,30 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
plots.get(world).put(id, plot); plots.get(world).put(id, plot);
} }
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
String world = entry.getKey();
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
HashMap<PlotId, Plot> newplots = plots.get(world);
Plot plot = newplots.get(entry2.getKey());
if (plot != null) {
plot.settings.setMerged(entry2.getValue());
}
}
}
r.close(); r.close();
stmt.close(); stmt.close();
try { try {
MainUtil.sendConsoleMessage(" - plotmeDenied"); MainUtil.sendConsoleMessage(" - " + plugin + "Denied");
stmt = connection.prepareStatement("SELECT * FROM `plotmeDenied`"); stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Denied`");
r = stmt.executeQuery(); r = stmt.executeQuery();
while (r.next()) { while (r.next()) {
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
final String name = r.getString("player"); final String name = r.getString("player");
final String world = PlotMeConverter.getWorld(r.getString("world")); final String world = LikePlotMeConverter.getWorld(r.getString("world"));
UUID denied = UUIDHandler.getUUID(name); UUID denied = UUIDHandler.getUUID(name);
if (denied == null) { if (denied == null) {
if (name.equals("*")) { if (name.equals("*")) {
@ -121,13 +213,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
} }
} }
stmt = connection.prepareStatement("SELECT * FROM `plotmeAllowed`"); stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Allowed`");
r = stmt.executeQuery(); r = stmt.executeQuery();
while (r.next()) { while (r.next()) {
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
final String name = r.getString("player"); final String name = r.getString("player");
final String world = PlotMeConverter.getWorld(r.getString("world")); final String world = LikePlotMeConverter.getWorld(r.getString("world"));
UUID helper = UUIDHandler.getUUID(name); UUID helper = UUIDHandler.getUUID(name);
if (helper == null) { if (helper == null) {
if (name.equals("*")) { if (name.equals("*")) {
@ -146,11 +238,24 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
stmt.close(); stmt.close();
} }
catch (Exception e) { catch (Exception e) {}
}
return plots; return plots;
} }
public Location getPlotTopLocAbs(int path, int plot, final PlotId plotid) {
final int px = plotid.x;
final int pz = plotid.y;
final int x = (px * (path + plot)) - ((int) Math.floor(path / 2)) - 1;
final int z = (pz * (path + plot)) - ((int) Math.floor(path / 2)) - 1;
return new Location(null, x, 256, z);
}
public Location getPlotBottomLocAbs(int path, int plot, final PlotId plotid) {
final int px = plotid.x;
final int pz = plotid.y;
final int x = (px * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1;
final int z = (pz * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1;
return new Location(null, x, 1, z);
}
} }

View File

@ -23,16 +23,11 @@ package com.intellectualcrafters.plot.database.plotme;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
@ -43,13 +38,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/** /**
* Created 2014-08-17 for PlotSquared * Created 2014-08-17 for PlotSquared
@ -57,18 +49,28 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret * @author Citymonstret
* @author Empire92 * @author Empire92
*/ */
public class PlotMeConverter { public class LikePlotMeConverter {
private String plugin;
/** /**
* Constructor * Constructor
* *
* @param plugin Plugin Used to run the converter * @param plugin Plugin Used to run the converter
*/ */
public LikePlotMeConverter(String plugin) {
this.plugin = plugin;
}
private void sendMessage(final String message) { private void sendMessage(final String message) {
PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message); PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message);
} }
public String getPlotMePath() { public String getPlotMePath() {
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator; return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
}
public String getAthionPlotsPath() {
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
} }
public FileConfiguration getPlotMeConfig(String dataFolder) { public FileConfiguration getPlotMeConfig(String dataFolder) {
@ -83,43 +85,35 @@ public class PlotMeConverter {
return plotConfig.getConfigurationSection("worlds").getKeys(false); return plotConfig.getConfigurationSection("worlds").getKeys(false);
} }
public void run(final APlotMeConnector connector) { public boolean run(final APlotMeConnector connector) {
try { try {
String dataFolder = getPlotMePath(); String dataFolder = getPlotMePath();
FileConfiguration plotConfig = getPlotMeConfig(dataFolder); FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
if (plotConfig == null) { if (plotConfig == null) {
return; return false;
} }
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder); Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
if (connection == null) { if (connection == null) {
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue"); sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
return; return false;
} }
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'"); sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
sendMessage("Connecting to PlotMe DB"); sendMessage("Connecting to " + plugin + " DB");
int plotCount = 0; int plotCount = 0;
final ArrayList<Plot> createdPlots = new ArrayList<>(); final ArrayList<Plot> createdPlots = new ArrayList<>();
sendMessage("Collecting plot data"); sendMessage("Collecting plot data");
sendMessage(" - plotmePlots");
String dbPrefix = plugin.toLowerCase();
sendMessage(" - " + dbPrefix + "Plots");
final Set<String> worlds = getPlotMeWorlds(plotConfig); final Set<String> worlds = getPlotMeWorlds(plotConfig);
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
plotCount += entry.getValue().size();
}
if (!Settings.CONVERT_PLOTME) {
return;
}
sendMessage(" - plotmeAllowed"); for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
sendMessage("Collected " + plotCount + " plots from PlotMe");
for (final String world : plots.keySet()) {
sendMessage("Copying config for: " + world); sendMessage("Copying config for: " + world);
try { try {
final String plotMeWorldName = world.toLowerCase(); final String plotMeWorldName = world.toLowerCase();
@ -145,6 +139,18 @@ public class PlotMeConverter {
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
} }
} }
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
plotCount += entry.getValue().size();
}
if (!Settings.CONVERT_PLOTME) {
return false;
}
sendMessage(" - " + dbPrefix + "Allowed");
sendMessage("Collected " + plotCount + " plots from PlotMe");
final 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()) { if (PLOTME_DG_FILE.exists()) {
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE); final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
@ -215,6 +221,7 @@ public class PlotMeConverter {
@Override @Override
public void run() { public void run() {
sendMessage("&aDatabase conversion is now complete!"); sendMessage("&aDatabase conversion is now complete!");
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
} }
}); });
sendMessage("Saving configuration..."); sendMessage("Saving configuration...");
@ -270,7 +277,6 @@ public class PlotMeConverter {
myworld.save(); myworld.save();
} }
} }
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -284,6 +290,7 @@ public class PlotMeConverter {
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.log("&/end/"); PlotSquared.log("&/end/");
} }
return true;
} }
public static String getWorld(final String world) { public static String getWorld(final String world) {

View File

@ -232,17 +232,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler @EventHandler
public void PlayerCommand(final PlayerCommandPreprocessEvent event) { public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
final String message = event.getMessage(); final String message = event.getMessage();
if (message.toLowerCase().startsWith("/plotme")) { if (message.toLowerCase().startsWith("/plotme") || message.toLowerCase().startsWith("/ap")) {
final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); final Player player = event.getPlayer();
if (plotme == null) { if (Settings.USE_PLOTME_ALIAS) {
final Player player = event.getPlayer(); player.performCommand(message.replace("/plotme", "plots"));
if (Settings.USE_PLOTME_ALIAS) { } else {
player.performCommand(message.replace("/plotme", "plots")); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
} else {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
}
event.setCancelled(true);
} }
event.setCancelled(true);
} }
} }