Add attributes copy feature
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-12-08 20:21:51 +01:00
Ursprung 8100667da5
Commit 75ba8813d3
58 geänderte Dateien mit 2955 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,40 @@
/*
* 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 + ");");
}
}

Datei anzeigen

@ -81,6 +81,16 @@ REGION_TYPE_NORMAL = Normal
REGION_TYPE_BUILD = Build area
REGION_TYPE_ONLY_TB = Dummy
# AttributesCopy
ATTRIBUTES_CANT_COPY = §cYou need to hold the same item type and hover over the same block to copy.
ATTRIBUTES_NO_COPY = §cNo attributes to copy.
ATTRIBUTES_COPIED = §eAttributes copied.
ATTRIBUTE_REMOVE_COMMAND_HELP = §8/§eattributeremove §8[§eattribute§8|§7all§8|§7*§8]
ATTRIBUTE_REMOVE_ALL = §eAll attributes removed.
ATTRIBUTE_REMOVE_SINGLE = §eAttribute §7{0}§e removed.
ATTRIBUTE_REMOVE_NOT_FOUND = §cAttribute not found
# AutoStart
AUTOSTART_COMMAND_HELP = §8/§etimer §8- §7Retrieve AutostartTimer Tool
AUTOSTART_ITEM_NAME = §eAutostartTimer

Datei anzeigen

@ -81,6 +81,15 @@ REGION_TYPE_NORMAL = Normal
REGION_TYPE_BUILD = Baubereich
REGION_TYPE_ONLY_TB = Testblock
# AttributesCopy
ATTRIBUTES_CANT_COPY = §cDu musst den Item Type in der Hand halten wo du auch drauf guckst.
ATTRIBUTES_NO_COPY = §cKeine Attribute kopiert.
ATTRIBUTES_COPIED = §eAttribute kopiert.
ATTRIBUTE_REMOVE_ALL = §eAlle Attribute entfernt.
ATTRIBUTE_REMOVE_SINGLE = §eAttribut §7{0}§e entfernt.
ATTRIBUTE_REMOVE_NOT_FOUND = §cAttribut nicht gefunden
# AutoStart
AUTOSTART_COMMAND_HELP = §8/§etimer §8- §7Legt den AutostartTimer ins Inventar
AUTOSTART_ITEM_NAME = §eAutostartTimer

Datei anzeigen

@ -0,0 +1,102 @@
/*
* 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 de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@Linked
@MinVersion(18)
public class AttributeRemoveCommand extends SWCommand {
public AttributeRemoveCommand() {
super("removeattribute", "attributesremove");
}
@Register({"all"})
@Register({"*"})
public void genericCommand(Player player) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(new ArrayList<>());
itemStack.setItemMeta(itemMeta);
BauSystem.MESSAGE.send("ATTRIBUTE_REMOVE_ALL", player);
}
@Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP")
public void genericCommand(Player player, @Mapper("attribute") String attribute) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = itemMeta.getLore();
if (lore.isEmpty()) {
BauSystem.MESSAGE.send("ATTRIBUTE_REMOVE_NOT_FOUND", player);
return;
}
if (!lore.get(0).equals("§eAttributes§8:")) {
BauSystem.MESSAGE.send("ATTRIBUTE_REMOVE_NOT_FOUND", player);
return;
}
lore.removeIf(s -> s.equals("§8-§7 " + attribute));
if (lore.size() == 1) {
itemStack.setItemMeta(null);
} else {
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
}
BauSystem.MESSAGE.send("ATTRIBUTE_REMOVE_SINGLE", player, attribute);
}
@Mapper(value = "attribute", local = true)
public TypeMapper<String> attribute() {
return new TypeMapper<String>() {
@Override
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
Player player = (Player) commandSender;
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = itemMeta.getLore();
if (lore.isEmpty()) return null;
if (!lore.get(0).equals("§eAttributes§8:")) return null;
return lore.stream()
.skip(1)
.map(s1 -> s1.substring(6))
.map(s1 -> s1.replace(' ', '_'))
.collect(Collectors.toList());
}
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
return s.replace('_', ' ');
}
};
}
}

Datei anzeigen

@ -0,0 +1,87 @@
/*
* 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 de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.FluidCollisionMode;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
@Linked
@MinVersion(18)
public class AttributesCopyCommand extends SWCommand {
static List<BlockAttribute<?>> blockAttributeList = new ArrayList<>();
public static void add(BlockAttribute<?> blockAttribute) {
blockAttributeList.add(blockAttribute);
}
public AttributesCopyCommand() {
super("copyattributes", "attributescopy");
}
@Register
public void genericCommand(Player player) {
linkIfNeeded();
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
ItemStack mainHand = player.getInventory().getItemInMainHand();
if (mainHand.getType() != block.getType()) {
BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player);
return;
}
BlockData blockData = block.getBlockData();
List<String> attributesToCopy = new ArrayList<>();
for (BlockAttribute blockAttribute : blockAttributeList) {
if (blockAttribute.type().isInstance(blockData)) {
blockAttribute.copy(attributesToCopy, blockData);
}
}
if (attributesToCopy.isEmpty()) {
BauSystem.MESSAGE.send("ATTRIBUTES_NO_COPY", player);
return;
}
ItemMeta itemMeta = mainHand.getItemMeta();
List<String> lore = new ArrayList<>(attributesToCopy);
lore.add(0, "§eAttributes§8:");
itemMeta.setLore(lore);
mainHand.setItemMeta(itemMeta);
player.getInventory().setItemInMainHand(mainHand);
BauSystem.MESSAGE.send("ATTRIBUTES_COPIED", player);
}
private static boolean isLinked = false;
static void linkIfNeeded() {
if (isLinked) return;
LinkageUtils.linkBlockAttributes();
isLinked = true;
}
}

Datei anzeigen

@ -0,0 +1,62 @@
/*
* 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 de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static de.steamwar.bausystem.features.attributescopy.AttributesCopyCommand.blockAttributeList;
@Linked
@MinVersion(18)
public class AttributesCopyListener implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
AttributesCopyCommand.linkIfNeeded();
ItemStack itemStack = event.getItemInHand();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) return;
List<String> strings = itemMeta.getLore();
if (strings == null) return;
if (strings.isEmpty()) return;
if (!strings.get(0).equals("§eAttributes§8:")) return;
Set<String> attributesToPaste = new HashSet<>(strings);
Block block = event.getBlock();
BlockData blockData = block.getBlockData();
for (BlockAttribute blockAttribute : blockAttributeList) {
if (blockAttribute.type().isInstance(blockData)) {
blockAttribute.paste(attributesToPaste, blockData);
}
}
block.setBlockData(blockData, false);
}
}

Datei anzeigen

@ -0,0 +1,31 @@
/*
* 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);
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,51 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
* 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()) {
if (!blockData.getAllowedFaces().contains(blockFace)) continue;
blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase()));
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* 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.bausystem.features.script.command.logic.Or;
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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,62 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,60 @@
/*
* 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()) {
RedstoneWire.Connection connection = blockData.getFace(blockFace);
if (connection != RedstoneWire.Connection.NONE) {
attributes.add(attribute + blockFace.name().toLowerCase() + " " + 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);
}
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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 attribute = "§8-§7 delay ";
@Override
public Class<Repeater> type() {
return Repeater.class;
}
@Override
public void copy(List<String> attributes, Repeater blockData) {
attributes.add(attribute + blockData.getDelay());
}
@Override
public void paste(Set<String> attributes, Repeater blockData) {
attributes.stream()
.filter(s -> s.startsWith(attribute))
.map(s -> s.replace(attribute, ""))
.map(Integer::parseInt)
.findFirst()
.ifPresent(blockData::setDelay);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,56 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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());
}
@Override
public void paste(Set<String> attributes, Stairs blockData) {
for (Stairs.Shape shape : Stairs.Shape.values()) {
if (attributes.contains(attribute + shape.name())) {
blockData.setShape(shape);
return;
}
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,63 @@
/*
* 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) {
attributes.add(attribute2 + face.name().toLowerCase() + " " + blockData.getHeight(face));
}
}
@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;
}
}
}
}
}

Datei anzeigen

@ -27,7 +27,6 @@ import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.core.VersionDependent;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;