Fix AutoStartCommand and AutostartListener
Dieser Commit ist enthalten in:
Ursprung
f6a3fbd22e
Commit
1b14a8e554
@ -19,18 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.autostart;
|
package de.steamwar.bausystem.features.autostart;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.bausystem.linkage.LinkedInstance;
|
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 de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
public class AutoStartCommand extends SWCommand {
|
public class AutoStartCommand extends SWCommand {
|
||||||
@ -52,30 +46,4 @@ public class AutoStartCommand extends SWCommand {
|
|||||||
SWUtils.giveItemToPlayer(p, AutostartListener.WAND);
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,11 @@ import de.steamwar.bausystem.region.utils.RegionType;
|
|||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -49,6 +51,32 @@ public class AutostartListener implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
private Map<Region, Long> regionStartTime = new HashMap<>();
|
private Map<Region, Long> 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
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren