Search in sources :

Example 56 with Trade

use of com.earth2me.essentials.Trade in project Essentials by drtshock.

the class Commandjump method run.

@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;
    }
    Location loc;
    final Location cloc = user.getLocation();
    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);
    }
    final Trade charge = new Trade(this.getName(), ess);
    charge.isAffordableFor(user);
    user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
    throw new NoChargeException();
}
Also used : Trade(com.earth2me.essentials.Trade) Location(org.bukkit.Location)

Example 57 with Trade

use of com.earth2me.essentials.Trade in project Essentials by drtshock.

the class Commandtop method run.

@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
    final int topX = user.getLocation().getBlockX();
    final int topZ = user.getLocation().getBlockZ();
    final float pitch = user.getLocation().getPitch();
    final float yaw = user.getLocation().getYaw();
    final Location loc = LocationUtil.getSafeDestination(new Location(user.getWorld(), topX, user.getWorld().getMaxHeight(), topZ, yaw, pitch));
    user.getTeleport().teleport(loc, new Trade(this.getName(), ess), TeleportCause.COMMAND);
    user.sendMessage(tl("teleportTop", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
Also used : Trade(com.earth2me.essentials.Trade) Location(org.bukkit.Location)

Example 58 with Trade

use of com.earth2me.essentials.Trade in project Essentials by drtshock.

the class Commandtp method run.

@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
    switch(args.length) {
        case 0:
            throw new NotEnoughArgumentsException();
        case 1:
            final User player = getPlayer(server, user, args, 0);
            if (!player.isTeleportEnabled()) {
                throw new Exception(tl("teleportDisabled", player.getDisplayName()));
            }
            if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) {
                throw new Exception(tl("noPerm", "essentials.worlds." + player.getWorld().getName()));
            }
            final Trade charge = new Trade(this.getName(), ess);
            charge.isAffordableFor(user);
            user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
            throw new NoChargeException();
        case 3:
            if (!user.isAuthorized("essentials.tp.position")) {
                throw new Exception(tl("noPerm", "essentials.tp.position"));
            }
            final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + (args[0].length() > 1 ? Double.parseDouble(args[0].substring(1)) : 0) : Double.parseDouble(args[0]);
            final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
            final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + (args[2].length() > 1 ? Double.parseDouble(args[2].substring(1)) : 0) : Double.parseDouble(args[2]);
            if (x2 > 30000000 || y2 > 30000000 || z2 > 30000000 || x2 < -30000000 || y2 < -30000000 || z2 < -30000000) {
                throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
            }
            final Location locpos = new Location(user.getWorld(), x2, y2, z2, user.getLocation().getYaw(), user.getLocation().getPitch());
            user.getTeleport().now(locpos, false, TeleportCause.COMMAND);
            user.sendMessage(tl("teleporting", locpos.getWorld().getName(), locpos.getBlockX(), locpos.getBlockY(), locpos.getBlockZ()));
            break;
        case 4:
            if (!user.isAuthorized("essentials.tp.others")) {
                throw new Exception(tl("noPerm", "essentials.tp.others"));
            }
            if (!user.isAuthorized("essentials.tp.position")) {
                throw new Exception(tl("noPerm", "essentials.tp.position"));
            }
            final User target2 = getPlayer(server, user, args, 0);
            final double x = args[1].startsWith("~") ? target2.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
            final double y = args[2].startsWith("~") ? target2.getLocation().getY() + (args[2].length() > 1 ? Double.parseDouble(args[2].substring(1)) : 0) : Double.parseDouble(args[2]);
            final double z = args[3].startsWith("~") ? target2.getLocation().getZ() + (args[3].length() > 1 ? Double.parseDouble(args[3].substring(1)) : 0) : Double.parseDouble(args[3]);
            if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000) {
                throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
            }
            final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
            if (!target2.isTeleportEnabled()) {
                throw new Exception(tl("teleportDisabled", target2.getDisplayName()));
            }
            user.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
            target2.getTeleport().now(locposother, false, TeleportCause.COMMAND);
            target2.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
            break;
        case 2:
        default:
            if (!user.isAuthorized("essentials.tp.others")) {
                throw new Exception(tl("noPerm", "essentials.tp.others"));
            }
            final User target = getPlayer(server, user, args, 0);
            final User toPlayer = getPlayer(server, user, args, 1);
            if (!target.isTeleportEnabled()) {
                throw new Exception(tl("teleportDisabled", target.getDisplayName()));
            }
            if (!toPlayer.isTeleportEnabled()) {
                throw new Exception(tl("teleportDisabled", toPlayer.getDisplayName()));
            }
            if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + toPlayer.getWorld().getName())) {
                throw new Exception(tl("noPerm", "essentials.worlds." + toPlayer.getWorld().getName()));
            }
            target.sendMessage(tl("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
            target.getTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND);
            break;
    }
}
Also used : Trade(com.earth2me.essentials.Trade) User(com.earth2me.essentials.User) Location(org.bukkit.Location)

Example 59 with Trade

use of com.earth2me.essentials.Trade in project Essentials by drtshock.

the class Commandwarp method warpUser.

private void warpUser(final User owner, final User user, final String name) throws Exception {
    final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
    final Trade chargeCmd = new Trade(this.getName(), ess);
    final BigDecimal fullCharge = chargeWarp.getCommandCost(user).add(chargeCmd.getCommandCost(user));
    final Trade charge = new Trade(fullCharge, ess);
    charge.isAffordableFor(owner);
    if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warps." + name)) {
        throw new Exception(tl("warpUsePermission"));
    }
    owner.getTeleport().warp(user, name, charge, TeleportCause.COMMAND);
}
Also used : Trade(com.earth2me.essentials.Trade) BigDecimal(java.math.BigDecimal)

Example 60 with Trade

use of com.earth2me.essentials.Trade in project Essentials by drtshock.

the class EssentialsCommand method run.

@Override
public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception {
    final Trade charge = new Trade(this.getName(), ess);
    charge.isAffordableFor(user);
    run(server, user, commandLabel, args);
    charge.charge(user);
}
Also used : Trade(com.earth2me.essentials.Trade)

Aggregations

Trade (com.earth2me.essentials.Trade)86 ItemStack (org.bukkit.inventory.ItemStack)26 ChargeException (com.earth2me.essentials.ChargeException)20 BigDecimal (java.math.BigDecimal)18 Location (org.bukkit.Location)18 User (com.earth2me.essentials.User)14 NoChargeException (com.earth2me.essentials.commands.NoChargeException)4 MaxMoneyException (net.ess3.api.MaxMoneyException)4 World (org.bukkit.World)4 Kit (com.earth2me.essentials.Kit)2 Mob (com.earth2me.essentials.Mob)2 Teleport (com.earth2me.essentials.Teleport)2 Commandrepair (com.earth2me.essentials.commands.Commandrepair)2 NotEnoughArgumentsException (com.earth2me.essentials.commands.NotEnoughArgumentsException)2 IText (com.earth2me.essentials.textreader.IText)2 KeywordReplacer (com.earth2me.essentials.textreader.KeywordReplacer)2 TextInput (com.earth2me.essentials.textreader.TextInput)2 TextPager (com.earth2me.essentials.textreader.TextPager)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2