Пример #1
0
 @Override
 public boolean init(
     final Expression<?>[] exprs,
     final int matchedPattern,
     final Kleenean isDelayed,
     final ParseResult parser) {
   switch (matchedPattern) {
     case 0:
       breakLevels = ScriptLoader.currentSections.size() + 1;
       type = EVERYTHING;
       break;
     case 1:
     case 2:
       breakLevels = matchedPattern == 1 ? 1 : Integer.parseInt(parser.regexes.get(0).group());
       type = parser.mark;
       if (breakLevels > numLevels(type)) {
         if (numLevels(type) == 0)
           Skript.error(
               "can't stop any " + names[type] + " as there are no " + names[type] + " present",
               ErrorQuality.SEMANTIC_ERROR);
         else
           Skript.error(
               "can't stop "
                   + breakLevels
                   + " "
                   + names[type]
                   + " as there are only "
                   + numLevels(type)
                   + " "
                   + names[type]
                   + " present",
               ErrorQuality.SEMANTIC_ERROR);
         return false;
       }
       break;
     case 3:
       type = parser.mark;
       breakLevels = numLevels(type);
       if (breakLevels == 0) {
         Skript.error(
             "can't stop any " + names[type] + " as there are no " + names[type] + " present",
             ErrorQuality.SEMANTIC_ERROR);
         return false;
       }
       break;
   }
   return true;
 }
Пример #2
0
 @Nullable
 public E spawn(final Location loc) {
   assert loc != null;
   try {
     final E e = loc.getWorld().spawn(loc, getType());
     if (e == null) throw new IllegalArgumentException();
     if (baby.isTrue() && e instanceof Ageable) ((Ageable) e).setBaby();
     set(e);
     return e;
   } catch (final IllegalArgumentException e) {
     if (Skript.testing()) Skript.error("Can't spawn " + getType().getName());
     return null;
   }
 }