@Override
 public boolean matches(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   String loc = CoreUtilities.getXthArg(3, lower);
   return loc.equals(CoreUtilities.toLowerCase(notable))
       || tryLocation(new dLocation(event.getPlayer().getLocation()), loc);
 }
 @Override
 public boolean matches(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   String inv = CoreUtilities.getXthArg(2, lower);
   if (!inv.equals("inventory")
       && !inv.equals(CoreUtilities.toLowerCase(inventory.getInventoryType().name()))) {
     return false;
   }
   return true;
 }
  @Override
  public boolean matches(ScriptContainer scriptContainer, String s) {
    String lower = CoreUtilities.toLowerCase(s);
    String cmd = CoreUtilities.getXthArg(1, lower);
    if (cmd.equals("starts") && !state) {
      return false;
    }
    if (cmd.equals("stops") && state) {
      return false;
    }

    return runInCheck(scriptContainer, s, lower, event.getPlayer().getLocation());
  }
 public static dServer getServerFromName(String name) {
   name = CoreUtilities.toLowerCase(name);
   if (onlineServers.containsKey(name)) {
     return onlineServers.get(name);
   }
   return null;
 }
  public static boolean matches(String arg) {
    if (onlineServers.containsKey(CoreUtilities.toLowerCase(arg).replace("server@", ""))) {
      return true;
    }

    return false;
  }
 @Override
 public boolean applyDetermination(ScriptContainer container, String determination) {
   String lower = CoreUtilities.toLowerCase(determination);
   if (lower.equals("buildable")) {
     cancelled = false;
   }
   return super.applyDetermination(container, determination);
 }
 @Override
 public boolean matches(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   String cmd = CoreUtilities.getXthArg(1, lower);
   String veh =
       cmd.equals("destroyed")
           ? CoreUtilities.getXthArg(0, lower)
           : CoreUtilities.getXthArg(2, lower);
   String ent = cmd.equals("destroys") ? CoreUtilities.getXthArg(0, lower) : "";
   if (!vehicle.matchesEntity(veh)) {
     return false;
   }
   if (ent.length() > 0) {
     if (entity == null || !entity.matchesEntity(ent)) {
       return false;
     }
   }
   return runInCheck(scriptContainer, s, lower, vehicle.getLocation());
 }
  @Override
  public boolean matches(ScriptContainer scriptContainer, String s) {
    String lower = CoreUtilities.toLowerCase(s);

    if (!runInCheck(scriptContainer, s, lower, location)) {
      return false;
    }

    String mat1 = CoreUtilities.getXthArg(0, lower);
    if (!tryMaterial(new_material, mat1)) {
      return false;
    }

    String mat2 = CoreUtilities.getXthArg(4, lower);
    if (mat2.length() > 0 && !tryMaterial(old_material, mat2)) {
      return false;
    }
    return true;
  }
  @Fetchable("server")
  public static dServer valueOf(String string, TagContext context) {
    if (string == null) {
      return null;
    }

    dServer server = getServerFromName(CoreUtilities.toLowerCase(string).replace("server@", ""));

    if (server == null) {
      dB.echoError("Specified server '" + string + "' does not exist or is not online.");
    }

    string = CoreUtilities.toLowerCase(string).replace("server@", "");
    if (onlineServers.containsKey(string)) {
      return onlineServers.get(string);
    }
    if (context == null || context.debug) {
      dB.echoError("Specified server '" + string + "' does not exist or is not online.");
    }

    return server;
  }
 @Override
 public boolean couldMatch(ScriptContainer scriptContainer, String s) {
   return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).equals("flying")
       || CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).equals("flight");
 }
 @Override
 public boolean couldMatch(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   return lower.startsWith("player opens");
 }
 public static void removeOnlineServer(String name) {
   name = CoreUtilities.toLowerCase(name);
   if (onlineServers.containsKey(name)) {
     onlineServers.remove(name);
   }
 }
