From 9b932cb1c684f591968aa09bdc8633189b5b030a Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 24 Apr 2013 16:10:16 +0200 Subject: [PATCH] Permission node cleanup and removal of the commented out deprecated API. --- plugin.yml | 189 +++++++++++--------- src/com/massivecraft/factions/FFlag.java | 8 +- src/com/massivecraft/factions/FPerm.java | 8 +- src/com/massivecraft/factions/Factions.java | 128 +------------ src/com/massivecraft/factions/Perm.java | 8 - 5 files changed, 121 insertions(+), 220 deletions(-) diff --git a/plugin.yml b/plugin.yml index 8aa9488c..88f2e64e 100644 --- a/plugin.yml +++ b/plugin.yml @@ -9,69 +9,97 @@ permissions: # -------------------------------------------- # # THE REAL NODES # -------------------------------------------- # - factions.access: {description: grant territory access for your faction, with the proper fperm} - factions.access.any: {description: grant territory access for any faction} - factions.access.view: {description: view territory access info for your faction} - factions.adminmode: {description: enable admin bypass mode} - factions.autoclaim: {description: auto-claim land as you walk around} - factions.cape: {description: manage faction capes} - factions.cape.get: {description: get faction cape} - factions.cape.set: {description: set faction cape} - factions.cape.remove: {description: remove faction cape} - factions.claim: {description: claim land where you are standing} - factions.claim.radius: {description: claim land in a large radius} - factions.config: {description: change a conf.json setting} - factions.create: {description: create a new faction} - factions.demote: {description: demote lesser members in your faction} - factions.description: {description: change the faction description} - factions.disband: {description: disband a faction} - factions.flag: {description: read faction flags} - factions.flag.set: {description: set faction flags} - factions.help: {description: display a help page} - factions.home: {description: teleport to the faction home} - factions.invite: {description: set if a player is invited} - factions.join: {description: join a faction} - factions.join.any: {description: join any faction, bypassing invitation process for closed factions} - factions.join.others: {description: specify another player in the join command, to move them to the specified faction} - factions.kick: {description: kick a player from the faction} - factions.leader: {description: hand over leader rights} - factions.leader.any: {description: give or revoke leader status for any player in any faction} - factions.leave: {description: leave your faction} - factions.list: {description: see a list of the factions} - factions.lock: {description: lock all write stuff} - factions.map: {description: show the territory map, and set optional auto update} - factions.money.balance: {description: show money balance for a faction} - factions.money.balance.any: {description: show money balance for another faction} - factions.money.deposit: {description: deposit money to faction bank} - factions.money.f2f: {description: transfer f --> f} - factions.money.f2p: {description: transfer f --> p} - factions.money.p2f: {description: transfer p --> f} - factions.money.withdraw: {description: withdraw money from faction bank} - factions.officer: {description: give or revoke officer rights} - factions.officer.any: {description: give or revoke officer rights for any player in any faction} - factions.open: {description: switch if invitation is required to join} - factions.perm: {description: change faction permissions} - factions.powerboost: {description: apply permanent power bonus/penalty to specified player or faction} - factions.promote: {description: promote lesser members in your faction} - factions.relation: {description: set relation wish to another faction} - factions.reload: {description: reload data file(s) from disk} - factions.save: {description: save all data to disk} - factions.seechunk: {description: see the chunk you stand in} - factions.sethome: {description: set the faction home} - factions.show: {description: show faction information} - factions.tag: {description: change the faction tag} - factions.title: {description: set or remove a players title} - factions.unclaim: {description: unclaim the land where you are standing} - factions.unclaimall: {description: unclaim all of your factions land} - factions.version: {description: see the version of the plugin} + factions.access: {description: grant territory access, with the proper fperm, default: false} + factions.access.any: {description: grant territory access for another faction, default: false} + factions.access.view: {description: view territory access, default: false} + factions.adminmode: {description: enable adminmode, default: false} + factions.autoclaim: {description: autoclaim when walking, default: false} + factions.claim: {description: claim land where you stand, default: false} + factions.claim.radius: {description: claim land with radius, default: false} + factions.create: {description: create new faction, default: false} + factions.demote: {description: demote lesser members in your faction, default: false} + factions.description: {description: change faction description, default: false} + factions.disband: {description: disband faction, default: false} + factions.flag: {description: read faction flags, default: false} + factions.flag.set: {description: set faction flags, default: false} + factions.home: {description: teleport to faction home, default: false} + factions.invite: {description: set if player is invited, default: false} + factions.join: {description: join faction, default: false} + factions.join.any: {description: join closed faction, default: false} + factions.join.others: {description: have another player join faction, default: false} + factions.kick: {description: kick player from faction, default: false} + factions.leader: {description: set leader for faction, default: false} + factions.leader.any: {description: set leader for another faction, default: false} + factions.leave: {description: leave your faction, default: false} + factions.list: {description: list all factions, default: false} + factions.map: {description: show territory map, default: false} + factions.money.balance: {description: show faction money, default: false} + factions.money.balance.any: {description: show another factions money, default: false} + factions.money.deposit: {description: deposit to faction, default: false} + factions.money.f2f: {description: transfer f --> f, default: false} + factions.money.f2p: {description: transfer f --> p, default: false} + factions.money.p2f: {description: transfer p --> f, default: false} + factions.money.withdraw: {description: withdraw from faction, default: false} + factions.officer: {description: make player officer, default: false} + factions.officer.any: {description: set officers for another faction, default: false} + factions.open: {description: set if invitation is required to join, default: false} + factions.perm: {description: change faction permissions, default: false} + factions.powerboost: {description: set powerboost, default: false} + factions.promote: {description: promote lesser members in your faction, default: false} + factions.relation: {description: set relation wish to another faction, default: false} + factions.seechunk: {description: see the chunk you stand in, default: false} + factions.sethome: {description: set the faction home, default: false} + factions.show: {description: show faction information, default: false} + factions.tag: {description: set faction tag, default: false} + factions.title: {description: set player title, default: false} + factions.unclaim: {description: unclaim land where you stand, default: false} + factions.unclaimall: {description: unclaim all land, default: false} + factions.version: {description: see plugin version, default: false} # -------------------------------------------- # # STAR NOTATION # -------------------------------------------- # - factions.cape.*: + factions.*: children: - factions.cape.get: true - factions.cape.set: true - factions.cape.remove: true + factions.access: true + factions.access.any: true + factions.access.view: true + factions.adminmode: true + factions.autoclaim: true + factions.claim: true + factions.claim.radius: true + factions.create: true + factions.demote: true + factions.description: true + factions.disband: true + factions.flag: true + factions.flag.set: true + factions.home: true + factions.invite: true + factions.join: true + factions.join.any: true + factions.join.others: true + factions.kick: true + factions.leader: true + factions.leader.any: true + factions.leave: true + factions.list: true + factions.map: true + factions.money.*: true + factions.officer: true + factions.officer.any: true + factions.open: true + factions.perm: true + factions.powerboost: true + factions.promote: true + factions.relation: true + factions.seechunk: true + factions.sethome: true + factions.show: true + factions.tag: true + factions.title: true + factions.unclaim: true + factions.unclaimall: true + factions.version: true factions.money.*: children: factions.money.balance: true @@ -84,22 +112,18 @@ permissions: # -------------------------------------------- # # KITS # -------------------------------------------- # - factions.kit.admin: - description: All faction permissions. + factions.kit.op: + default: op children: - factions.kit.mod: true - factions.config: true - factions.lock: true - factions.reload: true - factions.save: true - factions.*: - description: This is just an alias for factions.kit.admin + factions.*: true + factions.kit.rank3: + default: false children: - factions.kit.admin: true - factions.kit.mod: - description: All faction permissions but configuration and persistance. + factions.kit.rank2: true + factions.kit.rank2: + default: false children: - factions.kit.halfmod: true + factions.kit.rank1: true factions.flag.set: true factions.powerboost: true factions.join.any: true @@ -107,31 +131,24 @@ permissions: factions.leader.any: true factions.officer.any: true factions.access.any: true - factions.kit.halfmod: - description: Can use adminmode and chat spy + factions.kit.rank1: + default: false children: - factions.kit.fullplayer: true + factions.kit.rank0: true factions.adminmode: true - factions.kit.fullplayer: - description: Can also create new factions. + factions.kit.rank0: + default: false children: - factions.kit.halfplayer: true factions.create: true - factions.kit.halfplayer: - description: Can do all but create factions. - children: factions.access: true factions.access.view: true factions.autoclaim: true - factions.cape: true - factions.cape.*: true factions.claim: true factions.claim.radius: true factions.demote: true factions.description: true factions.disband: true factions.flag: true - factions.help: true factions.home: true factions.invite: true factions.join: true @@ -153,3 +170,7 @@ permissions: factions.unclaim: true factions.unclaimall: true factions.version: true + factions.kit.default: + default: true + children: + factions.kit.rank0: true \ No newline at end of file diff --git a/src/com/massivecraft/factions/FFlag.java b/src/com/massivecraft/factions/FFlag.java index 79754535..6b412549 100644 --- a/src/com/massivecraft/factions/FFlag.java +++ b/src/com/massivecraft/factions/FFlag.java @@ -84,7 +84,7 @@ public enum FFlag } // -------------------------------------------- // - // FRODOODODFOFL + // PARSE // -------------------------------------------- // public static FFlag parse(String str) @@ -103,6 +103,10 @@ public enum FFlag return null; } + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + public String getStateInfo(boolean value, boolean withDesc) { String ret = (value ? "YES" : "NOO") + " " + this.getNicename(); @@ -113,6 +117,4 @@ public enum FFlag return ret; } - - } diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index 39901dc6..f0384e4c 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -38,7 +38,6 @@ public enum FPerm SETHOME("sethome", "set the home", Rel.LEADER, Rel.OFFICER), WITHDRAW("withdraw", "withdraw money", Rel.LEADER, Rel.OFFICER), TERRITORY("territory", "claim or unclaim", Rel.LEADER, Rel.OFFICER), - CAPE("cape", "set the cape", Rel.LEADER, Rel.OFFICER), ACCESS("access", "grant territory access", Rel.LEADER, Rel.OFFICER), DISBAND("disband", "disband the faction", Rel.LEADER), PERMS("perms", "manage permissions", Rel.LEADER), @@ -97,7 +96,7 @@ public enum FPerm } // -------------------------------------------- // - // FROOODLDLLD + // PARSE // -------------------------------------------- // public static FPerm parse(String str) @@ -115,12 +114,15 @@ public enum FPerm if (str.startsWith("s")) return SETHOME; if (str.startsWith("w")) return WITHDRAW; if (str.startsWith("t")) return TERRITORY; - if (str.startsWith("ca")) return CAPE; if (str.startsWith("di")) return DISBAND; if (str.startsWith("pe")) return PERMS; return null; } + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + public static String getStateHeaders() { String ret = ""; diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 1b695e26..5a0d1dc0 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -123,6 +123,12 @@ public class Factions extends MPlugin // Right now only a few situations are handled through this listener. FactionsListenerEcon.get().setup(); + // Integrate + this.integrate( + HerochatFeatures.get(), + LwcFeatures.get() + ); + // Schedule recurring non-tps-dependent tasks TaskPlayerPowerUpdate.get().schedule(this); TaskPlayerDataRemove.get().schedule(this); @@ -144,12 +150,6 @@ public class Factions extends MPlugin ChatTagTagforce.get().register(); ChatTagTitle.get().register(); - // Integrate - this.integrate( - HerochatFeatures.get(), - LwcFeatures.get() - ); - postEnable(); } @@ -165,121 +165,5 @@ public class Factions extends MPlugin .registerTypeAdapter(FFlag.class, FFlagAdapter.get()) ; } - - // -------------------------------------------- // - // Functions for other plugins to hook into - // -------------------------------------------- // - // TODO: This "outer API" is removed. I should ensure these features are - // available using the appropriate classes and then remove this commented out section below. - - /* - - // Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat - public String getPlayerFactionTag(Player player) - { - return getPlayerFactionTagRelation(player, null); - } - - // Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag - public String getPlayerFactionTagRelation(Player speaker, Player listener) - { - String tag = "~"; - - if (speaker == null) - return tag; - - FPlayer me = FPlayerColl.i.get(speaker); - if (me == null) - return tag; - - // if listener isn't set, or config option is disabled, give back uncolored tag - if (listener == null || !ConfServer.chatParseTagsColored) { - tag = me.getChatTag().trim(); - } else { - FPlayer you = FPlayerColl.i.get(listener); - if (you == null) - tag = me.getChatTag().trim(); - else // everything checks out, give the colored tag - tag = me.getChatTag(you).trim(); - } - if (tag.isEmpty()) - tag = "~"; - - return tag; - } - - // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat - public String getPlayerTitle(Player player) - { - if (player == null) - return ""; - - FPlayer me = FPlayerColl.i.get(player); - if (me == null) - return ""; - - return me.getTitle().trim(); - } - - // Get a list of all faction tags (names) - public Set getFactionTags() - { - Set tags = new HashSet(); - for (Faction faction : FactionColl.i.get()) - { - tags.add(faction.getTag()); - } - return tags; - } - - // Get a list of all players in the specified faction - public Set getPlayersInFaction(String factionTag) - { - Set players = new HashSet(); - Faction faction = FactionColl.i.getByTag(factionTag); - if (faction != null) - { - for (FPlayer fplayer : faction.getFPlayers()) - { - players.add(fplayer.getName()); - } - } - return players; - } - - // Get a list of all online players in the specified faction - public Set getOnlinePlayersInFaction(String factionTag) - { - Set players = new HashSet(); - Faction faction = FactionColl.i.getByTag(factionTag); - if (faction != null) - { - for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) - { - players.add(fplayer.getName()); - } - } - return players; - } - - // check if player is allowed to build/destroy in a particular location - public boolean isPlayerAllowedToBuildHere(Player player, Location location) - { - return FactionsBlockListener.playerCanBuildDestroyBlock(player, location.getBlock(), "", true); - } - - // check if player is allowed to interact with the specified block (doors/chests/whatever) - public boolean isPlayerAllowedToInteractWith(Player player, Block block) - { - return FactionsPlayerListener.canPlayerUseBlock(player, block, true); - } - - // check if player is allowed to use a specified item (flint&steel, buckets, etc) in a particular location - public boolean isPlayerAllowedToUseThisHere(Player player, Location location, Material material) - { - return FactionsPlayerListener.playerCanUseItemHere(player, location, material, true); - } - - */ } diff --git a/src/com/massivecraft/factions/Perm.java b/src/com/massivecraft/factions/Perm.java index 08584cf4..256d0c85 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/com/massivecraft/factions/Perm.java @@ -15,20 +15,14 @@ public enum Perm ACCESS_VIEW("access.view"), ADMIN("adminmode"), AUTOCLAIM("autoclaim"), - CAPE("cape"), - CAPE_GET("cape.get"), - CAPE_SET("cape.set"), - CAPE_REMOVE("cape.remove"), CLAIM("claim"), CLAIM_RADIUS("claim.radius"), - CONFIG("config"), CREATE("create"), DEMOTE("demote"), DESCRIPTION("description"), DISBAND("disband"), FLAG("flag"), FLAG_SET("flag.set"), - HELP("help"), HOME("home"), INVITE("invite"), JOIN("join"), @@ -39,7 +33,6 @@ public enum Perm LEADER_ANY("leader.any"), LEAVE("leave"), LIST("list"), - LOCK("lock"), MAP("map"), MONEY_BALANCE("money.balance"), MONEY_BALANCE_ANY("money.balance.any"), @@ -55,7 +48,6 @@ public enum Perm POWERBOOST("powerboost"), PROMOTE("promote"), RELATION("relation"), - RELOAD("reload"), SAVE("save"), SEE_CHUNK("seechunk"), SETHOME("sethome"),