public Construct exec(Target t, Env environment, Construct... args)
     throws ConfigRuntimeException {
   int x;
   int z;
   MCWorld w;
   if (args.length == 2) {
     MCWorld defaultWorld =
         environment.GetPlayer() == null ? null : environment.GetPlayer().getWorld();
     MCLocation l = ObjectGenerator.GetGenerator().location(args[0], defaultWorld, t);
     x = l.getBlockX();
     z = l.getBlockZ();
     w = l.getWorld();
   } else {
     x = (int) Static.getInt(args[0]);
     z = (int) Static.getInt(args[1]);
     if (args.length == 3) {
       w = environment.GetPlayer().getWorld();
     } else {
       w = Static.getServer().getWorld(args[2].val());
     }
   }
   MCBiomeType bt;
   try {
     bt = MCBiomeType.valueOf(args[args.length - 1].val());
   } catch (IllegalArgumentException e) {
     throw new ConfigRuntimeException(
         "The biome type \"" + args[1].val() + "\" does not exist.",
         ExceptionType.FormatException,
         t);
   }
   w.setBiome(x, z, bt);
   return new CVoid(t);
 }
 public Construct exec(Target t, Env environment, Construct... args)
     throws ConfigRuntimeException {
   MCLocation l =
       ObjectGenerator.GetGenerator()
           .location(
               args[0],
               environment.GetPlayer() == null ? null : environment.GetPlayer().getWorld(),
               t);
   return new CBoolean(l.getBlock().isSign(), t);
 }
    public Construct exec(Target t, Env environment, Construct... args)
        throws ConfigRuntimeException {
      MCLocation l =
          ObjectGenerator.GetGenerator()
              .location(
                  args[0],
                  environment.GetPlayer() == null ? null : environment.GetPlayer().getWorld(),
                  t);
      if (l.getBlock().isSign()) {
        String line1 = "";
        String line2 = "";
        String line3 = "";
        String line4 = "";
        if (args.length == 2 && args[1] instanceof CArray) {
          CArray ca = (CArray) args[1];
          if (ca.size() >= 1) {
            line1 = ca.get(0, t).val();
          }
          if (ca.size() >= 2) {
            line2 = ca.get(1, t).val();
          }
          if (ca.size() >= 3) {
            line3 = ca.get(2, t).val();
          }
          if (ca.size() >= 4) {
            line4 = ca.get(3, t).val();
          }

        } else {
          if (args.length >= 2) {
            line1 = args[1].val();
          }
          if (args.length >= 3) {
            line2 = args[2].val();
          }
          if (args.length >= 4) {
            line3 = args[3].val();
          }
          if (args.length >= 5) {
            line4 = args[4].val();
          }
        }
        MCSign s = l.getBlock().getSign();
        s.setLine(0, line1);
        s.setLine(1, line2);
        s.setLine(2, line3);
        s.setLine(3, line4);
        return new CVoid(t);
      } else {
        throw new ConfigRuntimeException(
            "The block at the specified location is not a sign", ExceptionType.RangeException, t);
      }
    }
    public Construct exec(Target t, Env env, Construct... args)
        throws CancelCommandException, ConfigRuntimeException {
      double x = 0;
      double y = 0;
      double z = 0;
      float size = 3;
      MCWorld w = null;
      MCPlayer m = null;

      if (args.length == 2 && args[1] instanceof CInt) {
        CInt temp = (CInt) args[1];
        size = temp.getInt();
      }

      if (size > 100) {
        throw new ConfigRuntimeException(
            "A bit excessive, don't you think? Let's scale that back some, huh?",
            ExceptionType.RangeException,
            t);
      }

      if (!(args[0] instanceof CArray)) {
        throw new ConfigRuntimeException(
            "Expecting an array at parameter 1 of explosion", ExceptionType.CastException, t);
      }

      MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
      w = loc.getWorld();
      x = loc.getX();
      z = loc.getZ();
      y = loc.getY();

      if (w == null) {
        if (!(env.GetCommandSender() instanceof MCPlayer)) {
          throw new ConfigRuntimeException(
              this.getName()
                  + " needs a world in the location array, or a player so it can take the current world of that player.",
              ExceptionType.PlayerOfflineException,
              t);
        }

        m = env.GetPlayer();
        w = m.getWorld();
      }

      w.explosion(x, y, z, size);
      return new CVoid(t);
    }
 public Construct exec(Target t, Env env, Construct... args)
     throws CancelCommandException, ConfigRuntimeException {
   double x = 0;
   double y = 0;
   double z = 0;
   MCWorld w = null;
   String world = null;
   if (env.GetPlayer() instanceof MCPlayer) {
     w = env.GetPlayer().getWorld();
   }
   if (args.length == 1 || args.length == 2) {
     if (args[0] instanceof CArray) {
       MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
       x = loc.getX();
       y = loc.getY();
       z = loc.getZ();
       world = loc.getWorld().getName();
     } else {
       throw new ConfigRuntimeException(
           "get_block_at expects param 1 to be an array", ExceptionType.CastException, t);
     }
     if (args.length == 2) {
       world = args[1].val();
     }
   } else if (args.length == 3 || args.length == 4) {
     x = Static.getDouble(args[0]);
     y = Static.getDouble(args[1]);
     z = Static.getDouble(args[2]);
     if (args.length == 4) {
       world = args[3].val();
     }
   }
   if (world != null) {
     w = Static.getServer().getWorld(world);
   }
   if (w == null) {
     throw new ConfigRuntimeException(
         "The specified world " + world + " doesn't exist",
         ExceptionType.InvalidWorldException,
         t);
   }
   x = java.lang.Math.floor(x);
   y = java.lang.Math.floor(y);
   z = java.lang.Math.floor(z);
   MCBlock b = w.getBlockAt((int) x, (int) y, (int) z);
   return new CString(b.getTypeId() + ":" + b.getData(), t);
 }
    public Construct exec(Target t, Env env, Construct... args)
        throws CancelCommandException, ConfigRuntimeException {
      double x = 0;
      double y = 0;
      double z = 0;
      MCWorld w = null;
      String world = null;
      if (env.GetPlayer() instanceof MCPlayer) {
        w = env.GetPlayer().getWorld();
      }

      if (args[0] instanceof CArray && !(args.length == 3)) {
        MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
        x = loc.getX();
        z = loc.getZ();
        world = loc.getWorld().getName();
        if (args.length == 2) {
          world = args[1].val();
        }
      } else if (args.length == 2 || args.length == 3) {
        x = Static.getDouble(args[0]);
        z = Static.getDouble(args[1]);
        if (args.length == 3) {
          world = args[2].val();
        }
      }

      if (world != null) {
        w = Static.getServer().getWorld(world);
      }
      if (w == null) {
        throw new ConfigRuntimeException(
            "The specified world " + world + " doesn't exist",
            ExceptionType.InvalidWorldException,
            t);
      }
      x = java.lang.Math.floor(x);
      y = java.lang.Math.floor(y) - 1;
      z = java.lang.Math.floor(z);
      MCBlock b = w.getHighestBlockAt((int) x, (int) z);
      return new CArray(t, new CInt(b.getX(), t), new CInt(b.getY(), t), new CInt(b.getZ(), t));
    }
 public Construct exec(Target t, Env environment, Construct... args)
     throws ConfigRuntimeException {
   MCLocation l =
       ObjectGenerator.GetGenerator()
           .location(
               args[0],
               environment.GetPlayer() == null ? null : environment.GetPlayer().getWorld(),
               t);
   if (l.getBlock().isSign()) {
     MCSign s = l.getBlock().getSign();
     CString line1 = new CString(s.getLine(0), t);
     CString line2 = new CString(s.getLine(1), t);
     CString line3 = new CString(s.getLine(2), t);
     CString line4 = new CString(s.getLine(3), t);
     return new CArray(t, line1, line2, line3, line4);
   } else {
     throw new ConfigRuntimeException(
         "The block at the specified location is not a sign", ExceptionType.RangeException, t);
   }
 }
 public Construct exec(Target t, Env environment, Construct... args)
     throws ConfigRuntimeException {
   int x;
   int z;
   MCWorld w;
   if (args.length == 1) {
     MCWorld defaultWorld =
         environment.GetPlayer() == null ? null : environment.GetPlayer().getWorld();
     MCLocation l = ObjectGenerator.GetGenerator().location(args[0], defaultWorld, t);
     x = l.getBlockX();
     z = l.getBlockZ();
     w = l.getWorld();
   } else {
     x = (int) Static.getInt(args[0]);
     z = (int) Static.getInt(args[1]);
     if (args.length == 2) {
       w = environment.GetPlayer().getWorld();
     } else {
       w = Static.getServer().getWorld(args[2].val());
     }
   }
   MCBiomeType bt = w.getBiome(x, z);
   return new CString(bt.name(), t);
 }
 public Construct exec(Target t, Env environment, Construct... args)
     throws ConfigRuntimeException {
   MCLocation l;
   MCPlayer p;
   p = environment.GetPlayer();
   MCWorld w = (p != null ? p.getWorld() : null);
   l = ObjectGenerator.GetGenerator().location(args[0], w, t);
   if (l.getWorld() instanceof CraftWorld) {
     CraftWorld cw = (CraftWorld) l.getWorld();
     net.minecraft.server.Block.byId[l.getBlock().getTypeId()].dropNaturally(
         cw.getHandle(),
         l.getBlockX(),
         l.getBlockY(),
         l.getBlockZ(),
         l.getBlock().getData(),
         1.0f,
         0);
   }
   l.getBlock().setTypeId(0);
   CraftServer cs = (CraftServer) ((BukkitMCServer) Static.getServer()).__Server();
   cs.getHandle().a(new Packet0KeepAlive(), 0);
   return new CVoid(t);
 }
