Major code reformatting

This commit is contained in:
MattBDev
2016-03-22 21:41:37 -04:00
parent e18e1d4816
commit 9e2c6f2182
209 changed files with 9551 additions and 9237 deletions

View File

@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
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.sponge.util.SpongeUtil;
@ -28,13 +28,13 @@ import java.util.UUID;
public class SpongePlayer extends PlotPlayer {
public final Player player;
public HashSet<String> hasPerm = new HashSet<>();
public HashSet<String> noPerm = new HashSet<>();
private UUID uuid;
private String name;
private long last = 0;
public HashSet<String> hasPerm = new HashSet<>();
public HashSet<String> noPerm = new HashSet<>();
public SpongePlayer(final Player player) {
public SpongePlayer(Player player) {
this.player = player;
super.populatePersistentMetaMap();
}
@ -46,208 +46,201 @@ public class SpongePlayer extends PlotPlayer {
@Override
public long getPreviousLogin() {
if (last != 0) {
return last;
if (this.last != 0) {
return this.last;
}
final Value<Instant> data = player.getJoinData().lastPlayed();
Value<Instant> data = this.player.getJoinData().lastPlayed();
if (data.exists()) {
return last = data.get().getEpochSecond() * 1000;
return this.last = data.get().getEpochSecond() * 1000;
}
return 0;
}
@Override
public Location getLocation() {
final Location loc = super.getLocation();
return loc == null ? SpongeUtil.getLocation(player) : loc;
Location location = super.getLocation();
if (location == null) {
return SpongeUtil.getLocation(this.player);
} else {
return location;
}
}
@Override
public Location getLocationFull() {
return SpongeUtil.getLocationFull(player);
return SpongeUtil.getLocationFull(this.player);
}
@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 perm) {
public boolean hasPermission(String permission) {
if (Settings.PERMISSION_CACHING) {
if (noPerm.contains(perm)) {
if (this.noPerm.contains(permission)) {
return false;
}
if (hasPerm.contains(perm)) {
if (this.hasPerm.contains(permission)) {
return true;
}
final boolean result = player.hasPermission(perm);
boolean result = this.player.hasPermission(permission);
if (!result) {
noPerm.add(perm);
this.noPerm.add(permission);
return false;
}
hasPerm.add(perm);
this.hasPerm.add(permission);
return true;
}
return player.hasPermission(perm);
return this.player.hasPermission(permission);
}
@Override
public void sendMessage(final String message) {
player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
public void sendMessage(String message) {
this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(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;
}
final String world = player.getWorld().getName();
if (!world.equals(loc.getWorld())) {
player.transferToWorld(loc.getWorld(), new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
String world = this.player.getWorld().getName();
if (!world.equals(location.getWorld())) {
this.player.transferToWorld(location.getWorld(), new Vector3d(location.getX(), location.getY(), location.getZ()));
} else {
org.spongepowered.api.world.Location current = player.getLocation();
current = current.setPosition(new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
player.setLocation(current);
org.spongepowered.api.world.Location current = this.player.getLocation();
current = current.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
this.player.setLocation(current);
}
}
@Override
public boolean isOnline() {
return player.isOnline();
return this.player.isOnline();
}
@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 void setCompassTarget(final Location loc) {
final TargetedLocationData target = player.getOrCreate(TargetedLocationData.class).get();
target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(loc).getPosition());
public void setCompassTarget(Location location) {
TargetedLocationData target = this.player.getOrCreate(TargetedLocationData.class).get();
target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition());
}
@Override
public void loadData() {
public void setWeather(PlotWeather weather) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void saveData() {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void setWeather(final PlotWeather weather) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public PlotGamemode getGamemode() {
final GameMode gamemode = player.getGameModeData().type().get();
public PlotGameMode getGameMode() {
GameMode gamemode = this.player.getGameModeData().type().get();
if (gamemode == GameModes.ADVENTURE) {
return PlotGamemode.ADVENTURE;
return PlotGameMode.ADVENTURE;
}
if (gamemode == GameModes.CREATIVE) {
return PlotGamemode.CREATIVE;
return PlotGameMode.CREATIVE;
}
if (gamemode == GameModes.SPECTATOR) {
return PlotGamemode.SPECTATOR;
return PlotGameMode.SPECTATOR;
}
if (gamemode == GameModes.SURVIVAL) {
return PlotGamemode.SURVIVAL;
return PlotGameMode.SURVIVAL;
}
throw new UnsupportedOperationException("INVALID GAMEMODE");
}
@Override
public void setGamemode(final PlotGamemode gamemode) {
switch (gamemode) {
public void setGameMode(PlotGameMode gameMode) {
switch (gameMode) {
case ADVENTURE:
player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
this.player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
return;
case CREATIVE:
player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
this.player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
return;
case SPECTATOR:
player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
this.player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
return;
case SURVIVAL:
player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
this.player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
return;
}
}
@Override
public void setTime(final long time) {
public void setTime(long time) {
// TODO Auto-generated method stub
if (time != Long.MAX_VALUE) {} else {}
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void setFlight(final boolean fly) {
player.offer(Keys.IS_FLYING, fly);
player.offer(Keys.CAN_FLY, fly);
public void setFlight(boolean fly) {
this.player.offer(Keys.IS_FLYING, fly);
this.player.offer(Keys.CAN_FLY, fly);
}
@Override
public void playMusic(final Location loc, final int id) {
public void playMusic(Location location, int id) {
switch (id) {
case 0:
player.playSound(null, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(null, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2256:
player.playSound(SoundTypes.RECORDS_11, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_11, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2257:
player.playSound(SoundTypes.RECORDS_13, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_13, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2258:
player.playSound(SoundTypes.RECORDS_BLOCKS, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_BLOCKS, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2259:
player.playSound(SoundTypes.RECORDS_CAT, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_CAT, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2260:
player.playSound(SoundTypes.RECORDS_CHIRP, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_CHIRP, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2261:
player.playSound(SoundTypes.RECORDS_FAR, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_FAR, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2262:
player.playSound(SoundTypes.RECORDS_MALL, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_MALL, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2263:
player.playSound(SoundTypes.RECORDS_MELLOHI, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_MELLOHI, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2264:
player.playSound(SoundTypes.RECORDS_STAL, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_STAL, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2265:
player.playSound(SoundTypes.RECORDS_STRAD, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_STRAD, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2266:
player.playSound(SoundTypes.RECORDS_WAIT, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_WAIT, SpongeUtil.getLocation(location).getPosition(), 1);
break;
case 2267:
player.playSound(SoundTypes.RECORDS_WARD, SpongeUtil.getLocation(loc).getPosition(), 1);
this.player.playSound(SoundTypes.RECORDS_WARD, SpongeUtil.getLocation(location).getPosition(), 1);
break;
}
}
@Override
public void kick(final String message) {
player.kick(SpongeUtil.getText(message));
public void kick(String message) {
this.player.kick(SpongeUtil.getText(message));
}
@Override public void stopSpectating() {
@ -257,6 +250,6 @@ public class SpongePlayer extends PlotPlayer {
@Override
public boolean isBanned() {
BanService service = Sponge.getServiceManager().provide(BanService.class).get();
return service.isBanned(player.getProfile());
return service.isBanned(this.player.getProfile());
}
}