SteamWar/BauSystem2.0
Archiviert
12
0

Hotfix AttributesCopyCommand and AttributesPlaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-12-09 22:14:09 +01:00
Ursprung 6a52a319ab
Commit 3a28f5c42f
2 geänderte Dateien mit 10 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -63,7 +63,7 @@ public class AttributesCopyCommand extends SWCommand {
BlockData blockData = block.getBlockData(); BlockData blockData = block.getBlockData();
List<String> attributesToCopy = new ArrayList<>(); List<String> attributesToCopy = new ArrayList<>();
if (needsType(block)) { if (needsType(block)) {
attributesToCopy.add("§8-§7 type " + block.getType().name().toLowerCase()); attributesToCopy.add("§8-§7 material " + block.getType().name().toLowerCase());
} }
for (BlockAttribute blockAttribute : blockAttributeList) { for (BlockAttribute blockAttribute : blockAttributeList) {
if (blockAttribute.type().isInstance(blockData)) { if (blockAttribute.type().isInstance(blockData)) {

Datei anzeigen

@ -65,10 +65,16 @@ public class AttributesPlaceListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
Material material = strings.stream() Material material = strings.stream()
.filter(s -> s.startsWith("§8-§7 type ")) .filter(s -> s.startsWith("§8-§7 material "))
.map(s -> s.replace("§8-§7 type ", "")) .map(s -> s.replace("§8-§7 material ", ""))
.map(String::toUpperCase) .map(String::toUpperCase)
.map(Material::valueOf) .map(s -> {
try {
return Material.valueOf(s.toUpperCase());
} catch (Exception e) {
return null;
}
})
.findFirst() .findFirst()
.orElse(type); .orElse(type);
event.getBlock().setType(material, false); event.getBlock().setType(material, false);