Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
11ae4721f6
Commit
9155bd7070
@ -83,7 +83,7 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
|
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// SimulatorStorage.start(name);
|
tntSimulator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper("simulators")
|
@Mapper("simulators")
|
||||||
|
@ -19,13 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.TNTElementGUI;
|
import de.steamwar.bausystem.features.simulator.gui.TNTElementGUI;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.TNTSimulatorGui;
|
import de.steamwar.bausystem.features.simulator.gui.TNTSimulatorGui;
|
||||||
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
|
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
||||||
|
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
|
||||||
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,6 +40,7 @@ import yapion.hierarchy.types.YAPIONObject;
|
|||||||
import yapion.hierarchy.types.YAPIONType;
|
import yapion.hierarchy.types.YAPIONType;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -201,4 +207,53 @@ public class TNTSimulator {
|
|||||||
show(p);
|
show(p);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result = new HashMap<>();
|
||||||
|
for (SimulatorElement element : tntElementList) {
|
||||||
|
element.locations(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||||
|
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
||||||
|
if (simulatorAutoTrace) {
|
||||||
|
RecordStateMachine.commandSingle();
|
||||||
|
player.performCommand("trace show");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
result.forEach((integer, integerSetMap) -> {
|
||||||
|
List<Pair<Integer, Set<Pair<Runnable, Integer>>>> elements = new ArrayList<>();
|
||||||
|
integerSetMap.forEach((integer2, set) -> {
|
||||||
|
elements.add(new Pair<>(integer2, set));
|
||||||
|
});
|
||||||
|
elements.sort(Comparator.comparingInt(Pair::getKey));
|
||||||
|
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
for (Pair<Integer, Set<Pair<Runnable, Integer>>> pair : elements) {
|
||||||
|
Map<Runnable, Integer> counts = new HashMap<>();
|
||||||
|
pair.getValue().forEach(runnableIntegerPair -> {
|
||||||
|
counts.put(runnableIntegerPair.getKey(), runnableIntegerPair.getValue());
|
||||||
|
});
|
||||||
|
List<Runnable> order = new ArrayList<>();
|
||||||
|
counts.forEach((runnable, integer1) -> {
|
||||||
|
order.add(runnable);
|
||||||
|
});
|
||||||
|
Collections.shuffle(order);
|
||||||
|
|
||||||
|
while (!counts.isEmpty()) {
|
||||||
|
for (Runnable runnable : order) {
|
||||||
|
if (counts.get(runnable) == 0) {
|
||||||
|
counts.remove(runnable);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
runnable.run();
|
||||||
|
counts.put(runnable, counts.get(runnable) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, integer);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
if (simulator == null) {
|
if (simulator == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("Left click");
|
simulator.start();
|
||||||
break;
|
break;
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
@ -47,7 +47,7 @@ public interface SimulatorElement {
|
|||||||
void hide(SimulatorEntityShowMode showMode);
|
void hide(SimulatorEntityShowMode showMode);
|
||||||
|
|
||||||
SWItem menu(Player p);
|
SWItem menu(Player p);
|
||||||
void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result); // Ticks to subtick order to spawning runnable to count of activations
|
void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result); // Ticks to subtick order to spawning runnable to count of activations
|
||||||
|
|
||||||
// Observer
|
// Observer
|
||||||
default void change() {
|
default void change() {
|
||||||
|
@ -163,10 +163,11 @@ public class TNTElement implements SimulatorElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result) {
|
public void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result) {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>())
|
result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>())
|
||||||
.computeIfAbsent(OrderUtils.order(order), ignore -> new Pair<>(() -> {
|
.computeIfAbsent(OrderUtils.order(order), ignore -> new HashSet<>())
|
||||||
|
.add(new Pair<>(() -> {
|
||||||
SimulatorStorage.WORLD.spawn(getPosition().toLocation(SimulatorStorage.WORLD), TNTPrimed.class, tntPrimed -> {
|
SimulatorStorage.WORLD.spawn(getPosition().toLocation(SimulatorStorage.WORLD), TNTPrimed.class, tntPrimed -> {
|
||||||
tntPrimed.setFuseTicks(fuseTicks);
|
tntPrimed.setFuseTicks(fuseTicks);
|
||||||
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
||||||
|
@ -34,6 +34,7 @@ import yapion.hierarchy.types.YAPIONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -136,7 +137,7 @@ public class TNTGroup implements SimulatorElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result) {
|
public void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result) {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
elements.forEach(tntElement -> {
|
elements.forEach(tntElement -> {
|
||||||
tntElement.locations(result);
|
tntElement.locations(result);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren