SteamWar/BauSystem2.0
Archiviert
12
0

Add eta to laufbau states
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-09-20 15:07:42 +02:00
Ursprung f039687325
Commit cc895ea5ec
12 geänderte Dateien mit 38 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -1108,7 +1108,7 @@ LAUFBAU_STATE_SPLITTING_POINTS = Splitting points
LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points
LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner blocks LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner blocks
LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Creating outer blocks LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Creating outer blocks
LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} §7Time left§8: §e{3}
LAUFBAU_DONE = §aDone LAUFBAU_DONE = §aDone
LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau

Datei anzeigen

@ -1087,7 +1087,7 @@ LAUFBAU_STATE_SPLITTING_POINTS = Punkte trennen
LAUFBAU_STATE_SHRINKING_POINTS = Punkte ausdünnen LAUFBAU_STATE_SHRINKING_POINTS = Punkte ausdünnen
LAUFBAU_STATE_CREATING_INNER_BLOCKS = Innenraum füllen LAUFBAU_STATE_CREATING_INNER_BLOCKS = Innenraum füllen
LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Mantel bauen LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Mantel bauen
LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} §7Übrige Zeit §8: §e{3}
LAUFBAU_DONE = §aZuende gebaut LAUFBAU_DONE = §aZuende gebaut
LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau

Datei anzeigen

@ -1107,7 +1107,7 @@ LAUFBAU_STATE_SPLITTING_POINTS = Splitting points
LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points
LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner blocks LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner blocks
LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Creating outer blocks LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Creating outer blocks
LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} §7Time left§8: §e{3}
LAUFBAU_DONE = §aDone LAUFBAU_DONE = §aDone
LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau LAUFBAU_SETTINGS_GUI_NAME = §eLaufbau

Datei anzeigen

@ -116,7 +116,7 @@ public class Laufbau {
return; return;
} }
if (shrinkingOuterPointsState != null) { if (shrinkingOuterPointsState != null) {
creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, processingTracesState.getCuboidList(), splittingPointsState.getIntersectedCuboid(), editSession, elements, preferingBlastResistance); creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, splittingPointsState.getIntersectedCuboid(), editSession, elements);
return; return;
} }
if (splittingPointsState != null) { if (splittingPointsState != null) {

Datei anzeigen

@ -30,36 +30,37 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class CreatingInnerBlocksState implements LaufbauState { public class CreatingInnerBlocksState implements LaufbauState {
private long start = System.currentTimeMillis();
private List<Point> innerBlocks; private List<Point> innerBlocks;
private int index = 0; private int index = 0;
private World world; private World world;
private List<Cuboid> cuboidList;
private Map<Point, List<Cuboid>> intersectedCuboid; private Map<Point, List<Cuboid>> intersectedCuboid;
private EditSession editSession; private EditSession editSession;
private List<BlockBoundingBox> elements; private List<BlockBoundingBox> elements;
private boolean preferingBlastResistance;
public CreatingInnerBlocksState(List<Point> innerBlocks, World world, List<Cuboid> cuboidList, Map<Point, List<Cuboid>> intersectedCuboid, EditSession editSession, List<BlockBoundingBox> elements, boolean preferingBlastResistance) { public CreatingInnerBlocksState(List<Point> innerBlocks, World world, Map<Point, List<Cuboid>> intersectedCuboid, EditSession editSession, List<BlockBoundingBox> elements) {
this.innerBlocks = innerBlocks; this.innerBlocks = innerBlocks;
this.world = world; this.world = world;
this.cuboidList = cuboidList;
this.intersectedCuboid = intersectedCuboid; this.intersectedCuboid = intersectedCuboid;
this.editSession = editSession; this.editSession = editSession;
this.elements = elements; this.elements = elements;
this.preferingBlastResistance = preferingBlastResistance;
} }
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_INNER_BLOCKS", p), index, innerBlocks.size()); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_INNER_BLOCKS", p), index, innerBlocks.size(), eta(p, start, index, innerBlocks.size()));
} }
@Override @Override

Datei anzeigen

@ -41,6 +41,8 @@ public class CreatingOuterBlocksState implements LaufbauState {
SHELL = BlockTypes.get("minecraft:end_stone").getDefaultState().toBaseBlock(); SHELL = BlockTypes.get("minecraft:end_stone").getDefaultState().toBaseBlock();
} }
private long start = System.currentTimeMillis();
private List<Point> outerBlocks; private List<Point> outerBlocks;
private int index = 0; private int index = 0;
@ -55,7 +57,7 @@ public class CreatingOuterBlocksState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_OUTER_BLOCKS", p), index, outerBlocks.size()); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_OUTER_BLOCKS", p), index, outerBlocks.size(), eta(p, start, index, outerBlocks.size()));
} }
@Override @Override

