PlotSquared/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java

74 lines
2.0 KiB
Java
Raw Normal View History

2015-07-30 16:25:16 +02:00
package com.plotsquared.sponge.uuid;
import java.util.UUID;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
2015-07-30 16:25:16 +02:00
import com.plotsquared.sponge.SpongeMain;
2015-07-30 19:24:01 +02:00
import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
@Override
public UUID getUUID(PlotPlayer player) {
return ((SpongePlayer) player).player.getUniqueId();
}
@Override
public UUID getUUID(OfflinePlotPlayer player) {
return player.getUUID();
}
@Override
public UUID getUUID(String name) {
try {
return SpongeMain.THIS.getResolver().get(name, true).get().getUniqueId();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
String name;
try {
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName();
}
catch (Exception e) {
name = null;
}
final String username = name;
return new OfflinePlotPlayer() {
@Override
public boolean isOnline() {
return UUIDHandler.getPlayer(uuid) != null;
}
@Override
public UUID getUUID() {
return uuid;
}
@Override
public String getName() {
return username;
}
@Override
public long getLastPlayed() {
// TODO FIXME
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
};
}
@Override
public OfflinePlotPlayer[] getOfflinePlayers() {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
}