Updated readme, Fixed admin bypass command and corresponding permissions, Swapped colors for ally and truce, added new faction permissions, improved explosion protection and implemented firespread protection, fixed painbuild check order, flags can only be changed by server admins now and implemented type adapters for some enumerations for future changes to be non breaking. That it \:D /
This commit is contained in:
parent
57c4b70dad
commit
72db45e45e
23
README.md
23
README.md
@ -12,33 +12,10 @@ Usage
|
||||
---------
|
||||
<b>Read the full userguide here: [http://massivecraft.com/dev/factions](http://massivecraft.com/dev/factions)</b>
|
||||
|
||||
The chat console command is:
|
||||
|
||||
* `/f`
|
||||
|
||||
This command has subcommands like:
|
||||
|
||||
* `/f create MyFactionName`
|
||||
* `/f invite MyFriendsName`
|
||||
* `/f claim`
|
||||
* `/f map`
|
||||
* ... etc
|
||||
|
||||
You may also read the documentation ingame as the plugin ships with an ingame help manual. Read the help pages like this:
|
||||
|
||||
* `/f help 1`
|
||||
* `/f help 2`
|
||||
* `/f help 3`
|
||||
|
||||
Note that you may optionally skip the slash and just write
|
||||
|
||||
* `f`
|
||||
|
||||
Installing
|
||||
----------
|
||||
1. Download the latest release: [https://github.com/MassiveCraft/Factions/downloads](https://github.com/MassiveCraft/Factions/downloads)<br>
|
||||
1. Put Factions.jar in the plugins folder.
|
||||
1. [Download gson.jar to your lib folder](http://massivecraft.com/plugins/libraries)
|
||||
|
||||
A default config file will be created on the first run.
|
||||
|
||||
|
73
plugin.yml
73
plugin.yml
@ -24,17 +24,12 @@ permissions:
|
||||
description: All faction permissions but configuration and persistance.
|
||||
children:
|
||||
factions.kit.halfmod: true
|
||||
factions.disband.any: true
|
||||
factions.sethome.any: true
|
||||
factions.money.*: true
|
||||
factions.flag.set: true
|
||||
factions.kit.halfmod:
|
||||
description: Zones, bypassing, and kicking
|
||||
description: Can use adminmode
|
||||
children:
|
||||
factions.kit.fullplayer: true
|
||||
factions.bypass: true
|
||||
factions.flag.any: true
|
||||
factions.perm.any: true
|
||||
factions.kick.any: true
|
||||
factions.adminmode: true
|
||||
factions.kit.fullplayer:
|
||||
default: true
|
||||
description: Can also create new factions.
|
||||
@ -44,7 +39,6 @@ permissions:
|
||||
factions.kit.halfplayer:
|
||||
description: Can do all but create factions.
|
||||
children:
|
||||
factions.leader: true
|
||||
factions.autoclaim: true
|
||||
factions.chat: true
|
||||
factions.claim: true
|
||||
@ -52,18 +46,19 @@ permissions:
|
||||
factions.description: true
|
||||
factions.disband: true
|
||||
factions.flag: true
|
||||
factions.perm: true
|
||||
factions.help: true
|
||||
factions.home: true
|
||||
factions.invite: true
|
||||
factions.join: true
|
||||
factions.kick: true
|
||||
factions.leader: true
|
||||
factions.leave: true
|
||||
factions.list: true
|
||||
factions.map: true
|
||||
factions.money.*: true
|
||||
factions.officer: true
|
||||
factions.money.kit.standard: true
|
||||
factions.open: true
|
||||
factions.perm: true
|
||||
factions.power: true
|
||||
factions.power.any: true
|
||||
factions.relation: true
|
||||
@ -71,15 +66,13 @@ permissions:
|
||||
factions.show: true
|
||||
factions.tag: true
|
||||
factions.title: true
|
||||
factions.version: true
|
||||
factions.unclaim: true
|
||||
factions.unclaimall: true
|
||||
factions.leader:
|
||||
description: hand over your leader rights
|
||||
factions.version: true
|
||||
factions.adminmode:
|
||||
description: enable admin bypass mode
|
||||
factions.autoclaim:
|
||||
description: auto-claim land as you walk around
|
||||
factions.bypass:
|
||||
description: enable admin bypass mode
|
||||
factions.chat:
|
||||
description: change chat mode
|
||||
factions.claim:
|
||||
@ -94,16 +87,10 @@ permissions:
|
||||
description: change the faction description
|
||||
factions.disband:
|
||||
description: disband a faction
|
||||
factions.disband.any:
|
||||
description: disband an other faction
|
||||
factions.flag:
|
||||
description: change faction flags
|
||||
factions.flag.any:
|
||||
description: change all flags for all factions
|
||||
factions.perm:
|
||||
description: change faction permissions
|
||||
factions.perm.any:
|
||||
description: change all permissions for all factions
|
||||
description: read faction flags
|
||||
factions.flag.set:
|
||||
description: set faction flags
|
||||
factions.help:
|
||||
description: display a help page
|
||||
factions.home:
|
||||
@ -114,8 +101,8 @@ permissions:
|
||||
description: join a faction
|
||||
factions.kick:
|
||||
description: kick a player from the faction
|
||||
factions.kick.any:
|
||||
description: kick anyone from any faction
|
||||
factions.leader:
|
||||
description: hand over your leader rights
|
||||
factions.leave:
|
||||
description: leave your faction
|
||||
factions.list:
|
||||
@ -124,45 +111,35 @@ permissions:
|
||||
description: lock all write stuff
|
||||
factions.map:
|
||||
description: show the territory map, and set optional auto update
|
||||
factions.officer:
|
||||
description: give or revoke officer rights
|
||||
factions.money.balance:
|
||||
description: show your factions current money balance
|
||||
factions.money.balance.any:
|
||||
description: show money balance for factions other than your own
|
||||
factions.money.deposit:
|
||||
description: deposit money into a faction bank
|
||||
factions.money.withdraw:
|
||||
description: withdraw money from your faction bank
|
||||
factions.money.withdraw.any:
|
||||
description: withdraw money from your factions other than your own
|
||||
factions.money.f2f:
|
||||
description: transfer money from faction to faction
|
||||
factions.money.f2p:
|
||||
description: transfer money from faction to player
|
||||
factions.money.p2f:
|
||||
description: transfer money from player to faction
|
||||
factions.money.kit.standard:
|
||||
factions.money.withdraw:
|
||||
description: withdraw money from your faction bank
|
||||
factions.money.*:
|
||||
children:
|
||||
factions.money.balance: true
|
||||
factions.money.balance.any: true
|
||||
factions.money.deposit: true
|
||||
factions.money.withdraw: true
|
||||
factions.money.f2f: true
|
||||
factions.money.f2p: true
|
||||
factions.money.p2f: true
|
||||
factions.money.*:
|
||||
children:
|
||||
factions.money.kit.standard: true
|
||||
factions.money.balance.any: true
|
||||
factions.money.deposit: true
|
||||
factions.money.withdraw: true
|
||||
factions.money.withdraw.any: true
|
||||
factions.money.f2f: true
|
||||
factions.money.f2p: true
|
||||
factions.money.p2f: true
|
||||
factions.officer:
|
||||
description: give or revoke officer rights
|
||||
factions.open:
|
||||
description: switch if invitation is required to join
|
||||
factions.perm:
|
||||
description: change faction permissions
|
||||
factions.power:
|
||||
description: show player power info
|
||||
factions.power.any:
|
||||
@ -175,17 +152,15 @@ permissions:
|
||||
description: save all data to disk
|
||||
factions.sethome:
|
||||
description: set the faction home
|
||||
factions.sethome.any:
|
||||
description: set faction home for another faction
|
||||
factions.show:
|
||||
description: show faction information
|
||||
factions.tag:
|
||||
description: change the faction tag
|
||||
factions.title:
|
||||
description: set or remove a players title
|
||||
factions.version:
|
||||
description: see the version of the plugin
|
||||
factions.unclaim:
|
||||
description: unclaim the land where you are standing
|
||||
factions.unclaimall:
|
||||
description: unclaim all of your factions land
|
||||
description: unclaim all of your factions land
|
||||
factions.version:
|
||||
description: see the version of the plugin
|
@ -10,6 +10,8 @@ import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
@ -39,6 +41,14 @@ public class Board
|
||||
{
|
||||
return Factions.i.get(getIdAt(flocation));
|
||||
}
|
||||
public static Faction getFactionAt(Location location)
|
||||
{
|
||||
return getFactionAt(new FLocation(location));
|
||||
}
|
||||
public static Faction getFactionAt(Block block)
|
||||
{
|
||||
return getFactionAt(new FLocation(block));
|
||||
}
|
||||
|
||||
public static void setIdAt(String id, FLocation flocation)
|
||||
{
|
||||
|
@ -16,8 +16,8 @@ public class Conf
|
||||
|
||||
// Colors
|
||||
public static ChatColor colorMember = ChatColor.GREEN;
|
||||
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
|
||||
public static ChatColor colorTruce = ChatColor.DARK_PURPLE;
|
||||
public static ChatColor colorAlly = ChatColor.DARK_PURPLE;
|
||||
public static ChatColor colorTruce = ChatColor.LIGHT_PURPLE;
|
||||
public static ChatColor colorNeutral = ChatColor.WHITE;
|
||||
public static ChatColor colorEnemy = ChatColor.RED;
|
||||
|
||||
@ -206,11 +206,9 @@ public class Conf
|
||||
baseCommandAliases.add("f");
|
||||
|
||||
factionFlagDefaults = new LinkedHashMap<FFlag, Boolean>();
|
||||
factionFlagIsChangeable = new LinkedHashMap<FFlag, Boolean>();
|
||||
for (FFlag flag : FFlag.values())
|
||||
{
|
||||
factionFlagDefaults.put(flag, flag.defaultDefaultValue);
|
||||
factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable);
|
||||
}
|
||||
|
||||
factionPermDefaults = new LinkedHashMap<FPerm, Set<Rel>>();
|
||||
|
@ -15,6 +15,7 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||
@ -80,9 +81,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public Faction getAutoClaimFor() { return autoClaimFor; }
|
||||
public void setAutoClaimFor(Faction faction) { this.autoClaimFor = faction; }
|
||||
|
||||
private transient boolean isAdminBypassing = false;
|
||||
public boolean isAdminBypassing() { return this.isAdminBypassing; }
|
||||
public void setIsAdminBypassing(boolean val) { this.isAdminBypassing = val; }
|
||||
private transient boolean hasAdminMode = false;
|
||||
public boolean hasAdminMode() { return this.hasAdminMode; }
|
||||
public void setHasAdminMode(boolean val) { this.hasAdminMode = val; }
|
||||
|
||||
// FIELD: loginPvpDisabled
|
||||
private transient boolean loginPvpDisabled;
|
||||
@ -470,7 +471,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay
|
||||
if (makePay && Econ.shouldBeUsed() && ! this.isAdminBypassing())
|
||||
if (makePay && Econ.shouldBeUsed() && ! this.hasAdminMode())
|
||||
{
|
||||
double cost = Conf.econCostLeave;
|
||||
if ( ! Econ.modifyMoney(this, -cost, "to leave your faction.", "for leaving your faction.")) return;
|
||||
@ -511,24 +512,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
P.p.log("The faction "+myFaction.getTag()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canClaimForFaction(Faction forFaction)
|
||||
{
|
||||
if (forFaction.isNone()) return false;
|
||||
|
||||
if
|
||||
(
|
||||
this.isAdminBypassing()
|
||||
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
||||
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
||||
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure)
|
||||
{
|
||||
@ -547,21 +530,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
{
|
||||
error = P.p.txt.parse("<b>Sorry, this world has land claiming disabled.");
|
||||
}
|
||||
else if (this.isAdminBypassing())
|
||||
else if (this.hasAdminMode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (myFaction != forFaction)
|
||||
{
|
||||
error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this));
|
||||
}
|
||||
else if (forFaction == currentFaction)
|
||||
{
|
||||
error = P.p.txt.parse("%s<i> already own this land.", forFaction.describeTo(this, true));
|
||||
}
|
||||
else if ( ! this.getRole().isAtLeast(Rel.OFFICER))
|
||||
else if ( ! FPerm.TERRITORY.has(this, forFaction, true))
|
||||
{
|
||||
error = P.p.txt.parse("<b>You must be <h>%s<b> to claim land.", Rel.OFFICER.toString());
|
||||
return false;
|
||||
}
|
||||
else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers)
|
||||
{
|
||||
@ -578,7 +557,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
else if
|
||||
(
|
||||
Conf.claimsMustBeConnected
|
||||
&& ! this.isAdminBypassing()
|
||||
&& ! this.hasAdminMode()
|
||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
||||
&& !Board.isConnectedLocation(flocation, myFaction)
|
||||
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
||||
@ -624,7 +603,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay
|
||||
// TODO: Add flag no costs??
|
||||
//if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone())
|
||||
if (Econ.shouldBeUsed() && ! this.isAdminBypassing())
|
||||
if (Econ.shouldBeUsed() && ! this.hasAdminMode())
|
||||
{
|
||||
double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||
//String costString = Econ.moneyString(cost);
|
||||
|
@ -122,9 +122,26 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
if (ret == null) ret = perm.getDefault();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void addPermittedRelation(FPerm perm, Rel rel)
|
||||
{
|
||||
Set<Rel> newPermittedRelations = EnumSet.noneOf(Rel.class);
|
||||
newPermittedRelations.addAll(this.getPermittedRelations(perm));
|
||||
newPermittedRelations.add(rel);
|
||||
this.setPermittedRelations(perm, newPermittedRelations);
|
||||
}
|
||||
|
||||
public void removePermittedRelation(FPerm perm, Rel rel)
|
||||
{
|
||||
Set<Rel> newPermittedRelations = EnumSet.noneOf(Rel.class);
|
||||
newPermittedRelations.addAll(this.getPermittedRelations(perm));
|
||||
newPermittedRelations.remove(rel);
|
||||
this.setPermittedRelations(perm, newPermittedRelations);
|
||||
}
|
||||
|
||||
public void setPermittedRelations(FPerm perm, Set<Rel> rels)
|
||||
{
|
||||
if (Conf.factionPermDefaults.get(perm).equals(rels))
|
||||
if (perm.getDefault().equals(rels))
|
||||
{
|
||||
this.permOverrides.remove(perm);
|
||||
return;
|
||||
|
@ -14,6 +14,11 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.factions.adapters.FFlagTypeAdapter;
|
||||
import com.massivecraft.factions.adapters.FLocToStringSetTypeAdapter;
|
||||
import com.massivecraft.factions.adapters.FPermTypeAdapter;
|
||||
import com.massivecraft.factions.adapters.LocationTypeAdapter;
|
||||
import com.massivecraft.factions.adapters.RelTypeAdapter;
|
||||
import com.massivecraft.factions.cmd.*;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
@ -24,10 +29,9 @@ import com.massivecraft.factions.listeners.FactionsEntityListener;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.MapFLocToStringSetTypeAdapter;
|
||||
import com.massivecraft.factions.util.MyLocationTypeAdapter;
|
||||
import com.massivecraft.factions.util.MyRelTypeAdapter;
|
||||
import com.massivecraft.factions.zcore.MPlugin;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
@ -132,6 +136,8 @@ public class P extends MPlugin
|
||||
this.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.BLOCK_SPREAD, this.blockListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.BLOCK_BURN, this.blockListener, Event.Priority.Normal);
|
||||
|
||||
// Server Events
|
||||
this.registerEvent(Event.Type.PLUGIN_ENABLE, this.serverListener, Event.Priority.Monitor);
|
||||
@ -149,9 +155,11 @@ public class P extends MPlugin
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
||||
.registerTypeAdapter(Location.class, new MyLocationTypeAdapter())
|
||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter())
|
||||
.registerTypeAdapter(Rel.class, new MyRelTypeAdapter()); // This one is for users upgrading from 1.6 to 1.7... should be removed some time in the future.
|
||||
.registerTypeAdapter(Location.class, new LocationTypeAdapter())
|
||||
.registerTypeAdapter(mapFLocToStringSetType, new FLocToStringSetTypeAdapter())
|
||||
.registerTypeAdapter(Rel.class, new RelTypeAdapter())
|
||||
.registerTypeAdapter(FPerm.class, new FPermTypeAdapter())
|
||||
.registerTypeAdapter(FFlag.class, new FFlagTypeAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
18
src/com/massivecraft/factions/adapters/FFlagTypeAdapter.java
Normal file
18
src/com/massivecraft/factions/adapters/FFlagTypeAdapter.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.massivecraft.factions.adapters;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
|
||||
public class FFlagTypeAdapter implements JsonDeserializer<FFlag>
|
||||
{
|
||||
@Override
|
||||
public FFlag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
return FFlag.parse(json.getAsString());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.adapters;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -23,7 +23,7 @@ import com.massivecraft.factions.P;
|
||||
|
||||
|
||||
// TODO: Is this one even used anymore??
|
||||
public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLocation, Set<String>>>, JsonSerializer<Map<FLocation, Set<String>>>
|
||||
public class FLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLocation, Set<String>>>, JsonSerializer<Map<FLocation, Set<String>>>
|
||||
{
|
||||
|
||||
@Override
|
18
src/com/massivecraft/factions/adapters/FPermTypeAdapter.java
Normal file
18
src/com/massivecraft/factions/adapters/FPermTypeAdapter.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.massivecraft.factions.adapters;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
|
||||
public class FPermTypeAdapter implements JsonDeserializer<FPerm>
|
||||
{
|
||||
@Override
|
||||
public FPerm deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
return FPerm.parse(json.getAsString());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.adapters;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
@ -16,7 +16,7 @@ import com.google.gson.JsonSerializer;
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
|
||||
public class MyLocationTypeAdapter implements JsonDeserializer<Location>, JsonSerializer<Location>
|
||||
public class LocationTypeAdapter implements JsonDeserializer<Location>, JsonSerializer<Location>
|
||||
{
|
||||
private static final String WORLD = "world";
|
||||
private static final String X = "x";
|
@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.adapters;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@ -8,10 +8,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
/**
|
||||
* This is a legacy solution. Since Relation and Role enums have ben merged AND the rename ADMIN -> LEADER, MODERATOR -> OFFICER
|
||||
*/
|
||||
public class MyRelTypeAdapter implements JsonDeserializer<Rel>
|
||||
public class RelTypeAdapter implements JsonDeserializer<Rel>
|
||||
{
|
||||
@Override
|
||||
public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
@ -3,17 +3,17 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdBypass extends FCommand
|
||||
public class CmdAdmin extends FCommand
|
||||
{
|
||||
public CmdBypass()
|
||||
public CmdAdmin()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("bypass");
|
||||
this.aliases.add("admin");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.BYPASS.node;
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
@ -25,12 +25,11 @@ public class CmdBypass extends FCommand
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
fme.setIsAdminBypassing(this.argAsBool(0, ! fme.isAdminBypassing()));
|
||||
fme.setHasAdminMode(this.argAsBool(0, ! fme.hasAdminMode()));
|
||||
|
||||
// TODO: Move this to a transient field in the model??
|
||||
if ( fme.isAdminBypassing())
|
||||
if ( fme.hasAdminMode())
|
||||
{
|
||||
fme.msg("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
|
||||
fme.msg("<i>You have enabled admin bypass mode.");
|
||||
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
|
||||
}
|
||||
else
|
@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
public class CmdAutoClaim extends FCommand
|
||||
{
|
||||
@ -33,16 +33,8 @@ public class CmdAutoClaim extends FCommand
|
||||
msg("<i>Auto-claiming of land disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (! fme.canClaimForFaction(forFaction))
|
||||
{
|
||||
if (myFaction == forFaction)
|
||||
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||
else
|
||||
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! FPerm.TERRITORY.has(fme, forFaction, true)) return;
|
||||
|
||||
fme.setAutoClaimFor(forFaction);
|
||||
|
||||
|
@ -8,8 +8,8 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdDisband extends FCommand
|
||||
{
|
||||
@ -37,19 +37,7 @@ public class CmdDisband extends FCommand
|
||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||
|
||||
if (isMyFaction)
|
||||
{
|
||||
if ( ! assertMinRole(Rel.LEADER)) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! Permission.DISBAND_ANY.has(sender, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ( ! FPerm.DISBAND.has(sender, faction, true)) return;
|
||||
|
||||
if (faction.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdFlag extends FCommand
|
||||
{
|
||||
@ -12,6 +11,7 @@ public class CmdFlag extends FCommand
|
||||
{
|
||||
super();
|
||||
this.aliases.add("flag");
|
||||
this.aliases.add("flags");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
@ -59,26 +59,8 @@ public class CmdFlag extends FCommand
|
||||
Boolean targetValue = this.argAsBool(2);
|
||||
if (targetValue == null) return;
|
||||
|
||||
// Do the sender have the right to change flags for this faction?
|
||||
if (Permission.FLAG_ANY.has(sender))
|
||||
{
|
||||
// This sender may modify any flag for anyone
|
||||
}
|
||||
else if ( ! flag.isChangeable())
|
||||
{
|
||||
msg("<b>Only server operators can change this flag.");
|
||||
return;
|
||||
}
|
||||
else if (faction != myFaction)
|
||||
{
|
||||
msg("<b>You are not a member in that faction.");
|
||||
return;
|
||||
}
|
||||
else if (fme.getRole().isLessThan(Rel.OFFICER))
|
||||
{
|
||||
msg("<b>You must be faction leader or officer to change your faction flags.");
|
||||
return;
|
||||
}
|
||||
// Do the sender have the right to change flags?
|
||||
if ( ! Permission.FLAG_SET.has(sender, true)) return;
|
||||
|
||||
// Do the change
|
||||
msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true)));
|
||||
|
@ -54,7 +54,7 @@ public class CmdJoin extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.isAdminBypassing()))
|
||||
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.hasAdminMode()))
|
||||
{
|
||||
msg("<i>This faction requires invitation.");
|
||||
faction.msg("%s<i> tried to join your faction.", fme.describeTo(faction, true));
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdKick extends FCommand
|
||||
@ -41,31 +42,16 @@ public class CmdKick extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0)
|
||||
{
|
||||
msg("<b>You cannot kick that member until their power is positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction yourFaction = you.getFaction();
|
||||
|
||||
// players with admin-level "disband" permission can bypass these requirements
|
||||
if ( ! Permission.KICK_ANY.has(sender))
|
||||
{
|
||||
if (yourFaction != myFaction)
|
||||
{
|
||||
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole().isAtLeast(fme.getRole()))
|
||||
{
|
||||
// TODO add more informative messages.
|
||||
msg("<b>Your rank is too low to kick this player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0)
|
||||
{
|
||||
msg("<b>You cannot kick that member until their power is positive.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fme != null && ! FPerm.KICK.has(fme, yourFaction)) return;
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return;
|
||||
|
||||
|
@ -15,6 +15,7 @@ public class CmdPerm extends FCommand
|
||||
{
|
||||
super();
|
||||
this.aliases.add("perm");
|
||||
this.aliases.add("perms");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
@ -63,26 +64,20 @@ public class CmdPerm extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Rel> targetValue = FPerm.parseRelDeltas(TextUtil.implode(args.subList(2, args.size()), " "), faction.getPermittedRelations(perm));
|
||||
|
||||
// Do the sender have the right to change perms for this faction?
|
||||
if (Permission.PERM_ANY.has(sender))
|
||||
{
|
||||
// This sender may modify any perm for anyone
|
||||
}
|
||||
else if (faction != myFaction)
|
||||
{
|
||||
msg("<b>You are not a member in that faction.");
|
||||
return;
|
||||
}
|
||||
else if (fme.getRole().isLessThan(Rel.OFFICER))
|
||||
{
|
||||
msg("<b>You must be faction leader or officer to change your faction permissions.");
|
||||
return;
|
||||
}
|
||||
if ( ! FPerm.PERMS.has(sender, faction, true)) return;
|
||||
|
||||
// Do the change
|
||||
Set<Rel> targetValue = FPerm.parseRelDeltas(TextUtil.implode(args.subList(2, args.size()), " "), faction.getPermittedRelations(perm));
|
||||
|
||||
// The following is to make sure the leader always has the right to change perms if that is our goal.
|
||||
if (perm == FPerm.PERMS && FPerm.PERMS.getDefault().contains(Rel.LEADER))
|
||||
{
|
||||
targetValue.add(Rel.LEADER);
|
||||
}
|
||||
|
||||
faction.setPermittedRelations(perm, targetValue);
|
||||
|
||||
msg(p.txt.titleize("Perm for " + faction.describeTo(fme, true)));
|
||||
msg(FPerm.getStateHeaders());
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
|
@ -4,8 +4,8 @@ import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdSethome extends FCommand
|
||||
{
|
||||
@ -38,19 +38,12 @@ public class CmdSethome extends FCommand
|
||||
if (faction == null) return;
|
||||
|
||||
// Can the player set the home for this faction?
|
||||
if (faction == myFaction)
|
||||
{
|
||||
if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Rel.OFFICER)) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Permission.SETHOME_ANY.has(sender, true)) return;
|
||||
}
|
||||
if ( ! FPerm.SETHOME.has(sender, faction, true)) return;
|
||||
|
||||
// Can the player set the faction home HERE?
|
||||
if
|
||||
(
|
||||
! Permission.BYPASS.has(me)
|
||||
! fme.hasAdminMode()
|
||||
&&
|
||||
Conf.homesMustBeInClaimedTerritory
|
||||
&&
|
||||
|
@ -7,8 +7,8 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdUnclaim extends FCommand
|
||||
{
|
||||
@ -34,37 +34,8 @@ public class CmdUnclaim extends FCommand
|
||||
{
|
||||
FLocation flocation = new FLocation(fme);
|
||||
Faction otherFaction = Board.getFactionAt(flocation);
|
||||
|
||||
if (fme.isAdminBypassing())
|
||||
{
|
||||
Board.removeAt(flocation);
|
||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||
|
||||
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
|
||||
msg("<i>You unclaimed this land.");
|
||||
|
||||
if (Conf.logLandUnclaims)
|
||||
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! assertHasFaction())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! assertMinRole(Rel.OFFICER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( myFaction != otherFaction)
|
||||
{
|
||||
msg("<b>You don't own this land.");
|
||||
return;
|
||||
}
|
||||
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
|
||||
|
||||
//String moneyBack = "<i>";
|
||||
if (Econ.shouldBeUsed())
|
||||
|
@ -8,7 +8,7 @@ public class FCmdRoot extends FCommand
|
||||
{
|
||||
public CmdLeader cmdLeader = new CmdLeader();
|
||||
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
||||
public CmdBypass cmdBypass = new CmdBypass();
|
||||
public CmdAdmin cmdBypass = new CmdAdmin();
|
||||
public CmdChat cmdChat = new CmdChat();
|
||||
public CmdClaim cmdClaim = new CmdClaim();
|
||||
public CmdConfig cmdConfig = new CmdConfig();
|
||||
|
@ -387,7 +387,7 @@ public abstract class FCommand extends MCommand<P>
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
|
||||
{
|
||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.hasAdminMode()) return true;
|
||||
|
||||
if(Conf.bankFactionPaysLandCosts && fme.hasFaction())
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public class Econ
|
||||
if (fI == null) return true;
|
||||
|
||||
// Bypassing players can do any kind of transaction
|
||||
if (i instanceof FPlayer && ((FPlayer)i).isAdminBypassing()) return true;
|
||||
if (i instanceof FPlayer && ((FPlayer)i).hasAdminMode()) return true;
|
||||
|
||||
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
|
||||
if (i == you) return true;
|
||||
|
@ -4,11 +4,13 @@ import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
@ -17,6 +19,7 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
|
||||
|
||||
@ -28,17 +31,40 @@ public class FactionsBlockListener extends BlockListener
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockSpread(BlockSpreadEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getSource().getTypeId() != 51) return; // Must be Fire
|
||||
Faction faction = Board.getFactionAt(event.getBlock());
|
||||
if (faction.getFlag(FFlag.FIRESPREAD) == false)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBurn(BlockBurnEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Faction faction = Board.getFactionAt(event.getBlock());
|
||||
if (faction.getFlag(FFlag.FIRESPREAD) == false)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Block block, String action, boolean justCheck)
|
||||
{
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.hasAdminMode()) return true;
|
||||
|
||||
Location location = block.getLocation();
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction factionHere = Board.getFactionAt(loc);
|
||||
|
||||
if (FPerm.PAINBUILD.has(me, location))
|
||||
if ( ! FPerm.BUILD.has(me, location) && FPerm.PAINBUILD.has(me, location))
|
||||
{
|
||||
if (!justCheck)
|
||||
{
|
||||
@ -48,7 +74,7 @@ public class FactionsBlockListener extends BlockListener
|
||||
return true;
|
||||
}
|
||||
|
||||
return FPerm.BUILD.has(me, location, true);
|
||||
return FPerm.BUILD.has(me, loc, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,7 +132,6 @@ public class FactionsBlockListener extends BlockListener
|
||||
|
||||
// if potentially pushing into air in another territory, we need to check it out
|
||||
|
||||
|
||||
if (targetBlock.isEmpty() && ! FPerm.BUILD.has(pistonFaction, targetBlock.getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.listeners;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
@ -91,15 +92,15 @@ public class FactionsEntityListener extends EntityListener
|
||||
{
|
||||
if ( event.isCancelled()) return;
|
||||
|
||||
Location loc = event.getLocation();
|
||||
|
||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false)
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
Faction faction = Board.getFactionAt(new FLocation(block));
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,14 +242,14 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
public static boolean playerCanUseItemHere(Player player, Location loc, Material material, boolean justCheck)
|
||||
{
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.hasAdminMode()) return true;
|
||||
if (Conf.materialsEditTools.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
|
||||
{
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me.isAdminBypassing()) return true;
|
||||
if (me.hasAdminMode()) return true;
|
||||
Location loc = block.getLocation();
|
||||
Material material = block.getType();
|
||||
|
||||
@ -350,7 +350,7 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
&&
|
||||
! Conf.territoryNeutralDenyCommands.isEmpty()
|
||||
&&
|
||||
! me.isAdminBypassing()
|
||||
! me.hasAdminMode()
|
||||
)
|
||||
{
|
||||
Iterator<String> iter = Conf.territoryNeutralDenyCommands.iterator();
|
||||
@ -378,7 +378,7 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
&&
|
||||
! Conf.territoryEnemyDenyCommands.isEmpty()
|
||||
&&
|
||||
! me.isAdminBypassing()
|
||||
! me.hasAdminMode()
|
||||
)
|
||||
{
|
||||
Iterator<String> iter = Conf.territoryEnemyDenyCommands.iterator();
|
||||
|
@ -12,34 +12,32 @@ import com.massivecraft.factions.Conf;
|
||||
public enum FFlag
|
||||
{
|
||||
// Faction flags
|
||||
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false, false),
|
||||
PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false, false),
|
||||
INFPOWER("infpower", "<i>This flag gives the faction infinite power.", false, false),
|
||||
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false),
|
||||
PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false),
|
||||
INFPOWER("infpower", "<i>This flag gives the faction infinite power.", false),
|
||||
// This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level
|
||||
|
||||
// (Faction) Territory flags
|
||||
// If a faction later could have many different territories this would probably be in another enum
|
||||
POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true, false),
|
||||
PVP("pvp", "<i>Can you PVP in territory?", true, false),
|
||||
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false, false),
|
||||
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true, false),
|
||||
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true, false),
|
||||
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true, false),
|
||||
//LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true, false), Possible to add later.
|
||||
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false, true),
|
||||
POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true),
|
||||
PVP("pvp", "<i>Can you PVP in territory?", true),
|
||||
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false),
|
||||
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true),
|
||||
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true),
|
||||
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true),
|
||||
//LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true), Possible to add later.
|
||||
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false),
|
||||
;
|
||||
|
||||
private final String nicename;
|
||||
private final String desc;
|
||||
public final boolean defaultDefaultValue;
|
||||
public final boolean defaultDefaultChangeable;
|
||||
|
||||
private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue, final boolean defaultDefaultChangeable)
|
||||
private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue)
|
||||
{
|
||||
this.nicename = nicename;
|
||||
this.desc = desc;
|
||||
this.defaultDefaultValue = defaultDefaultValue;
|
||||
this.defaultDefaultChangeable = defaultDefaultChangeable;
|
||||
}
|
||||
|
||||
public String getNicename()
|
||||
@ -62,18 +60,6 @@ public enum FFlag
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this flag changeable by the faction leaders or not?
|
||||
* The normal faction members can never change these flags.
|
||||
* Note that server operators and admin bypassers can change all flags.
|
||||
*/
|
||||
public boolean isChangeable()
|
||||
{
|
||||
Boolean ret = Conf.factionFlagIsChangeable.get(this);
|
||||
if (ret == null) return this.defaultDefaultChangeable;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static FFlag parse(String str)
|
||||
{
|
||||
str = str.toLowerCase();
|
||||
@ -84,9 +70,10 @@ public enum FFlag
|
||||
if (str.startsWith("pvp")) return PVP;
|
||||
if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE;
|
||||
if (str.startsWith("m")) return MONSTERS;
|
||||
if (str.startsWith("e")) return EXPLOSIONS;
|
||||
if (str.startsWith("ex")) return EXPLOSIONS;
|
||||
if (str.startsWith("fi")) return FIRESPREAD;
|
||||
//if (str.startsWith("l")) return LIGHTNING;
|
||||
if (str.startsWith("en")) return ENDERGRIEF;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,16 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
|
||||
/**
|
||||
@ -21,13 +25,18 @@ import com.massivecraft.factions.iface.RelationParticipator;
|
||||
*/
|
||||
public enum FPerm
|
||||
{
|
||||
BUILD("build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
BUILD("build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
PAINBUILD("painbuild", "edit but take damage", Rel.ALLY),
|
||||
DOOR("door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
BUTTON("button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
LEVER("lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
WITHDRAW("withdraw", "withdraw faction money", Rel.LEADER, Rel.OFFICER),
|
||||
DOOR("door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
BUTTON("button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
LEVER("lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
KICK("kick", "kick members", Rel.LEADER, Rel.OFFICER),
|
||||
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),
|
||||
DISBAND("disband", "disband the faction", Rel.LEADER),
|
||||
PERMS("perms", "manage permissions", Rel.LEADER),
|
||||
;
|
||||
|
||||
private final String nicename;
|
||||
@ -63,12 +72,17 @@ public enum FPerm
|
||||
{
|
||||
str = str.toLowerCase();
|
||||
if (str.startsWith("bui")) return BUILD;
|
||||
if (str.startsWith("p")) return PAINBUILD;
|
||||
if (str.startsWith("d")) return DOOR;
|
||||
if (str.startsWith("c")) return CONTAINER;
|
||||
if (str.startsWith("pa")) return PAINBUILD;
|
||||
if (str.startsWith("do")) return DOOR;
|
||||
if (str.startsWith("but")) return BUTTON;
|
||||
if (str.startsWith("l")) return LEVER;
|
||||
if (str.startsWith("w")) return WITHDRAW;
|
||||
if (str.startsWith("l")) return LEVER;
|
||||
if (str.startsWith("co")) return CONTAINER;
|
||||
if (str.startsWith("k")) return KICK;
|
||||
if (str.startsWith("s")) return SETHOME;
|
||||
if (str.startsWith("w")) return WITHDRAW;
|
||||
if (str.startsWith("t")) return TERRITORY;
|
||||
if (str.startsWith("di")) return DISBAND;
|
||||
if (str.startsWith("pe")) return PERMS;
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -145,44 +159,63 @@ public enum FPerm
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static final String errorpattern = "<b>%s<b> can't %s in the territory of %s<b>.";
|
||||
public boolean has(RelationParticipator testSubject, Faction hostFaction, boolean informIfNot)
|
||||
private static final String errorpattern = "%s<b> does not allow you to %s<b>.";
|
||||
public boolean has(Object testSubject, Faction hostFaction, boolean informIfNot)
|
||||
{
|
||||
//Faction factionDoer = RelationUtil.getFaction(testSubject);
|
||||
//P.p.log("Testing the permission "+this.toString()+" for a "+testSubject.getClass().getSimpleName());
|
||||
//P.p.log("hostFaction: "+hostFaction);
|
||||
Rel rel = testSubject.getRelationTo(hostFaction);
|
||||
if (testSubject instanceof ConsoleCommandSender) return true;
|
||||
|
||||
//P.p.log("rel: "+rel);
|
||||
RelationParticipator rpSubject = null;
|
||||
|
||||
if (testSubject instanceof Player)
|
||||
{
|
||||
rpSubject = FPlayers.i.get((Player)testSubject);
|
||||
}
|
||||
else if (testSubject instanceof RelationParticipator)
|
||||
{
|
||||
rpSubject = (RelationParticipator) testSubject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Rel rel = rpSubject.getRelationTo(hostFaction);
|
||||
|
||||
// TODO: Create better description messages like: "You must at least be officer".
|
||||
boolean ret = hostFaction.getPermittedRelations(this).contains(rel);
|
||||
|
||||
if (!ret && informIfNot && testSubject instanceof FPlayer)
|
||||
if (rpSubject instanceof FPlayer && ret == false && ((FPlayer)rpSubject).hasAdminMode()) ret = true;
|
||||
|
||||
if (!ret && informIfNot && rpSubject instanceof FPlayer)
|
||||
{
|
||||
FPlayer fplayer = (FPlayer)testSubject;
|
||||
fplayer.msg(errorpattern, fplayer.describeTo(fplayer, true), this.getDescription(), hostFaction.describeTo(fplayer));
|
||||
FPlayer fplayer = (FPlayer)rpSubject;
|
||||
fplayer.msg(errorpattern, hostFaction.describeTo(fplayer, true), this.getDescription());
|
||||
if (Permission.ADMIN.has(fplayer.getPlayer()))
|
||||
{
|
||||
fplayer.msg("<i>You can bypass by using " + P.p.cmdBase.cmdBypass.getUseageTemplate(false));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Faction hostFaction)
|
||||
public boolean has(Object testSubject, Faction hostFaction)
|
||||
{
|
||||
return this.has(testSubject, hostFaction, false);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc, boolean informIfNot)
|
||||
public boolean has(Object testSubject, FLocation floc, boolean informIfNot)
|
||||
{
|
||||
Faction factionThere = Board.getFactionAt(floc);
|
||||
return this.has(testSubject, factionThere, informIfNot);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Location loc, boolean informIfNot)
|
||||
public boolean has(Object testSubject, Location loc, boolean informIfNot)
|
||||
{
|
||||
FLocation floc = new FLocation(loc);
|
||||
return this.has(testSubject, floc, informIfNot);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Location loc)
|
||||
public boolean has(Object testSubject, Location loc)
|
||||
{
|
||||
return this.has(testSubject, loc, false);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc)
|
||||
public boolean has(Object testSubject, FLocation floc)
|
||||
{
|
||||
return this.has(testSubject, floc, false);
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package com.massivecraft.factions.struct;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
public enum Permission
|
||||
{
|
||||
LEADER("leader"),
|
||||
ADMIN("adminmode"),
|
||||
AUTOCLAIM("autoclaim"),
|
||||
BYPASS("bypass"),
|
||||
CHAT("chat"),
|
||||
CLAIM("claim"),
|
||||
CONFIG("config"),
|
||||
@ -16,39 +14,34 @@ public enum Permission
|
||||
DEINVITE("deinvite"),
|
||||
DESCRIPTION("description"),
|
||||
DISBAND("disband"),
|
||||
DISBAND_ANY("disband.any"), // WHAT TO DO?
|
||||
FLAG("flag"),
|
||||
FLAG_ANY("flag.any"),
|
||||
PERM("perm"),
|
||||
PERM_ANY("perm.any"),
|
||||
FLAG_SET("flag.set"),
|
||||
HELP("help"),
|
||||
HOME("home"),
|
||||
INVITE("invite"),
|
||||
JOIN("join"),
|
||||
KICK("kick"),
|
||||
KICK_ANY("kick.any"),
|
||||
LEADER("leader"),
|
||||
LEAVE("leave"),
|
||||
LIST("list"),
|
||||
LOCK("lock"),
|
||||
MAP("map"),
|
||||
OFFICER("officer"),
|
||||
MONEY_BALANCE("money.balance"),
|
||||
MONEY_BALANCE_ANY("money.balance.any"),
|
||||
MONEY_DEPOSIT("money.deposit"),
|
||||
MONEY_WITHDRAW("money.withdraw"),
|
||||
MONEY_WITHDRAW_ANY("money.withdraw.any"), // WHAT TO DO?
|
||||
MONEY_F2F("money.f2f"),
|
||||
MONEY_F2P("money.f2p"),
|
||||
MONEY_P2F("money.p2f"),
|
||||
MONEY_WITHDRAW("money.withdraw"),
|
||||
OFFICER("officer"),
|
||||
OPEN("open"),
|
||||
SET_PEACEFUL("setpeaceful"),
|
||||
PERM("perm"),
|
||||
POWER("power"),
|
||||
POWER_ANY("power.any"),
|
||||
RELATION("relation"),
|
||||
RELOAD("reload"),
|
||||
SAVE("save"),
|
||||
SETHOME("sethome"),
|
||||
SETHOME_ANY("sethome.any"), // WHAT TO DO?
|
||||
SHOW("show"),
|
||||
TAG("tag"),
|
||||
TITLE("title"),
|
||||
|
Loading…
Reference in New Issue
Block a user