package cd.casic.plugin.core;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

/**
 * @description: TODO
 * @author: mianbin
 * @date: 2025/5/12 20:38
 * @version: 1.0
 */
@Getter
@Slf4j
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public class BasePlugin extends Plugin {

    protected PluginContext context;

    @Deprecated(since = "1.0.0", forRemoval = true)
    public BasePlugin(PluginWrapper wrapper) {
        super(wrapper);
        log.warn("官方说废弃 Deprecated constructor 'BasePlugin(PluginWrapper wrapper)' called, please use "
                        + "'BasePlugin(PluginContext pluginContext)' instead for plugin '{}',This "
                        + "constructor will be removed in 2.19.0",
                wrapper.getPluginId());
    }

    /**
     * 根据插件主类获取插件包
     *
     * @return String
     */
    public String scanPackage() {
        return this.getClass().getPackage().getName();
    }
}
