Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Minecraft rank system kotlin display rank befor username

$
0
0

I'm doing a rank system for Minecraft in kotlin. Now I would like to display the rank in front of the player name in the tabluator and in chat messages

Chat example:[Owner] Fabboy: Hello world[User] Player: Hey Fabboy

Does anyone know how I do it?(The ranks are saved in the config, Minecraft 1.17.1, Java 16)

I am not a professional in programming with Kotlin so I would be very grateful for a detailed answer

The code:

package dev.fabboy.borkimport net.kyori.adventure.text.Componentimport net.kyori.adventure.text.TextComponentimport org.bukkit.Bukkitimport org.bukkit.entity.Playerimport org.bukkit.event.EventHandlerimport org.bukkit.event.Listenerimport org.bukkit.event.player.PlayerJoinEventimport org.bukkit.plugin.java.JavaPluginimport org.bukkit.scoreboard.DisplaySlotconst val version = "0.1"//lateinit var INSTANCE: Borkclass Bork : JavaPlugin(), Listener {    override fun onEnable() {        INSTANCE = this        println("----------\n[Bork] Plugin loaded \nVersion: $version\nVersion from: 2021-09-07\n${(System.currentTimeMillis())}\n----------")        server.pluginManager.registerEvents(this, this)        getCommand("broadcast")?.setExecutor(Broadcast())        getCommand("setrank")?.setExecutor(setrank())        getCommand("rank")?.setExecutor(rank())    }    override fun onDisable() {        Bukkit.getConsoleSender().sendMessage("[Bork] Plugin Disabled")    }    @EventHandler    fun onJoin(joinEvent: PlayerJoinEvent) {        val player = joinEvent.player        var j = this.config.get("Bork.${player.uniqueId}.joins", 0) as Int        var r = this.config.get("Bork.${player.uniqueId}.rank", 1) as Int        j += 1        var ranker = ""        if(r == 1){            ranker = "§3User"        }        if(r == 2){            ranker = "§dVIP"        }        if(r == 3){            ranker = "§6Admin"        }        if(r == 4){            ranker = "§cOwner"        }        player.sendMessage("§e-------------§r§lPrivate§r§e--------------§r\n§lWelcome§r\n${(player.displayName() as TextComponent).content()}\nThis is your: §e§l$j Join§r\nYour Rank: $ranker §r\n§e----------------------------------§r\nRanks:\n1. §3User§r\n2. §dVIP§r\n3. §6Admin§r\n4. §cOwner§r\n§e-------------§r§lPrivate§r§e--------------")        this.config.set("Bork.${player.uniqueId}.joins", j)        this.config.set("Bork.${player.uniqueId}.rank", r)        this.saveConfig()    }}

Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>