Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 00:23:03 +01:00
Fix Geyser not working in IDE
Dieser Commit ist enthalten in:
Ursprung
b5eb27693f
Commit
f9fd7cb831
@ -78,7 +78,7 @@ public interface GeyserApiBase {
|
|||||||
* @return the major API version. Bumped whenever a significant breaking change or feature addition is added.
|
* @return the major API version. Bumped whenever a significant breaking change or feature addition is added.
|
||||||
*/
|
*/
|
||||||
default int majorApiVersion() {
|
default int majorApiVersion() {
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +116,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
public static final String GIT_VERSION = "${gitVersion}"; // A fallback for running in IDEs
|
public static final String GIT_VERSION = "${gitVersion}"; // A fallback for running in IDEs
|
||||||
public static final String VERSION = "${version}"; // A fallback for running in IDEs
|
public static final String VERSION = "${version}"; // A fallback for running in IDEs
|
||||||
|
|
||||||
public static final int BUILD_NUMBER = Integer.parseInt("${buildNumber}");
|
public static final String BUILD_NUMBER = "${buildNumber}";
|
||||||
public static final String BRANCH = "${branch}";
|
public static final String BRANCH = "${branch}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,7 +318,7 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
|
|
||||||
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
||||||
|
|
||||||
this.newsHandler = new NewsHandler(BRANCH, BUILD_NUMBER);
|
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
||||||
|
|
||||||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
||||||
@ -632,6 +632,14 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
return this.getConfig().getMaxPlayers();
|
return this.getConfig().getMaxPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int buildNumber() {
|
||||||
|
if (!this.isProductionEnvironment()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(BUILD_NUMBER);
|
||||||
|
}
|
||||||
|
|
||||||
public static GeyserImpl start(PlatformType platformType, GeyserBootstrap bootstrap) {
|
public static GeyserImpl start(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
return new GeyserImpl(platformType, bootstrap);
|
return new GeyserImpl(platformType, bootstrap);
|
||||||
|
@ -79,7 +79,7 @@ public class VersionCommand extends GeyserCommand {
|
|||||||
URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
|
URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
|
||||||
if (buildXML.startsWith("<buildNumber>")) {
|
if (buildXML.startsWith("<buildNumber>")) {
|
||||||
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
|
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
|
||||||
int buildNum = GeyserImpl.BUILD_NUMBER;
|
int buildNum = this.geyser.buildNumber();
|
||||||
if (latestBuildNum == buildNum) {
|
if (latestBuildNum == buildNum) {
|
||||||
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.no_updates", sender.locale()));
|
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.no_updates", sender.locale()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.Object2ReferenceMap;
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.geysermc.api.Geyser;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.event.ExtensionEventBus;
|
import org.geysermc.geyser.api.event.ExtensionEventBus;
|
||||||
import org.geysermc.geyser.api.extension.*;
|
import org.geysermc.geyser.api.extension.*;
|
||||||
@ -125,14 +126,6 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) {
|
protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) {
|
||||||
// noinspection ConstantConditions
|
|
||||||
if (!GeyserImpl.VERSION.contains(".")) {
|
|
||||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_version_number"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] apiVersion = GeyserImpl.VERSION.split("\\.");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Files.notExists(EXTENSION_DIRECTORY)) {
|
if (Files.notExists(EXTENSION_DIRECTORY)) {
|
||||||
Files.createDirectory(EXTENSION_DIRECTORY);
|
Files.createDirectory(EXTENSION_DIRECTORY);
|
||||||
@ -166,27 +159,30 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int majorVersion = Geyser.api().majorApiVersion();
|
||||||
|
int minorVersion = Geyser.api().minorApiVersion();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check the format: majorVersion.minorVersion.patch
|
// Check the format: majorVersion.minorVersion.patch
|
||||||
if (!API_VERSION_PATTERN.matcher(description.apiVersion()).matches()) {
|
if (!API_VERSION_PATTERN.matcher(description.apiVersion()).matches()) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException | IllegalArgumentException e) {
|
} catch (NullPointerException | IllegalArgumentException e) {
|
||||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_format", name, apiVersion[0] + "." + apiVersion[1]));
|
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_format", name, majorVersion + "." + minorVersion));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (Integer.parseInt(versionArray[0]) != majorVersion) {
|
||||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, apiVersion[0] + "." + apiVersion[1]));
|
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, majorVersion + "." + minorVersion));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the extension requires new API features, being backwards compatible
|
// If the extension requires new API features, being backwards compatible
|
||||||
if (Integer.parseInt(versionArray[1]) > Integer.parseInt(apiVersion[1])) {
|
if (Integer.parseInt(versionArray[1]) > minorVersion) {
|
||||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, apiVersion[0] + "." + apiVersion[1]));
|
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, majorVersion + "." + minorVersion));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren