mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 14:13:35 +01:00
Implemented the setspawn command
This commit is contained in:
parent
bc0f1b4bb9
commit
79dd26da0f
@ -195,6 +195,18 @@ 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 setspawn command
|
||||||
|
CommandDescription setSpawnCommand = new CommandDescription(
|
||||||
|
new SetSpawnCommand(),
|
||||||
|
new ArrayList<String>() {{
|
||||||
|
add("setspawn");
|
||||||
|
add("chgspawn");
|
||||||
|
}},
|
||||||
|
"Change the spawn",
|
||||||
|
"Change the player's spawn to your current position.",
|
||||||
|
authMeCommand);
|
||||||
|
setSpawnCommand.setCommandPermissions("authme.admin.setspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the purge command
|
// Register the purge command
|
||||||
CommandDescription purgeCommand = new CommandDescription(
|
CommandDescription purgeCommand = new CommandDescription(
|
||||||
new PurgeCommand(),
|
new PurgeCommand(),
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
|
import fr.xephi.authme.command.CommandParts;
|
||||||
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
|
import fr.xephi.authme.settings.Spawn;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SetSpawnCommand 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) {
|
||||||
|
// Make sure the command executor is a player
|
||||||
|
try {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
if (Spawn.getInstance().setSpawn(((Player) sender).getLocation())) {
|
||||||
|
sender.sendMessage("[AuthMe] Correctly defined new spawn point");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("[AuthMe] SetSpawn has failed, please retry");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("[AuthMe] Please use that command in game");
|
||||||
|
}
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user