0.1.3: switch to paper & textcomponents
This commit is contained in:
@@ -9,12 +9,13 @@ base.archivesName = project.extra["plugin_base_name"] as String
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
name = "papermc"
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot-api:1.21.10-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.25.0")
|
||||
}
|
||||
|
||||
@@ -23,3 +24,11 @@ java {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
// Explicitly specify a Mojang-mapped server, see PaperMC docs
|
||||
// https://docs.papermc.io/paper/dev/project-setup/#mojang-mappings
|
||||
tasks.jar {
|
||||
manifest {
|
||||
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,6 @@ org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# Plugin
|
||||
plugin_version=0.1.2
|
||||
plugin_version=0.1.3
|
||||
plugin_group=xyz.twokilohertz
|
||||
plugin_base_name=playerlistdeathcount
|
||||
|
||||
# Spigot
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PlayerListDeathCount extends JavaPlugin {
|
||||
HandlerList.unregisterAll(playerEventListener);
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
player.setPlayerListName(null);
|
||||
player.playerListName(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package xyz.twokilohertz.playerlistdeathcount.listeners;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -25,7 +28,11 @@ public class PlayerEventListener implements Listener {
|
||||
}
|
||||
|
||||
private void updatePlayerDeathCount(Player player) {
|
||||
int deaths = player.getStatistic(Statistic.DEATHS);
|
||||
player.setPlayerListName(player.getName() + " (" + Integer.toString(deaths) + ((deaths == 1) ? " death)" : " deaths)"));
|
||||
int numDeaths = player.getStatistic(Statistic.DEATHS);
|
||||
String deathsString = (numDeaths == 1) ? "death" : "deaths";
|
||||
|
||||
TextComponent newName =
|
||||
Component.text(player.getName()).append(Component.text(" (" + numDeaths + " " + deathsString + ")", NamedTextColor.GRAY));
|
||||
player.playerListName(newName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: PlayerListDeathCount
|
||||
version: 0.1.2
|
||||
version: 0.1.3
|
||||
description: Show the number of deaths players have in the server online player list
|
||||
author: twokilohertz
|
||||
website: https://git.2khz.xyz/adam/PlayerListDeathCount
|
||||
|
||||
Reference in New Issue
Block a user