mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fixed PlotMe converter + Added more debug statements
This commit is contained in:
parent
d69209364a
commit
0daf83c232
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.5.12</version>
|
<version>2.6.0</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -900,7 +900,14 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
public static void worldLoad(WorldLoadEvent event) {
|
public static void worldLoad(WorldLoadEvent event) {
|
||||||
if (!UUIDHandler.CACHED) {
|
if (!UUIDHandler.CACHED) {
|
||||||
UUIDHandler.cacheAll();
|
UUIDHandler.cacheAll();
|
||||||
if (Settings.CONVERT_PLOTME && Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
if (Settings.CONVERT_PLOTME) {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||||
|
sendConsoleSenderMessage("&c[IMPORTANT] THIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU WISH TO CONVERT A PLOTME DATABASE");
|
||||||
|
sendConsoleSenderMessage("&c[IMPORTANT] - Please delete your PlotMe.jar before starting your server!");
|
||||||
|
sendConsoleSenderMessage("&c[IMPORTANT] - This is required as the database may be locked if PlotMe is using it!");
|
||||||
|
sendConsoleSenderMessage("&c[IMPORTANT] - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
new PlotMeConverter(PlotMain.getMain()).runAsync();
|
new PlotMeConverter(PlotMain.getMain()).runAsync();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -83,6 +83,9 @@ public class PlotMeConverter {
|
|||||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||||
final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||||
|
if (!plotMeFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@ -96,6 +99,7 @@ public class PlotMeConverter {
|
|||||||
connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator + "plots.db").openConnection();
|
connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator + "plots.db").openConnection();
|
||||||
}
|
}
|
||||||
sendMessage("Collecting plot data");
|
sendMessage("Collecting plot data");
|
||||||
|
sendMessage(" - plotmePlots");
|
||||||
ResultSet r;
|
ResultSet r;
|
||||||
Statement stmt;
|
Statement stmt;
|
||||||
final HashMap<String, Integer> plotSize = new HashMap<>();
|
final HashMap<String, Integer> plotSize = new HashMap<>();
|
||||||
@ -114,7 +118,6 @@ public class PlotMeConverter {
|
|||||||
plotSize.put(world, size);
|
plotSize.put(world, size);
|
||||||
plots.put(world, new HashMap<PlotId, Plot>());
|
plots.put(world, new HashMap<PlotId, Plot>());
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID owner = UUIDHandler.getUUID(name);
|
UUID owner = UUIDHandler.getUUID(name);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
if (name.equals("*")) {
|
if (name.equals("*")) {
|
||||||
@ -128,7 +131,7 @@ public class PlotMeConverter {
|
|||||||
final 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);
|
plots.get(world).put(id, plot);
|
||||||
}
|
}
|
||||||
|
sendMessage(" - plotmeAllowed");
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
||||||
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"));
|
||||||
@ -147,7 +150,7 @@ public class PlotMeConverter {
|
|||||||
plots.get(world).get(id).helpers.add(helper);
|
plots.get(world).get(id).helpers.add(helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sendMessage(" - plotmeDenied");
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
||||||
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"));
|
||||||
@ -301,7 +304,7 @@ public class PlotMeConverter {
|
|||||||
|
|
||||||
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
|
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
|
||||||
sendMessage("Conversion has finished");
|
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.");
|
PlotMain.sendConsoleSenderMessage("&cPlease disable 'plotme-convert.enabled' in the settings.yml to indicate that you conversion is no longer required.");
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
@ -151,100 +153,105 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createAllSettingsAndHelpers(final ArrayList<Plot> plots) {
|
public void createAllSettingsAndHelpers(final ArrayList<Plot> mylist) {
|
||||||
|
int size = mylist.size();
|
||||||
// TODO SEVERE [ More than 5000 plots will fail in a single SQLite
|
int packet;
|
||||||
// query.
|
if (PlotMain.getMySQL() != null) {
|
||||||
|
packet = Math.min(size, 50000);
|
||||||
final HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<>();
|
|
||||||
final HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<>();
|
|
||||||
try {
|
|
||||||
final PreparedStatement stmt = this.connection.prepareStatement(this.GET_ALL_PLOTS);
|
|
||||||
final ResultSet result = stmt.executeQuery();
|
|
||||||
while (result.next()) {
|
|
||||||
final int id = result.getInt("id");
|
|
||||||
final int idx = result.getInt("plot_id_x");
|
|
||||||
final int idz = result.getInt("plot_id_z");
|
|
||||||
final String world = result.getString("world");
|
|
||||||
|
|
||||||
if (!stored.containsKey(world)) {
|
|
||||||
stored.put(world, new HashMap<PlotId, Integer>());
|
|
||||||
}
|
|
||||||
stored.get(world).put(new PlotId(idx, idz), id);
|
|
||||||
}
|
|
||||||
} catch (final SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
for (final Plot plot : plots) {
|
packet = Math.min(size, 5000);
|
||||||
final String world = Bukkit.getWorld(plot.world).getName();
|
|
||||||
if (stored.containsKey(world)) {
|
|
||||||
final Integer id = stored.get(world).get(plot.id);
|
|
||||||
if (id != null) {
|
|
||||||
helpers.put(id, plot.helpers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
int amount = size/packet;
|
||||||
if (helpers.size() == 0) {
|
for (int j = 0; j <= amount;j++) {
|
||||||
return;
|
List<Plot> plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||||
}
|
final HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<>();
|
||||||
// add plot settings
|
final HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<>();
|
||||||
final Integer[] ids = helpers.keySet().toArray(new Integer[helpers.keySet().size()]);
|
|
||||||
StringBuilder statement = new StringBuilder(this.CREATE_SETTINGS);
|
|
||||||
for (int i = 0; i < (ids.length - 1); i++) {
|
|
||||||
statement.append("(?),");
|
|
||||||
}
|
|
||||||
statement.append("(?)");
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
stmt = this.connection.prepareStatement(statement.toString());
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
|
||||||
stmt.setInt(i + 1, ids[i]);
|
|
||||||
}
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
} catch (final SQLException e) {
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
|
||||||
createPlotSettings(ids[i], null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add plot helpers
|
|
||||||
String prefix = "";
|
|
||||||
statement = new StringBuilder(this.CREATE_HELPERS);
|
|
||||||
for (final Integer id : helpers.keySet()) {
|
|
||||||
for (final UUID helper : helpers.get(id)) {
|
|
||||||
statement.append(prefix + "(?, ?)");
|
|
||||||
prefix = ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (prefix.equals("")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
stmt = this.connection.prepareStatement(statement.toString());
|
|
||||||
int counter = 0;
|
|
||||||
for (final Integer id : helpers.keySet()) {
|
|
||||||
for (final UUID helper : helpers.get(id)) {
|
|
||||||
|
|
||||||
stmt.setInt((counter * 2) + 1, id);
|
|
||||||
stmt.setString((counter * 2) + 2, helper.toString());
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
} catch (final SQLException e) {
|
|
||||||
try {
|
try {
|
||||||
for (final Integer id : helpers.keySet()) {
|
final PreparedStatement stmt = this.connection.prepareStatement(this.GET_ALL_PLOTS);
|
||||||
for (final UUID helper : helpers.get(id)) {
|
final ResultSet result = stmt.executeQuery();
|
||||||
setHelper(id, helper);
|
while (result.next()) {
|
||||||
|
final int id = result.getInt("id");
|
||||||
|
final int idx = result.getInt("plot_id_x");
|
||||||
|
final int idz = result.getInt("plot_id_z");
|
||||||
|
final String world = result.getString("world");
|
||||||
|
|
||||||
|
if (!stored.containsKey(world)) {
|
||||||
|
stored.put(world, new HashMap<PlotId, Integer>());
|
||||||
|
}
|
||||||
|
stored.get(world).put(new PlotId(idx, idz), id);
|
||||||
|
}
|
||||||
|
} catch (final SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
for (final Plot plot : plots) {
|
||||||
|
final String world = plot.world;
|
||||||
|
if (stored.containsKey(world)) {
|
||||||
|
final Integer id = stored.get(world).get(plot.id);
|
||||||
|
if (id != null) {
|
||||||
|
helpers.put(id, plot.helpers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e2) {}
|
if (helpers.size() == 0) {
|
||||||
PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set all helpers for plots");
|
return;
|
||||||
|
}
|
||||||
|
// add plot settings
|
||||||
|
final Integer[] ids = helpers.keySet().toArray(new Integer[helpers.keySet().size()]);
|
||||||
|
StringBuilder statement = new StringBuilder(this.CREATE_SETTINGS);
|
||||||
|
for (int i = 0; i < (ids.length - 1); i++) {
|
||||||
|
statement.append("(?),");
|
||||||
|
}
|
||||||
|
statement.append("(?)");
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
stmt = this.connection.prepareStatement(statement.toString());
|
||||||
|
for (int i = 0; i < ids.length; i++) {
|
||||||
|
stmt.setInt(i + 1, ids[i]);
|
||||||
|
}
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
} catch (final SQLException e) {
|
||||||
|
for (int i = 0; i < ids.length; i++) {
|
||||||
|
createPlotSettings(ids[i], null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add plot helpers
|
||||||
|
String prefix = "";
|
||||||
|
statement = new StringBuilder(this.CREATE_HELPERS);
|
||||||
|
for (final Integer id : helpers.keySet()) {
|
||||||
|
for (final UUID helper : helpers.get(id)) {
|
||||||
|
statement.append(prefix + "(?, ?)");
|
||||||
|
prefix = ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prefix.equals("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
stmt = this.connection.prepareStatement(statement.toString());
|
||||||
|
int counter = 0;
|
||||||
|
for (final Integer id : helpers.keySet()) {
|
||||||
|
for (final UUID helper : helpers.get(id)) {
|
||||||
|
|
||||||
|
stmt.setInt((counter * 2) + 1, id);
|
||||||
|
stmt.setString((counter * 2) + 2, helper.toString());
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
} catch (final SQLException e) {
|
||||||
|
try {
|
||||||
|
for (final Integer id : helpers.keySet()) {
|
||||||
|
for (final UUID helper : helpers.get(id)) {
|
||||||
|
setHelper(id, helper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e2) {}
|
||||||
|
PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set all helpers for plots");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,53 +261,62 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @param plots
|
* @param plots
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createPlots(final ArrayList<Plot> plots) {
|
public void createPlots(final ArrayList<Plot> mylist) {
|
||||||
|
int size = mylist.size();
|
||||||
// TODO SEVERE [ More than 5000 plots will fail in a single SQLite
|
int packet;
|
||||||
// query.
|
if (PlotMain.getMySQL() != null) {
|
||||||
|
packet = Math.min(size, 50000);
|
||||||
if (plots.size() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
final StringBuilder statement = new StringBuilder(this.CREATE_PLOTS);
|
else {
|
||||||
|
packet = Math.min(size, 5000);
|
||||||
for (int i = 0; i < (plots.size() - 1); i++) {
|
|
||||||
statement.append("(?,?,?,?),");
|
|
||||||
}
|
}
|
||||||
statement.append("(?,?,?,?)");
|
int amount = size/packet;
|
||||||
|
for (int j = 0; j <= amount;j++) {
|
||||||
PreparedStatement stmt = null;
|
List<Plot> plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||||
try {
|
if (plots.size() == 0) {
|
||||||
stmt = this.connection.prepareStatement(statement.toString());
|
return;
|
||||||
for (int i = 0; i < plots.size(); i++) {
|
|
||||||
final Plot plot = plots.get(i);
|
|
||||||
stmt.setInt((i * 4) + 1, plot.id.x);
|
|
||||||
stmt.setInt((i * 4) + 2, plot.id.y);
|
|
||||||
try {
|
|
||||||
stmt.setString((i * 4) + 3, plot.owner.toString());
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
stmt.setString((i * 4) + 3, DBFunc.everyone.toString());
|
|
||||||
}
|
|
||||||
stmt.setString((i * 4) + 4, plot.world);
|
|
||||||
}
|
}
|
||||||
stmt.executeUpdate();
|
final StringBuilder statement = new StringBuilder(this.CREATE_PLOTS);
|
||||||
stmt.close();
|
|
||||||
} catch (final Exception e) {
|
for (int i = 0; i < (plots.size() - 1); i++) {
|
||||||
PlotMain.sendConsoleSenderMessage("&6[WARN] "+"Could not bulk save. Conversion may be slower...");
|
statement.append("(?,?,?,?),");
|
||||||
|
}
|
||||||
|
statement.append("(?,?,?,?)");
|
||||||
|
|
||||||
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
for (Plot plot : plots) {
|
stmt = this.connection.prepareStatement(statement.toString());
|
||||||
|
for (int i = 0; i < plots.size(); i++) {
|
||||||
|
final Plot plot = plots.get(i);
|
||||||
|
stmt.setInt((i * 4) + 1, plot.id.x);
|
||||||
|
stmt.setInt((i * 4) + 2, plot.id.y);
|
||||||
try {
|
try {
|
||||||
createPlot(plot);
|
stmt.setString((i * 4) + 3, plot.owner.toString());
|
||||||
}
|
}
|
||||||
catch (Exception e3) {
|
catch (Exception e) {
|
||||||
PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot: "+plot.id);
|
stmt.setString((i * 4) + 3, DBFunc.everyone.toString());
|
||||||
|
}
|
||||||
|
stmt.setString((i * 4) + 4, plot.world);
|
||||||
|
}
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
} catch (final Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
PlotMain.sendConsoleSenderMessage("&6[WARN] "+"Could not bulk save. Conversion may be slower...");
|
||||||
|
try {
|
||||||
|
for (Plot plot : plots) {
|
||||||
|
try {
|
||||||
|
createPlot(plot);
|
||||||
|
}
|
||||||
|
catch (Exception e3) {
|
||||||
|
PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot: "+plot.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e2) {
|
||||||
catch (Exception e2) {
|
e2.printStackTrace();
|
||||||
e2.printStackTrace();
|
PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plots!");
|
||||||
PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plots!");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1393,9 +1409,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (alias != null) {
|
if (alias != null) {
|
||||||
cluster.settings.setAlias(alias);
|
cluster.settings.setAlias(alias);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
System.out.print("ALIAS IS NULL!!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String pos = r.getString("position");
|
final String pos = r.getString("position");
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -106,12 +105,12 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
*/
|
*/
|
||||||
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onWorldLoad(final WorldLoadEvent event) {
|
public static void onWorldLoad(final WorldLoadEvent event) {
|
||||||
PlotMain.loadWorld(event.getWorld());
|
PlotMain.loadWorld(event.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onChunkLoad(final ChunkLoadEvent event) {
|
public static void onChunkLoad(final ChunkLoadEvent event) {
|
||||||
String worldname = event.getWorld().getName();
|
String worldname = event.getWorld().getName();
|
||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
@ -125,7 +124,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onJoin(final PlayerJoinEvent event) {
|
public static void onJoin(final PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPlayedBefore()) {
|
if (!player.hasPlayedBefore()) {
|
||||||
@ -275,7 +274,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onBigBoom(final EntityExplodeEvent event) {
|
public static void onBigBoom(final EntityExplodeEvent event) {
|
||||||
final World world = event.getLocation().getWorld();
|
final World world = event.getLocation().getWorld();
|
||||||
if (!isPlotWorld(world)) {
|
if (!isPlotWorld(world)) {
|
||||||
@ -482,7 +481,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onInteract(final PlayerInteractEvent event) {
|
public static void onInteract(final PlayerInteractEvent event) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
@ -188,7 +188,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUID(final String name) {
|
public static UUID getUUID(final String name) {
|
||||||
if (name == null) {
|
if (name == null || name.length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// check online
|
// check online
|
||||||
@ -205,11 +205,9 @@ public class UUIDHandler {
|
|||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read from disk OR convert directly to offline UUID
|
// Read from disk OR convert directly to offline UUID
|
||||||
if (Settings.UUID_FROM_DISK || uuidWrapper instanceof OfflineUUIDWrapper) {
|
if (Settings.UUID_FROM_DISK || uuidWrapper instanceof OfflineUUIDWrapper) {
|
||||||
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
uuid = UUIDHandler.uuidWrapper.getUUID(name);
|
||||||
uuid = UUIDHandler.uuidWrapper.getUUID(op);
|
|
||||||
add(new StringWrapper(name), uuid);
|
add(new StringWrapper(name), uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -28,4 +28,9 @@ public class DefaultUUIDWrapper extends UUIDWrapper {
|
|||||||
return Bukkit.getPlayer(uuid);
|
return Bukkit.getPlayer(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(String name) {
|
||||||
|
return Bukkit.getOfflinePlayer(name).getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,4 +56,9 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(String name) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ public abstract class UUIDWrapper {
|
|||||||
|
|
||||||
public abstract UUID getUUID(OfflinePlayer player);
|
public abstract UUID getUUID(OfflinePlayer player);
|
||||||
|
|
||||||
|
public abstract UUID getUUID(String name);
|
||||||
|
|
||||||
public abstract OfflinePlayer getOfflinePlayer(UUID uuid);
|
public abstract OfflinePlayer getOfflinePlayer(UUID uuid);
|
||||||
|
|
||||||
public abstract Player getPlayer(UUID uuid);
|
public abstract Player getPlayer(UUID uuid);
|
||||||
|
Loading…
Reference in New Issue
Block a user