This commit is contained in:
Olof Larsson 2011-10-23 22:08:57 +02:00
parent ac6870b770
commit 21783ef9d4
24 changed files with 149 additions and 712 deletions

View File

@ -25,16 +25,12 @@ permissions:
children: children:
factions.kit.halfmod: true factions.kit.halfmod: true
factions.disband.any: true factions.disband.any: true
factions.setpermanent: true
factions.setpeaceful: true
factions.sethome.any: true factions.sethome.any: true
factions.money.*: true factions.money.*: true
factions.kit.halfmod: factions.kit.halfmod:
description: Zones, bypassing, and kicking description: Zones, bypassing, and kicking
children: children:
factions.kit.fullplayer: true factions.kit.fullplayer: true
factions.managesafezone: true
factions.managewarzone: true
factions.bypass: true factions.bypass: true
factions.flag.any: true factions.flag.any: true
factions.kick.any: true factions.kick.any: true
@ -124,10 +120,6 @@ permissions:
description: see a list of the factions description: see a list of the factions
factions.lock: factions.lock:
description: lock all write stuff description: lock all write stuff
factions.managesafezone:
description: claim land as a safe zone and build/destroy within safe zones
factions.managewarzone:
description: claim land as a war zone and build/destroy within war zones
factions.map: factions.map:
description: show the territory map, and set optional auto update description: show the territory map, and set optional auto update
factions.officer: factions.officer:
@ -167,8 +159,6 @@ permissions:
factions.money.f2f: true factions.money.f2f: true
factions.money.f2p: true factions.money.f2p: true
factions.money.p2f: true factions.money.p2f: true
factions.noboom:
description: toggle explosions (peaceful factions only)
factions.open: factions.open:
description: switch if invitation is required to join description: switch if invitation is required to join
factions.owner: factions.owner:
@ -177,10 +167,6 @@ permissions:
description: list owner(s) of this claimed land description: list owner(s) of this claimed land
factions.ownershipbypass: factions.ownershipbypass:
description: bypass ownership restrictions within own faction's territory description: bypass ownership restrictions within own faction's territory
factions.setpeaceful:
description: designate a faction as peaceful
factions.setpermanent:
description: designate a faction as permanent
factions.power: factions.power:
description: show player power info description: show player power info
factions.power.any: factions.power.any:

View File

@ -218,14 +218,14 @@ public class Board
{ {
row += ChatColor.GRAY+"-"; row += ChatColor.GRAY+"-";
} }
else if (factionHere.isSafeZone()) /*else if (factionHere.isSafeZone())
{ {
row += Conf.colorPeaceful+"+"; row += Conf.colorPeaceful+"+";
} }
else if (factionHere.isWarZone()) else if (factionHere.isWarZone())
{ {
row += ChatColor.DARK_RED+"+"; row += ChatColor.DARK_RED+"+";
} }*/
else if else if
( (
factionHere == faction factionHere == faction

View File

@ -15,11 +15,12 @@ public class Conf
// Colors // Colors
public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorMember = ChatColor.GREEN;
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
public static ChatColor colorTruce = ChatColor.GOLD;
public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorNeutral = ChatColor.WHITE;
public static ChatColor colorEnemy = ChatColor.RED; public static ChatColor colorEnemy = ChatColor.RED;
public static ChatColor colorPeaceful = ChatColor.GOLD; //public static ChatColor colorPeaceful = ChatColor.GOLD;
public static ChatColor colorWar = ChatColor.DARK_RED; //public static ChatColor colorWar = ChatColor.DARK_RED;
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN; //public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
@ -143,6 +144,12 @@ public class Conf
public static boolean territoryAllyPainBuildWhenOffline = false; public static boolean territoryAllyPainBuildWhenOffline = false;
public static boolean territoryAllyDenyUseage = true; public static boolean territoryAllyDenyUseage = true;
public static boolean territoryAllyProtectMaterials = true; public static boolean territoryAllyProtectMaterials = true;
public static boolean territoryTruceDenyBuild = true;
public static boolean territoryTruceDenyBuildWhenOffline = true;
public static boolean territoryTrucePainBuild = false;
public static boolean territoryTrucePainBuildWhenOffline = false;
public static boolean territoryTruceDenyUseage = true;
public static boolean territoryTruceProtectMaterials = true;
public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepers = false;
public static boolean territoryBlockCreepersWhenOffline = false; public static boolean territoryBlockCreepersWhenOffline = false;
public static boolean territoryBlockFireballs = false; public static boolean territoryBlockFireballs = false;
@ -152,7 +159,7 @@ public class Conf
public static boolean territoryDenyEndermanBlocks = true; public static boolean territoryDenyEndermanBlocks = true;
public static boolean territoryDenyEndermanBlocksWhenOffline = true; public static boolean territoryDenyEndermanBlocksWhenOffline = true;
public static boolean safeZoneDenyBuild = true; /*public static boolean safeZoneDenyBuild = true;
public static boolean safeZoneDenyUseage = true; public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true; public static boolean safeZoneBlockTNT = true;
public static boolean safeZonePreventAllDamageToPlayers = false; public static boolean safeZonePreventAllDamageToPlayers = false;
@ -166,14 +173,15 @@ public class Conf
public static boolean warZonePowerLoss = true; public static boolean warZonePowerLoss = true;
public static boolean warZoneFriendlyFire = false; public static boolean warZoneFriendlyFire = false;
public static boolean warZoneDenyEndermanBlocks = true; public static boolean warZoneDenyEndermanBlocks = true;
*/
public static boolean wildernessDenyBuild = false; /*public static boolean wildernessDenyBuild = false;
public static boolean wildernessDenyUseage = false; public static boolean wildernessDenyUseage = false;
public static boolean wildernessBlockCreepers = false; public static boolean wildernessBlockCreepers = false;
public static boolean wildernessBlockFireballs = false; public static boolean wildernessBlockFireballs = false;
public static boolean wildernessBlockTNT = false; public static boolean wildernessBlockTNT = false;
public static boolean wildernessPowerLoss = true; public static boolean wildernessPowerLoss = true;
public static boolean wildernessDenyEndermanBlocks = false; public static boolean wildernessDenyEndermanBlocks = false;*/
// for claimed areas where further faction-member ownership can be defined // for claimed areas where further faction-member ownership can be defined
public static boolean ownedAreasEnabled = true; public static boolean ownedAreasEnabled = true;
@ -198,6 +206,7 @@ public class Conf
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
// TODO: Rename to monsterCreatureTypes
public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(CreatureType.class); public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(CreatureType.class);
// Spout features // Spout features
@ -257,6 +266,7 @@ public class Conf
public static Set<String> worldsNoClaiming = new HashSet<String>(); public static Set<String> worldsNoClaiming = new HashSet<String>();
public static Set<String> worldsNoPowerLoss = new HashSet<String>(); public static Set<String> worldsNoPowerLoss = new HashSet<String>();
public static Set<String> worldsIgnorePvP = new HashSet<String>(); public static Set<String> worldsIgnorePvP = new HashSet<String>();
// TODO: A better solution Would be to have One wilderness faction per world.
public static Set<String> worldsNoWildernessProtection = new HashSet<String>(); public static Set<String> worldsNoWildernessProtection = new HashSet<String>();
public static transient int mapHeight = 8; public static transient int mapHeight = 8;
@ -268,30 +278,12 @@ public class Conf
baseCommandAliases.add("f"); baseCommandAliases.add("f");
factionFlagDefaults = new LinkedHashMap<FactionFlag, Boolean>(); factionFlagDefaults = new LinkedHashMap<FactionFlag, Boolean>();
factionFlagDefaults.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultValue);
factionFlagDefaults.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultValue);
factionFlagIsChangeable = new LinkedHashMap<FactionFlag, Boolean>(); factionFlagIsChangeable = new LinkedHashMap<FactionFlag, Boolean>();
factionFlagIsChangeable.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultChangeable); for (FactionFlag flag : FactionFlag.values())
factionFlagIsChangeable.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultChangeable); {
factionFlagIsChangeable.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultChangeable); factionFlagDefaults.put(flag, flag.defaultDefaultValue);
factionFlagIsChangeable.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultChangeable); factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultChangeable); }
factionFlagIsChangeable.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultChangeable);
factionFlagIsChangeable.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultChangeable);
territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("home");
territoryEnemyDenyCommands.add("sethome"); territoryEnemyDenyCommands.add("sethome");

