Implemented the spawn command

This commit is contained in:
Tim Visée 2015-11-01 18:19:36 +01:00
parent 4ff8cb8c59
commit c9eef4f174
2 changed files with 49 additions and 0 deletions

View File

@ -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 spawn command
CommandDescription spawnCommand = new CommandDescription(
new SpawnCommand(),
new ArrayList<String>() {{
add("spawn");
add("home");
}},
"Teleport to spawn",
"Teleport to the spawn.",
authMeCommand);
spawnCommand.setCommandPermissions("authme.admin.spawn", CommandPermissions.DefaultPermission.OP_ONLY);
// Register the setspawn command // Register the setspawn command
CommandDescription setSpawnCommand = new CommandDescription( CommandDescription setSpawnCommand = new CommandDescription(
new SetSpawnCommand(), new SetSpawnCommand(),

View File

@ -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 SpawnCommand 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().getSpawn() != null)
((Player) sender).teleport(Spawn.getInstance().getSpawn());
else sender.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
} catch (NullPointerException ex) {
ConsoleLogger.showError(ex.getMessage());
}
return true;
}
}