1.0.0 GOLDEN CARROTS MUST DIE
This commit is contained in:
parent
5c08a977dd
commit
98d9ea1090
8 changed files with 41 additions and 56 deletions
|
|
@ -15,7 +15,7 @@ val javaVersion = 24
|
|||
|
||||
group = "dev.marrow"
|
||||
version = "1.0"
|
||||
description = "paper plugin template"
|
||||
description = "Golden carrots must die"
|
||||
|
||||
// paper-plugin.yml
|
||||
paper {
|
||||
|
|
@ -25,7 +25,7 @@ paper {
|
|||
// version is version value
|
||||
|
||||
foliaSupported = true
|
||||
author = "You"
|
||||
author = "Lonewoss"
|
||||
main = "$group.${project.name.lowercase()}.Core"
|
||||
apiVersion = "1.21"
|
||||
prefix = project.name.lowercase()
|
||||
|
|
@ -70,7 +70,8 @@ publishing {
|
|||
tasks {
|
||||
|
||||
runServer {
|
||||
version("1.21.8")
|
||||
serverJar(file("run/prismatic-bundler-1.21.8-R0.1-SNAPSHOT-mojmap.jar"))
|
||||
version("1.21.7")
|
||||
}
|
||||
|
||||
build {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
rootProject.name = "plugin"
|
||||
rootProject.name = "zcarrots"
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package dev.marrow.plugin.commands
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode
|
||||
import net.kyori.adventure.text.Component
|
||||
import com.mojang.brigadier.Command
|
||||
import dev.marrow.plugin.Core
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||
import io.papermc.paper.command.brigadier.Commands.literal
|
||||
import io.papermc.paper.command.brigadier.Commands.argument
|
||||
import io.papermc.paper.command.brigadier.argument.ArgumentTypes
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver
|
||||
|
||||
class Example private constructor() {
|
||||
companion object {
|
||||
operator fun invoke(command: String): LiteralCommandNode<CommandSourceStack> {
|
||||
return literal(command).apply {
|
||||
then(argument("player", ArgumentTypes.player()).apply {
|
||||
then(argument("message", StringArgumentType.greedyString()).apply {
|
||||
executes {
|
||||
val sender = it.source.sender
|
||||
val targetResolver = it.getArgument("player", PlayerSelectorArgumentResolver::class.java)
|
||||
val target = targetResolver.resolve(it.source).first()
|
||||
val message = it.getArgument("message", String::class.java)
|
||||
sender.sendMessage("${target.name} will receive your message in 1 second")
|
||||
target.scheduler.runDelayed(Core.instance, {
|
||||
target.sendMessage(Component.text("${sender.name}: $message"))
|
||||
}, null, 20)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
})
|
||||
})
|
||||
}.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/main/kotlin/dev/marrow/plugin/Core.kt → src/main/kotlin/dev/marrow/zcarrots/Core.kt
Executable file → Normal file
15
src/main/kotlin/dev/marrow/plugin/Core.kt → src/main/kotlin/dev/marrow/zcarrots/Core.kt
Executable file → Normal file
|
|
@ -1,9 +1,8 @@
|
|||
package dev.marrow.plugin
|
||||
package dev.marrow.zcarrots
|
||||
|
||||
import dev.marrow.plugin.commands.Example
|
||||
import dev.marrow.plugin.config.ConfigIO
|
||||
import dev.marrow.plugin.utils.ComponentExtension.deserializeMiniMessage
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents
|
||||
import dev.marrow.zcarrots.config.ConfigIO
|
||||
import dev.marrow.zcarrots.listeners.CarrotListener
|
||||
import dev.marrow.zcarrots.utils.ComponentExtension.deserializeMiniMessage
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
|
@ -20,14 +19,10 @@ class Core : JavaPlugin() {
|
|||
console = logger
|
||||
ConfigIO.readConfig()
|
||||
|
||||
this.lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS) {
|
||||
it.registrar().register(Example("example"), listOf("example_alias"))
|
||||
}
|
||||
|
||||
server.pluginManager.registerEvents(CarrotListener(this), this)
|
||||
server.consoleSender.sendMessage(ConfigIO.instance.enabledMessage.deserializeMiniMessage())
|
||||
}
|
||||
|
||||
|
||||
override fun onLoad() {
|
||||
File("${System.getProperty("user.dir")}/plugins/${this.name}").mkdir()
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package dev.marrow.plugin.config
|
||||
package dev.marrow.zcarrots.config
|
||||
|
||||
import dev.marrow.plugin.Core
|
||||
import dev.marrow.plugin.utils.CommonUtils.gson
|
||||
import dev.marrow.zcarrots.Core
|
||||
import dev.marrow.zcarrots.utils.CommonUtils.gson
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
|
|
@ -13,7 +13,7 @@ object ConfigIO {
|
|||
lateinit var instance: ConfigurationModel
|
||||
|
||||
data class ConfigurationModel(
|
||||
val enabledMessage: String = "<green>example plugin enabled"
|
||||
val enabledMessage: String = "<green>ZCarrots enabled"
|
||||
)
|
||||
|
||||
private val file = File("${System.getProperty("user.dir")}/plugins/${Core.instance.name}/config.json")
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package dev.marrow.zcarrots.listeners
|
||||
|
||||
import dev.marrow.zcarrots.Core
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.inventory.InventoryClickEvent
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent
|
||||
import org.bukkit.inventory.EquipmentSlot
|
||||
import org.bukkit.inventory.PlayerInventory
|
||||
|
||||
class CarrotListener(private val plugin: Core) : Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
fun onTakeGoldenCarrot(e: InventoryClickEvent) {
|
||||
val item = e.cursor.takeIf { it.type == Material.GOLDEN_CARROT } ?: e.currentItem.takeIf { it?.type == Material.GOLDEN_CARROT } ?: return
|
||||
val itemMeta = item.itemMeta ?: return
|
||||
if (!itemMeta.hasEquippable()) return
|
||||
|
||||
val inventory = e.whoClicked.inventory
|
||||
val sourceSlot = inventory.first(item)
|
||||
if (sourceSlot == -1) return
|
||||
inventory.setItem(sourceSlot, null)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.marrow.plugin.utils
|
||||
package dev.marrow.zcarrots.utils
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
2
src/main/kotlin/dev/marrow/plugin/utils/ComponentExtension.kt → src/main/kotlin/dev/marrow/zcarrots/utils/ComponentExtension.kt
Executable file → Normal file
2
src/main/kotlin/dev/marrow/plugin/utils/ComponentExtension.kt → src/main/kotlin/dev/marrow/zcarrots/utils/ComponentExtension.kt
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
|||
@file:Suppress("unused")
|
||||
|
||||
package dev.marrow.plugin.utils
|
||||
package dev.marrow.zcarrots.utils
|
||||
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.TextDecoration
|
||||
Loading…
Add table
Add a link
Reference in a new issue