diff --git a/build.gradle.kts b/build.gradle.kts index e657ac3..1a94d18 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,9 @@ repositories { maven("https://oss.sonatype.org/content/groups/public/") { name = "sonatype" } - maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") } + maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") { + name = "placeholder-api" + } } dependencies { @@ -37,6 +39,9 @@ dependencies { // PlaceholderAPI compileOnly("me.clip:placeholderapi:2.11.6") + + // NickAPI + compileOnly(files("libs/nickapi-7.4.jar")) } val targetJavaVersion = 21 @@ -59,7 +64,6 @@ tasks { } shadowJar { -// relocate("fr.mrmicky.fastboard", "dev.edwnl.macSMPCore") archiveFileName.set("MAC-SMP-Core.jar") } } diff --git a/libs/nickapi-7.4.jar b/libs/nickapi-7.4.jar new file mode 100644 index 0000000..d6bd171 Binary files /dev/null and b/libs/nickapi-7.4.jar differ diff --git a/src/main/kotlin/dev/edwnl/macSMPCore/nick/NickCommand.kt b/src/main/kotlin/dev/edwnl/macSMPCore/nick/NickCommand.kt new file mode 100644 index 0000000..0f6f82e --- /dev/null +++ b/src/main/kotlin/dev/edwnl/macSMPCore/nick/NickCommand.kt @@ -0,0 +1,55 @@ +package dev.edwnl.macSMPCore.nick + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor +import org.bukkit.command.Command +import org.bukkit.command.CommandExecutor +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import xyz.haoshoku.nick.api.NickAPI + +// Disabled - NickAPI not compatible with 1.21.3 yet +class NickCommand : CommandExecutor { + override fun onCommand( + sender: CommandSender, + command: Command, + label: String, + args: Array + ): Boolean { + if (sender !is Player) return true + + if (args.isEmpty()) { + sender.sendMessage(Component.text("/nick reset", NamedTextColor.YELLOW)) + sender.sendMessage(Component.text("/nick ", NamedTextColor.YELLOW)) + return true + } + + when (args[0].lowercase()) { + "reset" -> { + NickAPI.resetNick(sender) + NickAPI.resetSkin(sender) + NickAPI.resetUniqueId(sender) + NickAPI.resetProfileName(sender) + NickAPI.refreshPlayer(sender) + sender.sendMessage( + Component.text("Successfully reset nick") + .color(NamedTextColor.GREEN) + ) + } + else -> { + val name = args[0] + NickAPI.setNick(sender, name) + NickAPI.setSkin(sender, name) + NickAPI.setUniqueId(sender, name) + NickAPI.setProfileName(sender, name) + NickAPI.refreshPlayer(sender) + sender.sendMessage( + Component.text("Successfully set the nickname to ") + .color(NamedTextColor.GREEN) + .append(Component.text(name).color(NamedTextColor.YELLOW)) + ) + } + } + return true + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/edwnl/macSMPCore/nick/WhoIsCommand.kt b/src/main/kotlin/dev/edwnl/macSMPCore/nick/WhoIsCommand.kt new file mode 100644 index 0000000..e26bc69 --- /dev/null +++ b/src/main/kotlin/dev/edwnl/macSMPCore/nick/WhoIsCommand.kt @@ -0,0 +1,59 @@ +package dev.edwnl.macSMPCore.nick + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor +import org.bukkit.Bukkit +import org.bukkit.command.Command +import org.bukkit.command.CommandExecutor +import org.bukkit.command.CommandSender +import xyz.haoshoku.nick.api.NickAPI + +// Disabled - NickAPI not compatible with 1.21.3 yet +class WhoisCommand : CommandExecutor { + override fun onCommand( + sender: CommandSender, + command: Command, + label: String, + args: Array + ): Boolean { + if (args.isEmpty()) { + sender.sendMessage( + Component.text("/whois ") + .color(NamedTextColor.YELLOW) + ) + return true + } + + val targetName = args[0] + val targetPlayer = Bukkit.getPlayer(targetName) + + if (targetPlayer == null) { + sender.sendMessage( + Component.text("Player not found") + .color(NamedTextColor.GREEN) + ) + return true + } + + if (!NickAPI.isNicked(targetPlayer)) { + sender.sendMessage( + Component.text("Player ") + .color(NamedTextColor.GREEN) + .append(Component.text(targetName).color(NamedTextColor.YELLOW)) + .append(Component.text(" is not nicked").color(NamedTextColor.GREEN)) + ) + return true + } + + val realName = NickAPI.getOriginalName(targetPlayer) + sender.sendMessage( + Component.text("Player ") + .color(NamedTextColor.GREEN) + .append(Component.text(targetName).color(NamedTextColor.YELLOW)) + .append(Component.text(" is actually ").color(NamedTextColor.GREEN)) + .append(Component.text(realName).color(NamedTextColor.YELLOW)) + ) + + return true + } +} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3f68613..cb50bea 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -8,4 +8,10 @@ commands: claimchest: description: Claims items from the nearest death chest usage: /claimchest - aliases: [cc] \ No newline at end of file + aliases: [cc] +# nick: +# description: Change your nickname +# usage: /nick +# whois: +# description: Reveals the true identity of a nicked player +# usage: /whois \ No newline at end of file