SteamWar/BauSystem2.0
Archiviert
12
0

Add Loader.single

Dieser Commit ist enthalten in:
yoyosource 2024-04-18 16:11:46 +02:00
Ursprung 356b14d49c
Commit 17a8389703
4 geänderte Dateien mit 38 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -522,6 +522,7 @@ LOADER_SETUP = §eSetup
LOADER_RUNNING = §aRunning
LOADER_PAUSE = §7Pause
LOADER_END = §8Finished
LOADER_SINGLE=§aSingle
LOADER_MESSAGE_INTERACT=§e{0} added {1}
LOADER_MESSAGE_UNINTERACT=§eRemoved Element
@ -543,7 +544,8 @@ LOADER_BUTTON_FENCEGATE=Fencegate
LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions
LOADER_SETUP_STOP_FIRST=§cPlease stop the current loader first!
LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action
LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded actions
LOADER_HELP_SINGLE=§8/§7loader single - §7Single playback of previously recoded actions
LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader
LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
@ -554,6 +556,7 @@ LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader.
LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
LOADER_ACTIVE=§7The Loader is now active.
LOADER_STOP=§7The Loader has been stopped.
LOADER_SINGLE_CMD=§7The Loader does a single playback.
LOADER_PAUSED=§7The Loader is now paused.
LOADER_SMALL_TIME=§cThe wait time is too small
LOADER_NEW_TIME=§7The wait time is now: {0}

Datei anzeigen

@ -498,6 +498,7 @@ LOADER_SETUP = §eEinrichtung
LOADER_RUNNING = §aLaufend
LOADER_PAUSE = §7Pausiert
LOADER_END = §8Beendet
LOADER_SINGLE=§aEinmal
LOADER_MESSAGE_INTERACT = §e{0} hinzugefügt {1}
LOADER_BUTTON_TNT = TNT
@ -519,6 +520,7 @@ LOADER_BUTTON_FENCEGATE=Fencegate
LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen
LOADER_SETUP_STOP_FIRST=§cBitte stoppe zuerst den Loader
LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab
LOADER_HELP_SINGLE=§8/§eloader single §8- §7Spielt die zuvor aufgenommenen Aktionen einmal ab
LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen
LOADER_HELP_GUI=§8/§7loader settings §8- §7Zeigt die Einstellungen an
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen
@ -529,6 +531,7 @@ LOADER_NEW=§7Belade und feuer einmal die Kanone ab, um den Loader zu initialisi
LOADER_HOW_TO_START=§7Führe dann /§eloader start§7 um den Loader zu starten
LOADER_ACTIVE=§7Der Loader ist nun aktiviert.
LOADER_STOP=§7Der Loader ist nun gestoppt.
LOADER_SINGLE_CMD=§7Der Loader spielt nun einmal ab.
LOADER_PAUSED=§7Der Loader ist nun pausiert.
LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein
LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}

Datei anzeigen

@ -39,7 +39,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class Loader implements Listener {
@ -78,6 +81,10 @@ public class Loader implements Listener {
}
if (currentElement >= elements.size()) {
currentElement = 0;
if (stage == Stage.SINGLE) {
stage = Stage.PAUSE;
return;
}
}
while (currentElement < elements.size()) {
@ -92,6 +99,20 @@ public class Loader implements Listener {
}, 0, 1);
}
public void single() {
if (stage == Stage.END) return;
if (stage == Stage.RUNNING) return;
stage = Stage.SINGLE;
if (recorder != null) {
recorder.stop();
recorder = null;
}
if (elements.isEmpty()) {
BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p);
stop();
}
}
public void start() {
if (stage == Stage.END) return;
if (stage == Stage.RUNNING) return;
@ -349,6 +370,7 @@ public class Loader implements Listener {
public enum Stage implements EnumDisplay {
SETUP("LOADER_SETUP"),
RUNNING("LOADER_RUNNING"),
SINGLE("LOADER_SINGLE"),
PAUSE("LOADER_PAUSE"),
END("LOADER_END");

Datei anzeigen

@ -20,10 +20,8 @@
package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -105,6 +103,14 @@ public class LoaderCommand extends SWCommand implements Listener {
loader.setTicksBetweenBlocks(delay);
}
@Register(value = "single", description = "LOADER_HELP_SINGLE")
public void singleLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) return;
loader.single();
BauSystem.MESSAGE.send("LOADER_SINGLE_CMD", p);
}
@EventHandler
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
event.getNewSpectator().forEach(player -> {