package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.zcore.util.TL; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import java.util.Map; public class CmdFWarp extends FCommand { public CmdFWarp() { super(); this.aliases.add("warp"); this.aliases.add("warps"); this.optionalArgs.put("warpname", "warpname"); this.permission = Permission.WARP.node; this.senderMustBeMember = true; this.senderMustBeModerator = false; } @Override public void perform() { //TODO: check if in combat. if (args.size() == 0) { TextComponent component = new TextComponent(TL.COMMAND_FWARP_WARPS.toString()); component.setColor(net.md_5.bungee.api.ChatColor.GOLD); Map warps = myFaction.getWarps(); for (String s : warps.keySet()) { TextComponent then = new TextComponent(s + " "); then.setColor(net.md_5.bungee.api.ChatColor.WHITE); then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_FWARP_CLICKTOWARP.toString())})); then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " warp " + s)); component.addExtra(then); } fme.getPlayer().spigot().sendMessage(component); } else if (args.size() > 1) { fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT); } else { final String warpName = argAsString(0); if (myFaction.isWarp(argAsString(0))) { if (!transact(fme)) { return; } this.doWarmUp(TL.WARMUPS_NOTIFY_TELEPORT, warpName, new Runnable() { @Override public void run() { CmdFWarp.this.fme.getPlayer().teleport(CmdFWarp.this.myFaction.getWarp(warpName).getLocation()); CmdFWarp.this.fme.msg(TL.COMMAND_FWARP_WARPED, warpName); } }, this.p.getConfig().getLong("warmups.f-warp", 0)); } else { fme.msg(TL.COMMAND_FWARP_INVALID, warpName); } } } private boolean transact(FPlayer player) { return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); } @Override public TL getUsageTranslation() { return TL.COMMAND_FWARP_DESCRIPTION; } }