adding /spawn command

This commit is contained in:
Martin Olischläger 2023-04-28 18:38:28 +02:00
parent f9aec0fe58
commit 3de50d7557
2 changed files with 24 additions and 2 deletions

View File

@ -2,10 +2,12 @@ package eu.mhsl.craftattack.worldmuseum;
import eu.mhsl.craftattack.worldmuseum.commands.GamemodeCommand;
import eu.mhsl.craftattack.worldmuseum.commands.GcCommand;
import eu.mhsl.craftattack.worldmuseum.commands.SpawnCommand;
import eu.mhsl.craftattack.worldmuseum.commands.TeleportCommand;
import eu.mhsl.craftattack.worldmuseum.listener.*;
import eu.mhsl.craftattack.worldmuseum.skins.SkinCache;
import eu.mhsl.craftattack.worldmuseum.util.Config;
import eu.mhsl.craftattack.worldmuseum.util.SignHandler;
import eu.mhsl.craftattack.worldmuseum.worlds.World;
import eu.mhsl.craftattack.worldmuseum.worlds.WorldManager;
import eu.mhsl.craftattack.worldmuseum.items.CompassManager;
@ -24,9 +26,10 @@ public class Main {
public static void main(String[] args) {
// Initialization
System.setProperty("minestom.chunk-view-distance", "16");
System.setProperty("minestom.chunk-view-distance", "8");
MinecraftServer minecraftServer = MinecraftServer.init();
MinecraftServer.setChunkViewDistance(8);
// MinecraftServer.setChunkViewDistance(8);
//temp
MinecraftServer.getSchedulerManager().scheduleTask(new TablistUpdateTask(), TaskSchedule.tick(20), TaskSchedule.tick(20));
@ -55,11 +58,13 @@ public class Main {
globalEventHandler.addListener(PlayerBlockBreakEvent.class, new BlockBreakListener());
globalEventHandler.addListener(PlayerBlockPlaceEvent.class, new BlockPlaceListener());
globalEventHandler.addListener(PlayerMoveEvent.class, new MovementListener());
MinecraftServer.getBlockManager().registerHandler("minecraft:sign", SignHandler::new);
//commands
MinecraftServer.getCommandManager().register(new TeleportCommand());
MinecraftServer.getCommandManager().register(new GcCommand());
MinecraftServer.getCommandManager().register(new GamemodeCommand());
MinecraftServer.getCommandManager().register(new SpawnCommand());
globalEventHandler.addListener(PlayerLoginEvent.class, event -> {
final NewPlayer player = (NewPlayer) event.getPlayer();

View File

@ -0,0 +1,17 @@
package eu.mhsl.craftattack.worldmuseum.commands;
import eu.mhsl.craftattack.worldmuseum.worlds.World;
import net.minestom.server.command.builder.Command;
import net.minestom.server.entity.Player;
public class SpawnCommand extends Command {
public SpawnCommand() {
super("spawn");
setDefaultExecutor((sender, context) -> {
Player p = (Player) sender;
World world = (World) p.getInstance();
assert world != null;
p.teleport(world.getSpawn());
});
}
}