Exemple #13
0
  @Override
  public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

    Element id = scriptEntry.getElement("map-id");
    dWorld create = scriptEntry.getdObject("new");
    Element reset = scriptEntry.getElement("reset");
    dLocation resetLoc = scriptEntry.getdObject("reset-loc");
    Element image = scriptEntry.getElement("image");
    dScript script = scriptEntry.getdObject("script");
    Element resize = scriptEntry.getElement("resize");
    Element width = scriptEntry.getElement("width");
    Element height = scriptEntry.getElement("height");
    Element x = scriptEntry.getElement("x-value");
    Element y = scriptEntry.getElement("y-value");

    dB.report(
        scriptEntry,
        getName(),
        (id != null ? id.debug() : "")
            + (create != null ? create.debug() : "")
            + reset.debug()
            + (resetLoc != null ? resetLoc.debug() : "")
            + (image != null ? image.debug() : "")
            + (script != null ? script.debug() : "")
            + resize.debug()
            + (width != null ? width.debug() : "")
            + (height != null ? height.debug() : "")
            + x.debug()
            + y.debug());

    MapView map = null;
    if (create != null) {
      map = Bukkit.getServer().createMap(create.getWorld());
      scriptEntry.addObject("created_map", new Element(map.getId()));
    } else if (id != null) {
      map = Bukkit.getServer().getMap((short) id.asInt());
      if (map == null)
        throw new CommandExecutionException("No map found for ID '" + id.asInt() + "'!");
    } else {
      throw new CommandExecutionException(
          "The map command failed somehow! Report this to a developer!");
    }

    if (reset.asBoolean()) {
      List<MapRenderer> oldRenderers = DenizenMapManager.removeDenizenRenderers(map);
      for (MapRenderer renderer : oldRenderers) {
        map.addRenderer(renderer);
      }
      if (resetLoc != null) {
        map.setCenterX(resetLoc.getBlockX());
        map.setCenterZ(resetLoc.getBlockZ());
        map.setWorld(resetLoc.getWorld());
      }
    } else if (script != null) {
      DenizenMapManager.removeDenizenRenderers(map);
      ((MapScriptContainer) script.getContainer()).applyTo(map);
    } else {
      DenizenMapRenderer dmr = DenizenMapManager.getDenizenRenderer(map);
      if (image != null) {
        int wide = width != null ? width.asInt() : resize.asBoolean() ? 128 : 0;
        int high = height != null ? height.asInt() : resize.asBoolean() ? 128 : 0;
        if (CoreUtilities.toLowerCase(image.asString()).endsWith(".gif"))
          dmr.addObject(
              new MapAnimatedImage(
                  x.asString(), y.asString(), "true", false, image.asString(), wide, high));
        else
          dmr.addObject(
              new MapImage(
                  x.asString(), y.asString(), "true", false, image.asString(), wide, high));
      }
    }
  }
 @Override
 public boolean couldMatch(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   String cmd = CoreUtilities.getXthArg(1, lower);
   return cmd.equals("destroyed") || cmd.equals("destroys");
 }
 @Override
 public boolean couldMatch(ScriptContainer scriptContainer, String s) {
   return CoreUtilities.toLowerCase(s).startsWith("player walks over");
 }
 @Override
 public boolean matches(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   return runInCheck(scriptContainer, s, lower, location);
 }
  @Override
  public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

    ParticleHelper particleHelper = NMSHandler.getInstance().getParticleHelper();

    // Iterate through arguments
    for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {

      if (!scriptEntry.hasObject("location") && arg.matchesArgumentList(dLocation.class)) {

        scriptEntry.addObject("location", arg.asType(dList.class).filter(dLocation.class));
      } else if (!scriptEntry.hasObject("effect")
          && !scriptEntry.hasObject("particleeffect")
          && !scriptEntry.hasObject("iconcrack")) {

        if (particleHelper.hasParticle(arg.getValue())) {
          scriptEntry.addObject("particleeffect", particleHelper.getParticle(arg.getValue()));
        } else if (arg.matches("random")) {
          // Get another effect if "RANDOM" is used
          if (CoreUtilities.getRandom().nextDouble() < 0.5) {
            // Make sure the new effect is not an invisible effect
            List<Particle> visible = particleHelper.getVisibleParticles();
            scriptEntry.addObject(
                "particleeffect", visible.get(CoreUtilities.getRandom().nextInt(visible.size())));
          } else {
            List<Effect> visual = particleHelper.getVisualEffects();
            scriptEntry.addObject(
                "effect", visual.get(CoreUtilities.getRandom().nextInt(visual.size())));
          }
        } else if (arg.startsWith("iconcrack_")) {
          // Allow iconcrack_[id],[data] for item break effects (ex: iconcrack_1)
          String shrunk = arg.getValue().substring("iconcrack_".length());
          String[] split = shrunk.split(",");
          Element typeId = new Element(split[0]);
          if (typeId.isInt()
              && typeId.asInt() > 0
              && Material.getMaterial(typeId.asInt()) != null) {
            scriptEntry.addObject("iconcrack", typeId);
          } else {
            dB.echoError("Invalid iconcrack_[id]. Must be a valid Material ID, besides 0.");
          }
          Element dataId = new Element(split.length <= 1 ? "0" : split[1]);
          scriptEntry.addObject("iconcrack_data", dataId);
          scriptEntry.addObject("iconcrack_type", new Element("iconcrack"));
        } else if (arg.startsWith("blockcrack_")) {
          String shrunk = arg.getValue().substring("blockcrack_".length());
          Element typeId = new Element(shrunk);
          if (typeId.isInt()
              && typeId.asInt() > 0
              && Material.getMaterial(typeId.asInt()) != null) {
            scriptEntry.addObject("iconcrack", typeId);
          } else {
            dB.echoError("Invalid blockcrack_[id]. Must be a valid Material ID, besides 0.");
          }
          scriptEntry.addObject("iconcrack_type", new Element("blockcrack"));
        } else if (arg.startsWith("blockdust_")) {
          String shrunk = arg.getValue().substring("blockdust_".length());
          Element typeId = new Element(shrunk);
          if (typeId.isInt()
              && typeId.asInt() > 0
              && Material.getMaterial(typeId.asInt()) != null) {
            scriptEntry.addObject("iconcrack", typeId);
          } else {
            dB.echoError("Invalid blockdust_[id]. Must be a valid Material ID, besides 0.");
          }
          scriptEntry.addObject("iconcrack_type", new Element("blockdust"));
        } else if (particleHelper.hasEffect(arg.getValue())) {
          scriptEntry.addObject("effect", particleHelper.getEffect(arg.getValue()));
        }
      } else if (!scriptEntry.hasObject("radius")
          && arg.matchesPrimitive(aH.PrimitiveType.Double)
          && arg.matchesPrefix("visibility", "v", "radius", "r")) {

        scriptEntry.addObject("radius", arg.asElement());
      } else if (!scriptEntry.hasObject("data")
          && arg.matchesPrimitive(aH.PrimitiveType.Double)
          && arg.matchesPrefix("data", "d")) {

        scriptEntry.addObject("data", arg.asElement());
      } else if (!scriptEntry.hasObject("qty")
          && arg.matchesPrimitive(aH.PrimitiveType.Integer)
          && arg.matchesPrefix("qty", "q", "quantity")) {

        scriptEntry.addObject("qty", arg.asElement());
      } else if (!scriptEntry.hasObject("offset")
          && arg.matchesPrimitive(aH.PrimitiveType.Double)
          && arg.matchesPrefix("offset", "o")) {

        double offset = arg.asElement().asDouble();
        scriptEntry.addObject("offset", new dLocation(null, offset, offset, offset));
      } else if (!scriptEntry.hasObject("offset")
          && arg.matchesArgumentType(dLocation.class)
          && arg.matchesPrefix("offset", "o")) {

        scriptEntry.addObject("offset", arg.asType(dLocation.class));
      } else if (!scriptEntry.hasObject("targets")
          && arg.matchesArgumentList(dPlayer.class)
          && arg.matchesPrefix("targets", "target", "t")) {

        scriptEntry.addObject("targets", arg.asType(dList.class).filter(dPlayer.class));
      } else {
        arg.reportUnhandled();
      }
    }

    // Use default values if necessary
    scriptEntry.defaultObject(
        "location",
        ((BukkitScriptEntryData) scriptEntry.entryData).hasNPC()
                && ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().isSpawned()
            ? Arrays.asList(((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getLocation())
            : null,
        ((BukkitScriptEntryData) scriptEntry.entryData).hasPlayer()
                && ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().isOnline()
            ? Arrays.asList(
                ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getLocation())
            : null);
    scriptEntry.defaultObject("data", new Element(0));
    scriptEntry.defaultObject("radius", new Element(15));
    scriptEntry.defaultObject("qty", new Element(1));
    scriptEntry.defaultObject("offset", new dLocation(null, 0.5, 0.5, 0.5));

    // Check to make sure required arguments have been filled

    if (!scriptEntry.hasObject("effect")
        && !scriptEntry.hasObject("particleeffect")
        && !scriptEntry.hasObject("iconcrack")) {
      throw new InvalidArgumentsException("Missing effect argument!");
    }

    if (!scriptEntry.hasObject("location")) {
      throw new InvalidArgumentsException("Missing location argument!");
    }
  }
Exemple #18
0
 public BiomeNMS(Biome biome) {
   this.biomeBase = CraftBlock.biomeToBiomeBase(biome);
   this.name = CoreUtilities.toLowerCase(biome.name());
 }
 @Override
 public boolean couldMatch(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   return lower.contains(" being built");
 }
Exemple #20
0
 @Override
 public boolean accept(File dir, String name) {
   return (CoreUtilities.toLowerCase(name).endsWith(".java"));
 }
 public static void addOnlineServer(String name) {
   onlineServers.put(CoreUtilities.toLowerCase(name), new dServer(name));
 }