Add Commands !players !exp name !death name
This commit is contained in:
@@ -6,5 +6,12 @@ author: Bryce
|
|||||||
api-version: 1.20.4
|
api-version: 1.20.4
|
||||||
commands:
|
commands:
|
||||||
players:
|
players:
|
||||||
description: Command description here
|
description: displays the list of players logged on to the server
|
||||||
usage: /players
|
usage: /players
|
||||||
|
exp:
|
||||||
|
description: update & show the exp counter (OBS)
|
||||||
|
usage: /exp <player>
|
||||||
|
death:
|
||||||
|
description: update Death counter and post in chat [player has died [x] times]
|
||||||
|
usage: /death <player>
|
||||||
|
|
@@ -6,6 +6,9 @@ import java.net.ServerSocket;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class MCbot extends JavaPlugin {
|
public class MCbot extends JavaPlugin {
|
||||||
@@ -79,6 +82,34 @@ public class MCbot extends JavaPlugin {
|
|||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
return "Players online: " + playerList;
|
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
|
// Add more command processing logic as needed
|
||||||
return "Unknown command: " + command;
|
return "Unknown command: " + command;
|
||||||
|
Reference in New Issue
Block a user