fix: replace usage of core's ServerVersion with new MajorServerVersion

I can't be bothered to update 100+ or whatever usages
and conditions.
Too much brain work to re-think all those constraints.
This commit is contained in:
Christian Koop 2024-07-19 19:09:59 +02:00
parent 1f66573ded
commit 251f7abc61
No known key found for this signature in database
GPG Key ID: 6A4A09E8ED946113
37 changed files with 143 additions and 109 deletions

View File

@ -2,13 +2,12 @@ package com.craftaro.skyblock;
import com.craftaro.core.SongodaCore;
import com.craftaro.core.SongodaPlugin;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerProject;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.configuration.Config;
import com.craftaro.core.gui.GuiManager;
import com.craftaro.core.hooks.HologramManager;
import com.craftaro.core.hooks.LogManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.api.SkyBlockAPI;
import com.craftaro.skyblock.ban.BanManager;
import com.craftaro.skyblock.bank.BankManager;
@ -71,6 +70,7 @@ import com.craftaro.skyblock.usercache.UserCacheManager;
import com.craftaro.skyblock.visit.VisitManager;
import com.craftaro.skyblock.visit.VisitTask;
import com.craftaro.skyblock.world.WorldManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -81,9 +81,7 @@ import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class SkyBlock extends SongodaPlugin {
private FileManager fileManager;
@ -154,17 +152,18 @@ public class SkyBlock extends SongodaPlugin {
@Override
public void onPluginEnable() {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_20) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_20) || MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_8)) {
this.getLogger().warning("This Minecraft version is not officially supported.");
}
if (this.paper = ServerProject.isServer(ServerProject.PAPER)) {
this.paper = ServerProject.isServer(ServerProject.PAPER);
if (this.paper) {
try {
Bukkit.spigot().getClass().getMethod("getPaperConfig");
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) {
this.paperAsync = true;
} else {
this.paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) &&
this.paperAsync = MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13) &&
Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false);
}
} catch (NoSuchMethodException ignored) {
@ -266,7 +265,7 @@ public class SkyBlock extends SongodaPlugin {
pluginManager.registerEvents(new FallBreakListeners(this), this);
pluginManager.registerEvents(new WorldListeners(this), this);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
pluginManager.registerEvents(new SpongeListeners(this), this);
}

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.blockscanner;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.utils.world.WorldUtil;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -272,7 +273,7 @@ public final class BlockScanner extends BukkitRunnable {
for (int z = initZ; z <= lastZ; z++) {
for (int y = scanY; y < world.getMaxHeight(); y++) {
final Optional<XMaterial> type = CompatibleMaterial.getMaterial(
ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)
? shot.getSnapshot().getBlockType(x, y, z) :
MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z)));

View File

@ -1,6 +1,6 @@
package com.craftaro.skyblock.blockscanner;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.compatibility.MajorServerVersion;
import org.bukkit.Material;
import java.util.HashMap;
@ -15,7 +15,7 @@ public final class MaterialIDHelper {
static {
MATERIALS = new HashMap<>();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
for (Material type : Material.values()) {
if (type.isLegacy()) {
MATERIALS.put(type.getId(), type);

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.generator;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XBlock;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -109,7 +110,7 @@ public class GeneratorManager {
@SuppressWarnings("deprecation")
private int getLiquidLevel(Block block) {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12) && block.getState().getBlockData() instanceof Levelled) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12) && block.getState().getBlockData() instanceof Levelled) {
Levelled levelled = (Levelled) block.getState().getBlockData();
return levelled.getLevel();
} else {
@ -131,7 +132,7 @@ public class GeneratorManager {
this.plugin.getSoundManager().playSound(block.getLocation(), XSound.BLOCK_FIRE_EXTINGUISH, 1, 10);
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
XBlock.setType(block, materials);
} else {
ItemStack is = materials.parseItem();

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.island;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -104,7 +105,7 @@ public class IslandLevel {
}
public long getMaterialPoints(String material) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (material.toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -216,7 +217,7 @@ public class IslandLevel {
}
public void setMaterialAmount(String material, long amount) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (material.toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -232,7 +233,7 @@ public class IslandLevel {
}
public long getMaterialAmount(String material) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (material.toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -244,7 +245,7 @@ public class IslandLevel {
}
public void removeMaterial(String material) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (material.toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":

View File

@ -5,6 +5,7 @@ import com.bekvon.bukkit.residence.containers.Flags;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.craftaro.core.compatibility.CompatibleBiome;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.nms.Nms;
import com.craftaro.skyblock.SkyBlock;
@ -1502,7 +1503,7 @@ public class IslandManager {
updateFlight(player);
if (world == IslandWorld.NETHER) {
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
return;
}
}
@ -1665,7 +1666,7 @@ public class IslandManager {
double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d;
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
if (worldList != IslandWorld.NETHER || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (worldList != IslandWorld.NETHER || MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
Nms.getImplementations().getWorldBorder().send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.ISLAND).clone().add(increment, 0, increment));
@ -1677,7 +1678,7 @@ public class IslandManager {
}
} else {
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
if (worldList != IslandWorld.NETHER || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (worldList != IslandWorld.NETHER || MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
Nms.getImplementations().getWorldBorder().send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.levelling;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -260,7 +261,7 @@ public final class IslandLevelManager {
// placed.
// This shouldn't cause any issues besides the task number being increased
// insanely fast.
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
updateLevelLocation(island, location);
});
@ -272,7 +273,7 @@ public final class IslandLevelManager {
private void updateLevelLocation(Island island, Location location) {
Block block = location.getBlock();
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.limit.impl;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -73,7 +74,7 @@ public final class BlockLimitation extends EnumLimitation<XMaterial> {
}
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (type.toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -111,7 +112,7 @@ public final class BlockLimitation extends EnumLimitation<XMaterial> {
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
} else {
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (type.toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.hooks.LogManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XBlock;
@ -115,7 +116,7 @@ public class BlockListeners implements Listener {
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block.getType()).get());
if (stackable != null) {
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -194,7 +195,7 @@ public class BlockListeners implements Listener {
}
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -271,7 +272,7 @@ public class BlockListeners implements Listener {
return;
}
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_8)) {
if (event instanceof BlockMultiPlaceEvent) {
for (BlockState blockState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) {
if (!island.equals(islandManager.getIslandAtLocation(blockState.getLocation()))) {
@ -360,7 +361,7 @@ public class BlockListeners implements Listener {
if (limits.isBlockLimitExceeded(block, limit) && !XMaterial.ENDER_EYE.isSimilar(item)) {
XMaterial material = null;
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -391,7 +392,7 @@ public class BlockListeners implements Listener {
// Not util used 2 islandLevelManager if condition is true
// Sponge level dupe fix
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13) &&
block.getType() == XMaterial.SPONGE.parseMaterial()) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
if (blockLoc.getBlock().getType() == XMaterial.WET_SPONGE.parseMaterial()) {
@ -454,7 +455,7 @@ public class BlockListeners implements Listener {
for (Entity ent : entities) {
boolean witherSkeleton;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
} else {
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
@ -464,7 +465,7 @@ public class BlockListeners implements Listener {
XSound.BLOCK_FIRE_EXTINGUISH.play(block.getLocation());
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
} else {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) {
if (((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) {
event.setCancelled(true);
XSound.BLOCK_FIRE_EXTINGUISH.play(block.getLocation());
@ -488,7 +489,7 @@ public class BlockListeners implements Listener {
return;
}
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_12)) {
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
handleGeneration(block, island, event.getToBlock().getState());
}, 1L);
@ -719,7 +720,7 @@ public class BlockListeners implements Listener {
IslandManager islandManager = this.plugin.getIslandManager();
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to
// ArrayList<BlockState> in 1.14.1
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_13)) {
List<BlockState> blocks = event.getBlocks(); // TODO 1.8
if (event.getBlocks().isEmpty()) {
return;
@ -828,7 +829,7 @@ public class BlockListeners implements Listener {
if (CompatibleMaterial.isAir(destmaterial)) {
return;
}
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
switch (event.getToBlock().getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -868,7 +869,7 @@ public class BlockListeners implements Listener {
XMaterial material = CompatibleMaterial.getMaterial(block.getType()).orElse(null);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_12)
&& material != XMaterial.WATER
&& material != XMaterial.LAVA) {
return false;
@ -952,7 +953,7 @@ public class BlockListeners implements Listener {
BlockState genState = generatorManager.generateBlock(generator, block);
block.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
BlockState tempState = block.getState();
tempState.setData(genState.getData());
tempState.update(true, true);
@ -989,7 +990,7 @@ public class BlockListeners implements Listener {
BlockState genState = generatorManager.generateBlock(generator, block);
state.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
state.setData(genState.getData());
}
islandLevelManager.updateLevel(island, genState.getLocation());

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XBlock;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -242,7 +243,7 @@ public class EntityListeners implements Listener {
return;
}
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersion(MajorServerVersion.V1_8)) {
return;
}
@ -371,7 +372,7 @@ public class EntityListeners implements Listener {
&& configLoad.getBoolean("Island.Spawn.Protection")) {
FallingBlock fallingBlock = (FallingBlock) event.getEntity();
if (fallingBlock.getDropItem()) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
fallingBlock.getWorld().dropItemNaturally(fallingBlock.getLocation(),
new ItemStack(fallingBlock.getBlockData().getMaterial(), 1));
} else {
@ -532,25 +533,25 @@ public class EntityListeners implements Listener {
return;
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_10)) {
if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian) {
return;
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
if (livingEntity instanceof Evoker) {
return;
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_12)) {
if (livingEntity instanceof Llama) {
return;
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_14)) {
if (livingEntity instanceof Ravager || livingEntity instanceof Illager) {
return;
}
@ -577,7 +578,7 @@ public class EntityListeners implements Listener {
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.DROPS)) {
Set<ItemStack> dontMultiply = new HashSet<>();
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_8)) {
EntityEquipment equipment = livingEntity.getEquipment();
if (equipment != null) {
for (ItemStack item : event.getDrops()) {
@ -589,7 +590,7 @@ public class EntityListeners implements Listener {
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) {
if (livingEntity instanceof Steerable) {
Steerable steerable = (Steerable) livingEntity;
if (steerable.hasSaddle()) {
@ -701,7 +702,7 @@ public class EntityListeners implements Listener {
return;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { // getPassengers() was added in 1.11
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) { // getPassengers() was added in 1.11
for (org.bukkit.entity.Entity passenger : entity.getPassengers()) {
passenger.remove();
}

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -46,7 +47,7 @@ public class FallBreakListeners implements Listener {
if (island != null) {
Optional<XMaterial> material = Optional.empty();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
material = CompatibleMaterial.getMaterial(ent.getBlockData().getMaterial());
} else {
try {

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -105,7 +106,7 @@ public class GrowListeners implements Listener {
return;
}
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
try {
Object blockData = block.getClass().getMethod("getBlockData").invoke(block);
if (blockData instanceof org.bukkit.block.data.Ageable) {

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.skyblock.SkyBlock;
@ -124,7 +125,7 @@ public class MoveListeners implements Listener {
player.setLevel(0);
player.setExp(0.0F);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue());
} else {
player.setHealth(player.getMaxHealth());

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.listeners;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.island.Island;
@ -41,7 +42,7 @@ public class SpawnerListeners implements Listener {
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()
&& island.isUpgrade(Upgrade.Type.SPAWNER)) {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
if (spawner.getDelay() == 20) {
spawner.setDelay(10);
}

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.menus;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.utils.SkullItemCreator;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -278,7 +279,7 @@ public class Levelling {
String name = plugin.getLocalizationManager().getLocalizationFor(XMaterial.class).getLocale(materials.get());
if (materials.get() == XMaterial.FARMLAND && ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) {
if (materials.get() == XMaterial.FARMLAND && MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_9)) {
materials = Optional.of(XMaterial.DIRT);
}

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.menus;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.hooks.economies.Economy;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -495,10 +496,10 @@ public class Upgrade {
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
com.craftaro.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
PotionMeta pm = (PotionMeta) potion.getItemMeta();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_10)) {
pm.setBasePotionData(new PotionData(PotionType.SPEED));
} else {
pm.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1, 0), true);
@ -547,11 +548,11 @@ public class Upgrade {
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
com.craftaro.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_8)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_8)) {
potion = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta) potion.getItemMeta();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
pm.setBasePotionData(new PotionData(PotionType.JUMP));
} else {
pm.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 1, 0), true);

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.menus.admin;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.AnvilGui;
import com.craftaro.core.utils.SkullItemCreator;
@ -265,7 +266,7 @@ public class Creator implements Listener {
FileConfiguration configLoad = config.getFileConfiguration();
String inventoryName = "";
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
@ -1212,7 +1213,7 @@ public class Creator implements Listener {
FileConfiguration configLoad = config.getFileConfiguration();
String inventoryName = "";
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.menus.admin;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.AnvilGui;
import com.craftaro.core.utils.SkullItemCreator;
@ -194,7 +195,7 @@ public class Generator implements Listener {
FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.menus.admin;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.AnvilGui;
import com.craftaro.core.utils.SkullItemCreator;
@ -168,7 +169,7 @@ public class Levelling implements Listener {
FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
@ -398,7 +399,7 @@ public class Levelling implements Listener {
XMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType()).get();
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
materials.parseItem().setData(event.getCurrentItem().getData());
}

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.menus.admin;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.AnvilGui;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -240,7 +241,7 @@ public class Upgrade {
ItemStack jumpPotion = new ItemStack(Material.POTION);
com.craftaro.skyblock.upgrade.Upgrade upgrade;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
PotionMeta pm = (PotionMeta) speedPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.SPEED));
speedPotion.setItemMeta(pm);
@ -258,7 +259,7 @@ public class Upgrade {
new Placeholder("%status", getStatus(upgrade))},
null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
PotionMeta pm = (PotionMeta) jumpPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.JUMP));
jumpPotion.setItemMeta(pm);

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.permission;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.config.FileManager;
@ -142,7 +143,7 @@ public class PermissionManager {
registerPermission(new HungerPermission(plugin));
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_20)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_20)) {
registerPermission(new SignEditPermission(plugin));
}

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.permission.permissions.listening;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -49,7 +50,7 @@ public class AnimalBreedingPermission extends ListeningPermission {
} else if (entity.getType() == EntityType.CHICKEN) {
if (!(XMaterial.WHEAT_SEEDS.isSimilar(is)
|| XMaterial.PUMPKIN_SEEDS.isSimilar(is) || XMaterial.MELON_SEEDS.isSimilar(is))) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
if (!(XMaterial.BEETROOT_SEEDS.isSimilar(is))) {
return;
}
@ -86,12 +87,12 @@ public class AnimalBreedingPermission extends ListeningPermission {
return;
}
} else {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_10)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_10)) {
if (entity.getType() == EntityType.LLAMA) {
if (!(XMaterial.HAY_BLOCK.isSimilar(is))) {
return;
}
} else if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
} else if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
if (entity.getType() == EntityType.TURTLE) {
if (!(XMaterial.SEAGRASS.isSimilar(is))) {
return;

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.permission.permissions.listening;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -37,7 +38,7 @@ public class DamagePermission extends ListeningPermission {
return;
}
} else {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_12)) {
if (event.getCause() == EntityDamageEvent.DamageCause.valueOf("ENTITY_SWEEP_ATTACK")) {
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.permission.permissions.listening;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -59,7 +60,7 @@ public class PortalPermission extends ListeningPermission {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL
|| event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL
|| event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL
|| (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
|| (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)
&& event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY)) {
/*event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer()));
Location to = getToLocation(event.getFrom(), event.getPlayer());

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.permission.permissions.listening;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -26,7 +27,7 @@ public class TradingPermission extends ListeningPermission {
Player player = event.getPlayer();
if (event.getRightClicked().getType() == EntityType.VILLAGER
|| ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)
|| MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_14)
&& event.getRightClicked().getType() == EntityType.WANDERING_TRADER) {
cancelAndMessage(event, player, this.plugin, this.messageManager);
}

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.scoreboard;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.placeholder.PlaceholderManager;
@ -24,7 +25,7 @@ class Board {
this.player = player;
this.plugin = plugin;
this.board = this.plugin.getServer().getScoreboardManager().getNewScoreboard();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
this.objective = this.board.registerNewObjective("sb1", "sb2", "sb3");
} else {
this.objective = this.board.registerNewObjective("sb1", "sb2");
@ -66,7 +67,7 @@ class Board {
this.cache.put(line, string);
ScoreboardLine parts;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
parts = convertIntoPieces(string, 64);
} else {
parts = convertIntoPieces(string, 16);

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.stackable;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
@ -147,7 +148,7 @@ public class Stackable {
as.setVisible(false);
as.setGravity(false);
as.setSmall(true);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
as.setMarker(true);
}
as.setBasePlate(true);

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.tasks;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.island.IslandWorld;
@ -50,7 +51,7 @@ public class MobNetherWaterTask extends BukkitRunnable {
if (ent instanceof Blaze || ent instanceof MagmaCube || ent instanceof Wither || ent instanceof Ghast)
return true;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
return ent.getType() == EntityType.WITHER_SKELETON;
} else {
return ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType() == Skeleton.SkeletonType.WITHER;

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.utils.item;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -20,7 +21,7 @@ public class InventoryUtil {
ItemStack is = ammo.get(index);
ItemMeta im = is.getItemMeta();
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
if (((Damageable) im).getDamage() != 0) {
continue;
}
@ -56,7 +57,7 @@ public class InventoryUtil {
ItemMeta im = is.getItemMeta();
if (!im.hasDisplayName()) {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) {
if (((Damageable) im).getDamage() != 0) {
continue;
}

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.utils.item;
import com.craftaro.core.compatibility.ClassMapping;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.MethodMapping;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -18,7 +19,7 @@ import java.lang.reflect.Constructor;
import java.math.BigInteger;
public class ItemStackUtil {
private static final boolean isAbove1_16_R1 = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)
private static final boolean isAbove1_16_R1 = MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)
&& !ServerVersion.getServerVersionString().equals("v1_16_R1");
public static ItemStack deserializeItemStack(String data) {
@ -37,9 +38,9 @@ public class ItemStackUtil {
Object craftItemStack;
assert NMSItemStackClass != null;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
craftItemStack = NMSItemStackClass.getMethod("a", NBTTagCompoundClass).invoke(null, NBTTagCompound);
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
} else if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
craftItemStack = NMSItemStackClass.getConstructor(NBTTagCompoundClass).newInstance(NBTTagCompound);
} else {
craftItemStack = NMSItemStackClass.getMethod("createStack", NBTTagCompoundClass).invoke(null,

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.utils.structure;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.SkyBlock;
import org.bukkit.Bukkit;
@ -20,7 +21,7 @@ public class SchematicUtil {
}
Runnable pasteTask = () -> {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) { // WorldEdit 7
if (MajorServerVersion.isServerVersionAbove(MajorServerVersion.V1_12)) { // WorldEdit 7
com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
try (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader reader = format.getReader(Files.newInputStream(schematicFile.toPath()))) {
com.sk89q.worldedit.extent.clipboard.Clipboard clipboard = reader.read();

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.utils.version;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
@ -197,7 +198,7 @@ public enum CompatibleSpawners {
}
public static CompatibleSpawners getMaterials(Material material, byte data) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
return fromString(material.name());
}

View File

@ -1,5 +1,6 @@
package com.craftaro.skyblock.utils.version;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.utils.StringUtil;
@ -34,7 +35,7 @@ public enum SBiome {
THE_VOID("SKY", XMaterial.OBSIDIAN),
WARM_OCEAN(true, XMaterial.TROPICAL_FISH);
private static final boolean isPostVersion = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13);
private static final boolean isPostVersion = MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13);
private final String legacyName;
private final boolean isPost13;

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.utils.world;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -35,7 +36,7 @@ public final class LocationUtil {
Location tempLoc = LocationUtil.getDefinitiveLocation(loc.clone());
if (tempLoc.getBlock().getType() == Material.WATER) {
tempLoc.getBlock().setType(Material.AIR);
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
} else if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
LocationUtil113.removeWaterLoggedFromLocation(tempLoc);
}
}
@ -72,7 +73,7 @@ public final class LocationUtil {
for (locWorking.setY(locWorking.getBlockY()); locWorking.getBlockY() >= 0; locWorking.setY(locWorking.getBlockY() - 1)) {
if (!locWorking.getBlock().isEmpty()) {
if (locWorking.getBlock().getType() == XMaterial.WATER.parseMaterial() ||
(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) &&
(MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13) &&
locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)) {
loc = locWorking;
}
@ -90,7 +91,7 @@ public final class LocationUtil {
locChecked.getBlock().getType().isBlock() &&
locChecked.add(0d, 1d, 0d).getBlock().getType() == XMaterial.AIR.parseMaterial() &&
locChecked.add(0d, 2d, 0d).getBlock().getType() == XMaterial.AIR.parseMaterial() &&
!(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)) {
!(MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13) && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)) {
safe = true;
switch (CompatibleMaterial.getMaterial(locChecked.getBlock().getType()).orElse(XMaterial.AIR)) {
case ACACIA_DOOR: // <= 1.8.8

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.utils.world.block;
import com.craftaro.core.compatibility.ClassMapping;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.MethodMapping;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
@ -54,7 +55,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setVersion(Integer.parseInt(ServerVersion.getVersionReleaseNumber()));
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
blockData.setBlockData(block.getBlockData().getAsString());
}
@ -77,7 +78,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setPotionEffect(primaryEffectName + ":" + secondaryEffectName);
blockData.setStateType(BlockStateType.BEACON.toString());
} else if (blockState instanceof BrewingStand && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
} else if (blockState instanceof BrewingStand && MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_12)) {
BrewingStand brewingStand = (BrewingStand) blockState;
blockData.setBrewingTime(brewingStand.getBrewingTime());
blockData.setFuelLevel(brewingStand.getFuelLevel());
@ -191,7 +192,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setRotateFace(skull.getRotation().toString());
blockData.setStateType(BlockStateType.SKULL.toString());
} else {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
if (blockState instanceof EndGateway) {
EndGateway endGateway = (EndGateway) blockState;
blockData.setExactTeleport(endGateway.isExactTeleport());
@ -201,7 +202,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setStateType(BlockStateType.ENDGATEWAY.toString());
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
if (blockState instanceof ShulkerBox) {
ShulkerBox shulkerBox = (ShulkerBox) blockState;
@ -217,7 +218,7 @@ public final class BlockUtil extends BlockUtils {
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_14)) {
if (blockState instanceof Barrel) {
Barrel barrel = (Barrel) blockState;
@ -232,7 +233,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setStateType(BlockStateType.BARREL.toString());
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) {
if (blockState instanceof RespawnAnchor) {
RespawnAnchor respawnAnchor = (RespawnAnchor) blockState;
blockData.setCharges(respawnAnchor.getCharges());
@ -247,7 +248,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setFacing(((Stairs) materialData).getFacing().toString());
blockData.setDataType(BlockDataType.STAIRS.toString());
} else if (materialData instanceof org.bukkit.material.FlowerPot) {
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAtOrBelow(MajorServerVersion.V1_12)) {
try {
World world = block.getWorld();
@ -301,7 +302,7 @@ public final class BlockUtil extends BlockUtils {
return;
}
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAtOrBelow(MajorServerVersion.V1_12)) {
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
} else {
block.setBlockData(Bukkit.getServer().createBlockData(blockData.getBlockData()));
@ -334,7 +335,7 @@ public final class BlockUtil extends BlockUtils {
beacon.setSecondaryEffect(PotionEffectType.getByName(potionEffect[1].toUpperCase()));
}
state.update();
} else if (blockTypeState == BlockStateType.BREWINGSTAND && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
} else if (blockTypeState == BlockStateType.BREWINGSTAND && MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_12)) {
BrewingStand brewingStand = (BrewingStand) state;
brewingStand.setBrewingTime(blockData.getBrewingTime());
brewingStand.setFuelLevel(blockData.getFuelLevel());
@ -422,14 +423,14 @@ public final class BlockUtil extends BlockUtils {
skull.setRotation(BlockFace.valueOf(blockData.getRotateFace().toUpperCase()));
skull.setSkullType(SkullType.valueOf(blockData.getSkullType().toUpperCase()));
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_10)) {
skull.setOwningPlayer(Bukkit.getServer().getOfflinePlayer(blockData.getSkullOwner()));
} else {
skull.setOwner(blockData.getSkullOwner());
}
state.update();
} else {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
if (blockTypeState == BlockStateType.ENDGATEWAY) {
EndGateway endGateway = (EndGateway) state;
endGateway.setExactTeleport(blockData.isExactTeleport());
@ -445,7 +446,7 @@ public final class BlockUtil extends BlockUtils {
state.update();
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
if (blockTypeState == BlockStateType.SHULKERBOX) {
ShulkerBox shulkerBox = (ShulkerBox) state;
@ -456,7 +457,7 @@ public final class BlockUtil extends BlockUtils {
}
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_14)) {
if (blockTypeState == BlockStateType.BARREL) {
Barrel barrel = (Barrel) state;
@ -469,7 +470,7 @@ public final class BlockUtil extends BlockUtils {
}
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) {
if (blockTypeState == BlockStateType.RESPAWN_ANCHOR) {
RespawnAnchor respawnAnchor = (RespawnAnchor) state;
respawnAnchor.setCharges(blockData.getCharges());
@ -488,7 +489,7 @@ public final class BlockUtil extends BlockUtils {
state.setData(stairs);
} else if (blockDataType == BlockDataType.FLOWERPOT) {
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), XMaterial.STONE, (byte) 0);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_8) && ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_8) && MajorServerVersion.isServerVersionAtOrBelow(MajorServerVersion.V1_12)) {
if (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR) {
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), XMaterial.STONE, (byte) 0);
}
@ -533,11 +534,11 @@ public final class BlockUtil extends BlockUtils {
materialStr = null;
if (blockData.getVersion() > 12) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
materialStr = flower[0].toUpperCase();
}
} else {
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
materialStr = flower[0].toUpperCase();
}
}
@ -558,7 +559,7 @@ public final class BlockUtil extends BlockUtils {
if (bottomBlock.getType() == Material.AIR && !topBlock.getType().name().equals("DOUBLE_PLANT")) {
bottomBlock.setType(XMaterial.LARGE_FERN.parseMaterial());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionBelow(MajorServerVersion.V1_13)) {
try {
bottomBlock.getClass().getMethod("setData", byte.class).invoke(bottomBlock, (byte) 2);
} catch (Exception ex) {

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.utils.world.entity;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.nms.Nms;
import com.craftaro.skyblock.utils.item.ItemStackUtil;
@ -119,8 +120,8 @@ public final class EntityUtil {
LivingEntity livingEntity = (LivingEntity) entity;
EntityEquipment entityEquipment = livingEntity.getEquipment();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_9)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_10)) {
livingEntity.setAI(entityData.hasAI());
}
@ -175,7 +176,7 @@ public final class EntityUtil {
Material material = CompatibleMaterial.getMaterial(materialData[0].toUpperCase()).get().parseMaterial();
if (material != null) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
((Enderman) entity).setCarriedBlock(Bukkit.getServer().createBlockData(material));
} else {
((Enderman) entity).setCarriedMaterial(new MaterialData(material, data));
@ -229,7 +230,7 @@ public final class EntityUtil {
villager.getInventory().setContents(items.toArray(new ItemStack[0]));
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
if (entity instanceof Llama) {
Llama llama = ((Llama) entity);
llama.setColor(Llama.Color.valueOf(entityData.getLlamaColor().toUpperCase()));
@ -244,7 +245,7 @@ public final class EntityUtil {
llama.getInventory().setContents(items.toArray(new ItemStack[0]));
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_11)) {
if (entity instanceof Parrot) {
((Parrot) entity)
.setVariant(Parrot.Variant.valueOf(entityData.getParrotVariant().toUpperCase()));

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.world.generator;
import com.craftaro.core.compatibility.CompatibleBiome;
import com.craftaro.core.compatibility.MajorServerVersion;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
@ -56,7 +57,7 @@ public class VoidGenerator extends ChunkGenerator {
throw new IllegalStateException("Unexpected value: " + world.getEnvironment());
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there
if (MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there
setChunkBiome3D(biome, biomeGrid, world);
} else {
setChunkBiome2D(biome, biomeGrid);