mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fixed the uuid saving functions, added ability to change caching methods.
This commit is contained in:
parent
2bbcdb17bc
commit
0961671eaf
@ -502,18 +502,22 @@ public class PlotMain extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
// Init the logger
|
||||||
setupLogger();
|
setupLogger();
|
||||||
|
|
||||||
// Check for outdated java version.
|
// Check for outdated java version.
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
||||||
|
// Didn't know of any other link :D
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
|
sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup configurations
|
||||||
configs();
|
configs();
|
||||||
|
|
||||||
|
// Setup metrics
|
||||||
if (Settings.METRICS) {
|
if (Settings.METRICS) {
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this);
|
||||||
@ -525,13 +529,17 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kill mobs on roads?
|
||||||
if (Settings.KILL_ROAD_MOBS) {
|
if (Settings.KILL_ROAD_MOBS) {
|
||||||
killAllEntities();
|
killAllEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enabled<3
|
||||||
if (C.ENABLED.s().length() > 0) {
|
if (C.ENABLED.s().length() > 0) {
|
||||||
Broadcast(C.ENABLED);
|
Broadcast(C.ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use mysql?
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
try {
|
try {
|
||||||
mySQL =
|
mySQL =
|
||||||
@ -568,10 +576,12 @@ public class PlotMain extends JavaPlugin {
|
|||||||
plots = DBFunc.getPlots();
|
plots = DBFunc.getPlots();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// TODO: Implement mongo
|
||||||
else
|
else
|
||||||
if (Settings.DB.USE_MONGO) {
|
if (Settings.DB.USE_MONGO) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||||
}
|
}
|
||||||
|
// Use Sqlite :D<3
|
||||||
else
|
else
|
||||||
if (Settings.DB.USE_SQLITE) {
|
if (Settings.DB.USE_SQLITE) {
|
||||||
try {
|
try {
|
||||||
@ -626,6 +636,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
getCommand("plots").setAliases(new ArrayList<String>() {
|
getCommand("plots").setAliases(new ArrayList<String>() {
|
||||||
{
|
{
|
||||||
add("p");
|
add("p");
|
||||||
|
add("ps");
|
||||||
add("plotme");
|
add("plotme");
|
||||||
add("plot");
|
add("plot");
|
||||||
}
|
}
|
||||||
@ -683,7 +694,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
com.intellectualcrafters.plot.commands.plugin.setup(this);
|
com.intellectualcrafters.plot.commands.plugin.setup(this);
|
||||||
|
|
||||||
setUUIDSaver(new PlotUUIDSaver());
|
setUUIDSaver(new PlotUUIDSaver());
|
||||||
UUIDHandler.startFetch(this);
|
getUUIDSaver().globalPopulate();
|
||||||
|
//UUIDHandler.startFetch(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@ import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -54,43 +53,6 @@ public class UUIDHandler {
|
|||||||
uuidMap.put(name, uuid);
|
uuidMap.put(name, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param plugin
|
|
||||||
*/
|
|
||||||
public static void startFetch(JavaPlugin plugin) {
|
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
|
|
||||||
int length = offlinePlayers.length;
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
String name;
|
|
||||||
UUID uuid;
|
|
||||||
for (OfflinePlayer player : offlinePlayers) {
|
|
||||||
uuid = player.getUniqueId();
|
|
||||||
if (!uuidExists(uuid)) {
|
|
||||||
name = player.getName();
|
|
||||||
add(name, uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long time = System.currentTimeMillis() - start;
|
|
||||||
int size = uuidMap.size();
|
|
||||||
double ups;
|
|
||||||
if(time == 0l || size == 0) {
|
|
||||||
ups = size;
|
|
||||||
} else {
|
|
||||||
ups = size / time;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Plot Squared Only...
|
|
||||||
PlotMain.sendConsoleSenderMessage("&cFinished caching of offline player UUIDs! Took &6" + time + "&cms (&6" + ups + "&c per millisecond), &6"
|
|
||||||
+ length + " &cUUIDs were cached" + " and there is now a grand total of &6" + size
|
|
||||||
+ " &ccached.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package com.intellectualcrafters.plot.uuid;
|
package com.intellectualcrafters.plot.uuid;
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -9,6 +14,41 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class PlotUUIDSaver extends UUIDSaver {
|
public class PlotUUIDSaver extends UUIDSaver {
|
||||||
|
|
||||||
|
public void globalPopulate() {
|
||||||
|
JavaPlugin.getPlugin(PlotMain.class).getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
|
||||||
|
int length = offlinePlayers.length;
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
String name;
|
||||||
|
UUID uuid;
|
||||||
|
for (OfflinePlayer player : offlinePlayers) {
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
if (!UUIDHandler.uuidExists(uuid)) {
|
||||||
|
name = player.getName();
|
||||||
|
UUIDHandler.add(name, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis() - start;
|
||||||
|
int size = UUIDHandler.getUuidMap().size();
|
||||||
|
double ups;
|
||||||
|
if(time == 0l || size == 0) {
|
||||||
|
ups = size;
|
||||||
|
} else {
|
||||||
|
ups = size / time;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Plot Squared Only...
|
||||||
|
PlotMain.sendConsoleSenderMessage("&cFinished caching of offline player UUIDs! Took &6" + time + "&cms (&6" + ups + "&c per millisecond), &6"
|
||||||
|
+ length + " &cUUIDs were cached" + " and there is now a grand total of &6" + size
|
||||||
|
+ " &ccached.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void globalSave(BiMap<String, UUID> map) {
|
public void globalSave(BiMap<String, UUID> map) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.util.UUID;
|
|||||||
* Created by Citymonstret on 2014-10-13.
|
* Created by Citymonstret on 2014-10-13.
|
||||||
*/
|
*/
|
||||||
public abstract class UUIDSaver {
|
public abstract class UUIDSaver {
|
||||||
|
public abstract void globalPopulate();
|
||||||
public abstract void globalSave(BiMap<String, UUID> map);
|
public abstract void globalSave(BiMap<String, UUID> map);
|
||||||
public abstract void save(UUIDSet set);
|
public abstract void save(UUIDSet set);
|
||||||
public abstract UUIDSet get(String name);
|
public abstract UUIDSet get(String name);
|
||||||
|
@ -10,7 +10,7 @@ database: false
|
|||||||
commands:
|
commands:
|
||||||
plots:
|
plots:
|
||||||
description: PlotMain PlotSquared command.
|
description: PlotMain PlotSquared command.
|
||||||
aliases: [p,plotme,plot]
|
aliases: [p,plotme,plot,ps]
|
||||||
permission: plots.use
|
permission: plots.use
|
||||||
permissions:
|
permissions:
|
||||||
plots.use:
|
plots.use:
|
||||||
|
Loading…
Reference in New Issue
Block a user