diff --git a/build.gradle b/build.gradle index 65d5c3882..b82fee978 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ wrapper { - gradleVersion = "7.5.1" + gradleVersion = "7.6" setDistributionType(Wrapper.DistributionType.ALL) } @@ -7,7 +7,7 @@ subprojects { apply plugin: "dev.magicspells.msjava" dependencies { - implementation(group: "io.papermc.paper", name: "paper-api", version: "1.19.2-R0.1-SNAPSHOT") + implementation(group: "io.papermc.paper", name: "paper-api", version: "1.19.3-R0.1-SNAPSHOT") } processResources { diff --git a/buildSrc/src/main/java/dev/magicspells/gradle/MSPaperweight.java b/buildSrc/src/main/java/dev/magicspells/gradle/MSPaperweight.java index ee611f323..8b2b4dddc 100644 --- a/buildSrc/src/main/java/dev/magicspells/gradle/MSPaperweight.java +++ b/buildSrc/src/main/java/dev/magicspells/gradle/MSPaperweight.java @@ -7,6 +7,6 @@ public class MSPaperweight implements Plugin { // TODO figure out how to apply the plugin @Override public void apply(Project project) { - project.getDependencies().add("paperweightDevelopmentBundle", "io.papermc.paper:dev-bundle:1.19.2-R0.1-SNAPSHOT").because("We need a server implementation rather than just an api here."); + project.getDependencies().add("paperweightDevelopmentBundle", "io.papermc.paper:dev-bundle:1.19.3-R0.1-SNAPSHOT").because("We need a server implementation rather than just an api here."); } } diff --git a/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt b/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt index 0851c6687..212837862 100644 --- a/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt +++ b/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R1/VolatileCode1_19_R1.kt @@ -1,5 +1,6 @@ package com.nisovin.magicspells.volatilecode.v1_19_R1 +/* import org.bukkit.Bukkit import org.bukkit.entity.* import org.bukkit.Location @@ -39,7 +40,7 @@ class VolatileCode1_19_R1: VolatileCodeHandle { entityLivingPotionEffectColorField.isAccessible = true entityLivingPotionEffectColor = entityLivingPotionEffectColorField.get(null) as EntityDataAccessor } catch (e: Exception) { - MagicSpells.error("THIS OCCURRED WHEN CREATING THE VOLATILE CODE HANDLE FOR 1.19, THE FOLLOWING ERROR IS MOST LIKELY USEFUL IF YOU'RE RUNNING THE LATEST VERSION OF MAGICSPELLS.") + MagicSpells.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() } } @@ -130,3 +131,4 @@ class VolatileCode1_19_R1: VolatileCodeHandle { } } +*/ diff --git a/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt b/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt new file mode 100644 index 000000000..e7a0ddd77 --- /dev/null +++ b/core/src/main/java/com/nisovin/magicspells/volatilecode/v1_19_R2/VolatileCode1_19_R2.kt @@ -0,0 +1,132 @@ +package com.nisovin.magicspells.volatilecode.v1_19_R2 + +import org.bukkit.Bukkit +import org.bukkit.entity.* +import org.bukkit.Location +import org.bukkit.util.Vector +import org.bukkit.inventory.ItemStack +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.minecraft.world.phys.Vec3 +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.EntityType +import net.minecraft.network.protocol.game.* +import net.minecraft.world.entity.item.PrimedTnt +import net.minecraft.world.item.alchemy.PotionUtils +import net.minecraft.network.syncher.EntityDataAccessor +import net.minecraft.world.entity.boss.enderdragon.EnderDragon + +import com.nisovin.magicspells.MagicSpells +import com.nisovin.magicspells.util.BoundingBox +import com.nisovin.magicspells.util.compat.EventUtil +import com.nisovin.magicspells.volatilecode.VolatileCodeHandle + +private typealias nmsItemStack = net.minecraft.world.item.ItemStack + +class VolatileCode1_19_R2: VolatileCodeHandle { + + 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) { + MagicSpells.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) { + MagicSpells.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: nmsItemStack? + if (item != null) nmsItem = CraftItemStack.asNMSCopy(item) + else nmsItem = null + + 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) + EventUtil.call(event) + return event.isCancelled + } + + override fun setFallingBlockHurtEntities(block: FallingBlock, damage: Float, max: Int) { + val efb = (block as CraftFallingBlock).handle + block.setHurtEntities(true) + efb.setHurtsEntities(damage, max) + } + + 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 box = BoundingBox(location, 64.0) + val players = ArrayList() + for (player in location.world!!.players) { + if (!box.contains(player)) continue + players.add(player) + (player as CraftPlayer).handle.connection.send(addMobPacket) + player.handle.connection.send(addMobPacket) + player.handle.connection.send(entityEventPacket) + } + + MagicSpells.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 setInventoryTitle(player: Player, title: String) { + val entityPlayer = (player as CraftPlayer).handle + val container = entityPlayer.containerMenu + val packet = ClientboundOpenScreenPacket(container.containerId, container.type, Component.literal(title)) + + player.handle.connection.send(packet) + player.updateInventory() + } + + override fun startAutoSpinAttack(player: Player?, ticks: Int) { + val entityPlayer = (player as CraftPlayer).handle + entityPlayer.startAutoSpinAttack(ticks) + } + +} diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 4a6b130b5..fafe909b8 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: MagicSpells main: com.nisovin.magicspells.MagicSpells version: $version authors: [nisovin, TheComputerGeek2, Chronoken] -api-version: "1.18" +api-version: "1.19" softdepend: - GriefPrevention - Vault diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8fad3f5a9..f42e62f37 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists