Faction home fix

This commit is contained in:
prosavage 2019-07-20 12:12:51 -05:00
parent e121d49762
commit 4a794fe706

View File

@ -10,6 +10,7 @@ import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.SmokeUtil; import com.massivecraft.factions.zcore.util.SmokeUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,29 +55,21 @@ public class CmdHome extends FCommand {
return; return;
} }
Faction factionArg = myFaction; Faction factionArg;
if(argIsSet(0)){ if (args.isEmpty())
factionArg = argAsFaction(0); factionArg = myFaction;
} else
factionArg = argAsFaction(0);
if(factionArg == null || factionArg.isWilderness())
return;
Access access1 = myFaction.getAccess(fme, PermissableAction.HOME); if (factionArg.isSystemFaction()) {
if(factionArg.hasHome()){ fme.msg(TL.GENERIC_NOPERMISSION, "teleport to system faction home");
if(fme.isAdminBypassing() || (myFaction.equals(fme.getFaction()) && fme.getRole().equals(Role.LEADER)) || access1 == Access.ALLOW ) {
fme.getPlayer().teleport(factionArg.getHome());
fme.msg(TL.COMMAND_HOME_TELEPORT_OTHER, factionArg.getTag());
} else {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return;
}
} else {
fme.msg(TL.COMMAND_HOME_OTHER_NOTSET, factionArg.getTag());
return; return;
} }
myFaction = factionArg;
if(myFaction.isWilderness()) if(myFaction.isWilderness())
return; return;
@ -90,6 +83,7 @@ public class CmdHome extends FCommand {
} }
if (!myFaction.hasHome()) { if (!myFaction.hasHome()) {
fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
@ -98,6 +92,7 @@ public class CmdHome extends FCommand {
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
fme.msg(TL.COMMAND_HOME_INENEMY); fme.msg(TL.COMMAND_HOME_INENEMY);
return; return;
@ -144,15 +139,20 @@ public class CmdHome extends FCommand {
} }
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) {
return; return;
} }
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown) // TODO: Need to document this better confusing everyone, removed for now.
if (Essentials.handleTeleport(me, myFaction.getHome())) { // // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
return; // if (Essentials.handleTeleport(me, myFaction.getHome())) {
} // return;
// }
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> { this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
// Create a smoke effect // Create a smoke effect