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:
Ursprung
805f7f666a
Commit
f3a331981f
@ -27,6 +27,9 @@ package org.geysermc.geyser.api.extension;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Geyer extension description
|
||||||
|
*/
|
||||||
public interface ExtensionDescription {
|
public interface ExtensionDescription {
|
||||||
/**
|
/**
|
||||||
* Gets the extension's name
|
* Gets the extension's name
|
||||||
@ -47,7 +50,7 @@ public interface ExtensionDescription {
|
|||||||
*
|
*
|
||||||
* @return the extension's api version
|
* @return the extension's api version
|
||||||
*/
|
*/
|
||||||
String ApiVersion();
|
String apiVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the extension's description
|
* 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 org.geysermc.geyser.api.extension.exception.InvalidExtensionException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The extension loader is responsible for loading, unloading, enabling and disabling extensions
|
||||||
|
*/
|
||||||
public interface ExtensionLoader {
|
public interface ExtensionLoader {
|
||||||
/**
|
/**
|
||||||
* Loads an extension from a given file
|
* Loads an extension from a given file
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.api.extension;
|
package org.geysermc.geyser.api.extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Geyser extension logger
|
||||||
|
*/
|
||||||
public interface ExtensionLogger {
|
public interface ExtensionLogger {
|
||||||
/**
|
/**
|
||||||
* Get the logger prefix
|
* Get the logger prefix
|
||||||
|
@ -30,6 +30,9 @@ import java.io.*;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is to be extended by a Geyser extension
|
||||||
|
*/
|
||||||
public class GeyserExtension {
|
public class GeyserExtension {
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
@ -460,7 +460,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
|
|
||||||
ResourcePack.PACKS.clear();
|
ResourcePack.PACKS.clear();
|
||||||
|
|
||||||
GeyserExtensionManager.getExtensionManager().disableExtensions();
|
GeyserExtensionManager.getInstance().disableExtensions();
|
||||||
|
|
||||||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
||||||
}
|
}
|
||||||
@ -468,6 +468,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
shutdown();
|
shutdown();
|
||||||
|
GeyserExtensionManager.getInstance().enableExtensions();
|
||||||
bootstrap.onEnable();
|
bootstrap.onEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
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.text.AsteriskSerializer;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.network.MinecraftProtocol;
|
import org.geysermc.geyser.network.MinecraftProtocol;
|
||||||
@ -54,10 +56,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -76,6 +75,7 @@ public class DumpInfo {
|
|||||||
private LogsInfo logsInfo;
|
private LogsInfo logsInfo;
|
||||||
private final BootstrapDumpInfo bootstrapInfo;
|
private final BootstrapDumpInfo bootstrapInfo;
|
||||||
private final FlagsInfo flagsInfo;
|
private final FlagsInfo flagsInfo;
|
||||||
|
private final List<ExtensionInfo> extensionInfo;
|
||||||
|
|
||||||
public DumpInfo(boolean addLog) {
|
public DumpInfo(boolean addLog) {
|
||||||
this.versionInfo = new VersionInfo();
|
this.versionInfo = new VersionInfo();
|
||||||
@ -125,6 +125,11 @@ public class DumpInfo {
|
|||||||
this.bootstrapInfo = GeyserImpl.getInstance().getBootstrap().getDumpInfo();
|
this.bootstrapInfo = GeyserImpl.getInstance().getBootstrap().getDumpInfo();
|
||||||
|
|
||||||
this.flagsInfo = new FlagsInfo();
|
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
|
@Getter
|
||||||
@ -277,4 +282,15 @@ public class DumpInfo {
|
|||||||
this.flags = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
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
|
@Override
|
||||||
public String ApiVersion() {
|
public String apiVersion() {
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class GeyserExtensionManager {
|
|||||||
geyserExtensionManager.enableExtensions();
|
geyserExtensionManager.enableExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GeyserExtensionManager getExtensionManager() {
|
public static GeyserExtensionManager getInstance() {
|
||||||
return geyserExtensionManager;
|
return geyserExtensionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ public class GeyserExtensionManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
//Check the format: majorVersion.minorVersion.patch
|
//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();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException | IllegalArgumentException e) {
|
} catch (NullPointerException | IllegalArgumentException e) {
|
||||||
@ -178,7 +178,7 @@ public class GeyserExtensionManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] versionArray = description.ApiVersion().split("\\.");
|
String[] versionArray = description.apiVersion().split("\\.");
|
||||||
|
|
||||||
//Completely different API version
|
//Completely different API version
|
||||||
if (!Objects.equals(Integer.valueOf(versionArray[0]), Integer.valueOf(apiVersion[0]))) {
|
if (!Objects.equals(Integer.valueOf(versionArray[0]), Integer.valueOf(apiVersion[0]))) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren