Resource UMC Project

Discussion in 'Spigot Plugin Development' started by iUseRod, Sep 14, 2021.

  1. If you find anything not pleasant or not clean, we can discuss it in this thread!

    (Univeral Main Class) is an open-source project where you can share your thoughts, and commit your ideas, if they're helpful & useful they'll be added to the UMC, i hope everyone shares with us there knowledge to make this the perfect main class for every plugin!

    (if you're here to make jokes or some criticism, your future posts will be immediatly removed & you won't be able to share your ideas with us anymore, unless you appeal and get accepted!)

    Code (Java):
    package perfect.universal.mainClass;

    import org.bukkit.Bukkit;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.Plugin;
    import org.reflections.Reflections;

    import java.lang.reflect.InvocationTargetException;
    import java.util.HashMap;
    import java.util.Map;

    public final class MainClass extends JavaPlugin {
        final static Plugin INSTANCE = MainClass.getPlugin(MainClass.class);
        final static FileConfiguration CONFIG = INSTANCE.getConfig();
        final String ENABLE_MESSAGE = this.getDescription().getName() + " has been enabled \n" +
                "version: " + this.getDescription().getVersion();

        boolean events = false;
        boolean commands = false;
        String listenerPackageName = "listener"; //how it appears on the program:
        Map<String, CommandExecutor> commandsList = new HashMap<>();

        public void onEnable() {
            events = true;
            commands = true;
            addCommand("commandname", null /*command executor class here*/);
            //remember to register this command to the plugin.yml file



        void registerAll() {
            if(events) {

            if(commands) {
                commandsList.forEach((commandName, commandExecutor) -> getCommand(commandName).setExecutor(commandExecutor));

        void registerEvents() {
            String packageName = getClass().getPackage().getName();

            for (Class<?> clazz : new Reflections(packageName + "." + listenerPackageName).getSubTypesOf(Listener.class)) {
                try {
                    Listener listener = (Listener) clazz.getDeclaredConstructor().newInstance();
                    getServer().getPluginManager().registerEvents(listener, this);
                } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {

        void addCommand(String name, CommandExecutor executorClass) {
            commandsList.put(name, executorClass);

        public void onDisable() {}
    needed dependencies:
    #1 iUseRod, Sep 14, 2021
    Last edited: Sep 14, 2021
    • Funny Funny x 4
    • Like Like x 1
    • Optimistic Optimistic x 1
    • Creative Creative x 1
  2. My idea: use JeffLib.
    Also, why the heck aren't you allowing criticism? It's the key to becoming actually good.
    • Agree Agree x 1
  3. The problem with this library is it that it doesn't fully support below version 1.16.3, but i want the Class to support every single minecraft version, or to be universal in other words, sorry! but i can't include that into the UMC.

    (btw why would you leave a "Funny" reaction, i don't find the funny thing about it?)
    • Funny Funny x 1
  4. Why do you use a bool for commands and events if you instantly changes it to true?
    Also, spigot has a default enable message. With this class you'll see two enable messages (I just realized that you declared it but never uses it???).
    You should also follow java naming conventions. final variables should be CAPITALIZED with _ instead of space. Example: PLAYERS_MAP
    • Agree Agree x 2
  5. tf is this
    • Agree Agree x 3
  6. my bad, i forgot to, thanks for the note tho lol

  7. please prevent from posting stuff that aren't related to the project, or trying to be sarcastic about it
  8. please prevent from reinventing a wheel, especially almost effortlessly, in little quantities and without accepting criticism. jefflib does the job for 1.17, and if you code for under 1.17, then just use separate modules; copy Jeff's classes; etc.
    • Like Like x 1