Compare commits
2 Commits
8485ed71dd
...
1266ff75cd
| Author | SHA1 | Date | |
|---|---|---|---|
| 1266ff75cd | |||
| f6bebd133b |
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
|||
[submodule "kommand-lib"]
|
||||
path = kommand-lib
|
||||
url = git@gitea.hareworks.net:Hare/kommand-lib.git
|
||||
[submodule "permits-lib"]
|
||||
path = permits-lib
|
||||
url = git@gitea.hareworks.net:Hare/permits-lib.git
|
||||
|
|
|
|||
|
|
@ -18,21 +18,21 @@ val exposedVersion = "1.0.0-rc-4"
|
|||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
|
||||
compileOnly("net.kyori:adventure-api:4.25.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.25.0")
|
||||
implementation("net.kyori:adventure-api:4.25.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.25.0")
|
||||
|
||||
compileOnly("org.postgresql:postgresql:42.7.8")
|
||||
compileOnly("org.jetbrains.kotlinx:kotlinx-datetime:0.7.1")
|
||||
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
|
||||
compileOnly("org.jetbrains.exposed:exposed-core:$exposedVersion")
|
||||
compileOnly("org.jetbrains.exposed:exposed-dao:$exposedVersion")
|
||||
compileOnly("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
|
||||
compileOnly("org.jetbrains.exposed:exposed-kotlin-datetime:$exposedVersion")
|
||||
compileOnly("com.michael-bull.kotlin-result:kotlin-result:2.1.0")
|
||||
compileOnly("net.hareworks:kommand-lib:1.1")
|
||||
compileOnly("net.hareworks:permits-lib:1.1")
|
||||
implementation("org.postgresql:postgresql:42.7.8")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.7.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
|
||||
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-kotlin-datetime:$exposedVersion")
|
||||
implementation("com.michael-bull.kotlin-result:kotlin-result:2.1.0")
|
||||
implementation("net.hareworks:kommand-lib:1.1")
|
||||
implementation("net.hareworks:permits-lib:1.1")
|
||||
}
|
||||
tasks {
|
||||
withType<Jar> {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 6c62d3306e2cc0e0fefe8ec7fb9b64a47caae3cb
|
||||
Subproject commit 3835c9b9e2d488681b39f4cfd827e3e3371a1e1b
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 660f9a343607513272346ac82b61eb38187b23e8
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
rootProject.name = "elevator"
|
||||
|
||||
includeBuild("kommand-lib")
|
||||
includeBuild("permits-lib")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
package com.github.kaaariyaaa.elevator;
|
||||
|
||||
import com.github.kaaariyaaa.elevator.command.CommandRegistrar
|
||||
import net.hareworks.kommand_lib.KommandLib
|
||||
import net.hareworks.permits_lib.PermitsLib
|
||||
import net.hareworks.permits_lib.domain.NodeRegistration
|
||||
|
||||
import org.bukkit.permissions.PermissionDefault
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
public class App : JavaPlugin() {
|
||||
|
||||
private var commands: KommandLib? = null
|
||||
private val permits = PermitsLib.session(this)
|
||||
|
||||
companion object {
|
||||
lateinit var instance: App
|
||||
private set
|
||||
|
|
@ -10,6 +20,10 @@ public class App : JavaPlugin() {
|
|||
|
||||
override fun onEnable() {
|
||||
instance = this
|
||||
logger.info("SamplePlugin enabled!!!!")
|
||||
saveDefaultConfig()
|
||||
server.pluginManager.registerEvents(com.github.kaaariyaaa.elevator.listeners.EventListener(this), this)
|
||||
logger.info("Elevator plugin enabled!")
|
||||
|
||||
commands = CommandRegistrar.register(this, permits)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.github.kaaariyaaa.elevator.command
|
||||
|
||||
import com.github.kaaariyaaa.elevator.App
|
||||
import net.hareworks.kommand_lib.KommandLib
|
||||
import net.hareworks.kommand_lib.kommand
|
||||
import net.hareworks.permits_lib.bukkit.MutationSession
|
||||
import org.bukkit.permissions.PermissionDefault
|
||||
|
||||
object CommandRegistrar {
|
||||
fun register(plugin: App, permits: MutationSession): KommandLib {
|
||||
return kommand(plugin) {
|
||||
// Permission configuration
|
||||
permissions {
|
||||
namespace = "elevator"
|
||||
defaultValue = PermissionDefault.TRUE
|
||||
session(permits)
|
||||
}
|
||||
|
||||
// Main command structure
|
||||
command("elevator", "el") {
|
||||
description = "Elevator plugin main command"
|
||||
|
||||
// Default execution if no arguments
|
||||
executes {
|
||||
sender.sendMessage("Elevator plugin v${plugin.description.version}")
|
||||
}
|
||||
|
||||
// Subcommand: /elevator reload
|
||||
literal("reload") {
|
||||
permission {
|
||||
description = "Allows reloading the plugin"
|
||||
defaultValue = PermissionDefault.OP
|
||||
}
|
||||
executes {
|
||||
plugin.reloadConfig()
|
||||
sender.sendMessage("Configuration reloaded.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.github.kaaariyaaa.elevator.listeners
|
||||
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent
|
||||
import com.destroystokyo.paper.event.player.PlayerJumpEvent
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.Block
|
||||
|
||||
import com.github.kaaariyaaa.elevator.App
|
||||
|
||||
class EventListener(private val plugin: App) : Listener {
|
||||
|
||||
private val oreBlock: Set<Material>
|
||||
get() = plugin.config.getStringList("elevatorBlocks")
|
||||
.mapNotNull { Material.matchMaterial(it) }
|
||||
.toSet()
|
||||
|
||||
@EventHandler
|
||||
fun onJump(event: PlayerJumpEvent) {
|
||||
val player = event.player
|
||||
val blockUnder = player.location.subtract(0.0, 1.0, 0.0).block
|
||||
|
||||
if (blockUnder.type.isSolid && blockUnder.type in oreBlock) {
|
||||
var location = blockUnder.location
|
||||
location = location.add(0.0, 1.0, 0.0)
|
||||
|
||||
val maxHeight = plugin.config.getInt("maxHeight", 64)
|
||||
var distance = 0
|
||||
|
||||
while (!location.block.type.isSolid && !(location.block.type in oreBlock) && distance < maxHeight) {
|
||||
location = location.add(0.0, 1.0, 0.0)
|
||||
distance++
|
||||
}
|
||||
|
||||
if (location.block.type.isSolid && location.block.type in oreBlock) {
|
||||
player.teleport(location.add(0.5, 1.0, 0.5).addRotation(player.location.yaw, player.location.pitch))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onSneak(event: PlayerToggleSneakEvent) {
|
||||
if (!event.isSneaking) return
|
||||
|
||||
val player = event.player
|
||||
val blockUnder = player.location.subtract(0.0, 1.0, 0.0).block
|
||||
|
||||
if (blockUnder.type.isSolid && blockUnder.type in oreBlock) {
|
||||
var location = blockUnder.location
|
||||
location = location.subtract(0.0, 1.0, 0.0)
|
||||
|
||||
val maxHeight = plugin.config.getInt("maxHeight", 64)
|
||||
var distance = 0
|
||||
|
||||
while (!location.block.type.isSolid && !(location.block.type in oreBlock) && distance < maxHeight) {
|
||||
location = location.subtract(0.0, 1.0, 0.0)
|
||||
distance++
|
||||
}
|
||||
|
||||
if (location.block.type.isSolid && location.block.type in oreBlock) {
|
||||
player.teleport(location.add(0.5, 1.0, 0.5).addRotation(player.location.yaw, player.location.pitch))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/main/resources/config.yml
Normal file
15
src/main/resources/config.yml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Elevator Plugin Configuration
|
||||
|
||||
# The maximum distance (in blocks) the elevator will search for a valid destination.
|
||||
maxHeight: 64
|
||||
|
||||
# Blocks that function as elevators
|
||||
elevatorBlocks:
|
||||
- minecraft:iron_block
|
||||
- minecraft:gold_block
|
||||
- minecraft:diamond_block
|
||||
- minecraft:lapis_block
|
||||
- minecraft:redstone_block
|
||||
- minecraft:emerald_block
|
||||
- minecraft:netherite_block
|
||||
- minecraft:coal_block
|
||||
Loading…
Reference in New Issue
Block a user