All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.whoisamyy.api.plugins.events.Event Maven / Gradle / Ivy

There is a newer version: 0.0.4-release
Show newest version
package ru.whoisamyy.api.plugins.events;

import ru.whoisamyy.api.plugins.events.listeners.EventListener;
import ru.whoisamyy.core.Core;

import java.util.*;

/**
 * Every class that inherits from this must have {@code Class[] allowedTypes} const.
 */
public abstract class Event {
    public HashMap eventParameters = new HashMap<>();
    protected static List parameterNames = new ArrayList<>();
    protected static List> allowedTypes = new ArrayList<>(); //last allowedType must be return type of corresponding method in ru.whoisamyy.core.endpoints.RequestManager

    public Event(Object... parameterValues) throws NoSuchFieldException {
        init();
        for (int i = 0; i < parameterValues.length; i++) {
            //if (parameterValues[i].getClass()== allowedTypes.get(i))
            eventParameters.put(parameterNames.get(i), parameterValues[i]);
            //else throw new NoSuchFieldException();
        }
    }

    abstract void init();

    public void callEvent() {
        EventListener.getInstance().callEvent(this);
        //parameterNames.forEach(x->Core.logger.info(x));
    }


    //todo add more events inheriting this class
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy