diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
index 829132c..e50e4ee 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
@@ -95,6 +95,7 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandWorldSpawn();
new CommandRegion();
new CommandSelect();
+ new CommandAutostartTimer();
VersionedRunnable.call(new VersionedRunnable(() -> {
if (Region.buildAreaEnabled()) {
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandAutostartTimer.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandAutostartTimer.java
new file mode 100644
index 0000000..6c5a1dd
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandAutostartTimer.java
@@ -0,0 +1,106 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.bausystem.commands;
+
+import de.steamwar.bausystem.BauSystem;
+import de.steamwar.bausystem.SWUtils;
+import de.steamwar.bausystem.world.TPSUtils;
+import de.steamwar.bausystem.world.regions.GlobalRegion;
+import de.steamwar.bausystem.world.regions.Region;
+import de.steamwar.bausystem.world.regions.RegionExtensionType;
+import de.steamwar.bausystem.world.regions.RegionType;
+import de.steamwar.command.SWCommand;
+import de.steamwar.inventory.SWItem;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.ItemStack;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CommandAutostartTimer extends SWCommand implements Listener {
+
+ public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eAutostartTimer", Arrays.asList("§eRechtsklick Block §8- §7Starte den Timer"), false, null).getItemStack();
+
+ private Map regionStartTime = new HashMap<>();
+
+ public CommandAutostartTimer() {
+ super("timer", "autostarttimer", "at");
+ Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
+ }
+
+ @Register(help = true)
+ public void genericHelp(Player p, String... args) {
+ p.sendMessage("§8/§etimer §8- §7Legt den AutostartTimer ins Inventar");
+ }
+
+ @Register
+ public void genericCommand(Player p) {
+ SWUtils.giveItemToPlayer(p, WAND);
+ }
+
+ @EventHandler
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (!WAND.isSimilar(event.getItem())) {
+ return;
+ }
+ if (event.getClickedBlock() == null) {
+ return;
+ }
+ Player player = event.getPlayer();
+ Region region = Region.getRegion(event.getClickedBlock().getLocation());
+ if (GlobalRegion.isGlobalRegion(region)) {
+ player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
+ return;
+ }
+ if (!region.hasTestblock()) {
+ player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
+ return;
+ }
+ if (regionStartTime.containsKey(region)) {
+ player.sendMessage(BauSystem.PREFIX + "§eDer AutostartTimer wurde zurückgesetzt");
+ } else {
+ player.sendMessage(BauSystem.PREFIX + "§eAutostartTimer gestartet");
+ }
+ regionStartTime.put(region, TPSUtils.currentTick.get());
+ }
+
+ @EventHandler
+ public void onEntityExplode(EntityExplodeEvent event) {
+ event.blockList().forEach(block -> {
+ Region region = Region.getRegion(block.getLocation());
+ if (!regionStartTime.containsKey(region)) return;
+ if (!region.hasTestblock()) return;
+ if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
+ long tickDiff = TPSUtils.currentTick.get() - regionStartTime.remove(region);
+ RegionUtils.message(region, BauSystem.PREFIX + "§eZeit §7bis zur §eExplosion §7am Gegner§8:§e " + new SimpleDateFormat("mm:ss SSSS").format(new Date(tickDiff * 50)));
+ RegionUtils.message(region, BauSystem.PREFIX + "§eZeitdifferenz in ticks §7bis 60 Sekunden§8:§e " + (1200 - tickDiff));
+ RegionUtils.message(region, BauSystem.PREFIX + "§7Positiv, wenn zu wenig, negativ wenn zu viel");
+ });
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
index 8247efa..cc87d7e 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
@@ -20,10 +20,8 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
-import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.world.RedstoneListener;
-import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player;
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
index 1d9dc60..2a9774c 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
@@ -39,4 +39,12 @@ public class RegionUtils {
}
}
+ public static void message(Region region, String s) {
+ if (GlobalRegion.isGlobalRegion(region)) {
+ Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.sendMessage(s));
+ } else {
+ Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.sendMessage(s));
+ }
+ }
+
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java
index c52f4f7..14ae255 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java
@@ -20,7 +20,6 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
-import de.steamwar.bausystem.Permission;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;