Add DetonatorCommand.toggleAutostartTimer
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
9503b91e58
Commit
e666ff0739
@ -47,6 +47,13 @@ import java.util.Map;
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class AutostartListener implements Listener {
|
||||
|
||||
@Getter
|
||||
public static AutostartListener instance;
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static ItemStack getWandItem(Player player) {
|
||||
ItemStack itemStack = new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("AUTOSTART_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("AUTOSTART_ITEM_LORE", player)), false, null).getItemStack();
|
||||
ItemUtils.setItem(itemStack, "autostart");
|
||||
@ -64,8 +71,11 @@ public class AutostartListener implements Listener {
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
Region region = Region.getRegion(event.getClickedBlock().getLocation());
|
||||
activate(event.getPlayer());
|
||||
}
|
||||
|
||||
public void activate(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO-REGION", player);
|
||||
return;
|
||||
|
@ -22,6 +22,8 @@ package de.steamwar.bausystem.features.detonator;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.config.ColorConfig;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.autostart.AutostartListener;
|
||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
@ -75,6 +77,10 @@ public class Detonator {
|
||||
|
||||
public static void activateDetonator(DetonatorStorage detonator) {
|
||||
Player p = detonator.getPlayer();
|
||||
if (Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false)) {
|
||||
AutostartListener.instance.activate(p);
|
||||
}
|
||||
|
||||
Map<Integer, Set<Block>> deactivate = new HashMap<>();
|
||||
Set<Location> invalid = new HashSet<>();
|
||||
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bausystem.features.detonator;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.config.ColorConfig;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
@ -81,4 +83,11 @@ public class DetonatorCommand extends SWCommand {
|
||||
storage.clear();
|
||||
storage.write();
|
||||
}
|
||||
|
||||
@Register("autostart")
|
||||
public void toggleAutostartTimer(Player p) {
|
||||
boolean current = Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false);
|
||||
Config.getInstance().get(p).put("detonator-autostart", !current);
|
||||
p.sendMessage(BauSystem.PREFIX + "Autostart beim detonate " + (!current ? "§aangeschaltet" : "§causgeschaltet"));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren