From 4a938a3e85cde2436eb8d829502400f71864b74f Mon Sep 17 00:00:00 2001 From: "version-bump[github-action]" <41898282+version-bump[github-action]@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:40:13 +0000 Subject: [PATCH 1/5] Bump version from 1.3.12 to 1.3.12-SNAPSHOT0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 634cabf..a7fe5cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ # along with this program. If not, see . # group=plugily.projects -version=1.3.12 +version=1.3.12-SNAPSHOT0 From 94bebf23f25aa59bb995dc55318da7d435a98fe2 Mon Sep 17 00:00:00 2001 From: Tigerpanzer_02 <37453987+Tigerpanzer02@users.noreply.github.com> Date: Thu, 11 Jul 2024 22:52:11 +0200 Subject: [PATCH 2/5] Updated XSeries to work with 1.20.6 - 1.21 --- MiniGamesBox API/build.gradle.kts | 2 +- MiniGamesBox Classic/build.gradle.kts | 2 +- .../handlers/setup/items/template/AddonItem.java | 2 +- .../handlers/setup/items/template/PatreonItem.java | 2 +- .../classic/utils/version/VersionUtils.java | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MiniGamesBox API/build.gradle.kts b/MiniGamesBox API/build.gradle.kts index 8bd2213..974faf6 100644 --- a/MiniGamesBox API/build.gradle.kts +++ b/MiniGamesBox API/build.gradle.kts @@ -25,7 +25,7 @@ plugins { dependencies { implementation("me.tigerhix.lib:scoreboard:1.4.4") { isTransitive = false } compileOnly(project(":MiniGamesBox-Database", "shadow")) - compileOnly("com.github.cryptomorin:XSeries:9.10.0") { isTransitive = false } + compileOnly("com.github.cryptomorin:XSeries:11.2.0") { isTransitive = false } } tasks{ diff --git a/MiniGamesBox Classic/build.gradle.kts b/MiniGamesBox Classic/build.gradle.kts index 94ff9dd..9218aa3 100644 --- a/MiniGamesBox Classic/build.gradle.kts +++ b/MiniGamesBox Classic/build.gradle.kts @@ -24,7 +24,7 @@ plugins { dependencies { implementation("me.tigerhix.lib:scoreboard:1.4.4") { isTransitive = false } - implementation("com.github.cryptomorin:XSeries:9.10.0") { isTransitive = false } + implementation("com.github.cryptomorin:XSeries:11.2.0") { isTransitive = false } implementation(project(":MiniGamesBox-API", "shadow")) implementation(project(":MiniGamesBox-Inventory", "shadow")) implementation(project(":MiniGamesBox-Database", "shadow")) diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/AddonItem.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/AddonItem.java index e0e4746..d813201 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/AddonItem.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/AddonItem.java @@ -51,7 +51,7 @@ public ItemStack getItem() { .lore(ChatColor.GOLD + "Custom Kits, Custom Achievements, Custom ranks, Replay Ability and more!") .lore("&aControls") .lore("&eCLICK \n&7-> Link for patreon program") - .enchantment(XEnchantment.DURABILITY.getEnchant()) + .enchantment(XEnchantment.UNBREAKING.getEnchant()) .colorizeItem(); return item.build(); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/PatreonItem.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/PatreonItem.java index 6323dbe..3506c1c 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/PatreonItem.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/setup/items/template/PatreonItem.java @@ -52,7 +52,7 @@ public ItemStack getItem() { .lore(ChatColor.GRAY + "support us by donating on other platforms such as paypal!") .lore("&aControls") .lore("&eCLICK \n&7-> Link for donation options") - .enchantment(XEnchantment.DURABILITY.getEnchant()) + .enchantment(XEnchantment.UNBREAKING.getEnchant()) .colorizeItem(); return item.build(); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java index 95ed4b1..3cde8b8 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java @@ -196,10 +196,10 @@ public static CompletableFuture teleport(Entity entity, Location locati public static void sendParticles(String particleName, Player player, Location location, int count) { if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); location.getWorld().spawnParticle(particle, location, count, 0, 0, 0, 0, getParticleDataType(particle, location)); } else if(isParticleBuilderSupported) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); Object dataType = getParticleDataType(particle, location); if(dataType == null) { @@ -217,10 +217,10 @@ public static void sendParticles(String particleName, Player player, Location lo public static void sendParticles(String particleName, Set players, Location location, int count) { if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); location.getWorld().spawnParticle(particle, location, count, 0, 0, 0, 0, getParticleDataType(particle, location)); } else if(isParticleBuilderSupported) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); Object dataType = getParticleDataType(particle, location); if(dataType == null) { @@ -242,7 +242,7 @@ public static void sendParticles(String particle, Set players, Location public static void sendParticles(String particleName, Set players, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); Object dataType = getParticleDataType(particle, location); if(dataType != null) { @@ -251,7 +251,7 @@ public static void sendParticles(String particleName, Set players, Locat location.getWorld().spawnParticle(particle, location, count, 0, 0, 0, extra); } } else if(isParticleBuilderSupported) { - Particle particle = XParticle.getParticle(particleName); + Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); Object dataType = getParticleDataType(particle, location); if(dataType == null) { From 6a7eaf3d6a2d066343acdd402aa68c946677e245 Mon Sep 17 00:00:00 2001 From: "version-bump[github-action]" <41898282+version-bump[github-action]@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:53:32 +0000 Subject: [PATCH 3/5] Bump version from 1.3.12-SNAPSHOT0 to 1.3.12-SNAPSHOT1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a7fe5cf..3624262 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ # along with this program. If not, see . # group=plugily.projects -version=1.3.12-SNAPSHOT0 +version=1.3.12-SNAPSHOT1 From adf33f3aa5cf785455430a7e983bd4a7d1d241fe Mon Sep 17 00:00:00 2001 From: Tigerpanzer_02 <37453987+Tigerpanzer02@users.noreply.github.com> Date: Sat, 13 Jul 2024 01:28:00 +0200 Subject: [PATCH 4/5] Changed ServerVersion as 1.20.6+ removed package nms --- MiniGamesBox API/build.gradle.kts | 2 +- MiniGamesBox Classic/build.gradle.kts | 2 +- .../minigamesbox/classic/PluginMain.java | 2 +- .../arena/managers/BossbarManager.java | 2 +- .../arguments/PluginArgumentsRegistry.java | 2 +- .../classic/events/CycleEvents.java | 4 +- .../minigamesbox/classic/events/Events.java | 2 +- .../handlers/language/MessageBuilder.java | 2 +- .../classic/handlers/sign/ArenaSign.java | 2 +- .../classic/handlers/sign/SignManager.java | 14 +- .../classic/utils/helper/ItemUtils.java | 4 +- .../utils/hologram/ArmorStandHologram.java | 6 +- .../classic/utils/misc/Debugger.java | 2 +- .../classic/utils/misc/MiscUtils.java | 12 +- .../misc/complement/ComplementAccessor.java | 2 +- .../serialization/InventorySerializer.java | 6 +- .../classic/utils/version/PacketUtils.java | 9 +- .../classic/utils/version/ServerVersion.java | 132 ++++++++---------- .../utils/version/TextComponentBuilder.java | 4 +- .../classic/utils/version/VersionUtils.java | 82 +++++------ .../version/events/EventsInitializer.java | 2 +- 21 files changed, 143 insertions(+), 152 deletions(-) diff --git a/MiniGamesBox API/build.gradle.kts b/MiniGamesBox API/build.gradle.kts index 974faf6..7408fb6 100644 --- a/MiniGamesBox API/build.gradle.kts +++ b/MiniGamesBox API/build.gradle.kts @@ -23,7 +23,7 @@ plugins { } dependencies { - implementation("me.tigerhix.lib:scoreboard:1.4.4") { isTransitive = false } + implementation("me.tigerhix.lib:scoreboard:1.4.5") { isTransitive = false } compileOnly(project(":MiniGamesBox-Database", "shadow")) compileOnly("com.github.cryptomorin:XSeries:11.2.0") { isTransitive = false } } diff --git a/MiniGamesBox Classic/build.gradle.kts b/MiniGamesBox Classic/build.gradle.kts index 9218aa3..e61b09a 100644 --- a/MiniGamesBox Classic/build.gradle.kts +++ b/MiniGamesBox Classic/build.gradle.kts @@ -23,7 +23,7 @@ plugins { } dependencies { - implementation("me.tigerhix.lib:scoreboard:1.4.4") { isTransitive = false } + implementation("me.tigerhix.lib:scoreboard:1.4.5") { isTransitive = false } implementation("com.github.cryptomorin:XSeries:11.2.0") { isTransitive = false } implementation(project(":MiniGamesBox-API", "shadow")) implementation(project(":MiniGamesBox-Inventory", "shadow")) diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/PluginMain.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/PluginMain.java index 27c95a7..967c48e 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/PluginMain.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/PluginMain.java @@ -293,7 +293,7 @@ private boolean validateIfPluginShouldStart() { getServer().getPluginManager().disablePlugin(this); return false; } - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_8)) { MiscUtils.sendLineBreaker(getName()); messageUtils.thisVersionIsNotSupported(); MiscUtils.sendVersionInformation(this, getName(), getDescription()); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/arena/managers/BossbarManager.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/arena/managers/BossbarManager.java index a74ba02..509d470 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/arena/managers/BossbarManager.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/arena/managers/BossbarManager.java @@ -98,7 +98,7 @@ public void bossBarUpdate() { @Override public void doBarAction(IPluginArena.IBarAction action, Player player) { - if (ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_9_R1) || !plugin.getConfigPreferences().getOption("BOSSBAR")) { + if (ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_9) || !plugin.getConfigPreferences().getOption("BOSSBAR")) { return; } switch (action) { diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/commands/arguments/PluginArgumentsRegistry.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/commands/arguments/PluginArgumentsRegistry.java index 857f7b4..4317293 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/commands/arguments/PluginArgumentsRegistry.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/commands/arguments/PluginArgumentsRegistry.java @@ -192,7 +192,7 @@ private void sendAdminHelpCommand(CommandSender sender) { data.addAll(mappedArguments.get(plugin.getPluginNamePrefixLong()).stream().filter(arg -> arg instanceof LabeledCommandArgument) .map(arg -> ((LabeledCommandArgument) arg).getLabelData()).collect(Collectors.toList())); - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_11_R1)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_11)) { for(LabelData labelData : data) { sender.sendMessage(labelData.getText() + " - " + labelData.getDescription().split("\n", 2)[0]); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/CycleEvents.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/CycleEvents.java index 23d11ac..697ab25 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/CycleEvents.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/CycleEvents.java @@ -64,7 +64,7 @@ private void changeWorldCycles() { } private void setWeatherGameRule(World world) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13)) { world.setGameRule(GameRule.DO_WEATHER_CYCLE, false); } else { world.setGameRuleValue("doWeatherCycle", "false"); @@ -72,7 +72,7 @@ private void setWeatherGameRule(World world) { } private void setDayLightGameRule(World world) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13)) { world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); } else { world.setGameRuleValue("doDaylightCycle", "false"); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/Events.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/Events.java index 8837fe6..f99c7b3 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/Events.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/events/Events.java @@ -68,7 +68,7 @@ public void onItemSwap(PlugilyPlayerSwapHandItemsEvent event) { @EventHandler public void onSpawn(CreatureSpawnEvent event) { if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM - || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1) && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.COMMAND)) { + || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17) && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.COMMAND)) { return; } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/language/MessageBuilder.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/language/MessageBuilder.java index 1593a4f..205a34a 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/language/MessageBuilder.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/language/MessageBuilder.java @@ -146,7 +146,7 @@ private void formatSpecialChars() { } private void colorRawMessage() { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1) && message.indexOf('#') != -1) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16) && message.indexOf('#') != -1) { message = MiscUtils.matchColorRegex(message); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/ArenaSign.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/ArenaSign.java index 9b39c5a..e6749d8 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/ArenaSign.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/ArenaSign.java @@ -53,7 +53,7 @@ public ArenaSign(Sign sign, IPluginArena arena) { private void setBehindBlock() { behind = null; if(MaterialUtils.isWallSign(sign.getBlock().getType())) { - behind = ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_14_R1) ? getBlockBehind() : getBlockBehindLegacy(); + behind = ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_14) ? getBlockBehind() : getBlockBehindLegacy(); } } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/SignManager.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/SignManager.java index 07e908a..f6be688 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/SignManager.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/handlers/sign/SignManager.java @@ -180,8 +180,8 @@ public void loadSigns() { org.bukkit.block.BlockState state = loc.getBlock().getState(); if(state instanceof Sign) { arenaSigns.add(new ArenaSign((Sign) state, arena)); - if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_12_R1)) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_20_R1)) { + if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_12)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_20)) { ((Sign) state).setWaxed(true); } else { ((Sign) state).setEditable(false); @@ -213,31 +213,31 @@ public void updateSigns() { switch(arenaSign.getArena().getArenaState()) { case WAITING_FOR_PLAYERS: behind.setType(XMaterial.WHITE_STAINED_GLASS.parseMaterial()); - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { Block.class.getMethod("setData", byte.class).invoke(behind, XMaterial.WHITE_STAINED_GLASS.getData()); } break; case STARTING: behind.setType(XMaterial.YELLOW_STAINED_GLASS.parseMaterial()); - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { Block.class.getMethod("setData", byte.class).invoke(behind, XMaterial.YELLOW_STAINED_GLASS.getData()); } break; case IN_GAME: behind.setType(XMaterial.ORANGE_STAINED_GLASS.parseMaterial()); - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { Block.class.getMethod("setData", byte.class).invoke(behind, XMaterial.ORANGE_STAINED_GLASS.getData()); } break; case ENDING: behind.setType(XMaterial.GRAY_STAINED_GLASS.parseMaterial()); - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { Block.class.getMethod("setData", byte.class).invoke(behind, XMaterial.GRAY_STAINED_GLASS.getData()); } break; case RESTARTING: behind.setType(XMaterial.BLACK_STAINED_GLASS.parseMaterial()); - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { Block.class.getMethod("setData", byte.class).invoke(behind, XMaterial.BLACK_STAINED_GLASS.getData()); } break; diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/ItemUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/ItemUtils.java index 93c86ff..4e48624 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/ItemUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/ItemUtils.java @@ -66,13 +66,13 @@ public static ItemStack getSkull(String url) { SkullMeta headMeta = (SkullMeta) head.getItemMeta(); GameProfile profile; - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_20_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_20)) { profile = new GameProfile(UUID.randomUUID(), "Plugily"); } else { profile = new GameProfile(UUID.randomUUID(), null); } profile.getProperties().put("textures", new Property("textures", url)); - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15)) { try { Method mtd = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class); mtd.setAccessible(true); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/hologram/ArmorStandHologram.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/hologram/ArmorStandHologram.java index 6a272c3..5bafd29 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/hologram/ArmorStandHologram.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/hologram/ArmorStandHologram.java @@ -194,11 +194,11 @@ private void append() { } entityItem.setCustomNameVisible(false); - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_10_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_10)) { entityItem.setGravity(true); } - if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_8_8)) { entityItem.setInvulnerable(true); } VersionUtils.teleport(entityItem, location); @@ -214,7 +214,7 @@ private ArmorStand getEntityArmorStand(double y) { loc.setY(y); World world = loc.getWorld(); - if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_8_R1)) { + if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_8_8)) { world.getNearbyEntities(location, 0.2, 0.2, 0.2).forEach(entity -> { if(entity instanceof ArmorStand && !armorStands.contains(entity) && !plugin.getHologramManager().getArmorStands().contains(entity)) { entity.remove(); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/Debugger.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/Debugger.java index 69a4cb1..c5bfd4b 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/Debugger.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/Debugger.java @@ -65,7 +65,7 @@ public void monitorPerformance(String task) { @Override public void sendConsoleMsg(String msg) { - if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1) && msg.indexOf('#') >= 0) { + if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16) && msg.indexOf('#') >= 0) { msg = MiscUtils.matchColorRegex(msg); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/MiscUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/MiscUtils.java index a6901e1..d87b939 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/MiscUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/MiscUtils.java @@ -56,7 +56,7 @@ private MiscUtils() { } public static String matchColorRegex(String s) { - if(Version.isCurrentLower(Version.v1_16_R1)) { + if(Version.isCurrentLower(Version.v1_16)) { return s; } @@ -198,21 +198,21 @@ public static void sendStartUpMessage(Plugin plugin, String pluginname, PluginDe Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][SNAPSHOT] §eSNAPSHOT builds are just for test purposes and we do not provide any support to them!"); } if(disclaimer) { - if(ServerVersion.Version.isCurrentEqual(Version.v0_0_R0) || ServerVersion.Version.isCurrentLower(Version.v1_12_R1)) { + if(ServerVersion.Version.isCurrentEqual(Version.v0_0_0) || ServerVersion.Version.isCurrentLower(Version.v1_12)) { Bukkit.getConsoleSender().sendMessage("[" + pluginname + "] "); - if(ServerVersion.Version.isCurrentEqual(Version.v0_0_R0)) { + if(ServerVersion.Version.isCurrentEqual(Version.v0_0_0)) { Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][DISCLAIMER] §cIt seems like our system does not know your Server version, you should contact our support!"); } - if(ServerVersion.Version.isCurrentLower(Version.v1_17_R1)) { + if(ServerVersion.Version.isCurrentLower(Version.v1_17)) { Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][DISCLAIMER] §cWe noticed that you are using an older version of Minecraft."); Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][DISCLAIMER] §cPlease keep in mind that newer versions will help improving the security and performance of your server."); - if(ServerVersion.Version.isCurrentLower(Version.v1_12_R1)) { + if(ServerVersion.Version.isCurrentLower(Version.v1_12)) { Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][DISCLAIMER] §cWe do not give official support for old Minecraft versions as they are to outdated, have security risks and slow down dev progress!"); } } } } - if(support && ServerVersion.Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + if(support && ServerVersion.Version.isCurrentEqualOrHigher(Version.v1_12)) { Bukkit.getConsoleSender().sendMessage("[" + pluginname + "] "); Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][SUPPORT] If you have any problems, you can always contact us on our Discord server! ( https://discord.plugily.xyz )"); Bukkit.getConsoleSender().sendMessage("[" + pluginname + "][SUPPORT] You can also check out our wiki at https://wiki.plugily.xyz"); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/complement/ComplementAccessor.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/complement/ComplementAccessor.java index eca3fb2..93f9ef8 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/complement/ComplementAccessor.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/misc/complement/ComplementAccessor.java @@ -33,7 +33,7 @@ public final class ComplementAccessor { } catch(NoSuchMethodException | ClassNotFoundException e) { } - complement = (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R3) && kyoriSupported) + complement = (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16) && kyoriSupported) ? new Complement2() : new Complement1(); } diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/serialization/InventorySerializer.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/serialization/InventorySerializer.java index b829aaa..acb8bb1 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/serialization/InventorySerializer.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/serialization/InventorySerializer.java @@ -111,7 +111,7 @@ public static boolean saveInventoryToFile(JavaPlugin plugin, Player player) { for(int i = 0; i < invContents.length; i++) { ItemStack itemInInv = invContents[i]; if(itemInInv != null && itemInInv.getType() != Material.AIR) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3) && itemInInv.getItemMeta() instanceof SkullMeta) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8) && itemInInv.getItemMeta() instanceof SkullMeta) { SkullMeta skullMeta = ((SkullMeta) itemInInv.getItemMeta()); if(skullMeta.getOwner() != null) { try { @@ -133,7 +133,7 @@ public static boolean saveInventoryToFile(JavaPlugin plugin, Player player) { } } - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { invConfig.set("Offhand", inventory.getItemInOffHand()); } @@ -221,7 +221,7 @@ public static void loadInventory(JavaPlugin plugin, Player player) { } } playerInventory.setArmorContents(armor); - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { playerInventory.setItemInOffHand(invConfig.getItemStack("Offhand", new ItemStack(Material.AIR))); } VersionUtils.setMaxHealth(player, invConfig.getDouble("Max health")); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/PacketUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/PacketUtils.java index 73a7f78..1d5dc79 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/PacketUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/PacketUtils.java @@ -21,6 +21,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; /** @@ -42,12 +43,12 @@ public static void sendPacket(Player player, Object packet) { if (playerConnectionField == null) playerConnectionField = handle.getClass().getField( - (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1) ? "b" : "playerConnection")); + (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17) ? "b" : "playerConnection")); Object playerConnection = playerConnectionField.get(handle); if (sendPacketMethod == null) - sendPacketMethod = playerConnection.getClass().getMethod((ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18_R1) ? "a" : "sendPacket"), + sendPacketMethod = playerConnection.getClass().getMethod((ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18) ? "a" : "sendPacket"), classByName("net.minecraft.network.protocol", "Packet")); sendPacketMethod.invoke(playerConnection, packet); @@ -57,8 +58,8 @@ public static void sendPacket(Player player, Object packet) { } public static Class classByName(String newPackageName, String className) { - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_17_R1) || newPackageName == null) { - newPackageName = "net.minecraft.server." + ServerVersion.Version.getPackageVersion()[3]; + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_17) || newPackageName == null) { + newPackageName = "net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; } try { diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/ServerVersion.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/ServerVersion.java index 5b527bf..8fbddbd 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/ServerVersion.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/ServerVersion.java @@ -20,6 +20,9 @@ import org.bukkit.Bukkit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class ServerVersion { public Version getVersion() { @@ -27,119 +30,106 @@ public Version getVersion() { } public enum Version { - v0_0_R0, - v1_8_R1, - v1_8_R2, - v1_8_R3, - v1_9_R1, - v1_9_R2, - v1_10_R1, - v1_10_R2, - v1_11_R1, - v1_12_R1, - v1_13_R1, - v1_13_R2, - v1_14_R1, - v1_14_R2, - v1_15_R1, - v1_15_R2, - v1_16_R1, - v1_16_R2, - v1_16_R3, - v1_17_R1, - v1_17_R2, - v1_18_R1, - v1_18_R2, - v1_19_R1, - v1_19_R2, - v1_19_R3, - v1_20_R1, - v1_20_R2, - v1_20_R3, - v1_20_R4, - V1_20_R5, - V1_20_R6, - V1_21_R1; - - private final int value; - - private static String[] packageVersion; + v0_0_0(0, 0), + v1_8_8(8, 4), + v1_9(9, 4), + v1_10(10, 2), + v1_11(11, 0), + v1_12(12, 0), + v1_13(13, 1), + v1_14(14, 0), + v1_15(15, 0), + v1_16(16, 0), + v1_17(17, 0), + v1_18(18, 0), + v1_19(19, 0), + v1_20(20, 0), + v1_21(21, 0); + + private static Version current; + private final int minor; + private final int minPatch; - Version() { - value = Integer.parseInt(name().replaceAll("[^\\d.]", "")); + Version(int minor, int minPatch) { + this.minor = minor; + this.minPatch = minPatch; } - public int getValue() { - return value; + public int getMinor() { + return minor; } - public static String[] getPackageVersion() { - if(packageVersion == null) { - packageVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\."); - } - - return packageVersion; + public int getMinPatch() { + return minPatch; } public static Version getCurrent() { - if(current != null) + if(current != null) { return current; + } - String[] v = getPackageVersion(); - String vv = v[v.length - 1]; - for(Version one : values()) { - if(one.name().equalsIgnoreCase(vv)) { - current = one; - break; + Matcher serverVersion = Pattern.compile("^(?\\d+)\\.(?\\d+)(?:\\.(?\\d+))?").matcher(Bukkit.getBukkitVersion()); + if(serverVersion.find()) { + int serverMinor = Integer.parseInt(serverVersion.group("minor")); + String patch = serverVersion.group("patch"); + int serverPatch = Integer.parseInt((patch == null || patch.isEmpty()) ? "0" : patch); + + for(Version value : values()) { + if(value.getMinor() == serverMinor && serverPatch >= value.getMinPatch()) { + current = value; + break; + } } + } else { + throw new IllegalStateException("Cannot parse server version: \"" + Bukkit.getBukkitVersion() + '"'); } - if(current == null) { // If we forgot to add new version to enum - current = Version.v0_0_R0; + if(current == null) { // Fallback + current = Version.v0_0_0; } return current; } public boolean isLower(Version version) { - return value < version.getValue(); + return minor < version.getMinor(); } public boolean isHigher(Version version) { - return value > version.getValue(); + return minor > version.getMinor(); } public boolean isEqual(Version version) { - return value == version.getValue(); + return minor == version.getMinor(); } public boolean isEqualOrLower(Version version) { - return value <= version.getValue(); + return minor <= version.getMinor(); } public boolean isEqualOrHigher(Version version) { - return value >= version.getValue(); + return minor >= version.getMinor(); } - public static boolean isCurrentEqualOrHigher(Version v) { - return getCurrent().getValue() >= v.getValue(); + public static boolean isCurrentEqualOrHigher(Version fixedVersion) { + return getCurrent().getMinor() >= fixedVersion.getMinor(); } - public static boolean isCurrentHigher(Version v) { - return getCurrent().getValue() > v.getValue(); + public static boolean isCurrentHigher(Version fixedVersion) { + return getCurrent().getMinor() > fixedVersion.getMinor(); } - public static boolean isCurrentLower(Version v) { - return getCurrent().getValue() < v.getValue(); + public static boolean isCurrentLower(Version fixedVersion) { + return getCurrent().getMinor() < fixedVersion.getMinor(); } - public static boolean isCurrentEqualOrLower(Version v) { - return getCurrent().getValue() <= v.getValue(); + public static boolean isCurrentEqualOrLower(Version fixedVersion) { + return getCurrent().getMinor() <= fixedVersion.getMinor(); } - public static boolean isCurrentEqual(Version v) { - return getCurrent().getValue() == v.getValue(); + public static boolean isCurrentEqual(Version fixedVersion) { + return getCurrent().getMinor() == fixedVersion.getMinor(); } } } \ No newline at end of file diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/TextComponentBuilder.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/TextComponentBuilder.java index 32997ef..448b51d 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/TextComponentBuilder.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/TextComponentBuilder.java @@ -133,7 +133,7 @@ public void sendPlayer() { } private void send(Player onlinePlayer) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12)) { onlinePlayer.sendRawMessage(message); return; } @@ -142,7 +142,7 @@ private void send(Player onlinePlayer) { component.setClickEvent(new ClickEvent(ClickEvent.Action.valueOf(String.valueOf(clickEventAction)), clickEventValue)); } if(hoverEventAction != null && hoverEventValue != null) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16)) { component.setHoverEvent(new HoverEvent(HoverEvent.Action.valueOf(String.valueOf(hoverEventAction)), new Text(hoverEventValue))); } else { component.setHoverEvent(new HoverEvent(HoverEvent.Action.valueOf(String.valueOf(hoverEventAction)), TextComponent.fromLegacyText(hoverEventValue))); diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java index 3cde8b8..26269f2 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/VersionUtils.java @@ -84,7 +84,7 @@ public final class VersionUtils { isPaper = false; } - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { PARTICLE_VALUES = Stream.of(Particle.values()).map(Enum::toString).filter(string -> !string.contains("legacy")).collect(Collectors.toList()); } else { PARTICLE_VALUES = Stream.of(XParticleLegacy.values()).map(Enum::toString).collect(Collectors.toList()); @@ -96,7 +96,7 @@ public final class VersionUtils { } catch(NoSuchMethodException | NoClassDefFoundError ignored) { } - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R2)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) { iChatBaseComponent = PacketUtils.classByName("net.minecraft.network.chat", "IChatBaseComponent"); chatMessageTypeClass = PacketUtils.classByName("net.minecraft.network.chat", "ChatMessageType"); @@ -153,11 +153,11 @@ public static boolean isPaper() { } public static boolean checkOffHand(EquipmentSlot equipmentSlot) { - return ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && equipmentSlot == EquipmentSlot.OFF_HAND; + return ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9) && equipmentSlot == EquipmentSlot.OFF_HAND; } public static SkullMeta setPlayerHead(Player player, SkullMeta meta) { - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_12_R1)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_12)) { meta.setOwner(player.getName()); } else if(isPaper) { if(player.getPlayerProfile().hasTextures()) { @@ -195,7 +195,7 @@ public static CompletableFuture teleport(Entity entity, Location locati } public static void sendParticles(String particleName, Player player, Location location, int count) { - if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); location.getWorld().spawnParticle(particle, location, count, 0, 0, 0, 0, getParticleDataType(particle, location)); } else if(isParticleBuilderSupported) { @@ -216,7 +216,7 @@ public static void sendParticles(String particleName, Player player, Location lo } public static void sendParticles(String particleName, Set players, Location location, int count) { - if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); location.getWorld().spawnParticle(particle, location, count, 0, 0, 0, 0, getParticleDataType(particle, location)); } else if(isParticleBuilderSupported) { @@ -241,7 +241,7 @@ public static void sendParticles(String particle, Set players, Location } public static void sendParticles(String particleName, Set players, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { - if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(!isPaper && ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { Particle particle = XParticle.of(particleName).orElse(XParticle.ANGRY_VILLAGER).get(); Object dataType = getParticleDataType(particle, location); @@ -272,7 +272,7 @@ public static void sendParticles(String particleName, Set players, Locat // Some particle in new versions needs their own data type // See https://www.spigotmc.org/threads/343001/ private static Object getParticleDataType(Particle particle, Location location) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R2) && particle == Particle.REDSTONE) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13) && particle == Particle.REDSTONE) { return new Particle.DustOptions(Color.RED, 2); } @@ -281,12 +281,12 @@ private static Object getParticleDataType(Particle particle, Location location) } if(particle == Particle.BLOCK_CRACK || particle == Particle.BLOCK_DUST - || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R2) && particle == Particle.FALLING_DUST) - || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18_R1) && particle == Particle.BLOCK_MARKER)) { + || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13) && particle == Particle.FALLING_DUST) + || (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18) && particle == Particle.BLOCK_MARKER)) { return location.getBlock().getType().createBlockData(); } - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_13_R1) && (particle == Particle.LEGACY_BLOCK_CRACK + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_13) && (particle == Particle.LEGACY_BLOCK_CRACK || particle == Particle.LEGACY_BLOCK_DUST || particle == Particle.LEGACY_FALLING_DUST)) { org.bukkit.Material type = location.getBlock().getType(); @@ -297,11 +297,11 @@ private static Object getParticleDataType(Particle particle, Location location) } } - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_19_R1) && (particle == Particle.SCULK_CHARGE || particle == Particle.SHRIEK)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_19) && (particle == Particle.SCULK_CHARGE || particle == Particle.SHRIEK)) { return 0; } - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17)) { if(particle == Particle.DUST_COLOR_TRANSITION) { if(dustTransition == null) { dustTransition = new org.bukkit.Particle.DustTransition(Color.fromRGB(255, 0, 0), Color.fromRGB(255, 255, 255), 1.0F); @@ -337,7 +337,7 @@ public static void updateNameTagsVisibility(Player player, Player other, String team = scoreboard.registerNewTeam(tag); } team.setCanSeeFriendlyInvisibles(false); - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_11_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_11)) { team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER); } else { team.setNameTagVisibility(NameTagVisibility.NEVER); @@ -352,7 +352,7 @@ public static void updateNameTagsVisibility(Player player, Player other, String public static Entity getPassenger(Entity ent) { - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R2)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { return ent.getPassenger(); } else if(!ent.getPassengers().isEmpty()) { return ent.getPassengers().get(0); @@ -362,7 +362,7 @@ public static Entity getPassenger(Entity ent) { } public static void setDurability(ItemStack item, short durability) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13)) { ItemMeta meta = item.getItemMeta(); if(meta instanceof Damageable) { ((Damageable) meta).setDamage(durability); @@ -373,7 +373,7 @@ public static void setDurability(ItemStack item, short durability) { } public static void hidePlayer(JavaPlugin plugin, Player to, Player p) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13)) { to.hidePlayer(plugin, p); } else { to.hidePlayer(p); @@ -381,7 +381,7 @@ public static void hidePlayer(JavaPlugin plugin, Player to, Player p) { } public static void showPlayer(JavaPlugin plugin, Player to, Player p) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_13)) { to.showPlayer(plugin, p); } else { to.showPlayer(p); @@ -389,7 +389,7 @@ public static void showPlayer(JavaPlugin plugin, Player to, Player p) { } public static void setPassenger(Entity to, Entity... passengers) { - if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13_R2)) { + if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_13)) { for(Entity ps : passengers) { to.setPassenger(ps); } @@ -401,7 +401,7 @@ public static void setPassenger(Entity to, Entity... passengers) { } public static void sendTextComponent(CommandSender sender, TextComponent component) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { if(sender instanceof Player) { ((Player) sender).spigot().sendMessage(component); } else { @@ -413,19 +413,19 @@ public static void sendTextComponent(CommandSender sender, TextComponent compone } public static void setGlowing(Player player, boolean value) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { player.setGlowing(value); } } public static void setGlowing(Entity entity, boolean value) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) { entity.setGlowing(value); } } public static void setCollidable(Player player, boolean value) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { //player.spigot().setCollidesWithEntities(value); } else { player.setCollidable(value); @@ -433,7 +433,7 @@ public static void setCollidable(Player player, boolean value) { } public static void setCollidable(ArmorStand stand, boolean value) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { //stand.spigot().setCollidesWithEntities(value); } else { stand.setCollidable(value); @@ -446,7 +446,7 @@ public static double getHealth(Player player) { } public static double getMaxHealth(LivingEntity entity) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { return entity.getMaxHealth(); } @@ -455,7 +455,7 @@ public static double getMaxHealth(LivingEntity entity) { } public static void setMaxHealth(Player player, double health) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { player.setMaxHealth(health); } else { MiscUtils.getEntityAttribute(player, Attribute.GENERIC_MAX_HEALTH).ifPresent(ai -> ai.setBaseValue(health)); @@ -463,7 +463,7 @@ public static void setMaxHealth(Player player, double health) { } public static void setMaxHealth(LivingEntity entity, double health) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { entity.setMaxHealth(health); } else { MiscUtils.getEntityAttribute(entity, Attribute.GENERIC_MAX_HEALTH).ifPresent(ai -> ai.setBaseValue(health)); @@ -471,14 +471,14 @@ public static void setMaxHealth(LivingEntity entity, double health) { } public static ItemStack getItemInHand(Player player) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { return player.getItemInHand(); } return player.getInventory().getItemInMainHand(); } public static void setMaterialCooldown(HumanEntity entity, Material material, int ticks) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { ///no method on 1.8! return; } @@ -486,7 +486,7 @@ public static void setMaterialCooldown(HumanEntity entity, Material material, in } public static void setItemInHand(Player player, ItemStack stack) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { player.setItemInHand(stack); return; } @@ -499,7 +499,7 @@ public static void setItemInHand(LivingEntity entity, ItemStack stack) { if(equipment == null) { return; } - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { equipment.setItemInHand(stack); return; } @@ -512,7 +512,7 @@ public static void setItemInHandDropChance(LivingEntity entity, float chance) { if(equipment == null) { return; } - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { equipment.setItemInHandDropChance(chance); return; } @@ -523,7 +523,7 @@ public static void setItemInHandDropChance(LivingEntity entity, float chance) { public static void sendActionBar(Player player, String message) { if(player == null) return; - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R1)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) { try { if(chatMessageTypeClass == null) { PacketUtils.sendPacket(player, packetPlayOutChatConstructor.newInstance(chatComponentTextConstructor.newInstance(message), (byte) 2)); @@ -537,7 +537,7 @@ public static void sendActionBar(Player player, String message) { } catch(ReflectiveOperationException e) { e.printStackTrace(); } - } else if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R3)) { + } else if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16)) { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, player.getUniqueId(), new ComponentBuilder(message).create()); } else { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(message).create()); @@ -566,13 +566,13 @@ public static void sendTitles(Player player, String title, String subtitle, int public static void sendTitle(Player player, String text, int fadeInTime, int showTime, int fadeOutTime) { if(player == null) return; - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R2)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) { try { Object chatTitle = null; Class[] declaredClasses = iChatBaseComponent.getDeclaredClasses(); if(declaredClasses.length > 0) { chatTitle = declaredClasses[0].getMethod("a", String.class).invoke(null, "{\"text\": \"" + text + "\"}"); - } else if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_R2)) { + } else if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_8)) { Class chatSerializer = PacketUtils.classByName(null, "ChatSerializer"); chatTitle = iChatBaseComponent.cast(chatSerializer.getMethod("a", String.class).invoke(chatSerializer, "{\"text\":\"" + text + "\"}")); } @@ -588,13 +588,13 @@ public static void sendTitle(Player player, String text, int fadeInTime, int sho public static void sendSubTitle(Player player, String text, int fadeInTime, int showTime, int fadeOutTime) { if(player == null) return; - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R2)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) { try { Object chatTitle = null; Class[] declaredClasses = iChatBaseComponent.getDeclaredClasses(); if(declaredClasses.length > 0) { chatTitle = declaredClasses[0].getMethod("a", String.class).invoke(null, "{\"text\": \"" + text + "\"}"); - } else if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_R2)) { + } else if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_8)) { Class chatSerializer = PacketUtils.classByName(null, "ChatSerializer"); chatTitle = iChatBaseComponent.cast(chatSerializer.getMethod("a", String.class).invoke(chatSerializer, "{\"text\":\"" + text + "\"}")); } @@ -609,7 +609,7 @@ public static void sendSubTitle(Player player, String text, int fadeInTime, int public static ItemStack getPotion(PotionType type, int tier, boolean splash) { ItemStack potion; - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_R3)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_8_8)) { potion = new Potion(type, tier, splash).toItemStack(1); } else { potion = new ItemStack(!splash ? Material.POTION : Material.SPLASH_POTION, 1); @@ -629,14 +629,14 @@ public static int getWorldMaxHeight(World world) { } public static int getWorldMinHeight(World world) { - if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R3)) { + if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16)) { return world.getMinHeight(); } return 0; } public static Entity spawnEntity(Location location, EntityType entityType) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_15_R2)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_15)) { return location.getWorld().spawnEntity(location, entityType); } if(isPaper) { diff --git a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/events/EventsInitializer.java b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/events/EventsInitializer.java index f453062..563f2ad 100644 --- a/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/events/EventsInitializer.java +++ b/MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/version/events/EventsInitializer.java @@ -29,7 +29,7 @@ public class EventsInitializer { public EventsInitializer(JavaPlugin plugin) { - if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R2)) { + if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) { new LegacyEvents(plugin); } else { new Events(plugin); From f1910f5735851f2b61530b8494102befcd2b74b1 Mon Sep 17 00:00:00 2001 From: "version-bump[github-action]" <41898282+version-bump[github-action]@users.noreply.github.com> Date: Fri, 12 Jul 2024 23:29:22 +0000 Subject: [PATCH 5/5] Bump version from 1.3.12-SNAPSHOT1 to 1.3.12-SNAPSHOT2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3624262..4a89aa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ # along with this program. If not, see . # group=plugily.projects -version=1.3.12-SNAPSHOT1 +version=1.3.12-SNAPSHOT2