From 47374eaacac470bc8ae295116156fcfc3d6d70ec Mon Sep 17 00:00:00 2001 From: Chechu Date: Mon, 3 Jun 2024 18:49:58 +0200 Subject: [PATCH] update: update to 1.20.4 (#45) * update: update to 1.20.4 * fix: newItem is no longer nullable --- build.gradle.kts | 2 +- .../de/danielmaile/mpp/block/BlockBreakingService.kt | 10 +++++----- .../de/danielmaile/mpp/block/utils/HardnessUtil.kt | 4 ++-- .../de/danielmaile/mpp/item/function/ArmorListener.kt | 2 +- .../kotlin/de/danielmaile/mpp/packet/PacketHandler.kt | 2 +- src/main/kotlin/de/danielmaile/mpp/util/PlayerUtils.kt | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e38937c..d571b93 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ import java.io.BufferedReader import java.nio.file.Paths val javaVersion = 17 -val minecraftVersion = "1.19.4" +val minecraftVersion = "1.20.4" fun runCommand(command: Array) = Runtime .getRuntime() diff --git a/src/main/kotlin/de/danielmaile/mpp/block/BlockBreakingService.kt b/src/main/kotlin/de/danielmaile/mpp/block/BlockBreakingService.kt index b78dd4a..8d7c6bd 100644 --- a/src/main/kotlin/de/danielmaile/mpp/block/BlockBreakingService.kt +++ b/src/main/kotlin/de/danielmaile/mpp/block/BlockBreakingService.kt @@ -36,8 +36,8 @@ import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.Action -import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance +import net.minecraft.world.effect.MobEffects import org.bukkit.Bukkit import org.bukkit.GameMode import org.bukkit.Material @@ -48,7 +48,7 @@ import org.bukkit.inventory.meta.Damageable import org.bukkit.potion.PotionEffectType import kotlin.random.Random -private val MINING_FATIGUE = MobEffectInstance(MobEffect.byId(4)!!, Integer.MAX_VALUE, 255, false, false, false) +private val MINING_FATIGUE = MobEffectInstance(MobEffects.DIG_SLOWDOWN, Integer.MAX_VALUE, 255, false, false, false) object BlockBreakingService { private val damagedBlocks: HashMap = HashMap() @@ -150,7 +150,7 @@ object BlockBreakingService { // the player might actually have mining fatigue. // in this case, it is important to copy the hasIcon value to prevent it from disappearing. val effectInstance = MobEffectInstance( - MobEffect.byId(4)!!, + MobEffects.DIG_SLOWDOWN, Int.MAX_VALUE, 255, effect.isAmbient, @@ -171,7 +171,7 @@ object BlockBreakingService { val packet = if (effect != null) { // if the player actually has mining fatigue, send the correct effect again val effectInstance = MobEffectInstance( - MobEffect.byId(4)!!, + MobEffects.DIG_SLOWDOWN, effect.duration, effect.amplifier, effect.isAmbient, @@ -181,7 +181,7 @@ object BlockBreakingService { ClientboundUpdateMobEffectPacket(this.entityId, effectInstance) } else { // remove the effect - ClientboundRemoveMobEffectPacket(this.entityId, MobEffect.byId(4)!!) + ClientboundRemoveMobEffectPacket(this.entityId, MobEffects.DIG_SLOWDOWN) } PacketHandler.sendPacket(this, packet) diff --git a/src/main/kotlin/de/danielmaile/mpp/block/utils/HardnessUtil.kt b/src/main/kotlin/de/danielmaile/mpp/block/utils/HardnessUtil.kt index 4601420..e0f9a3a 100644 --- a/src/main/kotlin/de/danielmaile/mpp/block/utils/HardnessUtil.kt +++ b/src/main/kotlin/de/danielmaile/mpp/block/utils/HardnessUtil.kt @@ -33,8 +33,8 @@ import net.minecraft.world.item.PickaxeItem import net.minecraft.world.item.ShovelItem import net.minecraft.world.level.block.state.BlockState import org.bukkit.block.Block -import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock -import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack +import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock +import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack import org.bukkit.enchantments.Enchantment import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/src/main/kotlin/de/danielmaile/mpp/item/function/ArmorListener.kt b/src/main/kotlin/de/danielmaile/mpp/item/function/ArmorListener.kt index eaa441a..175e44f 100644 --- a/src/main/kotlin/de/danielmaile/mpp/item/function/ArmorListener.kt +++ b/src/main/kotlin/de/danielmaile/mpp/item/function/ArmorListener.kt @@ -39,7 +39,7 @@ class ArmorListener : Listener { // This method is planned for subsequent updates @EventHandler fun playerEquipArmor(event: PlayerArmorChangeEvent) { - val armorPiece = event.newItem ?: return + val armorPiece = event.newItem val armorPieceItem = ItemRegistry.getItemFromItemstack(armorPiece) ?: return if (armorPieceItem is Armors) { diff --git a/src/main/kotlin/de/danielmaile/mpp/packet/PacketHandler.kt b/src/main/kotlin/de/danielmaile/mpp/packet/PacketHandler.kt index af68f6a..4348428 100644 --- a/src/main/kotlin/de/danielmaile/mpp/packet/PacketHandler.kt +++ b/src/main/kotlin/de/danielmaile/mpp/packet/PacketHandler.kt @@ -22,7 +22,7 @@ import io.netty.channel.ChannelHandlerContext import io.netty.channel.ChannelPromise import net.minecraft.network.protocol.Packet import org.bukkit.Bukkit -import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer +import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener diff --git a/src/main/kotlin/de/danielmaile/mpp/util/PlayerUtils.kt b/src/main/kotlin/de/danielmaile/mpp/util/PlayerUtils.kt index 1e6c967..cb31fe8 100644 --- a/src/main/kotlin/de/danielmaile/mpp/util/PlayerUtils.kt +++ b/src/main/kotlin/de/danielmaile/mpp/util/PlayerUtils.kt @@ -27,7 +27,7 @@ import org.bukkit.FluidCollisionMode import org.bukkit.attribute.Attribute import org.bukkit.block.Block import org.bukkit.block.BlockFace -import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer +import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer import org.bukkit.entity.Player import org.bukkit.potion.PotionEffect import org.bukkit.potion.PotionEffectType