Datei anzeigen

@ -36,6 +36,8 @@ import java.util.function.BiPredicate;
public class ExpandingTracesState implements LaufbauState { public class ExpandingTracesState implements LaufbauState {
private long start = System.currentTimeMillis();
private List<Cuboid> cuboidList; private List<Cuboid> cuboidList;
private int totalCuboids; private int totalCuboids;
@ -54,7 +56,7 @@ public class ExpandingTracesState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_EXPANDING_TRACES", p), totalCuboids - cuboidList.size(), totalCuboids); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_EXPANDING_TRACES", p), totalCuboids - cuboidList.size(), totalCuboids, eta(p, start, totalCuboids - cuboidList.size(), totalCuboids));
} }
@Override @Override

Datei anzeigen

@ -35,6 +35,8 @@ import java.util.function.BiPredicate;
public class FilteringTracesState implements LaufbauState { public class FilteringTracesState implements LaufbauState {
private long start = System.currentTimeMillis();
private World world; private World world;
private BiPredicate<Location, Integer> inRegionCheck; private BiPredicate<Location, Integer> inRegionCheck;
@ -55,7 +57,7 @@ public class FilteringTracesState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_FILTERING_TRACES", p), totalRecord - recordList.size(), totalRecord); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_FILTERING_TRACES", p), totalRecord - recordList.size(), totalRecord, eta(p, start, totalRecord - recordList.size(), totalRecord));
} }
@Override @Override

Datei anzeigen

@ -19,8 +19,13 @@
package de.steamwar.bausystem.features.slaves.laufbau.states; package de.steamwar.bausystem.features.slaves.laufbau.states;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
public interface LaufbauState { public interface LaufbauState {
String actionBarMessage(Player p); String actionBarMessage(Player p);
@ -28,4 +33,8 @@ public interface LaufbauState {
boolean hasNext(); boolean hasNext();
void next(); void next();
default String eta(Player p, long start, int done, int total) {
return new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Date.from(Instant.ofEpochMilli((System.currentTimeMillis() - start) / done * total)));
}
} }

Datei anzeigen

@ -31,6 +31,8 @@ import java.util.List;
public class ProcessingTracesState implements LaufbauState { public class ProcessingTracesState implements LaufbauState {
private long start = System.currentTimeMillis();
private int totalTNTPositions; private int totalTNTPositions;
private List<TNTPosition> tntPositionList; private List<TNTPosition> tntPositionList;
@ -44,7 +46,7 @@ public class ProcessingTracesState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTNTPositions - tntPositionList.size(), totalTNTPositions); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTNTPositions - tntPositionList.size(), totalTNTPositions, eta(p, start, totalTNTPositions - tntPositionList.size(), totalTNTPositions));
} }
@Override @Override

Datei anzeigen

@ -29,6 +29,8 @@ import java.util.List;
public class ShrinkingOuterPointsState implements LaufbauState { public class ShrinkingOuterPointsState implements LaufbauState {
private long start = System.currentTimeMillis();
private List<Point> outerPoints; private List<Point> outerPoints;
private List<Point> innerPoints; private List<Point> innerPoints;
private int index = 0; private int index = 0;
@ -43,7 +45,7 @@ public class ShrinkingOuterPointsState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SHRINKING_POINTS", p), index, outerPoints.size()); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SHRINKING_POINTS", p), index, outerPoints.size(), eta(p, start, index, outerPoints.size()));
} }
@Override @Override

Datei anzeigen

@ -32,6 +32,8 @@ public class SplittingPointsState implements LaufbauState {
private static final Cuboid ONE = new Cuboid(0, 0, 0, 1, 1, 1); private static final Cuboid ONE = new Cuboid(0, 0, 0, 1, 1, 1);
private static final Cuboid ABOVE_HALF = new Cuboid(0, 1, 0, 1, 0.5, 1); private static final Cuboid ABOVE_HALF = new Cuboid(0, 1, 0, 1, 0.5, 1);
private long start = System.currentTimeMillis();
private List<Point> blocks; private List<Point> blocks;
private int totalBlocks; private int totalBlocks;
private List<Cuboid> cuboidList; private List<Cuboid> cuboidList;
@ -53,7 +55,7 @@ public class SplittingPointsState implements LaufbauState {
@Override @Override
public String actionBarMessage(Player p) { public String actionBarMessage(Player p) {
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SPLITTING_POINTS", p), totalBlocks - blocks.size(), totalBlocks); return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SPLITTING_POINTS", p), totalBlocks - blocks.size(), totalBlocks, eta(p, start, totalBlocks - blocks.size(), totalBlocks));
} }
@Override @Override