Hotfix RedstoneWireAttribute and RepeaterAttribute
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
6d298e1dec
Commit
e7e714f8ee
@ -96,6 +96,9 @@ public class AttributesCopyCommand extends SWCommand {
|
|||||||
if (itemStack.getType() == Material.DRAGON_HEAD && block.getType() == Material.DRAGON_WALL_HEAD) return true;
|
if (itemStack.getType() == Material.DRAGON_HEAD && block.getType() == Material.DRAGON_WALL_HEAD) return true;
|
||||||
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) return true;
|
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) return true;
|
||||||
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) return true;
|
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) return true;
|
||||||
|
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true;
|
||||||
|
if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
|
||||||
|
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.attributescopy;
|
package de.steamwar.bausystem.features.attributescopy;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -37,7 +40,7 @@ import static de.steamwar.bausystem.features.attributescopy.AttributesCopyComman
|
|||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MinVersion(18)
|
@MinVersion(18)
|
||||||
public class AttributesCopyListener implements Listener {
|
public class AttributesPlaceListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
@ -49,14 +52,19 @@ public class AttributesCopyListener implements Listener {
|
|||||||
if (strings == null) return;
|
if (strings == null) return;
|
||||||
if (strings.isEmpty()) return;
|
if (strings.isEmpty()) return;
|
||||||
if (!strings.get(0).equals("§eAttributes§8:")) return;
|
if (!strings.get(0).equals("§eAttributes§8:")) return;
|
||||||
Set<String> attributesToPaste = new HashSet<>(strings);
|
Material type = event.getBlock().getType();
|
||||||
Block block = event.getBlock();
|
event.setCancelled(true);
|
||||||
BlockData blockData = block.getBlockData();
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
event.getBlock().setType(type, false);
|
||||||
if (blockAttribute.type().isInstance(blockData)) {
|
Set<String> attributesToPaste = new HashSet<>(strings);
|
||||||
blockAttribute.paste(attributesToPaste, blockData);
|
Block block = event.getBlock();
|
||||||
|
BlockData blockData = block.getBlockData();
|
||||||
|
for (BlockAttribute blockAttribute : blockAttributeList) {
|
||||||
|
if (blockAttribute.type().isInstance(blockData)) {
|
||||||
|
blockAttribute.paste(attributesToPaste, blockData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
block.setBlockData(blockData, false);
|
||||||
block.setBlockData(blockData, false);
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,10 +40,7 @@ public class RedstoneWireAttribute implements BlockAttribute<RedstoneWire> {
|
|||||||
@Override
|
@Override
|
||||||
public void copy(List<String> attributes, RedstoneWire blockData) {
|
public void copy(List<String> attributes, RedstoneWire blockData) {
|
||||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
||||||
RedstoneWire.Connection connection = blockData.getFace(blockFace);
|
attributes.add(attribute + blockFace.name().toLowerCase() + " " + blockData.getFace(blockFace).name().toLowerCase());
|
||||||
if (connection != RedstoneWire.Connection.NONE) {
|
|
||||||
attributes.add(attribute + blockFace.name().toLowerCase() + " " + connection.name().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ import java.util.Set;
|
|||||||
@Linked
|
@Linked
|
||||||
public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
||||||
|
|
||||||
private String attribute = "§8-§7 delay ";
|
private String attribute1 = "§8-§7 delay ";
|
||||||
|
private String attribute2 = "§8-§7 locked";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Repeater> type() {
|
public Class<Repeater> type() {
|
||||||
@ -38,16 +39,18 @@ public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copy(List<String> attributes, Repeater blockData) {
|
public void copy(List<String> attributes, Repeater blockData) {
|
||||||
attributes.add(attribute + blockData.getDelay());
|
attributes.add(attribute1 + blockData.getDelay());
|
||||||
|
if (blockData.isLocked()) attributes.add(attribute2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Set<String> attributes, Repeater blockData) {
|
public void paste(Set<String> attributes, Repeater blockData) {
|
||||||
attributes.stream()
|
attributes.stream()
|
||||||
.filter(s -> s.startsWith(attribute))
|
.filter(s -> s.startsWith(attribute1))
|
||||||
.map(s -> s.replace(attribute, ""))
|
.map(s -> s.replace(attribute1, ""))
|
||||||
.map(Integer::parseInt)
|
.map(Integer::parseInt)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(blockData::setDelay);
|
.ifPresent(blockData::setDelay);
|
||||||
|
blockData.setLocked(attributes.contains(attribute2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren