mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-21 23:04:42 +02:00
Major code reformatting
This commit is contained in:
@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
@ -31,12 +31,12 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
|
||||
* @param player
|
||||
*/
|
||||
public BukkitPlayer(final Player player) {
|
||||
public BukkitPlayer(Player player) {
|
||||
this.player = player;
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
|
||||
public BukkitPlayer(final Player player, final boolean offline) {
|
||||
|
||||
public BukkitPlayer(Player player, boolean offline) {
|
||||
this.player = player;
|
||||
this.offline = offline;
|
||||
super.populatePersistentMetaMap();
|
||||
@ -44,45 +44,45 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
if (last == 0) {
|
||||
last = player.getLastPlayed();
|
||||
if (this.last == 0) {
|
||||
this.last = this.player.getLastPlayed();
|
||||
}
|
||||
return last;
|
||||
return this.last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
final Location loc = super.getLocation();
|
||||
return loc == null ? BukkitUtil.getLocation(player) : loc;
|
||||
Location location = super.getLocation();
|
||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (uuid == null) {
|
||||
uuid = UUIDHandler.getUUID(this);
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
return uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String node) {
|
||||
if (offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), node);
|
||||
public boolean hasPermission(String permission) {
|
||||
if (this.offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), permission);
|
||||
}
|
||||
return player.hasPermission(node);
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
public Permission getPermission(final String node) {
|
||||
final PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
public Permission getPermission(String node) {
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
Permission perm = manager.getPermission(node);
|
||||
if (perm == null) {
|
||||
final String[] nodes = node.split("\\.");
|
||||
String[] nodes = node.split("\\.");
|
||||
perm = new Permission(node);
|
||||
final StringBuilder n = new StringBuilder();
|
||||
StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i < nodes.length - 1; i++) {
|
||||
n.append(nodes[i]).append(".");
|
||||
if (!node.equals(n + C.PERMISSION_STAR.s())) {
|
||||
final Permission parent = getPermission(n + C.PERMISSION_STAR.s());
|
||||
Permission parent = getPermission(n + C.PERMISSION_STAR.s());
|
||||
if (parent != null) {
|
||||
perm.addParent(parent, true);
|
||||
}
|
||||
@ -96,134 +96,125 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
player.sendMessage(message);
|
||||
public void sendMessage(String message) {
|
||||
this.player.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc) {
|
||||
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
|
||||
public void teleport(Location location) {
|
||||
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
|
||||
return;
|
||||
}
|
||||
player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()), TeleportCause.COMMAND);
|
||||
this.player.teleport(
|
||||
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5, location.getY(), location.getZ() + 0.5,
|
||||
location.getYaw(), location.getPitch()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
name = player.getName();
|
||||
if (this.name == null) {
|
||||
this.name = this.player.getName();
|
||||
}
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return !offline && player.isOnline();
|
||||
return !this.offline && this.player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(final Location loc) {
|
||||
player.setCompassTarget(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()));
|
||||
public void setCompassTarget(Location location) {
|
||||
this.player.setCompassTarget(
|
||||
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocationFull() {
|
||||
return BukkitUtil.getLocationFull(player);
|
||||
return BukkitUtil.getLocationFull(this.player);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
if (!player.isOnline()) {
|
||||
player.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
player.saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(final PlotWeather weather) {
|
||||
public void setWeather(PlotWeather weather) {
|
||||
switch (weather) {
|
||||
case CLEAR:
|
||||
player.setPlayerWeather(WeatherType.CLEAR);
|
||||
this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||
return;
|
||||
case RAIN:
|
||||
player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
return;
|
||||
case RESET:
|
||||
player.resetPlayerWeather();
|
||||
this.player.resetPlayerWeather();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotGamemode getGamemode() {
|
||||
switch (player.getGameMode()) {
|
||||
public PlotGameMode getGameMode() {
|
||||
switch (this.player.getGameMode()) {
|
||||
case ADVENTURE:
|
||||
return PlotGamemode.ADVENTURE;
|
||||
return PlotGameMode.ADVENTURE;
|
||||
case CREATIVE:
|
||||
return PlotGamemode.CREATIVE;
|
||||
return PlotGameMode.CREATIVE;
|
||||
case SPECTATOR:
|
||||
return PlotGamemode.SPECTATOR;
|
||||
return PlotGameMode.SPECTATOR;
|
||||
case SURVIVAL:
|
||||
return PlotGamemode.SURVIVAL;
|
||||
return PlotGameMode.SURVIVAL;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGamemode(final PlotGamemode gamemode) {
|
||||
switch (gamemode) {
|
||||
public void setGameMode(PlotGameMode gameMode) {
|
||||
switch (gameMode) {
|
||||
case ADVENTURE:
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
this.player.setGameMode(GameMode.ADVENTURE);
|
||||
return;
|
||||
case CREATIVE:
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
this.player.setGameMode(GameMode.CREATIVE);
|
||||
return;
|
||||
case SPECTATOR:
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
this.player.setGameMode(GameMode.SPECTATOR);
|
||||
return;
|
||||
case SURVIVAL:
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
this.player.setGameMode(GameMode.SURVIVAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(final long time) {
|
||||
public void setTime(long time) {
|
||||
if (time != Long.MAX_VALUE) {
|
||||
player.setPlayerTime(time, false);
|
||||
this.player.setPlayerTime(time, false);
|
||||
} else {
|
||||
player.resetPlayerTime();
|
||||
this.player.resetPlayerTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlight(final boolean fly) {
|
||||
player.setAllowFlight(fly);
|
||||
public void setFlight(boolean fly) {
|
||||
this.player.setAllowFlight(fly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(final Location loc, final int id) {
|
||||
player.playEffect(BukkitUtil.getLocation(loc), Effect.RECORD_PLAY, id);
|
||||
public void playMusic(Location location, int id) {
|
||||
this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(final String message) {
|
||||
player.kickPlayer(message);
|
||||
public void kick(String message) {
|
||||
this.player.kickPlayer(message);
|
||||
}
|
||||
|
||||
@Override public void stopSpectating() {
|
||||
if (getGamemode() == PlotGamemode.SPECTATOR) {
|
||||
player.setSpectatorTarget(null);
|
||||
if (getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
this.player.setSpectatorTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return player.isBanned();
|
||||
return this.player.isBanned();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user