REMOVED owned plots
This commit is contained in:
parent
958a1e0d9f
commit
e3821a8d4e
@ -42,8 +42,6 @@ public class Board
|
||||
|
||||
public static void setIdAt(String id, FLocation flocation)
|
||||
{
|
||||
clearOwnershipAt(flocation);
|
||||
|
||||
if (id == "0")
|
||||
{
|
||||
removeAt(flocation);
|
||||
@ -59,28 +57,11 @@ public class Board
|
||||
|
||||
public static void removeAt(FLocation flocation)
|
||||
{
|
||||
clearOwnershipAt(flocation);
|
||||
flocationIds.remove(flocation);
|
||||
}
|
||||
|
||||
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
||||
public static void clearOwnershipAt(FLocation flocation)
|
||||
{
|
||||
Faction faction = getFactionAt(flocation);
|
||||
if (faction != null && faction.isNormal())
|
||||
{
|
||||
faction.clearClaimOwnership(flocation);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unclaimAll(String factionId)
|
||||
{
|
||||
Faction faction = Factions.i.get(factionId);
|
||||
if (faction != null && faction.isNormal())
|
||||
{
|
||||
faction.clearAllClaimOwnership();
|
||||
}
|
||||
|
||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.*;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FactionPerm;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class Conf
|
||||
@ -25,17 +25,9 @@ public class Conf
|
||||
//public static ChatColor colorWar = ChatColor.DARK_RED;
|
||||
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
||||
|
||||
|
||||
// REFACTOR ASJDKJASDKFJKASDF
|
||||
public static Map<FactionFlag, Boolean> factionFlagDefaults;
|
||||
public static Map<FactionFlag, Boolean> factionFlagIsChangeable;
|
||||
public static Map<FactionPerm, Set<Rel>> factionPermDefaults;
|
||||
|
||||
|
||||
// REFACTOR ASJDKJASDKFJKASDF EEEEEENNNNDD
|
||||
|
||||
|
||||
|
||||
public static Map<FPerm, Set<Rel>> factionPermDefaults;
|
||||
|
||||
// Power
|
||||
public static double powerPlayerMax = 10.0;
|
||||
@ -124,14 +116,14 @@ public class Conf
|
||||
|
||||
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
|
||||
|
||||
public static int actionDeniedPainAmount = 1;
|
||||
public static int actionDeniedPainAmount = 2;
|
||||
|
||||
// commands which will be prevented when in claimed territory of another faction
|
||||
public static Set<String> territoryNeutralDenyCommands = new HashSet<String>();
|
||||
public static Set<String> territoryEnemyDenyCommands = new HashSet<String>();
|
||||
|
||||
public static double territoryShieldFactor = 0.3;
|
||||
public static boolean territoryDenyBuild = true;
|
||||
/*public static boolean territoryDenyBuild = true;
|
||||
public static boolean territoryDenyBuildWhenOffline = true;
|
||||
public static boolean territoryPainBuild = false;
|
||||
public static boolean territoryPainBuildWhenOffline = false;
|
||||
@ -161,7 +153,7 @@ public class Conf
|
||||
public static boolean territoryBlockTNT = false;
|
||||
public static boolean territoryBlockTNTWhenOffline = false;
|
||||
public static boolean territoryDenyEndermanBlocks = true;
|
||||
public static boolean territoryDenyEndermanBlocksWhenOffline = true;
|
||||
public static boolean territoryDenyEndermanBlocksWhenOffline = true;*/
|
||||
|
||||
/*public static boolean safeZoneDenyBuild = true;
|
||||
public static boolean safeZoneDenyUseage = true;
|
||||
@ -205,13 +197,16 @@ public class Conf
|
||||
|
||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
||||
|
||||
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryDenyUseageMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||
public final transient static Set<Material> materialsEditOnInteract = EnumSet.noneOf(Material.class);
|
||||
public final transient static Set<Material> materialsEditTools = EnumSet.noneOf(Material.class);
|
||||
public final transient static Set<Material> materialsDoor = EnumSet.noneOf(Material.class);
|
||||
public final transient static Set<Material> materialsContainer = EnumSet.noneOf(Material.class);
|
||||
|
||||
//public static Set<Material> territoryProtectedMaterialsWhenOffline = 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> monsters = EnumSet.noneOf(CreatureType.class);
|
||||
|
||||
// Spout features
|
||||
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
|
||||
@ -289,8 +284,8 @@ public class Conf
|
||||
factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable);
|
||||
}
|
||||
|
||||
factionPermDefaults = new LinkedHashMap<FactionPerm, Set<Rel>>();
|
||||
for (FactionPerm perm: FactionPerm.values())
|
||||
factionPermDefaults = new LinkedHashMap<FPerm, Set<Rel>>();
|
||||
for (FPerm perm: FPerm.values())
|
||||
{
|
||||
factionPermDefaults.put(perm, perm.defaultDefaultValue);
|
||||
}
|
||||
@ -302,21 +297,27 @@ public class Conf
|
||||
territoryEnemyDenyCommands.add("tpaccept");
|
||||
territoryEnemyDenyCommands.add("tpa");
|
||||
|
||||
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
|
||||
territoryProtectedMaterials.add(Material.TRAP_DOOR);
|
||||
territoryProtectedMaterials.add(Material.FENCE_GATE);
|
||||
territoryProtectedMaterials.add(Material.DISPENSER);
|
||||
territoryProtectedMaterials.add(Material.CHEST);
|
||||
territoryProtectedMaterials.add(Material.FURNACE);
|
||||
territoryProtectedMaterials.add(Material.BURNING_FURNACE);
|
||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_OFF);
|
||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_ON);
|
||||
|
||||
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
|
||||
territoryDenyUseageMaterials.add(Material.BUCKET);
|
||||
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
|
||||
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
|
||||
materialsContainer.add(Material.DISPENSER);
|
||||
materialsContainer.add(Material.CHEST);
|
||||
materialsContainer.add(Material.FURNACE);
|
||||
materialsContainer.add(Material.BURNING_FURNACE);
|
||||
|
||||
materialsEditOnInteract.add(Material.DIODE_BLOCK_OFF);
|
||||
materialsEditOnInteract.add(Material.DIODE_BLOCK_ON);
|
||||
|
||||
materialsDoor.add(Material.WOODEN_DOOR);
|
||||
materialsDoor.add(Material.TRAP_DOOR);
|
||||
materialsDoor.add(Material.FENCE_GATE);
|
||||
|
||||
materialsEditTools.add(Material.FLINT_AND_STEEL);
|
||||
materialsEditTools.add(Material.BUCKET);
|
||||
materialsEditTools.add(Material.WATER_BUCKET);
|
||||
materialsEditTools.add(Material.LAVA_BUCKET);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
|
||||
territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR);
|
||||
territoryProtectedMaterialsWhenOffline.add(Material.FENCE_GATE);
|
||||
@ -330,18 +331,18 @@ public class Conf
|
||||
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
|
||||
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
|
||||
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
|
||||
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
|
||||
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);*/
|
||||
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.CAVE_SPIDER);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.CREEPER);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.ENDERMAN);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.GHAST);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.PIG_ZOMBIE);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.SILVERFISH);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.SKELETON);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.SPIDER);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.SLIME);
|
||||
safeZoneNerfedCreatureTypes.add(CreatureType.ZOMBIE);
|
||||
monsters.add(CreatureType.CAVE_SPIDER);
|
||||
monsters.add(CreatureType.CREEPER);
|
||||
monsters.add(CreatureType.ENDERMAN);
|
||||
monsters.add(CreatureType.GHAST);
|
||||
monsters.add(CreatureType.PIG_ZOMBIE);
|
||||
monsters.add(CreatureType.SILVERFISH);
|
||||
monsters.add(CreatureType.SKELETON);
|
||||
monsters.add(CreatureType.SPIDER);
|
||||
monsters.add(CreatureType.SLIME);
|
||||
monsters.add(CreatureType.ZOMBIE);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -132,16 +132,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
|
||||
public final void resetFactionData(boolean doSpotUpdate)
|
||||
{
|
||||
// clean up any territory ownership in old faction, if there is one
|
||||
if (Factions.i.exists(this.getFactionId()))
|
||||
{
|
||||
Faction currentFaction = this.getFaction();
|
||||
if (currentFaction.isNormal())
|
||||
{
|
||||
currentFaction.clearClaimOwnership(this.getId());
|
||||
}
|
||||
}
|
||||
|
||||
this.factionId = "0"; // The default neutral faction
|
||||
this.chatMode = ChatMode.PUBLIC;
|
||||
this.role = Rel.MEMBER;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.massivecraft.factions;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -12,8 +10,7 @@ import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FactionPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.zcore.persist.Entity;
|
||||
@ -25,9 +22,6 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
// FIELD: relationWish
|
||||
private Map<String, Rel> relationWish;
|
||||
|
||||
// FIELD: claimOwnership
|
||||
private Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||
|
||||
// FIELD: invites
|
||||
// Where string is a lowercase player name
|
||||
private Set<String> invites;
|
||||
@ -131,14 +125,14 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// FIELDS: Permission <-> Groups management
|
||||
private Map<FactionPerm, Set<Rel>> permOverrides; // Contains the modifications to the default values
|
||||
public Set<Rel> getPerm(FactionPerm perm)
|
||||
private Map<FPerm, Set<Rel>> permOverrides; // Contains the modifications to the default values
|
||||
public Set<Rel> getPermittedRelations(FPerm perm)
|
||||
{
|
||||
Set<Rel> ret = this.permOverrides.get(perm);
|
||||
if (ret == null) ret = perm.getDefault();
|
||||
return ret;
|
||||
}
|
||||
public void setPerm(FactionPerm perm, Set<Rel> value)
|
||||
public void setPermittedRelations(FPerm perm, Set<Rel> value)
|
||||
{
|
||||
if (Conf.factionPermDefaults.get(perm).equals(value))
|
||||
{
|
||||
@ -165,7 +159,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
//this.peacefulExplosionsEnabled = false;
|
||||
this.money = 0.0;
|
||||
this.flagOverrides = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
this.permOverrides = new LinkedHashMap<FactionPerm, Set<Rel>>();
|
||||
this.permOverrides = new LinkedHashMap<FPerm, Set<Rel>>();
|
||||
}
|
||||
|
||||
|
||||
@ -451,167 +445,6 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Ownership of specific claims
|
||||
//----------------------------------------------//
|
||||
|
||||
public void clearAllClaimOwnership()
|
||||
{
|
||||
claimOwnership.clear();
|
||||
}
|
||||
|
||||
public void clearClaimOwnership(FLocation loc)
|
||||
{
|
||||
claimOwnership.remove(loc);
|
||||
}
|
||||
|
||||
public void clearClaimOwnership(String playerName)
|
||||
{
|
||||
if (playerName == null || playerName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> ownerData;
|
||||
String player = playerName.toLowerCase();
|
||||
|
||||
for (Entry<FLocation, Set<String>> entry : claimOwnership.entrySet())
|
||||
{
|
||||
ownerData = entry.getValue();
|
||||
|
||||
if (ownerData == null) continue;
|
||||
|
||||
Iterator<String> iter = ownerData.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
if (iter.next().equals(player))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (ownerData.isEmpty())
|
||||
{
|
||||
claimOwnership.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCountOfClaimsWithOwners()
|
||||
{
|
||||
return claimOwnership.isEmpty() ? 0 : claimOwnership.size();
|
||||
}
|
||||
|
||||
public boolean doesLocationHaveOwnersSet(FLocation loc)
|
||||
{
|
||||
if (claimOwnership.isEmpty() || !claimOwnership.containsKey(loc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
return ownerData != null && !ownerData.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isPlayerInOwnerList(String playerName, FLocation loc)
|
||||
{
|
||||
if (claimOwnership.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ownerData.contains(playerName.toLowerCase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPlayerAsOwner(String playerName, FLocation loc)
|
||||
{
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null)
|
||||
{
|
||||
ownerData = new HashSet<String>();
|
||||
}
|
||||
ownerData.add(playerName.toLowerCase());
|
||||
claimOwnership.put(loc, ownerData);
|
||||
}
|
||||
|
||||
public void removePlayerAsOwner(String playerName, FLocation loc)
|
||||
{
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ownerData.remove(playerName.toLowerCase());
|
||||
claimOwnership.put(loc, ownerData);
|
||||
}
|
||||
|
||||
public Set<String> getOwnerList(FLocation loc)
|
||||
{
|
||||
return claimOwnership.get(loc);
|
||||
}
|
||||
|
||||
public String getOwnerListString(FLocation loc)
|
||||
{
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null || ownerData.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
String ownerList = "";
|
||||
|
||||
Iterator<String> iter = ownerData.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!ownerList.isEmpty())
|
||||
{
|
||||
ownerList += ", ";
|
||||
}
|
||||
ownerList += iter.next();
|
||||
}
|
||||
return ownerList;
|
||||
}
|
||||
|
||||
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc)
|
||||
{
|
||||
// in own faction, with sufficient role or permission to bypass ownership?
|
||||
if
|
||||
(
|
||||
fplayer.getFaction() == this
|
||||
&&
|
||||
(
|
||||
fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Rel.OFFICER : Rel.LEADER)
|
||||
||
|
||||
Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer())
|
||||
)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// make sure claimOwnership is initialized
|
||||
if (claimOwnership.isEmpty())
|
||||
return true;
|
||||
|
||||
// need to check the ownership list, then
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
|
||||
// if no owner list, owner list is empty, or player is in owner list, they're allowed
|
||||
if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getName().toLowerCase()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// Persistance and entity management
|
||||
//----------------------------------------------//
|
||||
|
@ -343,7 +343,7 @@ public class P extends MPlugin
|
||||
// check if player is allowed to build/destroy in a particular location
|
||||
public boolean isPlayerAllowedToBuildHere(Player player, Location location)
|
||||
{
|
||||
return FactionsBlockListener.playerCanBuildDestroyBlock(player, location, "", true);
|
||||
return FactionsBlockListener.playerCanBuildDestroyBlock(player, location.getBlock(), "", true);
|
||||
}
|
||||
|
||||
// check if player is allowed to interact with the specified block (doors/chests/whatever)
|
||||
|
@ -113,8 +113,6 @@ public class CmdHelp extends FCommand
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) );
|
||||
pageLines.add( p.cmdBase.cmdOwner.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>that only the owner(s), faction admin, and possibly the"));
|
||||
pageLines.add(p.txt.parse("<i>faction moderators have full access."));
|
||||
|
@ -1,115 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
|
||||
public class CmdOwner extends FCommand
|
||||
{
|
||||
|
||||
public CmdOwner()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("owner");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("player name", "you");
|
||||
|
||||
this.permission = Permission.OWNER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
// TODO: Fix colors!
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
boolean hasBypass = fme.isAdminBypassing();
|
||||
|
||||
if ( ! hasBypass && ! assertHasFaction()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.ownedAreasEnabled)
|
||||
{
|
||||
fme.msg("<b>Sorry, but owned areas are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction)
|
||||
{
|
||||
fme.msg("<b>Sorry, but you have reached the server's <h>limit of %d <b>owned areas per faction.", Conf.ownedAreasLimitPerFaction);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Rel.OFFICER : Rel.LEADER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FLocation flocation = new FLocation(fme);
|
||||
|
||||
Faction factionHere = Board.getFactionAt(flocation);
|
||||
if (factionHere != myFaction)
|
||||
{
|
||||
if ( ! hasBypass)
|
||||
{
|
||||
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! factionHere.isNormal())
|
||||
{
|
||||
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||
if (target == null) return;
|
||||
|
||||
String playerName = target.getName();
|
||||
|
||||
if (target.getFaction() != myFaction)
|
||||
{
|
||||
fme.msg("%s<i> is not a member of this faction.", playerName);
|
||||
return;
|
||||
}
|
||||
|
||||
// if no player name was passed, and this claim does already have owners set, clear them
|
||||
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation))
|
||||
{
|
||||
myFaction.clearClaimOwnership(flocation);
|
||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
||||
fme.msg("<i>You have cleared ownership for this claimed area.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFaction.isPlayerInOwnerList(playerName, flocation))
|
||||
{
|
||||
myFaction.removePlayerAsOwner(playerName, flocation);
|
||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
||||
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
|
||||
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.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return;
|
||||
|
||||
myFaction.setPlayerAsOwner(playerName, flocation);
|
||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
||||
|
||||
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
public class CmdOwnerList extends FCommand
|
||||
{
|
||||
|
||||
public CmdOwnerList()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("ownerlist");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.OWNERLIST.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
boolean hasBypass = fme.isAdminBypassing();
|
||||
|
||||
if ( ! hasBypass && ! assertHasFaction())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.ownedAreasEnabled)
|
||||
{
|
||||
fme.msg("<b>Owned areas are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
FLocation flocation = new FLocation(fme);
|
||||
|
||||
if (Board.getFactionAt(flocation) != myFaction)
|
||||
{
|
||||
if (!hasBypass)
|
||||
{
|
||||
fme.msg("<b>This land is not claimed by your faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction = Board.getFactionAt(flocation);
|
||||
if (!myFaction.isNormal())
|
||||
{
|
||||
fme.msg("<i>This land is not claimed by any faction, thus no owners.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String owners = myFaction.getOwnerListString(flocation);
|
||||
|
||||
if (owners == null || owners.isEmpty())
|
||||
{
|
||||
fme.msg("<i>No owners are set here; everyone in the faction has access.");
|
||||
return;
|
||||
}
|
||||
|
||||
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FactionPerm;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
@ -46,23 +46,23 @@ public class CmdPerm extends FCommand
|
||||
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
for (FactionPerm perm : FactionPerm.values())
|
||||
for (FPerm perm : FPerm.values())
|
||||
{
|
||||
msg(perm.getStateInfo(faction.getPerm(perm), true));
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FactionPerm perm = this.argAsFactionPerm(1);
|
||||
FPerm perm = this.argAsFactionPerm(1);
|
||||
if (perm == null) return;
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(perm.getStateInfo(faction.getPerm(perm), true));
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Awesomesause parser for deltas...
|
||||
Set<Rel> targetValue = FactionPerm.parseRelDeltas(TextUtil.implode(args.subList(2, args.size()), " "), faction.getPerm(perm));
|
||||
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))
|
||||
@ -81,8 +81,8 @@ public class CmdPerm extends FCommand
|
||||
}
|
||||
|
||||
// Do the change
|
||||
faction.setPerm(perm, targetValue);
|
||||
msg(perm.getStateInfo(faction.getPerm(perm), true));
|
||||
faction.setPermittedRelations(perm, targetValue);
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ public class FCmdRoot extends FCommand
|
||||
public CmdOfficer cmdOfficer = new CmdOfficer();
|
||||
public CmdMoney cmdMoney = new CmdMoney();
|
||||
public CmdOpen cmdOpen = new CmdOpen();
|
||||
public CmdOwner cmdOwner = new CmdOwner();
|
||||
public CmdOwnerList cmdOwnerList = new CmdOwnerList();
|
||||
public CmdPerm cmdPerm = new CmdPerm();
|
||||
public CmdPower cmdPower = new CmdPower();
|
||||
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
||||
@ -92,8 +90,6 @@ public class FCmdRoot extends FCommand
|
||||
this.addSubCommand(this.cmdOfficer);
|
||||
this.addSubCommand(this.cmdMoney);
|
||||
this.addSubCommand(this.cmdOpen);
|
||||
this.addSubCommand(this.cmdOwner);
|
||||
this.addSubCommand(this.cmdOwnerList);
|
||||
this.addSubCommand(this.cmdPerm);
|
||||
this.addSubCommand(this.cmdPower);
|
||||
this.addSubCommand(this.cmdRelationAlly);
|
||||
|
@ -13,7 +13,7 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FactionPerm;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.MCommand;
|
||||
|
||||
@ -310,13 +310,13 @@ public abstract class FCommand extends MCommand<P>
|
||||
}
|
||||
|
||||
// FACTION PERM ======================
|
||||
public FactionPerm strAsFactionPerm(String name, FactionPerm def, boolean msg)
|
||||
public FPerm strAsFactionPerm(String name, FPerm def, boolean msg)
|
||||
{
|
||||
FactionPerm ret = def;
|
||||
FPerm ret = def;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
FactionPerm perm = FactionPerm.parse(name);
|
||||
FPerm perm = FPerm.parse(name);
|
||||
if (perm != null)
|
||||
{
|
||||
ret = perm;
|
||||
@ -330,15 +330,15 @@ public abstract class FCommand extends MCommand<P>
|
||||
|
||||
return ret;
|
||||
}
|
||||
public FactionPerm argAsFactionPerm(int idx, FactionPerm def, boolean msg)
|
||||
public FPerm argAsFactionPerm(int idx, FPerm def, boolean msg)
|
||||
{
|
||||
return this.strAsFactionPerm(this.argAsString(idx), def, msg);
|
||||
}
|
||||
public FactionPerm argAsFactionPerm(int idx, FactionPerm def)
|
||||
public FPerm argAsFactionPerm(int idx, FPerm def)
|
||||
{
|
||||
return this.argAsFactionPerm(idx, def, true);
|
||||
}
|
||||
public FactionPerm argAsFactionPerm(int idx)
|
||||
public FPerm argAsFactionPerm(int idx)
|
||||
{
|
||||
return this.argAsFactionPerm(idx, null);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.iface;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public interface RelationParticipator
|
||||
|
@ -89,30 +89,6 @@ public class SpoutFeatures
|
||||
return mainListener.updateTerritoryDisplay(player, true);
|
||||
}
|
||||
|
||||
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
||||
public static void updateOwnerListLoc(FLocation fLoc)
|
||||
{
|
||||
if (!enabled())
|
||||
return;
|
||||
|
||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||
|
||||
for (FPlayer player : players)
|
||||
{
|
||||
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
||||
mainListener.updateOwnerList(player);
|
||||
}
|
||||
}
|
||||
|
||||
// update owner list for specified player
|
||||
public static void updateOwnerList(FPlayer player)
|
||||
{
|
||||
if (!enabled())
|
||||
return;
|
||||
|
||||
mainListener.updateOwnerList(player);
|
||||
}
|
||||
|
||||
public static void playerDisconnect(FPlayer player)
|
||||
{
|
||||
if (!enabled())
|
||||
|
@ -58,20 +58,6 @@ public class SpoutMainListener extends SpoutListener
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateOwnerList(FPlayer player)
|
||||
{
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer());
|
||||
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && ! Conf.spoutTerritoryNoticeShow))
|
||||
return;
|
||||
|
||||
FLocation here = new FLocation(player);
|
||||
Faction factionHere = Board.getFactionAt(here);
|
||||
|
||||
doOwnerList(player, sPlayer, here, factionHere);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void removeTerritoryLabels(String playerName)
|
||||
{
|
||||
territoryLabels.remove(playerName);
|
||||
@ -146,47 +132,8 @@ public class SpoutMainListener extends SpoutListener
|
||||
label.resetNotice();
|
||||
label.setDirty(true);
|
||||
}
|
||||
|
||||
// and owner list, of course
|
||||
doOwnerList(player, sPlayer, here, factionHere);
|
||||
}
|
||||
|
||||
private void doOwnerList(FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere)
|
||||
{
|
||||
// ----------
|
||||
// Owner list
|
||||
// ----------
|
||||
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled)
|
||||
{
|
||||
GenericLabel label;
|
||||
if (ownerLabels.containsKey(player.getName()))
|
||||
label = ownerLabels.get(player.getName());
|
||||
else
|
||||
{
|
||||
label = new GenericLabel();
|
||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||
label.setY((int)(10 * Conf.spoutTerritoryDisplaySize));
|
||||
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||
ownerLabels.put(player.getName(), label);
|
||||
}
|
||||
|
||||
String msg = "";
|
||||
|
||||
if (player.getFaction() == factionHere)
|
||||
{
|
||||
msg = factionHere.getOwnerListString(here);
|
||||
|
||||
if (!msg.isEmpty())
|
||||
msg = Conf.ownedLandMessage + msg;
|
||||
}
|
||||
|
||||
label.setText(msg);
|
||||
alignLabel(label, msg);
|
||||
label.setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this is only necessary because Spout text size scaling is currently bugged and breaks their built-in alignment methods
|
||||
public void alignLabel(GenericLabel label, String text)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
@ -18,7 +17,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.Rel;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
|
||||
|
||||
public class FactionsBlockListener extends BlockListener
|
||||
@ -35,13 +34,14 @@ public class FactionsBlockListener extends BlockListener
|
||||
if (event.isCancelled()) return;
|
||||
if ( ! event.canBuild()) return;
|
||||
|
||||
// TODO: Test if this old stuff is still an issue.
|
||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE)
|
||||
/*if (event.getBlockPlaced().getType() == Material.FIRE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false))
|
||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "build", false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class FactionsBlockListener extends BlockListener
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy", false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class FactionsBlockListener extends BlockListener
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
||||
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy", false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -81,10 +81,11 @@ public class FactionsBlockListener extends BlockListener
|
||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||
|
||||
// if potentially pushing into air in another territory, we need to check it out
|
||||
if (targetBlock.isEmpty() && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
|
||||
|
||||
|
||||
if (targetBlock.isEmpty() && ! FPerm.BUILD.has(pistonFaction, targetBlock.getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -98,97 +99,43 @@ public class FactionsBlockListener extends BlockListener
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
||||
{
|
||||
// if not a sticky piston, retraction should be fine
|
||||
if (event.isCancelled() || !event.isSticky() || !Conf.pistonProtectionThroughDenyBuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.isCancelled() || !event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) return;
|
||||
|
||||
Location targetLoc = event.getRetractLocation();
|
||||
|
||||
// if potentially retracted block is just air, no worries
|
||||
if (targetLoc.getBlock().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (targetLoc.getBlock().isEmpty()) return;
|
||||
|
||||
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
||||
|
||||
if (!canPistonMoveBlock(pistonFaction, targetLoc))
|
||||
if ( ! FPerm.BUILD.has(pistonFaction, targetLoc))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target)
|
||||
{
|
||||
|
||||
Faction otherFaction = Board.getFactionAt(new FLocation(target));
|
||||
|
||||
if (pistonFaction == otherFaction)
|
||||
return true;
|
||||
|
||||
Rel rel = pistonFaction.getRelationTo(otherFaction);
|
||||
|
||||
if (rel.confDenyBuild(otherFaction.hasPlayersOnline()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck)
|
||||
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.isAdminBypassing()) return true;
|
||||
|
||||
Location location = block.getLocation();
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
Faction factionHere = Board.getFactionAt(loc);
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
Rel rel = myFaction.getRelationTo(otherFaction);
|
||||
boolean online = otherFaction.hasPlayersOnline();
|
||||
boolean pain = !justCheck && rel.confPainBuild(online);
|
||||
boolean deny = rel.confDenyBuild(online);
|
||||
|
||||
// hurt the player for building/destroying in other territory?
|
||||
if (pain)
|
||||
{
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
|
||||
if (!deny)
|
||||
me.msg("<b>It is painful to try to "+action+" in the territory of "+otherFaction.getTag(myFaction));
|
||||
}
|
||||
|
||||
// cancel building/destroying in other territory?
|
||||
if (deny)
|
||||
if (FPerm.PAINBUILD.has(me, location))
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't "+action+" in the territory of "+otherFaction.getTag(myFaction));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also cancel and/or cause pain if player doesn't have ownership rights for this claim
|
||||
if (Conf.ownedAreasEnabled && (Conf.ownedAreaDenyBuild || Conf.ownedAreaPainBuild) && !otherFaction.playerHasOwnershipRights(me, loc))
|
||||
{
|
||||
if (!pain && Conf.ownedAreaPainBuild && !justCheck)
|
||||
{
|
||||
me.msg("<b>It is painful to try to "+action+" in the territory of "+factionHere.getTag(myFaction));
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
|
||||
if (!Conf.ownedAreaDenyBuild)
|
||||
me.msg("<b>It is painful to try to "+action+" in this territory, it is owned by: "+otherFaction.getOwnerListString(loc));
|
||||
}
|
||||
if (Conf.ownedAreaDenyBuild)
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't "+action+" in this territory, it is owned by: "+otherFaction.getOwnerListString(loc));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return FPerm.BUILD.has(me, location, true);
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
|
||||
if (faction.getFlag(FactionFlag.MONSTERS)) return;
|
||||
if ( ! Conf.safeZoneNerfedCreatureTypes.contains(event.getCreatureType())) return;
|
||||
if ( ! Conf.monsters.contains(event.getCreatureType())) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -288,7 +288,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
if (target == null) return;
|
||||
|
||||
// We are interested in blocking targeting for certain mobs:
|
||||
if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return;
|
||||
if ( ! Conf.monsters.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return;
|
||||
|
||||
FLocation floc = new FLocation(target.getLocation());
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
@ -314,7 +314,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock((Player)breaker, event.getPainting().getLocation(), "remove paintings", false))
|
||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock((Player)breaker, event.getPainting().getLocation().getBlock(), "remove paintings", false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -325,7 +325,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false) )
|
||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation().getBlock(), "place paintings", false) )
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -198,56 +198,10 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
// Did we change "host"(faction)?
|
||||
Faction factionFrom = Board.getFactionAt(from);
|
||||
Faction factionTo = Board.getFactionAt(to);
|
||||
Faction myFaction = me.getFaction();
|
||||
String ownersTo = myFaction.getOwnerListString(to);
|
||||
boolean spoutClient = SpoutFeatures.availableFor(player);
|
||||
|
||||
if (factionFrom != factionTo)
|
||||
{
|
||||
me.sendFactionHereMessage();
|
||||
if
|
||||
(
|
||||
Conf.ownedAreasEnabled
|
||||
&&
|
||||
Conf.ownedMessageOnBorder
|
||||
&&
|
||||
(
|
||||
!spoutClient
|
||||
||
|
||||
!Conf.spoutTerritoryOwnersShow
|
||||
)
|
||||
&&
|
||||
myFaction == factionTo
|
||||
&&
|
||||
!ownersTo.isEmpty()
|
||||
)
|
||||
{
|
||||
me.sendMessage(Conf.ownedLandMessage+ownersTo);
|
||||
}
|
||||
}
|
||||
else if (spoutClient && Conf.spoutTerritoryOwnersShow)
|
||||
{
|
||||
SpoutFeatures.updateOwnerList(me);
|
||||
}
|
||||
else if
|
||||
(
|
||||
Conf.ownedAreasEnabled
|
||||
&&
|
||||
Conf.ownedMessageInsideTerritory
|
||||
&&
|
||||
factionFrom == factionTo
|
||||
&&
|
||||
myFaction == factionTo
|
||||
)
|
||||
{
|
||||
String ownersFrom = myFaction.getOwnerListString(from);
|
||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo))
|
||||
{
|
||||
if (!ownersTo.isEmpty())
|
||||
me.sendMessage(Conf.ownedLandMessage+ownersTo);
|
||||
else if (!Conf.publicLandMessage.isEmpty())
|
||||
me.sendMessage(Conf.publicLandMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,99 +242,27 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: Improve with the... system for... Permissions
|
||||
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck)
|
||||
// TODO: Refactor ! justCheck -> to informIfNot
|
||||
// TODO: Possibly incorporate pain build...
|
||||
public static boolean playerCanUseItemHere(Player player, Location loc, Material material, boolean justCheck)
|
||||
{
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
if (me.isAdminBypassing())
|
||||
return true;
|
||||
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
|
||||
if (otherFaction.hasPlayersOnline())
|
||||
{
|
||||
if ( ! Conf.territoryDenyUseageMaterials.contains(material))
|
||||
return true; // Item isn't one we're preventing for online factions.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! Conf.territoryDenyUseageMaterialsWhenOffline.contains(material))
|
||||
return true; // Item isn't one we're preventing for offline factions.
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
Rel rel = myFaction.getRelationTo(otherFaction);
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
if (rel.confDenyUseage())
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in the territory of <h>%s<b>.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also cancel if player doesn't have ownership rights for this claim
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc))
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (me.isAdminBypassing()) 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.isAdminBypassing()) return true;
|
||||
Location loc = block.getLocation();
|
||||
Material material = block.getType();
|
||||
FLocation loc = new FLocation(block);
|
||||
Faction otherFaction = Board.getFactionAt(loc);
|
||||
|
||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||
if (!otherFaction.isNormal())
|
||||
return true;
|
||||
|
||||
// We only care about some material types.
|
||||
if (otherFaction.hasPlayersOnline())
|
||||
{
|
||||
if ( ! Conf.territoryProtectedMaterials.contains(material))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! Conf.territoryProtectedMaterialsWhenOffline.contains(material))
|
||||
return true;
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
Rel rel = myFaction.getRelationTo(otherFaction);
|
||||
|
||||
// You may use any block unless it is another faction's territory...
|
||||
if (rel == Rel.NEUTRAL || (rel == Rel.ENEMY && Conf.territoryEnemyProtectMaterials) || (rel == Rel.ALLY && Conf.territoryAllyProtectMaterials))
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in the territory of <h>%s<b>.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Also cancel if player doesn't have ownership rights for this claim
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc))
|
||||
{
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Conf.materialsEditOnInteract.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
|
||||
if (Conf.materialsContainer.contains(material) && ! FPerm.CONTAINER.has(me, loc, ! justCheck)) return false;
|
||||
if (Conf.materialsDoor.contains(material) && ! FPerm.DOOR.has(me, loc, ! justCheck)) return false;
|
||||
if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, loc, ! justCheck)) return false;
|
||||
if (material == Material.LEVER && ! FPerm.LEVER.has(me, loc, ! justCheck)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,19 +6,27 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
/**
|
||||
* Permissions that you (a player) may or may not have in the territory of a certain faction.
|
||||
* Each faction have many Rel's assigned to each one of these Perms.
|
||||
*/
|
||||
public enum FactionPerm
|
||||
public enum FPerm
|
||||
{
|
||||
BUILD("build", "edit the terrain", Rel.MEMBER),
|
||||
PAINBUILD("painbuild", "edit but take damage", Rel.ALLY),
|
||||
DOOR("door", "use doors etc.", Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use chests etc.", Rel.MEMBER),
|
||||
DOOR("door", "use doors", Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use containers", Rel.MEMBER),
|
||||
BUTTON("button", "use stone buttons", Rel.MEMBER, Rel.ALLY),
|
||||
LEVER("lever", "use levers", Rel.MEMBER, Rel.ALLY),
|
||||
;
|
||||
@ -27,7 +35,7 @@ public enum FactionPerm
|
||||
private final String desc;
|
||||
public final Set<Rel> defaultDefaultValue;
|
||||
|
||||
private FactionPerm(final String nicename, final String desc, final Rel... rels)
|
||||
private FPerm(final String nicename, final String desc, final Rel... rels)
|
||||
{
|
||||
this.nicename = nicename;
|
||||
this.desc = desc;
|
||||
@ -52,7 +60,7 @@ public enum FactionPerm
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static FactionPerm parse(String str)
|
||||
public static FPerm parse(String str)
|
||||
{
|
||||
str = str.toLowerCase();
|
||||
if (str.startsWith("bui")) return BUILD;
|
||||
@ -116,4 +124,31 @@ public enum FactionPerm
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static final String errorpattern = "<b>%s can't <h>%s<b> in the territory of %s<b>.";
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc, boolean informIfNot)
|
||||
{
|
||||
Faction factionThere = Board.getFactionAt(floc);
|
||||
Faction factionDoer = RelationUtil.getFaction(testSubject);
|
||||
boolean ret = factionThere.getPermittedRelations(this).contains(factionThere.getRelationTo(factionDoer));
|
||||
if (!ret && informIfNot && testSubject instanceof FPlayer)
|
||||
{
|
||||
FPlayer fplayer = (FPlayer)testSubject;
|
||||
fplayer.msg(errorpattern, fplayer.describeTo(fplayer, true), this.getDescription(), factionThere.describeTo(fplayer));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Location loc, boolean informIfNot)
|
||||
{
|
||||
FLocation floc = new FLocation(loc);
|
||||
return this.has(testSubject, floc, informIfNot);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Location loc)
|
||||
{
|
||||
return this.has(testSubject, loc, false);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc)
|
||||
{
|
||||
return this.has(testSubject, floc, false);
|
||||
}
|
||||
}
|
@ -119,79 +119,4 @@ public enum Rel
|
||||
else
|
||||
return Conf.econCostNeutral;
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
||||
public boolean confDenyBuild(boolean online)
|
||||
{
|
||||
if (this == MEMBER)
|
||||
return false;
|
||||
|
||||
if (online)
|
||||
{
|
||||
if (this == ENEMY)
|
||||
return Conf.territoryEnemyDenyBuild;
|
||||
else if (this == ALLY)
|
||||
return Conf.territoryAllyDenyBuild;
|
||||
else if (this == TRUCE)
|
||||
return Conf.territoryTruceDenyBuild;
|
||||
else
|
||||
return Conf.territoryDenyBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this == ENEMY)
|
||||
return Conf.territoryEnemyDenyBuildWhenOffline;
|
||||
else if (this == ALLY)
|
||||
return Conf.territoryAllyDenyBuildWhenOffline;
|
||||
else if (this == TRUCE)
|
||||
return Conf.territoryTruceDenyBuildWhenOffline;
|
||||
else
|
||||
return Conf.territoryDenyBuildWhenOffline;
|
||||
}
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
||||
public boolean confPainBuild(boolean online)
|
||||
{
|
||||
if (this == MEMBER)
|
||||
return false;
|
||||
|
||||
if (online)
|
||||
{
|
||||
if (this == ENEMY)
|
||||
return Conf.territoryEnemyPainBuild;
|
||||
else if (this == ALLY)
|
||||
return Conf.territoryAllyPainBuild;
|
||||
else if (this == TRUCE)
|
||||
return Conf.territoryTrucePainBuild;
|
||||
else
|
||||
return Conf.territoryPainBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this == ENEMY)
|
||||
return Conf.territoryEnemyPainBuildWhenOffline;
|
||||
else if (this == ALLY)
|
||||
return Conf.territoryAllyPainBuildWhenOffline;
|
||||
else if (this == TRUCE)
|
||||
return Conf.territoryTrucePainBuildWhenOffline;
|
||||
else
|
||||
return Conf.territoryPainBuildWhenOffline;
|
||||
}
|
||||
}
|
||||
|
||||
// return appropriate Conf setting for DenyUseage based on this relation
|
||||
public boolean confDenyUseage()
|
||||
{
|
||||
if (this == MEMBER)
|
||||
return false;
|
||||
else if (this == ENEMY)
|
||||
return Conf.territoryEnemyDenyUseage;
|
||||
else if (this == ALLY)
|
||||
return Conf.territoryAllyDenyUseage;
|
||||
else if (this == TRUCE)
|
||||
return Conf.territoryTruceDenyUseage;
|
||||
else
|
||||
return Conf.territoryDenyUseage;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user