Permission node cleanup and removal of the commented out deprecated API.

This commit is contained in:
Olof Larsson
2013-04-24 16:10:16 +02:00
parent da2cc0f052
commit 9b932cb1c6
5 changed files with 121 additions and 220 deletions

View File

@ -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 ? "<g>YES" : "<b>NOO") + "<c> " + this.getNicename();
@ -113,6 +117,4 @@ public enum FFlag
return ret;
}
}

View File

@ -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 = "";

View File

@ -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<String> getFactionTags()
{
Set<String> tags = new HashSet<String>();
for (Faction faction : FactionColl.i.get())
{
tags.add(faction.getTag());
}
return tags;
}
// Get a list of all players in the specified faction
public Set<String> getPlayersInFaction(String factionTag)
{
Set<String> players = new HashSet<String>();
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<String> getOnlinePlayersInFaction(String factionTag)
{
Set<String> players = new HashSet<String>();
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);
}
*/
}

View File

@ -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"),