diff --git a/MCbot.yml b/MCbot.yml index 073dadc..06cd2e8 100644 --- a/MCbot.yml +++ b/MCbot.yml @@ -6,5 +6,12 @@ author: Bryce api-version: 1.20.4 commands: players: - description: Command description here + description: displays the list of players logged on to the server usage: /players + exp: + description: update & show the exp counter (OBS) + usage: /exp + death: + description: update Death counter and post in chat [player has died [x] times] + usage: /death + \ No newline at end of file diff --git a/src/MCbot.java b/src/MCbot.java index 9c30397..c3cf817 100644 --- a/src/MCbot.java +++ b/src/MCbot.java @@ -6,6 +6,9 @@ import java.net.ServerSocket; import java.net.Socket; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.Statistic; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class MCbot extends JavaPlugin { @@ -79,7 +82,35 @@ public class MCbot extends JavaPlugin { .collect(Collectors.toList())); return "Players online: " + playerList; } - + if (command.startsWith("!exp ")) { + // Extract player name from command + String playerName = command.substring(5); // Assuming "!exp " is 5 characters long + + // Get player object by name + Player player = Bukkit.getPlayer(playerName); + if (player != null) { + // Get player's experience level + int expLevel = player.getLevel(); + return playerName + "'s experience level: " + expLevel; + } else { + return "Player not found: " + playerName; + } + } + if (command.startsWith("!deaths ")) { + //Extract player name from command + String playerName = command.substring(8); // Assuming "!deaths " is at least 8 chars long + + // Get Player object by name + Player player = Bukkit.getPlayer(playerName); + if(player != null) { + // Get Player's Death Count + int deaths = player.getStatistic(Statistic.DEATHS); + return playerName + "has died" + deaths + "times"; + }else { + return "Player not found: " + playerName; + } + } + // Add more command processing logic as needed return "Unknown command: " + command; }