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

78 lines
2.2 KiB
Java
Raw Normal View History

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