Skip to content

Commit

Permalink
Merge pull request #176 from Mercerenies/minecraft-1-21-upgrade
Browse files Browse the repository at this point in the history
Minecraft 1 21 upgrade
  • Loading branch information
Mercerenies authored Jan 17, 2025
2 parents b1dbc33 + ae955a8 commit 888b981
Show file tree
Hide file tree
Showing 42 changed files with 164 additions and 342 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ A Turtle's Troll also provides integrations with a few other plugins.
None of these are required, but some features may be unavailable if
these dependencies are not present.

* [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/)
is required for the `rainwater` feature. If ProtocolLib is not
present, this feature will be disabled.
* [Raccoon-Mischief](https://github.com/EvanSkiStudios/Raccoon-Mischief)
is recommended for interoperation with several features. Nothing
strictly requires this plugin to be present, but many things either
Expand All @@ -49,7 +46,11 @@ these dependencies are not present.

### Version 1.25

* Random events that apply to players do not fire if there are no players online (currently this is all random events, though in the future there may be events that make sense with no players)
* A Turtle's Troll has been updated to run in Minecraft 1.21.3.
* The `rainwater` effect no longer depends on ProtocolLib and will
work out-of-the-box.
* Random events that apply to players do not fire if there are no players online (currently this is all random events, though in the future there may be events that make sense with no players).
* The allay's flower pool has been adjusted to prevent bugs.

### Version 1.24.2

Expand Down
20 changes: 11 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

sourceSets {
main {
Expand All @@ -27,15 +29,15 @@ sourceSets {

tasks {
withType<KotlinCompile> {
kotlinOptions {
apiVersion = "1.5"
languageVersion = "1.5"
jvmTarget = "17"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
apiVersion.set(KotlinVersion.KOTLIN_2_1)
languageVersion.set(KotlinVersion.KOTLIN_2_1)
}
}
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
sourceCompatibility = "21"
targetCompatibility = "21"
}
jar {
val dependencies = configurations
Expand All @@ -57,7 +59,7 @@ tasks {

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm") version "1.8.22"
id("org.jetbrains.kotlin.jvm") version "2.1.0"

// Apply the java-library plugin for API and implementation separation.
`java-library`
Expand All @@ -78,9 +80,9 @@ dependencies {
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")
compileOnly("net.kyori:adventure-text-serializer-plain:4.14.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
compileOnly("com.discordsrv:discordsrv:1.26.0")

implementation(
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 0 additions & 2 deletions src/AllayManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntitySpawnEvent
import org.bukkit.potion.PotionEffectType
import org.bukkit.entity.Entity
import org.bukkit.entity.Allay
import org.bukkit.entity.Player
import org.bukkit.plugin.Plugin
import org.bukkit.inventory.ItemStack
import org.bukkit.Bukkit
Expand Down
4 changes: 2 additions & 2 deletions src/BlockTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object BlockTypes {
)

val TALL_GRASS = SetListAllomorph.of(
Material.GRASS, Material.TALL_GRASS, Material.FERN,
Material.GRASS_BLOCK, Material.TALL_GRASS, Material.FERN,
Material.LARGE_FERN, Material.DEAD_BUSH, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS,
)

Expand Down Expand Up @@ -132,7 +132,7 @@ object BlockTypes {
Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE,
Material.SUNFLOWER, Material.LILAC, Material.ROSE_BUSH, Material.PEONY,
Material.PINK_TULIP, Material.WHITE_TULIP, Material.ORANGE_TULIP,
Material.SWEET_BERRY_BUSH, Material.TORCHFLOWER,
Material.TORCHFLOWER,
)

val WOOLS = SetListAllomorph.of(
Expand Down
11 changes: 7 additions & 4 deletions src/BucketRouletteRunnable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class BucketRouletteRunnable(plugin: Plugin) : RunnableFeature(plugin) {
return !itemMeta.hasDisplayName()
}

private fun cycleBucketType(itemStack: ItemStack) {
private fun cycleBucketType(itemStack: ItemStack): ItemStack {
var newBucketType = BlockTypes.BUCKETS.random()
while (newBucketType == itemStack.type) {
newBucketType = BlockTypes.BUCKETS.random()
}
itemStack.type = newBucketType
return ItemStack(newBucketType, itemStack.amount)
}

}
Expand All @@ -53,9 +53,12 @@ class BucketRouletteRunnable(plugin: Plugin) : RunnableFeature(plugin) {
for (player in onlinePlayers) {
// TODO (HACK) Kotlin can't parse the more complex nullability
// annotation on getContents(), so it gets the wrong idea.
for (itemStack in player.inventory.contents!!) {
var inventoryIter = player.inventory.iterator()
while (inventoryIter.hasNext()) {
val itemStack = inventoryIter.next()
if ((itemStack != null) && (shouldCycle(itemStack))) {
cycleBucketType(itemStack)
val newItemStack = cycleBucketType(itemStack)
inventoryIter.set(newItemStack)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DragonBombManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class DragonBombManager(
}

private fun currentTriggersPerAttack(dragon: EnderDragon): Long {
val maxHealth = dragon.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.getValue()
val maxHealth = dragon.getAttribute(Attribute.MAX_HEALTH)!!.getValue()
val healthFraction = dragon.getHealth().toDouble() / maxHealth
val triggers = healthFraction * maxTimerTriggersPerAttack + (1 - healthFraction) * minTimerTriggersPerAttack
return triggers.toLong()
Expand Down
4 changes: 2 additions & 2 deletions src/FallDamageListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class FallDamageListener() : AbstractFeature(), Listener {
if (!event.isCancelled()) {
if (victim is Player) {
if (event.cause == EntityDamageEvent.DamageCause.FALL) {
victim.addPotionEffect(PotionEffect(PotionEffectType.CONFUSION, Constants.TICKS_PER_SECOND * 10, 1))
victim.addPotionEffect(PotionEffect(PotionEffectType.SLOW, Constants.TICKS_PER_SECOND * 10, 0))
victim.addPotionEffect(PotionEffect(PotionEffectType.NAUSEA, Constants.TICKS_PER_SECOND * 10, 1))
victim.addPotionEffect(PotionEffect(PotionEffectType.SLOWNESS, Constants.TICKS_PER_SECOND * 10, 0))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GrassPoisonListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GrassPoisonListener(
if (!bootsDamager.tryWearDownBoots(player)) {
telegrapher.trigger(player)
player.addPotionEffect(PotionEffect(PotionEffectType.POISON, Constants.TICKS_PER_SECOND * 5, 0))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOW, Constants.TICKS_PER_SECOND * 10, 1))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOWNESS, Constants.TICKS_PER_SECOND * 10, 1))
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/PiglinBarterListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ class PiglinBarterListener(
private val ENCHANTMENT_CHOICES = listOf(
EnchantmentData(Enchantment.MENDING, 1),
EnchantmentData(Enchantment.THORNS, 1),
EnchantmentData(Enchantment.DURABILITY, 2),
EnchantmentData(Enchantment.DURABILITY, 3),
EnchantmentData(Enchantment.PROTECTION_ENVIRONMENTAL, 1),
EnchantmentData(Enchantment.PROTECTION_ENVIRONMENTAL, 2),
EnchantmentData(Enchantment.PROTECTION_ENVIRONMENTAL, 3),
EnchantmentData(Enchantment.PROTECTION_FIRE, 2),
EnchantmentData(Enchantment.PROTECTION_FIRE, 3),
EnchantmentData(Enchantment.PROTECTION_FIRE, 4),
EnchantmentData(Enchantment.PROTECTION_EXPLOSIONS, 2),
EnchantmentData(Enchantment.PROTECTION_EXPLOSIONS, 3),
EnchantmentData(Enchantment.PROTECTION_EXPLOSIONS, 4),
EnchantmentData(Enchantment.PROTECTION_PROJECTILE, 2),
EnchantmentData(Enchantment.PROTECTION_PROJECTILE, 3),
EnchantmentData(Enchantment.PROTECTION_PROJECTILE, 4),
EnchantmentData(Enchantment.UNBREAKING, 2),
EnchantmentData(Enchantment.UNBREAKING, 3),
EnchantmentData(Enchantment.PROTECTION, 1),
EnchantmentData(Enchantment.PROTECTION, 2),
EnchantmentData(Enchantment.PROTECTION, 3),
EnchantmentData(Enchantment.FIRE_PROTECTION, 2),
EnchantmentData(Enchantment.FIRE_PROTECTION, 3),
EnchantmentData(Enchantment.FIRE_PROTECTION, 4),
EnchantmentData(Enchantment.BLAST_PROTECTION, 2),
EnchantmentData(Enchantment.BLAST_PROTECTION, 3),
EnchantmentData(Enchantment.BLAST_PROTECTION, 4),
EnchantmentData(Enchantment.PROJECTILE_PROTECTION, 2),
EnchantmentData(Enchantment.PROJECTILE_PROTECTION, 3),
EnchantmentData(Enchantment.PROJECTILE_PROTECTION, 4),
)

override fun create(state: BuilderState): FeatureContainer =
Expand Down
4 changes: 2 additions & 2 deletions src/PumpkinSlownessManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class PumpkinSlownessManager(plugin: Plugin) : RunnableFeature(plugin), Listener
}
for (player in Bukkit.getOnlinePlayers()) {
if (Hats.isWearingOrdinaryHat(player)) {
player.addPotionEffect(PotionEffect(PotionEffectType.SLOW, Constants.TICKS_PER_SECOND * 10, 1))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOW_DIGGING, Constants.TICKS_PER_SECOND * 10, 0))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOWNESS, Constants.TICKS_PER_SECOND * 10, 1))
player.addPotionEffect(PotionEffect(PotionEffectType.MINING_FATIGUE, Constants.TICKS_PER_SECOND * 10, 0))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/SaddleListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import org.bukkit.Chunk
import org.bukkit.plugin.Plugin
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import org.spigotmc.event.entity.EntityMountEvent
import org.spigotmc.event.entity.EntityDismountEvent
import org.bukkit.event.entity.EntityMountEvent
import org.bukkit.event.entity.EntityDismountEvent

class SaddleListener(
val plugin: Plugin,
Expand All @@ -37,7 +37,7 @@ class SaddleListener(
PotionEffect(PotionEffectType.SPEED, Constants.TICKS_PER_SECOND * 999, 100)
}
EntityType.STRIDER -> {
PotionEffect(PotionEffectType.SLOW, Constants.TICKS_PER_SECOND * 999, 2)
PotionEffect(PotionEffectType.SLOWNESS, Constants.TICKS_PER_SECOND * 999, 2)
}
else -> {
null
Expand Down
2 changes: 1 addition & 1 deletion src/SlowSlabListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SlowSlabListener(
if (BLOCKS.contains(block.type)) {
val player = event.player
if (!bootsDamager.tryWearDownBoots(player)) {
player.addPotionEffect(PotionEffect(PotionEffectType.SLOW, Constants.TICKS_PER_SECOND * slowTimeSeconds, slownessLevel))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOWNESS, Constants.TICKS_PER_SECOND * slowTimeSeconds, slownessLevel))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/SweetDreamsListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class SweetDreamsListener(
companion object : FeatureContainerFactory<FeatureContainer> {

val DEFAULT_EFFECTS_POOL: List<(Int) -> PotionEffect> = listOf(
{ length -> PotionEffect(PotionEffectType.SLOW, length, 1) },
{ length -> PotionEffect(PotionEffectType.CONFUSION, length, 0) },
{ length -> PotionEffect(PotionEffectType.SLOWNESS, length, 1) },
{ length -> PotionEffect(PotionEffectType.NAUSEA, length, 0) },
{ length -> PotionEffect(PotionEffectType.BLINDNESS, length, 0) },
{ length -> PotionEffect(PotionEffectType.SLOW_DIGGING, length, 4) },
{ length -> PotionEffect(PotionEffectType.MINING_FATIGUE, length, 4) },
{ length -> PotionEffect(PotionEffectType.REGENERATION, length, 4) },
)

Expand Down
2 changes: 1 addition & 1 deletion src/ZombieSpeedListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ZombieSpeedListener(
}
val entity = event.entity
if (entity is Zombie) {
val instance = entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)
val instance = entity.getAttribute(Attribute.MOVEMENT_SPEED)
instance?.setBaseValue(desiredSpeed)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/angel/WeepingAngelManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class WeepingAngelManager(
safeAngels.add(lookingAt)
val location = lookingAt.location.clone().add(0.0, 1.0, 0.0)
val world = lookingAt.world
world.spawnParticle(Particle.REDSTONE, location, 4, 0.25, 0.5, 0.25, Particle.DustOptions(Color.ORANGE, 1.0f))
world.spawnParticle(Particle.DUST, location, 4, 0.25, 0.5, 0.25, Particle.DustOptions(Color.ORANGE, 1.0f))
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/bridge/ProtocolLibBridge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package com.mercerenies.turtletroll.bridge
import com.comphenix.protocol.ProtocolLibrary
import com.comphenix.protocol.ProtocolManager

// As of 1.23.3, we don't use ProtocolLib for anything (since
// `rainwater` is available in stock Bukkit now). But this class still
// exists, in case we need it for something ridiculous down the road.
object ProtocolLibBridge : PluginBridge() {

override val pluginName = "ProtocolLib"
Expand Down
18 changes: 9 additions & 9 deletions src/cake/ApplyPotionEffect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ class ApplyPotionEffect(
companion object {

val Absorption = ApplyPotionEffect( 0.85, "Absorption" , PotionEffect(PotionEffectType.ABSORPTION , Constants.TICKS_PER_SECOND * 60, 1))
val DamageResistance = ApplyPotionEffect( 0.85, "Damage Resistance" , PotionEffect(PotionEffectType.DAMAGE_RESISTANCE , Constants.TICKS_PER_SECOND * 60, 1))
val DamageResistance = ApplyPotionEffect( 0.85, "Damage Resistance" , PotionEffect(PotionEffectType.RESISTANCE , Constants.TICKS_PER_SECOND * 60, 1))
val DolphinsGrace = ApplyPotionEffect( 0.40, "Dolphin's Grace" , PotionEffect(PotionEffectType.DOLPHINS_GRACE , Constants.TICKS_PER_SECOND * 60, 1))
val FastDigging = ApplyPotionEffect( 0.55, "Fast Digging" , PotionEffect(PotionEffectType.FAST_DIGGING , Constants.TICKS_PER_SECOND * 60, 1))
val FastDigging = ApplyPotionEffect( 0.55, "Haste" , PotionEffect(PotionEffectType.HASTE , Constants.TICKS_PER_SECOND * 60, 1))
val FireResistance = ApplyPotionEffect( 0.80, "Fire Resistance" , PotionEffect(PotionEffectType.FIRE_RESISTANCE , Constants.TICKS_PER_SECOND * 60, 1))
val Heal = ApplyPotionEffect( 0.75, "Heal" , PotionEffect(PotionEffectType.HEAL , Constants.TICKS_PER_SECOND * 60, 1))
val Heal = ApplyPotionEffect( 0.75, "Instant Health" , PotionEffect(PotionEffectType.INSTANT_HEALTH , Constants.TICKS_PER_SECOND * 60, 1))
val HealthBoost = ApplyPotionEffect( 0.75, "Health Boost" , PotionEffect(PotionEffectType.HEALTH_BOOST , Constants.TICKS_PER_SECOND * 60, 1))
val HeroOfTheVillage = ApplyPotionEffect( 0.45, "Hero Of The Village", PotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE, Constants.TICKS_PER_SECOND * 60, 1))
val IncreaseDamage = ApplyPotionEffect( 0.55, "Increase Damage" , PotionEffect(PotionEffectType.INCREASE_DAMAGE , Constants.TICKS_PER_SECOND * 60, 1))
val IncreaseDamage = ApplyPotionEffect( 0.55, "Strength" , PotionEffect(PotionEffectType.STRENGTH , Constants.TICKS_PER_SECOND * 60, 1))
val Invisibility = ApplyPotionEffect( 0.35, "Invisibility" , PotionEffect(PotionEffectType.INVISIBILITY , Constants.TICKS_PER_SECOND * 60, 1))
val Jump = ApplyPotionEffect( 0.50, "Jump" , PotionEffect(PotionEffectType.JUMP , Constants.TICKS_PER_SECOND * 60, 1))
val Jump = ApplyPotionEffect( 0.50, "Jump Boost" , PotionEffect(PotionEffectType.JUMP_BOOST , Constants.TICKS_PER_SECOND * 60, 1))
val Luck = ApplyPotionEffect( 0.40, "Luck" , PotionEffect(PotionEffectType.LUCK , Constants.TICKS_PER_SECOND * 60, 1))
val NightVision = ApplyPotionEffect( 0.65, "Night Vision" , PotionEffect(PotionEffectType.NIGHT_VISION , Constants.TICKS_PER_SECOND * 60, 1))
val Regeneration = ApplyPotionEffect( 0.90, "Regeneration" , PotionEffect(PotionEffectType.REGENERATION , Constants.TICKS_PER_SECOND * 60, 1))
Expand All @@ -43,12 +43,12 @@ class ApplyPotionEffect(

val BadOmen = ApplyPotionEffect(-0.45, "Bad Omen" , PotionEffect(PotionEffectType.BAD_OMEN , Constants.TICKS_PER_SECOND * 60, 1))
val Blindness = ApplyPotionEffect(-0.55, "Blindness" , PotionEffect(PotionEffectType.BLINDNESS , Constants.TICKS_PER_SECOND * 60, 1))
val Confusion = ApplyPotionEffect(-0.60, "Confusion" , PotionEffect(PotionEffectType.CONFUSION , Constants.TICKS_PER_SECOND * 60, 1))
val Harm = ApplyPotionEffect(-0.70, "Harm" , PotionEffect(PotionEffectType.HARM , Constants.TICKS_PER_SECOND * 60, 1))
val Confusion = ApplyPotionEffect(-0.60, "Nausea" , PotionEffect(PotionEffectType.NAUSEA , Constants.TICKS_PER_SECOND * 60, 1))
val Harm = ApplyPotionEffect(-0.70, "Instant Damage" , PotionEffect(PotionEffectType.INSTANT_DAMAGE , Constants.TICKS_PER_SECOND * 60, 1))
val Hunger = ApplyPotionEffect(-0.60, "Hunger" , PotionEffect(PotionEffectType.HUNGER , Constants.TICKS_PER_SECOND * 60, 1))
val Poison = ApplyPotionEffect(-0.80, "Poison" , PotionEffect(PotionEffectType.POISON , Constants.TICKS_PER_SECOND * 60, 1))
val Slow = ApplyPotionEffect(-0.30, "Slow" , PotionEffect(PotionEffectType.SLOW , Constants.TICKS_PER_SECOND * 60, 1))
val SlowDigging = ApplyPotionEffect(-0.50, "Slow Digging" , PotionEffect(PotionEffectType.SLOW_DIGGING , Constants.TICKS_PER_SECOND * 60, 1))
val Slow = ApplyPotionEffect(-0.30, "Slowness" , PotionEffect(PotionEffectType.SLOWNESS , Constants.TICKS_PER_SECOND * 60, 1))
val SlowDigging = ApplyPotionEffect(-0.50, "Mining Fatigue" , PotionEffect(PotionEffectType.MINING_FATIGUE , Constants.TICKS_PER_SECOND * 60, 1))
val Unluck = ApplyPotionEffect(-0.40, "Unluck" , PotionEffect(PotionEffectType.UNLUCK , Constants.TICKS_PER_SECOND * 60, 1))
val Weakness = ApplyPotionEffect(-0.30, "Weakness" , PotionEffect(PotionEffectType.WEAKNESS , Constants.TICKS_PER_SECOND * 60, 1))
val Wither = ApplyPotionEffect(-0.90, "Wither" , PotionEffect(PotionEffectType.WITHER , Constants.TICKS_PER_SECOND * 60, 1))
Expand Down
Loading

0 comments on commit 888b981

Please sign in to comment.