2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-11-18 17:42:26 +00:00
|
|
|
import com.earth2me.essentials.Trade;
|
2011-03-30 04:03:21 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.LocationUtil;
|
2017-06-11 00:17:43 +00:00
|
|
|
import com.google.common.collect.Lists;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
2011-12-07 01:12:36 +00:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2017-06-11 00:17:43 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
2012-10-06 02:31:34 +00:00
|
|
|
// This method contains an undocumented sub command #EasterEgg
|
2015-04-15 04:06:16 +00:00
|
|
|
public class Commandjump extends EssentialsCommand {
|
|
|
|
public Commandjump() {
|
|
|
|
super("jump");
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
|
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 > 0 && args[0].contains("lock") && user.isAuthorized("essentials.jump.lock")) {
|
|
|
|
if (user.isFlyClickJump()) {
|
|
|
|
user.setRightClickJump(false);
|
|
|
|
user.sendMessage("Flying wizard mode disabled");
|
|
|
|
} else {
|
|
|
|
user.setRightClickJump(true);
|
|
|
|
user.sendMessage("Enabling flying wizard mode");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2012-08-30 23:47:53 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
Location loc;
|
|
|
|
final Location cloc = user.getLocation();
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
try {
|
|
|
|
loc = LocationUtil.getTarget(user.getBase());
|
|
|
|
loc.setYaw(cloc.getYaw());
|
|
|
|
loc.setPitch(cloc.getPitch());
|
|
|
|
loc.setY(loc.getY() + 1);
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
throw new Exception(tl("jumpError"), ex);
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
final Trade charge = new Trade(this.getName(), ess);
|
|
|
|
charge.isAffordableFor(user);
|
|
|
|
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
|
|
|
|
throw new NoChargeException();
|
|
|
|
}
|
2017-06-11 00:17:43 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1 && user.isAuthorized("essentials.jump.lock")) {
|
|
|
|
// XXX these actually do the same thing
|
|
|
|
return Lists.newArrayList("lock", "unlock");
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|