<commit_before>package com.btk5h.skriptmirror.skript;

import com.btk5h.skriptmirror.SkriptMirror;

import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.EventExecutor;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptConfig;
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser;

public class EvtByReflection extends SkriptEvent {
  static {
    Skript.registerEvent("Bukkit Event", EvtByReflection.class, BukkitEvent.class,
        "%strings% [(at|on|with) priority %-number%]");
  }

  private static class PriorityListener implements Listener {
    private EventPriority priority;
    private Set<Class<? extends Event>> events = new HashSet<>();

    public PriorityListener(int priority) {
      this.priority = EventPriority.values()[priority];
    }

    public EventPriority getPriority() {
      return priority;
    }

    public Set<Class<? extends Event>> getEvents() {
      return events;
    }
  }

  private static EventExecutor executor =
      (listener, event) -> Bukkit.getPluginManager()
          .callEvent(new BukkitEvent(event, ((PriorityListener) listener).getPriority()));

  private static PriorityListener[] listeners = new PriorityListener[]{
      new PriorityListener(0),
      new PriorityListener(1),
      new PriorityListener(2),
      new PriorityListener(3),
      new PriorityListener(4),
      new PriorityListener(5)
  };

  static class BukkitEvent extends Event {
    private final static HandlerList handlers = new HandlerList();

    private final Event event;
    private final EventPriority priority;

    public BukkitEvent(Event event, EventPriority priority) {
      this.event = event;
      this.priority = priority;
    }

    public Event getEvent() {
      return event;
    }

    public EventPriority getPriority() {
      return priority;
    }

    public static HandlerList getHandlerList() {
      return handlers;
    }

    @Override
    public HandlerList getHandlers() {
      return handlers;
    }
<commit_msg>Make custom events cancellable<commit_after>package com.btk5h.skriptmirror.skript;

import com.btk5h.skriptmirror.SkriptMirror;

import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.EventExecutor;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptConfig;
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser;

public class EvtByReflection extends SkriptEvent {
  static {
    Skript.registerEvent("Bukkit Event", EvtByReflection.class, BukkitEvent.class,
        "%strings% [(at|on|with) priority %-number%]");
  }

  private static class PriorityListener implements Listener {
    private EventPriority priority;
    private Set<Class<? extends Event>> events = new HashSet<>();

    public PriorityListener(int priority) {
      this.priority = EventPriority.values()[priority];
    }

    public EventPriority getPriority() {
      return priority;
    }

    public Set<Class<? extends Event>> getEvents() {
      return events;
    }
  }

  private static EventExecutor executor =
      (listener, event) -> Bukkit.getPluginManager()
          .callEvent(new BukkitEvent(event, ((PriorityListener) listener).getPriority()));

  private static PriorityListener[] listeners = new PriorityListener[]{
      new PriorityListener(0),
      new PriorityListener(1),
      new PriorityListener(2),
      new PriorityListener(3),
      new PriorityListener(4),
      new PriorityListener(5)
  };

  static class BukkitEvent extends Event implements Cancellable {
    private final static HandlerList handlers = new HandlerList();

    private final Event event;
    private final EventPriority priority;

    public BukkitEvent(Event event, EventPriority priority) {
      this.event = event;
      this.priority = priority;
    }

    public Event getEvent() {
      return event;
    }

    public EventPriority getPriority() {
      return priority;
    }

    public static HandlerList getHandlerList() {
      return handlers;
    }

    @Override
    public HandlerList getHandlers() {
      return handlers;
    }

    @Override
    public boolean isCancelled() {
      return event instanceof Cancellable && ((Cancellable) event).isCancelled();
    }

    @Override
    public void setCancelled(boolean cancel) {
      if (event instanceof Cancellable) {
        ((Cancellable) event).setCancelled(cancel);
      }
    }
{'fraction_non_alphanumeric': 0.097708082026538, 'fraction_numerical': 0.003216726980297547, 'mean_word_length': 3.6064814814814814, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014460', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1416, 'n_words': 350}