Ejemplo n.º 1
0
    @Override
    public IRoutineBuilder getNew(Matcher matcher, ScriptLine scriptLine, EventInfo info) {
      String name = matcher.group(1).toLowerCase();
      IDataProvider<Location> locationDP = DataProvider.parse(info, Location.class, name);
      if (locationDP == null) return null;
      Collection<ModDamageItemStack> items = ItemAliaser.match(matcher.group(2), info);
      if (items == null || items.isEmpty()) return null;

      IDataProvider<? extends Number> quantity;
      if (matcher.group(3) != null)
        quantity = DataProvider.parse(info, Integer.class, matcher.group(3));
      else quantity = new LiteralNumber(1);

      if (quantity == null) return null;

      ModDamageLogger.info("Drop item at " + locationDP + ": " + items);

      DropItem routine = new DropItem(scriptLine, locationDP, items, quantity);
      return new NestedRoutineBuilder(routine, routine.routines, info.chain(myInfo));
    }
Ejemplo n.º 2
0
  public static void register() {
    DataProvider.register(
        Boolean.class,
        pattern,
        new BaseDataParser<Boolean>() {
          @Override
          public IDataProvider<Boolean> parse(EventInfo info, Matcher m, StringMatcher sm) {
            IDataProvider<Boolean> bool = DataProvider.parse(info, Boolean.class, sm.spawn());
            if (bool == null) return null;

            sm.accept();
            return invert(bool);
          }
        });
  }
Ejemplo n.º 3
0
  public static void register() {
    DataProvider.register(
        Boolean.class,
        World.class,
        pattern,
        new IDataParser<Boolean, World>() {
          @Override
          public IDataProvider<Boolean> parse(
              EventInfo info, IDataProvider<World> worldDP, Matcher m, StringMatcher sm) {
            try {
              Environment environment = Environment.valueOf(m.group(1).toUpperCase());

              return new WorldEnvironment(worldDP, environment);
            } catch (IllegalArgumentException e) {
              return null;
            }
          }
        });
  }