Fix rounding error Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
b22fabe8cd
Commit
a21e652ac9
@ -512,6 +512,8 @@ SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
||||
|
||||
SIMULATOR_NO_SIM_IN_HAND = §cNo simulator item selected
|
||||
SIMULATOR_GUI_SELECT_SIM = Simulator selection
|
||||
SIMULATOR_GUI_CREATE_SIM = §eCreate simulator
|
||||
SIMULATOR_GUI_CREATE_SIM_GUI = Create simulator
|
||||
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator already exists
|
||||
SIMULATOR_NAME_INVALID = §cInvalid name
|
||||
SIMULATOR_NOT_EXISTS = §cSimulator does not exist
|
||||
@ -607,7 +609,6 @@ SIMULATOR_TNT_SPAWN_ACTIVATED_WITH = §7Primed by §8- §e{0}
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR = Comparator
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER = Repeater
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_OBSERVER = Observer
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_UNKNOWN = Unknown
|
||||
SIMULATOR_TNT_SPAWN_INACTIVE = §7> §7{0}
|
||||
SIMULATOR_TNT_SPAWN_ACTIVE = §e> §7{0}
|
||||
SIMULATOR_TNT_SPAWN_MATERIAL = §eMaterial
|
||||
|
@ -513,6 +513,8 @@ SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
||||
|
||||
SIMULATOR_NO_SIM_IN_HAND = §cKein Simulator Item gewählt
|
||||
SIMULATOR_GUI_SELECT_SIM = Simulator wählen
|
||||
SIMULATOR_GUI_CREATE_SIM = §eSimulator erstellen
|
||||
SIMULATOR_GUI_CREATE_SIM_GUI = Simulator erstellen
|
||||
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator existiert bereits
|
||||
SIMULATOR_NAME_INVALID = §cUngültiger Name
|
||||
SIMULATOR_NOT_EXISTS = §cSimulator existiert nicht
|
||||
@ -594,7 +596,6 @@ SIMULATOR_TNT_SPAWN_ACTIVATED_WITH = §7Gezündet durch §8- §e{0}
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR = Comparator
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER = Repeater
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_OBSERVER = Observer
|
||||
SIMULATOR_TNT_SPAWN_ACTIVATED_UNKNOWN = Unbekannt
|
||||
SIMULATOR_TNT_SPAWN_MATERIAL = §eMaterial
|
||||
SIMULATOR_TNT_SPAWN_MATERIAL_LORE_1 = §7Jetziges Material§8: §e{0}
|
||||
SIMULATOR_TNT_SPAWN_MATERIAL_LORE_2 = §eLink-Click §7Zum ändern
|
||||
|
@ -58,16 +58,21 @@ public class SimulatorCommand extends SWCommand {
|
||||
|
||||
@Register(value = "create", description = "SIMULATOR_CREATE_HELP")
|
||||
public void create(@Guard Player p, String name) {
|
||||
createSimulator(p, name);
|
||||
}
|
||||
|
||||
public static boolean createSimulator(Player p, String name) {
|
||||
if (SimulatorStorage.getSimulatorNames().contains(name)) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (!name.matches("[a-zA-Z_]+")) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", p);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
SimulatorStorage.createNewSimulator(name);
|
||||
BauSystem.MESSAGE.send("SIMULATOR_CREATE", p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Register(value = "delete", description = "SIMULATOR_DELETE_HELP")
|
||||
|
@ -20,11 +20,14 @@
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorCommand;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -53,6 +56,24 @@ public class SimulatorSelectionGUI {
|
||||
player.closeInventory();
|
||||
});
|
||||
|
||||
inv.setItem(49, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("SIMULATOR_GUI_CREATE_SIM", player), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_CREATE_SIM_GUI", player), "");
|
||||
swAnvilInv.setItem(Material.PAPER);
|
||||
swAnvilInv.setCallback(s -> {
|
||||
player.closeInventory();
|
||||
if (SimulatorCommand.createSimulator(player, s)) {
|
||||
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
||||
if (current != null) {
|
||||
current.remove(player);
|
||||
}
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(s);
|
||||
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
||||
player.getInventory().setItemInMainHand(hand);
|
||||
}
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
|
||||
inv.open();
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ 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;
|
||||
|
||||
@ -136,7 +135,7 @@ public class ChangePosition {
|
||||
}
|
||||
|
||||
private double clamp(double d) {
|
||||
return (int) (d * 100) * 0.01;
|
||||
return (int) (d * 10000) * 0.0001;
|
||||
}
|
||||
|
||||
private void changePosition(Player player, double defaultValue, Consumer<Double> result, Runnable failure) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren