Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
add PlaceholderAPI support - player profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbit4 committed Sep 12, 2022
1 parent 9d83104 commit d2e8c25
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/pl/norbit/discordmc/bot/commands/ProfileCommand.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package pl.norbit.discordmc.bot.commands

import me.clip.placeholderapi.PlaceholderAPI
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
import pl.norbit.discordmc.bot.embed.Embed
import pl.norbit.discordmc.db.PluginDBManager
import pl.norbit.discordmc.server.config.PluginConfig
Expand Down Expand Up @@ -44,7 +46,7 @@ class ProfileCommand: ListenerAdapter() {

val builder = Embed.getProfileMessage(userName, mcName);
val replacements: HashMap<String, String> = HashMap()
var status = ""
val status: String
val replacementsOnline = arrayOf("{X}", "{Y}", "{Z}", "{WORLD}")

//checks player online status
Expand Down Expand Up @@ -83,7 +85,22 @@ class ProfileCommand: ListenerAdapter() {
if(line == "{EMPTY_LINE}"){
builder?.addBlankField(false)
}else{
val lineArgs = line.split("//")

val formattedPlaceholder: String = if(PluginConfig.PLACEHOLDER_API_EXIST) {
if (p != null) {

PlaceholderAPI.setPlaceholders(p, line)
} else {

val offlineP: OfflinePlayer? = databaseRecord.player

PlaceholderAPI.setPlaceholders(offlineP, line)
}
}else{
line;
}

val lineArgs = formattedPlaceholder.split("//")
if (lineArgs.size > 1) {
var arg1 = lineArgs[0]
var arg2 = lineArgs[1]
Expand Down

0 comments on commit d2e8c25

Please sign in to comment.