Skip to content

Commit

Permalink
fix 1.21.1 craftbukkit
Browse files Browse the repository at this point in the history
  • Loading branch information
alvindimas05 committed Aug 11, 2024
1 parent 55690d4 commit b6a1084
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ public enum ServerPackage {
public static String getServerVersion() {
String name = Bukkit.getServer().getClass().getPackage().getName();

// Bukkit doesn't use server version on the package name after version 1.20.5
// CraftBukkit doesn't use server version on the package name after version 1.20.5
// So we need to add it manually instead
if(!name.contains("v1_")){
String version = Bukkit.getBukkitVersion().split("-")[0];
switch (version){
case "1.20.5":
case "1.20.6":
return "v1_20_R4";
case "1.21": return "v1_21_R1";
}
return switch (version) {
case "1.20.5", "1.20.6" -> "v1_20_R4";
// Set default to latest
default -> "v1_21_R1";
};
}

return name.substring(name.lastIndexOf('.') + 1);
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/org/alvindimas05/lagassist/utils/VersionMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ public static ItemStack[] getStatics() {
public static boolean isV1_8() {
return Bukkit.getVersion().contains("1.8");
}

public static boolean isV1_9() {
return Bukkit.getVersion().contains("1.9");
}

public static boolean isV1_10() {
return Bukkit.getVersion().contains("1.10");
}

public static boolean isV1_11() {
return Bukkit.getVersion().contains("1.11");
}

public static boolean isV1_12() {
return Bukkit.getVersion().contains("1.12");
}

public static boolean isV1_13() {
return Bukkit.getVersion().contains("1.13");
}

public static boolean isV1_14() {
return Bukkit.getVersion().contains("1.14");
}

public static boolean isV1_17() {
return Bukkit.getVersion().contains("1.17");
}

public static boolean isV1_18() {
return Bukkit.getVersion().contains("1.18");
}
Expand All @@ -80,30 +80,30 @@ public static boolean isV1_21() {
public static boolean isV_17Plus() {
return isV1_17() || isV1_18() || isV1_19() || isV1_20() || isV1_21();
}

public static boolean isNewMaterials() {
if (isV1_8()) {
return false;
}

if (isV1_9()) {
return false;
}

if (isV1_10()) {
return false;
}

if (isV1_11()) {
return false;
}

if (isV1_12()) {
return false;
}

return true;

}

public static boolean isPaper() {
Expand Down Expand Up @@ -138,31 +138,31 @@ public static void loadChunk(World world, int x, int z) {
// }
// e.remove();
// }
//
//
chk.unload();
}

public static Object setUnbreakable(ItemMeta imeta, boolean unbreakable) {
return V1_13.setUnbreakable(imeta, unbreakable);
}

public static boolean isUnbreakable(ItemMeta imeta) {
return V1_13.isUnbreakable(imeta);
}

public static boolean isChunkGenerated(World world, Object provider, int x, int z) {
return isNewMaterials() ? V1_13.isChunkGenerated(world, x, z) : Reflection.isChunkExistent(provider, x, z);
}


public static boolean hasPassengers(Entity ent) {
if (isV1_8()) {
return ent.getPassenger() != null;
} else {
return !ent.getPassengers().isEmpty();
}
}

public static double getMaxHealth(LivingEntity ent) {
if (isV1_8()) {
return ent.getMaxHealth();
Expand Down

0 comments on commit b6a1084

Please sign in to comment.