Fixed offline player UUID cache issue.

This commit is contained in:
boy0001 2015-01-10 02:02:02 +11:00
parent 1fd8b18d6f
commit f116b13cc7
7 changed files with 17 additions and 24 deletions

View File

@ -834,6 +834,13 @@ import java.util.concurrent.TimeUnit;
public static void worldLoad(WorldLoadEvent event) { public static void worldLoad(WorldLoadEvent event) {
if (!UUIDHandler.CACHED) { if (!UUIDHandler.CACHED) {
UUIDHandler.cacheAll(); UUIDHandler.cacheAll();
if (Bukkit.getServer().getPluginManager().getPlugin("PlotMe") != null) {
try {
new PlotMeConverter(PlotMain.getMain()).runAsync();
} catch (final Exception e) {
e.printStackTrace();
}
}
} }
} }
@ -1318,7 +1325,7 @@ import java.util.concurrent.TimeUnit;
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented"); sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
} else if (Settings.DB.USE_SQLITE) { } else if (Settings.DB.USE_SQLITE) {
try { try {
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection(); connection = new SQLite(this, this.getDataFolder() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection();
{ {
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
final DatabaseMetaData meta = connection.getMetaData(); final DatabaseMetaData meta = connection.getMetaData();
@ -1349,17 +1356,6 @@ import java.util.concurrent.TimeUnit;
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }
// We should not start the plugin if
// plotme is present. Maybe do this
// earlier, and no register any commands
// nor listeners, just run the converter?
if (getServer().getPluginManager().getPlugin("PlotMe") != null) {
try {
new PlotMeConverter(this).runAsync();
} catch (final Exception e) {
e.printStackTrace();
}
}
// Setup the command handler // Setup the command handler
{ {
final MainCommand command = new MainCommand(); final MainCommand command = new MainCommand();

View File

@ -47,8 +47,6 @@ public class Delete extends SubCommand {
return !sendMessage(plr, C.UNLINK_REQUIRED); return !sendMessage(plr, C.UNLINK_REQUIRED);
} }
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) { if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) {
System.out.print(UUIDHandler.uuidWrapper.getUUID(plr));
System.out.print(plot.getOwner());
return !sendMessage(plr, C.NO_PLOT_PERMS); return !sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;

View File

@ -107,9 +107,10 @@ public class PlotMeConverter {
while (r.next()) { while (r.next()) {
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
String name = r.getString("owner"); String name = r.getString("owner");
System.out.print("NAME: "+name);
String world = r.getString("world"); String world = r.getString("world");
if (!plotSize.containsKey(world)) { if (!plotSize.containsKey(world)) {
int size = r.getInt("topZ") - r.getInt("botZ"); int size = r.getInt("topZ") - r.getInt("bottomZ");
plotSize.put(world,size); plotSize.put(world,size);
plots.put(world, new HashMap<PlotId, Plot>()); plots.put(world, new HashMap<PlotId, Plot>());
} }

View File

@ -671,7 +671,6 @@ public class SQLManager implements AbstractDB {
if (element.contains(":")) { if (element.contains(":")) {
final String[] split = element.split(":"); final String[] split = element.split(":");
try { try {
System.out.print("NEW FLAG] "+element);
flags.add(new Flag(FlagManager.getFlag(split[0], true), split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ","))); flags.add(new Flag(FlagManager.getFlag(split[0], true), split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",")));
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -755,7 +754,6 @@ public class SQLManager implements AbstractDB {
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
stmt.setString(1, flag_string.toString()); stmt.setString(1, flag_string.toString());
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
System.out.print(stmt.toString());
stmt.execute(); stmt.execute();
stmt.close(); stmt.close();
} catch (final SQLException e) { } catch (final SQLException e) {

View File

@ -58,7 +58,7 @@ public class SQLite extends Database {
if (!this.plugin.getDataFolder().exists()) { if (!this.plugin.getDataFolder().exists()) {
this.plugin.getDataFolder().mkdirs(); this.plugin.getDataFolder().mkdirs();
} }
final File file = new File(this.plugin.getDataFolder(), this.dbLocation); final File file = new File(this.dbLocation);
if (!(file.exists())) { if (!(file.exists())) {
try { try {
file.createNewFile(); file.createNewFile();
@ -67,7 +67,7 @@ public class SQLite extends Database {
} }
} }
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.plugin.getDataFolder().toPath().toString() + "/" + this.dbLocation); this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
return this.connection; return this.connection;
} }

View File

@ -53,15 +53,12 @@ public class ExpireManager {
ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() {
@Override @Override
public void run() { public void run() {
System.out.print("RUNNING TASK");
for (String world : PlotMain.getPlotWorldsString()) { for (String world : PlotMain.getPlotWorldsString()) {
System.out.print(" - check world");
if (!ExpireManager.updatingPlots.contains(world)) { if (!ExpireManager.updatingPlots.contains(world)) {
ExpireManager.updatingPlots.put(world, false); ExpireManager.updatingPlots.put(world, false);
} }
Boolean updating = ExpireManager.updatingPlots.get(world); Boolean updating = ExpireManager.updatingPlots.get(world);
if (updating) { if (updating) {
System.out.print(" - ERR UPDATING");
return; return;
} }
ArrayList<Plot> plots = expiredPlots.get(world); ArrayList<Plot> plots = expiredPlots.get(world);

View File

@ -201,7 +201,8 @@ public class UUIDHandler {
} }
// check cache // check cache
UUID uuid = UUIDHandler.uuidMap.get(name); StringWrapper wrap = new StringWrapper(name);
UUID uuid = UUIDHandler.uuidMap.get(wrap);
if (uuid != null) { if (uuid != null) {
return uuid; return uuid;
} }
@ -209,7 +210,9 @@ public class UUIDHandler {
// Read from disk // Read from disk
if (Settings.UUID_FROM_DISK) { if (Settings.UUID_FROM_DISK) {
OfflinePlayer op = Bukkit.getOfflinePlayer(name); OfflinePlayer op = Bukkit.getOfflinePlayer(name);
return UUIDHandler.uuidWrapper.getUUID(op); uuid = UUIDHandler.uuidWrapper.getUUID(op);
add(new StringWrapper(name), uuid);
return uuid;
} }
return null; return null;