View File

@ -15,7 +15,6 @@ import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.FactionFlag; import com.massivecraft.factions.struct.FactionFlag;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.factions.zcore.persist.PlayerEntity; import com.massivecraft.factions.zcore.persist.PlayerEntity;
@ -78,38 +77,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
public void setAutoClaimFor(Faction faction) public void setAutoClaimFor(Faction faction)
{ {
this.autoClaimFor = faction; this.autoClaimFor = faction;
if (this.autoClaimFor != null)
{
// TODO: merge these into same autoclaim
this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false;
}
}
// FIELD: autoSafeZoneEnabled
private transient boolean autoSafeZoneEnabled;
public boolean isAutoSafeClaimEnabled() { return autoSafeZoneEnabled; }
public void setIsAutoSafeClaimEnabled(boolean enabled)
{
this.autoSafeZoneEnabled = enabled;
if (enabled)
{
this.autoClaimFor = null;
this.autoWarZoneEnabled = false;
}
}
// FIELD: autoWarZoneEnabled
private transient boolean autoWarZoneEnabled;
public boolean isAutoWarClaimEnabled() { return autoWarZoneEnabled; }
public void setIsAutoWarClaimEnabled(boolean enabled)
{
this.autoWarZoneEnabled = enabled;
if (enabled)
{
this.autoClaimFor = null;
this.autoSafeZoneEnabled = false;
}
} }
private transient boolean isAdminBypassing = false; private transient boolean isAdminBypassing = false;
@ -154,8 +121,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
this.lastLoginTime = System.currentTimeMillis(); this.lastLoginTime = System.currentTimeMillis();
this.mapAutoUpdating = false; this.mapAutoUpdating = false;
this.autoClaimFor = null; this.autoClaimFor = null;
this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false;
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
this.deleteMe = false; this.deleteMe = false;
@ -653,14 +618,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
{ {
return true; return true;
} }
else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
{
return true;
}
else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))
{
return true;
}
else if (myFaction != forFaction) else if (myFaction != forFaction)
{ {
error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this)); error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this));
@ -677,21 +634,13 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
{ {
error = P.p.txt.parse("Factions must have at least <h>%s<b> members to claim land.", Conf.claimsRequireMinFactionMembers); error = P.p.txt.parse("Factions must have at least <h>%s<b> members to claim land.", Conf.claimsRequireMinFactionMembers);
} }
else if (currentFaction.isSafeZone())
{
error = P.p.txt.parse("<b>You can not claim a Safe Zone.");
}
else if (currentFaction.isWarZone())
{
error = P.p.txt.parse("<b>You can not claim a War Zone.");
}
else if (ownedLand >= forFaction.getPowerRounded()) else if (ownedLand >= forFaction.getPowerRounded())
{ {
error = P.p.txt.parse("<b>You can't claim more land! You need more power!"); error = P.p.txt.parse("<b>You can't claim more land! You need more power!");
} }
else if (currentFaction.getRelationTo(forFaction) == Rel.ALLY) else if (currentFaction.getRelationTo(forFaction).isAtLeast(Rel.TRUCE))
{ {
error = P.p.txt.parse("<b>You can't claim the land of your allies."); error = P.p.txt.parse("<b>You can't claim this land due to your relation with the current owner.");
} }
else if else if
( (
@ -709,15 +658,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
} }
else if (currentFaction.isNormal()) else if (currentFaction.isNormal())
{ {
if (myFaction.isPeaceful()) if ( ! currentFaction.hasLandInflation())
{
error = P.p.txt.parse("%s<i> owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this));
}
else if (currentFaction.isPeaceful())
{
error = P.p.txt.parse("%s<i> owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this));
}
else if ( ! currentFaction.hasLandInflation())
{ {
// TODO more messages WARN current faction most importantly // TODO more messages WARN current faction most importantly
error = P.p.txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this)); error = P.p.txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
@ -748,7 +689,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
if ( ! this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false; if ( ! this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false;
// if economy is enabled and they're not on the bypass list, make 'em pay // if economy is enabled and they're not on the bypass list, make 'em pay
if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone()) // TODO: Add flag no costs??
//if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone())
if (Econ.shouldBeUsed() && ! this.isAdminBypassing())
{ {
double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal()); double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
//String costString = Econ.moneyString(cost); //String costString = Econ.moneyString(cost);

View File

@ -41,16 +41,16 @@ public class Faction extends Entity implements EconomyParticipator
// FIELD: peaceful // FIELD: peaceful
// "peaceful" status can only be set by server admins/moderators/ops, and prevents PvP and land capture to/from the faction // "peaceful" status can only be set by server admins/moderators/ops, and prevents PvP and land capture to/from the faction
private boolean peaceful; //private boolean peaceful;
public boolean isPeaceful() { return this.peaceful; } //public boolean isPeaceful() { return this.peaceful; }
public void setPeaceful(boolean isPeaceful) { this.peaceful = isPeaceful; } //public void setPeaceful(boolean isPeaceful) { this.peaceful = isPeaceful; }
// FIELD: peacefulExplosionsEnabled // FIELD: peacefulExplosionsEnabled
private boolean peacefulExplosionsEnabled; //private boolean peacefulExplosionsEnabled;
public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; } //public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; }
public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; } //public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; }
public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; } //public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; }
// FIELD: permanent // FIELD: permanent
// "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members // "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members
@ -163,8 +163,8 @@ public class Faction extends Entity implements EconomyParticipator
this.tag = "???"; this.tag = "???";
this.description = "Default faction description :("; this.description = "Default faction description :(";
this.lastPlayerLoggedOffTime = 0; this.lastPlayerLoggedOffTime = 0;
this.peaceful = false; //this.peaceful = false;
this.peacefulExplosionsEnabled = false; //this.peacefulExplosionsEnabled = false;
this.money = 0.0; this.money = 0.0;
this.flagOverrides = new LinkedHashMap<FactionFlag, Boolean>(); this.flagOverrides = new LinkedHashMap<FactionFlag, Boolean>();
} }
@ -173,9 +173,9 @@ public class Faction extends Entity implements EconomyParticipator
// Extra Getters And Setters // Extra Getters And Setters
// -------------------------------------------- // // -------------------------------------------- //
public boolean noPvPInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); } //public boolean noPvPInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); }
public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); } //public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); }
@ -187,7 +187,8 @@ public class Faction extends Entity implements EconomyParticipator
public boolean isNormal() public boolean isNormal()
{ {
return ! (this.isNone() || this.isSafeZone() || this.isWarZone()); //return ! (this.isNone() || this.isSafeZone() || this.isWarZone());
return ! this.isNone();
} }
public boolean isNone() public boolean isNone()
@ -195,7 +196,7 @@ public class Faction extends Entity implements EconomyParticipator
return this.getId().equals("0"); return this.getId().equals("0");
} }
public boolean isSafeZone() /*public boolean isSafeZone()
{ {
return this.getId().equals("-1"); return this.getId().equals("-1");
} }
@ -208,7 +209,7 @@ public class Faction extends Entity implements EconomyParticipator
public boolean isPlayerFreeType() public boolean isPlayerFreeType()
{ {
return this.isSafeZone() || this.isWarZone(); return this.isSafeZone() || this.isWarZone();
} }*/
// ------------------------------- // -------------------------------
@ -338,7 +339,7 @@ public class Faction extends Entity implements EconomyParticipator
public ArrayList<FPlayer> getFPlayers() public ArrayList<FPlayer> getFPlayers()
{ {
ArrayList<FPlayer> ret = new ArrayList<FPlayer>(); ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
if (this.isPlayerFreeType()) return ret; //if (this.isPlayerFreeType()) return ret;
for (FPlayer fplayer : FPlayers.i.get()) for (FPlayer fplayer : FPlayers.i.get())
{ {
@ -354,7 +355,7 @@ public class Faction extends Entity implements EconomyParticipator
public ArrayList<FPlayer> getFPlayersWhereOnline(boolean online) public ArrayList<FPlayer> getFPlayersWhereOnline(boolean online)
{ {
ArrayList<FPlayer> ret = new ArrayList<FPlayer>(); ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
if (this.isPlayerFreeType()) return ret; //if (this.isPlayerFreeType()) return ret;
for (FPlayer fplayer : FPlayers.i.get()) for (FPlayer fplayer : FPlayers.i.get())
{ {
@ -400,7 +401,7 @@ public class Faction extends Entity implements EconomyParticipator
public ArrayList<Player> getOnlinePlayers() public ArrayList<Player> getOnlinePlayers()
{ {
ArrayList<Player> ret = new ArrayList<Player>(); ArrayList<Player> ret = new ArrayList<Player>();
if (this.isPlayerFreeType()) return ret; //if (this.isPlayerFreeType()) return ret;
for (Player player: P.p.getServer().getOnlinePlayers()) for (Player player: P.p.getServer().getOnlinePlayers())
{ {
@ -418,7 +419,7 @@ public class Faction extends Entity implements EconomyParticipator
public boolean hasPlayersOnline() public boolean hasPlayersOnline()
{ {
// only real factions can have players online, not safe zone / war zone // only real factions can have players online, not safe zone / war zone
if (this.isPlayerFreeType()) return false; //if (this.isPlayerFreeType()) return false;
for (Player player: P.p.getServer().getOnlinePlayers()) for (Player player: P.p.getServer().getOnlinePlayers())
{ {

View File

@ -1,44 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.Permission;
public class CmdBoom extends FCommand
{
public CmdBoom()
{
super();
this.aliases.add("noboom");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip");
this.permission = Permission.NO_BOOM.node;
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = true;
senderMustBeLeader = false;
}
@Override
public void perform()
{
if ( ! myFaction.isPeaceful())
{
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful.");
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.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return;
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
// Inform
myFaction.msg("%s<i> has "+enabled+" explosions in your faction's territory.", fme.describeTo(myFaction));
}
}

View File

@ -113,7 +113,6 @@ public class CmdHelp extends FCommand
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) );
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so")); pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
@ -125,6 +124,7 @@ public class CmdHelp extends FCommand
pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) );
pageLines.add(""); pageLines.add("");
pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdRelationTruce.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) );
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction.")); pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
@ -163,15 +163,11 @@ public class CmdHelp extends FCommand
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone")); pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone")); pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
pageLines.add(p.txt.parse("<c>/f autoclaim [safezone|warzone] <i>take a guess")); pageLines.add(p.txt.parse("<c>/f autoclaim [safezone|warzone] <i>take a guess"));
pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate(true) );
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well.")); pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) );
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add(p.txt.parse("<i>More commands for server admins:")); pageLines.add(p.txt.parse("<i>More commands for server admins:"));
pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) );
pageLines.add(p.txt.parse("<i>Peaceful factions are protected from PvP and land capture.")); pageLines.add(p.txt.parse("<i>Peaceful factions are protected from PvP and land capture."));
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );

View File

@ -13,6 +13,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.FactionFlag;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.zcore.util.SmokeUtil; import com.massivecraft.factions.zcore.util.SmokeUtil;
@ -79,7 +80,7 @@ public class CmdHome extends FCommand
( (
Conf.homesTeleportAllowedEnemyDistance > 0 Conf.homesTeleportAllowedEnemyDistance > 0
&& &&
! faction.isSafeZone() faction.getFlag(FactionFlag.PVP)
&& &&
( (
! fme.isInOwnTerritory() ! fme.isInOwnTerritory()

View File

@ -1,63 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
public class CmdPeaceful extends FCommand
{
public CmdPeaceful()
{
super();
this.aliases.add("peaceful");
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.SET_PEACEFUL.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
Faction faction = this.argAsFaction(0);
if (faction == null) return;
String change;
if (faction.isPeaceful())
{
change = "removed peaceful status from";
faction.setPeaceful(false);
}
else
{
change = "granted peaceful status to";
faction.setPeaceful(true);
}
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == faction)
{
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" your faction.");
}
else
{
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "<i>\".");
}
}
SpoutFeatures.updateAppearances(faction);
}
}

View File

@ -6,7 +6,7 @@ public class CmdRelationTruce extends FRelationCommand
{ {
public CmdRelationTruce() public CmdRelationTruce()
{ {
aliases.add("neutral"); aliases.add("truce");
targetRelation = Rel.NEUTRAL; targetRelation = Rel.TRUCE;
} }
} }

View File

@ -1,41 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdSafeunclaimall extends FCommand
{
public CmdSafeunclaimall()
{
this.aliases.add("safeunclaimall");
this.aliases.add("safedeclaimall");
//this.requiredArgs.add("");
//this.optionalArgs.put("radius", "0");
this.permission = Permission.MANAGE_SAFE_ZONE.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
this.setHelpShort("Unclaim all safezone land");
}
@Override
public void perform()
{
Board.unclaimAll(Factions.i.getSafeZone().getId());
msg("<i>You unclaimed ALL safe zone land.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed all safe zones.");
}
}

View File

@ -56,9 +56,9 @@ public class CmdShow extends FCommand
} }
String peaceStatus = ""; String peaceStatus = "";
if (faction.isPeaceful()) if (faction.getFlag(FactionFlag.PEACEFUL))
{ {
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful"; peaceStatus = " "+Conf.colorTruce+"This faction is Peaceful";
} }
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);

View File

@ -35,41 +35,6 @@ public class CmdUnclaim extends FCommand
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
Faction otherFaction = Board.getFactionAt(flocation); Faction otherFaction = Board.getFactionAt(flocation);
if (otherFaction.isSafeZone())
{
if (Permission.MANAGE_SAFE_ZONE.has(sender))
{
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>Safe zone was unclaimed.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
}
else
{
msg("<b>This is a safe zone. You lack permissions to unclaim.");
}
return;
}
else if (otherFaction.isWarZone())
{
if (Permission.MANAGE_WAR_ZONE.has(sender))
{
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>War zone was unclaimed.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
}
else
{
msg("<b>This is a war zone. You lack permissions to unclaim.");
}
return;
}
if (fme.isAdminBypassing()) if (fme.isAdminBypassing())
{ {
Board.removeAt(flocation); Board.removeAt(flocation);
@ -114,52 +79,6 @@ public class CmdUnclaim extends FCommand
{ {
if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return; if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return;
} }
/*
// a real refund
if (refund > 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+"<i> received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
else
{
Econ.addMoney(fme.getName(), refund);
moneyBack = " They received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
}
// wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
if(!faction.removeMoney(-refund))
{
msg("<b>Unclaiming this land will cost <h>%s<b> which your faction can't currently afford.", Econ.moneyString(-refund));
return;
}
moneyBack = " It cost "+faction.getTag()+" <h>"+Econ.moneyString(refund)+"<i>.";
}
else
{
if (!Econ.deductMoney(fme.getName(), -refund))
{
msg("<b>Unclaiming this land will cost <h>%s<b> which you can't currently afford.", Econ.moneyString(-refund));
return;
}
moneyBack = " It cost them <h>"+Econ.moneyString(refund)+"<i>.";
}
}
// no refund
else
{
moneyBack = "";
}
*/
} }
Board.removeAt(flocation); Board.removeAt(flocation);

View File

@ -1,41 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdWarunclaimall extends FCommand
{
public CmdWarunclaimall()
{
this.aliases.add("warunclaimall");
this.aliases.add("wardeclaimall");
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.MANAGE_WAR_ZONE.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
this.setHelpShort("unclaim all warzone land");
}
@Override
public void perform()
{
Board.unclaimAll(Factions.i.getWarZone().getId());
msg("<i>You unclaimed ALL war zone land.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed all war zones.");
}
}

View File

@ -8,7 +8,6 @@ public class FCmdRoot extends FCommand
{ {
public CmdLeader cmdLeader = new CmdLeader(); public CmdLeader cmdLeader = new CmdLeader();
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
public CmdBoom cmdBoom = new CmdBoom();
public CmdBypass cmdBypass = new CmdBypass(); public CmdBypass cmdBypass = new CmdBypass();
public CmdChat cmdChat = new CmdChat(); public CmdChat cmdChat = new CmdChat();
public CmdClaim cmdClaim = new CmdClaim(); public CmdClaim cmdClaim = new CmdClaim();
@ -32,13 +31,12 @@ public class FCmdRoot extends FCommand
public CmdOpen cmdOpen = new CmdOpen(); public CmdOpen cmdOpen = new CmdOpen();
public CmdOwner cmdOwner = new CmdOwner(); public CmdOwner cmdOwner = new CmdOwner();
public CmdOwnerList cmdOwnerList = new CmdOwnerList(); public CmdOwnerList cmdOwnerList = new CmdOwnerList();
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
public CmdPower cmdPower = new CmdPower(); public CmdPower cmdPower = new CmdPower();
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly(); public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral();
public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce();
public CmdReload cmdReload = new CmdReload(); public CmdReload cmdReload = new CmdReload();
public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall();
public CmdSaveAll cmdSaveAll = new CmdSaveAll(); public CmdSaveAll cmdSaveAll = new CmdSaveAll();
public CmdSethome cmdSethome = new CmdSethome(); public CmdSethome cmdSethome = new CmdSethome();
public CmdShow cmdShow = new CmdShow(); public CmdShow cmdShow = new CmdShow();
@ -47,7 +45,6 @@ public class FCmdRoot extends FCommand
public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaim cmdUnclaim = new CmdUnclaim();
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
public CmdVersion cmdVersion = new CmdVersion(); public CmdVersion cmdVersion = new CmdVersion();
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
public FCmdRoot() public FCmdRoot()
{ {
@ -73,7 +70,6 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdLeader); this.addSubCommand(this.cmdLeader);
this.addSubCommand(this.cmdAutoClaim); this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdBoom);
this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdChat);
this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdClaim);
@ -97,13 +93,12 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOpen);
this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwner);
this.addSubCommand(this.cmdOwnerList); this.addSubCommand(this.cmdOwnerList);
this.addSubCommand(this.cmdPeaceful);
this.addSubCommand(this.cmdPower); this.addSubCommand(this.cmdPower);
this.addSubCommand(this.cmdRelationAlly); this.addSubCommand(this.cmdRelationAlly);
this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationEnemy);
this.addSubCommand(this.cmdRelationNeutral); this.addSubCommand(this.cmdRelationNeutral);
this.addSubCommand(this.cmdRelationTruce);
this.addSubCommand(this.cmdReload); this.addSubCommand(this.cmdReload);
this.addSubCommand(this.cmdSafeunclaimall);
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSaveAll);
this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdShow); this.addSubCommand(this.cmdShow);
@ -112,7 +107,6 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdUnclaim); this.addSubCommand(this.cmdUnclaim);
this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdUnclaimall);
this.addSubCommand(this.cmdVersion); this.addSubCommand(this.cmdVersion);
this.addSubCommand(this.cmdWarunclaimall);
} }
@Override @Override

