Hotfix Loader Bau slowdowns and crashes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5f7f11bf87
Commit
27798df7ce
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||||
|
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
|
||||||
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
|
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
|
||||||
import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait;
|
import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait;
|
||||||
import de.steamwar.bausystem.shared.EnumDisplay;
|
import de.steamwar.bausystem.shared.EnumDisplay;
|
||||||
@ -58,31 +59,32 @@ public class Loader implements Listener {
|
|||||||
|
|
||||||
private List<LoaderElement> elements = new ArrayList<>();
|
private List<LoaderElement> elements = new ArrayList<>();
|
||||||
private int currentElement = 0;
|
private int currentElement = 0;
|
||||||
private long totalDelay = 0;
|
private long waitTime = 0;
|
||||||
|
|
||||||
public Loader(Player p) {
|
public Loader(Player p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
this.recorder = new LoaderRecorder(p, elements);
|
this.recorder = new LoaderRecorder(p, elements);
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||||
}
|
|
||||||
|
|
||||||
private void next() {
|
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
currentElement++;
|
if (stage != Stage.RUNNING) return;
|
||||||
if (currentElement >= elements.size()) {
|
if (waitTime > 0) {
|
||||||
currentElement = 0;
|
waitTime--;
|
||||||
if (totalDelay == 0) {
|
|
||||||
BauSystem.runTaskLater(BauSystem.getInstance(), this::next, 1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
totalDelay = 0;
|
|
||||||
}
|
while (currentElement < elements.size()) {
|
||||||
if (stage == Stage.RUNNING) {
|
|
||||||
LoaderElement element = elements.get(currentElement);
|
LoaderElement element = elements.get(currentElement);
|
||||||
if (element instanceof LoaderWait) {
|
currentElement++;
|
||||||
totalDelay += ((LoaderWait) element).getDelay();
|
element.execute(delay -> waitTime = delay);
|
||||||
|
if (waitTime > 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
element.execute(this::next);
|
|
||||||
}
|
}
|
||||||
|
if (currentElement >= elements.size()) {
|
||||||
|
currentElement = 0;
|
||||||
|
}
|
||||||
|
}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@ -96,9 +98,7 @@ public class Loader implements Listener {
|
|||||||
if (elements.isEmpty()) {
|
if (elements.isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p);
|
BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p);
|
||||||
stop();
|
stop();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
elements.get(currentElement).execute(this::next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
@ -133,7 +133,12 @@ public class Loader implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SWItem item = element.menu(p);
|
SWItem item = element.menu(p);
|
||||||
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_MODES", p, elements.size()), "§8", BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p)));
|
if (element instanceof LoaderInteractionElement<?>) {
|
||||||
|
LoaderInteractionElement<?> interactionElement = (LoaderInteractionElement<?>) element;
|
||||||
|
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_MODES", p, interactionElement.size()), "§8", BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p)));
|
||||||
|
} else {
|
||||||
|
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p)));
|
||||||
|
}
|
||||||
list.add(new SWListInv.SWListEntry<>(item, element));
|
list.add(new SWListInv.SWListEntry<>(item, element));
|
||||||
}
|
}
|
||||||
SWListInv<LoaderElement> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {});
|
SWListInv<LoaderElement> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {});
|
||||||
|
@ -23,9 +23,11 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface ElementSettings {
|
public interface ElementSettings {
|
||||||
SWItem menu(Player player);
|
SWItem menu(Player player);
|
||||||
void execute(Runnable nextAction);
|
void execute(Consumer<Long> delay);
|
||||||
void click(Player player, Runnable backAction, Runnable deleteAction);
|
void click(Player player, Runnable backAction, Runnable deleteAction);
|
||||||
|
|
||||||
default void playerInteract() {}
|
default void playerInteract() {}
|
||||||
|
@ -22,8 +22,10 @@ package de.steamwar.bausystem.features.loader.elements;
|
|||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface LoaderElement {
|
public interface LoaderElement {
|
||||||
SWItem menu(Player player);
|
SWItem menu(Player player);
|
||||||
void execute(Runnable nextAction);
|
void execute(Consumer<Long> delay);
|
||||||
void click(Player player, Runnable backAction);
|
void click(Player player, Runnable backAction);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class LoaderInteractionElement<T extends ElementSettings> implements LoaderElement {
|
public abstract class LoaderInteractionElement<T extends ElementSettings> implements LoaderElement {
|
||||||
|
|
||||||
@ -49,9 +50,9 @@ public abstract class LoaderInteractionElement<T extends ElementSettings> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
if (currentShot >= elements.size()) currentShot = 0;
|
if (currentShot >= elements.size()) currentShot = 0;
|
||||||
elements.get(currentShot).execute(nextAction);
|
elements.get(currentShot).execute(delay);
|
||||||
currentShot++;
|
currentShot++;
|
||||||
if (currentShot >= elements.size()) currentShot = 0;
|
if (currentShot >= elements.size()) currentShot = 0;
|
||||||
}
|
}
|
||||||
@ -122,4 +123,8 @@ public abstract class LoaderInteractionElement<T extends ElementSettings> implem
|
|||||||
protected final String translateItemName(String name, Player player) {
|
protected final String translateItemName(String name, Player player) {
|
||||||
return BauSystem.MESSAGE.parse("LOADER_SETTING_NAME", player, BauSystem.MESSAGE.parse(name, player));
|
return BauSystem.MESSAGE.parse("LOADER_SETTING_NAME", player, BauSystem.MESSAGE.parse(name, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return elements.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderComparator extends LoaderInteractionElement<LoaderComparator.ComparatorSettings> {
|
public class LoaderComparator extends LoaderInteractionElement<LoaderComparator.ComparatorSettings> {
|
||||||
|
|
||||||
@ -62,8 +63,7 @@ public class LoaderComparator extends LoaderInteractionElement<LoaderComparator.
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.COMPARATOR) return;
|
if (location.getBlock().getType() != Material.COMPARATOR) return;
|
||||||
Comparator comparator = (Comparator) location.getBlock().getBlockData();
|
Comparator comparator = (Comparator) location.getBlock().getBlockData();
|
||||||
if (interact) {
|
if (interact) {
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderDaylightDetector extends LoaderInteractionElement<LoaderDaylightDetector.DaylightDetectorSettings> {
|
public class LoaderDaylightDetector extends LoaderInteractionElement<LoaderDaylightDetector.DaylightDetectorSettings> {
|
||||||
|
|
||||||
@ -64,8 +65,7 @@ public class LoaderDaylightDetector extends LoaderInteractionElement<LoaderDayli
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.DAYLIGHT_DETECTOR) return;
|
if (location.getBlock().getType() != Material.DAYLIGHT_DETECTOR) return;
|
||||||
DaylightDetector daylightDetector = (DaylightDetector) location.getBlock().getBlockData();
|
DaylightDetector daylightDetector = (DaylightDetector) location.getBlock().getBlockData();
|
||||||
if (noop) {
|
if (noop) {
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.inventory.meta.BookMeta;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderLectern extends LoaderInteractionElement<LoaderLectern.LecternSettings> {
|
public class LoaderLectern extends LoaderInteractionElement<LoaderLectern.LecternSettings> {
|
||||||
|
|
||||||
@ -68,8 +69,7 @@ public class LoaderLectern extends LoaderInteractionElement<LoaderLectern.Lecter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.LECTERN) return;
|
if (location.getBlock().getType() != Material.LECTERN) return;
|
||||||
Lectern lectern = (Lectern) location.getBlock().getState();
|
Lectern lectern = (Lectern) location.getBlock().getState();
|
||||||
if (!((org.bukkit.block.data.type.Lectern) lectern.getBlockData()).hasBook()) return;
|
if (!((org.bukkit.block.data.type.Lectern) lectern.getBlockData()).hasBook()) return;
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderLever extends LoaderInteractionElement<LoaderLever.LeverSettings> {
|
public class LoaderLever extends LoaderInteractionElement<LoaderLever.LeverSettings> {
|
||||||
|
|
||||||
@ -63,8 +64,7 @@ public class LoaderLever extends LoaderInteractionElement<LoaderLever.LeverSetti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.LEVER) return;
|
if (location.getBlock().getType() != Material.LEVER) return;
|
||||||
if (noop) return;
|
if (noop) return;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.MovementSettings> {
|
public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.MovementSettings> {
|
||||||
|
|
||||||
@ -83,15 +84,9 @@ public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.Move
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
if (!(material == Material.STRING && location.getBlock().getType() == Material.TRIPWIRE) && location.getBlock().getType() != material) {
|
if (!(material == Material.STRING && location.getBlock().getType() == Material.TRIPWIRE) && location.getBlock().getType() != material) return;
|
||||||
nextAction.run();
|
if (noop) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (noop) {
|
|
||||||
nextAction.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockData blockData = location.getBlock().getBlockData();
|
BlockData blockData = location.getBlock().getBlockData();
|
||||||
if (blockData instanceof AnaloguePowerable) {
|
if (blockData instanceof AnaloguePowerable) {
|
||||||
@ -111,7 +106,9 @@ public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.Move
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ticks >= 0) {
|
if (ticks >= 0) {
|
||||||
boolean finalWaitFor = waitFor;
|
if (waitFor) {
|
||||||
|
delay.accept(ticks);
|
||||||
|
}
|
||||||
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
if (blockData instanceof AnaloguePowerable) {
|
if (blockData instanceof AnaloguePowerable) {
|
||||||
AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData;
|
AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData;
|
||||||
@ -124,13 +121,7 @@ public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.Move
|
|||||||
location.getBlock().setBlockData(powerable, true);
|
location.getBlock().setBlockData(powerable, true);
|
||||||
update(powerable);
|
update(powerable);
|
||||||
}
|
}
|
||||||
if (finalWaitFor) {
|
|
||||||
nextAction.run();
|
|
||||||
}
|
|
||||||
}, ticks);
|
}, ticks);
|
||||||
if (!finalWaitFor) {
|
|
||||||
nextAction.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderNoteBlock extends LoaderInteractionElement<LoaderNoteBlock.NoteBlockSettings> {
|
public class LoaderNoteBlock extends LoaderInteractionElement<LoaderNoteBlock.NoteBlockSettings> {
|
||||||
|
|
||||||
@ -60,8 +61,7 @@ public class LoaderNoteBlock extends LoaderInteractionElement<LoaderNoteBlock.No
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.NOTE_BLOCK) return;
|
if (location.getBlock().getType() != Material.NOTE_BLOCK) return;
|
||||||
NoteBlock noteBlock = (NoteBlock) location.getBlock().getBlockData();
|
NoteBlock noteBlock = (NoteBlock) location.getBlock().getBlockData();
|
||||||
if (interact) {
|
if (interact) {
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderOpenable extends LoaderInteractionElement<LoaderOpenable.TrapdoorSettings> {
|
public class LoaderOpenable extends LoaderInteractionElement<LoaderOpenable.TrapdoorSettings> {
|
||||||
|
|
||||||
@ -68,8 +69,7 @@ public class LoaderOpenable extends LoaderInteractionElement<LoaderOpenable.Trap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != material) return;
|
if (location.getBlock().getType() != material) return;
|
||||||
Openable openable = (Openable) location.getBlock().getBlockData();
|
Openable openable = (Openable) location.getBlock().getBlockData();
|
||||||
if (noop) {
|
if (noop) {
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderRepeater extends LoaderInteractionElement<LoaderRepeater.RepeaterSettings> {
|
public class LoaderRepeater extends LoaderInteractionElement<LoaderRepeater.RepeaterSettings> {
|
||||||
|
|
||||||
@ -63,8 +64,7 @@ public class LoaderRepeater extends LoaderInteractionElement<LoaderRepeater.Repe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> __) {
|
||||||
nextAction.run();
|
|
||||||
if (location.getBlock().getType() != Material.REPEATER) return;
|
if (location.getBlock().getType() != Material.REPEATER) return;
|
||||||
Repeater repeater = (Repeater) location.getBlock().getBlockData();
|
Repeater repeater = (Repeater) location.getBlock().getBlockData();
|
||||||
if (interact) {
|
if (interact) {
|
||||||
|
@ -29,6 +29,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderTNT implements LoaderElement {
|
public class LoaderTNT implements LoaderElement {
|
||||||
|
|
||||||
@ -46,15 +47,14 @@ public class LoaderTNT implements LoaderElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
if (block.getType() != Material.AIR && block.getType() != Material.WATER) {
|
if (block.getType() != Material.AIR && block.getType() != Material.WATER) {
|
||||||
BauSystem.runTaskLater(BauSystem.getInstance(), () -> execute(nextAction), 1);
|
delay.accept(1L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
block.setType(Material.TNT, true);
|
block.setType(Material.TNT, true);
|
||||||
nextAction.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSettings> {
|
public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSettings> {
|
||||||
|
|
||||||
@ -71,13 +72,11 @@ public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSetti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> delay) {
|
||||||
if (location.getBlock().getType() != material) {
|
if (location.getBlock().getType() != material) {
|
||||||
nextAction.run();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (noop) {
|
if (noop) {
|
||||||
nextAction.run();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,18 +85,14 @@ public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSetti
|
|||||||
location.getBlock().setBlockData(powerable, true);
|
location.getBlock().setBlockData(powerable, true);
|
||||||
update(powerable);
|
update(powerable);
|
||||||
|
|
||||||
boolean finalWaitFor = waitFor;
|
if (waitFor) {
|
||||||
|
delay.accept((long) ticks);
|
||||||
|
}
|
||||||
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
powerable.setPowered(false);
|
powerable.setPowered(false);
|
||||||
location.getBlock().setBlockData(powerable, true);
|
location.getBlock().setBlockData(powerable, true);
|
||||||
update(powerable);
|
update(powerable);
|
||||||
if (finalWaitFor) {
|
|
||||||
nextAction.run();
|
|
||||||
}
|
|
||||||
}, ticks);
|
}, ticks);
|
||||||
if (!finalWaitFor) {
|
|
||||||
nextAction.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LoaderWait implements LoaderElement, Listener {
|
public class LoaderWait implements LoaderElement, Listener {
|
||||||
|
|
||||||
@ -53,12 +54,8 @@ public class LoaderWait implements LoaderElement, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable nextAction) {
|
public void execute(Consumer<Long> __) {
|
||||||
if (delay == 0) {
|
__.accept(delay);
|
||||||
nextAction.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauSystem.runTaskLater(BauSystem.getInstance(), nextAction, delay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren