mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Fix Geyser not working in IDE
This commit is contained in:
parent
b5eb27693f
commit
f9fd7cb831
4 changed files with 21 additions and 17 deletions
|
@ -78,7 +78,7 @@ public interface GeyserApiBase {
|
|||
* @return the major API version. Bumped whenever a significant breaking change or feature addition is added.
|
||||
*/
|
||||
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 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}";
|
||||
|
||||
/**
|
||||
|
@ -318,7 +318,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
||||
|
||||
this.newsHandler = new NewsHandler(BRANCH, BUILD_NUMBER);
|
||||
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
||||
|
||||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
||||
|
@ -632,6 +632,14 @@ public class GeyserImpl implements GeyserApi {
|
|||
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) {
|
||||
if (instance == null) {
|
||||
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");
|
||||
if (buildXML.startsWith("<buildNumber>")) {
|
||||
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
|
||||
int buildNum = GeyserImpl.BUILD_NUMBER;
|
||||
int buildNum = this.geyser.buildNumber();
|
||||
if (latestBuildNum == buildNum) {
|
||||
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.no_updates", sender.locale()));
|
||||
} else {
|
||||
|
|
|
@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.Object2ReferenceMap;
|
|||
import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.event.ExtensionEventBus;
|
||||
import org.geysermc.geyser.api.extension.*;
|
||||
|
@ -125,14 +126,6 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||
|
||||
@Override
|
||||
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 {
|
||||
if (Files.notExists(EXTENSION_DIRECTORY)) {
|
||||
Files.createDirectory(EXTENSION_DIRECTORY);
|
||||
|
@ -166,27 +159,30 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||
return;
|
||||
}
|
||||
|
||||
int majorVersion = Geyser.api().majorApiVersion();
|
||||
int minorVersion = Geyser.api().minorApiVersion();
|
||||
|
||||
try {
|
||||
// Check the format: majorVersion.minorVersion.patch
|
||||
if (!API_VERSION_PATTERN.matcher(description.apiVersion()).matches()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
String[] versionArray = description.apiVersion().split("\\.");
|
||||
|
||||
// Completely different API version
|
||||
if (!Objects.equals(Integer.valueOf(versionArray[0]), Integer.valueOf(apiVersion[0]))) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, apiVersion[0] + "." + apiVersion[1]));
|
||||
if (Integer.parseInt(versionArray[0]) != majorVersion) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, majorVersion + "." + minorVersion));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the extension requires new API features, being backwards compatible
|
||||
if (Integer.parseInt(versionArray[1]) > Integer.parseInt(apiVersion[1])) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, apiVersion[0] + "." + apiVersion[1]));
|
||||
if (Integer.parseInt(versionArray[1]) > minorVersion) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, majorVersion + "." + minorVersion));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue