SteamWar/BauSystem2.0
Archiviert
12
0

Update TNTSimulator
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Fix StopCommand for Console

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-19 17:38:21 +01:00
Ursprung 340beff8a5
Commit 72652d95f8
3 geänderte Dateien mit 44 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -578,8 +578,15 @@ SIMULATOR_TNT_SPAWN_POSITION_Z = §7z-Position §8- §e{0}
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH = §7Gezündet durch §8- §e{0} SIMULATOR_TNT_SPAWN_ACTIVATED_WITH = §7Gezündet durch §8- §e{0}
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR = Comparator SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR = Comparator
SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER = Repeater SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER = Repeater
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
SIMULATOR_TNT_SPAWN_MATERIAL_LORE_3 = §eRechts-Click §7Zum zurücksetzten
SIMULATOR_MATERIAL_GUI_NAME = Material ändern
SIMULATOR_MATERIAL_NAME = §e{0}
SIMULATOR_MATERIAL_CLICK = §eClicken zum wählen
SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE = §eZündphase hinzufügen SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE = §eZündphase hinzufügen
SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT = §eZündphase hinzufügen und +1 Tick Offset SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT = §eShift-Click§8: §7Zündphase hinzufügen und +1 Tick Offset
SIMULATOR_TNT_SPAWN_ADD_TNT = §eTNT hinzufügen SIMULATOR_TNT_SPAWN_ADD_TNT = §eTNT hinzufügen
SIMULATOR_TNT_SPAWN_REMOVE_TNT = §cEntfernen SIMULATOR_TNT_SPAWN_REMOVE_TNT = §cEntfernen
SIMULATOR_TNT_SPAWN_POSITION_ANVIL_GUI_NAME = Position SIMULATOR_TNT_SPAWN_POSITION_ANVIL_GUI_NAME = Position

Datei anzeigen

