From 983ec33f459be99d930ba22222b38738ef5d58a4 Mon Sep 17 00:00:00 2001 From: Chronoken Date: Thu, 19 Oct 2023 20:12:05 +0200 Subject: [PATCH] Remove unsupported 1.19-1.19.3 versions. --- core/build.gradle | 2 - nms/v1_19_R1/build.gradle | 8 - .../v1_19_R1/VolatileCode1_19_R1.kt | 173 ------------------ nms/v1_19_R2/build.gradle | 8 - .../v1_19_R2/VolatileCode1_19_R2.kt | 173 ------------------ 5 files changed, 364 deletions(-) delete mode 100644 nms/v1_19_R1/build.gradle delete mode 100644 nms/v1_19_R1/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt delete mode 100644 nms/v1_19_R2/build.gradle delete mode 100644 nms/v1_19_R2/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt diff --git a/core/build.gradle b/core/build.gradle index 12764aca8..dc1d3faf4 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -11,8 +11,6 @@ dependencies { shadow(group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: "1.9.10") shadow(project(path: ":nms:shared", configuration: "apiElements")) - shadow(project(path: ":nms:v1_19_R1", configuration: "reobf")) - shadow(project(path: ":nms:v1_19_R2", configuration: "reobf")) shadow(project(path: ":nms:v1_19_R3", configuration: "reobf")) shadow(project(path: ":nms:v1_20_R1", configuration: "reobf")) shadow(project(path: ":nms:v1_20_R2", configuration: "reobf")) diff --git a/nms/v1_19_R1/build.gradle b/nms/v1_19_R1/build.gradle deleted file mode 100644 index ea7007ffb..000000000 --- a/nms/v1_19_R1/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -plugins { - id "io.papermc.paperweight.userdev" version "1.5.8" -} - -dependencies { - paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.2-R0.1-SNAPSHOT") - implementation project(":nms:shared") -} diff --git a/nms/v1_19_R1/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt b/nms/v1_19_R1/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt deleted file mode 100644 index 7ba034a8a..000000000 --- a/nms/v1_19_R1/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt +++ /dev/null @@ -1,173 +0,0 @@ -package com.nisovin.magicspells.volatilecode.v1_19_R1 - -import java.util.* - -import org.bukkit.Bukkit -import org.bukkit.entity.* -import org.bukkit.Location -import org.bukkit.util.Vector -import org.bukkit.EntityEffect -import org.bukkit.NamespacedKey -import org.bukkit.inventory.Recipe -import org.bukkit.inventory.ItemStack -import org.bukkit.inventory.RecipeChoice -import org.bukkit.inventory.SmithingRecipe -import org.bukkit.event.entity.ExplosionPrimeEvent - -import org.bukkit.craftbukkit.v1_19_R1.entity.* -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld -import org.bukkit.craftbukkit.v1_19_R1.CraftServer -import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack - -import net.kyori.adventure.text.Component - -import io.papermc.paper.adventure.PaperAdventure -import io.papermc.paper.advancement.AdvancementDisplay - -import net.minecraft.world.phys.Vec3 -import net.minecraft.advancements.FrameType -import net.minecraft.network.protocol.game.* -import net.minecraft.world.entity.EntityType -import net.minecraft.advancements.Advancement -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.entity.item.PrimedTnt -import net.minecraft.world.item.alchemy.PotionUtils -import net.minecraft.advancements.AdvancementProgress -import net.minecraft.network.syncher.EntityDataAccessor -import net.minecraft.advancements.critereon.ImpossibleTrigger -import net.minecraft.world.entity.boss.enderdragon.EnderDragon - -import com.nisovin.magicspells.volatilecode.VolatileCodeHandle -import com.nisovin.magicspells.volatilecode.VolatileCodeHelper - -class VolatileCode1_19_R1(helper: VolatileCodeHelper) : VolatileCodeHandle(helper) { - - private var entityLivingPotionEffectColor: EntityDataAccessor? = null - - init { - try { - // CHANGE THIS TO SPIGOT MAPPING VERSION OF MOJANG'S - EntityDataAccessor DATA_EFFECT_COLOR_ID - val entityLivingPotionEffectColorField = net.minecraft.world.entity.LivingEntity::class.java.getDeclaredField("bL") - entityLivingPotionEffectColorField.isAccessible = true - entityLivingPotionEffectColor = entityLivingPotionEffectColorField.get(null) as EntityDataAccessor - } catch (e: Exception) { - helper.error("THIS OCCURRED WHEN CREATING THE VOLATILE CODE HANDLE FOR 1.19.2, THE FOLLOWING ERROR IS MOST LIKELY USEFUL IF YOU'RE RUNNING THE LATEST VERSION OF MAGICSPELLS.") - e.printStackTrace() - } - } - - override fun addPotionGraphicalEffect(entity: LivingEntity, color: Int, duration: Long) { - val livingEntity = (entity as CraftLivingEntity).handle - val entityData = livingEntity.entityData - entityData.set(entityLivingPotionEffectColor, color) - - if (duration > 0) { - helper.scheduleDelayedTask({ - var c = 0 - if (livingEntity.getActiveEffects().isNotEmpty()) { - c = PotionUtils.getColor(livingEntity.getActiveEffects()) - } - entityData.set(entityLivingPotionEffectColor, c) - }, duration) - } - } - - override fun sendFakeSlotUpdate(player: Player, slot: Int, item: ItemStack?) { - val nmsItem = CraftItemStack.asNMSCopy(item) - val packet = ClientboundContainerSetSlotPacket(0, 0, slot.toShort() + 36, nmsItem) - (player as CraftPlayer).handle.connection.send(packet) - } - - override fun simulateTnt(target: Location, source: LivingEntity, explosionSize: Float, fire: Boolean): Boolean { - val e = PrimedTnt((target.world as CraftWorld).handle, target.x, target.y, target.z, (source as CraftLivingEntity).handle) - val c = CraftTNTPrimed(Bukkit.getServer() as CraftServer, e) - val event = ExplosionPrimeEvent(c, explosionSize, fire) - Bukkit.getPluginManager().callEvent(event) - return event.isCancelled - } - - override fun playDragonDeathEffect(location: Location) { - val dragon = EnderDragon(EntityType.ENDER_DRAGON, (location.world as CraftWorld).handle) - dragon.setPos(location.x, location.y, location.z) - - val addMobPacket = ClientboundAddEntityPacket(dragon) - val entityEventPacket = ClientboundEntityEventPacket(dragon, 3) - val removeEntityPacket = ClientboundRemoveEntitiesPacket(dragon.id) - - val players = ArrayList() - for (player in location.getNearbyPlayers(64.0)) { - players.add(player) - (player as CraftPlayer).handle.connection.send(addMobPacket) - player.handle.connection.send(addMobPacket) - player.handle.connection.send(entityEventPacket) - } - - helper.scheduleDelayedTask({ - for (player in players) { - if (!player.isValid) continue - (player as CraftPlayer).handle.connection.send(removeEntityPacket) - } - }, 250) - - } - - override fun setClientVelocity(player: Player, velocity: Vector) { - val packet = ClientboundSetEntityMotionPacket(player.entityId, Vec3(velocity.x, velocity.y, velocity.z)) - (player as CraftPlayer).handle.connection.send(packet) - } - - override fun startAutoSpinAttack(player: Player?, ticks: Int) { - val entityPlayer = (player as CraftPlayer).handle - entityPlayer.startAutoSpinAttack(ticks) - } - - override fun playHurtAnimation(entity: LivingEntity, yaw: Float) { - entity.playEffect(EntityEffect.HURT) - } - - override fun createSmithingRecipe( - namespacedKey: NamespacedKey, - result: ItemStack, - template: RecipeChoice, - base: RecipeChoice, - addition: RecipeChoice, - copyNbt: Boolean - ): Recipe { - return SmithingRecipe(namespacedKey, result, base, addition, copyNbt) - } - - override fun sendToastEffect(receiver: Player, icon: ItemStack, frameType: AdvancementDisplay.Frame, text: Component) { - val iconNms = CraftItemStack.asNMSCopy(icon) - val textNms = PaperAdventure.asVanilla(text) - val description = PaperAdventure.asVanilla(Component.empty()) - val frame = try { - FrameType.valueOf(frameType.name) - } catch (_: IllegalArgumentException) { - FrameType.TASK - } - - val id = ResourceLocation("magicspells", "toast_effect") - val advancement = Advancement.Builder.advancement() - .display(iconNms, textNms, description, null, frame, true, false, true) - .addCriterion("impossible", ImpossibleTrigger.TriggerInstance()) - .build(id) - val progress = AdvancementProgress() - progress.update(advancement.criteria, advancement.requirements) - progress.grantProgress("impossible") - - val player = (receiver as CraftPlayer).handle - player.connection.send(ClientboundUpdateAdvancementsPacket( - false, - Collections.singleton(advancement), - Collections.emptySet(), - Collections.singletonMap(id, progress) - )) - player.connection.send(ClientboundUpdateAdvancementsPacket( - false, - Collections.emptySet(), - Collections.singleton(id), - Collections.emptyMap() - )) - } - -} diff --git a/nms/v1_19_R2/build.gradle b/nms/v1_19_R2/build.gradle deleted file mode 100644 index ae45954ec..000000000 --- a/nms/v1_19_R2/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -plugins { - id "io.papermc.paperweight.userdev" version "1.5.8" -} - -dependencies { - paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.3-R0.1-SNAPSHOT") - implementation project(":nms:shared") -} diff --git a/nms/v1_19_R2/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt b/nms/v1_19_R2/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt deleted file mode 100644 index ba09a3303..000000000 --- a/nms/v1_19_R2/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt +++ /dev/null @@ -1,173 +0,0 @@ -package com.nisovin.magicspells.volatilecode.v1_19_R2 - -import java.util.* - -import org.bukkit.Bukkit -import org.bukkit.entity.* -import org.bukkit.Location -import org.bukkit.util.Vector -import org.bukkit.EntityEffect -import org.bukkit.NamespacedKey -import org.bukkit.inventory.Recipe -import org.bukkit.inventory.ItemStack -import org.bukkit.inventory.RecipeChoice -import org.bukkit.inventory.SmithingRecipe -import org.bukkit.event.entity.ExplosionPrimeEvent - -import org.bukkit.craftbukkit.v1_19_R2.entity.* -import org.bukkit.craftbukkit.v1_19_R2.CraftWorld -import org.bukkit.craftbukkit.v1_19_R2.CraftServer -import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack - -import net.kyori.adventure.text.Component - -import io.papermc.paper.adventure.PaperAdventure -import io.papermc.paper.advancement.AdvancementDisplay - -import net.minecraft.world.phys.Vec3 -import net.minecraft.advancements.FrameType -import net.minecraft.world.entity.EntityType -import net.minecraft.network.protocol.game.* -import net.minecraft.advancements.Advancement -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.entity.item.PrimedTnt -import net.minecraft.world.item.alchemy.PotionUtils -import net.minecraft.advancements.AdvancementProgress -import net.minecraft.network.syncher.EntityDataAccessor -import net.minecraft.advancements.critereon.ImpossibleTrigger -import net.minecraft.world.entity.boss.enderdragon.EnderDragon - -import com.nisovin.magicspells.volatilecode.VolatileCodeHandle -import com.nisovin.magicspells.volatilecode.VolatileCodeHelper - -class VolatileCode1_19_R2(helper: VolatileCodeHelper) : VolatileCodeHandle(helper) { - - private var entityLivingPotionEffectColor: EntityDataAccessor? = null - - init { - try { - // CHANGE THIS TO SPIGOT MAPPING VERSION OF MOJANG'S - EntityDataAccessor DATA_EFFECT_COLOR_ID - val entityLivingPotionEffectColorField = net.minecraft.world.entity.LivingEntity::class.java.getDeclaredField("bL") - entityLivingPotionEffectColorField.isAccessible = true - entityLivingPotionEffectColor = entityLivingPotionEffectColorField.get(null) as EntityDataAccessor - } catch (e: Exception) { - helper.error("THIS OCCURRED WHEN CREATING THE VOLATILE CODE HANDLE FOR 1.19.3, THE FOLLOWING ERROR IS MOST LIKELY USEFUL IF YOU'RE RUNNING THE LATEST VERSION OF MAGICSPELLS.") - e.printStackTrace() - } - } - - override fun addPotionGraphicalEffect(entity: LivingEntity, color: Int, duration: Long) { - val livingEntity = (entity as CraftLivingEntity).handle - val entityData = livingEntity.entityData - entityData.set(entityLivingPotionEffectColor, color) - - if (duration > 0) { - helper.scheduleDelayedTask({ - var c = 0 - if (livingEntity.getActiveEffects().isNotEmpty()) { - c = PotionUtils.getColor(livingEntity.getActiveEffects()) - } - entityData.set(entityLivingPotionEffectColor, c) - }, duration) - } - } - - override fun sendFakeSlotUpdate(player: Player, slot: Int, item: ItemStack?) { - val nmsItem = CraftItemStack.asNMSCopy(item) - val packet = ClientboundContainerSetSlotPacket(0, 0, slot.toShort() + 36, nmsItem) - (player as CraftPlayer).handle.connection.send(packet) - } - - override fun simulateTnt(target: Location, source: LivingEntity, explosionSize: Float, fire: Boolean): Boolean { - val e = PrimedTnt((target.world as CraftWorld).handle, target.x, target.y, target.z, (source as CraftLivingEntity).handle) - val c = CraftTNTPrimed(Bukkit.getServer() as CraftServer, e) - val event = ExplosionPrimeEvent(c, explosionSize, fire) - Bukkit.getPluginManager().callEvent(event) - return event.isCancelled - } - - override fun playDragonDeathEffect(location: Location) { - val dragon = EnderDragon(EntityType.ENDER_DRAGON, (location.world as CraftWorld).handle) - dragon.setPos(location.x, location.y, location.z) - - val addMobPacket = ClientboundAddEntityPacket(dragon) - val entityEventPacket = ClientboundEntityEventPacket(dragon, 3) - val removeEntityPacket = ClientboundRemoveEntitiesPacket(dragon.id) - - val players = ArrayList() - for (player in location.getNearbyPlayers(64.0)) { - players.add(player) - (player as CraftPlayer).handle.connection.send(addMobPacket) - player.handle.connection.send(addMobPacket) - player.handle.connection.send(entityEventPacket) - } - - helper.scheduleDelayedTask({ - for (player in players) { - if (!player.isValid) continue - (player as CraftPlayer).handle.connection.send(removeEntityPacket) - } - }, 250) - - } - - override fun setClientVelocity(player: Player, velocity: Vector) { - val packet = ClientboundSetEntityMotionPacket(player.entityId, Vec3(velocity.x, velocity.y, velocity.z)) - (player as CraftPlayer).handle.connection.send(packet) - } - - override fun startAutoSpinAttack(player: Player?, ticks: Int) { - val entityPlayer = (player as CraftPlayer).handle - entityPlayer.startAutoSpinAttack(ticks) - } - - override fun playHurtAnimation(entity: LivingEntity, yaw: Float) { - entity.playEffect(EntityEffect.HURT) - } - - override fun createSmithingRecipe( - namespacedKey: NamespacedKey, - result: ItemStack, - template: RecipeChoice, - base: RecipeChoice, - addition: RecipeChoice, - copyNbt: Boolean - ): Recipe { - return SmithingRecipe(namespacedKey, result, base, addition, copyNbt) - } - - override fun sendToastEffect(receiver: Player, icon: ItemStack, frameType: AdvancementDisplay.Frame, text: Component) { - val iconNms = CraftItemStack.asNMSCopy(icon) - val textNms = PaperAdventure.asVanilla(text) - val description = PaperAdventure.asVanilla(Component.empty()) - val frame = try { - FrameType.valueOf(frameType.name) - } catch (_: IllegalArgumentException) { - FrameType.TASK - } - - val id = ResourceLocation("magicspells", "toast_effect") - val advancement = Advancement.Builder.advancement() - .display(iconNms, textNms, description, null, frame, true, false, true) - .addCriterion("impossible", ImpossibleTrigger.TriggerInstance()) - .build(id) - val progress = AdvancementProgress() - progress.update(advancement.criteria, advancement.requirements) - progress.grantProgress("impossible") - - val player = (receiver as CraftPlayer).handle - player.connection.send(ClientboundUpdateAdvancementsPacket( - false, - Collections.singleton(advancement), - Collections.emptySet(), - Collections.singletonMap(id, progress) - )) - player.connection.send(ClientboundUpdateAdvancementsPacket( - false, - Collections.emptySet(), - Collections.singleton(id), - Collections.emptyMap() - )) - } - -}