Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
0f69d4acb1
Commit
f149ccce93
@ -124,55 +124,45 @@ public class TNTElementGUI {
|
||||
inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
|
||||
}
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
Runnable editObserver = () -> {
|
||||
ChangePosition.show(inv, player, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
|
||||
ChangePosition.show(inv, player, tntElement, vectorUnaryOperator -> {
|
||||
tntElement.setPosition(vectorUnaryOperator.apply(tntElement.getPosition()).subtract(tntElement.getParent().getPosition()));
|
||||
}, () -> editLocation(player, tntElement, back));
|
||||
|
||||
// Alignment
|
||||
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0, 0, 0.49));
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0, 0, 0.51));
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.51, 0, 0));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.49, 0, 0));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.5, 0, 0.5));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
};
|
||||
@ -355,7 +345,7 @@ public class TNTElementGUI {
|
||||
tntSimulator.getTntElementList().add(tntGroup);
|
||||
|
||||
// Add new TNT
|
||||
TNTElement newElement = new TNTElement(new Vector(0, 0, 0));
|
||||
TNTElement newElement = new TNTElement(new Vector(0, 0, 0), tntSimulator.getEntityServer());
|
||||
newElement.setTickOffset(1);
|
||||
tntGroup.add(newElement);
|
||||
|
||||
@ -371,7 +361,7 @@ public class TNTElementGUI {
|
||||
inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
Vector vector = tntElement.getOwnPosition().clone();
|
||||
TNTElement newElement = new TNTElement(vector);
|
||||
TNTElement newElement = new TNTElement(vector, tntSimulator.getEntityServer());
|
||||
if (tntElement.hasParent()) {
|
||||
newElement.setTickOffset(tntElement.getOwnTickOffset() + 1);
|
||||
tntElement.getParent().add(newElement);
|
||||
|
@ -148,7 +148,9 @@ public class TNTGroupEditGUI {
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
Runnable editObserver = () -> {
|
||||
ChangePosition.show(inv, player, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back));
|
||||
ChangePosition.show(inv, player, tntGroup, vectorUnaryOperator -> {
|
||||
tntGroup.setPosition(vectorUnaryOperator.apply(tntGroup.getPosition()));
|
||||
}, () -> open(player, tntGroup, back));
|
||||
ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back));
|
||||
Disabled.show(inv, player, 32, tntSimulator, tntGroup);
|
||||
|
||||
|
@ -35,6 +35,7 @@ import org.bukkit.util.Vector;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@ -51,7 +52,7 @@ public class ChangePosition {
|
||||
private static final Vector FY_VECTOR = new Vector(0, 1, 0);
|
||||
private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
|
||||
|
||||
public void show(SWInventory inv, Player player, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) {
|
||||
public void show(SWInventory inv, Player player, SimulatorElement simulatorElement, Consumer<UnaryOperator<Vector>> toChangeVector, Runnable back) {
|
||||
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
|
||||
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
|
||||
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
|
||||
@ -61,75 +62,84 @@ public class ChangePosition {
|
||||
// X Position
|
||||
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getX(), x -> {
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setX(clamp(calculatePositionX.apply(x)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setX(clamp(x));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
|
||||
// Y Position
|
||||
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getY(), y -> {
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setY(clamp(calculatePositionY.apply(y)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setY(clamp(y));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
|
||||
// Z Position
|
||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getZ(), z -> {
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setZ(clamp(z));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
}
|
||||
|
@ -35,13 +35,7 @@ public class Disabled {
|
||||
|
||||
public void show(SWInventory inv, Player player, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
|
||||
inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> {
|
||||
if (!simulatorElement.isDisabled()) {
|
||||
tntSimulator.hide(simulatorElement);
|
||||
}
|
||||
simulatorElement.setDisabled(!simulatorElement.isDisabled());
|
||||
if (!simulatorElement.isDisabled()) {
|
||||
tntSimulator.show(simulatorElement);
|
||||
}
|
||||
simulatorElement.change();
|
||||
}));
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren