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