Add eta to laufbau states
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
f3ac49fd12
Commit
6a3f53a1c1
@ -1116,7 +1116,7 @@ LAUFBAU_STATE_SPLITTING_POINTS = Splitting points
|
||||
LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points
|
||||
LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner 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_SETTINGS_GUI_NAME = §eLaufbau
|
||||
|
@ -1095,7 +1095,7 @@ LAUFBAU_STATE_SPLITTING_POINTS = Punkte trennen
|
||||
LAUFBAU_STATE_SHRINKING_POINTS = Punkte ausdünnen
|
||||
LAUFBAU_STATE_CREATING_INNER_BLOCKS = Innenraum füllen
|
||||
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_SETTINGS_GUI_NAME = §eLaufbau
|
||||
|
@ -116,7 +116,7 @@ public class Laufbau {
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (splittingPointsState != null) {
|
||||
|
@ -30,36 +30,37 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CreatingInnerBlocksState implements LaufbauState {
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private List<Point> innerBlocks;
|
||||
private int index = 0;
|
||||
|
||||
private World world;
|
||||
private List<Cuboid> cuboidList;
|
||||
private Map<Point, List<Cuboid>> intersectedCuboid;
|
||||
private EditSession editSession;
|
||||
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.world = world;
|
||||
this.cuboidList = cuboidList;
|
||||
this.intersectedCuboid = intersectedCuboid;
|
||||
this.editSession = editSession;
|
||||
this.elements = elements;
|
||||
this.preferingBlastResistance = preferingBlastResistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -41,6 +41,8 @@ public class CreatingOuterBlocksState implements LaufbauState {
|
||||
SHELL = BlockTypes.get("minecraft:end_stone").getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private List<Point> outerBlocks;
|
||||
private int index = 0;
|
||||
|
||||
@ -55,7 +57,7 @@ public class CreatingOuterBlocksState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -36,6 +36,8 @@ import java.util.function.BiPredicate;
|
||||
|
||||
public class ExpandingTracesState implements LaufbauState {
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private List<Cuboid> cuboidList;
|
||||
private int totalCuboids;
|
||||
|
||||
@ -54,7 +56,7 @@ public class ExpandingTracesState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -35,6 +35,8 @@ import java.util.function.BiPredicate;
|
||||
|
||||
public class FilteringTracesState implements LaufbauState {
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private World world;
|
||||
private BiPredicate<Location, Integer> inRegionCheck;
|
||||
|
||||
@ -55,7 +57,7 @@ public class FilteringTracesState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -19,8 +19,13 @@
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.states;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
|
||||
public interface LaufbauState {
|
||||
|
||||
String actionBarMessage(Player p);
|
||||
@ -28,4 +33,8 @@ public interface LaufbauState {
|
||||
boolean hasNext();
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ import java.util.List;
|
||||
|
||||
public class ProcessingTracesState implements LaufbauState {
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private int totalTNTPositions;
|
||||
private List<TNTPosition> tntPositionList;
|
||||
|
||||
@ -44,7 +46,7 @@ public class ProcessingTracesState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||
|
||||
public class ShrinkingOuterPointsState implements LaufbauState {
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private List<Point> outerPoints;
|
||||
private List<Point> innerPoints;
|
||||
private int index = 0;
|
||||
@ -43,7 +45,7 @@ public class ShrinkingOuterPointsState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -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 ABOVE_HALF = new Cuboid(0, 1, 0, 1, 0.5, 1);
|
||||
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
private List<Point> blocks;
|
||||
private int totalBlocks;
|
||||
private List<Cuboid> cuboidList;
|
||||
@ -53,7 +55,7 @@ public class SplittingPointsState implements LaufbauState {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren