Пример #1
0
    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);
    }
Пример #2
0
 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);
 }
Пример #3
0
    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));
    }
Пример #4
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;
 }