Add SpawnCommand.java

This commit is contained in:
Len
2024-02-05 15:00:37 +01:00
parent 1669a114bc
commit d2e4591c21
4 changed files with 42 additions and 1 deletions
@@ -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;
}
}