Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,6 +39,9 @@ dependencies {

// PlaceholderAPI
compileOnly("me.clip:placeholderapi:2.11.6")

// NickAPI
compileOnly(files("libs/nickapi-7.4.jar"))
}

val targetJavaVersion = 21
Expand All @@ -59,7 +64,6 @@ tasks {
}

shadowJar {
// relocate("fr.mrmicky.fastboard", "dev.edwnl.macSMPCore")
archiveFileName.set("MAC-SMP-Core.jar")
}
}
Expand Down
Binary file added libs/nickapi-7.4.jar
Binary file not shown.
55 changes: 55 additions & 0 deletions src/main/kotlin/dev/edwnl/macSMPCore/nick/NickCommand.kt
Original file line number Diff line number Diff line change
@@ -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<String>
): Boolean {
if (sender !is Player) return true

if (args.isEmpty()) {
sender.sendMessage(Component.text("/nick reset", NamedTextColor.YELLOW))
sender.sendMessage(Component.text("/nick <Name>", 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
}
}
59 changes: 59 additions & 0 deletions src/main/kotlin/dev/edwnl/macSMPCore/nick/WhoIsCommand.kt
Original file line number Diff line number Diff line change
@@ -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<String>
): Boolean {
if (args.isEmpty()) {
sender.sendMessage(
Component.text("/whois <player>")
.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
}
}
8 changes: 7 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ commands:
claimchest:
description: Claims items from the nearest death chest
usage: /claimchest
aliases: [cc]
aliases: [cc]
# nick:
# description: Change your nickname
# usage: /nick <name|reset>
# whois:
# description: Reveals the true identity of a nicked player
# usage: /whois <player>