mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-26 01:21:27 +01:00
Implemented the forcelogin command
This commit is contained in:
parent
14eb8e28cf
commit
afd46edb39
@ -236,7 +236,20 @@ public class CommandManager {
|
|||||||
"Get the IP address of the specified online player.",
|
"Get the IP address of the specified online player.",
|
||||||
authMeCommand);
|
authMeCommand);
|
||||||
getIpCommand.setCommandPermissions("authme.admin.getip", CommandPermissions.DefaultPermission.OP_ONLY);
|
getIpCommand.setCommandPermissions("authme.admin.getip", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", false));
|
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
||||||
|
|
||||||
|
// Register the forcelogin command
|
||||||
|
CommandDescription forceLoginCommand = new CommandDescription(
|
||||||
|
new ForceLoginCommand(),
|
||||||
|
new ArrayList<String>() {{
|
||||||
|
add("forcelogin");
|
||||||
|
add("login");
|
||||||
|
}},
|
||||||
|
"Force login player",
|
||||||
|
"Force the specified player to login.",
|
||||||
|
authMeCommand);
|
||||||
|
forceLoginCommand.setCommandPermissions("authme.admin.forcelogin", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
forceLoginCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
||||||
|
|
||||||
// Register the spawn command
|
// Register the spawn command
|
||||||
CommandDescription spawnCommand = new CommandDescription(
|
CommandDescription spawnCommand = new CommandDescription(
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
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 ForceLoginCommand 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);
|
||||||
|
|
||||||
|
// Command logic
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
|
if (player == null || !player.isOnline()) {
|
||||||
|
sender.sendMessage("Player needs to be online!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!plugin.authmePermissible(player, "authme.canbeforced")) {
|
||||||
|
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plugin.management.performLogin(player, "dontneed", true);
|
||||||
|
sender.sendMessage("Force Login for " + playerName + " performed!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage("An error occurred while trying to get that player!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user