View File

@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.FactionFlag;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
@ -63,13 +64,13 @@ public abstract class FRelationCommand extends FCommand
myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation); myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
} }
if ( targetRelation != Rel.NEUTRAL && them.isPeaceful()) if ( targetRelation != Rel.NEUTRAL && them.getFlag(FactionFlag.PEACEFUL))
{ {
them.msg("<i>This will have no effect while your faction is peaceful."); them.msg("<i>This will have no effect while your faction is peaceful.");
myFaction.msg("<i>This will have no effect while their faction is peaceful."); myFaction.msg("<i>This will have no effect while their faction is peaceful.");
} }
if ( targetRelation != Rel.NEUTRAL && myFaction.isPeaceful()) if ( targetRelation != Rel.NEUTRAL && myFaction.getFlag(FactionFlag.PEACEFUL))
{ {
them.msg("<i>This will have no effect while their faction is peaceful."); them.msg("<i>This will have no effect while their faction is peaceful.");
myFaction.msg("<i>This will have no effect while your faction is peaceful."); myFaction.msg("<i>This will have no effect while your faction is peaceful.");

View File

@ -267,7 +267,7 @@ public class SpoutFeatures
{ {
// yeah, no cape if no faction // yeah, no cape if no faction
} }
else if (viewedFaction.isPeaceful()) else if (relation == Rel.TRUCE)
cape = Conf.capePeaceful; cape = Conf.capePeaceful;
else if (relation == Rel.NEUTRAL) else if (relation == Rel.NEUTRAL)
cape = Conf.capeNeutral; cape = Conf.capeNeutral;

View File

@ -18,7 +18,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
@ -129,28 +128,6 @@ public class FactionsBlockListener extends BlockListener
if (pistonFaction == otherFaction) if (pistonFaction == otherFaction)
return true; return true;
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()))
return true;
return false;
}
else if (otherFaction.isSafeZone())
{
if ( ! Conf.safeZoneDenyBuild)
return true;
return false;
}
else if (otherFaction.isWarZone())
{
if ( ! Conf.warZoneDenyBuild)
return true;
return false;
}
Rel rel = pistonFaction.getRelationTo(otherFaction); Rel rel = pistonFaction.getRelationTo(otherFaction);
if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) if (rel.confDenyBuild(otherFaction.hasPlayersOnline()))
@ -169,37 +146,6 @@ public class FactionsBlockListener extends BlockListener
FLocation loc = new FLocation(location); FLocation loc = new FLocation(location);
Faction otherFaction = Board.getFactionAt(loc); Faction otherFaction = Board.getFactionAt(loc);
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true; // This is not faction territory. Use whatever you like here.
if (!justCheck)
me.msg("<b>You can't "+action+" in the wilderness.");
return false;
}
else if (otherFaction.isSafeZone())
{
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
return true;
if (!justCheck)
me.msg("<b>You can't "+action+" in a safe zone.");
return false;
}
else if (otherFaction.isWarZone())
{
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
return true;
if (!justCheck)
me.msg("<b>You can't "+action+" in a war zone.");
return false;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Rel rel = myFaction.getRelationTo(otherFaction); Rel rel = myFaction.getRelationTo(otherFaction);
boolean online = otherFaction.hasPlayersOnline(); boolean online = otherFaction.hasPlayersOnline();

View File

@ -3,9 +3,7 @@ package com.massivecraft.factions.listeners;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
@ -28,6 +26,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.FactionFlag;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
@ -44,42 +43,24 @@ public class FactionsEntityListener extends EntityListener
public void onEntityDeath(EntityDeathEvent event) public void onEntityDeath(EntityDeathEvent event)
{ {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if ( ! (entity instanceof Player)) if ( ! (entity instanceof Player)) return;
{
return;
}
Player player = (Player) entity; Player player = (Player) entity;
FPlayer fplayer = FPlayers.i.get(player); FPlayer fplayer = FPlayers.i.get(player);
Faction faction = Board.getFactionAt(new FLocation(player.getLocation())); Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
if (faction.isWarZone())
if ( ! faction.getFlag(FactionFlag.POWERLOSS))
{ {
// war zones always override worldsNoPowerLoss either way, thus this layout fplayer.msg("<i>You didn't lose any power since the territory you died in works that way.");
if (! Conf.warZonePowerLoss)
{
fplayer.msg("<i>You didn't lose any power since you were in a war zone.");
return;
}
if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName()))
{
fplayer.msg("<b>The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.");
}
}
else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName()))
{
fplayer.msg("<i>You didn't lose any power since you were in the wilderness.");
return; return;
} }
else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName()))
if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName()))
{ {
fplayer.msg("<i>You didn't lose any power due to the world you died in."); fplayer.msg("<i>You didn't lose any power due to the world you died in.");
return; return;
} }
else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful())
{
fplayer.msg("<i>You didn't lose any power since you are in a peaceful faction.");
return;
}
fplayer.onDeath(); fplayer.onDeath();
fplayer.msg("<i>Your power is now <h>"+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded()); fplayer.msg("<i>Your power is now <h>"+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded());
} }
@ -103,11 +84,12 @@ public class FactionsEntityListener extends EntityListener
event.setCancelled(true); event.setCancelled(true);
} }
} }
else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) // TODO: Add a no damage at all flag??
/*else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity()))
{ {
// Players can not take any damage in a Safe Zone // Players can not take any damage in a Safe Zone
event.setCancelled(true); event.setCancelled(true);
} }*/
} }
@Override @Override
@ -119,87 +101,14 @@ public class FactionsEntityListener extends EntityListener
Faction faction = Board.getFactionAt(new FLocation(loc)); Faction faction = Board.getFactionAt(new FLocation(loc));
if (faction.noExplosionsInTerritory()) if (faction.getFlag(FactionFlag.EXPLOSIONS) == false)
{ {
// faction is peaceful and has explosions set to disabled // faction is peaceful and has explosions set to disabled
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
boolean online = faction.hasPlayersOnline();
if
(
event.getEntity() instanceof Creeper
&&
(
(faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
||
(faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline))
||
(faction.isWarZone() && Conf.warZoneBlockCreepers)
||
faction.isSafeZone()
)
)
{
// creeper which needs prevention
event.setCancelled(true);
}
else if
(
event.getEntity() instanceof Fireball
&&
(
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
||
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
||
faction.isSafeZone()
)
)
{
// ghast fireball which needs prevention
event.setCancelled(true);
}
else if
(
(
faction.isNone()
&&
Conf.wildernessBlockTNT
&&
! Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())
)
||
(
faction.isNormal()
&&
(
online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline
)
)
||
(
faction.isWarZone()
&&
Conf.warZoneBlockTNT
)
||
(
faction.isSafeZone()
&&
Conf.safeZoneBlockTNT
)
)
{
// we'll assume it's TNT, which needs prevention
event.setCancelled(true);
}
} }
/*
public boolean isPlayerInSafeZone(Entity damagee) public boolean isPlayerInSafeZone(Entity damagee)
{ {
if ( ! (damagee instanceof Player)) if ( ! (damagee instanceof Player))
@ -212,7 +121,7 @@ public class FactionsEntityListener extends EntityListener
} }
return false; return false;
} }
*/
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub)
{ {
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
@ -247,14 +156,16 @@ public class FactionsEntityListener extends EntityListener
} }
// Players can not take attack damage in a SafeZone, or possibly peaceful territory // Players can not take attack damage in a SafeZone, or possibly peaceful territory
if (defLocFaction.noPvPInTerritory()) {
if (defLocFaction.getFlag(FactionFlag.PVP) == false)
{
if (damager instanceof Player) if (damager instanceof Player)
{ {
FPlayer attacker = FPlayers.i.get((Player)damager); FPlayer attacker = FPlayers.i.get((Player)damager);
attacker.msg("<i>You can't hurt other players in "+(defLocFaction.isSafeZone() ? "a SafeZone." : "peaceful territory.")); attacker.msg("<i>You can't hurt other players here.");
return false; return false;
} }
return !defLocFaction.noMonstersInTerritory(); return defLocFaction.getFlag(FactionFlag.MONSTERS);
} }
if ( ! (damager instanceof Player)) if ( ! (damager instanceof Player))
@ -278,15 +189,11 @@ public class FactionsEntityListener extends EntityListener
Faction locFaction = Board.getFactionAt(new FLocation(attacker)); Faction locFaction = Board.getFactionAt(new FLocation(attacker));
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
if (locFaction.noPvPInTerritory()) if (locFaction.getFlag(FactionFlag.PVP) == false)
{ {
attacker.msg("<i>You can't hurt other players while you are in "+(locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory.")); attacker.msg("<i>You can't hurt other players here.");
return false; return false;
} }
else if (locFaction.isWarZone() && Conf.warZoneFriendlyFire)
{
return true;
}
Faction defendFaction = defender.getFaction(); Faction defendFaction = defender.getFaction();
Faction attackFaction = attacker.getFaction(); Faction attackFaction = attacker.getFaction();
@ -310,17 +217,6 @@ public class FactionsEntityListener extends EntityListener
} }
} }
if (defendFaction.isPeaceful())
{
attacker.msg("<i>You can't hurt players who are in a peaceful faction.");
return false;
}
else if (attackFaction.isPeaceful())
{
attacker.msg("<i>You can't hurt players while you are in a peaceful faction.");
return false;
}
Rel relation = defendFaction.getRelationTo(attackFaction); Rel relation = defendFaction.getRelationTo(attackFaction);
// You can not hurt neutral factions // You can not hurt neutral factions
@ -370,15 +266,16 @@ public class FactionsEntityListener extends EntityListener
@Override @Override
public void onCreatureSpawn(CreatureSpawnEvent event) public void onCreatureSpawn(CreatureSpawnEvent event)
{ {
if (event.isCancelled() || event.getLocation() == null) if (event.isCancelled()) return;
{ if (event.getLocation() == null) return;
return;
}
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getCreatureType()) && Board.getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) FLocation floc = new FLocation(event.getLocation());
{ Faction faction = Board.getFactionAt(floc);
event.setCancelled(true);
} if (faction.getFlag(FactionFlag.MONSTERS)) return;
if ( ! Conf.safeZoneNerfedCreatureTypes.contains(event.getCreatureType())) return;
event.setCancelled(true);
} }
@Override @Override
@ -388,22 +285,17 @@ public class FactionsEntityListener extends EntityListener
// if there is a target // if there is a target
Entity target = event.getTarget(); Entity target = event.getTarget();
if (target == null) if (target == null) return;
{
return;
}
// We are interested in blocking targeting for certain mobs: // We are interested in blocking targeting for certain mobs:
if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return;
{
return;
}
// in case the target is in a safe zone. FLocation floc = new FLocation(target.getLocation());
if (Board.getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) Faction faction = Board.getFactionAt(floc);
{
event.setCancelled(true); if (faction.getFlag(FactionFlag.MONSTERS)) return;
}
event.setCancelled(true);
} }
@Override @Override
@ -444,10 +336,12 @@ public class FactionsEntityListener extends EntityListener
{ {
if (event.isCancelled()) return; if (event.isCancelled()) return;
if (stopEndermanBlockManipulation(event.getBlock().getLocation())) FLocation floc = new FLocation(event.getBlock());
{ Faction faction = Board.getFactionAt(floc);
event.setCancelled(true);
} if (faction.getFlag(FactionFlag.ENDERGRIEF)) return;
event.setCancelled(true);
} }
@Override @Override
@ -455,13 +349,15 @@ public class FactionsEntityListener extends EntityListener
{ {
if (event.isCancelled()) return; if (event.isCancelled()) return;
if (stopEndermanBlockManipulation(event.getLocation())) FLocation floc = new FLocation(event.getLocation());
{ Faction faction = Board.getFactionAt(floc);
event.setCancelled(true);
} if (faction.getFlag(FactionFlag.ENDERGRIEF)) return;
event.setCancelled(true);
} }
private boolean stopEndermanBlockManipulation(Location loc) /*private boolean stopEndermanBlockManipulation(Location loc)
{ {
if (loc == null) if (loc == null)
{ {
@ -505,5 +401,5 @@ public class FactionsEntityListener extends EntityListener
} }
return false; return false;
} }*/
} }

