mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Implemented the firstspawn command
This commit is contained in:
parent
c9eef4f174
commit
8ead129423
@ -219,6 +219,18 @@ public class CommandManager {
|
||||
authMeCommand);
|
||||
setSpawnCommand.setCommandPermissions("authme.admin.setspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
|
||||
// Register the firstspawn command
|
||||
CommandDescription firstSpawnCommand = new CommandDescription(
|
||||
new FirstSpawnCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("firstspawn");
|
||||
add("firsthome");
|
||||
}},
|
||||
"Teleport to first spawn",
|
||||
"Teleport to the first spawn.",
|
||||
authMeCommand);
|
||||
firstSpawnCommand.setCommandPermissions("authme.admin.firstspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
|
||||
// Register the setfirstspawn command
|
||||
CommandDescription setFirstSpawnCommand = new CommandDescription(
|
||||
new SetFirstSpawnCommand(),
|
||||
|
@ -0,0 +1,37 @@
|
||||
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 FirstSpawnCommand 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().getFirstSpawn() != null)
|
||||
((Player) sender).teleport(Spawn.getInstance().getFirstSpawn());
|
||||
else sender.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
||||
} 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