SteamWar/BauSystem2.0
Archiviert
12
0

Add PowerableActivation
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-10-05 20:01:50 +02:00
Ursprung bd98713843
Commit af9b521115
22 geänderte Dateien mit 380 neuen und 63 gelöschten Zeilen

Datei anzeigen

@ -251,6 +251,18 @@ TRACE_SHOW_GUI_INTERPOLATE-XZ_ITEM = §eInterpolation §7XZ-Achse
TRACE_SHOW_GUI_INTERPOLATE-XZ_LORE1 = §7Zeigt die Interpolation TRACE_SHOW_GUI_INTERPOLATE-XZ_LORE1 = §7Zeigt die Interpolation
TRACE_SHOW_GUI_INTERPOLATE-XZ_LORE2 = §7auf der XZ-Achse. TRACE_SHOW_GUI_INTERPOLATE-XZ_LORE2 = §7auf der XZ-Achse.
TRACE_GUI_TITLE = Trace GUI
TRACE_GUI_ITEM_BACK = §eBack
TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT
TRACE_GUI_CLEAR = §eTraces löschen
TRACE_GUI_RECORD_ITEM = §eTNT §8- §e{0} §7Positionen
TRACE_GUI_RECORD_CLEAR = §eTNT löschen
TRACE_GUI_POSITION_ITEM = §ePosition
TRACE_GUI_POSITION_X = §7X§8: §e{0}
TRACE_GUI_POSITION_Y = §7Y§8: §e{0}
TRACE_GUI_POSITION_Z = §7Z§8: §e{0}
TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0}
# Loader # Loader
LOADER_OFF = §caus LOADER_OFF = §caus
LOADER_SETUP = §eSetup LOADER_SETUP = §eSetup

Datei anzeigen

