mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-06-25 23:40:58 +00:00
9a23f806fe
Gradle is better than Maven, don't @ me. okay but actually it's [faster](https://www.youtube.com/watch?v=atuFSv2bLa8&feature=youtu.be&t=77), compiles and tests in parallel more efficiently, and more epic stuff).
44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
package com.earth2me.essentials.commands;
|
|
|
|
import com.earth2me.essentials.User;
|
|
import com.earth2me.essentials.api.IWarps;
|
|
import com.earth2me.essentials.utils.NumberUtil;
|
|
import com.earth2me.essentials.utils.StringUtil;
|
|
import net.ess3.api.InvalidWorldException;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Server;
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
public class Commandsetwarp extends EssentialsCommand {
|
|
public Commandsetwarp() {
|
|
super("setwarp");
|
|
}
|
|
|
|
@Override
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
if (args.length == 0) {
|
|
throw new NotEnoughArgumentsException();
|
|
}
|
|
|
|
if (NumberUtil.isInt(args[0]) || args[0].isEmpty()) {
|
|
throw new Exception(tl("invalidWarpName"));
|
|
}
|
|
|
|
final IWarps warps = ess.getWarps();
|
|
Location warpLoc = null;
|
|
|
|
try {
|
|
warpLoc = warps.getWarp(args[0]);
|
|
} catch (final WarpNotFoundException | InvalidWorldException ignored) {
|
|
}
|
|
|
|
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + StringUtil.safeString(args[0]))) {
|
|
warps.setWarp(user, args[0], user.getLocation());
|
|
} else {
|
|
throw new Exception(tl("warpOverwrite"));
|
|
}
|
|
user.sendMessage(tl("warpSet", args[0]));
|
|
}
|
|
}
|