3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

start plugin stuff

Dieser Commit ist enthalten in:
EOT3000 2019-07-08 15:47:37 -04:00
Ursprung 6f3c00c6ab
Commit abdd207406
4 geänderte Dateien mit 35 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,18 @@
package org.geysermc.api;
import org.geysermc.api.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
public class Geyser {
private static final List<Plugin> plugins = new ArrayList<>();
public static List<Plugin> getPlugins() {
return new ArrayList<>(plugins);
}
public static void add(Plugin p) {
plugins.add(p);
}
}

Datei anzeigen

@ -8,4 +8,8 @@ public class Plugin {
public void onDisable() {
}
public void onLoad() {
}
}

Datei anzeigen

@ -24,6 +24,7 @@ import org.geysermc.connector.command.GeyserCommandMap;
import org.geysermc.connector.configuration.GeyserConfiguration;
import org.geysermc.connector.console.ConsoleCommandReader;
import org.geysermc.connector.console.GeyserLogger;
import org.geysermc.connector.plugin.Loader;
import java.io.File;
import java.io.FileOutputStream;
@ -93,6 +94,9 @@ public class GeyserConnector {
logger.severe("Failed to create config.yml! Make sure it's up to date and writable!");
shutdown();
}
Loader.start();
commandMap = new GeyserCommandMap(this);
}

Datei anzeigen

@ -2,6 +2,7 @@ package org.geysermc.connector.plugin;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.geysermc.api.Geyser;
import org.geysermc.api.plugin.Plugin;
import java.io.File;
@ -58,7 +59,11 @@ public class Loader extends ClassLoader {
is.close();
((Plugin) Class.forName(yml.main, true, l).newInstance()).onEnable();
Plugin plugin = (Plugin) Class.forName(yml.main, true, l).newInstance();
plugin.onLoad();
Geyser.add(plugin);
} catch (Exception e) {
System.out.println("Error loading plugin " + f.getName());
@ -66,6 +71,9 @@ public class Loader extends ClassLoader {
}
}
}
for(Plugin p : Geyser.getPlugins()) {
p.onEnable();
}
LOADER = l;
}