diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java index 9bdd0916..e2fa19fc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java @@ -19,18 +19,12 @@ package de.steamwar.bausystem.features.autostart; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.LinkedInstance; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; @Linked(LinkageType.COMMAND) public class AutoStartCommand extends SWCommand { @@ -52,30 +46,4 @@ public class AutoStartCommand extends SWCommand { SWUtils.giveItemToPlayer(p, AutostartListener.WAND); } - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (!AutostartListener.WAND.isSimilar(event.getItem())) { - return; - } - if (event.getClickedBlock() == null) { - return; - } - Player player = event.getPlayer(); - Region region = Region.getRegion(event.getClickedBlock().getLocation()); - if (region.isGlobal()) { - player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return; - } - if (!region.hasType(RegionType.TESTBLOCK)) { - player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return; - } - if (autostartListener.getRegionStartTime().containsKey(region)) { - player.sendMessage(BauSystem.PREFIX + "§eDer AutostartTimer wurde zurückgesetzt"); - } else { - player.sendMessage(BauSystem.PREFIX + "§eAutostartTimer gestartet"); - } - autostartListener.getRegionStartTime().put(region, TPSUtils.currentTick.get()); - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index d21c9d19..0f58dfc0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -30,9 +30,11 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.inventory.SWItem; import lombok.Getter; 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; @@ -49,6 +51,32 @@ public class AutostartListener implements Listener { @Getter private Map regionStartTime = new HashMap<>(); + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + if (!AutostartListener.WAND.isSimilar(event.getItem())) { + return; + } + if (event.getClickedBlock() == null) { + return; + } + Player player = event.getPlayer(); + Region region = Region.getRegion(event.getClickedBlock().getLocation()); + if (region.isGlobal()) { + player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); + return; + } + if (!region.hasType(RegionType.TESTBLOCK)) { + 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 -> {