Skip to content

Commit

Permalink
Fix registerThing throwing at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulikauro committed Jun 14, 2020
1 parent 8134f3a commit d92b6d8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
javaParameters = true
freeCompilerArgs = listOf("-Xinline-classes", "-XXLanguage:+NewInference" , "-Xopt-in=kotlin.ExperimentalStdlibApi")
freeCompilerArgs = listOf("-Xopt-in=kotlin.ExperimentalStdlibApi")
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/NbtUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ fun NBTItem.addFakeEnchant() {
setInteger("HideFlags", 1)
}

// 😎
@Suppress("UNCHECKED_CAST")
inline fun <T: ItemMeta> ItemStack.modifyMeta(action: T.() -> Unit) {
itemMeta = (itemMeta as T).apply(action)
}
1 change: 1 addition & 0 deletions src/main/kotlin/RStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class RStack(private val worldEdit: WorldEdit) : BaseCommand() {
private fun doStack(player: WEPlayer, count: Int, spacing: Int, expand: Boolean, direction: String): Int {
val session = worldEdit.sessionManager.get(player)
val selection = try {
// TODO: null check session.selectionWorld
session.getSelection(session.selectionWorld)
} catch (e: IncompleteRegionException) {
throw ConditionFailedException("You do not have a selection!")
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/RedstoneTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class RedstoneTools : JavaPlugin() {
val worldEdit = wePlugin.worldEdit
server.pluginManager.registerEvents(WorldEditHelper(this, worldEdit), this)
PaperCommandManager(this).apply {
commandCompletions.registerCompletion("slabs", SlabCompletionHandler())
registerThing<SignalStrength>("Signal strength", { SignalStrength.of(it) }, SignalStrength.values)
registerThing<SignalContainer>("Container", { SignalContainer.of(it) }, SignalContainer.values)
setDefaultExceptionHandler(::handleCommandException, false)
registerCommands(
RStack(worldEdit),
Container(),
Slab()
)
commandCompletions.registerCompletion("slabs", SlabCompletionHandler())
registerThing("Signal strength", SignalStrength::of, SignalStrength.values)
registerThing("Container", SignalContainer::of, SignalContainer.values)
setDefaultExceptionHandler(::handleCommandException, false)
}
}
}
Expand All @@ -69,7 +69,7 @@ inline fun <reified T> PaperCommandManager.registerThing(
commandCompletions.setDefaultCompletion(name, T::class.java)
}

inline class SignalStrength(val value: Int) {
class SignalStrength(val value: Int) {
companion object {
fun of(arg: String): SignalStrength? = when (arg) {
in hexValues -> SignalStrength(arg.toInt(16))
Expand All @@ -82,7 +82,7 @@ inline class SignalStrength(val value: Int) {
}
}

inline class SignalContainer(val material: Material) {
class SignalContainer(val material: Material) {
companion object {
// Not a map [yet] cuz we want shortcuts
// maybe possible to just check first letter (like WorldEdit does with directions)
Expand Down

0 comments on commit d92b6d8

Please sign in to comment.