mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-23 18:55:25 +01:00
Added options to require faction homes to be set only inside the faction's own territory ("homesMustBeInClaimedTerritory", default is true) and to optionally prevent teleporting to the faction home if the player is in enemy territory ("homesTeleportAllowedFromEnemyTerritory", default is true thus not prevented)
Made commands which reference player names (like /f admin <name>) allow for partial name matches Optimized a couple of things, and updated help text to indicate /f unclaim works for safe/war zones
This commit is contained in:
parent
768f96bf9b
commit
56cbf54c98
@ -61,7 +61,9 @@ public class Conf {
|
||||
public static double autoLeaveAfterDaysOfInactivity = 14;
|
||||
|
||||
public static boolean homesEnabled = true;
|
||||
public static boolean homesMustBeInClaimedTerritory = true;
|
||||
public static boolean homesTeleportToOnDeath = true;
|
||||
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
|
||||
public static double homesTeleportAllowedEnemyDistance = 32;
|
||||
|
||||
public static boolean disablePVPForFactionlessPlayers = false;
|
||||
|
@ -393,7 +393,11 @@ public class FPlayer {
|
||||
|
||||
public boolean isInOthersTerritory() {
|
||||
int idHere = Board.getIdAt(new FLocation(this));
|
||||
return idHere != 0 && idHere != this.factionId;
|
||||
return idHere > 0 && idHere != this.factionId;
|
||||
}
|
||||
|
||||
public boolean isInEnemyTerritory() {
|
||||
return Board.getFactionAt(new FLocation(this)).getRelation(this) == Relation.ENEMY;
|
||||
}
|
||||
|
||||
public void sendFactionHereMessage() {
|
||||
@ -557,7 +561,8 @@ public class FPlayer {
|
||||
|
||||
public static FPlayer find(String playername) {
|
||||
for (Entry<String, FPlayer> entry : instances.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(playername)) {
|
||||
// if (entry.getKey().equalsIgnoreCase(playername)) {
|
||||
if (entry.getKey().startsWith(playername)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class Faction {
|
||||
}
|
||||
|
||||
public Relation getRelation(Faction otherFaction) {
|
||||
if (otherFaction.isNone() || this.isNone()) {
|
||||
if (!otherFaction.isNormal() || !this.isNormal()) {
|
||||
return Relation.NEUTRAL;
|
||||
}
|
||||
if (otherFaction.equals(this)) {
|
||||
|
@ -132,11 +132,12 @@ public class FCommandHelp extends FBaseCommand {
|
||||
pageLines.add( new FCommandWarclaim().getUseageTemplate() );
|
||||
pageLines.add( new FCommandAutoWarclaim().getUseageTemplate() );
|
||||
pageLines.add( new FCommandWarunclaimall().getUseageTemplate() );
|
||||
pageLines.add( new FCommandBypass().getUseageTemplate() );
|
||||
pageLines.add("Note: /f unclaim works on safe/war zones as well.");
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add("More commands for server admins:");
|
||||
pageLines.add( new FCommandBypass().getUseageTemplate() );
|
||||
pageLines.add( new FCommandWorldNoClaim().getUseageTemplate() );
|
||||
pageLines.add( new FCommandWorldNoPowerLoss().getUseageTemplate() );
|
||||
pageLines.add( new FCommandLock().getUseageTemplate() );
|
||||
|
@ -39,6 +39,11 @@ public class FCommandHome extends FBaseCommand {
|
||||
|
||||
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
|
||||
|
||||
if (!Conf.homesTeleportAllowedFromEnemyTerritory && me.isInEnemyTerritory()) {
|
||||
me.sendMessage("You cannot teleport to your faction home while in the territory of an enemy faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if (Conf.homesTeleportAllowedEnemyDistance > 0 && ! faction.isSafeZone() && ! me.isInOwnTerritory()) {
|
||||
Location loc = player.getLocation();
|
||||
|
@ -1,7 +1,9 @@
|
||||
package org.mcteam.factions.commands;
|
||||
|
||||
import org.mcteam.factions.Board;
|
||||
import org.mcteam.factions.Conf;
|
||||
import org.mcteam.factions.Faction;
|
||||
import org.mcteam.factions.FLocation;
|
||||
import org.mcteam.factions.struct.Role;
|
||||
|
||||
public class FCommandSethome extends FBaseCommand {
|
||||
@ -31,7 +33,10 @@ public class FCommandSethome extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO may only be inside faction territory
|
||||
if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory()) {
|
||||
me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
myFaction.setHome(player.getLocation());
|
||||
|
Loading…
Reference in New Issue
Block a user