View File

@ -28,10 +28,8 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
@ -257,40 +255,6 @@ public class FactionsPlayerListener extends PlayerListener
{ {
me.attemptClaim(me.getAutoClaimFor(), player.getLocation(), true); me.attemptClaim(me.getAutoClaimFor(), player.getLocation(), true);
} }
else if (me.isAutoSafeClaimEnabled())
{
if ( ! Permission.MANAGE_SAFE_ZONE.has(player))
{
me.setIsAutoSafeClaimEnabled(false);
}
else
{
FLocation playerFlocation = new FLocation(me);
if (!Board.getFactionAt(playerFlocation).isSafeZone())
{
Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation);
me.msg("<i>This land is now a safe zone.");
}
}
}
else if (me.isAutoWarClaimEnabled())
{
if ( ! Permission.MANAGE_WAR_ZONE.has(player))
{
me.setIsAutoWarClaimEnabled(false);
}
else
{
FLocation playerFlocation = new FLocation(me);
if (!Board.getFactionAt(playerFlocation).isWarZone())
{
Board.setFactionAt(Factions.i.getWarZone(), playerFlocation);
me.msg("<i>This land is now a war zone.");
}
}
}
} }
@Override @Override
@ -324,6 +288,8 @@ public class FactionsPlayerListener extends PlayerListener
} }
} }
// TODO: Improve with the... system for... Permissions
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck)
{ {
FPlayer me = FPlayers.i.get(player); FPlayer me = FPlayers.i.get(player);
@ -344,37 +310,6 @@ public class FactionsPlayerListener extends PlayerListener
return true; // Item isn't one we're preventing for offline factions. return true; // Item isn't one we're preventing for offline factions.
} }
if (otherFaction.isNone())
{
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true; // This is not faction territory. Use whatever you like here.
if (!justCheck)
me.msg("<b>You can't use <h>%s<b> in the wilderness.", TextUtil.getMaterialName(material));
return false;
}
else if (otherFaction.isSafeZone())
{
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player))
return true;
if (!justCheck)
me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material));
return false;
}
else if (otherFaction.isWarZone())
{
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player))
return true;
if (!justCheck)
me.msg("<b>You can't use <h>%s<b> in a war zone.", TextUtil.getMaterialName(material));
return false;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Rel rel = myFaction.getRelationTo(otherFaction); Rel rel = myFaction.getRelationTo(otherFaction);

