Skip to content

Commit

Permalink
refactor: use more accurate version check
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Aug 14, 2024
1 parent cbd2fbf commit 443ba1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/java/city/norain/slimefun4/SlimefunExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import city.norain.slimefun4.compatibillty.VersionedEvent;
import city.norain.slimefun4.listener.SlimefunMigrateListener;
import io.github.bakedlibs.dough.versions.MinecraftVersion;
import io.github.bakedlibs.dough.versions.UnknownServerVersionException;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.logging.Level;
import javax.annotation.Nonnull;
Expand All @@ -13,13 +15,23 @@ public final class SlimefunExtended {
@Getter
private static boolean databaseDebugMode = false;

@Getter
private static MinecraftVersion minecraftVersion;

private static void checkDebug() {
if ("true".equals(System.getProperty("slimefun.database.debug"))) {
databaseDebugMode = true;
}
}

public static boolean checkEnvironment(@Nonnull Slimefun sf) {
try {
minecraftVersion = MinecraftVersion.of(sf.getServer());
} catch (UnknownServerVersionException e) {
sf.getLogger().log(Level.WARNING, "无法识别你正在使用的服务端版本 :(");
return false;
}

if (EnvironmentChecker.checkHybridServer()) {
sf.getLogger().log(Level.WARNING, "#######################################################");
sf.getLogger().log(Level.WARNING, "");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils;

import city.norain.slimefun4.SlimefunExtended;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
import io.github.bakedlibs.dough.skins.PlayerHead;
Expand Down Expand Up @@ -510,7 +511,7 @@ private static boolean equalsItemMeta(
return potionMeta.hasBasePotionType()
&& sfPotionMeta.hasBasePotionType()
&& potionMeta.getBasePotionType().equals(sfPotionMeta.getBasePotionType());
} else if (Slimefun.getMinecraftVersion().isMinecraftVersion(20, 2)) {
} else if (SlimefunExtended.getMinecraftVersion().isAtLeast(1, 20, 2)) {
return potionMeta.getBasePotionType().equals(sfPotionMeta.getBasePotionType());
} else {
return potionMeta.getBasePotionData().equals(sfPotionMeta.getBasePotionData());
Expand Down

0 comments on commit 443ba1c

Please sign in to comment.