mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
progress
This commit is contained in:
parent
3eb07a8c09
commit
5f707c7397
5 changed files with 94 additions and 4 deletions
|
|
@ -49,9 +49,13 @@ open class CustomAnvil : JavaPlugin() {
|
|||
// Permission string required to reload the config
|
||||
const val commandReloadPermission = "ca.command.reload"
|
||||
|
||||
// Permission string required to get diagnostic data
|
||||
const val diagnosticPermission = "ca.command.diagnostic"
|
||||
|
||||
// Permission string required to edit the plugin's config
|
||||
const val editConfigPermission = "ca.config.edit"
|
||||
|
||||
|
||||
// Command Name to reload the config
|
||||
const val commandReloadName = "anvilconfigreload"
|
||||
|
||||
|
|
@ -292,6 +296,8 @@ open class CustomAnvil : JavaPlugin() {
|
|||
command = getCommand(commandConfigName)
|
||||
command?.setExecutor(EditConfigExecutor())
|
||||
|
||||
println(getCommand("customanvil"))
|
||||
println(getCommand("customanvila"))
|
||||
CustomAnvilCmd(this)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@ class CustomAnvilCmd(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
|||
init {
|
||||
commands = ImmutableMap.of<String, CASubCommand>(
|
||||
"gui", editConfigCommand,
|
||||
"reload", ReloadExecutor()
|
||||
"reload", ReloadExecutor(),
|
||||
"diagnostic", Diagnostic(),
|
||||
)
|
||||
|
||||
println(plugin.getCommand(genericCommandName))
|
||||
val self = plugin.getCommand(genericCommandName)!!
|
||||
self.setExecutor(this)
|
||||
self.tabCompleter = this
|
||||
|
|
|
|||
77
src/main/kotlin/xyz/alexcrea/cuanvil/command/Diagnostic.kt
Normal file
77
src/main/kotlin/xyz/alexcrea/cuanvil/command/Diagnostic.kt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
package xyz.alexcrea.cuanvil.command
|
||||
|
||||
import io.delilaheve.CustomAnvil
|
||||
import net.md_5.bungee.api.chat.ClickEvent
|
||||
import net.md_5.bungee.api.chat.HoverEvent
|
||||
import net.md_5.bungee.api.chat.TextComponent
|
||||
import net.md_5.bungee.api.chat.hover.content.Text
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.HumanEntity
|
||||
|
||||
class Diagnostic: CASubCommand() {
|
||||
|
||||
companion object{
|
||||
private const val NO_DIAG_PERM = "You do not have permission to diagnostic this server"
|
||||
}
|
||||
|
||||
override fun executeCommand(
|
||||
sender: CommandSender,
|
||||
cmd: Command,
|
||||
cmdstr: String,
|
||||
args: Array<out String>
|
||||
): Boolean {
|
||||
if (!allowed(sender)) {
|
||||
sender.sendMessage(NO_DIAG_PERM)
|
||||
return false
|
||||
}
|
||||
|
||||
val stb = StringBuilder("```\n")
|
||||
try {
|
||||
diagnostic(stb)
|
||||
} catch(e: Exception){
|
||||
// TODO append error message to diag
|
||||
TODO("error not handled yet $e")
|
||||
}
|
||||
|
||||
stb.append("\n```")
|
||||
|
||||
if (sender is HumanEntity) {
|
||||
val message = TextComponent(ChatColor.GREEN.toString() + "Click to copy diagnostic data")
|
||||
|
||||
message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString())
|
||||
message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy"))
|
||||
|
||||
sender.spigot().sendMessage(message);
|
||||
} else {
|
||||
sender.sendMessage(stb.toString());
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun allowed(sender: CommandSender): Boolean {
|
||||
return sender.hasPermission(CustomAnvil.diagnosticPermission)
|
||||
}
|
||||
|
||||
fun diagnostic(stb: StringBuilder){
|
||||
stb.append("Server Info\n");
|
||||
stb.append("Plugin Version: ").append(CustomAnvil.instance.description.version).append("\n");
|
||||
stb.append("Server Version: ").append(Bukkit.getVersion()).append(" (").append(Bukkit.getName()).append(')').append("\n");
|
||||
stb.append("Plugin Enabled: ").append(if(CustomAnvil.instance.isEnabled) "Yes" else "No").append("\n");
|
||||
//stb.append("NMS type: ").append(NMSMapper.hasNMS() ? "Yes" : "No").append("\n");
|
||||
stb.append("Java Version: ").append(System.getProperty("java.version")).append("\n");
|
||||
stb.append("OS: ").append(System.getProperty("os.name")).append(" ")
|
||||
.append(System.getProperty("os.version"))
|
||||
.append(System.getProperty("os.arch"))
|
||||
.append("\n\n");
|
||||
stb.append("Architecture: ").append(System.getProperty("os.arch")).append("\n\n");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ permissions:
|
|||
ca.command.reload:
|
||||
default: op
|
||||
description: Allow administrator to reload the plugin's configs
|
||||
ca.command.debug:
|
||||
ca.command.diagnostic:
|
||||
default: op
|
||||
description: Get debug information about the plugin and server
|
||||
ca.config.edit:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ libraries:
|
|||
- org.jetbrains.kotlin:kotlin-stdlib:2.0.21
|
||||
|
||||
commands:
|
||||
customanvil:
|
||||
description: Generic command for custom anvil
|
||||
anvilconfigreload:
|
||||
description: Reload every config of this plugin
|
||||
permission: ca.command.reload
|
||||
|
|
@ -37,6 +39,9 @@ permissions:
|
|||
ca.command.reload:
|
||||
default: op
|
||||
description: Allow administrator to reload the plugin's configs
|
||||
ca.command.diagnostic:
|
||||
default: op
|
||||
description: Get debug information about the plugin and server
|
||||
ca.config.edit:
|
||||
default: op
|
||||
description: Allow administrator to edit the plugin's config in game
|
||||
|
|
@ -55,8 +60,7 @@ permissions:
|
|||
default: op
|
||||
description: Allow player to edit lore via paper if enabled (toggleable)
|
||||
|
||||
|
||||
# soft depend on old name (UnsafeEnchantsPlus), so I can disable it if it is on the same server (old name for this plugin)
|
||||
# soft depend on old name of this plugin (UnsafeEnchantsPlus), so I can disable it if it is on the same server
|
||||
# Also depend to other plugin for compatibility
|
||||
softdepend:
|
||||
- UnsafeEnchantsPlus
|
||||
|
|
@ -66,3 +70,4 @@ softdepend:
|
|||
- EcoEnchants
|
||||
- eco
|
||||
- ExcellentEnchants
|
||||
- HavenBags
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue