Implemented version command

This commit is contained in:
Tim Visée 2015-11-01 17:06:36 +01:00
parent 53a2e8f9f0
commit c30792f278
2 changed files with 83 additions and 4 deletions

View File

@ -220,7 +220,7 @@ public class CommandManager {
"Show detailed information about all the Dungeon Maze serivces.",
dungeonMazeCommand);
serviceCommand.setMaximumArguments(false);
serviceCommand.setCommandPermissions("dungeonmaze.command.services", CommandPermissions.DefaultPermission.OP_ONLY);
serviceCommand.setCommandPermissions("dungeonmaze.command.services", CommandPermissions.DefaultPermission.OP_ONLY);*/
// Register the version command
CommandDescription versionCommand = new CommandDescription(
@ -233,9 +233,9 @@ public class CommandManager {
add("info");
}},
"Version info",
"Show detailed information about the installed Dungeon Maze version, and shows the developers, contributors, license and other information.",
dungeonMazeCommand);
versionCommand.setMaximumArguments(false);*/
"Show detailed information about the installed AuthMeReloaded version, and shows the developers, contributors, license and other information.",
authMeCommand);
versionCommand.setMaximumArguments(false);
// Add the base commands to the commands array
this.commandDescriptions.add(authMeCommand);

View File

@ -0,0 +1,79 @@
package fr.xephi.authme.command.executable;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class VersionCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.PLUGIN_NAME.toUpperCase() + " ABOUT ]==========");
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.PLUGIN_NAME + " v" + AuthMe.getVersionName() + ChatColor.GRAY + " (code: " + AuthMe.getVersionCode() + ")");
sender.sendMessage(ChatColor.GOLD + "Developers:");
printDeveloper(sender, "Xephi", "xephi", "Lead Developer");
printDeveloper(sender, "Sgdc3", "sgdc3", "Code Contributor");
printDeveloper(sender, "Tim Visee", "timvisee", "Code Contributor");
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.WHITE + "http://dev.bukkit.org/bukkit-plugins/authme-reloaded/");
sender.sendMessage(ChatColor.GOLD + "License: " + ChatColor.WHITE + "GNU GPL v3.0" + ChatColor.GRAY + ChatColor.ITALIC + " (See LICENSE file)");
sender.sendMessage(ChatColor.GOLD + "Copyright: " + ChatColor.WHITE + "Copyright (c) Xephi 2015. All rights reserved.");
return true;
}
/**
* Print a developer with proper styling.
*
* @param sender The command sender.
* @param name The display name of the developer.
* @param minecraftName The Minecraft username of the developer, if available.
* @param function The function of the developer.
*/
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
private void printDeveloper(CommandSender sender, String name, String minecraftName, String function) {
// Print the name
StringBuilder msg = new StringBuilder();
msg.append(" " + ChatColor.WHITE);
msg.append(name);
// Append the Minecraft name, if available
if(minecraftName.length() != 0)
msg.append(ChatColor.GRAY + " // " + ChatColor.WHITE + minecraftName);
msg.append(ChatColor.GRAY + "" + ChatColor.ITALIC + " (" + function + ")");
// Show the online status
if(minecraftName.length() != 0)
if(isPlayerOnline(minecraftName))
msg.append(ChatColor.GREEN + "" + ChatColor.ITALIC + " (In-Game)");
// Print the message
sender.sendMessage(msg.toString());
}
/**
* Check whether a player is online.
*
* @param minecraftName The Minecraft player name.
*
* @return True if the player is online, false otherwise.
*/
private boolean isPlayerOnline(String minecraftName) {
for(Player player : Bukkit.getOnlinePlayers())
if(player.getName().equalsIgnoreCase(minecraftName))
return true;
return false;
}
}