Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -14,63 +14,63 @@ import java.util.UUID;
|
||||
|
||||
public class CmdFWarp extends FCommand {
|
||||
|
||||
public CmdFWarp() {
|
||||
super();
|
||||
this.aliases.add("warp");
|
||||
this.aliases.add("warps");
|
||||
this.optionalArgs.put("warpname", "warpname");
|
||||
this.optionalArgs.put("password", "password");
|
||||
public CmdFWarp() {
|
||||
super();
|
||||
this.aliases.add("warp");
|
||||
this.aliases.add("warps");
|
||||
this.optionalArgs.put("warpname", "warpname");
|
||||
this.optionalArgs.put("password", "password");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.WARP)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.WARP)
|
||||
.build();
|
||||
}
|
||||
this.requirements = new CommandRequirements.Builder(Permission.WARP)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.WARP)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
if (context.args.size() == 0) {
|
||||
new FactionWarpsFrame(context.faction).buildGUI(context.fPlayer);
|
||||
} else if (context.args.size() > 2) {
|
||||
context.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
||||
} else {
|
||||
final String warpName = context.argAsString(0);
|
||||
final String passwordAttempt = context.argAsString(1);
|
||||
if (context.args.size() == 0) {
|
||||
new FactionWarpsFrame(context.faction).buildGUI(context.fPlayer);
|
||||
} else if (context.args.size() > 2) {
|
||||
context.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
||||
} else {
|
||||
final String warpName = context.argAsString(0);
|
||||
final String passwordAttempt = context.argAsString(1);
|
||||
|
||||
if (context.faction.isWarp(context.argAsString(0))) {
|
||||
if (context.faction.isWarp(context.argAsString(0))) {
|
||||
|
||||
// Check if requires password and if so, check if valid. CASE SENSITIVE
|
||||
if (context.faction.hasWarpPassword(warpName) && !context.faction.isWarpPassword(warpName, passwordAttempt)) {
|
||||
context.faction.msg(TL.COMMAND_FWARP_INVALID_PASSWORD);
|
||||
return;
|
||||
// Check if requires password and if so, check if valid. CASE SENSITIVE
|
||||
if (context.faction.hasWarpPassword(warpName) && !context.faction.isWarpPassword(warpName, passwordAttempt)) {
|
||||
context.faction.msg(TL.COMMAND_FWARP_INVALID_PASSWORD);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check transaction AFTER password check.
|
||||
if (!transact(context.fPlayer, context)) return;
|
||||
|
||||
final FPlayer fPlayer = context.fPlayer;
|
||||
final UUID uuid = context.player.getUniqueId();
|
||||
context.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
|
||||
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
}
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
|
||||
} else {
|
||||
context.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check transaction AFTER password check.
|
||||
if (!transact(context.fPlayer, context)) return;
|
||||
private boolean transact(FPlayer player, CommandContext context) {
|
||||
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = context.fPlayer;
|
||||
final UUID uuid = context.player.getUniqueId();
|
||||
context.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
|
||||
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
}
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
|
||||
} else {
|
||||
context.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean transact(FPlayer player, CommandContext context) {
|
||||
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().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;
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_FWARP_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user