mail@pastecode.io avatar
a year ago
2.0 kB
    Gathers the active symbols from the trigger and stores them into the 
    context state. If at any point this cannot be achieved a plugin exception 
    is thrown.
  public void init() {
    final PluginContext ctx = getContext();
    final Profile profile = ctx.get(Profile.class);

    // Ensures the trigger is present and not null
    Trigger trigger;
    try {
      trigger = checkNotNull(ctx.getTrigger(), "Trigger is NULL!");
    } catch (Exception e) {
      throw new PluginException("Trigger is not present!", e);

    Map<TriggerKey, Object> triggerAsMap = trigger.asMap();

    // Throw an exception if a required trigger key isn't present.
    for(SlotTriggerKey triggeringKey: REQUIRED_TRIGGERING_KEYS){
        throw new PluginException("%s Trigger does not contain required keys", INIT_ERROR_PREFIX);

    // Ensure we're only dealing with one award
    SpinLines cause = (SpinLines) triggerAsMap.get(SlotTriggerKey.CAUSE);
    if (cause.getSpinLines().size() != 1) {
      throw new PluginException("%s Trigger CAUSE does not contain a single SpinLine", INIT_ERROR_PREFIX);

    // Get active symbols.
    List<ActiveSymbol> activeSymbolsList = cause.getSpinLines().get(0).getActiveSymbolsList();

    // For debugging the activating symbols that enter the plugin.
      StringBuilder stringBuilder = new StringBuilder();

      for(ActiveSymbol activeSymbols: activeSymbolsList){
        stringBuilder.append("Symbol id: ").append(activeSymbols.getSymbol().getId())

    // Store the active symbol collection
    ctx.get(State.class, Scope.INVOCATION)
        .put(HOLD_TRIGGER_SYMBOL_STATE_KEY, activeSymbolsList);