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 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 { 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 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); }