Add Commands !players !exp name !death name
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user