mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Implemented getip command
This commit is contained in:
parent
c11ca35774
commit
14eb8e28cf
@ -225,6 +225,19 @@ public class CommandManager {
|
|||||||
setEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
setEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||||
setEmailCommand.addArgument(new CommandArgumentDescription("email", "Player email", false));
|
setEmailCommand.addArgument(new CommandArgumentDescription("email", "Player email", false));
|
||||||
|
|
||||||
|
// Register the getip command
|
||||||
|
CommandDescription getIpCommand = new CommandDescription(
|
||||||
|
new GetIpCommand(),
|
||||||
|
new ArrayList<String>() {{
|
||||||
|
add("getip");
|
||||||
|
add("ip");
|
||||||
|
}},
|
||||||
|
"Get player's IP",
|
||||||
|
"Get the IP address of the specified online player.",
|
||||||
|
authMeCommand);
|
||||||
|
getIpCommand.setCommandPermissions("authme.admin.getip", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", false));
|
||||||
|
|
||||||
// Register the spawn command
|
// Register the spawn command
|
||||||
CommandDescription spawnCommand = new CommandDescription(
|
CommandDescription spawnCommand = new CommandDescription(
|
||||||
new SpawnCommand(),
|
new SpawnCommand(),
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.command.CommandParts;
|
||||||
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class GetIpCommand 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) {
|
||||||
|
// AuthMe plugin instance
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
|
// Get the player query
|
||||||
|
String playerName = sender.getName();
|
||||||
|
if(commandArguments.getCount() >= 1)
|
||||||
|
playerName = commandArguments.get(0);
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage("This player is not actually online");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
|
||||||
|
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user