Add warmups for /f home and /f warp
This commit is contained in:
@@ -37,13 +37,18 @@ public class CmdFWarp extends FCommand {
|
||||
} else if (args.size() > 1) {
|
||||
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
||||
} else {
|
||||
String warpName = argAsString(0);
|
||||
final String warpName = argAsString(0);
|
||||
if (myFaction.isWarp(argAsString(0))) {
|
||||
if (!transact(fme)) {
|
||||
return;
|
||||
}
|
||||
fme.getPlayer().teleport(myFaction.getWarp(warpName).getLocation());
|
||||
fme.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation()));
|
||||
Location loc = me.getLocation().clone();
|
||||
final Location loc = me.getLocation().clone();
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if (Conf.homesTeleportAllowedEnemyDistance > 0 &&
|
||||
@@ -110,17 +110,22 @@ public class CmdHome extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<Location>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(myFaction.getHome());
|
||||
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||
}
|
||||
this.doWarmUp(TL.WARMUPS_NOTIFY_TELEPORT, "Home", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<Location>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome());
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0));
|
||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||
}
|
||||
|
||||
me.teleport(myFaction.getHome());
|
||||
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome());
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-home", 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.MCommand;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -286,4 +287,12 @@ public abstract class FCommand extends MCommand<P> {
|
||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
||||
}
|
||||
}
|
||||
|
||||
public void doWarmUp(TL translationKey, String action, Runnable runnable, long delay) {
|
||||
this.doWarmUp(this.fme, translationKey, action, runnable, delay);
|
||||
}
|
||||
|
||||
public void doWarmUp(FPlayer player, TL translationKey, String action, Runnable runnable, long delay) {
|
||||
WarmUpUtil.process(player, translationKey, action, runnable, delay);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user