@ -0,0 +1,54 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.slaves;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.RegionSelector;
import de.steamwar.bausystem.shared.Pair;
import lombok.experimental.UtilityClass;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@UtilityClass
public class WorldEditUtils {
public Pair<Location, Location> getSelection(Player player) {
RegionSelector regionSelector = WorldEdit.getInstance()
.getSessionManager()
.get(BukkitAdapter.adapt(player))
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
try {
BlockVector3 min = regionSelector.getRegion().getMinimumPoint();
BlockVector3 max = regionSelector.getRegion().getMaximumPoint();
return new Pair<>(adapt(player.getWorld(), min), adapt(player.getWorld(), max));
} catch (IncompleteRegionException e) {
return null;
}
}
private Location adapt(World world, BlockVector3 blockVector3) {
return new Location(world, blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
}
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern; package de.steamwar.bausystem.features.slaves.panzern;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -38,7 +38,7 @@ public class Panzern {
private static final BlockFace[] BLOCK_FACES = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN}; private static final BlockFace[] BLOCK_FACES = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN};
private Set<Location> current = new HashSet<>(); // Potenzielle geschwindigkeit durch `LinkedHashSet<>();` möchte aber lieber ein HashSet nehmen, weil dieses besser für mein Anwendungsfall ist private Set<Location> current = new LinkedHashSet<>(); // Potenzielle geschwindigkeit durch `LinkedHashSet<>();` möchte aber lieber ein HashSet nehmen, weil dieses besser für mein Anwendungsfall ist
private Set<Vector> emptyBlocks = new HashSet<>(); private Set<Vector> emptyBlocks = new HashSet<>();
private World world; private World world;

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern; package de.steamwar.bausystem.features.slaves.panzern;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;

Datei anzeigen

@ -17,26 +17,33 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern; package de.steamwar.bausystem.features.slaves.panzern;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.RegionSelector;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.slaves.WorldEditUtils;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Pair;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.block.data.type.Slab;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
public class PanzernCommand extends SWCommand { public class PanzernCommand extends SWCommand {
@ -52,7 +59,7 @@ public class PanzernCommand extends SWCommand {
return false; return false;
} }
@Register @Register(help = true)
public void genericHelp(Player player, String... args) { public void genericHelp(Player player, String... args) {
BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, "panzern"); BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, "panzern");
BauSystem.MESSAGE.send("PANZERN_HELP", player); BauSystem.MESSAGE.send("PANZERN_HELP", player);
@ -63,11 +70,11 @@ public class PanzernCommand extends SWCommand {
} }
@Register @Register
public void panzerSelection(Player player, Material blockMaterial, Material slabMaterial) { public void panzerSelection(Player player, @Mapper("block") Material blockMaterial, @Mapper("slab") Material slabMaterial) {
if (!permissionCheck(player, Permission.WORLDEDIT)) { if (!permissionCheck(player, Permission.WORLDEDIT)) {
return; return;
} }
Pair<Location, Location> selection = getSelection(player); Pair<Location, Location> selection = WorldEditUtils.getSelection(player);
if (selection == null) { if (selection == null) {
BauSystem.MESSAGE.send("PANZERN_NO_WORLDEDIT", player); BauSystem.MESSAGE.send("PANZERN_NO_WORLDEDIT", player);
return; return;
@ -98,22 +105,55 @@ public class PanzernCommand extends SWCommand {
}.runTaskTimer(BauSystem.getInstance(), 1, 1); }.runTaskTimer(BauSystem.getInstance(), 1, 1);
} }
private Pair<Location, Location> getSelection(Player player) { @Mapper(value = "block", local = true)
RegionSelector regionSelector = WorldEdit.getInstance() private TypeMapper<Material> blockMapper() {
.getSessionManager() Set<String> strings = new HashSet<>();
.get(BukkitAdapter.adapt(player)) for (Material material : Material.values()) {
.getRegionSelector(BukkitAdapter.adapt(player.getWorld())); if (!material.isBlock()) {
continue;
}
strings.add(material.name().toLowerCase());
}
return new TypeMapper<Material>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] ignored, String s) {
return new ArrayList<>(strings);
}
try { @Override
BlockVector3 min = regionSelector.getRegion().getMinimumPoint(); public Material map(CommandSender commandSender, String[] previousArguments, String s) {
BlockVector3 max = regionSelector.getRegion().getMaximumPoint(); if (strings.contains(s.toLowerCase())) {
return new Pair<>(adapt(player.getWorld(), min), adapt(player.getWorld(), max)); return Material.valueOf(s.toUpperCase());
} catch (IncompleteRegionException e) { }
return null; return null;
} }
};
} }
private Location adapt(World world, BlockVector3 blockVector3) { @Mapper(value = "slab", local = true)
return new Location(world, blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()); private TypeMapper<Material> slabMapper() {
Set<String> strings = new HashSet<>();
for (Material material : Material.values()) {
if (!material.isBlock()) {
continue;
}
if (material.name().contains("STAIRS") || material.name().contains("SLAB")) {
strings.add(material.name().toLowerCase());
}
}
return new TypeMapper<Material>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] ignored, String s) {
return new ArrayList<>(strings);
}
@Override
public Material map(CommandSender commandSender, String[] previousArguments, String s) {
if (strings.contains(s.toLowerCase())) {
return Material.valueOf(s.toUpperCase());
}
return null;
}
};
} }
} }

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern; package de.steamwar.bausystem.features.slaves.panzern;
public enum PanzernResult { public enum PanzernResult {
EMPTY, EMPTY,

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -0,0 +1,86 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.AnaloguePowerable;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.RedstoneWire;
import java.util.Map;
import java.util.Set;
@Linked(LinkageType.PANZERN)
public class PowerableActivation implements PanzernAlgorithm {
@Override
public PanzernResult check(Block source, Map<BlockFace, Block> adjacent, Set<Material> adjacentMaterials) {
int powered = 0;
int powerable = 0;
for (BlockFace blockFace : HORIZONTAL_FACES) {
if (!adjacent.containsKey(blockFace)) {
continue;
}
Block block = adjacent.get(blockFace);
if (block.getBlockData() instanceof Powerable || block.getBlockData() instanceof AnaloguePowerable && block.getType() != Material.OBSERVER) {
powerable++;
}
if (block.getType() == Material.TNT) {
powerable++;
}
switch (block.getType()) {
case REDSTONE_WIRE:
RedstoneWire redstoneWire = (RedstoneWire) block.getBlockData();
boolean dot = true;
for (BlockFace current : HORIZONTAL_FACES) {
dot &= redstoneWire.getFace(current) == RedstoneWire.Connection.NONE;
}
if (dot) {
powered++;
} else if (redstoneWire.getAllowedFaces().contains(blockFace)) {
if (redstoneWire.getFace(blockFace) == RedstoneWire.Connection.SIDE) {
powered++;
}
}
break;
case REPEATER:
case COMPARATOR:
case OBSERVER:
if (((Directional) block.getBlockData()).getFacing() == blockFace) {
powered++;
}
break;
default:
break;
}
}
if (powered <= 1 && powerable <= 1) {
return PanzernResult.DEFAULT;
}
return PanzernResult.SLAB;
}
}

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -17,15 +17,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Powerable;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -37,7 +38,17 @@ public class SlabOnTorch implements PanzernAlgorithm {
public PanzernResult check(Block source, Map<BlockFace, Block> adjacent, Set<Material> adjacentMaterials) { public PanzernResult check(Block source, Map<BlockFace, Block> adjacent, Set<Material> adjacentMaterials) {
boolean hasRedstone = false; boolean hasRedstone = false;
for (BlockFace blockFace : HORIZONTAL_FACES) { for (BlockFace blockFace : HORIZONTAL_FACES) {
if (adjacent.containsKey(blockFace) && adjacent.get(blockFace).getType() == Material.REDSTONE_WIRE) { if (!adjacent.containsKey(blockFace)) {
continue;
}
Block block = adjacent.get(blockFace);
if (block.getType() == Material.OBSERVER) {
continue;
}
if (block.getBlockData() instanceof Powerable) {
hasRedstone = true;
}
if (block.getType() == Material.TNT) {
hasRedstone = true; hasRedstone = true;
} }
} }

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.panzern.algorithms; package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.tracer.gui.TraceGui;
import de.steamwar.bausystem.features.tracer.gui.TraceShowGui; import de.steamwar.bausystem.features.tracer.gui.TraceShowGui;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
@ -92,15 +93,21 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_START", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_START", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_STOP", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_STOP", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_AUTO", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_AUTO", p);
// p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui"); p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_HIDE", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_HIDE", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_DELETE", p); BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_DELETE", p);
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); // p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
// p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an"); p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an");
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]"); // p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
} }
@Register({"gui"})
public void guiCommand(Player p) {
if (!permissionCheck(p)) return;
TraceGui.openGui(p);
}
@Register({"start"}) @Register({"start"})
public void startCommand(Player p) { public void startCommand(Player p) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;

Datei anzeigen

@ -0,0 +1,101 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tracer.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@UtilityClass
public class TraceGui {
public static void openGui(Player player) {
List<SWListInv.SWListEntry<Record>> recordList = new ArrayList<>();
StoredRecords.getRecords().forEach(record -> {
if (record.getTnt().isEmpty()) {
return;
}
SWItem swItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM", player, record.size()));
recordList.add(new SWListInv.SWListEntry<>(swItem, record));
});
SWListInv<Record> recordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, record) -> {
openRecordGui(player, record);
});
recordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> {
StoredRecords.clear();
player.getOpenInventory().close();
}));
recordSWListInv.setItem(50, new SWItem(Material.GLASS, "§e" + BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_TITLE", player), clickType -> {
TraceShowGui.openGui(player);
}));
recordSWListInv.open();
}
public static void openRecordGui(Player player, Record record) {
List<SWListInv.SWListEntry<Record.TNTRecord>> recordList = new ArrayList<>();
record.getTnt().forEach(tntRecord -> {
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()));
recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord));
});
SWListInv<Record.TNTRecord> tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> {
openTntGui(player, record, tntRecord);
});
tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> {
StoredRecords.getRecords().remove(record);
TraceShowManager.reshow();
openGui(player);
}));
tntRecordSWListInv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
openGui(player);
}));
// 48, 51
tntRecordSWListInv.open();
}
public static void openTntGui(Player player, Record record, Record.TNTRecord tntRecord) {
List<SWListInv.SWListEntry<TNTPosition>> positionList = new ArrayList<>();
tntRecord.getPositions().forEach(tntPosition -> {
SWItem swItem = new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_ITEM", player));
swItem.setLore(Arrays.asList(
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_X", player, tntPosition.getLocation().getX()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Y", player, tntPosition.getLocation().getY()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Z", player, tntPosition.getLocation().getZ()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_EXPLODED", player, tntPosition.isExploded())));
positionList.add(new SWListInv.SWListEntry<>(swItem, tntPosition));
});
SWListInv<TNTPosition> tntPositionSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, positionList, (clickType, tntPosition) -> {
});
tntPositionSWListInv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
openRecordGui(player, record);
}));
tntPositionSWListInv.open();
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.tracer.show;
import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,6 +31,8 @@ import java.util.List;
public class Record { public class Record {
private final long startTime; private final long startTime;
@Getter
private final List<TNTRecord> tnt = new ArrayList<>(); private final List<TNTRecord> tnt = new ArrayList<>();
public int size() { public int size() {
@ -62,6 +65,8 @@ public class Record {
} }
public static class TNTRecord { public static class TNTRecord {
@Getter
private final List<TNTPosition> positions = new ArrayList<>(41); private final List<TNTPosition> positions = new ArrayList<>(41);
public void showAll(ShowMode<TNTPosition> mode) { public void showAll(ShowMode<TNTPosition> mode) {
@ -88,9 +93,5 @@ public class Record {
public void explode(TNTPrimed tntPrimed) { public void explode(TNTPrimed tntPrimed) {
add(tntPrimed, true); add(tntPrimed, true);
} }
public List<TNTPosition> getPositions() {
return positions;
}
} }
} }

Datei anzeigen

@ -22,12 +22,14 @@ package de.steamwar.bausystem.features.tracer.show;
import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class StoredRecords { public class StoredRecords {
@Getter
private static final List<Record> records = new ArrayList<>(); private static final List<Record> records = new ArrayList<>();
public static void add(Record record) { public static void add(Record record) {

Datei anzeigen

@ -31,6 +31,11 @@ public class TraceShowManager implements Listener {
traceShowMode.hide(); traceShowMode.hide();
} }
public static void reshow() {
Map<Player, ShowMode<TNTPosition>> current = new HashMap<>(showModes);
current.forEach(TraceShowManager::show);
}
/* Only to be called by record */ /* Only to be called by record */
static void show(TNTPosition tnt) { static void show(TNTPosition tnt) {
for (ShowMode<TNTPosition> mode : showModes.values()) for (ShowMode<TNTPosition> mode : showModes.values())

Datei anzeigen

@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.ConfigConverter; import de.steamwar.bausystem.configplayer.ConfigConverter;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.gui.BauGUI; import de.steamwar.bausystem.features.gui.BauGUI;
import de.steamwar.bausystem.features.panzern.Panzern; import de.steamwar.bausystem.features.slaves.panzern.Panzern;
import de.steamwar.bausystem.features.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.linkage.specific.BauGuiItem;

Datei anzeigen

@ -19,8 +19,6 @@
package de.steamwar.bausystem.shared; package de.steamwar.bausystem.shared;
import de.steamwar.bausystem.shared.Position;
public interface ShowMode<T extends Position> { public interface ShowMode<T extends Position> {
void show(T position); void show(T position);