Skip to content

Commit

Permalink
fixed 1.20.1 versioned grass error
Browse files Browse the repository at this point in the history
  • Loading branch information
FN-FAL113 committed Sep 30, 2024
1 parent dcc11da commit 58f92c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ne.fnfal113</groupId>
<artifactId>FNAmplifications</artifactId>
<version>Unoffical-4.2.2</version>
<version>Unoffical-4.2.3</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

import javax.annotation.Nonnull;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;

import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

public class VersionedMaterial {

public static Material SHORT_GRASS = getKey("grass");
public static Material SHORT_GRASS;

// SHORT_GRASS exists on 1.20.4 versions above
static {
SHORT_GRASS = Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20) ? Material.SHORT_GRASS : getKey("grass");
String version = Bukkit.getBukkitVersion().split("-")[0];
String[] versionArr = version.split("\\.");

int major = Integer.parseInt(versionArr[1]);
int minor = Integer.parseInt(versionArr.length == 2 ? "0" : versionArr[2]);

SHORT_GRASS = major >= 20 && minor >= 4 ? Material.SHORT_GRASS : getKey("grass");
}

public VersionedMaterial() {}
Expand Down

0 comments on commit 58f92c9

Please sign in to comment.