View File

@ -56,7 +56,9 @@ public enum FactionFlag
*/ */
public boolean getDefault() public boolean getDefault()
{ {
return Conf.factionFlagDefaults.get(this); Boolean ret = Conf.factionFlagDefaults.get(this);
if (ret == null) return this.defaultDefaultValue;
return ret;
} }
/** /**
@ -66,7 +68,9 @@ public enum FactionFlag
*/ */
public boolean isChangeable() public boolean isChangeable()
{ {
return Conf.factionFlagIsChangeable.get(this); Boolean ret = Conf.factionFlagIsChangeable.get(this);
if (ret == null) return this.defaultDefaultChangeable;
return ret;
} }
public static FactionFlag parse(String str) public static FactionFlag parse(String str)

View File

@ -6,8 +6,6 @@ import com.massivecraft.factions.P;
public enum Permission public enum Permission
{ {
MANAGE_SAFE_ZONE("managesafezone"),
MANAGE_WAR_ZONE("managewarzone"),
OWNERSHIP_BYPASS("ownershipbypass"), OWNERSHIP_BYPASS("ownershipbypass"),
LEADER("leader"), LEADER("leader"),
AUTOCLAIM("autoclaim"), AUTOCLAIM("autoclaim"),

View File

@ -6,13 +6,13 @@ import com.massivecraft.factions.Conf;
public enum Rel public enum Rel
{ {
LEADER (70, "leader"), LEADER (70, "leader"),
OFFICER(60, "officer"), OFFICER (60, "officer"),
MEMBER (50, "member"), MEMBER (50, "member"),
ALLY (40, "ally"), ALLY (40, "ally"),
TRUCE (30, "truce"), TRUCE (30, "truce"),
NEUTRAL(20, "neutral"), NEUTRAL (20, "neutral"),
ENEMY (10, "enemy"), ENEMY (10, "enemy"),
; ;
public final int value; public final int value;
@ -87,6 +87,8 @@ public enum Rel
return Conf.colorAlly; return Conf.colorAlly;
else if (this == NEUTRAL) else if (this == NEUTRAL)
return Conf.colorNeutral; return Conf.colorNeutral;
else if (this == TRUCE)
return Conf.colorTruce;
else else
return Conf.colorEnemy; return Conf.colorEnemy;
} }
@ -107,6 +109,7 @@ public enum Rel
} }
// TODO: ADD TRUCE!!!! // TODO: ADD TRUCE!!!!
// TODO.... or remove it...
public double getRelationCost() public double getRelationCost()
{ {
if (this == ENEMY) if (this == ENEMY)
@ -129,6 +132,8 @@ public enum Rel
return Conf.territoryEnemyDenyBuild; return Conf.territoryEnemyDenyBuild;
else if (this == ALLY) else if (this == ALLY)
return Conf.territoryAllyDenyBuild; return Conf.territoryAllyDenyBuild;
else if (this == TRUCE)
return Conf.territoryTruceDenyBuild;
else else
return Conf.territoryDenyBuild; return Conf.territoryDenyBuild;
} }
@ -138,6 +143,8 @@ public enum Rel
return Conf.territoryEnemyDenyBuildWhenOffline; return Conf.territoryEnemyDenyBuildWhenOffline;
else if (this == ALLY) else if (this == ALLY)
return Conf.territoryAllyDenyBuildWhenOffline; return Conf.territoryAllyDenyBuildWhenOffline;
else if (this == TRUCE)
return Conf.territoryTruceDenyBuildWhenOffline;
else else
return Conf.territoryDenyBuildWhenOffline; return Conf.territoryDenyBuildWhenOffline;
} }
@ -155,6 +162,8 @@ public enum Rel
return Conf.territoryEnemyPainBuild; return Conf.territoryEnemyPainBuild;
else if (this == ALLY) else if (this == ALLY)
return Conf.territoryAllyPainBuild; return Conf.territoryAllyPainBuild;
else if (this == TRUCE)
return Conf.territoryTrucePainBuild;
else else
return Conf.territoryPainBuild; return Conf.territoryPainBuild;
} }
@ -164,6 +173,8 @@ public enum Rel
return Conf.territoryEnemyPainBuildWhenOffline; return Conf.territoryEnemyPainBuildWhenOffline;
else if (this == ALLY) else if (this == ALLY)
return Conf.territoryAllyPainBuildWhenOffline; return Conf.territoryAllyPainBuildWhenOffline;
else if (this == TRUCE)
return Conf.territoryTrucePainBuildWhenOffline;
else else
return Conf.territoryPainBuildWhenOffline; return Conf.territoryPainBuildWhenOffline;
} }
@ -178,6 +189,8 @@ public enum Rel
return Conf.territoryEnemyDenyUseage; return Conf.territoryEnemyDenyUseage;
else if (this == ALLY) else if (this == ALLY)
return Conf.territoryAllyDenyUseage; return Conf.territoryAllyDenyUseage;
else if (this == TRUCE)
return Conf.territoryTruceDenyUseage;
else else
return Conf.territoryDenyUseage; return Conf.territoryDenyUseage;
} }

View File

@ -2,10 +2,10 @@ package com.massivecraft.factions.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.struct.FactionFlag;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
@ -90,9 +90,9 @@ public class RelationUtil
return Rel.MEMBER; return Rel.MEMBER;
} }
if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) if (!ignorePeaceful && (fme.getFlag(FactionFlag.PEACEFUL) || fthat.getFlag(FactionFlag.PEACEFUL)))
{ {
return Rel.NEUTRAL; return Rel.TRUCE;
} }
if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value)
@ -121,8 +121,9 @@ public class RelationUtil
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me)
{ {
Faction thatFaction = getFaction(that); //Faction thatFaction = getFaction(that);
if (thatFaction != null) // TODO: Add special colors to zone as a feature to replace this one
/*if (thatFaction != null)
{ {
if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) if (thatFaction.isPeaceful() && thatFaction != getFaction(me))
{ {
@ -138,7 +139,7 @@ public class RelationUtil
{ {
return Conf.colorWar; return Conf.colorWar;
} }
} }*/
return getRelationTo(that, me).getColor(); return getRelationTo(that, me).getColor();
} }