Beispiel #10
0
 /**
  * Gets a Location Object, given a MCLocation
  *
  * @param l
  * @return
  */
 public CArray location(MCLocation l) {
   CArray ca = CArray.GetAssociativeArray(Target.UNKNOWN);
   Construct x = new CDouble(l.getX(), Target.UNKNOWN);
   Construct y = new CDouble(l.getY(), Target.UNKNOWN);
   Construct z = new CDouble(l.getZ(), Target.UNKNOWN);
   Construct world = new CString(l.getWorld().getName(), Target.UNKNOWN);
   Construct yaw = new CDouble(l.getYaw(), Target.UNKNOWN);
   Construct pitch = new CDouble(l.getPitch(), Target.UNKNOWN);
   ca.set("0", x, Target.UNKNOWN);
   ca.set("1", y, Target.UNKNOWN);
   ca.set("2", z, Target.UNKNOWN);
   ca.set("3", world, Target.UNKNOWN);
   ca.set("4", yaw, Target.UNKNOWN);
   ca.set("5", pitch, Target.UNKNOWN);
   ca.set("x", x, Target.UNKNOWN);
   ca.set("y", y, Target.UNKNOWN);
   ca.set("z", z, Target.UNKNOWN);
   ca.set("world", world, Target.UNKNOWN);
   ca.set("yaw", yaw, Target.UNKNOWN);
   ca.set("pitch", pitch, Target.UNKNOWN);
   return ca;
 }
