From 126dfe49a11a9bd91ca885c61afce9382b974d60 Mon Sep 17 00:00:00 2001 From: Driftay Date: Thu, 11 Jul 2019 03:15:02 -0400 Subject: [PATCH] Added Command Argument for F Home command to allow staff in F bypass to go to other faction homes! Usage: /f home --- .../massivecraft/factions/cmd/CmdHome.java | 34 ++++++++++++++++++- .../massivecraft/factions/zcore/util/TL.java | 4 ++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index 138bc22e..3e6b6c40 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -24,6 +24,7 @@ public class CmdHome extends FCommand { super(); this.aliases.add("home"); + this.optionalArgs.put("faction", "yours"); //this.requiredArgs.add(""); //this.optionalArgs.put("", ""); @@ -32,7 +33,7 @@ public class CmdHome extends FCommand { senderMustBePlayer = true; - senderMustBeMember = true; + senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; @@ -41,6 +42,8 @@ public class CmdHome extends FCommand { @Override public void perform() { // TODO: Hide this command on help also. + + if (!Conf.homesEnabled) { fme.msg(TL.COMMAND_HOME_DISABLED); return; @@ -50,6 +53,33 @@ public class CmdHome extends FCommand { fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED); return; } + + Faction factionArg = myFaction; + + if(argIsSet(0)){ + factionArg = argAsFaction(0); + } + + if(factionArg == null || factionArg.isWilderness()) + return; + + if(factionArg.hasHome()){ + if(fme.isAdminBypassing()) { + 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; + } + + + if(myFaction.isWilderness()) + return; + if (!fme.isAdminBypassing()) { Access access = myFaction.getAccess(fme, PermissableAction.HOME); if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { @@ -65,6 +95,8 @@ public class CmdHome extends FCommand { return; } + + if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { fme.msg(TL.COMMAND_HOME_INENEMY); return; diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index db95d635..944ad8d9 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -162,8 +162,10 @@ public enum TL { COMMAND_ALTKICK_NOTALT("&c&l[!] &7Player is not an alt."), COMMAND_ALTKICK_NOTMEMBER("&c&l[!] &7This player is not a member of your faction."), - COMMAND_ALTS_LIST_NOALTS("&c&l[!] &7$1%s does not have any alts in their faction!"), + COMMAND_ALTS_LIST_NOALTS("&c&l[!] &7%s does not have any alts in their faction!"), COMMAND_AUTOHELP_HELPFOR("Help for command \""), + COMMAND_HOME_OTHER_NOTSET("&c&l[!] &7%s does not have their faction home set!"), + COMMAND_HOME_TELEPORT_OTHER("&c&l[!] &7You have teleported to %s's faction home!"), COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."), COMMAND_BAN_TARGET("&c&l[!] &7You were &cbanned &7from &c%1$s"), // banned player perspective