TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java

47 lines
2 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
2015-04-15 04:06:16 +00:00
import static com.earth2me.essentials.I18n.tl;
2015-04-15 04:06:16 +00:00
public class Commandtpahere extends EssentialsCommand {
public Commandtpahere() {
super("tpahere");
}
2015-04-15 04:06:16 +00:00
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
2015-04-15 04:06:16 +00:00
final User player = getPlayer(server, user, args, 0);
if (user.getName().equalsIgnoreCase(player.getName())) {
throw new NotEnoughArgumentsException();
}
if (!player.isTeleportEnabled()) {
throw new Exception(tl("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
throw new Exception(tl("noPerm", "essentials.worlds." + user.getWorld().getName()));
}
// Don't let sender request teleport twice to the same player.
if (user.getConfigUUID().equals(player.getTeleportRequest())
&& player.isTpRequestHere() == true) { // Make sure the last teleport request was actually tpahere and not tpa
throw new Exception(tl("requestSentAlready", player.getDisplayName()));
}
2015-04-15 04:06:16 +00:00
if (!player.isIgnoredPlayer(user)) {
player.requestTeleport(user, true);
player.sendMessage(tl("teleportHereRequest", user.getDisplayName()));
player.sendMessage(tl("typeTpaccept"));
player.sendMessage(tl("typeTpdeny"));
if (ess.getSettings().getTpaAcceptCancellation() != 0) {
player.sendMessage(tl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()));
}
}
user.sendMessage(tl("requestSent", player.getDisplayName()));
}
}