Skip to content

Commit

Permalink
1.17 update
Browse files Browse the repository at this point in the history
  • Loading branch information
paulikauro committed Dec 7, 2021
1 parent 4202e0d commit e4296fb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
22 changes: 11 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ group = ""
version = execute("git", "describe", "--long", "--dirty")

plugins {
val kotlinVersion = "1.4.21"
val kotlinVersion = "1.6.0"
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
id("com.github.johnrengelman.shadow") version "2.0.4"
id("com.github.johnrengelman.shadow") version "7.1.0"
id("net.minecrell.plugin-yml.bukkit") version "0.3.0"
}

Expand All @@ -23,25 +23,25 @@ repositories {
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("com.google.re2j:re2j:1.5")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
implementation("com.google.re2j:re2j:1.6")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-RC")

compileOnly("de.tr7zw:item-nbt-api-plugin:2.5.0")
compileOnly("org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT")
compileOnly("de.tr7zw:item-nbt-api-plugin:2.8.0")
compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
compileOnly("com.comphenix.protocol:ProtocolLib:4.5.0")
compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.3.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.1")
}

bukkit {
main = "redstonetools.RedstoneTools"
apiVersion = "1.15"
depend = listOf("WorldEdit")
apiVersion = "1.17"
depend = listOf("WorldEdit", "ProtocolLib", "NBTAPI")
}

tasks.test {
Expand All @@ -54,7 +54,7 @@ tasks.shadowJar {

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
javaParameters = true
freeCompilerArgs = listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi",
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-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 5 additions & 8 deletions src/main/kotlin/Autowire.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.comphenix.protocol.PacketType
import com.comphenix.protocol.ProtocolManager
import com.comphenix.protocol.wrappers.EnumWrappers
import com.comphenix.protocol.wrappers.WrappedChatComponent
import net.md_5.bungee.api.ChatMessageType
import net.md_5.bungee.api.chat.TextComponent
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.block.data.type.RedstoneWire
Expand All @@ -25,7 +27,6 @@ import java.util.*
@Description("Get that there redstone automagically!")
@CommandPermission("redstonetools.autowire")
class Autowire(
private val protocolManager: ProtocolManager,
private val pluginManager: PluginManager,
) : BaseCommand(), Listener {
private val autos = mutableSetOf<UUID>()
Expand All @@ -42,11 +43,7 @@ class Autowire(
}

private fun Player.sendActionBarTitle(message: String) {
val titlePacket = protocolManager.createPacket(PacketType.Play.Server.TITLE).apply {
titleActions.write(0, EnumWrappers.TitleAction.ACTIONBAR)
chatComponents.write(0, WrappedChatComponent.fromText(message))
}
protocolManager.sendServerPacket(this, titlePacket)
spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent(message))
}

@EventHandler
Expand All @@ -62,7 +59,7 @@ class Autowire(
player.gameMode != GameMode.CREATIVE,
!block.blockData.material.isSolid,
blockPlaced.type.hasGravity(),
).any().ifTrue { return }
).any { it }.ifTrue { return }
}
val wirePosition = event.blockPlaced.location.add(0.0, 1.0, 0.0)
if (wirePosition.block.type != Material.AIR) return
Expand All @@ -89,4 +86,4 @@ class Autowire(

private inline fun Boolean.ifTrue(block: () -> Unit) {
if (this) block()
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/RStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class RStack(private val worldEdit: WorldEdit) : BaseCommand() {

private fun isDiagDirStr(direction: String, upOrDown: Char) =
// check length, because 'd' and 'u' alone are not diagonal directions (they're just up or down)
direction.length > 1 && direction.last().toLowerCase() == upOrDown
direction.length > 1 && direction.last().lowercaseChar() == upOrDown
}

private fun <E> List<E>.getOrDefault(index: Int, default: E): E = getOrNull(index) ?: default
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/RedstoneTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RedstoneTools : JavaPlugin() {
}
val worldEdit = wePlugin.worldEdit
val protocolManager = ProtocolLibrary.getProtocolManager()
val autowire = Autowire(protocolManager, server.pluginManager)
val autowire = Autowire(server.pluginManager)
arrayOf(
WorldEditHelper(this, worldEdit),
SlabListener(),
Expand Down Expand Up @@ -89,7 +89,7 @@ private interface Thing<T> {
}

private fun <T> PaperCommandManager.registerThing(thing: Thing<T>) {
val name = thing.readableName.replace(" ", "_").toLowerCase()
val name = thing.readableName.replace(" ", "_").lowercase()
val errorMessage = "${thing.readableName} must be one of ${thing.values}"
commandContexts.registerContext(thing.valueClass) { context ->
thing.of(context.popFirstArg()) ?: throw InvalidCommandArgument(errorMessage)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/Slab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Slab : BaseCommand() {
}

private fun getSlab(type: String): ItemStack? {
val material = Material.getMaterial(type.toUpperCase()) ?: return null
val material = Material.getMaterial(type.uppercase()) ?: return null
if (!material.isBlock) return null
val blockData = material.createBlockData() as? Slab ?: return null
val itemStack = ItemStack(material, 1)
Expand Down Expand Up @@ -76,5 +76,5 @@ class SlabCompletionHandler :
override fun getCompletions(context: BukkitCommandCompletionContext): Collection<String> = Material
.values()
.filter { it.isBlock && it.createBlockData() is Slab }
.map { it.toString().toLowerCase() }
.map { it.toString().lowercase() }
}

0 comments on commit e4296fb

Please sign in to comment.