2015-07-27 09:26:50 +02:00
|
|
|
package com.intellectualcrafters.plot.util;
|
2014-11-05 04:42:08 +01:00
|
|
|
|
2015-07-05 17:44:10 +02:00
|
|
|
import java.util.HashSet;
|
2015-07-24 16:06:58 +02:00
|
|
|
import java.util.Map;
|
2015-07-05 17:44:10 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2014-10-11 10:05:50 +02:00
|
|
|
import com.google.common.collect.BiMap;
|
2015-07-03 14:15:20 +02:00
|
|
|
import com.intellectualcrafters.plot.PS;
|
2015-07-27 09:26:50 +02:00
|
|
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
2015-07-05 17:44:10 +02:00
|
|
|
import com.intellectualcrafters.plot.object.Plot;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-07-27 09:26:50 +02:00
|
|
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
2015-07-05 17:44:10 +02:00
|
|
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
2014-12-30 07:50:55 +01:00
|
|
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-07-03 11:30:26 +02:00
|
|
|
public class UUIDHandler {
|
2015-07-24 16:06:58 +02:00
|
|
|
|
|
|
|
public static UUIDHandlerImplementation implementation;
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-12-30 07:50:55 +01:00
|
|
|
public static void add(final StringWrapper name, final UUID uuid) {
|
2015-07-24 16:06:58 +02:00
|
|
|
implementation.add(name, uuid);
|
2014-12-30 07:50:55 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-10-28 01:57:14 +01:00
|
|
|
/**
|
|
|
|
* Get the map containing all names/uuids
|
2014-11-05 04:42:08 +01:00
|
|
|
*
|
2014-10-28 01:57:14 +01:00
|
|
|
* @return map with names + uuids
|
2014-12-18 03:15:11 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* @see com.google.common.collect.BiMap
|
2014-10-28 01:57:14 +01:00
|
|
|
*/
|
2014-10-21 11:58:52 +02:00
|
|
|
public static BiMap<StringWrapper, UUID> getUuidMap() {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getUUIDMap();
|
2014-10-12 01:18:47 +02:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-10-28 01:57:14 +01:00
|
|
|
/**
|
|
|
|
* Check if a uuid is cached
|
2014-11-05 04:42:08 +01:00
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param uuid to check
|
|
|
|
*
|
2014-10-28 01:57:14 +01:00
|
|
|
* @return true of the uuid is cached
|
2014-12-18 03:15:11 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* @see com.google.common.collect.BiMap#containsValue(Object)
|
2014-10-28 01:57:14 +01:00
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
public static boolean uuidExists(final UUID uuid) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.uuidExists(uuid);
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-10-28 01:57:14 +01:00
|
|
|
/**
|
|
|
|
* Check if a name is cached
|
2014-11-05 04:42:08 +01:00
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param name to check
|
|
|
|
*
|
2014-10-28 01:57:14 +01:00
|
|
|
* @return true of the name is cached
|
2014-12-18 03:15:11 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* @see com.google.common.collect.BiMap#containsKey(Object)
|
2014-10-28 01:57:14 +01:00
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
public static boolean nameExists(final StringWrapper name) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.nameExists(name);
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2015-05-02 12:08:30 +02:00
|
|
|
|
|
|
|
public static HashSet<UUID> getAllUUIDS() {
|
2015-07-24 16:06:58 +02:00
|
|
|
HashSet<UUID> uuids = new HashSet<>();
|
2015-07-03 14:15:20 +02:00
|
|
|
for (Plot plot : PS.get().getPlotsRaw()) {
|
2015-05-02 12:08:30 +02:00
|
|
|
if (plot.owner != null) {
|
|
|
|
uuids.add(plot.owner);
|
2015-07-21 20:31:12 +02:00
|
|
|
uuids.addAll(plot.getTrusted());
|
|
|
|
uuids.addAll(plot.getMembers());
|
|
|
|
uuids.addAll(plot.getDenied());
|
2015-05-02 12:08:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return uuids;
|
|
|
|
}
|
2015-07-24 16:06:58 +02:00
|
|
|
|
|
|
|
public static UUIDWrapper getUUIDWrapper() {
|
|
|
|
return implementation.getUUIDWrapper();
|
2015-06-24 16:32:27 +02:00
|
|
|
}
|
2015-07-24 16:06:58 +02:00
|
|
|
|
|
|
|
public static void setUUIDWrapper(final UUIDWrapper wrapper) {
|
|
|
|
implementation.setUUIDWrapper(wrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void startCaching() {
|
|
|
|
implementation.startCaching();
|
|
|
|
}
|
|
|
|
|
2015-07-27 09:26:50 +02:00
|
|
|
public static void cache(final BiMap<StringWrapper, UUID> toAdd) {
|
|
|
|
implementation.add(toAdd);
|
2014-12-22 16:12:40 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-21 13:52:50 +01:00
|
|
|
public static UUID getUUID(final PlotPlayer player) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getUUID(player);
|
2014-12-22 16:12:40 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-07-27 09:26:50 +02:00
|
|
|
public static UUID getUUID(final OfflinePlotPlayer player) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getUUID(player);
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
public static String getName(final UUID uuid) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getName(uuid);
|
2014-12-13 12:59:43 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
|
|
|
public static PlotPlayer getPlayer(final UUID uuid) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getPlayer(uuid);
|
2015-02-21 13:52:50 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
|
|
|
public static PlotPlayer getPlayer(final String name) {
|
2015-07-24 16:06:58 +02:00
|
|
|
return implementation.getPlayer(name);
|
2015-02-21 13:52:50 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-07-27 09:26:50 +02:00
|
|
|
public static UUID getUUID(final String name, RunnableVal<UUID> ifFetch) {
|
|
|
|
return implementation.getUUID(name, ifFetch);
|
2015-07-24 16:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Map<String, PlotPlayer> getPlayers() {
|
|
|
|
return implementation.getPlayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void handleShutdown() {
|
|
|
|
implementation.handleShutdown();
|
2014-12-13 12:59:43 +01:00
|
|
|
}
|
2014-10-06 14:51:28 +02:00
|
|
|
}
|