diff --git a/pom.xml b/pom.xml
index da6c51e..2a7c8ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
de.fanta.challenges
ChallengesJoinEntities
- 1.18-DEV
+ 1.18.2
UTF-8
UTF-8
@@ -27,7 +27,7 @@
io.papermc.paper
paper-api
- 1.18-R0.1-SNAPSHOT
+ 1.18.2-R0.1-SNAPSHOT
provided
@@ -45,7 +45,7 @@
de.fanta.challenges
Challenges
- 1.18.1-DEV
+ 1.18.2
provided
@@ -66,12 +66,6 @@
provided
- de.cubeside.nmsutils
- nmsutils-v1_17_R1_1
- 0.0.1-SNAPSHOT
- provided
-
-
net.citizensnpcs
citizens-main
2.0.29-SNAPSHOT
@@ -118,15 +112,7 @@
maven-compiler-plugin
3.8.1
- 16
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 16
- 16
+ 17
diff --git a/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java b/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
index 1a1d701..f17d4fe 100644
--- a/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
+++ b/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
@@ -14,6 +14,7 @@
import de.fanta.challengesjoinentities.commands.PiglinCommand.Entitytphere;
import de.fanta.challengesjoinentities.commands.PiglinCommand.ListPiglinCommand;
import de.fanta.challengesjoinentities.commands.PiglinCommand.RemoveEntityCommand;
+import de.fanta.challengesjoinentities.commands.PiglinCommand.SetEntitySpawnLocationCommand;
import de.fanta.challengesjoinentities.commands.PiglinCommand.ToggleArenaCommand;
import de.fanta.challengesjoinentities.listeners.ChallengesEventListener;
import de.fanta.challengesjoinentities.listeners.EntityListener;
@@ -89,6 +90,7 @@
router.addCommandMapping(new RemoveEntityCommand(this), "remove");
router.addCommandMapping(new Entitytphere(this), "tphere");
router.addCommandMapping(new ListPiglinCommand(this), "list");
+ router.addCommandMapping(new SetEntitySpawnLocationCommand(this), "setlocation");
router.addCommandMapping(new ToggleArenaCommand(this, true), "enable");
router.addCommandMapping(new ToggleArenaCommand(this, false), "disable");
diff --git a/src/main/java/de/fanta/challengesjoinentities/Config.java b/src/main/java/de/fanta/challengesjoinentities/Config.java
index 2177dbf..3459847 100644
--- a/src/main/java/de/fanta/challengesjoinentities/Config.java
+++ b/src/main/java/de/fanta/challengesjoinentities/Config.java
@@ -13,14 +13,14 @@
public class Config {
- private final ChallengesJoinEntities plugin;
- private final Set challengeServers;
- private final Set adventureServers;
+ private static ChallengesJoinEntities plugin;
+ private static Set challengeServers;
+ private static Set adventureServers;
public Config(ChallengesJoinEntities plugin) {
- this.plugin = plugin;
- this.challengeServers = new HashSet<>();
- this.adventureServers = new HashSet<>();
+ Config.plugin = plugin;
+ challengeServers = new HashSet<>();
+ adventureServers = new HashSet<>();
if (Bukkit.getPluginManager().getPlugin("Challenges") == null) {
plugin.saveDefaultConfig();
@@ -28,7 +28,7 @@
}
}
- private void reloadConfig() {
+ public static void reloadConfig() {
plugin.reloadConfig();
FileConfiguration config = plugin.getConfig();
diff --git a/src/main/java/de/fanta/challengesjoinentities/commands/PiglinCommand/SetEntitySpawnLocationCommand.java b/src/main/java/de/fanta/challengesjoinentities/commands/PiglinCommand/SetEntitySpawnLocationCommand.java
new file mode 100644
index 0000000..6340d30
--- /dev/null
+++ b/src/main/java/de/fanta/challengesjoinentities/commands/PiglinCommand/SetEntitySpawnLocationCommand.java
@@ -0,0 +1,120 @@
+package de.fanta.challengesjoinentities.commands.PiglinCommand;
+
+import de.cubeside.connection.GlobalServer;
+import de.fanta.challengesjoinentities.ChallengesJoinEntities;
+import de.fanta.challengesjoinentities.ChatUtil;
+import de.fanta.challengesjoinentities.Config;
+import de.iani.cubesideutils.bukkit.commands.SubCommand;
+import de.iani.cubesideutils.commands.ArgsParser;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class SetEntitySpawnLocationCommand extends SubCommand {
+
+ private final ChallengesJoinEntities plugin;
+
+ public SetEntitySpawnLocationCommand(ChallengesJoinEntities plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) {
+ if (!(sender instanceof Player player)) {
+ ChatUtil.sendErrorMessage(sender, "You are not a Player :>");
+ return true;
+ }
+
+ if (!sender.hasPermission("challenges.spawn.teleporter")) {
+ ChatUtil.sendErrorMessage(sender, "Keine Berechtigung!");
+ return true;
+ }
+
+ if (args.hasNext()) {
+ String serverType = args.getNext();
+ if (args.hasNext()) {
+ String serverName = args.getNext();
+ if (serverType.equalsIgnoreCase("challenge")) {
+ if (setServerLocation(serverType, serverName, player.getLocation())) {
+ ChatUtil.sendNormalMessage(sender, "Neue location für " + serverName + " gesetzt!");
+ } else {
+ ChatUtil.sendErrorMessage(sender, "Der server steht nicht in der Config.");
+ return true;
+ }
+ } else if (serverType.equalsIgnoreCase("adventure")) {
+ if (setServerLocation(serverType, serverName, player.getLocation())) {
+ ChatUtil.sendNormalMessage(sender, "Neue location für " + serverName + " gesetzt!");
+ } else {
+ ChatUtil.sendErrorMessage(sender, "Der server steht nicht in der Config.");
+ return true;
+ }
+ } else {
+ ChatUtil.sendErrorMessage(sender, "Der Servertyp muss Challenge oder Adventure sein.");
+ return true;
+ }
+ } else {
+ ChatUtil.sendErrorMessage(sender, "/piglin setentityspawnlocation ");
+ return true;
+ }
+ } else {
+ ChatUtil.sendErrorMessage(sender, "/piglin setentityspawnlocation ");
+ return true;
+ }
+ return true;
+ }
+
+ @Override
+ public Collection onTabComplete(CommandSender sender, Command command, String alias, ArgsParser args) {
+ String ServerType = args.getNext();
+ if (!args.hasNext()) {
+ return List.of("adventure", "challenge");
+ }
+ args.next();
+ if (!args.hasNext()) {
+ if (ServerType.equalsIgnoreCase("adventure")) {
+ return plugin.getConfig().getConfigurationSection(ServerType.toLowerCase()).getKeys(false);
+ } else if (ServerType.equalsIgnoreCase("challenge")) {
+ return plugin.getConfig().getConfigurationSection(ServerType.toLowerCase()).getKeys(false);
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public String getUsage() {
+ return " ";
+ }
+
+ @Override
+ public String getRequiredPermission() {
+ return "challenges.spawn.teleporter";
+ }
+
+ public boolean setServerLocation(String ServerType, String ServerName, Location location) {
+ if (plugin.getConfig().getString(ServerType + "." + ServerName) != null) {
+ World world = location.getWorld();
+ double x = location.getX();
+ double y = location.getY();
+ double z = location.getZ();
+ double yaw = location.getYaw();
+ plugin.getConfig().set(ServerType.toLowerCase() + "." + ServerName.toLowerCase() + ".location" + ".world", world.getName());
+ plugin.getConfig().set(ServerType.toLowerCase() + "." + ServerName.toLowerCase() + ".location" + ".x", x);
+ plugin.getConfig().set(ServerType.toLowerCase() + "." + ServerName.toLowerCase() + ".location" + ".y", y);
+ plugin.getConfig().set(ServerType.toLowerCase() + "." + ServerName.toLowerCase() + ".location" + ".z", z);
+ plugin.getConfig().set(ServerType.toLowerCase() + "." + ServerName.toLowerCase() + ".location" + ".yaw", yaw);
+ plugin.saveConfig();
+ Config.reloadConfig();
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+}