From 337031fc11474d230afc42badd0ed4696e44c18c Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 28 Jan 2016 15:45:36 +0100 Subject: [PATCH] Boolean database conversion methods --- .../massivecraft/massivecore/store/Entity.java | 15 +++++++++++++++ .../massivecore/store/SenderEntity.java | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/com/massivecraft/massivecore/store/Entity.java b/src/com/massivecraft/massivecore/store/Entity.java index e4d8796a..6fd9fd98 100644 --- a/src/com/massivecraft/massivecore/store/Entity.java +++ b/src/com/massivecraft/massivecore/store/Entity.java @@ -168,6 +168,21 @@ public class Entity> return false; } + // -------------------------------------------- // + // CONVENIENCE: DATABASE + // -------------------------------------------- // + + public boolean convertGet(Boolean wrapper) + { + return wrapper != null ? wrapper.booleanValue() : false; + } + + public Boolean convertSet(boolean primitive) + { + this.changed(); + return primitive ? Boolean.TRUE : null; + } + // -------------------------------------------- // // STANDARDS // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/store/SenderEntity.java b/src/com/massivecraft/massivecore/store/SenderEntity.java index 2f967287..4359d991 100644 --- a/src/com/massivecraft/massivecore/store/SenderEntity.java +++ b/src/com/massivecraft/massivecore/store/SenderEntity.java @@ -12,6 +12,7 @@ import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.PermUtil; public abstract class SenderEntity> extends Entity implements Named { @@ -59,6 +60,18 @@ public abstract class SenderEntity> extends Entity return (SenderColl) super.getColl(); } + // -------------------------------------------- // + // CONVENIENCE: DATABASE + // -------------------------------------------- // + + public boolean convertGet(Boolean wrapper, String permission) + { + // Permission requirement + if ( ! PermUtil.has(this.getSender(), permission)) return false; + + return super.convertGet(wrapper); + } + // -------------------------------------------- // // TYPE // -------------------------------------------- //