Add SpawnCommand.java
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.alttd.essentia.commands.player;
|
||||
|
||||
import com.alttd.essentia.EssentiaPlugin;
|
||||
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||
import com.alttd.essentia.configuration.Config;
|
||||
import com.alttd.essentia.configuration.PlayerConfig;
|
||||
import com.alttd.essentia.tasks.TeleportSounds;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpawnCommand extends PlayerSubCommand {
|
||||
|
||||
public SpawnCommand(EssentiaPlugin plugin) {
|
||||
super(plugin, "back");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, PlayerConfig playerConfig, String... args) {
|
||||
World world = plugin.getServer().getWorld(Config.SPAWN_WORLD);
|
||||
if (world == null) {
|
||||
player.sendRichMessage("<red>Could not get the configured spawn world! contact and administrator");
|
||||
return true;
|
||||
}
|
||||
Location spawnLocation = world.getSpawnLocation();
|
||||
new TeleportSounds(spawnLocation, player.getLocation())
|
||||
.runTaskLater(plugin, 1);
|
||||
|
||||
player.teleportAsync(spawnLocation).thenAccept(result ->
|
||||
player.sendRichMessage("Teleporting to spawn"));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user