Just moving a few things.

This commit is contained in:
boy0001 2014-12-16 15:58:54 +11:00
parent a93e6b5a55
commit 37367adfcf
6 changed files with 108 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.intellectualcrafters</groupId>
<artifactId>PlotSquared</artifactId>
<version>2.3.8</version>
<version>2.4.0</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.listeners.*;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.Logger.LogLevel;
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
import com.intellectualcrafters.plot.uuid.UUIDSaver;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;

View File

@ -27,9 +27,13 @@ import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
import com.intellectualcrafters.plot.uuid.UUIDSaver;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

View File

@ -0,0 +1,31 @@
package com.intellectualcrafters.plot.uuid;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public class DefaultUUIDWrapper extends UUIDWrapper {
@Override
public UUID getUUID(Player player) {
return player.getUniqueId();
}
@Override
public UUID getUUID(OfflinePlayer player) {
return player.getUniqueId();
}
@Override
public OfflinePlayer getOfflinePlayer(UUID uuid) {
return Bukkit.getOfflinePlayer(uuid);
}
@Override
public Player getPlayer(UUID uuid) {
return Bukkit.getPlayer(uuid);
}
}

View File

@ -0,0 +1,55 @@
package com.intellectualcrafters.plot.uuid;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.UUIDHandler;
public class OfflineUUIDWrapper extends UUIDWrapper {
@Override
public UUID getUUID(Player player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
@Override
public UUID getUUID(OfflinePlayer player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
@Override
public OfflinePlayer getOfflinePlayer(UUID uuid) {
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
String name = map.get(uuid).value;
if (name != null) {
return Bukkit.getOfflinePlayer(name);
}
else {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (getUUID(player).equals(uuid)) {
return player;
}
}
}
return Bukkit.getOfflinePlayer(uuid.toString());
}
@Override
public Player getPlayer(UUID uuid) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (getUUID(player).equals(uuid)) {
return player;
}
}
return null;
}
}

View File

@ -0,0 +1,16 @@
package com.intellectualcrafters.plot.uuid;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public abstract class UUIDWrapper {
public abstract UUID getUUID(Player player);
public abstract UUID getUUID(OfflinePlayer player);
public abstract OfflinePlayer getOfflinePlayer(UUID uuid);
public abstract Player getPlayer(UUID uuid);
}