Add SpawnCommand.java
This commit is contained in:
parent
1669a114bc
commit
d2e4591c21
|
|
@ -57,6 +57,7 @@ public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI {
|
||||||
getCommand("heal").setExecutor(new HealCommand(this));
|
getCommand("heal").setExecutor(new HealCommand(this));
|
||||||
getCommand("feed").setExecutor(new FeedCommand(this));
|
getCommand("feed").setExecutor(new FeedCommand(this));
|
||||||
getCommand("enchant").setExecutor(new EnchantCommand(this));
|
getCommand("enchant").setExecutor(new EnchantCommand(this));
|
||||||
|
getCommand("spawn").setExecutor(new SpawnCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadEventListeners() {
|
public void loadEventListeners() {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -115,11 +115,13 @@ public class Config {
|
||||||
public static Sound SOUND_FROM;
|
public static Sound SOUND_FROM;
|
||||||
public static int BACK_COOLDOWN = 60;
|
public static int BACK_COOLDOWN = 60;
|
||||||
public static boolean UNSAFE_ENCHANTMENTS = false;
|
public static boolean UNSAFE_ENCHANTMENTS = false;
|
||||||
|
public static String SPAWN_WORLD = "Skyblock";
|
||||||
private static void settings() {
|
private static void settings() {
|
||||||
TELEPORT_REQUEST_TIMEOUT = getInt("teleport-request-timeout", TELEPORT_REQUEST_TIMEOUT);
|
TELEPORT_REQUEST_TIMEOUT = getInt("teleport-request-timeout", TELEPORT_REQUEST_TIMEOUT);
|
||||||
TELEPORT_REQUEST_TIMEOUT_MESSAGES = getBoolean("teleport-request-timeout-message", TELEPORT_REQUEST_TIMEOUT_MESSAGES);
|
TELEPORT_REQUEST_TIMEOUT_MESSAGES = getBoolean("teleport-request-timeout-message", TELEPORT_REQUEST_TIMEOUT_MESSAGES);
|
||||||
BACK_ON_DEATH = getBoolean("back-on-death", BACK_ON_DEATH);
|
BACK_ON_DEATH = getBoolean("back-on-death", BACK_ON_DEATH);
|
||||||
TELEPORT_SOUNDS = getBoolean("use-teleport-sounds", TELEPORT_SOUNDS);
|
TELEPORT_SOUNDS = getBoolean("use-teleport-sounds", TELEPORT_SOUNDS);
|
||||||
|
SPAWN_WORLD = getString("use-teleport-sounds", SPAWN_WORLD);
|
||||||
try {
|
try {
|
||||||
SOUND_TO = Sound.valueOf(config.getString("sound-to", "ENTITY_ENDERMAN_TELEPORT"));
|
SOUND_TO = Sound.valueOf(config.getString("sound-to", "ENTITY_ENDERMAN_TELEPORT"));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
|
||||||
|
|
@ -103,4 +103,8 @@ commands:
|
||||||
enchant:
|
enchant:
|
||||||
description: Enchants the item in hand
|
description: Enchants the item in hand
|
||||||
permission: essentia.command.enchant
|
permission: essentia.command.enchant
|
||||||
usage: /<command> [enchantment/all] (level) (unsafe)
|
usage: /<command> [enchantment/all] (level) (unsafe)
|
||||||
|
spawn:
|
||||||
|
description: Teleport yourself or another player to spawn.
|
||||||
|
permission: essentia.command.spawn
|
||||||
|
usage: /<command>
|
||||||
Loading…
Reference in New Issue
Block a user