Beispiel #11
0
    public Construct exec(Target t, Env env, Construct... args)
        throws CancelCommandException, ConfigRuntimeException {
      double x = 0;
      double y = 0;
      double z = 0;
      String id = null;
      String world = null;
      MCWorld w = null;
      if (env.GetPlayer() instanceof MCPlayer) {
        w = env.GetPlayer().getWorld();
      }
      if ((args.length == 2 || args.length == 3) && args[0] instanceof CArray) {
        MCLocation l =
            ObjectGenerator.GetGenerator().location(args[0], env.GetPlayer().getWorld(), t);
        x = l.getBlockX();
        y = l.getBlockY();
        z = l.getBlockZ();
        world = l.getWorld().getName();
        id = args[1].val();
        if (args.length == 3) {
          world = args[2].val();
        }

      } else {
        x = Static.getNumber(args[0]);
        y = Static.getNumber(args[1]);
        z = Static.getNumber(args[2]);
        id = args[3].val();
        if (args.length == 5) {
          world = args[4].val();
        }
      }
      if (world != null) {
        w = Static.getServer().getWorld(world);
      }
      if (w == null) {
        throw new ConfigRuntimeException(
            "The specified world " + world + " doesn't exist",
            ExceptionType.InvalidWorldException,
            t);
      }
      x = java.lang.Math.floor(x);
      y = java.lang.Math.floor(y);
      z = java.lang.Math.floor(z);
      int ix = (int) x;
      int iy = (int) y;
      int iz = (int) z;
      MCBlock b = w.getBlockAt(ix, iy, iz);
      StringBuilder data = new StringBuilder();
      StringBuilder meta = new StringBuilder();
      boolean inMeta = false;
      for (int i = 0; i < id.length(); i++) {
        Character c = id.charAt(i);
        if (!inMeta) {
          if (!Character.isDigit(c) && c != ':') {
            throw new ConfigRuntimeException(
                "id must be formatted as such: 'x:y' where x and y are integers",
                ExceptionType.FormatException,
                t);
          }
          if (c == ':') {
            inMeta = true;
            continue;
          }
          data.append(c);
        } else {
          meta.append(c);
        }
      }
      if (meta.length() == 0) {
        meta.append("0");
      }

      int idata = Integer.parseInt(data.toString());
      byte imeta = Byte.parseByte(meta.toString());
      b.setTypeId(idata);
      b.setData(imeta);

      return new CVoid(t);
    }