2014-11-07 18:49:54 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2014-11-11 16:28:53 +01:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.P;
|
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2014-11-07 18:49:54 +01:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-11-14 16:46:28 +01:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
|
|
|
import org.bukkit.ChatColor;
|
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) {
|
2014-11-14 16:46:28 +01:00
|
|
|
FancyMessage msg = new FancyMessage("Warps: ").color(ChatColor.GOLD);
|
2014-11-07 18:49:54 +01:00
|
|
|
for (String s : myFaction.getWarps().keySet()) {
|
2014-11-14 16:46:28 +01:00
|
|
|
msg.then(s + " ").tooltip("Click to warp!").command("f warp " + s).color(ChatColor.WHITE);
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|
2014-11-14 16:46:28 +01:00
|
|
|
sendFancyMessage(msg);
|
2014-11-07 18:49:54 +01:00
|
|
|
} else if (args.size() > 1) {
|
|
|
|
fme.msg("<i>/f warp <warpname>");
|
|
|
|
} else {
|
|
|
|
String warpName = argAsString(0);
|
|
|
|
if (myFaction.isWarp(argAsString(0))) {
|
2014-11-11 16:28:53 +01:00
|
|
|
if (!transact(fme)) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-07 18:49:54 +01:00
|
|
|
fme.getPlayer().teleport(myFaction.getWarp(warpName).getLocation());
|
|
|
|
fme.msg("<i>Warped to <a>%s", warpName);
|
|
|
|
} else {
|
|
|
|
fme.msg("<i>Couldn't find warp <a>%s", warpName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-11 16:28:53 +01:00
|
|
|
|
|
|
|
private boolean transact(FPlayer player) {
|
|
|
|
return P.p.getConfig().getBoolean("warp-cost.enabled", false) && !player.isAdminBypassing() && Econ.modifyMoney(player, P.p.getConfig().getDouble("warp-cost.warp", 5), "to warp", "for warping");
|
|
|
|
}
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|