MCPcopy Create free account
hub / github.com/Teneted/Tenet / VersionCommand

Class VersionCommand

src/main/java/org/bukkit/command/defaults/VersionCommand.java:28–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26import org.jetbrains.annotations.NotNull;
27
28public class VersionCommand extends BukkitCommand {
29 public VersionCommand(@NotNull String name) {
30 super(name);
31
32 this.description = "Gets the version of this server including any plugins in use";
33 this.usageMessage = "/version [plugin name]";
34 this.setPermission("bukkit.command.version");
35 this.setAliases(Arrays.asList("ver", "about"));
36 }
37
38 @Override
39 public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
40 if (!testPermission(sender)) return true;
41
42 if (args.length == 0) {
43 sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
44 //sendVersion(sender);
45 } else {
46 StringBuilder name = new StringBuilder();
47
48 for (String arg : args) {
49 if (name.length() > 0) {
50 name.append(' ');
51 }
52
53 name.append(arg);
54 }
55
56 String pluginName = name.toString();
57 Plugin exactPlugin = Bukkit.getPluginManager().getPlugin(pluginName);
58 if (exactPlugin != null) {
59 describeToSender(exactPlugin, sender);
60 return true;
61 }
62
63 boolean found = false;
64 pluginName = pluginName.toLowerCase(java.util.Locale.ENGLISH);
65 for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
66 if (plugin.getName().toLowerCase(java.util.Locale.ENGLISH).contains(pluginName)) {
67 describeToSender(plugin, sender);
68 found = true;
69 }
70 }
71
72 if (!found) {
73 sender.sendMessage("This server is not running any plugin by that name.");
74 sender.sendMessage("Use /plugins to get a list of plugins.");
75 }
76 }
77 return true;
78 }
79
80 private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
81 PluginDescriptionFile desc = plugin.getDescription();
82 sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
83
84 if (desc.getDescription() != null) {
85 sender.sendMessage(desc.getDescription());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected