java conventions and lombok

This commit is contained in:
Olof Larsson 2012-10-01 16:32:18 +02:00
parent 6fbc4b9a7a
commit 38aad961cc
40 changed files with 295 additions and 294 deletions

View File

@ -75,7 +75,7 @@ public abstract class MPlugin extends JavaPlugin implements Listener
// Collection shutdowns for new system. // Collection shutdowns for new system.
for (Coll<?, ?> coll : Coll.instances) for (Coll<?, ?> coll : Coll.instances)
{ {
if (coll.mplugin() != this) continue; if (coll.getMplugin() != this) continue;
coll.examineThread().interrupt(); coll.examineThread().interrupt();
coll.syncAll(); // TODO: Save outwards only? We may want to avoid loads at this stage... coll.syncAll(); // TODO: Save outwards only? We may want to avoid loads at this stage...
Coll.instances.remove(coll); Coll.instances.remove(coll);

View File

@ -14,10 +14,8 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.massivecraft.mcore4.store.accessor.Accessor;
import com.massivecraft.mcore4.util.Txt; import com.massivecraft.mcore4.util.Txt;
import com.massivecraft.mcore4.xlib.gson.annotations.SerializedName; import com.massivecraft.mcore4.xlib.gson.annotations.SerializedName;
@ -46,7 +44,7 @@ public class PS implements Cloneable
// Field: worldName // Field: worldName
@SerializedName("w") @SerializedName("w")
@Getter @Setter protected String worldName; @Getter @Setter protected String worldName = null;
// FakeField: world // FakeField: world
public World getWorld() public World getWorld()
@ -54,17 +52,16 @@ public class PS implements Cloneable
if (this.worldName == null) return null; if (this.worldName == null) return null;
return Bukkit.getWorld(this.worldName); return Bukkit.getWorld(this.worldName);
} }
public PS setWorld(World val) public void setWorld(World val)
{ {
this.worldName = val.getName(); this.worldName = val.getName();
return this;
} }
// --------------------- // ---------------------
// Field: blockX // Field: blockX
@SerializedName("bx") @SerializedName("bx")
@Getter @Setter protected Integer blockX; @Getter @Setter protected Integer blockX = null;
public Integer calcBlockX() public Integer calcBlockX()
{ {
return calcBlock(this.locationX, this.blockX, this.chunkX); return calcBlock(this.locationX, this.blockX, this.chunkX);
@ -72,7 +69,7 @@ public class PS implements Cloneable
// Field: blockY // Field: blockY
@SerializedName("by") @SerializedName("by")
@Getter @Setter protected Integer blockY; @Getter @Setter protected Integer blockY = null;
public Integer calcBlockY() public Integer calcBlockY()
{ {
return calcBlock(this.locationY, this.blockY, null); return calcBlock(this.locationY, this.blockY, null);
@ -80,7 +77,7 @@ public class PS implements Cloneable
// Field: blockZ // Field: blockZ
@SerializedName("bz") @SerializedName("bz")
@Getter @Setter protected Integer blockZ; @Getter @Setter protected Integer blockZ = null;
public Integer calcBlockZ() public Integer calcBlockZ()
{ {
return calcBlock(this.locationZ, this.blockZ, this.chunkZ); return calcBlock(this.locationZ, this.blockZ, this.chunkZ);
@ -98,7 +95,7 @@ public class PS implements Cloneable
// Field: locationX // Field: locationX
@SerializedName("lx") @SerializedName("lx")
@Getter @Setter protected Double locationX; @Getter @Setter protected Double locationX = null;
public Double calcLocationX() public Double calcLocationX()
{ {
return calcLocation(this.locationX, this.blockX, this.chunkX); return calcLocation(this.locationX, this.blockX, this.chunkX);
@ -106,7 +103,7 @@ public class PS implements Cloneable
// Field: locationY // Field: locationY
@SerializedName("ly") @SerializedName("ly")
@Getter @Setter protected Double locationY; @Getter @Setter protected Double locationY = null;
public Double calcLocationY() public Double calcLocationY()
{ {
return calcLocation(this.locationY, this.blockY, null); return calcLocation(this.locationY, this.blockY, null);
@ -114,7 +111,7 @@ public class PS implements Cloneable
// Field: locationZ // Field: locationZ
@SerializedName("lz") @SerializedName("lz")
@Getter @Setter protected Double locationZ; @Getter @Setter protected Double locationZ = null;
public Double calclocationZ() public Double calclocationZ()
{ {
return calcLocation(this.locationZ, this.blockZ, this.chunkZ); return calcLocation(this.locationZ, this.blockZ, this.chunkZ);
@ -132,7 +129,7 @@ public class PS implements Cloneable
// Field: chunkX // Field: chunkX
@SerializedName("cx") @SerializedName("cx")
@Getter @Setter protected Integer chunkX; @Getter @Setter protected Integer chunkX = null;
public Integer calcChunkX() public Integer calcChunkX()
{ {
return calcChunk(this.locationX, this.blockX, this.chunkX); return calcChunk(this.locationX, this.blockX, this.chunkX);
@ -140,7 +137,7 @@ public class PS implements Cloneable
// Field: chunkZ // Field: chunkZ
@SerializedName("xz") @SerializedName("xz")
@Getter @Setter protected Integer chunkZ; @Getter @Setter protected Integer chunkZ = null;
public Integer calcChunkZ() public Integer calcChunkZ()
{ {
return calcChunk(this.locationZ, this.blockZ, this.chunkZ); return calcChunk(this.locationZ, this.blockZ, this.chunkZ);
@ -158,8 +155,8 @@ public class PS implements Cloneable
// Field: pitch // Field: pitch
@SerializedName("p") @SerializedName("p")
@Getter protected Float pitch; @Getter protected Float pitch = null;
public PS setPitch(Float val) public void setPitch(Float val)
{ {
if (val == null) if (val == null)
{ {
@ -169,18 +166,17 @@ public class PS implements Cloneable
{ {
this.pitch = (val + 360F) % 360F; this.pitch = (val + 360F) % 360F;
} }
return this;
} }
// Field: yaw // Field: yaw
@SerializedName("y") @SerializedName("y")
@Getter @Setter protected Float yaw; @Getter @Setter protected Float yaw = null;
// --------------------- // ---------------------
// Field: velocityX // Field: velocityX
@SerializedName("vx") @SerializedName("vx")
@Getter @Setter protected Double velocityX; @Getter @Setter protected Double velocityX = null;
public Double calcVelocityX() public Double calcVelocityX()
{ {
return calcVelocity(this.locationX, this.blockX, this.chunkX, this.velocityX); return calcVelocity(this.locationX, this.blockX, this.chunkX, this.velocityX);
@ -188,7 +184,7 @@ public class PS implements Cloneable
// Field: velocityY // Field: velocityY
@SerializedName("vy") @SerializedName("vy")
@Getter @Setter protected Double velocityY; @Getter @Setter protected Double velocityY = null;
public Double calcVelocityY() public Double calcVelocityY()
{ {
return calcVelocity(this.locationY, this.blockY, 0, this.velocityY); return calcVelocity(this.locationY, this.blockY, 0, this.velocityY);
@ -196,7 +192,7 @@ public class PS implements Cloneable
// Field: velocityZ // Field: velocityZ
@SerializedName("vz") @SerializedName("vz")
@Getter @Setter protected Double velocityZ; @Getter @Setter protected Double velocityZ = null;
public Double calcVelocityZ() public Double calcVelocityZ()
{ {
return calcVelocity(this.locationZ, this.blockZ, this.chunkZ, this.velocityZ); return calcVelocity(this.locationZ, this.blockZ, this.chunkZ, this.velocityZ);
@ -212,7 +208,7 @@ public class PS implements Cloneable
} }
//----------------------------------------------// //----------------------------------------------//
// CONVERTERS // GET / CALC
//----------------------------------------------// //----------------------------------------------//
public synchronized Location getLocation() public synchronized Location getLocation()
@ -248,7 +244,7 @@ public class PS implements Cloneable
{ {
return this.innerBlock(this.calcBlockX(), this.calcBlockY(), this.calcBlockZ()); return this.innerBlock(this.calcBlockX(), this.calcBlockY(), this.calcBlockZ());
} }
public synchronized Block innerBlock(Integer x, Integer y, Integer z) protected synchronized Block innerBlock(Integer x, Integer y, Integer z)
{ {
World world = this.getWorld(); World world = this.getWorld();
if (world == null) return null; if (world == null) return null;
@ -268,7 +264,7 @@ public class PS implements Cloneable
{ {
return this.innerChunk(this.calcChunkX(), this.calcChunkZ()); return this.innerChunk(this.calcChunkX(), this.calcChunkZ());
} }
public synchronized Chunk innerChunk(Integer x, Integer z) protected synchronized Chunk innerChunk(Integer x, Integer z)
{ {
World world = this.getWorld(); World world = this.getWorld();
if (world == null) return null; if (world == null) return null;
@ -287,7 +283,7 @@ public class PS implements Cloneable
{ {
return this.innerVelocity(this.calcVelocityX(), this.calcVelocityY(), this.calcVelocityZ()); return this.innerVelocity(this.calcVelocityX(), this.calcVelocityY(), this.calcVelocityZ());
} }
public synchronized Vector innerVelocity(Double x, Double y, Double z) protected synchronized Vector innerVelocity(Double x, Double y, Double z)
{ {
if (x == null) return null; if (x == null) return null;
if (y == null) return null; if (y == null) return null;
@ -296,10 +292,10 @@ public class PS implements Cloneable
} }
//----------------------------------------------// //----------------------------------------------//
// READERS // SET
//----------------------------------------------// //----------------------------------------------//
public synchronized PS readDefault() public synchronized void setDefault()
{ {
this.worldName = null; this.worldName = null;
@ -320,30 +316,63 @@ public class PS implements Cloneable
this.velocityX = null; this.velocityX = null;
this.velocityY = null; this.velocityY = null;
this.velocityZ = null; this.velocityZ = null;
return this;
} }
public synchronized PS readTransparent(PS ps) public synchronized void setPSTransparent(PS ps)
{ {
Accessor.get(PS.class).copy(ps, this, true); if (ps.worldName != null) this.worldName = ps.worldName;
return this;
if (ps.blockX != null) this.blockX = ps.blockX;
if (ps.blockY != null) this.blockY = ps.blockY;
if (ps.blockZ != null) this.blockZ = ps.blockZ;
if (ps.locationX != null) this.locationX = ps.locationX;
if (ps.locationY != null) this.locationY = ps.locationY;
if (ps.locationZ != null) this.locationZ = ps.locationZ;
if (ps.chunkX != null) this.chunkX = ps.chunkX;
if (ps.chunkZ != null) this.chunkZ = ps.chunkZ;
if (ps.pitch != null) this.pitch = ps.pitch;
if (ps.yaw != null) this.yaw = ps.yaw;
if (ps.velocityX != null) this.velocityX = ps.velocityX;
if (ps.velocityY != null) this.velocityY = ps.velocityY;
if (ps.velocityZ != null) this.velocityZ = ps.velocityZ;
} }
public synchronized PS read(PS ps) public synchronized void setPS(PS ps)
{ {
Accessor.get(PS.class).copy(ps, this); this.worldName = ps.worldName;
return this;
this.blockX = ps.blockX;
this.blockY = ps.blockY;
this.blockZ = ps.blockZ;
this.locationX = ps.locationX;
this.locationY = ps.locationY;
this.locationZ = ps.locationZ;
this.chunkX = ps.chunkX;
this.chunkZ = ps.chunkZ;
this.pitch = ps.pitch;
this.yaw = ps.yaw;
this.velocityX = ps.velocityX;
this.velocityY = ps.velocityY;
this.velocityZ = ps.velocityZ;
} }
// --------------------- // ---------------------
public synchronized PS read(Location location) public synchronized void setLocation(Location location)
{ {
return this.readDefault().readTransparent(location); this.setDefault();
this.setLocationTransparent(location);
} }
public synchronized PS readTransparent(Location location) public synchronized void setLocationTransparent(Location location)
{ {
this.worldName = location.getWorld().getName(); this.worldName = location.getWorld().getName();
this.locationX = location.getX(); this.locationX = location.getX();
@ -351,79 +380,77 @@ public class PS implements Cloneable
this.locationZ = location.getZ(); this.locationZ = location.getZ();
this.setPitch(location.getPitch()); this.setPitch(location.getPitch());
this.yaw = location.getYaw(); this.yaw = location.getYaw();
return this;
} }
// --------------------- // ---------------------
public synchronized PS read(Vector vector) public synchronized void setVelocity(Vector vector)
{ {
return this.readDefault().readTransparent(vector); this.setDefault();
this.setVelocityTransparent(vector);
} }
public synchronized PS readTransparent(Vector vector) public synchronized void setVelocityTransparent(Vector vector)
{ {
this.velocityX = vector.getX(); this.velocityX = vector.getX();
this.velocityY = vector.getY(); this.velocityY = vector.getY();
this.velocityZ = vector.getZ(); this.velocityZ = vector.getZ();
return this;
} }
// --------------------- // ---------------------
public synchronized PS read(Player player) public synchronized void setEntity(Entity entity)
{ {
return this.readDefault().readTransparent(player); this.setDefault();
this.setEntityTransparent(entity);
} }
public synchronized PS readTransparent(Player player) public synchronized void setEntityTransparent(Entity entity)
{ {
this.readTransparent(player.getLocation()); this.setLocationTransparent(entity.getLocation());
this.readTransparent(player.getVelocity()); this.setVelocityTransparent(entity.getVelocity());
return this;
} }
// --------------------- // ---------------------
public synchronized PS read(Block block) public synchronized void setBlock(Block block)
{ {
return this.readDefault().readTransparent(block); this.setDefault();
this.setBlockTransparent(block);
} }
public synchronized PS readTransparent(Block block) public synchronized void setBlockTransparent(Block block)
{ {
this.worldName = block.getWorld().getName(); this.worldName = block.getWorld().getName();
this.blockX = block.getX(); this.blockX = block.getX();
this.blockY = block.getY(); this.blockY = block.getY();
this.blockZ = block.getZ(); this.blockZ = block.getZ();
return this;
} }
// --------------------- // ---------------------
public synchronized PS read(Chunk chunk) public synchronized void setChunk(Chunk chunk)
{ {
return this.readDefault().readTransparent(chunk); this.setDefault();
this.setChunkTransparent(chunk);
} }
public synchronized PS readTransparent(Chunk chunk) public synchronized void setChunkTransparent(Chunk chunk)
{ {
this.worldName = chunk.getWorld().getName(); this.worldName = chunk.getWorld().getName();
this.chunkX = chunk.getX(); this.chunkX = chunk.getX();
this.chunkZ = chunk.getZ(); this.chunkZ = chunk.getZ();
return this;
} }
// --------------------- // ---------------------
// TODO: This should be removed later on when my converting phase is complete.
public synchronized PS read(String str) public synchronized void setOldString(String str)
{ {
return this.readDefault().readTransparent(str); this.setDefault();
this.setOldStringTransparent(str);
} }
public synchronized PS readTransparent(String str) public synchronized void setOldStringTransparent(String str)
{ {
String[] parts = str.split("\\|"); String[] parts = str.split("\\|");
@ -443,8 +470,6 @@ public class PS implements Cloneable
this.pitch = Float.parseFloat(parts[4]); this.pitch = Float.parseFloat(parts[4]);
this.yaw = Float.parseFloat(parts[5]); this.yaw = Float.parseFloat(parts[5]);
} }
return this;
} }
@ -468,32 +493,37 @@ public class PS implements Cloneable
public PS(PS ps) public PS(PS ps)
{ {
this.read(ps); this.setPS(ps);
} }
public PS(Location location) public PS(Location location)
{ {
this.read(location); this.setLocationTransparent(location);
} }
public PS(Vector vector) public PS(Vector velocity)
{ {
this.read(vector); this.setVelocityTransparent(velocity);
} }
public PS(Player player) public PS(Entity entity)
{ {
this.read(player); this.setEntityTransparent(entity);
} }
public PS(Block block) public PS(Block block)
{ {
this.read(block); this.setBlockTransparent(block);
} }
public PS(Chunk chunk) public PS(Chunk chunk)
{ {
this.read(chunk); this.setChunkTransparent(chunk);
}
public PS(String oldString)
{
this.setOldStringTransparent(oldString);
} }
//----------------------------------------------// //----------------------------------------------//

View File

@ -22,7 +22,7 @@ public class PSAdapter implements JsonDeserializer<PS>
{ {
if (json.isJsonPrimitive()) if (json.isJsonPrimitive())
{ {
return new PS().read(json.getAsString()); return new PS(json.getAsString());
} }
return new Gson().fromJson(json, typeOfT); return new Gson().fromJson(json, typeOfT);
} }

View File

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

View File

@ -30,7 +30,7 @@ public class ARAspect extends ARAbstractSelect<Aspect>
@Override @Override
public Collection<String> altNames(MCommand mcommand) public Collection<String> altNames(MCommand mcommand)
{ {
return AspectColl.i.ids(); return AspectColl.i.getIds();
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -30,7 +30,7 @@ public class ARMultiverse extends ARAbstractSelect<Multiverse>
@Override @Override
public Collection<String> altNames(MCommand mcommand) public Collection<String> altNames(MCommand mcommand)
{ {
return MultiverseColl.i.ids(); return MultiverseColl.i.getIds();
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

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

View File

@ -22,7 +22,7 @@ public class AHAspect extends AHBase<Aspect>
this.error.add("<b>No aspect called \"<p>"+str+"<b>\"."); this.error.add("<b>No aspect called \"<p>"+str+"<b>\".");
if (Permission.USYS_ASPECT_LIST.has(sender, false)) if (Permission.USYS_ASPECT_LIST.has(sender, false))
{ {
this.error.add("<i>Use "+Txt.implodeCommaAndDot(AspectColl.i.ids(), "<h>%s", "<i>, ", " <i>or ", "<i>.")); this.error.add("<i>Use "+Txt.implodeCommaAndDot(AspectColl.i.getIds(), "<h>%s", "<i>, ", " <i>or ", "<i>."));
} }
} }

View File

@ -23,7 +23,7 @@ public class AHMultiverse extends AHBase<Multiverse>
this.error.add("<b>No multiverse called \"<p>"+str+"<b>\"."); this.error.add("<b>No multiverse called \"<p>"+str+"<b>\".");
if (Permission.USYS_MULTIVERSE_LIST.has(sender, false)) if (Permission.USYS_MULTIVERSE_LIST.has(sender, false))
{ {
this.error.add("<i>Use "+Txt.implodeCommaAndDot(MultiverseColl.i.ids(), "<h>%s", "<i>, ", " <i>or ", "<i>.")); this.error.add("<i>Use "+Txt.implodeCommaAndDot(MultiverseColl.i.getIds(), "<h>%s", "<i>, ", " <i>or ", "<i>."));
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,7 @@
package com.massivecraft.mcore4.integration; package com.massivecraft.mcore4.integration;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -20,8 +22,7 @@ public class Integration implements Listener
protected MPlugin ourPlugin; protected MPlugin ourPlugin;
protected IntegrationFeatures features; protected IntegrationFeatures features;
protected boolean active = false; @Getter protected boolean active = false;
public boolean active() { return this.active; }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT

View File

@ -31,52 +31,52 @@ public class Coll<E, L> implements CollInterface<E, L>
// -------------------------------------------- // // -------------------------------------------- //
protected final String name; protected final String name;
@Override public String name() { return this.name; } @Override public String getName() { return this.name; }
protected final String basename; protected final String basename;
@Override public String basename() { return this.basename; } @Override public String getBasename() { return this.basename; }
protected final String universe; protected final String universe;
@Override public String universe() { return this.universe; } @Override public String getUniverse() { return this.universe; }
protected final Class<E> entityClass; protected final Class<E> entityClass;
@Override public Class<E> entityClass() { return this.entityClass; } @Override public Class<E> getEntityClass() { return this.entityClass; }
protected final Class<L> idClass; protected final Class<L> idClass;
@Override public Class<L> idClass() { return this.idClass; } @Override public Class<L> getIdClass() { return this.idClass; }
// -------------------------------------------- // // -------------------------------------------- //
// SUPPORTING SYSTEM // SUPPORTING SYSTEM
// -------------------------------------------- // // -------------------------------------------- //
protected MPlugin mplugin; protected MPlugin mplugin;
@Override public MPlugin mplugin() { return this.mplugin; } @Override public MPlugin getMplugin() { return this.mplugin; }
protected Db<?> db; protected Db<?> db;
@Override public Db<?> db() { return this.db; } @Override public Db<?> getDb() { return this.db; }
@Override public Driver<?> driver() { return this.db.driver(); } @Override public Driver<?> getDriver() { return this.db.getDriver(); }
protected IdStrategy<L, ?> idStrategy; protected IdStrategy<L, ?> idStrategy;
@Override public IdStrategy<L, ?> idStrategy() { return this.idStrategy; } @Override public IdStrategy<L, ?> getIdStrategy() { return this.idStrategy; }
protected StoreAdapter storeAdapter; protected StoreAdapter storeAdapter;
@Override public StoreAdapter storeAdapter() { return this.storeAdapter; } @Override public StoreAdapter getStoreAdapter() { return this.storeAdapter; }
protected Object collDriverObject; protected Object collDriverObject;
@Override public Object collDriverObject() { return this.collDriverObject; } @Override public Object getCollDriverObject() { return this.collDriverObject; }
// -------------------------------------------- // // -------------------------------------------- //
// STORAGE // STORAGE
// -------------------------------------------- // // -------------------------------------------- //
protected Set<L> ids = Collections.newSetFromMap(new ConcurrentHashMap<L, Boolean>()); protected Set<L> ids = Collections.newSetFromMap(new ConcurrentHashMap<L, Boolean>());
@Override public Collection<L> ids() { return Collections.unmodifiableCollection(this.ids); } @Override public Collection<L> getIds() { return Collections.unmodifiableCollection(this.ids); }
@Override public Collection<L> idsRemote() { return this.db().driver().ids(this); } @Override public Collection<L> getIdsRemote() { return this.getDb().getDriver().getIds(this); }
@Override public boolean containsEntity(E entity) { return this.entities.contains(entity); }; @Override public boolean containsEntity(E entity) { return this.entities.contains(entity); };
@Override @Override
public boolean containsId(Object oid) public boolean containsId(Object oid)
{ {
L id = this.idFix(oid); L id = this.fixId(oid);
if (id == null) return false; if (id == null) return false;
return this.ids.contains(id); return this.ids.contains(id);
} }
@ -90,11 +90,11 @@ public class Coll<E, L> implements CollInterface<E, L>
@Override public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit, Integer offset) { return MStoreUtil.uglySQL(this.getAll(), where, orderby, limit, offset); } @Override public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit, Integer offset) { return MStoreUtil.uglySQL(this.getAll(), where, orderby, limit, offset); }
protected Map<L, E> id2entity = new ConcurrentHashMap<L, E>(); protected Map<L, E> id2entity = new ConcurrentHashMap<L, E>();
@Override public Map<L, E> id2entity() { return Collections.unmodifiableMap(this.id2entity); } @Override public Map<L, E> getId2entity() { return Collections.unmodifiableMap(this.id2entity); }
@Override @Override
public E get(Object oid) public E get(Object oid)
{ {
return this.get(oid, this.creative()); return this.get(oid, this.isCreative());
} }
@Override @Override
public E get(Object oid, boolean creative) public E get(Object oid, boolean creative)
@ -103,7 +103,7 @@ public class Coll<E, L> implements CollInterface<E, L>
} }
protected E get(Object oid, boolean creative, boolean noteChange) protected E get(Object oid, boolean creative, boolean noteChange)
{ {
L id = this.idFix(oid); L id = this.fixId(oid);
if (id == null) return null; if (id == null) return null;
E ret = this.id2entity.get(id); E ret = this.id2entity.get(id);
if (ret != null) return ret; if (ret != null) return ret;
@ -113,11 +113,11 @@ public class Coll<E, L> implements CollInterface<E, L>
// Get the id for this entity. // Get the id for this entity.
protected Map<E, L> entity2id = new ConcurrentHashMap<E, L>(); protected Map<E, L> entity2id = new ConcurrentHashMap<E, L>();
@Override public Map<E, L> entity2id() { return Collections.unmodifiableMap(this.entity2id); } @Override public Map<E, L> getEntity2id() { return Collections.unmodifiableMap(this.entity2id); }
@Override public L id(E entity) { return this.entity2id.get(entity); } @Override public L getId(E entity) { return this.entity2id.get(entity); }
@Override @Override
public L idFix(Object oid) public L fixId(Object oid)
{ {
if (oid == null) return null; if (oid == null) return null;
if (oid.getClass() == this.idClass) return this.idClass.cast(oid); if (oid.getClass() == this.idClass) return this.idClass.cast(oid);
@ -130,8 +130,8 @@ public class Coll<E, L> implements CollInterface<E, L>
// -------------------------------------------- // // -------------------------------------------- //
protected boolean creative; protected boolean creative;
@Override public boolean creative() { return this.creative; } @Override public boolean isCreative() { return this.creative; }
@Override public void creative(boolean val) { this.creative = val; } @Override public void setCreative(boolean val) { this.creative = val; }
// Should that instance be saved or not? // Should that instance be saved or not?
// If it is default it should not be saved. // If it is default it should not be saved.
@ -152,7 +152,7 @@ public class Coll<E, L> implements CollInterface<E, L>
} }
else else
{ {
Accessor.get(this.entityClass()).copy(ofrom, oto); Accessor.get(this.getEntityClass()).copy(ofrom, oto);
} }
} }
@ -213,17 +213,17 @@ public class Coll<E, L> implements CollInterface<E, L>
{ {
// Check entity // Check entity
if (entity == null) return null; if (entity == null) return null;
L id = this.id(entity); L id = this.getId(entity);
if (id != null) return id; if (id != null) return id;
// Check/Fix id // Check/Fix id
if (oid == null) if (oid == null)
{ {
id = this.idStrategy().generate(this); id = this.getIdStrategy().generate(this);
} }
else else
{ {
id = this.idFix(oid); id = this.fixId(oid);
if (id == null) return null; if (id == null) return null;
if (this.ids.contains(id)) return null; if (this.ids.contains(id)) return null;
} }
@ -266,7 +266,7 @@ public class Coll<E, L> implements CollInterface<E, L>
} }
else else
{ {
id = this.idFix(o); id = this.fixId(o);
} }
if (id == null) if (id == null)
{ {
@ -339,7 +339,7 @@ public class Coll<E, L> implements CollInterface<E, L>
this.clearIdentifiedChanges(id); this.clearIdentifiedChanges(id);
this.clearSynclog(id); this.clearSynclog(id);
this.db().driver().delete(this, id); this.getDb().getDriver().delete(this, id);
} }
@Override @Override
@ -351,17 +351,17 @@ public class Coll<E, L> implements CollInterface<E, L>
E entity = this.id2entity.get(id); E entity = this.id2entity.get(id);
if (entity == null) return; if (entity == null) return;
Object raw = this.storeAdapter().read(this, entity); Object raw = this.getStoreAdapter().read(this, entity);
this.lastRaw.put(id, raw); this.lastRaw.put(id, raw);
if (this.isDefault(entity)) if (this.isDefault(entity))
{ {
this.db.driver().delete(this, id); this.db.getDriver().delete(this, id);
this.lastDefault.add(id); this.lastDefault.add(id);
} }
else else
{ {
Long mtime = this.db.driver().save(this, id, raw); Long mtime = this.db.getDriver().save(this, id, raw);
if (mtime == null) return; // This fail should not happen often. We could handle it better though. if (mtime == null) return; // This fail should not happen often. We could handle it better though.
this.lastMtime.put(id, mtime); this.lastMtime.put(id, mtime);
} }
@ -372,7 +372,7 @@ public class Coll<E, L> implements CollInterface<E, L>
{ {
this.clearIdentifiedChanges(id); this.clearIdentifiedChanges(id);
Entry<?, Long> entry = this.db().driver().load(this, id); Entry<?, Long> entry = this.getDb().getDriver().load(this, id);
if (entry == null) return; if (entry == null) return;
Object raw = entry.getKey(); Object raw = entry.getKey();
@ -383,10 +383,10 @@ public class Coll<E, L> implements CollInterface<E, L>
E entity = this.get(id, true, false); E entity = this.get(id, true, false);
this.storeAdapter().write(this, raw, entity); this.getStoreAdapter().write(this, raw, entity);
// Store adapter again since result of a database read may be "different" from entity read. // Store adapter again since result of a database read may be "different" from entity read.
this.lastRaw.put(id, this.storeAdapter().read(this, entity)); this.lastRaw.put(id, this.getStoreAdapter().read(this, entity));
this.lastMtime.put(id, mtime); this.lastMtime.put(id, mtime);
this.lastDefault.remove(id); this.lastDefault.remove(id);
} }
@ -415,7 +415,7 @@ public class Coll<E, L> implements CollInterface<E, L>
E localEntity = this.id2entity.get(id); E localEntity = this.id2entity.get(id);
if ( ! remoteMtimeSupplied) if ( ! remoteMtimeSupplied)
{ {
remoteMtime = this.driver().mtime(this, id); remoteMtime = this.getDriver().getMtime(this, id);
} }
boolean existsLocal = (localEntity != null); boolean existsLocal = (localEntity != null);
@ -500,7 +500,7 @@ public class Coll<E, L> implements CollInterface<E, L>
{ {
// Find all ids // Find all ids
Set<L> allids = new HashSet<L>(this.ids); Set<L> allids = new HashSet<L>(this.ids);
allids.addAll(this.driver().ids(this)); allids.addAll(this.getDriver().getIds(this));
for (L id : allids) for (L id : allids)
{ {
this.syncId(id); this.syncId(id);
@ -511,7 +511,7 @@ public class Coll<E, L> implements CollInterface<E, L>
public void findSuspects() public void findSuspects()
{ {
// Get remote id and mtime snapshot // Get remote id and mtime snapshot
Map<L, Long> id2RemoteMtime = this.db().driver().id2mtime(this); Map<L, Long> id2RemoteMtime = this.getDb().getDriver().getId2mtime(this);
// Compile a list of all ids (both remote and local) // Compile a list of all ids (both remote and local)
Set<L> allids = new HashSet<L>(); Set<L> allids = new HashSet<L>();
@ -524,7 +524,7 @@ public class Coll<E, L> implements CollInterface<E, L>
Long remoteMtime = id2RemoteMtime.get(id); Long remoteMtime = id2RemoteMtime.get(id);
ModificationState state = this.examineId(id, remoteMtime); ModificationState state = this.examineId(id, remoteMtime);
//mplugin.log("findSuspects: It seems", id, "has state", state); //mplugin.log("findSuspects: It seems", id, "has state", state);
if (state.modified()) if (state.isModified())
{ {
//System.out.println("It seems "+id+" has state "+state); //System.out.println("It seems "+id+" has state "+state);
this.changedIds.add(id); this.changedIds.add(id);
@ -537,7 +537,7 @@ public class Coll<E, L> implements CollInterface<E, L>
// -------------------------------------------- // // -------------------------------------------- //
protected Runnable tickTask; protected Runnable tickTask;
@Override public Runnable tickTask() { return this.tickTask; } @Override public Runnable getTickTask() { return this.tickTask; }
@Override @Override
public void onTick() public void onTick()
{ {
@ -572,15 +572,15 @@ public class Coll<E, L> implements CollInterface<E, L>
this.mplugin = mplugin; this.mplugin = mplugin;
this.db = db; this.db = db;
this.storeAdapter = this.db.driver().getStoreAdapter(); this.storeAdapter = this.db.getDriver().getStoreAdapter();
this.idStrategy = this.db.driver().getIdStrategy(idStrategyName); this.idStrategy = this.db.getDriver().getIdStrategy(idStrategyName);
if (this.idStrategy == null) if (this.idStrategy == null)
{ {
throw new IllegalArgumentException("UNKNOWN: The id stragegy \""+idStrategyName+"\" is unknown to the driver \""+db.driver().name()+"\"."); throw new IllegalArgumentException("UNKNOWN: The id stragegy \""+idStrategyName+"\" is unknown to the driver \""+db.getDriver().getName()+"\".");
} }
else if (this.idStrategy.getLocalClass() != idClass) else if (this.idStrategy.getLocalClass() != idClass)
{ {
throw new IllegalArgumentException("MISSMATCH: The id stragegy \""+idStrategyName+"\" for the driver \""+db.driver().name()+"\" uses \""+this.idStrategy.getLocalClass().getSimpleName()+"\" but the collection "+this.name+"/"+this.getClass().getSimpleName()+" uses \""+idClass.getSimpleName()+"\"."); throw new IllegalArgumentException("MISSMATCH: The id stragegy \""+idStrategyName+"\" for the driver \""+db.getDriver().getName()+"\" uses \""+this.idStrategy.getLocalClass().getSimpleName()+"\" but the collection "+this.name+"/"+this.getClass().getSimpleName()+" uses \""+idClass.getSimpleName()+"\".");
} }
this.collDriverObject = db.getCollDriverObject(this); this.collDriverObject = db.getCollDriverObject(this);

View File

@ -14,28 +14,28 @@ public interface CollInterface<E, L>
// -------------------------------------------- // // -------------------------------------------- //
// WHAT DO WE HANDLE? // WHAT DO WE HANDLE?
// -------------------------------------------- // // -------------------------------------------- //
public String name(); public String getName();
public String basename(); public String getBasename();
public String universe(); public String getUniverse();
public Class<E> entityClass(); public Class<E> getEntityClass();
public Class<L> idClass(); public Class<L> getIdClass();
// -------------------------------------------- // // -------------------------------------------- //
// SUPPORTING SYSTEM // SUPPORTING SYSTEM
// -------------------------------------------- // // -------------------------------------------- //
public MPlugin mplugin(); public MPlugin getMplugin();
public Db<?> db(); public Db<?> getDb();
public Driver<?> driver(); public Driver<?> getDriver();
public StoreAdapter storeAdapter(); public StoreAdapter getStoreAdapter();
public IdStrategy<L, ?> idStrategy(); public IdStrategy<L, ?> getIdStrategy();
public Object collDriverObject(); public Object getCollDriverObject();
// -------------------------------------------- // // -------------------------------------------- //
// STORAGE // STORAGE
// -------------------------------------------- // // -------------------------------------------- //
public Collection<L> ids(); public Collection<L> getIds();
public Collection<L> idsRemote(); public Collection<L> getIdsRemote();
public boolean containsId(Object oid); public boolean containsId(Object oid);
public boolean containsEntity(E entity); public boolean containsEntity(E entity);
@ -45,19 +45,19 @@ public interface CollInterface<E, L>
public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit); public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit);
public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit, Integer offset); public Collection<E> getAll(Predictate<E> where, Comparator<E> orderby, Integer limit, Integer offset);
public Map<L, E> id2entity(); public Map<L, E> getId2entity();
public E get(Object oid); public E get(Object oid);
public E get(Object oid, boolean creative); public E get(Object oid, boolean creative);
public Map<E, L> entity2id(); public Map<E, L> getEntity2id();
public L id(E entity); public L getId(E entity);
public L idFix(Object oid); public L fixId(Object oid);
// -------------------------------------------- // // -------------------------------------------- //
// BAHAVIOR // BAHAVIOR
// -------------------------------------------- // // -------------------------------------------- //
public boolean creative(); public boolean isCreative();
public void creative(boolean val); public void setCreative(boolean val);
// A default entity will not be saved. // A default entity will not be saved.
// This is often used together with creative collections to save disc space. // This is often used together with creative collections to save disc space.
@ -133,7 +133,7 @@ public interface CollInterface<E, L>
// -------------------------------------------- // // -------------------------------------------- //
// The tickTask simply runs the onTick method. // The tickTask simply runs the onTick method.
public Runnable tickTask(); public Runnable getTickTask();
public void onTick(); public void onTick();
public Thread examineThread(); public Thread examineThread();

View File

@ -13,8 +13,8 @@ public abstract class Colls<C extends Coll<E, L>, E, L>
{ {
protected Map<String, C> name2coll = new HashMap<String, C>(); protected Map<String, C> name2coll = new HashMap<String, C>();
public abstract Aspect aspect(); public abstract Aspect getAspect();
public abstract String basename(); public abstract String getBasename();
public abstract C createColl(String name); public abstract C createColl(String name);
// -------------------------------------------- // // -------------------------------------------- //
@ -29,7 +29,7 @@ public abstract class Colls<C extends Coll<E, L>, E, L>
public List<C> getColls() public List<C> getColls()
{ {
List<C> ret = new ArrayList<C>(); List<C> ret = new ArrayList<C>();
Aspect a = this.aspect(); Aspect a = this.getAspect();
Multiverse m = a.multiverse(); Multiverse m = a.multiverse();
for (String universe : m.getUniverses()) for (String universe : m.getUniverses())
{ {
@ -44,14 +44,14 @@ public abstract class Colls<C extends Coll<E, L>, E, L>
public String collnameForUniverse(String universe) public String collnameForUniverse(String universe)
{ {
return this.basename() + "@" + universe; return this.getBasename() + "@" + universe;
} }
public String universeFromWorldName(String worldName) public String universeFromWorldName(String worldName)
{ {
if (worldName == null) throw new IllegalArgumentException("worldName may not be null."); if (worldName == null) throw new IllegalArgumentException("worldName may not be null.");
return this.aspect().multiverse().getUniverseForWorldName(worldName); return this.getAspect().multiverse().getUniverseForWorldName(worldName);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -4,13 +4,13 @@ import java.util.Set;
public interface Db<R> public interface Db<R>
{ {
public String name(); public String getName();
public boolean drop(); public boolean drop();
public Set<String> collnames(); public Set<String> getCollnames();
public Driver<R> driver(); public Driver<R> getDriver();
public Object getCollDriverObject(Coll<?, ?> coll); public Object getCollDriverObject(Coll<?, ?> coll);
} }

View File

@ -5,8 +5,8 @@ import java.util.Set;
public abstract class DbAbstract<R> implements Db<R> public abstract class DbAbstract<R> implements Db<R>
{ {
@Override @Override
public Set<String> collnames() public Set<String> getCollnames()
{ {
return this.driver().collnames(this); return this.getDriver().getCollnames(this);
} }
} }

View File

@ -14,7 +14,7 @@ public class DbGson extends DbAbstract<JsonElement>
public File dir; public File dir;
protected DriverGson driver; protected DriverGson driver;
@Override public DriverGson driver() { return driver; } @Override public DriverGson getDriver() { return driver; }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCTORS // CONSTRUCTORS
@ -31,7 +31,7 @@ public class DbGson extends DbAbstract<JsonElement>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public String name() public String getName()
{ {
return dir.getAbsolutePath(); return dir.getAbsolutePath();
} }
@ -52,6 +52,6 @@ public class DbGson extends DbAbstract<JsonElement>
@Override @Override
public Object getCollDriverObject(Coll<?, ?> coll) public Object getCollDriverObject(Coll<?, ?> coll)
{ {
return new File(dir, coll.name()); return new File(dir, coll.getName());
} }
} }

View File

@ -12,7 +12,7 @@ public class DbMongo extends DbAbstract<BasicDBObject>
public DB db; public DB db;
protected DriverMongo driver; protected DriverMongo driver;
@Override public DriverMongo driver() { return driver; } @Override public DriverMongo getDriver() { return driver; }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCTORS // CONSTRUCTORS
@ -29,7 +29,7 @@ public class DbMongo extends DbAbstract<BasicDBObject>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public String name() public String getName()
{ {
return db.getName(); return db.getName();
} }
@ -51,6 +51,6 @@ public class DbMongo extends DbAbstract<BasicDBObject>
@Override @Override
public Object getCollDriverObject(Coll<?, ?> coll) public Object getCollDriverObject(Coll<?, ?> coll)
{ {
return db.getCollection(coll.name()); return db.getCollection(coll.getName());
} }
} }

View File

@ -11,7 +11,7 @@ import com.massivecraft.mcore4.store.storeadapter.StoreAdapter;
public interface Driver<R> public interface Driver<R>
{ {
// Returns the name of the driver. // Returns the name of the driver.
public String name(); public String getName();
// This is the rawdata format this driver works with. // This is the rawdata format this driver works with.
// Could for example be JsonElement or DBObject // Could for example be JsonElement or DBObject
@ -25,22 +25,22 @@ public interface Driver<R>
public StoreAdapter getStoreAdapter(); public StoreAdapter getStoreAdapter();
// Get a database instance from the driver // Get a database instance from the driver
public Db<R> db(String uri); public Db<R> getDb(String uri);
// What collections are in the database? // What collections are in the database?
public Set<String> collnames(Db<?> db); public Set<String> getCollnames(Db<?> db);
// Is id X in the collection? // Is id X in the collection?
public <L> boolean containsId(Coll<?, L> coll, L id); public <L> boolean containsId(Coll<?, L> coll, L id);
// When was X last altered? // When was X last altered?
public <L> Long mtime(Coll<?, L> coll, L id); public <L> Long getMtime(Coll<?, L> coll, L id);
// What ids are in the collection? // What ids are in the collection?
public <L> Collection<L> ids(Coll<?, L> coll); public <L> Collection<L> getIds(Coll<?, L> coll);
// Return a map of all ids with their corresponding mtimes // Return a map of all ids with their corresponding mtimes
public <L> Map<L, Long> id2mtime(Coll<?, L> coll); public <L> Map<L, Long> getId2mtime(Coll<?, L> coll);
// Load the raw data for X. The second part of the entry is the remote mtime at the load. // Load the raw data for X. The second part of the entry is the remote mtime at the load.
public <L> Entry<R, Long> load(Coll<?, L> coll, L id); public <L> Entry<R, Long> load(Coll<?, L> coll, L id);

View File

@ -13,7 +13,7 @@ public abstract class DriverAbstract<R> implements Driver<R>
} }
protected String name; protected String name;
@Override public String name() { return this.name; } @Override public String getName() { return this.name; }
protected Map<String, IdStrategy<?, ?>> idStrategies = new HashMap<String, IdStrategy<?, ?>>(); protected Map<String, IdStrategy<?, ?>> idStrategies = new HashMap<String, IdStrategy<?, ?>>();
@Override @Override

View File

@ -37,7 +37,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
} }
@Override @Override
public Db<JsonElement> db(String uri) public Db<JsonElement> getDb(String uri)
{ {
// "gson://" is 7 chars // "gson://" is 7 chars
File folder = new File(uri.substring(7)); File folder = new File(uri.substring(7));
@ -46,7 +46,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
} }
@Override @Override
public Set<String> collnames(Db<?> db) public Set<String> getCollnames(Db<?> db)
{ {
Set<String> ret = new LinkedHashSet<String>(); Set<String> ret = new LinkedHashSet<String>();
@ -66,7 +66,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
} }
@Override @Override
public <L> Long mtime(Coll<?, L> coll, L id) public <L> Long getMtime(Coll<?, L> coll, L id)
{ {
File file = fileFromId(coll, id); File file = fileFromId(coll, id);
if ( ! file.isFile()) return null; if ( ! file.isFile()) return null;
@ -74,7 +74,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
} }
@Override @Override
public <L> Collection<L> ids(Coll<?, L> coll) public <L> Collection<L> getIds(Coll<?, L> coll)
{ {
List<L> ret = new ArrayList<L>(); List<L> ret = new ArrayList<L>();
@ -85,7 +85,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
{ {
// Then convert them to what they should be // Then convert them to what they should be
String remoteId = idFromFile(file); String remoteId = idFromFile(file);
L localId = coll.idStrategy().remoteToLocal(remoteId); L localId = coll.getIdStrategy().remoteToLocal(remoteId);
ret.add(localId); ret.add(localId);
} }
@ -93,7 +93,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
} }
@Override @Override
public <L> Map<L, Long> id2mtime(Coll<?, L> coll) public <L> Map<L, Long> getId2mtime(Coll<?, L> coll)
{ {
Map<L, Long> ret = new HashMap<L, Long>(); Map<L, Long> ret = new HashMap<L, Long>();
@ -104,7 +104,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
{ {
// Then convert them to what they should be // Then convert them to what they should be
String remoteId = idFromFile(file); String remoteId = idFromFile(file);
L localId = coll.idStrategy().remoteToLocal(remoteId); L localId = coll.getIdStrategy().remoteToLocal(remoteId);
ret.put(localId, file.lastModified()); ret.put(localId, file.lastModified());
} }
@ -128,7 +128,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
public <L> Long save(Coll<?, L> coll, L id, Object rawData) public <L> Long save(Coll<?, L> coll, L id, Object rawData)
{ {
File file = fileFromId(coll, id); File file = fileFromId(coll, id);
String content = coll.mplugin().gson.toJson((JsonElement)rawData); String content = coll.getMplugin().gson.toJson((JsonElement)rawData);
if (DiscUtil.writeCatch(file, content) == false) return null; if (DiscUtil.writeCatch(file, content) == false) return null;
return file.lastModified(); return file.lastModified();
} }
@ -146,7 +146,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
protected static File getCollDir(Coll<?, ?> coll) protected static File getCollDir(Coll<?, ?> coll)
{ {
return (File) coll.collDriverObject(); return (File) coll.getCollDriverObject();
} }
protected static String idFromFile(File file) protected static String idFromFile(File file)
@ -159,7 +159,7 @@ public class DriverGson extends DriverAbstract<JsonElement>
protected static <L> File fileFromId(Coll<?, L> coll, L id) protected static <L> File fileFromId(Coll<?, L> coll, L id)
{ {
File collDir = getCollDir(coll); File collDir = getCollDir(coll);
String idString = (String)coll.idStrategy().localToRemote(id); String idString = (String)coll.getIdStrategy().localToRemote(id);
File idFile = new File(collDir, idString+DOTJSON); File idFile = new File(collDir, idString+DOTJSON);
return idFile; return idFile;
} }

View File

@ -47,14 +47,14 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
} }
@Override @Override
public Db<BasicDBObject> db(String uri) public Db<BasicDBObject> getDb(String uri)
{ {
DB db = this.getDbInner(uri); DB db = this.getDbInner(uri);
return new DbMongo(this, db); return new DbMongo(this, db);
} }
@Override @Override
public Set<String> collnames(Db<?> db) public Set<String> getCollnames(Db<?> db)
{ {
return ((DbMongo)db).db.getCollectionNames(); return ((DbMongo)db).db.getCollectionNames();
} }
@ -63,22 +63,22 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
public <L> boolean containsId(Coll<?, L> coll, L id) public <L> boolean containsId(Coll<?, L> coll, L id)
{ {
DBCollection dbcoll = fixColl(coll); DBCollection dbcoll = fixColl(coll);
DBCursor cursor = dbcoll.find(new BasicDBObject(ID_FIELD, coll.idStrategy().localToRemote(id))); DBCursor cursor = dbcoll.find(new BasicDBObject(ID_FIELD, coll.getIdStrategy().localToRemote(id)));
return cursor.count() != 0; return cursor.count() != 0;
} }
@Override @Override
public <L> Long mtime(Coll<?, L> coll, L id) public <L> Long getMtime(Coll<?, L> coll, L id)
{ {
DBCollection dbcoll = fixColl(coll); DBCollection dbcoll = fixColl(coll);
BasicDBObject found = (BasicDBObject)dbcoll.findOne(new BasicDBObject(ID_FIELD, coll.idStrategy().localToRemote(id)), dboKeysMtime); BasicDBObject found = (BasicDBObject)dbcoll.findOne(new BasicDBObject(ID_FIELD, coll.getIdStrategy().localToRemote(id)), dboKeysMtime);
if (found == null) return null; if (found == null) return null;
if ( ! found.containsField(MTIME_FIELD)) return null; // This should not happen! But better to ignore than crash? if ( ! found.containsField(MTIME_FIELD)) return null; // This should not happen! But better to ignore than crash?
return found.getLong(MTIME_FIELD); return found.getLong(MTIME_FIELD);
} }
@Override @Override
public <L> Collection<L> ids(Coll<?, L> coll) public <L> Collection<L> getIds(Coll<?, L> coll)
{ {
List<L> ret = null; List<L> ret = null;
@ -91,7 +91,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
while(cursor.hasNext()) while(cursor.hasNext())
{ {
Object remoteId = cursor.next().get(ID_FIELD); Object remoteId = cursor.next().get(ID_FIELD);
L localId = coll.idStrategy().remoteToLocal(remoteId); L localId = coll.getIdStrategy().remoteToLocal(remoteId);
ret.add(localId); ret.add(localId);
} }
} }
@ -104,7 +104,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
} }
@Override @Override
public <L> Map<L, Long> id2mtime(Coll<?, L> coll) public <L> Map<L, Long> getId2mtime(Coll<?, L> coll)
{ {
Map<L, Long> ret = null; Map<L, Long> ret = null;
@ -118,7 +118,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
{ {
BasicDBObject raw = (BasicDBObject)cursor.next(); BasicDBObject raw = (BasicDBObject)cursor.next();
Object remoteId = raw.get(ID_FIELD); Object remoteId = raw.get(ID_FIELD);
L localId = coll.idStrategy().remoteToLocal(remoteId); L localId = coll.getIdStrategy().remoteToLocal(remoteId);
if ( ! raw.containsField(MTIME_FIELD)) continue; // This should not happen! But better to ignore than crash? if ( ! raw.containsField(MTIME_FIELD)) continue; // This should not happen! But better to ignore than crash?
Long mtime = raw.getLong(MTIME_FIELD); Long mtime = raw.getLong(MTIME_FIELD);
ret.put(localId, mtime); ret.put(localId, mtime);
@ -136,7 +136,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
public <L> Entry<BasicDBObject, Long> load(Coll<?, L> coll, L id) public <L> Entry<BasicDBObject, Long> load(Coll<?, L> coll, L id)
{ {
DBCollection dbcoll = fixColl(coll); DBCollection dbcoll = fixColl(coll);
BasicDBObject raw = (BasicDBObject)dbcoll.findOne(new BasicDBObject(ID_FIELD, coll.idStrategy().localToRemote(id))); BasicDBObject raw = (BasicDBObject)dbcoll.findOne(new BasicDBObject(ID_FIELD, coll.getIdStrategy().localToRemote(id)));
if (raw == null) return null; if (raw == null) return null;
Long mtime = (Long) raw.removeField(MTIME_FIELD); Long mtime = (Long) raw.removeField(MTIME_FIELD);
return new SimpleEntry<BasicDBObject, Long>(raw, mtime); return new SimpleEntry<BasicDBObject, Long>(raw, mtime);
@ -153,7 +153,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
Long mtime = System.currentTimeMillis(); Long mtime = System.currentTimeMillis();
data.put(MTIME_FIELD, mtime); data.put(MTIME_FIELD, mtime);
Object remoteId = coll.idStrategy().localToRemote(id); Object remoteId = coll.getIdStrategy().localToRemote(id);
dbcoll.update(new BasicDBObject(ID_FIELD, remoteId), data, true, false); dbcoll.update(new BasicDBObject(ID_FIELD, remoteId), data, true, false);
return mtime; return mtime;
@ -162,7 +162,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
@Override @Override
public <L> void delete(Coll<?, L> coll, L id) public <L> void delete(Coll<?, L> coll, L id)
{ {
fixColl(coll).remove(new BasicDBObject(ID_FIELD, coll.idStrategy().localToRemote(id))); fixColl(coll).remove(new BasicDBObject(ID_FIELD, coll.getIdStrategy().localToRemote(id)));
} }
//----------------------------------------------// //----------------------------------------------//
@ -171,7 +171,7 @@ public class DriverMongo extends DriverAbstract<BasicDBObject>
protected static DBCollection fixColl(Coll<?, ?> coll) protected static DBCollection fixColl(Coll<?, ?> coll)
{ {
return (DBCollection) coll.collDriverObject(); return (DBCollection) coll.getCollDriverObject();
} }
protected DB getDbInner(String uri) protected DB getDbInner(String uri)

View File

@ -28,7 +28,7 @@ public abstract class Entity<E extends Entity<E, L>, L>
Coll<E, L> coll = this.getColl(); Coll<E, L> coll = this.getColl();
if (coll == null) return null; if (coll == null) return null;
return coll.universe(); return coll.getUniverse();
} }
public L attach(Coll<E, L> coll) public L attach(Coll<E, L> coll)
@ -61,7 +61,7 @@ public abstract class Entity<E extends Entity<E, L>, L>
{ {
Coll<E, L> coll = this.getColl(); Coll<E, L> coll = this.getColl();
if (coll == null) return null; if (coll == null) return null;
return coll.id(this.getThis()); return coll.getId(this.getThis());
} }
public void changed() public void changed()
@ -100,7 +100,7 @@ public abstract class Entity<E extends Entity<E, L>, L>
{ {
Gson gson = MCore.gson; Gson gson = MCore.gson;
Coll<E, L> coll = this.getColl(); Coll<E, L> coll = this.getColl();
if (coll != null) gson = coll.mplugin().gson; if (coll != null) gson = coll.getMplugin().gson;
return this.getClazz().getSimpleName()+gson.toJson(this, this.getClazz()); return this.getClazz().getSimpleName()+gson.toJson(this, this.getClazz());
} }

View File

@ -7,7 +7,7 @@ public class ExamineThread<E, L> extends Thread
public ExamineThread(Coll<E, L> coll) public ExamineThread(Coll<E, L> coll)
{ {
this.coll = coll; this.coll = coll;
this.setName("ExamineThread for "+coll.name()); this.setName("ExamineThread for "+coll.getName());
} }
// TODO: Implement logging and/or auto adjusting system for how long the sleep should be? // TODO: Implement logging and/or auto adjusting system for how long the sleep should be?

View File

@ -13,8 +13,8 @@ public class MStore
protected static Map<String, Driver<?>> drivers = new HashMap<String, Driver<?>>(); protected static Map<String, Driver<?>> drivers = new HashMap<String, Driver<?>>();
public static boolean registerDriver(Driver<?> driver) public static boolean registerDriver(Driver<?> driver)
{ {
if (drivers.containsKey(driver.name())) return false; if (drivers.containsKey(driver.getName())) return false;
drivers.put(driver.name(), driver); drivers.put(driver.getName(), driver);
return true; return true;
} }
public static Driver<?> getDriver(String id) public static Driver<?> getDriver(String id)
@ -42,7 +42,7 @@ public class MStore
String scheme = uri.getScheme(); String scheme = uri.getScheme();
Driver<?> driver = getDriver(scheme); Driver<?> driver = getDriver(scheme);
if (driver == null) return null; if (driver == null) return null;
return driver.db(uri.toString()); return driver.getDb(uri.toString());
} }
static static

View File

@ -13,11 +13,11 @@ public enum ModificationState
; ;
private final boolean modified; private final boolean modified;
public boolean modified() { return this.modified; } public boolean isModified() { return this.modified; }
private final boolean local; private final boolean local;
public boolean local() { return this.local; } public boolean isLocal() { return this.local; }
public boolean remote() { return this.local == false; } public boolean isRemote() { return this.local == false; }
private ModificationState(boolean modified, boolean local) private ModificationState(boolean modified, boolean local)
{ {

View File

@ -67,7 +67,7 @@ public class PlayerColl<E extends PlayerEntity<E>> extends Coll<E, String>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public String idFix(Object oid) public String fixId(Object oid)
{ {
if (oid == null) return null; if (oid == null) return null;
String ret = MUtil.extract(String.class, "playerName", oid); String ret = MUtil.extract(String.class, "playerName", oid);
@ -105,8 +105,8 @@ public class PlayerColl<E extends PlayerEntity<E>> extends Coll<E, String>
protected Collection<Collection<String>> forgeAltColls() protected Collection<Collection<String>> forgeAltColls()
{ {
Collection<Collection<String>> ret = new ArrayList<Collection<String>>(); Collection<Collection<String>> ret = new ArrayList<Collection<String>>();
ret.add(this.ids()); ret.add(this.getIds());
if (this.creative()) ret.add(PlayerUtil.getAllVisitorNames()); if (this.isCreative()) ret.add(PlayerUtil.getAllVisitorNames());
return ret; return ret;
} }

View File

@ -5,7 +5,7 @@ import java.util.Collection;
public abstract class EntityAccessorAbstract implements EntityAccessor public abstract class EntityAccessorAbstract implements EntityAccessor
{ {
protected final Class<?> clazz; protected final Class<?> clazz;
public Class<?> clazz() { return this.clazz; } public Class<?> getClazz() { return this.clazz; }
public EntityAccessorAbstract(Class<?> clazz) public EntityAccessorAbstract(Class<?> clazz)
{ {

View File

@ -7,8 +7,8 @@ import java.util.Map;
public class EntityAccessorPerProperty extends EntityAccessorAbstract public class EntityAccessorPerProperty extends EntityAccessorAbstract
{ {
protected Map<String, PropertyAccessor> propertyAccessors; protected Map<String, PropertyAccessor> propertyAccessors;
public Map<String, PropertyAccessor> propertyAccessors() { return this.propertyAccessors; } public Map<String, PropertyAccessor> getPropertyAccessors() { return this.propertyAccessors; }
public PropertyAccessor propertyAccessor(String name) public PropertyAccessor getPropertyAccessor(String name)
{ {
PropertyAccessor ret = this.propertyAccessors.get(name); PropertyAccessor ret = this.propertyAccessors.get(name);
if (ret == null) if (ret == null)
@ -17,7 +17,7 @@ public class EntityAccessorPerProperty extends EntityAccessorAbstract
} }
return ret; return ret;
} }
public void propertyAccessor(String name, PropertyAccessor val) public void setPropertyAccessor(String name, PropertyAccessor val)
{ {
this.propertyAccessors.put(name, val); this.propertyAccessors.put(name, val);
} }
@ -66,14 +66,14 @@ public class EntityAccessorPerProperty extends EntityAccessorAbstract
@Override @Override
public void set(Object entity, String property, Object val) public void set(Object entity, String property, Object val)
{ {
PropertyAccessor pa = this.propertyAccessor(property); PropertyAccessor pa = this.getPropertyAccessor(property);
pa.set(entity, val); pa.set(entity, val);
} }
@Override @Override
public Object get(Object entity, String property) public Object get(Object entity, String property)
{ {
PropertyAccessor pa = this.propertyAccessor(property); PropertyAccessor pa = this.getPropertyAccessor(property);
return pa.get(entity); return pa.get(entity);
} }

View File

@ -26,7 +26,7 @@ public abstract class IdStrategyAbstract<L, R> implements IdStrategy<L, R>
@Override @Override
public L generate(CollInterface<?, L> coll) public L generate(CollInterface<?, L> coll)
{ {
Collection<L> alreadyInUse = coll.ids(); Collection<L> alreadyInUse = coll.getIds();
L ret = null; L ret = null;
do do
{ {

View File

@ -61,8 +61,8 @@ public class IdStrategyAiGson extends IdStrategyAbstract<String, String>
protected File getAiFile(CollInterface<?, String> coll) protected File getAiFile(CollInterface<?, String> coll)
{ {
DbGson cdb = (DbGson)coll.db(); DbGson cdb = (DbGson)coll.getDb();
return new File(cdb.dir, coll.name() + "_ai.txt"); return new File(cdb.dir, coll.getName() + "_ai.txt");
} }
protected boolean ensureFileExists(File file) protected boolean ensureFileExists(File file)

View File

@ -39,8 +39,8 @@ public class IdStrategyAiMongo extends IdStrategyAbstract<String, String>
@Override @Override
public String generateAttempt(CollInterface<?, String> coll) public String generateAttempt(CollInterface<?, String> coll)
{ {
String sequenseName = coll.name(); String sequenseName = coll.getName();
DBCollection sequenseCollection = ((DbMongo)coll.db()).db.getCollection(SEC); DBCollection sequenseCollection = ((DbMongo)coll.getDb()).db.getCollection(SEC);
// this object represents your "query", its analogous to a WHERE clause in SQL // this object represents your "query", its analogous to a WHERE clause in SQL
DBObject query = new BasicDBObject(); DBObject query = new BasicDBObject();

View File

@ -13,13 +13,13 @@ public class StoreAdapterGson extends StoreAdapterAbstract
@Override @Override
public Object read(Coll<?, ?> coll, Object entity) public Object read(Coll<?, ?> coll, Object entity)
{ {
return coll.mplugin().gson.toJsonTree(entity, coll.entityClass()); return coll.getMplugin().gson.toJsonTree(entity, coll.getEntityClass());
} }
@Override @Override
public void write(Coll<?, ?> coll, Object raw, Object entity) public void write(Coll<?, ?> coll, Object raw, Object entity)
{ {
Object temp = coll.mplugin().gson.fromJson((JsonElement)raw, coll.entityClass()); Object temp = coll.getMplugin().gson.fromJson((JsonElement)raw, coll.getEntityClass());
coll.copy(temp, entity); coll.copy(temp, entity);
} }

View File

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

View File

@ -28,7 +28,7 @@ public class AspectColl extends Coll<Aspect, String>
List<Aspect> ret = new ArrayList<Aspect>(); List<Aspect> ret = new ArrayList<Aspect>();
for (Aspect aspect : this.getAll()) for (Aspect aspect : this.getAll())
{ {
if(aspect.registered() == false) continue; if(aspect.isRegistered() == false) continue;
ret.add(aspect); ret.add(aspect);
} }
return ret; return ret;
@ -39,7 +39,7 @@ public class AspectColl extends Coll<Aspect, String>
List<Aspect> ret = new ArrayList<Aspect>(); List<Aspect> ret = new ArrayList<Aspect>();
for (Aspect aspect : this.getAll()) for (Aspect aspect : this.getAll())
{ {
if(aspect.registered() == false) continue; if(aspect.isRegistered() == false) continue;
if((aspect.multiverse() != multiverse) == normal) continue; if((aspect.multiverse() != multiverse) == normal) continue;
ret.add(aspect); ret.add(aspect);
} }

View File

@ -25,7 +25,7 @@ public class CmdUsysAspectShow extends UsysCommand
msg(Txt.titleize("Aspect: "+aspect.getId())); msg(Txt.titleize("Aspect: "+aspect.getId()));
msg("<k>using multiverse: <v>%s",aspect.multiverse().getId()); msg("<k>using multiverse: <v>%s",aspect.multiverse().getId());
for (String descLine : aspect.desc()) for (String descLine : aspect.getDesc())
{ {
msg(descLine); msg(descLine);
} }

View File

@ -19,7 +19,7 @@ public class CmdUsysMultiverseNew extends UsysCommand
{ {
String id = this.arg(0); String id = this.arg(0);
if (MultiverseColl.i.ids().contains(id)) if (MultiverseColl.i.getIds().contains(id))
{ {
msg("<b>The multiverse <h>%s<b> alread exists.", id); msg("<b>The multiverse <h>%s<b> alread exists.", id);
return; return;