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

@@ -4,13 +4,13 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.FactionsEventHomeTeleport;
@@ -35,14 +35,16 @@ public class CmdFactionsHome extends FCommand
@Override
public void perform()
{
UConf uconf = UConf.get(sender);
// TODO: Hide this command on help also.
if ( ! ConfServer.homesEnabled)
if ( ! uconf.homesEnabled)
{
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
return;
}
if ( ! ConfServer.homesTeleportCommandEnabled)
if ( ! uconf.homesTeleportCommandEnabled)
{
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
return;
@@ -55,13 +57,13 @@ public class CmdFactionsHome extends FCommand
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.");
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.");
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
(
ConfServer.homesTeleportAllowedEnemyDistance > 0
uconf.homesTeleportAllowedEnemyDistance > 0
&&
faction.getFlag(FFlag.PVP)
&&
@@ -84,7 +86,7 @@ public class CmdFactionsHome extends FCommand
(
fme.isInOwnTerritory()
&&
! ConfServer.homesTeleportIgnoreEnemiesIfInOwnTerritory
! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory
)
)
)
@@ -107,13 +109,13 @@ public class CmdFactionsHome extends FCommand
double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ());
double max = ConfServer.homesTeleportAllowedEnemyDistance;
double max = uconf.homesTeleportAllowedEnemyDistance;
// box-shaped distance check
if (dx > max || dy > max || dz > max)
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;
}
}

View File

@@ -1,11 +1,11 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.FactionsEventHomeChange;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
@@ -26,19 +26,19 @@ public class CmdFactionsSethome extends FCommand
@Override
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
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (faction == null) return;
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
if ( ! FPerm.SETHOME.has(sender, faction, true)) return;