Exemplo n.º 1
0
 @Override
 public boolean init() {
   final ParseLogHandler log = SkriptLogger.startParseLogHandler();
   try {
     boolean hasValue = false;
     for (final Class<? extends Event> e : ScriptLoader.getCurrentEvents()) {
       if (getters.containsKey(e)) {
         hasValue = true;
         continue;
       }
       final SerializableGetter<? extends T, ?> getter =
           EventValues.getEventValueGetter(e, c, getTime());
       if (getter != null) {
         getters.put(e, getter);
         hasValue = true;
       }
     }
     if (!hasValue) {
       log.printError(
           "There's no "
               + Classes.getSuperClassInfo(c).getName()
               + " in "
               + Utils.a(ScriptLoader.currentEventName)
               + " event");
       return false;
     }
     log.printLog();
     return true;
   } finally {
     log.stop();
   }
 }
Exemplo n.º 2
0
  static {
    Classes.registerClass(
        new ClassInfo<EntityData>(EntityData.class, "entitydata")
            .user("entity ?types?")
            .name("Entity Type")
            .description(
                "The type of an <a href='#entity'>entity</a>, e.g. player, wolf, powered creeper, etc.")
            .usage("<i>Detailed usage will be added eventually</i>")
            .examples("victim is a cow", "spawn a creeper")
            .since("1.3")
            .defaultExpression(
                new SimpleLiteral<EntityData>(new SimpleEntityData(Entity.class), true))
            .before("entitytype")
            .parser(
                new Parser<EntityData>() {
                  @Override
                  public String toString(final EntityData d, final int flags) {
                    return d.toString(flags);
                  }

                  @Override
                  @Nullable
                  public EntityData parse(final String s, final ParseContext context) {
                    return EntityData.parse(s);
                  }

                  @Override
                  public String toVariableNameString(final EntityData o) {
                    return "entitydata:" + o.toString();
                  }

                  @Override
                  public String getVariableNamePattern() {
                    return "entitydata:.+";
                  }
                })
            .serializer(serializer));
  }
Exemplo n.º 3
0
 @Override
 public Class<?>[] acceptChange(final ChangeMode mode) {
   if (changer == null)
     changer = (SerializableChanger<? super T>) Classes.getSuperClassInfo(c).getChanger();
   return changer == null ? null : changer.acceptChange(mode);
 }
Exemplo n.º 4
0
 @Override
 public String toString(final Event e, final boolean debug) {
   if (!debug || e == null) return "event-" + Classes.getSuperClassInfo(c).getName();
   return Classes.getDebugMessage(getValue(e));
 }