diff --git a/pom.xml b/pom.xml index 07c7f47..b10e324 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + worldedit + https://maven.enginehub.org/repo/ + @@ -26,5 +30,10 @@ 1.16.3-R0.1-SNAPSHOT provided + + com.sk89q.worldedit + worldedit-bukkit + 7.1.0 + \ No newline at end of file diff --git a/src/main/java/moe/sdg/PluginSDG/Commands/HubCommand.java b/src/main/java/moe/sdg/PluginSDG/Commands/HubCommand.java new file mode 100644 index 0000000..5bf9b92 --- /dev/null +++ b/src/main/java/moe/sdg/PluginSDG/Commands/HubCommand.java @@ -0,0 +1,32 @@ +package moe.sdg.PluginSDG.Commands; + +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +public class HubCommand implements CommandExecutor +{ + FileConfiguration config; + + public HubCommand(FileConfiguration config) + { + this.config = config; + } + + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) + { + if (commandSender instanceof Player) { + Player player = (Player)commandSender; + Location hub = config.getLocation("hub_pos"); + if (hub != null && hub.getWorld() != null) + player.teleport(hub); + else + player.sendMessage("No hub location set."); + return true; + } + return false; + } +} diff --git a/src/main/java/moe/sdg/PluginSDG/Commands/SetHubCommand.java b/src/main/java/moe/sdg/PluginSDG/Commands/SetHubCommand.java new file mode 100644 index 0000000..5037372 --- /dev/null +++ b/src/main/java/moe/sdg/PluginSDG/Commands/SetHubCommand.java @@ -0,0 +1,29 @@ +package moe.sdg.PluginSDG.Commands; + +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +public class SetHubCommand implements CommandExecutor +{ + FileConfiguration config; + + public SetHubCommand(FileConfiguration config) + { + this.config = config; + } + + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) + { + if (commandSender instanceof Player) { + Player player = (Player)commandSender; + config.set("hub_pos", player.getLocation()); + player.sendMessage("Hub location set to your position."); + return true; + } + return false; + } +} diff --git a/src/main/java/moe/sdg/PluginSDG/GameManager.java b/src/main/java/moe/sdg/PluginSDG/GameManager.java index a3721ef..facfaed 100644 --- a/src/main/java/moe/sdg/PluginSDG/GameManager.java +++ b/src/main/java/moe/sdg/PluginSDG/GameManager.java @@ -1,7 +1,10 @@ package moe.sdg.PluginSDG; +import moe.sdg.PluginSDG.Commands.HubCommand; +import moe.sdg.PluginSDG.Commands.SetHubCommand; import org.apache.commons.lang.NotImplementedException; import org.bukkit.Location; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; public class GameManager extends JavaPlugin @@ -9,7 +12,13 @@ public class GameManager extends JavaPlugin @Override public void onEnable() { - getLogger().info("Game manager loaded."); + FileConfiguration config = getConfig(); + config.addDefault("hub_pos", new Location(getServer().getWorld("hub"), 0, 0, 0)); + config.options().copyDefaults(true); + saveConfig(); + + getCommand("hub").setExecutor(new HubCommand(config)); + getCommand("sethub").setExecutor(new SetHubCommand(config)); } public Location getHubLocation() diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 817a23b..7b90cf8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,3 +1,10 @@ name: PluginSDG version: 1.0 -main: moe.sdg.PluginSDG.GameManager \ No newline at end of file +main: moe.sdg.PluginSDG.GameManager +commands: + hub: + description: Return to the hub + usage: / + sethub: + description: Set the hub location + usage: / \ No newline at end of file