DisableExlosions, Warp
This commit is contained in:
@ -2,6 +2,7 @@ package com.pobnellion.pobutils
|
|||||||
|
|
||||||
import com.pobnellion.pobutils.modules.CmdModule
|
import com.pobnellion.pobutils.modules.CmdModule
|
||||||
import com.pobnellion.pobutils.modules.ModuleBase
|
import com.pobnellion.pobutils.modules.ModuleBase
|
||||||
|
import com.pobnellion.pobutils.modules.disableExplosions.DisableExplosions
|
||||||
import com.pobnellion.pobutils.modules.disableTrample.DisableTrample
|
import com.pobnellion.pobutils.modules.disableTrample.DisableTrample
|
||||||
import com.pobnellion.pobutils.modules.formatChat.FormatChat
|
import com.pobnellion.pobutils.modules.formatChat.FormatChat
|
||||||
import com.pobnellion.pobutils.modules.hub.Hub
|
import com.pobnellion.pobutils.modules.hub.Hub
|
||||||
@ -9,6 +10,7 @@ import com.pobnellion.pobutils.modules.noJoinMessage.NoJoinMessage
|
|||||||
import com.pobnellion.pobutils.modules.portals.Portals
|
import com.pobnellion.pobutils.modules.portals.Portals
|
||||||
import com.pobnellion.pobutils.modules.sit.Sit
|
import com.pobnellion.pobutils.modules.sit.Sit
|
||||||
import com.pobnellion.pobutils.modules.spawn.Spawn
|
import com.pobnellion.pobutils.modules.spawn.Spawn
|
||||||
|
import com.pobnellion.pobutils.modules.warp.Warp
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -21,15 +23,19 @@ class Pobutils : JavaPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
loadDefaultConfig()
|
registerModule(DisableExplosions(this))
|
||||||
|
registerModule(DisableTrample(this))
|
||||||
registerModule(Portals(this))
|
registerModule(FormatChat(this)) // TODO: test set format config
|
||||||
|
registerModule(Hub(this))
|
||||||
registerModule(NoJoinMessage(this))
|
registerModule(NoJoinMessage(this))
|
||||||
|
registerModule(Portals(this))
|
||||||
registerModule(Sit(this)) // TODO: maybe sit when right click stairs?
|
registerModule(Sit(this)) // TODO: maybe sit when right click stairs?
|
||||||
registerModule(Spawn(this))
|
registerModule(Spawn(this))
|
||||||
registerModule(Hub(this))
|
registerModule(Warp(this))
|
||||||
registerModule(DisableTrample(this))
|
//snowballDamage
|
||||||
registerModule(FormatChat(this))
|
|
||||||
|
config.options().copyDefaults(true)
|
||||||
|
saveConfig()
|
||||||
|
|
||||||
CmdModule.register(this)
|
CmdModule.register(this)
|
||||||
|
|
||||||
@ -54,42 +60,8 @@ class Pobutils : JavaPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun registerModule(module: ModuleBase) {
|
private fun registerModule(module: ModuleBase) {
|
||||||
|
config.addDefault("modules.${module.name}", false)
|
||||||
availableModules[module.name] = module
|
availableModules[module.name] = module
|
||||||
module.register()
|
module.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDefaultConfig() {
|
|
||||||
saveResource("config.yml", false)
|
|
||||||
|
|
||||||
config.addDefault("modules.noJoinMessage", false)
|
|
||||||
config.addDefault("modules.portals", false)
|
|
||||||
config.addDefault("modules.sit", false)
|
|
||||||
config.addDefault("modules.spawn", false)
|
|
||||||
config.addDefault("modules.hub", false)
|
|
||||||
config.addDefault("modules.disableTrample", false)
|
|
||||||
|
|
||||||
config.addDefault("modules.formatChat", false)
|
|
||||||
config.addDefault("modules.disableTNT", false)
|
|
||||||
|
|
||||||
config.addDefault("modules.warp", false)
|
|
||||||
config.addDefault("modules.snowballDamage", false)
|
|
||||||
config.addDefault("modules.tabList", false)
|
|
||||||
|
|
||||||
config.addDefault("data.spawn.location", "")
|
|
||||||
config.addDefault("data.spawn.spawnOnJoin", false)
|
|
||||||
config.addDefault("data.spawn.spawnOnDeath", false)
|
|
||||||
|
|
||||||
// config.addDefault("data.spawn.spawnOnFirstJoin", false);
|
|
||||||
config.addDefault("data.portals", "")
|
|
||||||
config.addDefault("data.warps", "")
|
|
||||||
config.addDefault("data.formatChat.serverAlias", "?")
|
|
||||||
config.addDefault("data.formatChat.messageFormat", "<gray><server_alias> <white><username>: <message>")
|
|
||||||
config.addDefault("data.formatChat.formatMessageText", true)
|
|
||||||
|
|
||||||
config.addDefault("settings.snowballDamage.damageExceptions", ArrayList<String?>())
|
|
||||||
config.addDefault("settings.snowballDamage.snowmenDontHitEachother", true)
|
|
||||||
|
|
||||||
config.options().copyDefaults(true)
|
|
||||||
saveConfig()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ object CmdModule {
|
|||||||
.then(enable(plugin))
|
.then(enable(plugin))
|
||||||
.then(disable(plugin))
|
.then(disable(plugin))
|
||||||
.then(reload(plugin))
|
.then(reload(plugin))
|
||||||
.then(config(plugin))
|
.then(config())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
plugin.lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS) {commands ->
|
plugin.lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS) {commands ->
|
||||||
@ -120,7 +120,7 @@ object CmdModule {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun config(plugin: JavaPlugin) : LiteralArgumentBuilder<CommandSourceStack> {
|
private fun config() : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
val configCommand = Commands.literal("config")
|
val configCommand = Commands.literal("config")
|
||||||
.executes { ctx ->
|
.executes { ctx ->
|
||||||
for ((name, _) in Pobutils.availableModules) {
|
for ((name, _) in Pobutils.availableModules) {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.pobnellion.pobutils.modules
|
package com.pobnellion.pobutils.modules
|
||||||
|
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.pobnellion.pobutils.modules.disableExplosions
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Command
|
||||||
|
import com.mojang.brigadier.arguments.BoolArgumentType
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
|
import io.papermc.paper.command.brigadier.Commands
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
object CmdDisableExplosionsConfig {
|
||||||
|
fun configCmd(plugin: JavaPlugin, disableExplosions: DisableExplosions) : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
|
return Commands.literal(disableExplosions.name)
|
||||||
|
.then(Commands.literal("igniteTnt")
|
||||||
|
.then(Commands.argument("shouldIgniteTnt", BoolArgumentType.bool())
|
||||||
|
.executes { ctx ->
|
||||||
|
val shouldIgniteTnt = BoolArgumentType.getBool(ctx, "shouldIgniteTnt")
|
||||||
|
disableExplosions.igniteTnt = shouldIgniteTnt
|
||||||
|
plugin.config.set("data.disableExplosions.igniteTnt", shouldIgniteTnt)
|
||||||
|
plugin.saveConfig()
|
||||||
|
ctx.source.sender.sendMessage(Component.text("igniteTnt set to: $shouldIgniteTnt", NamedTextColor.YELLOW))
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}))
|
||||||
|
.executes { ctx ->
|
||||||
|
ctx.source.sender.sendMessage("DisableExplosions config:")
|
||||||
|
|
||||||
|
ctx.source.sender.sendMessage(Component.text("igniteTnt: ", NamedTextColor.YELLOW)
|
||||||
|
.append(Component.text(disableExplosions.igniteTnt.toString(), NamedTextColor.WHITE)))
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.pobnellion.pobutils.modules.disableExplosions
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
||||||
|
import com.pobnellion.pobutils.Pobutils
|
||||||
|
import com.pobnellion.pobutils.modules.ModuleBase
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
class DisableExplosions(plugin: JavaPlugin) : ModuleBase(plugin), Listener {
|
||||||
|
override val name: String = "disableExplosions"
|
||||||
|
var igniteTnt: Boolean = false
|
||||||
|
|
||||||
|
override fun register() {
|
||||||
|
plugin.server.pluginManager.registerEvents(this, plugin)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun reload() {
|
||||||
|
plugin.reloadConfig()
|
||||||
|
onEnable()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDisable() { }
|
||||||
|
|
||||||
|
override fun onEnable() {
|
||||||
|
igniteTnt = plugin.config.getBoolean("data.disableExplosions.igniteTnt")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun configCmd(): LiteralArgumentBuilder<CommandSourceStack>? {
|
||||||
|
return CmdDisableExplosionsConfig.configCmd(plugin, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onExplosion(event: EntityExplodeEvent) {
|
||||||
|
if (!Pobutils.isEnabled(this.name))
|
||||||
|
return
|
||||||
|
|
||||||
|
if (igniteTnt)
|
||||||
|
event.blockList().removeIf { block -> block.type != Material.TNT }
|
||||||
|
else
|
||||||
|
event.blockList().clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,7 @@ object CmdFormatChatConfig {
|
|||||||
plugin.config.set("data.formatChat.serverAlias", alias)
|
plugin.config.set("data.formatChat.serverAlias", alias)
|
||||||
formatChat.serverAlias = alias
|
formatChat.serverAlias = alias
|
||||||
plugin.saveConfig()
|
plugin.saveConfig()
|
||||||
|
ctx.source.sender.sendMessage(Component.text("serverAlias set to: $alias", NamedTextColor.YELLOW))
|
||||||
return@executes Command.SINGLE_SUCCESS
|
return@executes Command.SINGLE_SUCCESS
|
||||||
}))
|
}))
|
||||||
.then(Commands.literal("messageFormat"))
|
.then(Commands.literal("messageFormat"))
|
||||||
@ -30,6 +31,7 @@ object CmdFormatChatConfig {
|
|||||||
plugin.config.set("data.formatChat.messageFormat", format)
|
plugin.config.set("data.formatChat.messageFormat", format)
|
||||||
formatChat.messageFormat = format
|
formatChat.messageFormat = format
|
||||||
plugin.saveConfig()
|
plugin.saveConfig()
|
||||||
|
ctx.source.sender.sendMessage(Component.text("messageFormat set to: $format", NamedTextColor.YELLOW))
|
||||||
return@executes Command.SINGLE_SUCCESS
|
return@executes Command.SINGLE_SUCCESS
|
||||||
})
|
})
|
||||||
.then(Commands.literal("formatMessageText")
|
.then(Commands.literal("formatMessageText")
|
||||||
@ -39,19 +41,24 @@ object CmdFormatChatConfig {
|
|||||||
plugin.config.set("data.formatChat.formatMessageText", shouldFormat)
|
plugin.config.set("data.formatChat.formatMessageText", shouldFormat)
|
||||||
formatChat.formatMessageText = shouldFormat
|
formatChat.formatMessageText = shouldFormat
|
||||||
plugin.saveConfig()
|
plugin.saveConfig()
|
||||||
|
ctx.source.sender.sendMessage(Component.text("formatMessageText set to: $shouldFormat", NamedTextColor.YELLOW))
|
||||||
return@executes Command.SINGLE_SUCCESS
|
return@executes Command.SINGLE_SUCCESS
|
||||||
}))
|
}))
|
||||||
.executes { ctx ->
|
.executes { ctx ->
|
||||||
|
val serverAlias = plugin.config.getString("data.formatChat.serverAlias", "?")!!
|
||||||
|
val messageFormat = plugin.config.getString("data.formatChat.messageFormat", formatChat.defaultFormat)!!
|
||||||
|
val formatMessageText = plugin.config.getBoolean("data.formatChat.formatMessageText", true)
|
||||||
|
|
||||||
ctx.source.sender.sendMessage("FormatChat config:")
|
ctx.source.sender.sendMessage("FormatChat config:")
|
||||||
|
|
||||||
ctx.source.sender.sendMessage(Component.text("serverAlias: ", NamedTextColor.YELLOW)
|
ctx.source.sender.sendMessage(Component.text("serverAlias: ", NamedTextColor.YELLOW)
|
||||||
.append(Component.text(formatChat.serverAlias, NamedTextColor.WHITE)))
|
.append(Component.text(serverAlias, NamedTextColor.WHITE)))
|
||||||
|
|
||||||
ctx.source.sender.sendMessage(Component.text("messageFormat: ", NamedTextColor.YELLOW)
|
ctx.source.sender.sendMessage(Component.text("messageFormat: ", NamedTextColor.YELLOW)
|
||||||
.append(Component.text(formatChat.messageFormat, NamedTextColor.WHITE)))
|
.append(Component.text(messageFormat, NamedTextColor.WHITE)))
|
||||||
|
|
||||||
ctx.source.sender.sendMessage(Component.text("formatMessageText: ", NamedTextColor.YELLOW)
|
ctx.source.sender.sendMessage(Component.text("formatMessageText: ", NamedTextColor.YELLOW)
|
||||||
.append(Component.text(formatChat.formatMessageText.toString(), NamedTextColor.WHITE)))
|
.append(Component.text(formatMessageText.toString(), NamedTextColor.WHITE)))
|
||||||
|
|
||||||
return@executes Command.SINGLE_SUCCESS
|
return@executes Command.SINGLE_SUCCESS
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class FormatChat(plugin: JavaPlugin) : ModuleBase(plugin), Listener {
|
|||||||
override val name: String = "formatChat"
|
override val name: String = "formatChat"
|
||||||
lateinit var serverAlias: String
|
lateinit var serverAlias: String
|
||||||
lateinit var messageFormat: String
|
lateinit var messageFormat: String
|
||||||
|
val defaultFormat: String = "<gray><server_alias> <white><username>: <message>"
|
||||||
var formatMessageText: Boolean = false
|
var formatMessageText: Boolean = false
|
||||||
val renderer: Renderer = Renderer(this)
|
val renderer: Renderer = Renderer(this)
|
||||||
|
|
||||||
@ -30,9 +31,9 @@ class FormatChat(plugin: JavaPlugin) : ModuleBase(plugin), Listener {
|
|||||||
override fun onDisable() { }
|
override fun onDisable() { }
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
serverAlias = plugin.config.getString("data.formatChat.serverAlias")!!
|
serverAlias = plugin.config.getString("data.formatChat.serverAlias", "?")!!
|
||||||
messageFormat = plugin.config.getString("data.formatChat.messageFormat")!!
|
messageFormat = plugin.config.getString("data.formatChat.messageFormat", defaultFormat)!!
|
||||||
formatMessageText = plugin.config.getBoolean("data.formatChat.formatMessageText")
|
formatMessageText = plugin.config.getBoolean("data.formatChat.formatMessageText", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configCmd() : LiteralArgumentBuilder<CommandSourceStack>? {
|
override fun configCmd() : LiteralArgumentBuilder<CommandSourceStack>? {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.bukkit.entity.Player
|
|||||||
|
|
||||||
class Renderer(val formatChat: FormatChat) : ChatRenderer {
|
class Renderer(val formatChat: FormatChat) : ChatRenderer {
|
||||||
override fun render(source: Player, sourceDisplayName: Component, message: Component, viewer: Audience): Component {
|
override fun render(source: Player, sourceDisplayName: Component, message: Component, viewer: Audience): Component {
|
||||||
|
// Removes <playerName> at the start of the message
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,43 @@
|
|||||||
|
package com.pobnellion.pobutils.modules.warp
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Command
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType
|
||||||
|
import com.pobnellion.pobutils.Pobutils
|
||||||
|
import io.papermc.paper.command.brigadier.Commands
|
||||||
|
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
object CmdWarp {
|
||||||
|
fun register(plugin: JavaPlugin, warp: Warp) {
|
||||||
|
val command = Commands.literal("warp")
|
||||||
|
.requires { source -> Pobutils.isEnabled(warp.name) && source.sender is Player }
|
||||||
|
.then(Commands.argument("warp", StringArgumentType.string())
|
||||||
|
.suggests { ctx, builder ->
|
||||||
|
for (name in warp.warps.keys)
|
||||||
|
builder.suggest(name)
|
||||||
|
|
||||||
|
return@suggests builder.buildFuture()
|
||||||
|
}
|
||||||
|
.executes { ctx ->
|
||||||
|
val warpName = StringArgumentType.getString(ctx, "warp")
|
||||||
|
|
||||||
|
val warpLocation = warp.warps[warpName]
|
||||||
|
|
||||||
|
if (warpLocation == null)
|
||||||
|
ctx.source.sender.sendMessage(Component.text("No warp named '$warpName'", NamedTextColor.RED))
|
||||||
|
else
|
||||||
|
(ctx.source.sender as Player).teleport(warpLocation)
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
|
||||||
|
plugin.lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS) {commands ->
|
||||||
|
commands.registrar().register(command)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
package com.pobnellion.pobutils.modules.warp
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Command
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
|
import io.papermc.paper.command.brigadier.Commands
|
||||||
|
import io.papermc.paper.command.brigadier.argument.ArgumentTypes
|
||||||
|
import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
object CmdWarpConfig {
|
||||||
|
fun configCmd(plugin: JavaPlugin, warp: Warp) : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
|
return Commands.literal("warp")
|
||||||
|
.requires { source -> source.sender is Player }
|
||||||
|
.then(add(plugin, warp))
|
||||||
|
.then(update(plugin, warp))
|
||||||
|
.then(remove(plugin, warp))
|
||||||
|
.executes { ctx ->
|
||||||
|
ctx.source.sender.sendMessage("Warps:")
|
||||||
|
|
||||||
|
val warpNames = plugin.config.getConfigurationSection("data.warps")?.getKeys(false)
|
||||||
|
|
||||||
|
if (warpNames == null)
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
|
||||||
|
for (warpName in warpNames) {
|
||||||
|
val location = plugin.config.getLocation("data.warps.$warpName")!!
|
||||||
|
|
||||||
|
ctx.source.sender.sendMessage(Component.text("$warpName:", NamedTextColor.YELLOW)
|
||||||
|
.append(Component.text("${location.x} ${location.y} ${location.z}")))
|
||||||
|
}
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun add(plugin: JavaPlugin, warp: Warp) : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
|
return Commands.literal("add")
|
||||||
|
.then(Commands.argument("name", StringArgumentType.word())
|
||||||
|
.then(Commands.argument("location", ArgumentTypes.blockPosition())
|
||||||
|
.executes { ctx ->
|
||||||
|
val name = StringArgumentType.getString(ctx, "name")
|
||||||
|
val position = ctx.getArgument("location", BlockPositionResolver::class.java).resolve(ctx.source)
|
||||||
|
val location = position.toLocation((ctx.source.sender as Player).world)
|
||||||
|
|
||||||
|
if (plugin.config.get("data.warps.$name") != null) {
|
||||||
|
ctx.source.sender.sendMessage(Component.text("A warp called $name already exists!", NamedTextColor.RED))
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.config.set("data.warps.$name", location)
|
||||||
|
plugin.saveConfig()
|
||||||
|
|
||||||
|
warp.warps[name] = location
|
||||||
|
|
||||||
|
ctx.source.sender.sendMessage(Component.text("Created warp '$name'", NamedTextColor.YELLOW))
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun update(plugin: JavaPlugin, warp: Warp) : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
|
return Commands.literal("update")
|
||||||
|
.then(Commands.argument("name", StringArgumentType.word())
|
||||||
|
.suggests { ctx, builder ->
|
||||||
|
val warpNames = plugin.config.getConfigurationSection("data.warps")?.getKeys(false)
|
||||||
|
warpNames?.forEach { name -> builder.suggest(name) }
|
||||||
|
return@suggests builder.buildFuture()
|
||||||
|
}
|
||||||
|
.then(Commands.argument("location", ArgumentTypes.blockPosition())
|
||||||
|
.executes { ctx ->
|
||||||
|
val name = StringArgumentType.getString(ctx, "name")
|
||||||
|
val position = ctx.getArgument("location", BlockPositionResolver::class.java).resolve(ctx.source)
|
||||||
|
val location = position.toLocation((ctx.source.sender as Player).world)
|
||||||
|
|
||||||
|
if (plugin.config.get("data.warps.$name") == null) {
|
||||||
|
ctx.source.sender.sendMessage(Component.text("Could not find a warp called $name!", NamedTextColor.RED))
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.config.set("data.warps.$name", location)
|
||||||
|
plugin.saveConfig()
|
||||||
|
|
||||||
|
warp.warps[name] = location
|
||||||
|
|
||||||
|
ctx.source.sender.sendMessage(Component.text("Updated warp '$name'", NamedTextColor.YELLOW))
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun remove(plugin: JavaPlugin, warp: Warp) : LiteralArgumentBuilder<CommandSourceStack> {
|
||||||
|
return Commands.literal("remove")
|
||||||
|
.then(Commands.argument("name", StringArgumentType.word())
|
||||||
|
.suggests { ctx, builder ->
|
||||||
|
val warpNames = plugin.config.getConfigurationSection("data.warps")?.getKeys(false)
|
||||||
|
warpNames?.forEach { name -> builder.suggest(name) }
|
||||||
|
return@suggests builder.buildFuture()
|
||||||
|
}
|
||||||
|
.executes { ctx ->
|
||||||
|
val name = StringArgumentType.getString(ctx, "name")
|
||||||
|
|
||||||
|
if (plugin.config.get("data.warps.$name") == null) {
|
||||||
|
ctx.source.sender.sendMessage(Component.text("Could not find a warp called $name!", NamedTextColor.RED))
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.config.set("data.warps.$name", null)
|
||||||
|
plugin.saveConfig()
|
||||||
|
|
||||||
|
warp.warps.remove(name)
|
||||||
|
|
||||||
|
ctx.source.sender.sendMessage(Component.text("Removed warp '$name'", NamedTextColor.YELLOW))
|
||||||
|
|
||||||
|
return@executes Command.SINGLE_SUCCESS
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/main/kotlin/com/pobnellion/pobutils/modules/warp/Warp.kt
Normal file
39
src/main/kotlin/com/pobnellion/pobutils/modules/warp/Warp.kt
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.pobnellion.pobutils.modules.warp
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
||||||
|
import com.pobnellion.pobutils.modules.ModuleBase
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
class Warp(plugin: JavaPlugin) : ModuleBase(plugin) {
|
||||||
|
override val name: String = "warp"
|
||||||
|
val warps: MutableMap<String, Location> = mutableMapOf()
|
||||||
|
|
||||||
|
override fun register() {
|
||||||
|
CmdWarp.register(plugin, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun reload() {
|
||||||
|
warps.clear()
|
||||||
|
plugin.reloadConfig()
|
||||||
|
onEnable()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDisable() { }
|
||||||
|
|
||||||
|
override fun onEnable() {
|
||||||
|
val warpNames = plugin.config.getConfigurationSection("data.warps")?.getKeys(false)
|
||||||
|
|
||||||
|
if (warpNames == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
for (warpName in warpNames)
|
||||||
|
warps[warpName] = plugin.config.getLocation("data.warps.$warpName")!!
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun configCmd(): LiteralArgumentBuilder<CommandSourceStack>? {
|
||||||
|
return CmdWarpConfig.configCmd(plugin, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,27 +0,0 @@
|
|||||||
modules:
|
|
||||||
noJoinMessage: true
|
|
||||||
sit: true
|
|
||||||
spawn: false
|
|
||||||
portals: false
|
|
||||||
warp: false
|
|
||||||
hub: true
|
|
||||||
disableTNT: false
|
|
||||||
tabList: false
|
|
||||||
formatChat: true
|
|
||||||
disableTrample: false
|
|
||||||
snowballDamage: false
|
|
||||||
data:
|
|
||||||
spawn:
|
|
||||||
location: ''
|
|
||||||
spawnOnJoin: false
|
|
||||||
spawnOnDeath: false
|
|
||||||
portals: ''
|
|
||||||
warps: ''
|
|
||||||
formatChat:
|
|
||||||
serverAlias: '?'
|
|
||||||
messageFormat: '<gray><server_alias> <white><username>: <message>'
|
|
||||||
formatMessageText: true
|
|
||||||
settings:
|
|
||||||
snowballDamage:
|
|
||||||
damageExceptions: []
|
|
||||||
snowmenDontHitEachother: true
|
|
||||||
@ -8,7 +8,7 @@ authors: [ Bizink ]
|
|||||||
commands:
|
commands:
|
||||||
module:
|
module:
|
||||||
description: configure a module
|
description: configure a module
|
||||||
usage: /module <module> <enable|disable|config>
|
usage: /module <enable|disable|reload|config> <module>
|
||||||
permission: pobutils.admin
|
permission: pobutils.admin
|
||||||
|
|
||||||
spawn:
|
spawn:
|
||||||
@ -16,11 +16,6 @@ commands:
|
|||||||
usage: /spawn
|
usage: /spawn
|
||||||
permission: pobutils.user
|
permission: pobutils.user
|
||||||
|
|
||||||
setspawn:
|
|
||||||
description: Set spawn location
|
|
||||||
usage: /setspawn [location]
|
|
||||||
permission: pobutils.admin
|
|
||||||
|
|
||||||
sit:
|
sit:
|
||||||
description: Sit down for a while buddy
|
description: Sit down for a while buddy
|
||||||
usage: /sit
|
usage: /sit
|
||||||
@ -28,12 +23,12 @@ commands:
|
|||||||
|
|
||||||
portal:
|
portal:
|
||||||
description: add or remove a portal to another server
|
description: add or remove a portal to another server
|
||||||
usage: /portal <add|update|remove> <name> [x1] [y1] [z1] [x2] [y2] [z2] [destinationServer]
|
usage: /portal <add|update|remove|list> [name] [x1] [y1] [z1] [x2] [y2] [z2] [destinationServer]
|
||||||
permission: pobutils.admin
|
permission: pobutils.admin
|
||||||
|
|
||||||
warp:
|
warp:
|
||||||
description: list or go to warps
|
description: list or go to warps
|
||||||
usage: /warp [add|del|list|warpName] [warpName] [x] [y] [z] [yaw] [pitch]
|
usage: /warp <warpName>
|
||||||
permission: pobutils.user
|
permission: pobutils.user
|
||||||
|
|
||||||
hub:
|
hub:
|
||||||
|
|||||||
Reference in New Issue
Block a user