2014-11-07 18:49:54 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2014-12-19 13:51:24 +01:00
|
|
|
import com.massivecraft.factions.Conf;
|
2014-11-11 16:28:53 +01:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.P;
|
2014-11-07 18:49:54 +01:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 04:59:59 +01:00
|
|
|
import com.massivecraft.factions.util.LazyLocation;
|
2015-05-25 01:05:27 +02:00
|
|
|
import com.massivecraft.factions.util.WarmUpUtil;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2015-05-25 01:05:27 +02:00
|
|
|
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;
|
2014-11-07 18:49:54 +01:00
|
|
|
|
2014-12-08 04:59:59 +01:00
|
|
|
import java.util.Map;
|
|
|
|
|
2014-11-07 18:49:54 +01:00
|
|
|
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) {
|
2015-05-25 01:05:27 +02:00
|
|
|
TextComponent component = new TextComponent(TL.COMMAND_FWARP_WARPS.toString());
|
|
|
|
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
2014-12-08 04:59:59 +01:00
|
|
|
Map<String, LazyLocation> warps = myFaction.getWarps();
|
|
|
|
for (String s : warps.keySet()) {
|
2015-05-25 01:05:27 +02:00
|
|
|
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);
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|
2015-05-25 01:05:27 +02:00
|
|
|
fme.getPlayer().spigot().sendMessage(component);
|
2014-11-07 18:49:54 +01:00
|
|
|
} else if (args.size() > 1) {
|
2014-12-08 00:12:52 +01:00
|
|
|
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
2014-11-07 18:49:54 +01:00
|
|
|
} else {
|
2015-01-20 00:59:15 +01:00
|
|
|
final String warpName = argAsString(0);
|
2014-11-07 18:49:54 +01:00
|
|
|
if (myFaction.isWarp(argAsString(0))) {
|
2014-11-11 16:28:53 +01:00
|
|
|
if (!transact(fme)) {
|
|
|
|
return;
|
|
|
|
}
|
2015-05-25 06:42:31 +02:00
|
|
|
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, new Runnable() {
|
2015-01-20 00:59:15 +01:00
|
|
|
@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));
|
2014-11-07 18:49:54 +01:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
fme.msg(TL.COMMAND_FWARP_INVALID, warpName);
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-11 16:28:53 +01:00
|
|
|
|
|
|
|
private boolean transact(FPlayer player) {
|
2014-12-10 00:16:42 +01:00
|
|
|
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());
|
2014-11-11 16:28:53 +01:00
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_FWARP_DESCRIPTION;
|
|
|
|
}
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|