mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-23 15:00:37 +01:00
Added extension dump data & make plugins be enabled on reload
This commit is contained in:
parent
805f7f666a
commit
f3a331981f
8 changed files with 39 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.api.extension;
|
||||
|
||||
/**
|
||||
* This is the Geyser extension logger
|
||||
*/
|
||||
public interface ExtensionLogger {
|
||||
/**
|
||||
* Get the logger prefix
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GeyserExtensionDescription implements org.geysermc.geyser.api.exten
|
|||
}
|
||||
|
||||
@Override
|
||||
public String ApiVersion() {
|
||||
public String apiVersion() {
|
||||
return api;
|
||||
}
|
||||
|
||||
|
|
|
@ -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]))) {
|
||||
|
|
Loading…
Reference in a new issue