Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
11593c6aa8
Commit
1352b5eab7
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.linkage.types;
|
|
||||||
|
|
||||||
import de.steamwar.linkage.LinkageType;
|
|
||||||
import de.steamwar.linkage.plan.BuildPlan;
|
|
||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
|
||||||
|
|
||||||
public class BlockAttribute_GENERIC implements LinkageType {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String method() {
|
|
||||||
return "linkBlockAttributes";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
|
||||||
buildPlan.addImport("de.steamwar.bausystem.features.attributescopy.*");
|
|
||||||
methodBuilder.addLine("AttributesCopyCommand.add(" + s + ");");
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,7 +36,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MinVersion(18)
|
|
||||||
public class AttributeRemoveCommand extends SWCommand {
|
public class AttributeRemoveCommand extends SWCommand {
|
||||||
|
|
||||||
public AttributeRemoveCommand() {
|
public AttributeRemoveCommand() {
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 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.attributescopy;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class AttributeUtils {
|
||||||
|
|
||||||
|
private Map<Method, String> names = new HashMap<>();
|
||||||
|
private Map<Class<?>, List<Method>> getters = new HashMap<>();
|
||||||
|
private Map<Class<?>, Map<String, Method>> setters = new HashMap<>();
|
||||||
|
|
||||||
|
private void generate(BlockData blockData) {
|
||||||
|
Class<? extends BlockData> clazz = blockData.getClass();
|
||||||
|
if (getters.containsKey(clazz) && setters.containsKey(clazz)) return;
|
||||||
|
|
||||||
|
Map<String, List<Method>> methods = new HashMap<>();
|
||||||
|
for (Method declaredMethod : clazz.getMethods()) {
|
||||||
|
String s = declaredMethod.getName();
|
||||||
|
if (s.startsWith("get") && declaredMethod.getParameterCount() == 0) {
|
||||||
|
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||||
|
} else if (s.startsWith("is") && declaredMethod.getParameterCount() == 0) {
|
||||||
|
methods.computeIfAbsent(s.substring(2), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||||
|
} else if (s.startsWith("set") && declaredMethod.getParameterCount() == 1) {
|
||||||
|
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, List<Method>> entry : methods.entrySet()) {
|
||||||
|
if (entry.getValue().size() != 2) continue;
|
||||||
|
for (Method method : entry.getValue()) {
|
||||||
|
names.put(method, entry.getKey());
|
||||||
|
if (method.getName().startsWith("is") || method.getName().startsWith("get")) {
|
||||||
|
getters.computeIfAbsent(clazz, aClass -> new ArrayList<>()).add(method);
|
||||||
|
} else {
|
||||||
|
setters.computeIfAbsent(clazz, aClass -> new HashMap<>()).put(entry.getKey(), method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copy(BlockData blockData, List<String> attributes) {
|
||||||
|
generate(blockData);
|
||||||
|
|
||||||
|
getters.getOrDefault(blockData.getClass(), new ArrayList<>()).forEach(method -> {
|
||||||
|
try {
|
||||||
|
Object invoke = method.invoke(blockData);
|
||||||
|
if (invoke != null) {
|
||||||
|
attributes.add("§8-§7 " + names.get(method) + "§8:§7 " + convert(invoke));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paste(BlockData blockData, List<String> attributes) {
|
||||||
|
generate(blockData);
|
||||||
|
|
||||||
|
for (String attribute : attributes) {
|
||||||
|
String[] split = attribute.split("§8:§7 ");
|
||||||
|
if (split.length != 2) continue;
|
||||||
|
String name = split[0].substring(6);
|
||||||
|
String value = split[1];
|
||||||
|
Method method = setters.getOrDefault(blockData.getClass(), new HashMap<>()).get(name);
|
||||||
|
if (method == null) continue;
|
||||||
|
try {
|
||||||
|
method.invoke(blockData, convert(value, method.getParameterTypes()[0]));
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String convert(Object o) {
|
||||||
|
if (o.getClass().isEnum()) {
|
||||||
|
return ((Enum<?>) o).name();
|
||||||
|
} else {
|
||||||
|
return o.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object convert(String s, Class<?> type) {
|
||||||
|
if (type.isEnum()) {
|
||||||
|
return Enum.valueOf((Class<? extends Enum>) type, s);
|
||||||
|
} else if (type == int.class || type == Integer.class) {
|
||||||
|
return Integer.parseInt(s);
|
||||||
|
} else if (type == double.class || type == Double.class) {
|
||||||
|
return Double.parseDouble(s);
|
||||||
|
} else if (type == float.class || type == Float.class) {
|
||||||
|
return Float.parseFloat(s);
|
||||||
|
} else if (type == long.class || type == Long.class) {
|
||||||
|
return Long.parseLong(s);
|
||||||
|
} else if (type == short.class || type == Short.class) {
|
||||||
|
return Short.parseShort(s);
|
||||||
|
} else if (type == byte.class || type == Byte.class) {
|
||||||
|
return Byte.parseByte(s);
|
||||||
|
} else if (type == boolean.class || type == Boolean.class) {
|
||||||
|
return Boolean.parseBoolean(s);
|
||||||
|
} else {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,10 +20,8 @@
|
|||||||
package de.steamwar.bausystem.features.attributescopy;
|
package de.steamwar.bausystem.features.attributescopy;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -36,40 +34,29 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MinVersion(18)
|
|
||||||
public class AttributesCopyCommand extends SWCommand {
|
public class AttributesCopyCommand extends SWCommand {
|
||||||
|
|
||||||
static List<BlockAttribute<?>> blockAttributeList = new ArrayList<>();
|
|
||||||
|
|
||||||
public static void add(BlockAttribute<?> blockAttribute) {
|
|
||||||
blockAttributeList.add(blockAttribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttributesCopyCommand() {
|
public AttributesCopyCommand() {
|
||||||
super("copyattributes", "attributescopy", "ac");
|
super("copyattributes", "attributescopy", "ac");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player player) {
|
public void genericCommand(Player player) {
|
||||||
linkIfNeeded();
|
|
||||||
|
|
||||||
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
||||||
if (block == null) return;
|
if (block == null) return;
|
||||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||||
if (!isSame(block, mainHand)) {
|
|
||||||
|
if (!(block.getType().isItem() && block.getType() == mainHand.getType() || isSame(block, mainHand))) {
|
||||||
BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player);
|
BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockData blockData = block.getBlockData();
|
BlockData blockData = block.getBlockData();
|
||||||
List<String> attributesToCopy = new ArrayList<>();
|
List<String> attributesToCopy = new ArrayList<>();
|
||||||
if (needsType(block)) {
|
if (block.getType() != mainHand.getType()) {
|
||||||
attributesToCopy.add("§8-§7 material " + block.getType().name().toLowerCase());
|
attributesToCopy.add("§8-§7 Material§8:§7 " + block.getType().name());
|
||||||
}
|
|
||||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
|
||||||
if (blockAttribute.type().isInstance(blockData)) {
|
|
||||||
blockAttribute.copy(attributesToCopy, blockData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
AttributeUtils.copy(blockData, attributesToCopy);
|
||||||
if (attributesToCopy.isEmpty()) {
|
if (attributesToCopy.isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("ATTRIBUTES_NO_COPY", player);
|
BauSystem.MESSAGE.send("ATTRIBUTES_NO_COPY", player);
|
||||||
return;
|
return;
|
||||||
@ -83,15 +70,7 @@ public class AttributesCopyCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("ATTRIBUTES_COPIED", player);
|
BauSystem.MESSAGE.send("ATTRIBUTES_COPIED", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLinked = false;
|
|
||||||
static void linkIfNeeded() {
|
|
||||||
if (isLinked) return;
|
|
||||||
LinkageUtils.linkBlockAttributes();
|
|
||||||
isLinked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSame(Block block, ItemStack itemStack) {
|
private boolean isSame(Block block, ItemStack itemStack) {
|
||||||
if (block.getType() == itemStack.getType()) return true;
|
|
||||||
if (itemStack.getType() == Material.REDSTONE && block.getType() == Material.REDSTONE_WIRE) return true;
|
if (itemStack.getType() == Material.REDSTONE && block.getType() == Material.REDSTONE_WIRE) return true;
|
||||||
if (itemStack.getType() == Material.PLAYER_HEAD && block.getType() == Material.PLAYER_WALL_HEAD) return true;
|
if (itemStack.getType() == Material.PLAYER_HEAD && block.getType() == Material.PLAYER_WALL_HEAD) return true;
|
||||||
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
|
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
|
||||||
@ -102,22 +81,8 @@ public class AttributesCopyCommand extends SWCommand {
|
|||||||
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) 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() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
|
||||||
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
|
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
|
||||||
|
if (itemStack.getType() == Material.WHEAT_SEEDS && block.getType() == Material.WHEAT) return true;
|
||||||
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean needsType(Block block) {
|
|
||||||
if (block.getType().name().contains("WALL")) return true;
|
|
||||||
if (block.getType() == Material.PLAYER_HEAD) return true;
|
|
||||||
if (block.getType() == Material.ZOMBIE_HEAD) return true;
|
|
||||||
if (block.getType() == Material.CREEPER_HEAD) return true;
|
|
||||||
if (block.getType() == Material.DRAGON_HEAD) return true;
|
|
||||||
if (block.getType() == Material.SKELETON_SKULL) return true;
|
|
||||||
if (block.getType() == Material.WITHER_SKELETON_SKULL) return true;
|
|
||||||
if (block.getType() == Material.TORCH) return true;
|
|
||||||
if (block.getType() == Material.SOUL_TORCH) return true;
|
|
||||||
if (block.getType() == Material.REDSTONE_TORCH) return true;
|
|
||||||
if (block.getType().name().contains("_BANNER")) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.attributescopy;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -34,19 +33,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static de.steamwar.bausystem.features.attributescopy.AttributesCopyCommand.blockAttributeList;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MinVersion(18)
|
|
||||||
public class AttributesPlaceListener implements Listener {
|
public class AttributesPlaceListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
AttributesCopyCommand.linkIfNeeded();
|
|
||||||
ItemStack itemStack = event.getItemInHand();
|
ItemStack itemStack = event.getItemInHand();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
if (itemMeta == null) return;
|
if (itemMeta == null) return;
|
||||||
@ -64,12 +57,12 @@ 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 material "))
|
.filter(s -> s.startsWith("§8-§7 Material§8:§7 "))
|
||||||
.map(s -> s.replace("§8-§7 material ", ""))
|
.map(s -> s.replace("§8-§7 Material§8:§7 ", ""))
|
||||||
.map(String::toUpperCase)
|
.map(String::toUpperCase)
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
try {
|
try {
|
||||||
return Material.valueOf(s.toUpperCase());
|
return Material.valueOf(s);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -77,7 +70,6 @@ public class AttributesPlaceListener implements Listener {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(type);
|
.orElse(type);
|
||||||
event.getBlock().setType(material, false);
|
event.getBlock().setType(material, false);
|
||||||
Set<String> attributesToPaste = new HashSet<>(strings);
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
BlockData blockData = block.getBlockData();
|
BlockData blockData = block.getBlockData();
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
@ -87,11 +79,7 @@ public class AttributesPlaceListener implements Listener {
|
|||||||
skull.update(true, false);
|
skull.update(true, false);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
AttributeUtils.paste(blockData, strings);
|
||||||
if (blockAttribute.type().isInstance(blockData)) {
|
|
||||||
blockAttribute.paste(attributesToPaste, blockData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
block.setBlockData(blockData, false);
|
block.setBlockData(blockData, false);
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy;
|
|
||||||
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface BlockAttribute<T extends BlockData> {
|
|
||||||
Class<T> type();
|
|
||||||
void copy(List<String> attributes, T blockData);
|
|
||||||
void paste(Set<String> attributes, T blockData);
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Ageable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class AgeableAttribute implements BlockAttribute<Ageable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 age ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Ageable> type() {
|
|
||||||
return Ageable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Ageable blockData) {
|
|
||||||
attributes.add(attribute + blockData.getAge());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Ageable blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setAge);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.AnaloguePowerable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class AnaloguePowerableAttribute implements BlockAttribute<AnaloguePowerable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 power ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<AnaloguePowerable> type() {
|
|
||||||
return AnaloguePowerable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, AnaloguePowerable blockData) {
|
|
||||||
attributes.add(attribute + blockData.getPower());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, AnaloguePowerable blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setPower);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Attachable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class AttachableAttribute implements BlockAttribute<Attachable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 attached";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Attachable> type() {
|
|
||||||
return Attachable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Attachable blockData) {
|
|
||||||
if (blockData.isAttached()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Attachable blockData) {
|
|
||||||
blockData.setAttached(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Bisected;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class BisectedAttribute implements BlockAttribute<Bisected> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 half ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Bisected> type() {
|
|
||||||
return Bisected.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Bisected blockData) {
|
|
||||||
attributes.add(attribute + blockData.getHalf().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Bisected blockData) {
|
|
||||||
for (Bisected.Half half : Bisected.Half.values()) {
|
|
||||||
if (attributes.contains(attribute + half.name().toLowerCase())) {
|
|
||||||
blockData.setHalf(half);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.Directional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DirectionalAttribute implements BlockAttribute<Directional> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 facing ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Directional> type() {
|
|
||||||
return Directional.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Directional blockData) {
|
|
||||||
attributes.add(attribute + blockData.getFacing().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Directional blockData) {
|
|
||||||
for (BlockFace blockFace : blockData.getFaces()) {
|
|
||||||
if (attributes.contains(attribute + blockFace.name().toLowerCase())) {
|
|
||||||
blockData.setFacing(blockFace);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.FaceAttachable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class FaceAttachableAttribute implements BlockAttribute<FaceAttachable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 attached ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<FaceAttachable> type() {
|
|
||||||
return FaceAttachable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, FaceAttachable blockData) {
|
|
||||||
attributes.add(attribute + blockData.getAttachedFace().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, FaceAttachable blockData) {
|
|
||||||
for (FaceAttachable.AttachedFace attachedFace : FaceAttachable.AttachedFace.values()) {
|
|
||||||
if (attributes.contains(attribute + attachedFace.name().toLowerCase())) {
|
|
||||||
blockData.setAttachedFace(attachedFace);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.block.data.Hangable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
@MinVersion(19)
|
|
||||||
public class HangableAttribute implements BlockAttribute<Hangable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 hanging";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Hangable> type() {
|
|
||||||
return Hangable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Hangable blockData) {
|
|
||||||
if (!blockData.isHanging()) return;
|
|
||||||
attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Hangable blockData) {
|
|
||||||
blockData.setHanging(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Levelled;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class LevelledAttribute implements BlockAttribute<Levelled> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 level ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Levelled> type() {
|
|
||||||
return Levelled.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Levelled blockData) {
|
|
||||||
attributes.add(attribute + blockData.getLevel());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Levelled blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setLevel);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Lightable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class LightableAttribute implements BlockAttribute<Lightable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 lit";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Lightable> type() {
|
|
||||||
return Lightable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Lightable blockData) {
|
|
||||||
if (blockData.isLit()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Lightable blockData) {
|
|
||||||
blockData.setLit(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.MultipleFacing;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class MultipleFacingAttribute implements BlockAttribute<MultipleFacing> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 connected ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<MultipleFacing> type() {
|
|
||||||
return MultipleFacing.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, MultipleFacing blockData) {
|
|
||||||
blockData.getFaces().forEach(blockFace -> {
|
|
||||||
attributes.add(attribute + blockFace.name().toLowerCase());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, MultipleFacing blockData) {
|
|
||||||
for (BlockFace blockFace : BlockFace.values()) {
|
|
||||||
blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Openable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class OpenableAttribute implements BlockAttribute<Openable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 open";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Openable> type() {
|
|
||||||
return Openable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Openable blockData) {
|
|
||||||
if (blockData.isOpen()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Openable blockData) {
|
|
||||||
blockData.setOpen(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.Axis;
|
|
||||||
import org.bukkit.block.data.Orientable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class OrientableAttribute implements BlockAttribute<Orientable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 orientation ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Orientable> type() {
|
|
||||||
return Orientable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Orientable blockData) {
|
|
||||||
attributes.add(attribute + blockData.getAxis().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Orientable blockData) {
|
|
||||||
for (Axis axis : Axis.values()) {
|
|
||||||
if (attributes.contains(attribute + axis.name().toLowerCase())) {
|
|
||||||
blockData.setAxis(axis);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Powerable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class PowerableAttribute implements BlockAttribute<Powerable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 powered";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Powerable> type() {
|
|
||||||
return Powerable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Powerable blockData) {
|
|
||||||
if (blockData.isPowered()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Powerable blockData) {
|
|
||||||
blockData.setPowered(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Rail;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class RailAttribute implements BlockAttribute<Rail> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 rail shape ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Rail> type() {
|
|
||||||
return Rail.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Rail blockData) {
|
|
||||||
attributes.add(attribute + blockData.getShape().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Rail blockData) {
|
|
||||||
for (Rail.Shape shape : Rail.Shape.values()) {
|
|
||||||
if (attributes.contains(attribute + shape)) {
|
|
||||||
blockData.setShape(shape);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.Rotatable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class RotatableAttribute implements BlockAttribute<Rotatable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 rotation ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Rotatable> type() {
|
|
||||||
return Rotatable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Rotatable blockData) {
|
|
||||||
attributes.add(attribute + blockData.getRotation().name());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Rotatable blockData) {
|
|
||||||
for (BlockFace face : BlockFace.values()) {
|
|
||||||
if (attributes.contains(attribute + face.name())) {
|
|
||||||
blockData.setRotation(face);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Snowable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SnowableAttribute implements BlockAttribute<Snowable> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 snowy";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Snowable> type() {
|
|
||||||
return Snowable.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Snowable blockData) {
|
|
||||||
if (blockData.isSnowy()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Snowable blockData) {
|
|
||||||
blockData.setSnowy(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.Waterlogged;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class WaterloggedAttribute implements BlockAttribute<Waterlogged> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 waterlogged";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Waterlogged> type() {
|
|
||||||
return Waterlogged.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Waterlogged waterlogged) {
|
|
||||||
if (!waterlogged.isWaterlogged()) return;
|
|
||||||
attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Waterlogged waterlogged) {
|
|
||||||
waterlogged.setWaterlogged(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Bamboo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class BambooAttribute implements BlockAttribute<Bamboo> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 leaves ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Bamboo> type() {
|
|
||||||
return Bamboo.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Bamboo blockData) {
|
|
||||||
attributes.add(attribute + blockData.getLeaves());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Bamboo blockData) {
|
|
||||||
for (Bamboo.Leaves leaves : Bamboo.Leaves.values()) {
|
|
||||||
if (attributes.contains(attribute + leaves)) {
|
|
||||||
blockData.setLeaves(leaves);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Bell;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class BellAttribute implements BlockAttribute<Bell> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 attachament ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Bell> type() {
|
|
||||||
return Bell.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Bell blockData) {
|
|
||||||
attributes.add(attribute + blockData.getAttachment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Bell blockData) {
|
|
||||||
for (Bell.Attachment attachment : Bell.Attachment.values()) {
|
|
||||||
if (attributes.contains(attribute + attachment)) {
|
|
||||||
blockData.setAttachment(attachment);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.block.data.type.BigDripleaf;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
@MinVersion(18)
|
|
||||||
public class BigDripleafAttribute implements BlockAttribute<BigDripleaf> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 tilt ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<BigDripleaf> type() {
|
|
||||||
return BigDripleaf.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, BigDripleaf blockData) {
|
|
||||||
attributes.add(attribute + blockData.getTilt());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, BigDripleaf blockData) {
|
|
||||||
for (BigDripleaf.Tilt tilt : BigDripleaf.Tilt.values()) {
|
|
||||||
if (attributes.contains(attribute + tilt)) {
|
|
||||||
blockData.setTilt(tilt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Cake;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class CakeAttribute implements BlockAttribute<Cake> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 bites ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Cake> type() {
|
|
||||||
return Cake.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Cake blockData) {
|
|
||||||
attributes.add(attribute + blockData.getBites());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Cake blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setBites);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Campfire;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class CampfireAttribute implements BlockAttribute<Campfire> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 signal fire";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Campfire> type() {
|
|
||||||
return Campfire.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Campfire blockData) {
|
|
||||||
if (blockData.isSignalFire()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Campfire blockData) {
|
|
||||||
blockData.setSignalFire(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Candle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class CandleAttribute implements BlockAttribute<Candle> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 candles ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Candle> type() {
|
|
||||||
return Candle.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Candle blockData) {
|
|
||||||
if (blockData.getCandles() > 0) attributes.add(attribute + blockData.getCandles());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Candle blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setCandles);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.CaveVinesPlant;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class CaveVinesPlantAttribute implements BlockAttribute<CaveVinesPlant> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 berries";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<CaveVinesPlant> type() {
|
|
||||||
return CaveVinesPlant.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, CaveVinesPlant blockData) {
|
|
||||||
if (blockData.isBerries()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, CaveVinesPlant blockData) {
|
|
||||||
blockData.setBerries(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Comparator;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class ComparatorAttribute implements BlockAttribute<Comparator> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 mode ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Comparator> type() {
|
|
||||||
return Comparator.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Comparator blockData) {
|
|
||||||
attributes.add(attribute + blockData.getMode().name());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Comparator blockData) {
|
|
||||||
for (Comparator.Mode mode : Comparator.Mode.values()) {
|
|
||||||
if (attributes.contains(attribute + mode.name())) {
|
|
||||||
blockData.setMode(mode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.DaylightDetector;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DaylightDetectorAttribute implements BlockAttribute<DaylightDetector> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 inverted";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<DaylightDetector> type() {
|
|
||||||
return DaylightDetector.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, DaylightDetector blockData) {
|
|
||||||
if (blockData.isInverted()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, DaylightDetector blockData) {
|
|
||||||
blockData.setInverted(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Door;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DoorAttribute implements BlockAttribute<Door> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 hinge ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Door> type() {
|
|
||||||
return Door.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Door blockData) {
|
|
||||||
attributes.add(attribute + blockData.getHinge().toString().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Door blockData) {
|
|
||||||
for (Door.Hinge hinge : Door.Hinge.values()) {
|
|
||||||
if (attributes.contains(attribute + hinge.toString().toLowerCase())) {
|
|
||||||
blockData.setHinge(hinge);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.EndPortalFrame;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class EndPortalFrameAttribute implements BlockAttribute<EndPortalFrame> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 eye";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<EndPortalFrame> type() {
|
|
||||||
return EndPortalFrame.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, EndPortalFrame blockData) {
|
|
||||||
if (blockData.hasEye()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, EndPortalFrame blockData) {
|
|
||||||
blockData.setEye(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Farmland;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class FarmlandAttribute implements BlockAttribute<Farmland> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 moisture ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Farmland> type() {
|
|
||||||
return Farmland.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Farmland blockData) {
|
|
||||||
attributes.add(attribute + blockData.getMoisture());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Farmland blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setMoisture);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Gate;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class GateAttribute implements BlockAttribute<Gate> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 inWall";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Gate> type() {
|
|
||||||
return Gate.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Gate blockData) {
|
|
||||||
if (blockData.isInWall()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Gate blockData) {
|
|
||||||
blockData.setInWall(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Hopper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class HopperAttribute implements BlockAttribute<Hopper> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 enabled";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Hopper> type() {
|
|
||||||
return Hopper.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Hopper blockData) {
|
|
||||||
if (blockData.isEnabled()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Hopper blockData) {
|
|
||||||
blockData.setEnabled(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Jigsaw;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class JigsawAttribute implements BlockAttribute<Jigsaw> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 orientation ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Jigsaw> type() {
|
|
||||||
return Jigsaw.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Jigsaw blockData) {
|
|
||||||
attributes.add(attribute + blockData.getOrientation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Jigsaw blockData) {
|
|
||||||
for (Jigsaw.Orientation orientation : Jigsaw.Orientation.values()) {
|
|
||||||
if (attributes.contains(attribute + orientation)) {
|
|
||||||
blockData.setOrientation(orientation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Lantern;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class LanternAttribute implements BlockAttribute<Lantern> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 lantern";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Lantern> type() {
|
|
||||||
return Lantern.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Lantern lantern) {
|
|
||||||
if (!lantern.isHanging()) return;
|
|
||||||
attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Lantern lantern) {
|
|
||||||
lantern.setHanging(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Leaves;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class LeavesAttribute implements BlockAttribute<Leaves> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 persistent";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Leaves> type() {
|
|
||||||
return Leaves.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Leaves blockData) {
|
|
||||||
if (blockData.isPersistent()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Leaves blockData) {
|
|
||||||
blockData.setPersistent(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.type.PointedDripstone;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class PointedDripstoneAttribute implements BlockAttribute<PointedDripstone> {
|
|
||||||
|
|
||||||
private String attribute1 = "§8-§7 vertialDirection ";
|
|
||||||
private String attribute2 = "§8-§7 thickness ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<PointedDripstone> type() {
|
|
||||||
return PointedDripstone.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, PointedDripstone blockData) {
|
|
||||||
attributes.add(attribute1 + " " + blockData.getVerticalDirection().name().toLowerCase());
|
|
||||||
attributes.add(attribute2 + " " + blockData.getThickness().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, PointedDripstone blockData) {
|
|
||||||
for (BlockFace blockFace : blockData.getVerticalDirections()) {
|
|
||||||
if (attributes.contains(attribute1 + " " + blockFace.name().toLowerCase())) {
|
|
||||||
blockData.setVerticalDirection(blockFace);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (PointedDripstone.Thickness thickness : PointedDripstone.Thickness.values()) {
|
|
||||||
if (attributes.contains(attribute2 + " " + thickness.name().toLowerCase())) {
|
|
||||||
blockData.setThickness(thickness);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.type.RedstoneWire;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class RedstoneWireAttribute implements BlockAttribute<RedstoneWire> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 connection ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<RedstoneWire> type() {
|
|
||||||
return RedstoneWire.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, RedstoneWire blockData) {
|
|
||||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
|
||||||
attributes.add(attribute + blockFace.name().toLowerCase() + " " + blockData.getFace(blockFace).name().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, RedstoneWire blockData) {
|
|
||||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
|
||||||
for (RedstoneWire.Connection connection : RedstoneWire.Connection.values()) {
|
|
||||||
if (attributes.contains(attribute + blockFace.name().toLowerCase() + " " + connection.name().toLowerCase())) {
|
|
||||||
blockData.setFace(blockFace, connection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Repeater;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
|
||||||
|
|
||||||
private String attribute1 = "§8-§7 delay ";
|
|
||||||
private String attribute2 = "§8-§7 locked";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Repeater> type() {
|
|
||||||
return Repeater.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Repeater blockData) {
|
|
||||||
attributes.add(attribute1 + blockData.getDelay());
|
|
||||||
if (blockData.isLocked()) attributes.add(attribute2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Repeater blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute1))
|
|
||||||
.map(s -> s.replace(attribute1, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setDelay);
|
|
||||||
blockData.setLocked(attributes.contains(attribute2));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.RespawnAnchor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class RespawnAnchorAttribute implements BlockAttribute<RespawnAnchor> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 charges ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<RespawnAnchor> type() {
|
|
||||||
return RespawnAnchor.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, RespawnAnchor blockData) {
|
|
||||||
attributes.add(attribute + blockData.getCharges());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, RespawnAnchor blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setCharges);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Sapling;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SaplingAttribute implements BlockAttribute<Sapling> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 stage ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Sapling> type() {
|
|
||||||
return Sapling.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Sapling blockData) {
|
|
||||||
attributes.add(attribute + blockData.getStage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Sapling blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setStage);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Scaffolding;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class ScaffoldingAttribute implements BlockAttribute<Scaffolding> {
|
|
||||||
|
|
||||||
private String attribute1 = "§8-§7 bottom";
|
|
||||||
private String attribute2 = "§8-§7 distance ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Scaffolding> type() {
|
|
||||||
return Scaffolding.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Scaffolding blockData) {
|
|
||||||
if (blockData.isBottom()) attributes.add(attribute1);
|
|
||||||
attributes.add(attribute2 + blockData.getDistance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Scaffolding blockData) {
|
|
||||||
blockData.setBottom(attributes.contains(attribute1));
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute2))
|
|
||||||
.map(s -> s.replace(attribute2, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setDistance);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.SculkSensor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SculkSensorAttribute implements BlockAttribute<SculkSensor> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 phase ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<SculkSensor> type() {
|
|
||||||
return SculkSensor.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, SculkSensor blockData) {
|
|
||||||
attributes.add(attribute + blockData.getPhase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, SculkSensor blockData) {
|
|
||||||
for (SculkSensor.Phase phase : SculkSensor.Phase.values()) {
|
|
||||||
if (attributes.contains(attribute + phase)) {
|
|
||||||
blockData.setPhase(phase);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.SeaPickle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SeaPickleAttribute implements BlockAttribute<SeaPickle> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 pickles ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<SeaPickle> type() {
|
|
||||||
return SeaPickle.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, SeaPickle blockData) {
|
|
||||||
attributes.add(attribute + blockData.getPickles());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, SeaPickle blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setPickles);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Slab;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SlabAttribute implements BlockAttribute<Slab> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 type ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Slab> type() {
|
|
||||||
return Slab.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Slab blockData) {
|
|
||||||
attributes.add(attribute + blockData.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Slab blockData) {
|
|
||||||
for (Slab.Type type : Slab.Type.values()) {
|
|
||||||
if (attributes.contains(attribute + type)) {
|
|
||||||
blockData.setType(type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Snow;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SnowAttribute implements BlockAttribute<Snow> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 layers ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Snow> type() {
|
|
||||||
return Snow.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Snow blockData) {
|
|
||||||
attributes.add(attribute + blockData.getLayers());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Snow blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute))
|
|
||||||
.map(s -> s.replace(attribute, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setLayers);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Stairs;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class StairsAttribute implements BlockAttribute<Stairs> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 shape ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Stairs> type() {
|
|
||||||
return Stairs.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Stairs blockData) {
|
|
||||||
attributes.add(attribute + blockData.getShape().name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Stairs blockData) {
|
|
||||||
for (Stairs.Shape shape : Stairs.Shape.values()) {
|
|
||||||
if (attributes.contains(attribute + shape.name().toLowerCase())) {
|
|
||||||
blockData.setShape(shape);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.StructureBlock;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class StructureBlockAttribute implements BlockAttribute<StructureBlock> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 mode ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<StructureBlock> type() {
|
|
||||||
return StructureBlock.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, StructureBlock blockData) {
|
|
||||||
attributes.add(attribute + blockData.getMode().name());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, StructureBlock blockData) {
|
|
||||||
for (StructureBlock.Mode mode : StructureBlock.Mode.values()) {
|
|
||||||
if (attributes.contains(attribute + mode.name())) {
|
|
||||||
blockData.setMode(mode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.TNT;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class TNTAttribute implements BlockAttribute<TNT> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 unstable";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<TNT> type() {
|
|
||||||
return TNT.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, TNT blockData) {
|
|
||||||
if (blockData.isUnstable()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, TNT blockData) {
|
|
||||||
blockData.setUnstable(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.Tripwire;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class TripwireAttribute implements BlockAttribute<Tripwire> {
|
|
||||||
|
|
||||||
private String attribute = "§8-§7 disarmed";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Tripwire> type() {
|
|
||||||
return Tripwire.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Tripwire blockData) {
|
|
||||||
if (blockData.isDisarmed()) attributes.add(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Tripwire blockData) {
|
|
||||||
blockData.setDisarmed(attributes.contains(attribute));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.data.type.TurtleEgg;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class TurtleEggAttribute implements BlockAttribute<TurtleEgg> {
|
|
||||||
|
|
||||||
private String attribute1 = "§8-§7 eggs ";
|
|
||||||
private String attribute2 = "§8-§7 hatch ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<TurtleEgg> type() {
|
|
||||||
return TurtleEgg.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, TurtleEgg blockData) {
|
|
||||||
attributes.add(attribute1 + blockData.getEggs());
|
|
||||||
attributes.add(attribute2 + blockData.getHatch());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, TurtleEgg blockData) {
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute1))
|
|
||||||
.map(s -> s.replace(attribute1, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setEggs);
|
|
||||||
attributes.stream()
|
|
||||||
.filter(s -> s.startsWith(attribute2))
|
|
||||||
.map(s -> s.replace(attribute2, ""))
|
|
||||||
.map(Integer::parseInt)
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(blockData::setHatch);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.attributescopy.impl.type;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.type.Wall;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class WallAttribute implements BlockAttribute<Wall> {
|
|
||||||
|
|
||||||
private BlockFace[] faces = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
|
||||||
|
|
||||||
private String attribute1 = "§8-§7 up";
|
|
||||||
private String attribute2 = "§8-§7 connected ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Wall> type() {
|
|
||||||
return Wall.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copy(List<String> attributes, Wall blockData) {
|
|
||||||
if (blockData.isUp()) attributes.add(attribute1);
|
|
||||||
for (BlockFace face : faces) {
|
|
||||||
if (blockData.getHeight(face) == Wall.Height.NONE) continue;
|
|
||||||
attributes.add(attribute2 + face.name().toLowerCase() + " " + blockData.getHeight(face).name().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paste(Set<String> attributes, Wall blockData) {
|
|
||||||
blockData.setUp(attributes.contains(attribute1));
|
|
||||||
for (BlockFace face : faces) {
|
|
||||||
for (Wall.Height height : Wall.Height.values()) {
|
|
||||||
if (attributes.contains(attribute2 + face.name().toLowerCase() + " " + height.name().toLowerCase())) {
|
|
||||||
blockData.setHeight(face, height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren