I heard Lombok actually wasn't that fun. So I removed it.

This commit is contained in:
Olof Larsson 2013-02-28 19:44:30 +01:00
parent 9b0f96e794
commit 8c11390bf9
10 changed files with 238 additions and 78 deletions

View File

@ -5,10 +5,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -37,7 +33,6 @@ import com.massivecraft.mcore.xlib.gson.annotations.SerializedName;
* Hopefully this class will save you from implementing special classes for all those combinations.
*/
@EqualsAndHashCode
public class PS implements Cloneable, Serializable
{
// -------------------------------------------- //
@ -54,7 +49,9 @@ public class PS implements Cloneable, Serializable
// Field: worldName
@SerializedName("w")
@Getter @Setter protected String worldName = null;
protected String worldName = null;
public String getWorldName() { return this.worldName; }
public void setWorldName(String worldName) { this.worldName = worldName; }
// FakeField: world
public World getWorld()
@ -71,7 +68,10 @@ public class PS implements Cloneable, Serializable
// Field: blockX
@SerializedName("bx")
@Getter @Setter protected Integer blockX = null;
protected Integer blockX = null;
public Integer getBlockX() { return this.blockX; }
public void setBlockX(Integer blockX) { this.blockX = blockX; }
public Integer calcBlockX()
{
return calcBlock(this.locationX, this.blockX, this.chunkX);
@ -79,7 +79,10 @@ public class PS implements Cloneable, Serializable
// Field: blockY
@SerializedName("by")
@Getter @Setter protected Integer blockY = null;
protected Integer blockY = null;
public Integer getBlockY() { return this.blockY; }
public void setBlockY(Integer blockY) { this.blockY = blockY; }
public Integer calcBlockY()
{
return calcBlock(this.locationY, this.blockY, null);
@ -87,7 +90,10 @@ public class PS implements Cloneable, Serializable
// Field: blockZ
@SerializedName("bz")
@Getter @Setter protected Integer blockZ = null;
protected Integer blockZ = null;
public Integer getBlockZ() { return this.blockZ; }
public void setBlockZ(Integer blockZ) { this.blockZ = blockZ; }
public Integer calcBlockZ()
{
return calcBlock(this.locationZ, this.blockZ, this.chunkZ);
@ -105,7 +111,10 @@ public class PS implements Cloneable, Serializable
// Field: locationX
@SerializedName("lx")
@Getter @Setter protected Double locationX = null;
protected Double locationX = null;
public Double getLocationX() { return this.locationX; }
public void setLocationX(Double locationX) { this.locationX = locationX; }
public Double calcLocationX()
{
return calcLocation(this.locationX, this.blockX, this.chunkX);
@ -113,7 +122,10 @@ public class PS implements Cloneable, Serializable
// Field: locationY
@SerializedName("ly")
@Getter @Setter protected Double locationY = null;
protected Double locationY = null;
public Double getLocationY() { return this.locationY; }
public void setLocationY(Double locationY) { this.locationY = locationY; }
public Double calcLocationY()
{
return calcLocation(this.locationY, this.blockY, null);
@ -121,7 +133,10 @@ public class PS implements Cloneable, Serializable
// Field: locationZ
@SerializedName("lz")
@Getter @Setter protected Double locationZ = null;
protected Double locationZ = null;
public Double getLocationZ() { return this.locationZ; }
public void setLocationZ(Double locationZ) { this.locationZ = locationZ; }
public Double calcLocationZ()
{
return calcLocation(this.locationZ, this.blockZ, this.chunkZ);
@ -139,7 +154,10 @@ public class PS implements Cloneable, Serializable
// Field: chunkX
@SerializedName("cx")
@Getter @Setter protected Integer chunkX = null;
protected Integer chunkX = null;
public Integer getChunkX() { return this.chunkX; }
public void setChunkX(Integer chunkX) { this.chunkX = chunkX; }
public Integer calcChunkX()
{
return calcChunk(this.locationX, this.blockX, this.chunkX);
@ -147,7 +165,10 @@ public class PS implements Cloneable, Serializable
// Field: chunkZ
@SerializedName("xz")
@Getter @Setter protected Integer chunkZ = null;
protected Integer chunkZ = null;
public Integer getChunkZ() { return this.chunkZ; }
public void setChunkZ(Integer chunkZ) { this.chunkZ = chunkZ; }
public Integer calcChunkZ()
{
return calcChunk(this.locationZ, this.blockZ, this.chunkZ);
@ -165,28 +186,24 @@ public class PS implements Cloneable, Serializable
// Field: pitch
@SerializedName("p")
@Getter @Setter protected Float pitch = null;
/*public void setPitch(Float val)
{
if (val == null)
{
this.pitch = null;
}
else
{
this.pitch = (val + 360F) % 360F;
}
}*/
protected Float pitch = null;
public Float getPitch() { return this.pitch; }
public void setPitch(Float pitch) { this.pitch = pitch; }
// Field: yaw
@SerializedName("y")
@Getter @Setter protected Float yaw = null;
protected Float yaw = null;
public Float getYaw() { return this.yaw; }
public void setYaw(Float yaw) { this.yaw = yaw; }
// ---------------------
// Field: velocityX
@SerializedName("vx")
@Getter @Setter protected Double velocityX = null;
protected Double velocityX = null;
public Double getVelocityX() { return this.velocityX; }
public void setVelocityX(Double velocityX) { this.velocityX = velocityX; }
public Double calcVelocityX()
{
return calcVelocity(this.locationX, this.blockX, this.chunkX, this.velocityX);
@ -194,7 +211,10 @@ public class PS implements Cloneable, Serializable
// Field: velocityY
@SerializedName("vy")
@Getter @Setter protected Double velocityY = null;
protected Double velocityY = null;
public Double getVelocityY() { return this.velocityY; }
public void setVelocityY(Double velocityY) { this.velocityY = velocityY; }
public Double calcVelocityY()
{
return calcVelocity(this.locationY, this.blockY, 0, this.velocityY);
@ -202,7 +222,10 @@ public class PS implements Cloneable, Serializable
// Field: velocityZ
@SerializedName("vz")
@Getter @Setter protected Double velocityZ = null;
protected Double velocityZ = null;
public Double getVelocityZ() { return this.velocityZ; }
public void setVelocityZ(Double velocityZ) { this.velocityZ = velocityZ; }
public Double calcVelocityZ()
{
return calcVelocity(this.locationZ, this.blockZ, this.chunkZ, this.velocityZ);
@ -629,6 +652,120 @@ public class PS implements Cloneable, Serializable
return new PS(this);
}
//----------------------------------------------//
// EQUALS AND HASH CODE
//----------------------------------------------//
// Generated by eclipse
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((blockX == null) ? 0 : blockX.hashCode());
result = prime * result + ((blockY == null) ? 0 : blockY.hashCode());
result = prime * result + ((blockZ == null) ? 0 : blockZ.hashCode());
result = prime * result + ((chunkX == null) ? 0 : chunkX.hashCode());
result = prime * result + ((chunkZ == null) ? 0 : chunkZ.hashCode());
result = prime * result
+ ((locationX == null) ? 0 : locationX.hashCode());
result = prime * result
+ ((locationY == null) ? 0 : locationY.hashCode());
result = prime * result
+ ((locationZ == null) ? 0 : locationZ.hashCode());
result = prime * result + ((pitch == null) ? 0 : pitch.hashCode());
result = prime * result
+ ((velocityX == null) ? 0 : velocityX.hashCode());
result = prime * result
+ ((velocityY == null) ? 0 : velocityY.hashCode());
result = prime * result
+ ((velocityZ == null) ? 0 : velocityZ.hashCode());
result = prime * result
+ ((worldName == null) ? 0 : worldName.hashCode());
result = prime * result + ((yaw == null) ? 0 : yaw.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
PS other = (PS) obj;
if (blockX == null)
{
if (other.blockX != null) return false;
}
else if (!blockX.equals(other.blockX)) return false;
if (blockY == null)
{
if (other.blockY != null) return false;
}
else if (!blockY.equals(other.blockY)) return false;
if (blockZ == null)
{
if (other.blockZ != null) return false;
}
else if (!blockZ.equals(other.blockZ)) return false;
if (chunkX == null)
{
if (other.chunkX != null) return false;
}
else if (!chunkX.equals(other.chunkX)) return false;
if (chunkZ == null)
{
if (other.chunkZ != null) return false;
}
else if (!chunkZ.equals(other.chunkZ)) return false;
if (locationX == null)
{
if (other.locationX != null) return false;
}
else if (!locationX.equals(other.locationX)) return false;
if (locationY == null)
{
if (other.locationY != null) return false;
}
else if (!locationY.equals(other.locationY)) return false;
if (locationZ == null)
{
if (other.locationZ != null) return false;
}
else if (!locationZ.equals(other.locationZ)) return false;
if (pitch == null)
{
if (other.pitch != null) return false;
}
else if (!pitch.equals(other.pitch)) return false;
if (velocityX == null)
{
if (other.velocityX != null) return false;
}
else if (!velocityX.equals(other.velocityX)) return false;
if (velocityY == null)
{
if (other.velocityY != null) return false;
}
else if (!velocityY.equals(other.velocityY)) return false;
if (velocityZ == null)
{
if (other.velocityZ != null) return false;
}
else if (!velocityZ.equals(other.velocityZ)) return false;
if (worldName == null)
{
if (other.worldName != null) return false;
}
else if (!worldName.equals(other.worldName)) return false;
if (yaw == null)
{
if (other.yaw != null) return false;
}
else if (!yaw.equals(other.yaw)) return false;
return true;
}
//----------------------------------------------//
// STATIC COMPARISON TOOLS
//----------------------------------------------//

View File

@ -5,8 +5,6 @@ import java.util.Map;
import net.minecraft.server.v1_4_R1.NBTBase;
import lombok.Getter;
public enum NBType
{
// -------------------------------------------- //
@ -32,8 +30,11 @@ public enum NBType
// FIELDS
// -------------------------------------------- //
@Getter final byte id;
@Getter final String name;
final byte id;
public byte getId() { return this.id; }
final String name;
public String getName() { return this.name; }
// -------------------------------------------- //
// CONSTRUCT

View File

@ -3,9 +3,6 @@ package com.massivecraft.mcore.cmd;
import java.util.*;
import java.util.Map.Entry;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
@ -31,7 +28,10 @@ public abstract class MCommand
// FIELD: subCommands
// The sub-commands to this command
@Getter @Setter protected List<MCommand> subCommands;
protected List<MCommand> subCommands;
public List<MCommand> getSubCommands() { return this.subCommands; }
public void setSubCommands(List<MCommand> subCommands) { this.subCommands = subCommands; }
public void addSubCommand(MCommand subCommand)
{
subCommand.commandChain.addAll(this.commandChain);
@ -41,18 +41,27 @@ public abstract class MCommand
// FIELD: aliases
// The different names this commands will react to
@Getter @Setter protected List<String> aliases;
protected List<String> aliases;
public List<String> getAliases() { return this.aliases; }
public void setAliases(List<String> aliases) { this.aliases = aliases; }
public void addAliases(String... aliases) { this.aliases.addAll(Arrays.asList(aliases)); }
public void addAliases(List<String> aliases) { this.aliases.addAll(aliases); }
// FIELD: requiredArgs
// These args must always be sent
@Getter @Setter protected List<String> requiredArgs;
protected List<String> requiredArgs;
public List<String> getRequiredArgs() { return this.requiredArgs; }
public void setRequiredArgs(List<String> requiredArgs) { this.requiredArgs = requiredArgs; }
public void addRequiredArg(String arg) { this.requiredArgs.add(arg); }
// FIELD: optionalArgs
// These args are optional
@Getter @Setter protected Map<String, String> optionalArgs;
protected Map<String, String> optionalArgs;
public Map<String, String> getOptionalArgs() { return this.optionalArgs; }
public void setOptionalArgs(Map<String, String> optionalArgs) { this.optionalArgs = optionalArgs; }
public void addOptionalArg(String arg, String def) { this.optionalArgs.put(arg, def); }
// FIELD: errorOnToManyArgs
@ -63,13 +72,18 @@ public abstract class MCommand
// FIELD: requirements
// All these requirements must be met for the command to be executable;
@Getter @Setter protected List<IReq> requirements;
protected List<IReq> requirements;
public List<IReq> getRequirements() { return this.requirements; }
public void getRequirements(List<IReq> requirements) { this.requirements = requirements; }
public void addRequirements(IReq... requirements) { this.requirements.addAll(Arrays.asList(requirements)); }
// FIELD: desc
// This field may be left blank and will in such case be loaded from the permissions node instead.
// Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff".
@Setter protected String desc = null;
protected String desc = null;
public void setDesc(String desc) { this.desc = desc; }
public String getDesc()
{
if (this.desc != null) return this.desc;
@ -89,7 +103,9 @@ public abstract class MCommand
// FIELD: descPermission
// This permission node IS NOT TESTED AT ALL. It is rather used in the method above.
@Setter protected String descPermission;
protected String descPermission;
public void setDescPermission(String descPermission) { this.descPermission = descPermission; }
public String getDescPermission()
{
if (this.descPermission != null) return this.descPermission;
@ -110,7 +126,9 @@ public abstract class MCommand
public List<String> getHelp() { return this.help; }
// FIELD: visibilityMode
@Getter @Setter protected VisibilityMode visibilityMode;
protected VisibilityMode visibilityMode;
public VisibilityMode getVisibilityMode() { return this.visibilityMode; }
public void setVisibilityMode(VisibilityMode visibilityMode) { this.visibilityMode = visibilityMode; }
// -------------------------------------------- //
// EXECUTION INFO
@ -118,11 +136,15 @@ public abstract class MCommand
// FIELD: args
// Will contain the arguments, or and empty list if there are none.
@Getter @Setter protected List<String> args;
protected List<String> args;
public List<String> getArgs() { return this.args; }
public void setArgs(List<String> args) { this.args = args; }
// FIELD: commandChain
// The command chain used to execute this command
@Getter @Setter protected List<MCommand> commandChain = new ArrayList<MCommand>();
protected List<MCommand> commandChain = new ArrayList<MCommand>();
public List<MCommand> getCommandChain() { return this.commandChain; }
public void setCommandChain(List<MCommand> commandChain) { this.commandChain = commandChain; }
// FIELDS: sender, me, senderIsConsole
public CommandSender sender;

View File

@ -4,16 +4,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
public class ArgResult<T>
{
// -------------------------------------------- //
// FIELD: RESULT
// -------------------------------------------- //
@Getter @Setter protected T result = null;
protected T result = null;
public T getResult() { return this.result; }
public void setResult(T result) { this.result = result; }
public boolean hasResult()
{
return this.getResult() != null;
@ -23,7 +22,8 @@ public class ArgResult<T>
// FIELD: ERRORS
// -------------------------------------------- //
@Getter protected List<String> errors = new ArrayList<String>();
protected List<String> errors = new ArrayList<String>();
public List<String> getErrors() { return this.errors; }
public void setErrors(List<String> val)
{

View File

@ -1,8 +1,5 @@
package com.massivecraft.mcore.cmd.req;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.cmd.MCommand;
@ -10,7 +7,9 @@ import com.massivecraft.mcore.util.PermUtil;
public class ReqHasPerm implements IReq
{
@Getter @Setter private String perm;
private String perm;
public String getPerm() { return this.perm; }
public void setPerm(String perm) { this.perm = perm; }
public ReqHasPerm(String perm)
{

View File

@ -1,7 +1,5 @@
package com.massivecraft.mcore.event;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -22,9 +20,11 @@ public class MCoreAfterPlayerRespawnEvent extends Event implements Runnable
// FIELD
// -------------------------------------------- //
@Getter protected final Location deathLocation;
protected final Location deathLocation;
public Location getDeathLocation() { return this.deathLocation; }
@Getter protected final PlayerRespawnEvent bukkitEvent;
protected final PlayerRespawnEvent bukkitEvent;
public PlayerRespawnEvent getBukkitEvent() { return this.bukkitEvent; }
public Location getRespawnLocation() { return this.bukkitEvent.getRespawnLocation(); }
public Player getPlayer() { return this.bukkitEvent.getPlayer(); }

View File

@ -1,7 +1,5 @@
package com.massivecraft.mcore.event;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -24,7 +22,8 @@ public class MCoreAfterPlayerTeleportEvent extends Event implements Runnable
// FIELD
// -------------------------------------------- //
@Getter protected final PlayerTeleportEvent bukkitEvent;
protected final PlayerTeleportEvent bukkitEvent;
public PlayerTeleportEvent getBukkitEvent() { return this.bukkitEvent; }
public Location getFrom() { return this.bukkitEvent.getFrom(); }
public Location getTo() { return this.bukkitEvent.getTo(); }

View File

@ -3,8 +3,6 @@ package com.massivecraft.mcore.event;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -33,16 +31,20 @@ public class MCorePlayerLeaveEvent extends Event implements Runnable
// FIELD
// -------------------------------------------- //
@Getter protected final Player player;
protected final Player player;
public Player getPlayer() { return this.player; }
@Getter protected final boolean preDisconnect;
protected final boolean preDisconnect;
public boolean isPreDisconnect() { return this.preDisconnect; }
public boolean isPostDisconnect() { return !this.isPreDisconnect(); }
@Getter protected final String caller;
protected final String caller;
public String getCaller() { return this.caller; }
public boolean isQuit() { return "quit".equals(caller); }
public boolean isKick() { return "kick".equals(caller); }
@Getter protected final String message;
protected final String message;
public String getMessage() { return this.message; }
// -------------------------------------------- //
// CONSTRUCT

View File

@ -2,8 +2,6 @@ package com.massivecraft.mcore.integration;
import java.util.Collection;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -24,7 +22,8 @@ public class Integration implements Listener
protected MPlugin ourPlugin;
protected IntegrationFeatures features;
@Getter protected boolean active = false;
protected boolean active = false;
public boolean isActive() { return this.active; }
// -------------------------------------------- //
// CONSTRUCT

View File

@ -4,9 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import lombok.Getter;
import lombok.Setter;
import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.store.Entity;
import com.massivecraft.mcore.xlib.gson.annotations.SerializedName;
@ -26,10 +23,12 @@ public class Aspect extends Entity<Aspect, String>
// TRANSIENT FIELDS
// -------------------------------------------- //
@Getter protected transient boolean registered = false;
protected transient boolean registered = false;
public boolean isRegistered() { return this.registered; }
public void register() { this.registered = true; }
@Getter protected transient Collection<String> desc = new ArrayList<String>();
protected transient Collection<String> desc = new ArrayList<String>();
public Collection<String> getDesc() { return this.desc; }
public void setDesc(Collection<String> val) { this.desc = val; }
public void setDesc(String... val) { this.desc = Arrays.asList(val); }
@ -38,7 +37,9 @@ public class Aspect extends Entity<Aspect, String>
// -------------------------------------------- //
@SerializedName("mid")
@Getter @Setter protected String multiverseId;
protected String multiverseId;
public String getMultiverseId() { return this.multiverseId; }
public void setMultiverseId(String multiverseId) { this.multiverseId = multiverseId; }
public Multiverse multiverse()
{
Multiverse ret = MultiverseColl.i.get(this.multiverseId);