diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index f9513cd4..46d9779a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -167,7 +167,30 @@ public class TNTSimulator { if (elements.size() == 1) { TNTElementGUI.open(player, (TNTElement) elements.get(0), null); } else { - TNTSimulatorGui.open(player, null, null, () -> elements, null); + List tntGroups = tntElementList.stream().filter(TNTGroup.class::isInstance).map(TNTGroup.class::cast).collect(Collectors.toList()); + List newElementList = new ArrayList<>(); + for (TNTGroup tntGroup : tntGroups) { + if (new HashSet<>(elements).containsAll(tntGroup.getElements())) { + newElementList.add(tntGroup); + elements.removeAll(tntGroup.getElements()); + } + } + newElementList.addAll(elements); + if (newElementList.size() == 1) { + SimulatorElement element = newElementList.get(0); + if (element instanceof TNTGroup) { + TNTGroup tntGroup = (TNTGroup) element; + TNTSimulatorGui.open(player, null, tntGroup, () -> { + List elementList = new ArrayList<>(); + elementList.addAll(tntGroup.getElements()); + return elementList; + }, null); + } else { + TNTElementGUI.open(player, (TNTElement) elements.get(0), null); + } + } else { + TNTSimulatorGui.open(player, null, null, () -> newElementList, null); + } } return; }