@ -63,6 +63,14 @@ public class TNTSimulator {
private static final World WORLD = Bukkit.getWorlds().get(0); private static final World WORLD = Bukkit.getWorlds().get(0);
private static final List<TNTSpawn> EMPTY = new ArrayList<>(); private static final List<TNTSpawn> EMPTY = new ArrayList<>();
private static final List<Material> MATERIALS = new ArrayList<>();
static {
Arrays.stream(Material.values())
.filter(Material::isItem)
.filter(material -> !material.isLegacy())
.forEach(MATERIALS::add);
}
public static ItemStack getWand(Player p) { public static ItemStack getWand(Player p) {
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p)), false, null).getItemStack(); ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p)), false, null).getItemStack();
ItemUtils.setItem(itemStack, "simulator"); ItemUtils.setItem(itemStack, "simulator");
@ -225,7 +233,7 @@ public class TNTSimulator {
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_4", player, spawn.position.getX())); lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_4", player, spawn.position.getX()));
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_5", player, spawn.position.getY())); lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_5", player, spawn.position.getY()));
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_6", player, spawn.position.getZ())); lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_LORE_6", player, spawn.position.getZ()));
SWItem swItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_NAME", player), lore, false, null); SWItem swItem = new SWItem(spawn.material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_NAME", player), lore, false, null);
swItem.getItemStack().setAmount(spawn.count); swItem.getItemStack().setAmount(spawn.count);
return new SWListInv.SWListEntry<>(swItem, spawn); return new SWListInv.SWListEntry<>(swItem, spawn);
}).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList()); }).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList());
@ -399,6 +407,7 @@ public class TNTSimulator {
private boolean yVelocity = false; private boolean yVelocity = false;
private boolean zVelocity = false; private boolean zVelocity = false;
private boolean comparator = false; private boolean comparator = false;
private Material material = Material.TNT;
private TNTSpawn(Vector position, AbstractSimulatorEntity entity) { private TNTSpawn(Vector position, AbstractSimulatorEntity entity) {
this.position = position; this.position = position;
@ -407,7 +416,6 @@ public class TNTSimulator {
editTNT(spawns); editTNT(spawns);
} }
// TODO: Add Material to UI!
private TNTSpawn(YAPIONObject yapionObject) { private TNTSpawn(YAPIONObject yapionObject) {
this.position = new Vector(yapionObject.getPlainValueOrDefault("positionX", 0.0), yapionObject.getPlainValueOrDefault("positionY", 0.0), yapionObject.getPlainValueOrDefault("positionZ", 0.0)); this.position = new Vector(yapionObject.getPlainValueOrDefault("positionX", 0.0), yapionObject.getPlainValueOrDefault("positionY", 0.0), yapionObject.getPlainValueOrDefault("positionZ", 0.0));
this.entity = SimulatorEntityShowMode.createEntity(player, position, false); this.entity = SimulatorEntityShowMode.createEntity(player, position, false);
@ -418,6 +426,7 @@ public class TNTSimulator {
this.yVelocity = yapionObject.getPlainValue("yVelocity"); this.yVelocity = yapionObject.getPlainValue("yVelocity");
this.zVelocity = yapionObject.getPlainValue("zVelocity"); this.zVelocity = yapionObject.getPlainValue("zVelocity");
this.comparator = yapionObject.getPlainValue("comparator"); this.comparator = yapionObject.getPlainValue("comparator");
this.material = Material.getMaterial(yapionObject.getPlainValueOrDefault("material", "TNT"));
} }
private YAPIONObject output() { private YAPIONObject output() {
@ -432,6 +441,7 @@ public class TNTSimulator {
yapionObject.add("yVelocity", yVelocity); yapionObject.add("yVelocity", yVelocity);
yapionObject.add("zVelocity", zVelocity); yapionObject.add("zVelocity", zVelocity);
yapionObject.add("comparator", comparator); yapionObject.add("comparator", comparator);
yapionObject.add("material", material.name());
return yapionObject; return yapionObject;
} }
@ -627,12 +637,30 @@ public class TNTSimulator {
comparator = !comparator; comparator = !comparator;
editTNT(tntSpawns); editTNT(tntSpawns);
})); }));
swInventory.setItem(41, new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_MATERIAL", player), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_MATERIAL_LORE_1", player, material.name().toLowerCase()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_MATERIAL_LORE_2", player), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_MATERIAL_LORE_3", player)), false, clickType -> {
if (clickType.isLeftClick()) {
List<SWListInv.SWListEntry<Material>> swListEntries = new ArrayList<>();
MATERIALS.forEach(current -> {
swListEntries.add(new SWListInv.SWListEntry<>(new SWItem(current, BauSystem.MESSAGE.parse("SIMULATOR_MATERIAL_NAME", player, current.name().toLowerCase()), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_MATERIAL_CLICK", player)), false, ignored -> {
}), current));
});
SWListInv<Material> swListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_MATERIAL_GUI_NAME", player), false, swListEntries, (invClickType, material) -> {
TNTSpawn.this.material = material;
editTNT(tntSpawns);
});
swListInv.open();
} else {
material = Material.TNT;
editTNT(tntSpawns);
}
}));
swInventory.setItem(33, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT", player)), false, clickType -> { swInventory.setItem(33, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT", player)), false, clickType -> {
TNTSpawn tntSpawn = new TNTSpawn(position, entity); TNTSpawn tntSpawn = new TNTSpawn(position, entity);
if (clickType.isShiftClick()) { if (clickType.isShiftClick()) {
tntSpawn.setTickOffset(tickOffset + 1); tntSpawn.setTickOffset(tickOffset + 1);
} }
tntSpawn.material = material;
spawns.add(tntSpawn); spawns.add(tntSpawn);
})); }));

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
@ -40,14 +41,17 @@ public class StopCommand extends SWCommand {
} }
@Register(description = "STOP_HELP") @Register(description = "STOP_HELP")
public void genericCommand(@Guard Player p) { public void genericCommand(@Guard CommandSender sender) {
SWUtils.message(current -> BauSystem.MESSAGE.parsePrefixed("STOP_MESSAGE", current)); SWUtils.message(current -> BauSystem.MESSAGE.parsePrefixed("STOP_MESSAGE", current));
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }
@ClassGuard(value = Player.class, local = true) @ClassGuard(value = CommandSender.class, local = true)
public GuardChecker stopGuard() { public GuardChecker stopGuard() {
return (commandSender, guardCheckType, strings, s) -> { return (commandSender, guardCheckType, strings, s) -> {
if (!(commandSender instanceof Player)) {
return GuardResult.ALLOWED;
}
Player player = (Player) commandSender; Player player = (Player) commandSender;
if (Permission.hasPermission(player, Permission.WORLD)) { if (Permission.hasPermission(player, Permission.WORLD)) {
return GuardResult.ALLOWED; return GuardResult.ALLOWED;