Moving home config from ConfServer --> UConf

This commit is contained in:
Olof Larsson 2013-04-23 18:07:17 +02:00
parent 29e05fd54d
commit 3dc2691bea
5 changed files with 33 additions and 29 deletions

View File

@ -30,17 +30,7 @@ public class ConfServer extends SimpleConfig
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
// -------------------------------------------- //
// HOMES
// -------------------------------------------- //
public static boolean homesEnabled = true;
public static boolean homesMustBeInClaimedTerritory = true;
public static boolean homesTeleportCommandEnabled = true;
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
public static boolean homesTeleportAllowedFromDifferentWorld = true;
public static double homesTeleportAllowedEnemyDistance = 32.0;
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
// -------------------------------------------- // // -------------------------------------------- //
// PVP // PVP

View File

@ -4,13 +4,13 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.FactionsEventHomeTeleport; import com.massivecraft.factions.event.FactionsEventHomeTeleport;
@ -35,14 +35,16 @@ public class CmdFactionsHome extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UConf uconf = UConf.get(sender);
// TODO: Hide this command on help also. // TODO: Hide this command on help also.
if ( ! ConfServer.homesEnabled) if ( ! uconf.homesEnabled)
{ {
fme.msg("<b>Sorry, Faction homes are disabled on this server."); fme.msg("<b>Sorry, Faction homes are disabled on this server.");
return; return;
} }
if ( ! ConfServer.homesTeleportCommandEnabled) if ( ! uconf.homesTeleportCommandEnabled)
{ {
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server."); fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
return; return;
@ -55,13 +57,13 @@ public class CmdFactionsHome extends FCommand
return; return;
} }
if ( ! ConfServer.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) if ( ! uconf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory())
{ {
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction."); fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
return; return;
} }
if (!ConfServer.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(myFaction.getHome().getWorld())) if (!uconf.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(myFaction.getHome().getWorld()))
{ {
fme.msg("<b>You cannot teleport to your faction home while in a different world."); fme.msg("<b>You cannot teleport to your faction home while in a different world.");
return; return;
@ -74,7 +76,7 @@ public class CmdFactionsHome extends FCommand
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if if
( (
ConfServer.homesTeleportAllowedEnemyDistance > 0 uconf.homesTeleportAllowedEnemyDistance > 0
&& &&
faction.getFlag(FFlag.PVP) faction.getFlag(FFlag.PVP)
&& &&
@ -84,7 +86,7 @@ public class CmdFactionsHome extends FCommand
( (
fme.isInOwnTerritory() fme.isInOwnTerritory()
&& &&
! ConfServer.homesTeleportIgnoreEnemiesIfInOwnTerritory ! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory
) )
) )
) )
@ -107,13 +109,13 @@ public class CmdFactionsHome extends FCommand
double dx = Math.abs(x - l.getX()); double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY()); double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ()); double dz = Math.abs(z - l.getZ());
double max = ConfServer.homesTeleportAllowedEnemyDistance; double max = uconf.homesTeleportAllowedEnemyDistance;
// box-shaped distance check // box-shaped distance check
if (dx > max || dy > max || dz > max) if (dx > max || dy > max || dz > max)
continue; continue;
fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + ConfServer.homesTeleportAllowedEnemyDistance + " blocks of you."); fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + uconf.homesTeleportAllowedEnemyDistance + " blocks of you.");
return; return;
} }
} }

View File

@ -1,11 +1,11 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.FactionsEventHomeChange; import com.massivecraft.factions.event.FactionsEventHomeChange;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer; import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
@ -26,19 +26,19 @@ public class CmdFactionsSethome extends FCommand
@Override @Override
public void perform() public void perform()
{ {
// TODO: Make a command REQ instead?
if ( ! ConfServer.homesEnabled)
{
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
return;
}
// Args // Args
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction); Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (faction == null) return; if (faction == null) return;
PS newHome = PS.valueOf(me.getLocation()); PS newHome = PS.valueOf(me.getLocation());
// Validate
if ( ! UConf.get(faction).homesEnabled)
{
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
return;
}
// FPerm // FPerm
if ( ! FPerm.SETHOME.has(sender, faction, true)) return; if ( ! FPerm.SETHOME.has(sender, faction, true)) return;

View File

@ -231,7 +231,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean isValidHome(PS ps) public boolean isValidHome(PS ps)
{ {
if (ps == null) return true; if (ps == null) return true;
if (!ConfServer.homesMustBeInClaimedTerritory) return true; if (!UConf.get(this).homesMustBeInClaimedTerritory) return true;
if (BoardColls.get().getFactionAt(ps) == this) return true; if (BoardColls.get().getFactionAt(ps) == this) return true;
return false; return false;
} }

View File

@ -60,6 +60,18 @@ public class UConf extends Entity<UConf>
public double powerPerHour = 2.0; public double powerPerHour = 2.0;
public double powerPerDeath = -2.0; public double powerPerDeath = -2.0;
// -------------------------------------------- //
// HOMES
// -------------------------------------------- //
public boolean homesEnabled = true;
public boolean homesMustBeInClaimedTerritory = true;
public boolean homesTeleportCommandEnabled = true;
public boolean homesTeleportAllowedFromEnemyTerritory = true;
public boolean homesTeleportAllowedFromDifferentWorld = true;
public double homesTeleportAllowedEnemyDistance = 32.0;
public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
// -------------------------------------------- // // -------------------------------------------- //
// DENY COMMANDS // DENY COMMANDS
// -------------------------------------------- // // -------------------------------------------- //