From 8aa2870549e1946537f0501d6e92c9a449caa726 Mon Sep 17 00:00:00 2001 From: Swofty Date: Wed, 17 Jan 2024 11:37:34 +1100 Subject: [PATCH] Added /whereami --- .../java/net/swofty/swm/plugin/SWMPlugin.java | 2 ++ .../subtypes/subCommand_setworldspawn.java | 3 +++ .../subtypes/subCommand_whereami.java | 24 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_whereami.java diff --git a/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/SWMPlugin.java b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/SWMPlugin.java index b986ce4..a4c6b44 100644 --- a/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/SWMPlugin.java +++ b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/SWMPlugin.java @@ -24,6 +24,7 @@ import ninja.leaping.configurate.objectmapping.ObjectMappingException; import org.bukkit.*; import org.bukkit.command.CommandMap; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; @@ -67,6 +68,7 @@ public void onLoad() { ex.printStackTrace(); return; } + LoaderUtils.registerLoaders(); /* diff --git a/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_setworldspawn.java b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_setworldspawn.java index b553421..8b88278 100644 --- a/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_setworldspawn.java +++ b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_setworldspawn.java @@ -13,6 +13,7 @@ import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.command.CommandSender; +import org.spigotmc.event.player.PlayerSpawnLocationEvent; import java.util.Collections; import java.util.LinkedList; @@ -36,6 +37,8 @@ public void run(CommandSource sender, String[] args) { worldData.setSpawn(sender.getPlayer().getLocation().getBlockX() + ", " + sender.getPlayer().getLocation().getBlockY() + ", " + sender.getPlayer().getLocation().getBlockZ()); config.save(); + world.setSpawnLocation(sender.getPlayer().getLocation().getBlockX(), sender.getPlayer().getLocation().getBlockY(), sender.getPlayer().getLocation().getBlockZ()); + sender.send(Logging.COMMAND_PREFIX + ChatColor.GREEN + "Set world spawn for world " + world.getName() + " to " + sender.getPlayer().getLocation().getBlockX() + ", " + sender.getPlayer().getLocation().getBlockY() + ", " + sender.getPlayer().getLocation().getBlockZ() + "!"); } diff --git a/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_whereami.java b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_whereami.java new file mode 100644 index 0000000..0bdffdc --- /dev/null +++ b/swoftyworldmanager-plugin/src/main/java/net/swofty/swm/plugin/commands/subtypes/subCommand_whereami.java @@ -0,0 +1,24 @@ +package net.swofty.swm.plugin.commands.subtypes; + +import net.swofty.swm.plugin.commands.CommandParameters; +import net.swofty.swm.plugin.commands.CommandSource; +import net.swofty.swm.plugin.commands.SWMCommand; +import net.swofty.swm.plugin.log.Logging; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + +import java.util.List; + +@CommandParameters(description = "Prints to the player where they are", inGameOnly = true) +public class subCommand_whereami extends SWMCommand { + @Override + public void run(CommandSource sender, String[] args) { + sender.send(Logging.COMMAND_PREFIX + ChatColor.GRAY + " You are currently in " + + ChatColor.GREEN + sender.getPlayer().getWorld().getName() + ChatColor.GRAY + "!"); + } + + @Override + public List tabCompleters(CommandSender sender, String alias, String[] args) { + return null; + } +}