This commit is contained in:
boy0001 2014-12-16 15:59:27 +11:00
parent 37367adfcf
commit ffc7a5c7b7
3 changed files with 0 additions and 101 deletions

View File

@ -1,31 +0,0 @@
package com.intellectualcrafters.plot.util;
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

@ -1,54 +0,0 @@
package com.intellectualcrafters.plot.util;
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;
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

@ -1,16 +0,0 @@
package com.intellectualcrafters.plot.util;
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);
}