Minor DT Stuff and Fixes in Loader
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
10b5d9d3c1
Commit
47e6a8bbcd
@ -59,7 +59,7 @@ public class DetonatorCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(help = true)
|
@Register(help = true)
|
||||||
public void genericHelp(Player p, String... args) {
|
public void genericHelp(Player p, String... args) {
|
||||||
p.sendMessage(ColorConfig.BASE + "---===(" + ColorConfig.HIGHLIGHT + "Fernzünder" + ColorConfig.BASE + ")===---");
|
p.sendMessage(ColorConfig.BASE + "---=== (" + ColorConfig.HIGHLIGHT + "Fernzünder" + ColorConfig.BASE + ") ===---");
|
||||||
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator wand " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Gibt den Fernzünder");
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator wand " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Gibt den Fernzünder");
|
||||||
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator click " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Aktiviere einen Fernzünder (Haupthand -> Hotbar -> Inventar)");
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator click " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Aktiviere einen Fernzünder (Haupthand -> Hotbar -> Inventar)");
|
||||||
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator clear " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Cleare einen Fernzünder");
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "detonator clear " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Cleare einen Fernzünder");
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
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.block.Action;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@ -48,9 +49,11 @@ public class Loader implements Listener {
|
|||||||
private final List<AbstractLoaderActivation> actions = new LinkedList<>();
|
private final List<AbstractLoaderActivation> actions = new LinkedList<>();
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
@Getter
|
@Getter
|
||||||
private final int ticksBetweenShots = 80;
|
@Setter
|
||||||
|
private int ticksBetweenShots = 80;
|
||||||
@Getter
|
@Getter
|
||||||
private final int ticksBetweenBlocks = 1;
|
@Setter
|
||||||
|
private int ticksBetweenBlocks = 1;
|
||||||
@Getter
|
@Getter
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
@Getter
|
@Getter
|
||||||
@ -84,16 +87,16 @@ public class Loader implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
if (stage == Stage.PAUSE) {
|
if (stage == Stage.RUNNING) {
|
||||||
resume();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stage = Stage.PAUSE;
|
stage = Stage.PAUSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void resume() {
|
public void resume() {
|
||||||
|
if (stage == Stage.PAUSE) {
|
||||||
stage = Stage.RUNNING;
|
stage = Stage.RUNNING;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setup() {
|
public void setup() {
|
||||||
stage = Stage.SETUP;
|
stage = Stage.SETUP;
|
||||||
@ -109,7 +112,12 @@ public class Loader implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
if (stage == Stage.SETUP) {
|
||||||
actions.clear();
|
actions.clear();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Loader gecleart");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Du must im Setup-Modus sein um den Loader zu clearen");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -132,15 +140,21 @@ public class Loader implements Listener {
|
|||||||
|
|
||||||
current = iterator.next();
|
current = iterator.next();
|
||||||
|
|
||||||
try {
|
if (current.execute()) {
|
||||||
current.execute();
|
|
||||||
countdown = current.delay(this);
|
countdown = current.delay(this);
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
pause();
|
countdown = 1;
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Ein Fehler beim ausführen ist passiert, Autoloader wurde pausiert.");
|
iterator.previous();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void undo() {
|
||||||
|
if (actions.isEmpty() || stage != Stage.SETUP) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
actions.remove(actions.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.getPlayer() != p) {
|
if (event.getPlayer() != p) {
|
||||||
@ -169,8 +183,15 @@ public class Loader implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoaderButton.fromBlock(event.getClickedBlock()) != LoaderButton.INVALID) {
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL)
|
||||||
|
return;
|
||||||
|
if (event.getClickedBlock().getType() == Material.OBSERVER)
|
||||||
|
return;
|
||||||
|
LoaderButton button = LoaderButton.fromBlock(event.getClickedBlock());
|
||||||
|
if (button != LoaderButton.INVALID) {
|
||||||
actions.add(InteractionActivation.construct(p, event.getClickedBlock().getLocation(), this));
|
actions.add(InteractionActivation.construct(p, event.getClickedBlock().getLocation(), this));
|
||||||
|
lastActivation = 0;
|
||||||
|
SWUtils.sendToActionbar(p, ColorConfig.HIGHLIGHT + button.getName() + " hinzugefügt " + actions.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,16 @@ public class LoaderCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(help = true)
|
@Register(help = true)
|
||||||
public void genericHelp(Player p, String... args) {
|
public void genericHelp(Player p, String... args) {
|
||||||
p.sendMessage("@Help@");
|
p.sendMessage(ColorConfig.BASE + "---=== (" + ColorConfig.HIGHLIGHT + "Loader" + ColorConfig.BASE + ") ===---");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "loader setup " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Startet die Aufnahme der Aktionen");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.BASE + "loader undo " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Entfernt die zuletzt aufgenommene Aktion");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "loader start " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Spielt die zuvor aufgenommenen Aktionen ab");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.BASE + "loader wait " + ColorConfig.OTHER + "[" + ColorConfig.BASE + "Ticks" + ColorConfig.OTHER + "] - " + ColorConfig.BASE + "Setzt die Wartezeit zwischen Schüssen");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.BASE + "loader speed " + ColorConfig.OTHER + "[" + ColorConfig.BASE + "Ticks" + ColorConfig.OTHER + "] - " + ColorConfig.BASE + "Setzt die Wartezeit zwischen Aktionen");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.BASE + "loader pause " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Pausiert das Abspielen");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.BASE + "loader resume " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Spielt den Loader weiter ab");
|
||||||
|
p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "loader stop " + ColorConfig.OTHER + "- " + ColorConfig.BASE + "Stoppt die Aufnahme bzw. das Abspielen");
|
||||||
|
p.sendMessage(ColorConfig.BASE + "Der Loader arbeitet mit " + ColorConfig.HIGHLIGHT + "Ingame" + ColorConfig.OTHER + "-" + ColorConfig.HIGHLIGHT + "Ticks " + ColorConfig.OTHER + "(20 Ticks pro Sekunde)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loaderNullCheck(Loader loader, Player p) {
|
private boolean loaderNullCheck(Loader loader, Player p) {
|
||||||
@ -51,28 +60,98 @@ public class LoaderCommand extends SWCommand {
|
|||||||
public void setupLoader(Player p) {
|
public void setupLoader(Player p) {
|
||||||
if (Loader.getLoader(p) != null) {
|
if (Loader.getLoader(p) != null) {
|
||||||
Loader.getLoader(p).setup();
|
Loader.getLoader(p).setup();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.HIGHLIGHT + "Dein Loader ist nun wieder im Setup");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Dein Loader ist nun wieder im Setup");
|
||||||
} else {
|
} else {
|
||||||
Loader.newLoader(p);
|
Loader.newLoader(p);
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.HIGHLIGHT + "Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren.");
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Führe dann /" + ColorConfig.HIGHLIGHT + "loader start" + ColorConfig.BASE + " um den Loader zu starten");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("start")
|
@Register("start")
|
||||||
public void startLoader(Player p) {
|
public void startLoader(Player p) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p))
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
loader.start();
|
loader.start();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.HIGHLIGHT + "Der Loader ist nun aktiviert.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun aktiviert.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("stop")
|
@Register("stop")
|
||||||
public void stopLoader(Player p) {
|
public void stopLoader(Player p) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p))
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
loader.stop();
|
loader.stop();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.HIGHLIGHT + "Der Loader ist nun gestoppt.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun gestoppt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("pause")
|
||||||
|
public void pauseLoader(Player p) {
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loader.pause();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun pausiert.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("resume")
|
||||||
|
public void resumeLoader(Player p) {
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loader.resume();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader läuft nun weiter.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("wait")
|
||||||
|
public void shotDelayLoader(Player p, int delay) {
|
||||||
|
if (delay < 1) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Die Schusswartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenShots());
|
||||||
|
loader.setTicksBetweenShots(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("speed")
|
||||||
|
public void speedLoader(Player p, int delay) {
|
||||||
|
if (delay < 1) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "die Setzwartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenBlocks());
|
||||||
|
loader.setTicksBetweenShots(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("undo")
|
||||||
|
public void undoLast(Player p) {
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Undo erfolgreich.");
|
||||||
|
loader.undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("clear")
|
||||||
|
public void clearLoader(Player p) {
|
||||||
|
Loader loader = Loader.getLoader(p);
|
||||||
|
if (loaderNullCheck(loader, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loader.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public abstract class AbstractLoaderActivation {
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void execute();
|
public abstract boolean execute();
|
||||||
|
|
||||||
public abstract int delay(Loader loader);
|
public abstract int delay(Loader loader);
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,14 @@ public class BlockPlaceLoaderActivation extends AbstractLoaderActivation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public boolean execute() {
|
||||||
Block currBlock = location.getBlock();
|
Block currBlock = location.getBlock();
|
||||||
if (currBlock.getType() != Material.AIR && currBlock.getType() != Material.WATER) {
|
if (currBlock.getType() != Material.AIR && currBlock.getType() != Material.WATER) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currBlock.setType(material, true);
|
currBlock.setType(material, true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,11 +131,14 @@ public abstract class InteractionActivation extends AbstractLoaderActivation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public boolean execute() {
|
||||||
|
if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID)
|
||||||
|
return false;
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
setBlockPower(getBlockPower());
|
setBlockPower(!getBlockPower());
|
||||||
updateButton();
|
updateButton();
|
||||||
}, delay);
|
}, delay);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,13 +154,16 @@ public abstract class InteractionActivation extends AbstractLoaderActivation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public boolean execute() {
|
||||||
|
if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID)
|
||||||
|
return false;
|
||||||
setBlockPower(true);
|
setBlockPower(true);
|
||||||
updateButton();
|
updateButton();
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
setBlockPower(getBlockPower());
|
setBlockPower(false);
|
||||||
updateButton();
|
updateButton();
|
||||||
}, button.getTime());
|
}, button.getTime());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren