Add command to forcefully send player to f home from #478.

Functionality: /f ahome <target> - sends a player to their f home as long as they have an f home and are online.
Permission node is  and given to factions.admin and factions.*
This commit is contained in:
drtshock 2015-09-08 12:18:00 -05:00
parent d916e97d0d
commit c5571ba8ee
5 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,52 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.event.player.PlayerTeleportEvent;
public class CmdAHome extends FCommand {
public CmdAHome() {
super();
this.aliases.add("ahome");
this.requiredArgs.add("player name");
this.permission = Permission.AHOME.node;
this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
FPlayer target = argAsBestFPlayerMatch(0);
if (target == null) {
msg(TL.GENERIC_NOPLAYERMATCH, argAsString(0));
return;
}
if (target.isOnline()) {
Faction faction = target.getFaction();
if (faction.hasHome()) {
target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN);
msg(TL.COMMAND_AHOME_SUCCESS, target.getName());
target.msg(TL.COMMAND_AHOME_TARGET);
} else {
msg(TL.COMMAND_AHOME_NOHOME, target.getName());
}
} else {
msg(TL.COMMAND_AHOME_OFFLINE, target.getName());
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_AHOME_DESCRIPTION;
}
}

View File

@ -67,6 +67,7 @@ public class FCmdRoot extends FCommand {
public CmdLogins cmdLogins = new CmdLogins();
public CmdClaimLine cmdClaimLine = new CmdClaimLine();
public CmdTop cmdTop = new CmdTop();
public CmdAHome cmdAHome = new CmdAHome();
public FCmdRoot() {
super();
@ -149,6 +150,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdLogins);
this.addSubCommand(this.cmdClaimLine);
this.addSubCommand(this.cmdTop);
this.addSubCommand(this.cmdAHome);
}
@Override

View File

@ -9,6 +9,7 @@ public enum Permission {
OWNERSHIP_BYPASS("ownershipbypass"),
ADMIN("admin"),
ADMIN_ANY("admin.any"),
AHOME("ahome"),
ANNOUNCE("announce"),
AUTOCLAIM("autoclaim"),
BYPASS("bypass"),

View File

@ -59,6 +59,12 @@ public enum TL {
COMMAND_ADMIN_PROMOTED("%1$s<i> gave %2$s<i> the leadership of %3$s<i>."),
COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"),
COMMAND_AHOME_DESCRIPTION("Send a player to their f home no matter what."),
COMMAND_AHOME_NOHOME("%1$s doesn't have an f home."),
COMMAND_AHOME_SUCCESS("$1%s was sent to their f home."),
COMMAND_AHOME_OFFLINE("%1$s is offline."),
COMMAND_AHOME_TARGET("You were sent to your f home."),
COMMAND_ANNOUNCE_DESCRIPTION("Announce a message to players in faction."),
COMMAND_AUTOCLAIM_ENABLED("<i>Now auto-claiming land for <h>%1$s<i>."),

View File

@ -17,6 +17,7 @@ permissions:
factions.reload: true
factions.save: true
factions.modifypower: true
factions.ahome: true
factions.*:
description: This is just an alias for factions.kit.admin
children:
@ -259,4 +260,6 @@ permissions:
factions.togglealliancechat:
description: toggle alliance chat on and off
factions.dontlosepoweroffline:
description: Don't lose power for being offline.
description: Don't lose power for being offline.
factions.ahome:
description: Ability to send players to their faction home.