From 6d2db1930c5c8d81a6e357d41c2d54317a29338e Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 22 Apr 2013 16:26:44 +0200 Subject: [PATCH] We need UConf as well as MConf. --- plugin.yml | 4 -- .../massivecraft/factions/entity/MConf.java | 5 +- .../massivecraft/factions/entity/UConf.java | 22 +++++++++ .../factions/entity/UConfColl.java | 32 ++++++++++++ .../factions/entity/UConfColls.java | 49 +++++++++++++++++++ .../listeners/TodoFactionsPlayerListener.java | 25 +++++----- 6 files changed, 115 insertions(+), 22 deletions(-) create mode 100644 src/com/massivecraft/factions/entity/UConf.java create mode 100644 src/com/massivecraft/factions/entity/UConfColl.java create mode 100644 src/com/massivecraft/factions/entity/UConfColls.java diff --git a/plugin.yml b/plugin.yml index 7110825a..a2980622 100644 --- a/plugin.yml +++ b/plugin.yml @@ -5,10 +5,6 @@ website: http://massivecraft.com/factions authors: [Olof "Cayorion" Larsson, Brett Flannigan] depend: [mcore] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag] -commands: - factions: - description: The Factions base command - aliases: [f] permissions: # -------------------------------------------- # # THE REAL NODES diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index fba951d3..906cab15 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -16,10 +16,7 @@ public class MConf extends Entity // -------------------------------------------- // protected static transient MConf i; - public static MConf get() - { - return i; - } + public static MConf get() { return i; } // -------------------------------------------- // // COLORS diff --git a/src/com/massivecraft/factions/entity/UConf.java b/src/com/massivecraft/factions/entity/UConf.java new file mode 100644 index 00000000..224fbac3 --- /dev/null +++ b/src/com/massivecraft/factions/entity/UConf.java @@ -0,0 +1,22 @@ +package com.massivecraft.factions.entity; + +import com.massivecraft.mcore.store.Entity; + +public class UConf extends Entity +{ + // -------------------------------------------- // + // META + // -------------------------------------------- // + + public static UConf get(Object worldNameExtractable) + { + return UConfColls.get().get2(worldNameExtractable); + } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + + +} \ No newline at end of file diff --git a/src/com/massivecraft/factions/entity/UConfColl.java b/src/com/massivecraft/factions/entity/UConfColl.java new file mode 100644 index 00000000..2898d610 --- /dev/null +++ b/src/com/massivecraft/factions/entity/UConfColl.java @@ -0,0 +1,32 @@ +package com.massivecraft.factions.entity; + +import com.massivecraft.factions.ConfServer; +import com.massivecraft.factions.Factions; +import com.massivecraft.mcore.MCore; +import com.massivecraft.mcore.store.Coll; +import com.massivecraft.mcore.store.MStore; + +public class UConfColl extends Coll +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public UConfColl(String name) + { + super(name, UConf.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, false); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void init() + { + super.init(); + + this.get(MCore.INSTANCE); + } + +} diff --git a/src/com/massivecraft/factions/entity/UConfColls.java b/src/com/massivecraft/factions/entity/UConfColls.java new file mode 100644 index 00000000..d4e0ac73 --- /dev/null +++ b/src/com/massivecraft/factions/entity/UConfColls.java @@ -0,0 +1,49 @@ +package com.massivecraft.factions.entity; + +import com.massivecraft.factions.Const; +import com.massivecraft.factions.Factions; +import com.massivecraft.mcore.MCore; +import com.massivecraft.mcore.store.Colls; +import com.massivecraft.mcore.usys.Aspect; + +public class UConfColls extends Colls +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static UConfColls i = new UConfColls(); + public static UConfColls get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: COLLS + // -------------------------------------------- // + + @Override + public UConfColl createColl(String collName) + { + return new UConfColl(collName); + } + + @Override + public Aspect getAspect() + { + return Factions.get().getAspect(); + } + + @Override + public String getBasename() + { + return Const.COLLECTION_BASENAME_UCONF; + } + + @Override + public UConf get2(Object worldNameExtractable) + { + UConfColl coll = this.get(worldNameExtractable); + if (coll == null) return null; + return coll.get(MCore.INSTANCE); + } + +} + diff --git a/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java index befb089c..a8313f37 100644 --- a/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java @@ -164,9 +164,9 @@ public class TodoFactionsPlayerListener implements Listener if (Const.MATERIALS_EDIT_ON_INTERACT.contains(material) && ! FPerm.BUILD.has(me, ps, ! justCheck)) return false; if (Const.MATERIALS_CONTAINER.contains(material) && ! FPerm.CONTAINER.has(me, ps, ! justCheck)) return false; - if (Const.MATERIALS_DOOR.contains(material) && ! FPerm.DOOR.has(me, ps, ! justCheck)) return false; - if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, ps, ! justCheck)) return false; - if (material == Material.LEVER && ! FPerm.LEVER.has(me, ps, ! justCheck)) return false; + if (Const.MATERIALS_DOOR.contains(material) && ! FPerm.DOOR.has(me, ps, ! justCheck)) return false; + if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, ps, ! justCheck)) return false; + if (material == Material.LEVER && ! FPerm.LEVER.has(me, ps, ! justCheck)) return false; return true; } @@ -177,24 +177,21 @@ public class TodoFactionsPlayerListener implements Listener { Block block = event.getBlockClicked(); Player player = event.getPlayer(); - - if ( ! playerCanUseItemHere(player, PS.valueOf(block), event.getBucket(), false)) - { - event.setCancelled(true); - return; - } + + if (playerCanUseItemHere(player, PS.valueOf(block), event.getBucket(), false)) return; + + event.setCancelled(true); } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { Block block = event.getBlockClicked(); Player player = event.getPlayer(); - if ( ! playerCanUseItemHere(player, PS.valueOf(block), event.getBucket(), false)) - { - event.setCancelled(true); - return; - } + if (playerCanUseItemHere(player, PS.valueOf(block), event.getBucket(), false)) return; + + event.setCancelled(true); }