Misc. code changes

A lot of renaming
Some formatting
Narrowed scope of variables
Added annotations
This commit is contained in:
MattBDev
2019-05-13 21:57:41 -04:00
parent 84911c1a8c
commit b66734a472
42 changed files with 409 additions and 327 deletions

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
@ -19,7 +20,7 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
this.player = player;
}
@Override public UUID getUUID() {
@NotNull @Override public UUID getUUID() {
return this.player.getUniqueId();
}

View File

@ -6,7 +6,12 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -18,8 +23,8 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Set;
import java.util.UUID;
@ -55,7 +60,7 @@ public class BukkitPlayer extends PlotPlayer {
return location == null ? BukkitUtil.getLocation(this.player) : location;
}
@Nonnull @Override public UUID getUUID() {
@NotNull @Override public UUID getUUID() {
if (this.uuid == null) {
this.uuid = UUIDHandler.getUUID(this);
}

View File

@ -13,14 +13,6 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
public class OfflinePlayerUtil {
public static Player loadPlayer(String name) {
return loadPlayer(Bukkit.getOfflinePlayer(name));
}
public static Player loadPlayer(UUID id) {
return loadPlayer(Bukkit.getOfflinePlayer(id));
}
public static Player loadPlayer(OfflinePlayer player) {
if (player == null) {
return null;

View File

@ -26,8 +26,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
public BiomeGrid biomeGrid;
public Chunk chunk;
public String world;
public int cx;
public int cz;
public int chunkX;
public int chunkZ;
@Getter @Setter private ChunkData cd = null;
public GenChunk() {
@ -39,7 +39,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
if (chunk == null) {
World worldObj = BukkitUtil.getWorld(world);
if (worldObj != null) {
this.chunk = worldObj.getChunkAt(cx, cz);
this.chunk = worldObj.getChunkAt(chunkX, chunkZ);
}
}
return chunk;
@ -52,8 +52,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
public void setChunk(ChunkWrapper wrap) {
chunk = null;
world = wrap.world;
cx = wrap.x;
cz = wrap.z;
chunkX = wrap.x;
chunkZ = wrap.z;
}
@Override public void fillBiome(String biomeName) {
@ -82,13 +82,13 @@ public class GenChunk extends ScopedLocalBlockQueue {
Arrays.fill(data, start, end, block);
}
}
int minx = Math.min(pos1.getX(), pos2.getX());
int miny = Math.min(pos1.getY(), pos2.getY());
int minz = Math.min(pos1.getZ(), pos2.getZ());
int maxx = Math.max(pos1.getX(), pos2.getX());
int maxy = Math.max(pos1.getY(), pos2.getY());
int maxz = Math.max(pos1.getZ(), pos2.getZ());
cd.setRegion(minx, miny, minz, maxx + 1, maxy + 1, maxz + 1, block.to(Material.class));
int minX = Math.min(pos1.getX(), pos2.getX());
int minY = Math.min(pos1.getY(), pos2.getY());
int minZ = Math.min(pos1.getZ(), pos2.getZ());
int maxX = Math.max(pos1.getX(), pos2.getX());
int maxY = Math.max(pos1.getY(), pos2.getY());
int maxZ = Math.max(pos1.getZ(), pos2.getZ());
cd.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class));
}
@Override public boolean setBiome(int x, int z, String biome) {
@ -147,11 +147,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
}
public int getX() {
return chunk == null ? cx : chunk.getX();
return chunk == null ? chunkX : chunk.getX();
}
public int getZ() {
return chunk == null ? cz : chunk.getZ();
return chunk == null ? chunkZ : chunk.getZ();
}
@Override public String getWorld() {

View File

@ -7,13 +7,14 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.UUID;
public class DefaultUUIDWrapper extends UUIDWrapper {
@Override public UUID getUUID(PlotPlayer player) {
@NotNull @Override public UUID getUUID(PlotPlayer player) {
return ((BukkitPlayer) player).player.getUniqueId();
}

View File

@ -4,14 +4,14 @@ import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.google.common.base.Charsets;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
@NotNull @Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(OfflinePlotPlayer player) {

View File

@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -33,9 +34,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
}
}
@Override public UUID getUUID(PlotPlayer player) {
return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
@NotNull @Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(OfflinePlotPlayer player) {