Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdAHome.java

54 lines
1.3 KiB
Java
Raw Normal View History

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;
2019-06-02 20:28:42 +02:00
this.disableOnSpam = 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;
}
}