3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Added extension dump data & make plugins be enabled on reload

Dieser Commit ist enthalten in:
ImDaBigBoss 2022-01-12 15:31:28 +01:00
Ursprung 805f7f666a
Commit f3a331981f
8 geänderte Dateien mit 39 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -27,6 +27,9 @@ package org.geysermc.geyser.api.extension;
import java.util.List;
/**
* This is the Geyer extension description
*/
public interface ExtensionDescription {
/**
* Gets the extension's name
@ -47,7 +50,7 @@ public interface ExtensionDescription {
*
* @return the extension's api version
*/
String ApiVersion();
String apiVersion();
/**
* Gets the extension's description

Datei anzeigen

@ -29,6 +29,9 @@ import org.geysermc.geyser.api.extension.exception.InvalidDescriptionException;
import org.geysermc.geyser.api.extension.exception.InvalidExtensionException;
import java.io.File;
/**
* The extension loader is responsible for loading, unloading, enabling and disabling extensions
*/
public interface ExtensionLoader {
/**
* Loads an extension from a given file

Datei anzeigen

@ -25,6 +25,9 @@
package org.geysermc.geyser.api.extension;
/**
* This is the Geyser extension logger
*/
public interface ExtensionLogger {
/**
* Get the logger prefix

Datei anzeigen

@ -30,6 +30,9 @@ import java.io.*;
import java.net.URL;
import java.net.URLConnection;
/**
* This class is to be extended by a Geyser extension
*/
public class GeyserExtension {
private boolean initialized = false;
private boolean enabled = false;

Datei anzeigen

@ -460,7 +460,7 @@ public class GeyserImpl implements GeyserApi {
ResourcePack.PACKS.clear();
GeyserExtensionManager.getExtensionManager().disableExtensions();
GeyserExtensionManager.getInstance().disableExtensions();
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
}
@ -468,6 +468,7 @@ public class GeyserImpl implements GeyserApi {
@Override
public void reload() {
shutdown();
GeyserExtensionManager.getInstance().enableExtensions();
bootstrap.onEnable();
}

Datei anzeigen

@ -36,6 +36,8 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.extension.GeyserExtension;
import org.geysermc.geyser.extension.GeyserExtensionManager;
import org.geysermc.geyser.text.AsteriskSerializer;
import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.network.MinecraftProtocol;
@ -54,10 +56,7 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import java.util.stream.Collectors;
@Getter
@ -76,6 +75,7 @@ public class DumpInfo {
private LogsInfo logsInfo;
private final BootstrapDumpInfo bootstrapInfo;
private final FlagsInfo flagsInfo;
private final List<ExtensionInfo> extensionInfo;
public DumpInfo(boolean addLog) {
this.versionInfo = new VersionInfo();
@ -125,6 +125,11 @@ public class DumpInfo {
this.bootstrapInfo = GeyserImpl.getInstance().getBootstrap().getDumpInfo();
this.flagsInfo = new FlagsInfo();
this.extensionInfo = new ArrayList<>();
for (GeyserExtension extension : GeyserExtensionManager.getInstance().getExtensions().values()) {
this.extensionInfo.add(new ExtensionInfo(extension.isEnabled(), extension.name(), extension.description().version(), extension.description().main(), extension.description().authors(), extension.description().apiVersion()));
}
}
@Getter
@ -277,4 +282,15 @@ public class DumpInfo {
this.flags = ManagementFactory.getRuntimeMXBean().getInputArguments();
}
}
@Getter
@AllArgsConstructor
public static class ExtensionInfo {
public boolean enabled;
public String name;
public String version;
public String main;
public List<String> authors;
public String apiVersion;
}
}

Datei anzeigen

@ -85,7 +85,7 @@ public class GeyserExtensionDescription implements org.geysermc.geyser.api.exten
}
@Override
public String ApiVersion() {
public String apiVersion() {
return api;
}

Datei anzeigen

@ -53,7 +53,7 @@ public class GeyserExtensionManager {
geyserExtensionManager.enableExtensions();
}
public static GeyserExtensionManager getExtensionManager() {
public static GeyserExtensionManager getInstance() {
return geyserExtensionManager;
}
@ -170,7 +170,7 @@ public class GeyserExtensionManager {
try {
//Check the format: majorVersion.minorVersion.patch
if (!Pattern.matches("^[0-9]+\\.[0-9]+\\.[0-9]+$", description.ApiVersion())) {
if (!Pattern.matches("^[0-9]+\\.[0-9]+\\.[0-9]+$", description.apiVersion())) {
throw new IllegalArgumentException();
}
} catch (NullPointerException | IllegalArgumentException e) {
@ -178,7 +178,7 @@ public class GeyserExtensionManager {
continue;
}
String[] versionArray = description.ApiVersion().split("\\.");
String[] versionArray = description.apiVersion().split("\\.");
//Completely different API version
if (!Objects.equals(Integer.valueOf(versionArray[0]), Integer.valueOf(apiVersion[0]))) {