From b484b6bb38ed6b4d8781d3f464195a612acbbe64 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 10 Sep 2013 02:40:16 +0200 Subject: [PATCH] Add in a place for people to store their custom data. --- README.md | 2 +- src/com/massivecraft/factions/entity/Faction.java | 7 +++++++ src/com/massivecraft/factions/entity/MPlayer.java | 8 ++++++++ src/com/massivecraft/factions/entity/UPlayer.java | 8 ++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2601b86..0521d9ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ ![Factions Logotype](https://raw.github.com/MassiveCraft/Factions/master/media/logo300.png)
-http://massivecraft.com/factions
\ No newline at end of file +http://massivecraft.com/factions diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index b919f284..33668c00 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -24,6 +24,7 @@ import com.massivecraft.mcore.store.Entity; import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.Txt; +import com.massivecraft.mcore.xlib.gson.JsonObject; public class Faction extends Entity implements EconomyParticipator @@ -54,6 +55,7 @@ public class Faction extends Entity implements EconomyParticipator this.setRelationWishes(that.relationWishes); this.setFlags(that.flags); this.setPerms(that.perms); + this.setCustomData(that.getCustomData()); return this; } @@ -125,6 +127,11 @@ public class Faction extends Entity implements EconomyParticipator // Null means default for the universe. private Map> perms = null; + // Custom Data - Since JsonObject is mutable there is not point to using fancy getters/setters. + private JsonObject customData = null; + public JsonObject getCustomData() { return this.customData; } + public void setCustomData(JsonObject customData) { this.customData = customData; } + // -------------------------------------------- // // FIELD: id // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java index 7b18fd26..cd641f24 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.entity; import com.massivecraft.factions.Perm; import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.xlib.gson.JsonObject; public class MPlayer extends SenderEntity { @@ -23,6 +24,7 @@ public class MPlayer extends SenderEntity { this.mapAutoUpdating = that.mapAutoUpdating; this.usingAdminMode = that.usingAdminMode; + this.setCustomData(that.getCustomData()); return this; } @@ -32,6 +34,7 @@ public class MPlayer extends SenderEntity { if (this.isMapAutoUpdating()) return false; if (this.isUsingAdminMode()) return false; + if (this.getCustomData() != null && this.getCustomData().entrySet().size() > 0) return false; return true; } @@ -56,4 +59,9 @@ public class MPlayer extends SenderEntity } public void setUsingAdminMode(boolean usingAdminMode) { this.usingAdminMode = usingAdminMode; this.changed(); } + // Custom Data - Since JsonObject is mutable there is not point to using fancy getters/setters. + private JsonObject customData = null; + public JsonObject getCustomData() { return this.customData; } + public void setCustomData(JsonObject customData) { this.customData = customData; } + } diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/com/massivecraft/factions/entity/UPlayer.java index 869f6ae4..db300513 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/com/massivecraft/factions/entity/UPlayer.java @@ -24,6 +24,7 @@ import com.massivecraft.mcore.store.SenderEntity; import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.Txt; +import com.massivecraft.mcore.xlib.gson.JsonObject; public class UPlayer extends SenderEntity implements EconomyParticipator @@ -49,6 +50,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato this.setTitle(that.title); this.setPowerBoost(that.powerBoost); this.setPower(that.power); + this.setCustomData(that.getCustomData()); return this; } @@ -60,6 +62,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato // Role means nothing without a faction. // Title means nothing without a faction. if (this.getPowerRounded() != (int) Math.round(UConf.get(this).defaultPlayerPower)) return false; + if (this.getCustomData() != null && this.getCustomData().entrySet().size() > 0) return false; return true; } @@ -134,6 +137,11 @@ public class UPlayer extends SenderEntity implements EconomyParticipato public Faction getAutoClaimFaction() { return this.autoClaimFaction; } public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; } + // Custom Data - Since JsonObject is mutable there is not point to using fancy getters/setters. + private JsonObject customData = null; + public JsonObject getCustomData() { return this.customData; } + public void setCustomData(JsonObject customData) { this.customData = customData; } + // -------------------------------------------- // // FIELDS: MULTIVERSE PROXY // -------------------------------------------- //