PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java

159 lines
3.3 KiB
Java
Raw Normal View History

2015-07-27 15:10:14 +02:00
package com.intellectualcrafters.plot.object;
2015-07-30 16:25:16 +02:00
import java.util.HashMap;
import java.util.Set;
import java.util.UUID;
2015-07-27 15:10:14 +02:00
import com.intellectualcrafters.plot.PS;
2015-07-27 17:14:38 +02:00
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C;
2015-07-27 15:10:14 +02:00
import com.intellectualcrafters.plot.database.DBFunc;
2015-07-27 17:14:38 +02:00
import com.intellectualcrafters.plot.util.MainUtil;
2015-07-30 16:25:16 +02:00
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
2015-07-27 15:10:14 +02:00
2015-07-30 19:24:01 +02:00
public class ConsolePlayer extends PlotPlayer {
2015-07-27 15:10:14 +02:00
private static ConsolePlayer instance;
private Location loc;
private final HashMap<String, Object> meta;
public static ConsolePlayer getConsole() {
if (instance == null) {
instance = new ConsolePlayer();
}
return instance;
}
private ConsolePlayer() {
String world;
Set<String> plotworlds = PS.get().getPlotWorlds();
if (plotworlds.size() > 0) {
world = plotworlds.iterator().next();
}
else {
world = "world";
}
this.loc = new Location(world, 0, 0, 0);
this.meta = new HashMap<>();
}
public static boolean isConsole(PlotPlayer plr) {
return instance == plr;
}
@Override
public long getPreviousLogin() {
return 0;
}
@Override
public Location getLocation() {
return loc;
}
@Override
public Location getLocationFull() {
return loc;
}
@Override
public UUID getUUID() {
return DBFunc.everyone;
}
@Override
public boolean hasPermission(String perm) {
return true;
}
@Override
public void sendMessage(String message) {
PS.log(message);
}
2015-07-27 17:14:38 +02:00
@Override
public void sendMessage(C c, String... args) {
MainUtil.sendMessage(this, c, args);
}
2015-07-27 15:10:14 +02:00
@Override
public void teleport(Location loc) {
this.loc = loc;
}
@Override
public boolean isOnline() {
return true;
}
@Override
public String getName() {
return "*";
}
@Override
public void setCompassTarget(Location loc) {}
@Override
public void loadData() {}
@Override
public void saveData() {}
@Override
public void setAttribute(String key) {}
@Override
public boolean getAttribute(String key) {
return false;
}
@Override
public void removeAttribute(String key) {}
@Override
public void setMeta(String key, Object value) {
this.meta.put(key, value);
}
@Override
public Object getMeta(String key) {
return this.meta.get(key);
}
@Override
public void deleteMeta(String key) {
this.meta.remove(key);
}
2015-07-27 17:14:38 +02:00
@Override
public RequiredType getSuperCaller() {
return RequiredType.CONSOLE;
}
2015-07-30 16:25:16 +02:00
@Override
public void setWeather(PlotWeather weather) {}
@Override
public PlotGamemode getGamemode() {
return PlotGamemode.CREATIVE;
}
@Override
public void setGamemode(PlotGamemode gamemode) {}
@Override
public void setTime(long time) {}
@Override
public void setFlight(boolean fly) {}
@Override
public void playMusic(Location loc, int id) {}
@Override
public void kick(String message) {}
2015-07-27 15:10:14 +02:00
}