SteamWar/BauSystem2.0
Archiviert
12
0

Merge branch 'master' into SimulatorPreview
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-08-27 15:04:34 +02:00
Commit fb3db5d4dd
212 geänderte Dateien mit 8451 neuen und 8484 gelöschten Zeilen

Datei anzeigen

@ -37,14 +37,11 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.region.PasteOptions;
import de.steamwar.bausystem.region.Point;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -60,7 +57,12 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiPredicate;
import java.util.logging.Level;
public class FlatteningWrapper15 implements FlatteningWrapper {
@ -109,51 +111,49 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint)));
}
private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
private static final BaseBlock GLAZED = Objects.requireNonNull(BlockTypes.PINK_GLAZED_TERRACOTTA).getDefaultState().toBaseBlock();
private static final BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
private static final BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
private static final BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
@Override
public EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
public Clipboard loadSchematic(File file) {
Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read();
} catch (NullPointerException | IOException e) {
throw new SecurityException("Bausystem schematic not found", e);
}
EditSession editSession = paste(clipboard, pastePoint, pasteOptions);
return editSession;
return clipboard;
}
@Override
public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
public EditSession paste(PasteBuilder pasteBuilder) {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
if (pasteOptions.getColor() != Color.PINK) {
changeColor(clipboard, pasteOptions.getColor());
}
if (pasteOptions.isOnlyColors()) {
Set<String> blocks = new HashSet<>();
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_wool");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_terracotta");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_glazed_terracotta");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass_pane");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete_powder");
blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_carpet");
Clipboard clipboard = pasteBuilder.getClipboard();
if (!pasteBuilder.getMappers().isEmpty()) {
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
BlockVector3 pos = minimum.add(x, y, z);
pasteBuilder.getMappers().forEach(mapper -> mapper.accept(clipboard, pos));
}
}
}
}
AtomicReference<BlockVector3> pastePoint = new AtomicReference<>();
if (!pasteBuilder.getPredicates().isEmpty()) {
e.setMask(new Mask() {
@Override
public boolean test(BlockVector3 blockVector3) {
BaseBlock block = clipboard.getFullBlock(blockVector3);
String blockName = block.toString().toLowerCase();
return blocks.contains(blockName);
BaseBlock block = clipboard.getFullBlock(blockVector3.subtract(pastePoint.get()).add(clipboard.getRegion().getMinimumPoint()));
String blockName = block.getBlockType().toString().toLowerCase();
for (BiPredicate<BaseBlock, String> predicate : pasteBuilder.getPredicates()) {
if (!predicate.test(block, blockName)) return false;
}
return true;
}
public Mask copy() {
return this;
}
@Nullable
@ -161,76 +161,34 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
public Mask2D toMask2D() {
return null;
}
public Mask copy() {
return this;
}
});
}
ClipboardHolder ch = new ClipboardHolder(clipboard);
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(pastePoint.getX(), pastePoint.getY(), pastePoint.getZ());
BlockVector3 v = BlockVector3.at(pasteBuilder.getPastPoint().getX(), pasteBuilder.getPastPoint().getY(), pasteBuilder.getPastPoint().getZ());
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
if (pasteOptions.isRotate()) {
if (pasteBuilder.isRotate()) {
ch.setTransform(new AffineTransform().rotateY(180));
v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(0, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset);
}
pastePoint.set(v);
if (pasteOptions.isReset()) {
e.setBlocks((Region) new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
if (pasteOptions.getWaterLevel() != 0) {
e.setBlocks((Region) new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
if (pasteBuilder.isReset()) {
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
if (pasteBuilder.getWaterLevel() != 0) {
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint()).withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
}
}
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build());
return e;
} catch (WorldEditException e) {
throw new SecurityException(e.getMessage(), e);
}
}
@Override
public void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
BaseBlock clay = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
BaseBlock glazed = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_glazed_terracotta")).getDefaultState().toBaseBlock();
BaseBlock glass = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
BlockVector3 pos = minimum.add(x, y, z);
BaseBlock block = clipboard.getFullBlock(pos);
if (block.equals(WOOL)) {
clipboard.setBlock(pos, wool);
} else if (block.equals(CLAY)) {
clipboard.setBlock(pos, clay);
} else if (block.equals(GLAZED)) {
clipboard.setBlock(pos, glazed);
} else if (block.equals(GLASS)) {
clipboard.setBlock(pos, glass);
} else if (block.equals(GLASS_PANE)) {
clipboard.setBlock(pos, glassPane);
} else if (block.equals(CARPET)) {
clipboard.setBlock(pos, carpet);
} else if (block.equals(CONCRETE)) {
clipboard.setBlock(pos, concrete);
} else if (block.equals(CONCRETE_POWDER)) {
clipboard.setBlock(pos, concretePowder);
}
}
}
}
}
@Override
public boolean backup(Point minPoint, Point maxPoint, File file) {
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
@ -272,19 +230,4 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
return ((Waterlogged) data).isWaterlogged();
}
@Override
public Material getTraceShowMaterial() {
return Material.LIME_CONCRETE;
}
@Override
public Material getTraceHideMaterial() {
return Material.RED_CONCRETE;
}
@Override
public Material getTraceXZMaterial() {
return Material.QUARTZ_SLAB;
}
}

Datei anzeigen

@ -19,9 +19,10 @@
package de.steamwar.bausystem.features.tracer.record;
import net.minecraft.world.entity.item.EntityTNTPrimed;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.entity.LevelEntityGetter;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.entity.TNTPrimed;
import java.util.stream.Stream;
@ -29,13 +30,17 @@ import java.util.stream.StreamSupport;
public class TNTPrimedIterator18 implements TNTPrimedIterator {
private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0);
private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle");
private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
private static final Reflection.MethodInvoker getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null);
@Override
public Stream<TNTPrimed> iterator() {
return StreamSupport.stream(WORLD.getHandle().H().a().spliterator(), false)
.filter(EntityTNTPrimed.class::isInstance)
.map(entity -> (TNTPrimed) entity.getBukkitEntity());
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Bukkit.getWorlds().get(0))))).spliterator(), false)
.map(getBukkitEntity::invoke)
.filter(TNTPrimed.class::isInstance)
.map(TNTPrimed.class::cast);
}
}

Datei anzeigen

@ -1,41 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tracer.record;
import net.minecraft.world.entity.item.EntityTNTPrimed;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.entity.TNTPrimed;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class TNTPrimedIterator19 implements TNTPrimedIterator {
private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0);
@Override
public Stream<TNTPrimed> iterator() {
return StreamSupport.stream(WORLD.getHandle().F().a().spliterator(), false)
.filter(EntityTNTPrimed.class::isInstance)
.map(entity -> (TNTPrimed) entity.getBukkitEntity());
}
}

Datei anzeigen

@ -55,7 +55,6 @@ public class NMSWrapper19 implements NMSWrapper {
@SuppressWarnings("deprecation")
public void setInternalGameMode(Player player, GameMode gameMode) {
playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue()));
}
@Override

62
BauSystem_20/build.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,62 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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/>.
*/
plugins {
id 'base'
id 'java'
}
group 'steamwar'
version '1.0'
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDirs = ['src/']
}
resources {
srcDirs = ['src/']
exclude '**/*.java', '**/*.kt'
}
}
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation project(":BauSystem_Main")
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly 'com.mojang:datafixerupper:4.0.26'
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'com.mojang:brigadier:1.0.18'
compileOnly swdep('Spigot-1.20')
compileOnly swdep('SpigotCore')
}

Datei anzeigen

@ -0,0 +1,178 @@
/*
* 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.utils;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.features.util.NoClipCommand;
import net.minecraft.SystemUtils;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.DataWatcher;
import net.minecraft.server.level.PlayerInteractManager;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.function.LongSupplier;
public class NMSWrapper20 implements NMSWrapper {
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
@Override
@SuppressWarnings("deprecation")
public void setInternalGameMode(Player player, GameMode gameMode) {
playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue()));
}
@Override
public void setSlotToItemStack(Player player, Object o) {
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
int index = packetPlayInSetCreativeSlot.a();
if (index >= 36 && index <= 44) {
index -= 36;
} else if (index > 44) {
index -= 5;
} else if (index <= 8) {
index = index - 8 + 36;
}
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c()));
if (index < 9) player.getInventory().setHeldItemSlot(index);
player.updateInventory();
}
@Override
public void init(LongSupplier longSupplier) {
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
}
private static final List<Packet<?>> packets = new ArrayList<>();
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
@Override
public void createTickCache(World world) {
packets.clear();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion));
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
if (entity instanceof TNTPrimed) {
net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle();
List<DataWatcher.b<?>> list = serverEntity.aj().c();
if(list != null)
packets.add(new PacketPlayOutEntityMetadata(serverEntity.af(), list));
}
});
}
@Override
public void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
for (Packet<?> p : packets) {
TinyProtocol.instance.sendPacket(player, p);
}
});
}
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
@Override
public void setGameStateChangeReason(Object packet) {
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
}
@Override
public void setPlayerBuildAbilities(Player player) {
((CraftPlayer) player).getHandle().fO().d = true;
((CraftPlayer) player).getHandle().fO().e = true;
}
@Override
public Material pathMaterial() {
return Material.DIRT_PATH;
}
private static final int threshold = 2048;
@Override
public boolean checkItemStack(ItemStack item) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.v();
if (tag != null && tag.e("BlockEntityTag")) {
NBTTagCompound blockTag = tag.p("BlockEntityTag");
if (blockTag.e("Items")) {
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
}
}
return false;
}
private int drillDown(NBTTagList items, int layer, int start) {
if (layer > 2) return start + threshold;
int invalid = start;
for (NBTBase nbtBase : items) {
if (!(nbtBase instanceof NBTTagCompound))
continue;
NBTTagCompound slot = (NBTTagCompound) nbtBase;
if (slot.e("tag")) {
invalid += slot.f("Count");
NBTTagCompound iTag = slot.p("tag");
if (iTag.e("BlockEntityTag")) {
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
if (blockTag.e("Items")) {
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
}
}
}
if (invalid > threshold)
break;
}
return invalid;
}
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
@Override
public Object resetExplosionKnockback(Object packet) {
PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet;
return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), null);
}
}

Datei anzeigen

@ -0,0 +1,80 @@
/*
* 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.utils;
import net.minecraft.network.protocol.game.PacketPlayInFlying;
import net.minecraft.server.level.EntityPlayer;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
private static class Position {
private double x;
private double y;
private double z;
private float yaw;
private float pitch;
}
private Map<UUID, Position> playerLocationMap = new HashMap<>();
@Override
public void setPosition(Player player, Object object) {
Position position = playerLocationMap.computeIfAbsent(player.getUniqueId(), uuid -> {
Position pos = new Position();
Location location = player.getLocation();
pos.x = location.getX();
pos.y = location.getY();
pos.z = location.getZ();
pos.yaw = location.getYaw();
pos.pitch = location.getPitch();
return pos;
});
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
if (packetPlayInFlying.h) {
entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e);
position.x = packetPlayInFlying.a;
position.y = packetPlayInFlying.b;
position.z = packetPlayInFlying.c;
position.yaw = packetPlayInFlying.d;
position.pitch = packetPlayInFlying.e;
} else {
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
position.x = packetPlayInFlying.a;
position.y = packetPlayInFlying.b;
position.z = packetPlayInFlying.c;
}
}
@Override
public void disable(Player player) {
Position position = playerLocationMap.remove(player.getUniqueId());
if (position != null) {
player.teleport(new Location(player.getWorld(), position.x, position.y, position.z, position.yaw, position.pitch));
}
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.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 LuaLib_GENERIC implements LinkageType {
@Override
public String method() {
return "link";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
buildPlan.addImport("de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin");
methodBuilder.addLine("SteamWarLuaPlugin.add(" + s + ");");
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -25,16 +25,16 @@ import de.steamwar.linkage.plan.MethodBuilder;
import javax.lang.model.element.TypeElement;
public class Operator_GENERIC implements LinkageType {
public class ScoreboardElement_GENERIC implements LinkageType {
@Override
public String method() {
return "linkScriptCommands";
return "link";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
buildPlan.addImport("de.steamwar.bausystem.features.script.expression.Expression");
methodBuilder.addLine("Expression.registerOperator(" + s + ");");
buildPlan.addImport("de.steamwar.bausystem.features.world.BauScoreboard");
methodBuilder.addLine("BauScoreboard.ELEMENTS.add(" + s + ");");
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import javax.lang.model.element.TypeElement;
public class SpecialCommand_GENERIC implements LinkageType {
@Override
public String method() {
return "linkScriptCommands";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
buildPlan.addImport("de.steamwar.bausystem.features.script.ScriptExecutor");
methodBuilder.addLine("ScriptExecutor.SPECIAL_COMMANDS.add(" + s + ");");
}
}

Datei anzeigen

@ -64,4 +64,6 @@ dependencies {
annotationProcessor swdep('SpigotCore')
compileOnly swdep('FastAsyncWorldEdit-1.18')
implementation 'org.luaj:luaj-jse:3.0.1'
}

Datei anzeigen

@ -37,12 +37,16 @@ SCOREBOARD_TPS_FROZEN = §e Frozen
SCOREBOARD_TRACE_TICKS = Ticks
SCOREBOARD_TECHHIDER = TechHider§8: §aOn
SCOREBOARD_XRAY = XRay§8: §aOn
# Flags
FLAG_COLOR = Color
FLAG_TNT = TNT
FLAG_FIRE = Fire
FLAG_FREEZE = Freeze
FLAG_PROTECT = Protect
FLAG_ITEMS = Items
FLAG_FIRE_ALLOW = §con
FLAG_FIRE_DENY = §aoff
@ -57,6 +61,9 @@ FLAG_TNT_ALLOW = §aon
FLAG_TNT_DENY = §coff
FLAG_TNT_ONLY_TB = §7no §ebuild area
FLAG_ITEMS_ACTIVE = §aon
FLAG_ITEMS_INACTIVE = §coff
FLAG_COLOR_WHITE = §fWhite
FLAG_COLOR_ORANGE = §6Orange
FLAG_COLOR_MAGENTA = §dMagenta
@ -137,6 +144,7 @@ BAU_INFO_ITEM_LORE_DAMAGE=
BAU_INFO_ITEM_LORE_FIRE = §7Fire§8: §e{0}
BAU_INFO_ITEM_LORE_COLOR = §7Color§8: §e{0}
BAU_INFO_ITEM_LORE_PROTECT = §7Protect§8: §e{0}
BAU_INFO_ITEM_LORE_ITEMS = §7Items§8: §e{0}
BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Information regarding this build server
BAU_INFO_COMMAND_OWNER = §7Owner: §e{0}
@ -159,6 +167,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Second position at: §8[§7{0}§8, §7{1}§8,
COUNTINGWAND_MESSAGE_VOLUME = §e{0}
COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2}
# Design Endstone
DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Show where Endstone is
DESIGN_ENDSTONE_REGION_ERROR = §cThis region has no build area
DESIGN_ENDSTONE_ENABLE = §aEndstone is activated
DESIGN_ENDSTONE_DISABLE = §cEndstone is deactivated
# Detonator
DETONATOR_LOC_REMOVE = §e{0} removed
DETONATOR_LOC_ADD = §e{0} added
@ -216,303 +230,64 @@ GUI_EDITOR_TITLE_MORE=Select item
# Script
## Errors
SCRIPT_SLEEP_ERROR = §cInsert a sleep into your script
SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnknown variable {0}
SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression error with: {0}
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cThe first argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cThe first argument is missing and should be a number
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cThe first argument is missing and should be a variable or a number
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cThe first argument is missing and should be a jump-point
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cThe second argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cThe econd argument is missing and should be a value
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cThe second argument is missing and should be a jump-point
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cThe third argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cThe third argument is missing and should be a value
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cThe third argument is missing and should be a variable or a number
SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cThe fourth argument is missing and should be a value
SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cOnly booleans can be compared
SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cOnly numbers can be compared
SCRIPT_COMMAND_ERROR_NO_BOOLEAN = §cThe value is not a boolean
SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cOnly strings are allowed
SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cOnly numbers are allowed
SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnknown operation: {0}
## Commands
SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cOnly numbers or strings can be added
SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cOnly numbers can be divided
SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cOnly numbers can be multiplied
SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cOnly numbers can be subtracted
SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cOnly numbers can be raised to a power
SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cOnly whole numbers can be used for modulo
SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cOnly whole numbers and booleans can be used for and
SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cOnly whole numbers and booleans can be used for or
SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cOnly whole numbers and booleans can be used for xor
SCRIPT_COMMAND_ARITHMETIC_BIT_LEFT_ERROR = §cOnly whole numbers can be used for left shift value
SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_ERROR = §cOnly whole numbers can be used for right shift value
SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_LOGIC_ERROR = §cOnly whole numbers can be used for logic right shift value
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_3 = Ceils the second number and writes it in the first or ceils the second number with the precision from the third number and writes it in the first
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_1 = §cOnly floating point numbers can be ceiled
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2 = §cThe precision needs to be a whole number
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_1 = §efloor §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_2 = §efloor §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_3 = Floors the second number and writes it in the first or floors the second number with the precision from the third number and writes it in the first
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_1 = §cOnly floating point numbers can be floored
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2 = §cThe precision needs to be a whole number
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_1 = §eround §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_2 = §eround §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_3 = Round the second number and writes it in the first or rounds the second number with the precision from the third number and writes it in the first
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_1 = §cOnly floating point numbers can be rounded
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2 = §cThe precision needs to be a whole number
SCRIPT_COMMAND_IO_ECHO_HELP_1 = §eecho §8<§7value§8>
SCRIPT_COMMAND_IO_ECHO_HELP_2 = §7Send a message to the player. If the value is empty, the message will be empty as well
SCRIPT_COMMAND_IO_ECHO_MESSAGE = §f{0}
SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_1 = §eechoactionbar §8<§7value§8>
SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Send a message to the player to the action bar. If the value is empty, the message will be empty as well
SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7variable§8> §8<§7text§8>
SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Request an input from the player, which will be written in the variable. The text is optional
SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Insert something into a String at a given index. The number is the index and the variable is the string. Optionally the result can be written in another or a new variable
SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7variable§8> §8<§7from variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Removes all occurrences of a string from another string.
SCRIPT_COMMAND_STRING_REPLACE_HELP_1 = §ereplace §8<§7variable§8> §8<§7from variable§8> §8<§7to variable§8>
SCRIPT_COMMAND_STRING_REPLACE_HELP_2 = §ereplace §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8> §8<§7to variable§8>
SCRIPT_COMMAND_STRING_REPLACE_HELP_3 = Replaces all occurrences of a string from another string with a given string
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_1 = §esubstring §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_2 = §esubstring §8<§7variable§8> §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_3 = Shortens a string either from the start or the end, depending on whether the given index is positive (start) or negative (end)
SCRIPT_COMMAND_VARIABLE_CONST_HELP_1 = §econst §8<§7variable§8> §8[§7value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_CONST_HELP_2 = Writes a value in a constant, which can be a number, a boolean or a string
SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_1 = §econvert §8<§7variable§8> §8<§7value§8>
SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Converts a value to 'number' if it's a number, or to 'boolean' if it's either 'true' or 'false'. Otherwise it remains of type 'text'.
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7variable§8> §8[§7value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7variable§8>
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Deletes a global variable.
SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_1 = §eunvar §8<§7variable§8>
SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Deletes a local variable.
SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7variable§8> §8[§7value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8>
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Writes the material of a block in the world in the variable
SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_1 = §esetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8>
SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2 = Sets a block in the world with the given material, given in the variable
SCRIPT_COMMAND_EXIT_HELP_1 = §eexit
SCRIPT_COMMAND_EXIT_HELP_2 = Exits the script
SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7true/false§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7true/false§8> §8<§7jump-point§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_3 = §7Jump to the first jump-point if the given value is true or the second jump-point otherwise.
SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7jump-point§8>
SCRIPT_COMMAND_JUMP_HELP_2 = §7Jump to a jump-point. A jump-point is a line with §8'§7.§8'§7 before.
SCRIPT_COMMAND_JUMP_ERROR = §cUnknown jump-point: {0}
SCRIPT_COMMAND_CALL_HELP_1 = §ecall §8<§7jump-point§8>
SCRIPT_COMMAND_CALL_HELP_2 = §7Jump to a jump-point. A jump-point is a line with §8'§7.§8'§7 before. Building a return stack alongside. Use 'return' to jump back.
SCRIPT_COMMAND_CALL_ERROR = §cUnknown jump-point: {0}
SCRIPT_COMMAND_RETURN_HELP_1 = §ereturn
SCRIPT_COMMAND_RETURN_HELP_2 = §7Jump back to the last 'call' command
SCRIPT_COMMAND_RETURN_ERROR = §cNo 'call' command executed before
SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7time§8>
SCRIPT_COMMAND_SLEEP_HELP_2 = Pauses the execution by the given number of game ticks.
SCRIPT_COMMAND_SLEEP_ERROR = §cThe given number needs to be greater than zero.
## GUI
SCRIPT_GUI_ITEM_NAME = §eScript Help
SCRIPT_ERROR_GUI=§cError in parsing script: Line {0}
SCRIPT_ERROR_GLOBAL=§cError in global script: Line {0}
SCRIPT_ERROR_CLICK=§cError in script: Line {0}
SCRIPT_ERROR_ONLY_IN_GLOBAL=§cThis function is only available in global scripts
## CustomScript
SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} §8-§7 {1}
SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} §8-§7 {1}
SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e{0}
SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0}
SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0}
SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e/{0}
## Script Menu GUI
SCRIPT_MENU_GUI_ITEM_LORE_1 = §7Click to retrieve
SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shift-Click to copy
SCRIPT_MENU_GUI_NAME = §eScript Commands {0}{1}§7%
SCRIPT_MENU_GUI_ITEM_LORE_3 = §7Right-Click to edit
SCRIPT_MENU_GUI_ITEM_LORE_4 = §7Middle-Click to preview
SCRIPT_MENU_GUI_NAME = §eScript-Menu
SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eInsert
SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Click with a book to insert
SCRIPT_MENU_GUI_DUPLICATE_COMMAND = §cCommand '{0}' already defined
SCRIPT_MENU_GUI_UNKNOWN_EVENT = §cEvent '{0}' cannot be defined
SCRIPT_MENU_GUI_LIMIT = §cScript-Book limit reached
## ScriptCommand
SCRIPT_COMMAND_HELP = §8/§escript §8- §7Opens the ScriptGUI
SCRIPT_COMMAND_HELP_MENU = §8/§escript menu §8- §7Opens the ScriptGUI for custom commands shares across baus
## Script GUI
SCRIPT_GUI_NAME = Script Elements
SCRIPT_GUI_COMMAND_CHAT = §eScript Command§8: §e{0}
SCRIPT_GUI_CUSTOM_HOTKEYS = §eCustom Hotkeys
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1 = §7Write§8: §e#!HOTKEY 'Char'
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2 = §7at the beginning of a Script Book to use a custom hotkey. The 'Char' can be any char between '§eA§7' and '§eZ§7' as well as '§e0§7' and '§e9§7'. While executing two variables are available: §epressed§7, §ereleased§7.
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3 = §7You can add modifiers like "SHIFT", "CTRL", "ALT" or "META" to the hotkey. §7Example: §e#!HOTKEY SHIFT+A
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4 = §7
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5 = §cThis can only be used in conjunction with the Fabric-Mod: §eAdvancedScripts §7found on §ehttps://steamwar.de/downloads
SCRIPT_GUI_CUSTOM_COMMANDS = §eCustom Commands
SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1 = §7Write§8: §e#!CMD 'COMMAND'
SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2 = §7at the beginning of a Script Book to use a custom command. The command always starts with §e/§7 and can be structured as you wish. Everything in pointy Brackets '§e<>§7' will be counted as a Parameter and therefore as a variable. Parameters in round brackets '§e()§7' are optional. Simple texts as parameters get a variable with the same name with the values true/false, depending on whether the value was given or not
SCRIPT_GUI_CUSTOM_EVENTS = §eCustom Events
SCRIPT_GUI_CUSTOM_EVENTS_LORE_1 = §7Write§8: §e#!EVENT 'EventName'
SCRIPT_GUI_CUSTOM_EVENTS_LORE_2 = §7at the beginning of a Script Book to use a custom event. Every event can ve canceled by using 'var cancel true'. After the event name are the variables which are usable in a Script Book.
SCRIPT_GUI_CUSTOM_EVENTS_LORE_3 = §7Usable Events are:
SCRIPT_GUI_CUSTOM_EVENTS_LORE_4 = §eFF
SCRIPT_GUI_CUSTOM_EVENTS_LORE_5 = §ePlaceBlock §8-§7 blockX, blockY, blockZ, blockType
SCRIPT_GUI_CUSTOM_EVENTS_LORE_6 = §eBreakBlock §8-§7 blockX, blockY, blockZ, blockType
SCRIPT_GUI_CUSTOM_EVENTS_LORE_7 = §eRightClick §8-§7 blockInHand, action, handType,
SCRIPT_GUI_CUSTOM_EVENTS_LORE_8 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e*
SCRIPT_GUI_CUSTOM_EVENTS_LORE_9 = §eLeftClick §8-§7 blockInHand, action, handType,
SCRIPT_GUI_CUSTOM_EVENTS_LORE_10 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e*
SCRIPT_GUI_CUSTOM_EVENTS_LORE_11 = §eTNTSpawn
SCRIPT_GUI_CUSTOM_EVENTS_LORE_12 = §eTNTExplode §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_18 = §eScoreboard
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Everything in brackets is only set if the variable before is set on §etrue§7.
SCRIPT_GUI_OTHER = §eOther
SCRIPT_GUI_OTHER_LORE_1 = §7Comments start with §e#§7.
SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points start with §e.§7.
SCRIPT_GUI_OTHER_LORE_3 = §7A variable name enclosed in '§e{}§7' is replaced by its value. A variable can be prefixed with '§econst.§7' or '§elocal.§7' or '§eglobal.§7'.
SCRIPT_GUI_OTHER_LORE_4 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_5 = §7- Local variables are only available in the script book.
SCRIPT_GUI_OTHER_LORE_6 = §7- Global variables are available in every script book.
SCRIPT_GUI_OTHER_LORE_7 = §7- Constant variables are variables from the server (e.g. player name, TPS, etc.)
SCRIPT_GUI_OTHER_LORE_8 = §7A variable can be appended with '§e.length§7' or '§e.type§7' or '§e.isset§7'.
SCRIPT_GUI_OTHER_LORE_9 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_10 = §7- Length returns the length of the variable as a number.
SCRIPT_GUI_OTHER_LORE_11 = §7- Type returns the type (number, floating_number, text or boolean) as text.
SCRIPT_GUI_OTHER_LORE_12 = §7- Isset returns as a boolean whether the variable exists.
SCRIPT_GUI_OTHER_LORE_13 = §7Mathematical as well as logical operations can be specified in '§e{}§7'.
SCRIPT_GUI_OTHER_LORE_14 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_15 = §7- arithmetic operators: §e+ * - /§7 as well as §e%§7 for modulo
SCRIPT_GUI_OTHER_LORE_16 = §7- Logical operators: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (this is the character for or)
SCRIPT_GUI_OTHER_LORE_17 = §7- Bitwise operators: §e&§7; §e|§7; §e^
SCRIPT_GUI_OTHER_LORE_18 = §7- Shift operators: §e<<§7; §e>>§7; §e>>>§7
SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0}
SCRIPT_GUI_CUSTOM_VARIABLES = §eCustom Variables
SCRIPT_GUI_CONSTANT_TIME_NAME = §7Constant §etime
SCRIPT_GUI_CONSTANT_TIME_LORE = §7Formatted time variable.
SCRIPT_GUI_CONSTANT_TICKS_NAME = §7Constant §eticks
SCRIPT_GUI_CONSTANT_TICKS_LORE = §7Ticks since server start.
SCRIPT_GUI_CONSTANT_TRACE_NAME = §7Constant §etrace
SCRIPT_GUI_CONSTANT_TRACE_LORE = §etrue§7 if the trace is activated.
SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME = §7Constant §eautotrace
SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 if the auto trace is activated.
SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME = §7Constant §etrace_status
SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE = §7One of: §eOFF§8, §eIDLE§8, §eIDLE_AUTO_EXPLODE§8, §eIDLE_AUTO_IGNITE§8, §eIDLE_SINGLE
SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME = §7Constant §etrace_time
SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE = §e0§7 if the trace is not active, otherwise the time in ticks since the trace was started.
SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME = §7Constant §eloader_status
SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE = §7One of: §eOFF§8, §eSETUP§8, §eRUNNING§8, §eSINGLE§8, §ePAUSE§8, §eEND
SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt
SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 if tnt is not deactivated.
SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb
SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 if tnt no build is activated.
SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze
SCRIPT_GUI_CONSTANT_FREEZE_LORE = §etrue§7 if freeze is not deactivated.
SCRIPT_GUI_CONSTANT_FIRE_NAME = §7Constant §efire
SCRIPT_GUI_CONSTANT_FIRE_LORE = §etrue§7 if fire is not deactivated.
SCRIPT_GUI_CONSTANT_PROTECT_NAME = §7Constant §eprotect
SCRIPT_GUI_CONSTANT_PROTECT_LORE = §etrue§7 if protect is activated.
SCRIPT_GUI_CONSTANT_X_NAME = §7Constant §ex
SCRIPT_GUI_CONSTANT_X_LORE = §ex§7 position of the player.
SCRIPT_GUI_CONSTANT_Y_NAME = §7Constant §ey
SCRIPT_GUI_CONSTANT_Y_LORE = §ey§7 position of the player.
SCRIPT_GUI_CONSTANT_Z_NAME = §7Constant §ez
SCRIPT_GUI_CONSTANT_Z_LORE = §ez§7 position of the player.
SCRIPT_GUI_CONSTANT_NAME_NAME = §7Constant §ename
SCRIPT_GUI_CONSTANT_NAME_LORE = §eDisplay§7 name of the player.
SCRIPT_GUI_CONSTANT_SNEAK_NAME = §7Constant §esneaking
SCRIPT_GUI_CONSTANT_SNEAK_LORE = §etrue§7 if the player is sneaking.
SCRIPT_GUI_CONSTANT_SPRINTING_NAME = §7Constant §esprinting
SCRIPT_GUI_CONSTANT_SPRINTING_LORE = §etrue§7 is the player is sprinting.
SCRIPT_GUI_CONSTANT_SLOT_NAME = §7Constant §eslot
SCRIPT_GUI_CONSTANT_SLOT_LORE = §e0-8§7 for the selected slot.
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME = §7Constant §eslotmaterial
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE = §eMaterial§7 of the item in the current slot
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME = §7Constant §eoffhandmaterial
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE = §eMaterial§7 of the item in the off hand
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME = §7Constant §ematerialname
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the current slot
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the off hand
SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type
SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eregion type§7 of the current region
SCRIPT_GUI_CONSTANT_REGION_NAME_NAME = §7Constant §eregion_name
SCRIPT_GUI_CONSTANT_REGION_NAME_LORE = §eregion name§7 of the current region
SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps
SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 of the server
SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit
SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 of the server
SCRIPT_MENU_GUI_ENTER_NAME = §eEnter a name
SCRIPT_DEPRECATED=§cThe function §8\'§e{0}§8\'§c is deprecated and will be removed in the future. Please use §8\'§e{1}§8\'§c instead.
# Shield Printing
SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starts the shield printing
SHIELD_PRINTING_HELP_COPY = §8/§eshieldprinting copy §8- §7Copies the shield configuration
SHIELD_PRINTING_HELP_APPLY = §8/§eshieldprinting apply §8- §7Applies the shield configuration
SHIELD_PRINTING_HELP_STOP = §8/§eshieldprinting stop §8- §7Stops the shield printing
SHIELD_PRINTING_HELP_STEP_1 = §81. §7Paste the schematic you want to use
SHIELD_PRINTING_HELP_STEP_2 = §82. §7Start the shield printing with §8/§eshieldprinting start
SHIELD_PRINTING_HELP_STEP_3 = §83. §7Wait until the shield printing is finished
SHIELD_PRINTING_HELP_STEP_4 = §84. §7Edit the shields if necessary
SHIELD_PRINTING_HELP_STEP_5 = §85. §7Copy the shields printing with §8/§eshieldprinting copy
SHIELD_PRINTING_HELP_STEP_6 = §86. §7Paste the original schematic
SHIELD_PRINTING_HELP_STEP_7 = §87. §7Apply the shield printing with §8/§eshieldprinting apply
SHIELD_PRINTING_NO_REGION = §cYou are not in a region.
SHIELD_PRINTING_NOT_RUNNING = §cThe shield printing is not running.
SHIELD_PRINTING_DISALLOWED = §cYou are not allowed to use shield printing here.
SHIELD_PRINTING_BOSSBAR = §fMovements: {0}
SHIELD_PRINTING_BOSSBAR_COPIED = §fMovements: {0} Copied: {1}
SHIELD_PRINTING_GUI_NAME = §7Shield Printing
SHIELD_PRINTING_GUI_APPLY = §aApply
SHIELD_PRINTING_GUI_STATE_PREVIOUS = §7R-Click§8: §7Previous
SHIELD_PRINTING_GUI_STATE_NEXT = §7L-Click§8: §7Next
SHIELD_PRINTING_GUI_STATE_ACTIVE = §e> §7{0}
SHIELD_PRINTING_GUI_STATE_INACTIVE = §8> §7{0}
SHIELD_PRINTING_GUI_STATE_FROM_ORIGINAL = Original
SHIELD_PRINTING_GUI_STATE_FROM_COPY = Copy
SHIELD_PRINTING_GUI_STATE_ALWAYS_ON = On
SHIELD_PRINTING_GUI_STATE_ALWAYS_OFF = Off
SHIELD_PRINTING_GUI_STATE_ALWAYS_OPEN = Open
SHIELD_PRINTING_GUI_STATE_ALWAYS_CLOSED = Closed
SHIELD_PRINTING_GUI_STATE_FENCE = §7{0} §fFence Connections
SHIELD_PRINTING_GUI_STATE_OPENABLE = §7{0} §fOpened
SHIELD_PRINTING_GUI_STATE_PISTON = §7{0} §fExtended
SHIELD_PRINTING_GUI_STATE_POWERABLE = §7{0} §fPowered
SHIELD_PRINTING_GUI_STATE_WALL = §7{0} §fWall Connections
SHIELD_PRINTING_START = §aThe shield printing has been started.
SHIELD_PRINTING_COPY = §aThe shield has been copied.
@ -595,7 +370,6 @@ SIMULATOR_GUI_TNT_GROUP_LORE_6 = §7z§8: §e{0}
SIMULATOR_GUI_TNT_DISABLED = §cDisabled
SIMULATOR_GUI_NAME = Simulator
SIMULATOR_GUI_DELETE = §cDelete TNT
SIMULATOR_GUI_START = §eStart
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eMove all
@ -674,25 +448,15 @@ KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Toggle on/off
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Toggles BlockCounter on
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Toggles BlockCounter off
BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick
BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s
BLOCK_COUNTER_MESSAGE = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick
BLOCK_COUNTER_MESSAGE_SECOND = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s
BLOCK_COUNTER_ENABLE = §7BlockCounter activated
BLOCK_COUNTER_DISABLE = §7BlockCounter deactivated
# DepthCounter
DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Activate the depth-counter
DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deactivate the depth-counter
DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Lists active counting modes
DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Toggle counting modes
DEPTH_COUNTER_ENABLE_MESSAGE = §7You activated the depth-counter
DEPTH_COUNTER_DISABLE_MESSAGE = §7You deactivated the depth-counter
DEPTH_COUNTER_ACTIVE_MESSAGE = §7Active couting modes: §e{0}§8.
DEPTH_COUNTER_MESSAGE = §7Damage §8> §7{0}
DEPTH_COUNTER_HIGHLIGHT = §e
DEPTH_COUNTER_SEPARATOR = §7 §7
DEPTH_COUNTER_X = X: {0}
DEPTH_COUNTER_Y = Y: {0}
DEPTH_COUNTER_Z = Z: {0}
DEPTH_COUNTER_MESSAGE = §7Depth §8> §7
DEPTH_COUNTER_COUNT = {0}{1}§8×{2}{3}§8×{4}{5}
DEPTH_COUNTER_HOVER = §7X§8ק7Y§8ק7Z
DEPTH_COUNTER_TNT = §7 TNT§8: §e{0}
# TPSLimit
@ -720,7 +484,7 @@ TPSLIMIT_INVALID_FROZEN = §c and '0'
# Trace
TRACE_RECORD=§aon
TRACE_IDLE=§coff
TRACE_HAS_TRACES=§ehas Traces
TRACE_IDLE_SINGLE=§esingle
TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8)
TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8)
@ -736,7 +500,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated
TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden
TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate
TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here
TRACE_MESSAGE_NO_REGION = §cYou are not in a region
TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Starts recording of all TNT-positions
TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Starts a single recording of all TNT-positions
@ -776,63 +539,87 @@ TRACE_GUI_POSITION_SOURCE = §7Source§8: §e{0}
TRACE_GUI_POSITION_EXPLODED = §7Exploded§8: §e{0}
# Loader
LOADER_OFF = §coff
LOADER_SETUP = §eSetup
LOADER_RUNNING = §aRunning
LOADER_SINGLE_SIDEBAR = §aSingle
LOADER_PAUSE = §7Pause
LOADER_END = §8Finished
LOADER_MESSAGE_CLEAR = §7Loader cleared
LOADER_MESSAGE_CLEAR_HELP = §cYou have to be in Setup-Mode to clear the Loader
LOADER_MESSAGE_TNT = §eTNT added {0}
LOADER_MESSAGE_INTERACT=§e{0} added {1}
LOADER_BUTTON_TNT=TNT
LOADER_BUTTON_SWITCH=Lever
LOADER_BUTTON_WOOD_BUTTON=Button
LOADER_BUTTON_STONE_BUTTON=Button
LOADER_BUTTON_WOOD_BUTTON=Wooden Button
LOADER_BUTTON_STONE_BUTTON=Stone Button
LOADER_BUTTON_PRESSURE_PLATE=Pressure plate
LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Pressure plate
LOADER_BUTTON_TRIPWIRE=Tripwire
LOADER_BUTTON_NOTEBLOCK=Noteblock
LOADER_BUTTON_DAYLIGHTSENSOR=Daylightsensor
LOADER_BUTTON_INVALID=Invalid
LOADER_BUTTON_DAYLIGHT_DETECTOR=Daylight Detector
LOADER_BUTTON_COMPARATOR=Comparator
LOADER_BUTTON_REPEATER=Repeater
LOADER_BUTTON_LECTERN=Lectern
LOADER_BUTTON_TRAPDOOR=Trapdoor
LOADER_BUTTON_DOOR=Door
LOADER_BUTTON_FENCEGATE=Fencegate
LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions
LOADER_HELP_UNDO=§8/§7loader undo §8- §7Removes last recorded action
LOADER_SETUP_STOP_FIRST=§cPlease stop the current loader first!
LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action
LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots
LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions
LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader
LOADER_HELP_RESUME=§8/§7loader resume §8- §7Resumes Loader
LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Clears recording
LOADER_HELP_SINGLE=§8/§eloader single §8- §7Starts a single shot
LOADER_HELP_OTHER=§7The loader works with §eIngame§8-§eTicks §7(20 ticks per Second)
LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup
LOADER_BACK_SETUP=§7DYour Loader is in Setup again
LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader.
LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
LOADER_ACTIVE=§7The Loader is now active.
LOADER_STOP=§7The Loader has been stopped.
LOADER_PAUSED=§7The Loader is now paused.
LOADER_RESUME=§7The Loader is resuming.
LOADER_SINGLE=§7The Loader is shooting once.
LOADER_SMALL_TIME=§cThe wait time is too small
LOADER_NEW_TIME=§7The wait time is now: {0}, before {1}
LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0}, before {1}
LOADER_UNDO=§7Undo succesful.
LOADER_PERMS=§cYou are not allowed to use the Loader here
LOADER_GUI_NAME=§eLoader
LOADER_GUI_NEW=§eNew Loader
LOADER_GUI_START=§eStart Loader
LOADER_GUI_PAUSE=§7pause Loader
LOADER_GUI_UNDO=§7Undo last action
LOADER_GUI_WAIT=§7Shot delay
LOADER_GUI_WAIT_LORE=§7Currently: §e{0}
LOADER_GUI_WAIT_TITLE=§7Shot delay
LOADER_GUI_SPEED=§eSpeed
LOADER_GUI_SPEED_LORE=§7Currently: §e{0}
LOADER_GUI_SPEED_TITLE=§7Block placing speed
LOADER_GUI_STOP=§eStop Loader
LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet!
LOADER_GUI_TITLE=Loader GUI
LOADER_GUI_SHOW_INTERACTIONS=§eShow only Interactions
LOADER_GUI_SHOW_WAITS=§eShow only Waits
LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time between TNT
LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time all
LOADER_GUI_SHOW_WAITS_TITLE=§7Wait Time
LOADER_GUI_SETTINGS_TITLE=Settings
LOADER_GUI_SETTINGS_BACK=§8Back
LOADER_GUI_SETTINGS_DELETE=§cDelete
LOADER_GUI_WAIT_TITLE=Settings
LOADER_GUI_WAIT_BACK=§8Back
LOADER_GUI_CLICK_TO_EDIT=§7Klicke zum editieren
LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1}
LOADER_SETTING_NAME=§7{0}
LOADER_SETTING_MODES=§7Modi§8: §e{0}
LOADER_SETTING_POWER=§7Redstone Stärke§8: §e{0}
LOADER_SETTING_TICKS=§7Ticks§8: §e{0}
LOADER_SETTING_REPEATER=§7Repeater§8: §e{0}
LOADER_SETTING_WAIT=§7Wartezeit§8: §e{0} Tick(s)
LOADER_SETTING_WAIT_NAME=Wartezeit
LOADER_SETTING_TICKS_NAME=Ticks
LOADER_SETTING_TICKS_REMOVE_ONE=§c-1
LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5
LOADER_SETTING_TICKS_ADD_ONE=§a+1
LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5
LOADER_SETTING_TNT_NAME=§cTNT
LOADER_SETTING_TNT_X=§7X§8: §e{0}
LOADER_SETTING_TNT_Y=§7Y§8: §e{0}
LOADER_SETTING_TNT_Z=§7Z§8: §e{0}
LOADER_INTERACTION_NOOP=NOOP
LOADER_INTERACTION_INTERACT=Interagiere
LOADER_INTERACTION_POWERED=Aktiviert
LOADER_INTERACTION_UNPOWERED=Deaktiviert
LOADER_INTERACTION_PAGE_PREV=Vorherige Seite
LOADER_INTERACTION_PAGE_NEXT=Nächste Seite
LOADER_INTERACTION_PAGE=Seite {0}
LOADER_INTERACTION_ACTIVE=Aktiviert
LOADER_INTERACTION_INACTIVE=Deaktiviert
LOADER_INTERACTION_WAIT_FOR=Darauf warten
LOADER_INTERACTION_NO_WAIT_FOR=Nicht darauf warten
LOADER_INTERACTION_OPEN=Geöffnet
LOADER_INTERACTION_CLOSED=Geschlossen
# Loadtimer
LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon
LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Starts the simple Loadtimer
@ -1018,6 +805,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
REGION_FREEZE_NO_PERMS=§cYou are not allowed to freeze this world
REGION_FREEZE_ENABLED=§cRegion frozen
REGION_FREEZE_DISABLED=§aRegion thawed
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
REGION_ITEMS_NO_PERMS=§cYou are not allowed to toggle items in this world
REGION_ITEMS_ENABLED=§aItems enabled in this region
REGION_ITEMS_DISABLED_GLOBAL=§cItems disabled in this world
REGION_ITEMS_DISABLED=§cItems disabled in this region
REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region
REGION_PROTECT_DISABLE=§cProtection disabled
REGION_PROTECT_ENABLE=§aProtection enabled
@ -1074,6 +866,8 @@ REGION_TB_DONE=§7Dummy reset
REGION_TB_ERROR=§cError resetting the dummy
REGION_TB_NO_PERMS=§cYou are not allowed to reset the dummy here
REGION_TB_NO_REGION=§cYou are currently not in any region
REGION_TB_NO_SCHEMSHARING=§cYou currently cannot share schematics until {0}.
REGION_TB_NO_SCHEMRECEIVING=§cThe Owner of this build server cannot receive any schematics until {0}.
REGION_TNT_HELP=§8/§etnt §8- §7Change the TNT behaviour
REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Set TNT behaviour to a given mode
REGION_TNT_ON=§aTNT-Damage activated
@ -1081,12 +875,7 @@ REGION_TNT_OFF=§cTNT-Damage deactivated
REGION_TNT_TB=§aTNT-Damage activated outside the building area
REGION_TNT_NO_PERMS=§cYou are not allowed to toggle tnt damage here
REGION_TNT_BUILD=§cAn explosion would have destroyed blocks in the building area
# Team
LOCK_SCHEM_NO_USER=§7This player does not exist!
LOCK_SCHEM_NO_SCHEM=§7This player does not have a schem with that name!
LOCK_SCHEM_DIR=§7The given schem is a directory
LOCK_SCHEM_LOCKED=§e{0} §7by §e{1} §7was reset from §e{2} §7to §eNORMAL §7.
LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] - §7Lock a schematic (Notify user about locking reason!)
AFK_KICK_MESSAGE=§cNothing happened on this server for 5 minutes.
AFK_WARNING_MESSAGE=§cThis server will stop in one minute if you remain inactive

Datei anzeigen

@ -37,12 +37,16 @@ SCOREBOARD_TPS_FROZEN = §e Eingefroren
SCOREBOARD_TRACE_TICKS = Ticks
SCOREBOARD_TECHHIDER = TechHider§8: §aAn
SCOREBOARD_XRAY = XRay§8: §aAn
# Flags
FLAG_COLOR = Color
FLAG_TNT = TNT
FLAG_FIRE = Fire
FLAG_FREEZE = Freeze
FLAG_PROTECT = Protect
FLAG_ITEMS = Items
FLAG_FIRE_ALLOW = §can
FLAG_FIRE_DENY = §aaus
@ -57,6 +61,9 @@ FLAG_TNT_ALLOW = §aan
FLAG_TNT_DENY = §caus
FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen
FLAG_ITEMS_ACTIVE = §aan
FLAG_ITEMS_INACTIVE = §caus
FLAG_COLOR_WHITE = §fWeiß
FLAG_COLOR_ORANGE = §6Orange
FLAG_COLOR_MAGENTA = §dMagenta
@ -157,6 +164,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Zweite Position bei: §8[§7{0}§8, §7{1}§8,
COUNTINGWAND_MESSAGE_VOLUME = §e{0}
COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2}
# Design Endstone
DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Zeige wo Endstone ist
DESIGN_ENDSTONE_REGION_ERROR = §cDiese Region hat keinen Baubereich
DESIGN_ENDSTONE_ENABLE = §aEndstone ist aktiviert
DESIGN_ENDSTONE_DISABLE = §cEndstone ist deaktiviert
# Detonator
DETONATOR_LOC_REMOVE = §e{0} entfernt
DETONATOR_LOC_ADD = §e{0} hinzugefügt
@ -213,299 +226,58 @@ GUI_EDITOR_ITEM_CLOSE=§eSchließen
GUI_EDITOR_TITLE_MORE=Item auswählen
# Script
## Errors
SCRIPT_SLEEP_ERROR = §cFüge ein sleep in dein Script ein
SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnbekannte Variable {0}
SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression fehler in: {0}
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cDas erste Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cDas erste Argument fehlt und sollte eine Zahl sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cDas erste Argument fehlt und sollte eine Variable oder ein Wert sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cDas erste Argument fehlt und sollte ein Jump-Point sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cDas zweite Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cDas zweite Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cDas dritte Argument fehlt und sollte ein Jump-Point sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cDas dritte Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cDas dritte Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cDas dritte Argument fehlt und sollte eine Variable/Zahl sein
SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cDas vierte Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cNur Booleans können verglichen werden
SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cNur Zahlen können verglichen werden
SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cNur Strings können verwendet werden
SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cNur Zahlen können verwendet werden
SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnbekannte Operation: {0}
## Commands
SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cNur Zahlen können addiert werden
SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cNur Zahlen können dividiert werden
SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cNur Zahlen können multipliziert werden
SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cNur Zahlen können subtrahiert werden
SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cNur Zahlen können potenziert werden
SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cNur ganze Zahlen können für modulo verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cNur ganze Zahlen und booleans können für und verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cNur ganze Zahlen und booleans können für oder verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cNur ganze Zahlen und booleans können für xor verwendet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_3 = Aufrunden der zweiten Zahl und schreibt es in die erste oder aufrunden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_1 = §cNur Fließ-Komma-Zahlen können aufgerundet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_1 = §efloor §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_2 = §efloor §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_3 = Abrunden der zweiten Zahl und schreibt es in die erste oder abrunden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_1 = §cNur Fließ-Komma-Zahlen können abgerundet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_1 = §eround §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_2 = §eround §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_3 = Runden der zweiten Zahl und schreibt es in die erste oder runden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_1 = §cNur Fließ-Komma-Zahlen können gerundet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden
SCRIPT_COMMAND_IO_ECHO_HELP_1 = §eecho §8<§7Wert§8>
SCRIPT_COMMAND_IO_ECHO_HELP_2 = §7Schreibe etwas dem Spieler. Wenn kein Wert angegeben wurde ist die Nachricht leer.
SCRIPT_COMMAND_IO_ECHO_MESSAGE = §f{0}
SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_1 = §eechoactionbar §8<§7Wert§8>
SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Schreibe etwas dem Spieler in der ActionBar. Wenn kein Wert angegeben wurde ist die Nachricht leer.
SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7Variable§8> §8<§7Text§8>
SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Fordere eine Eingabe von dem Spieler, welche in die Variable geschrieben wird. Der Text ist optional.
SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Füge etwas in einen String an einer Stelle ein. Die Zahl ist für die Position und die Variable davor für was. Schreibe optional dies in eine neue oder andere Variable.
SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7Variable§8> §8<§7Von Variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Lösche eine Zeichenkette aus dem Ursprung. Dies ersetzt nicht nur die erste Stelle sondern alle.
SCRIPT_COMMAND_STRING_REPLACE_HELP_1 = §ereplace §8<§7Variable§8> §8<§7Von Variable§8> §8<§7Zu Variable§8>
SCRIPT_COMMAND_STRING_REPLACE_HELP_2 = §ereplace §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8> §8<§7Zu Variable§8>
SCRIPT_COMMAND_STRING_REPLACE_HELP_3 = Ersetzte eine Zeichenkette aus dem Ursprung mit einer neuen Zeichenkette. Dies ersetzt nicht nur die erste Stelle sondern alle.
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_1 = §esubstring §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_2 = §esubstring §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_SUBSTRING_HELP_3 = Kürze einen String entweder vorne oder hinter, je nachdem ob die Zahl positiv (vorne) oder negativ (hinten) ist.
SCRIPT_COMMAND_VARIABLE_CONST_HELP_1 = §econst §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_CONST_HELP_2 = Schreibt in eine Konstante einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text.
SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_1 = §econvert §8<§7Variable§8> §8<§7Value§8>
SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Konvertiere den Value zu 'number' wenn es eine Zahl ist, oder zu 'boolean' bei 'true' oder 'false' und behalte 'text' bei wenn nichts zutrifft.
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text.
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7Variable§8>
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Lösche eine Globale variable.
SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_1 = §eunvar §8<§7Variable§8>
SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Lösche eine Locale variable.
SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text.
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8>
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Schreibt das material von einem Block in der Welt in die Variable.
SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_1 = §esetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8>
SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2 = Setzt an einem Block in der Welt das Material der ersten Variable.
SCRIPT_COMMAND_EXIT_HELP_1 = §eexit
SCRIPT_COMMAND_EXIT_HELP_2 = Beendet das ausführen des Scripts.
SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7true/false§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7true/false§8> §8<§7jump-point§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_3 = §7Springe zu ersten Stelle, wenn der Wert true ist. Oder zu dem zweiten, wenn dies nicht der fall ist.
SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7Jump-Point§8>
SCRIPT_COMMAND_JUMP_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor.
SCRIPT_COMMAND_JUMP_ERROR = §cDer Jump-Point ({0}) ist nicht definiert.
SCRIPT_COMMAND_CALL_HELP_1 = §ecall §8<§7Jump-Point§8>
SCRIPT_COMMAND_CALL_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor. Hierbei wird auf den ReturnStack die jetzige Zeile geschrieben, dahin kann man wieder mit 'return' zurück springen.
SCRIPT_COMMAND_CALL_ERROR = §cDer Jump-Point ({0}) ist nicht definiert.
SCRIPT_COMMAND_RETURN_HELP_1 = §ereturn
SCRIPT_COMMAND_RETURN_HELP_2 = §7Springe zum letzten 'call' Befehl.
SCRIPT_COMMAND_RETURN_ERROR = §cEs wurde kein 'call' Befehl ausgeführt
SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7Time§8>
SCRIPT_COMMAND_SLEEP_HELP_2 = Pausiert das Ausführen des Scripts. Das erste Argument ist in GameTicks.
SCRIPT_COMMAND_SLEEP_ERROR = §cDie Zeit muss eine Zahl großer 0 sein.
## GUI
SCRIPT_GUI_ITEM_NAME = §eScript Hilfe
## CustomScript
SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} §8-§7 {1}
SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} §8-§7 {1}
SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e{0}
SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0}
SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0}
SCRIPT_COMMAND_ITEM_NAME = §7Befehl§8: §e/{0}
SCRIPT_ERROR_ONLY_IN_GLOBAL=§cDieses Skript kann nur als globales Skript ausgeführt werden
## Script Menu GUI
SCRIPT_MENU_GUI_ITEM_LORE_1 = §7Klicke zum rausnehmen
SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shift Klicke zum kopieren
SCRIPT_MENU_GUI_NAME = §eScript Commands {0}{1}§7%
SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shiftklick zum kopieren
SCRIPT_MENU_GUI_ITEM_LORE_3 = §7Rechtsklick zum editieren
SCRIPT_MENU_GUI_ITEM_LORE_4 = §7Mittelklick zum anschauen
SCRIPT_MENU_GUI_NAME = §eSkript-Menü
SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eHinzufügen
SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Klicke mit einem Buch zum hinzufügen
SCRIPT_MENU_GUI_DUPLICATE_COMMAND = §cCommand '{0}' bereits definiert
SCRIPT_MENU_GUI_UNKNOWN_EVENT = §cEvent '{0}' ist nicht definierbar
SCRIPT_MENU_GUI_LIMIT = §cScript-Buch Limit erreicht
## ScriptCommand
SCRIPT_COMMAND_HELP = §8/§escript §8- §7Öffnet die ScriptGUI
SCRIPT_COMMAND_HELP_MENU = §8/§escript menu §8- §7Öffnet die ScriptMenuGUI für Custom Command bauübergreifend
## Script GUI
SCRIPT_GUI_NAME = Script Elements
SCRIPT_GUI_COMMAND_CHAT = §eScript Command§8: §e{0}
SCRIPT_GUI_CUSTOM_HOTKEYS = §eCustom Hotkeys
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1 = §7Schreibe§8: §e#!HOTKEY 'Char'
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2 = §7am Anfang eines Skript Buches, um einen benutzerdefinierten Hotkey zu verwenden. Das 'Char' kann ein beliebiges Zeichen zwischen '§eA§7' und '§eZ§7' sowie '§e0§7' und '§e9§7' sein. Während der Ausführung sind zwei Variablen verfügbar: §epressed§7, §ereleased§7
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3 = §7Sie können dem Hotkey Modifikatoren wie "SHIFT", "CTRL", "ALT" oder "META" hinzufügen. §7Beispiel: §e#!HOTKEY SHIFT+A
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4 = §7
SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5 = §cDies kann nur in Verbindung mit den Fabric-Mod: §eAdvancedScripts §7runterladbar unter §ehttps://steamwar.de/downloads §cverwendet werden.
SCRIPT_GUI_CUSTOM_COMMANDS = §eCustom Commands
SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1 = §7Schreibe§8: §e#!CMD 'COMMAND'
SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2 = §7an den Anfang eines Script Buches um ein Custom Command zu nutzen. Der Befehl startet immer mit §e/§7 und kann dann so aufgebaut sein wie du willst. Alles was in Spitzen Klammern steht '§e<>§7' wird als Parameter und somit als Variable gewertet. Parameter, welche in runden Klammern stehen sind Optional. Einfache Texte als Parameter bekommen eine gleichnamige Variable mit true/false als Wert je nachdem ob dieser angegeben wurde oder nicht
SCRIPT_GUI_CUSTOM_EVENTS = §eCustom Events
SCRIPT_GUI_CUSTOM_EVENTS_LORE_1 = §7Schreibe§8: §e#!EVENT 'EventName'
SCRIPT_GUI_CUSTOM_EVENTS_LORE_2 = §7an den Anfang eines Script Buches um ein Custom Event zu nutzen. Jedes Event kann durch 'var cancel true' gecancelt werden. Hinter dem Event Namen stehen die Variablen, welche im Script durch das Event nutztbar sind.
SCRIPT_GUI_CUSTOM_EVENTS_LORE_3 = §7Nutzbare Events sind:
SCRIPT_GUI_CUSTOM_EVENTS_LORE_4 = §eFF
SCRIPT_GUI_CUSTOM_EVENTS_LORE_5 = §ePlaceBlock §8-§7 blockX, blockY, blockZ, blockType
SCRIPT_GUI_CUSTOM_EVENTS_LORE_6 = §eBreakBlock §8-§7 blockX, blockY, blockZ, blockType
SCRIPT_GUI_CUSTOM_EVENTS_LORE_7 = §eRightClick §8-§7 blockInHand, action, handType,
SCRIPT_GUI_CUSTOM_EVENTS_LORE_8 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e*
SCRIPT_GUI_CUSTOM_EVENTS_LORE_9 = §eLeftClick §8-§7 blockInHand, action, handType,
SCRIPT_GUI_CUSTOM_EVENTS_LORE_10 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e*
SCRIPT_GUI_CUSTOM_EVENTS_LORE_11 = §eTNTSpawn
SCRIPT_GUI_CUSTOM_EVENTS_LORE_12 = §eTNTExplode §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt, wenn die Variable davor auf §etrue§7 gesetzt ist.
SCRIPT_GUI_OTHER = §eOther
SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an.
SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points fangen mit §e.§7 an.
SCRIPT_GUI_OTHER_LORE_3 = §7Einen Variablennamen, der in '§e{}§7' eingeschlossen ist wird durch seinen Wert ersetzt. Eine Variable kann mit den Präfixen '§econst.§7' oder '§elocal.§7' oder '§eglobal.§7' versehen werden.
SCRIPT_GUI_OTHER_LORE_4 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_5 = §7- Lokalevariablen sind nur in dem Script-Buch verfügbar.
SCRIPT_GUI_OTHER_LORE_6 = §7- Gloablevariablen sind in jedem Script-Buch verfügbar.
SCRIPT_GUI_OTHER_LORE_7 = §7- Konstantevariablen sind Variablen vom Server (z.B. Spielername, TPS usw.)
SCRIPT_GUI_OTHER_LORE_8 = §7Eine Variable kann mit den Appendixen '§e.length§7' oder '§e.type§7' oder '§e.isset§7' versehen werden.
SCRIPT_GUI_OTHER_LORE_9 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_10 = §7- Length gibt die Länge der variable als Zahl zurück.
SCRIPT_GUI_OTHER_LORE_11 = §7- Type gibt den typen (number, floating number, text oder boolean) als Text zurück.
SCRIPT_GUI_OTHER_LORE_12 = §7- Isset gibt als boolean zurück, ob die Variable existiert.
SCRIPT_GUI_OTHER_LORE_13 = §7Mathematische sowie logische Operationsvorgänge können in '§e{}§7' angegeben werden.
SCRIPT_GUI_OTHER_LORE_14 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_15 = §7- Rechenoperatoren: §e+ * - /§7 sowie §e%§7 für Modulo
SCRIPT_GUI_OTHER_LORE_16 = §7- Logische Operatoren: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (Dies ist das Zeichen für oder)
SCRIPT_GUI_OTHER_LORE_17 = §7- Bitweise Operatoren: §e&§7; §e|§7; §e^
SCRIPT_GUI_OTHER_LORE_18 = §7- Shift Operatoren: §e<<§7; §e>>§7; §e>>>§7
SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0}
SCRIPT_GUI_CUSTOM_VARIABLES = §eCustom Variables
SCRIPT_GUI_CONSTANT_TIME_NAME = §7Constant §etime
SCRIPT_GUI_CONSTANT_TIME_LORE = §7Formattierte Uhrzeit
SCRIPT_GUI_CONSTANT_TICKS_NAME = §7Constant §eticks
SCRIPT_GUI_CONSTANT_TICKS_LORE = §7Ticks seit dem Serverstart
SCRIPT_GUI_CONSTANT_TRACE_NAME = §7Constant §etrace
SCRIPT_GUI_CONSTANT_TRACE_LORE = §etrue§7 wenn gerade der Tracer an ist.
SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME = §7Constant §eautotrace
SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 wenn gerade der AutoTracer an ist.
SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME = §7Constant §etrace_status
SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE = §7Ein Wert von: §eOFF§8, §eIDLE§8, §eIDLE_AUTO_EXPLODE§8, §eIDLE_AUTO_IGNITE§8, §eIDLE_SINGLE
SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME = §7Constant §etrace_time
SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE = §e0§7 wenn gerade kein TNT getraced wird, ansonsten die Zeit in Ticks seit dem Start des Tracers.
SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME = §7Constant §eloader_status
SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE = §7Ein Wert von: §eOFF§8, §eSETUP§8, §eRUNNING§8, §eSINGLE§8, §ePAUSE§8, §eEND
SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt
SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 wenn TNT nicht ausgeschaltet ist.
SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb
SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 wenn TNT Nur Testblock an ist.
SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze
SCRIPT_GUI_CONSTANT_FREEZE_LORE = §etrue§7 wenn Freeze nicht ausgeschaltet ist.
SCRIPT_GUI_CONSTANT_FIRE_NAME = §7Constant §efire
SCRIPT_GUI_CONSTANT_FIRE_LORE = §etrue§7 wenn Fire nicht ausgeschaltet ist.
SCRIPT_GUI_CONSTANT_PROTECT_NAME = §7Constant §eprotect
SCRIPT_GUI_CONSTANT_PROTECT_LORE = §etrue§7 wenn Protect angeschaltet ist.
SCRIPT_GUI_CONSTANT_X_NAME = §7Constant §ex
SCRIPT_GUI_CONSTANT_X_LORE = §ex§7 Position des Spielers.
SCRIPT_GUI_CONSTANT_Y_NAME = §7Constant §ey
SCRIPT_GUI_CONSTANT_Y_LORE = §ey§7 Position des Spielers.
SCRIPT_GUI_CONSTANT_Z_NAME = §7Constant §ez
SCRIPT_GUI_CONSTANT_Z_LORE = §ez§7 Position des Spielers.
SCRIPT_GUI_CONSTANT_NAME_NAME = §7Constant §ename
SCRIPT_GUI_CONSTANT_NAME_LORE = §eDisplay§7 Name des Spielers.
SCRIPT_GUI_CONSTANT_SNEAK_NAME = §7Constant §esneaking
SCRIPT_GUI_CONSTANT_SNEAK_LORE = §etrue§7 wenn der Spieler gerade sneakt.
SCRIPT_GUI_CONSTANT_SPRINTING_NAME = §7Constant §esprinting
SCRIPT_GUI_CONSTANT_SPRINTING_LORE = §etrue§7 wenn der Spieler gerade rennt.
SCRIPT_GUI_CONSTANT_SLOT_NAME = §7Constant §eslot
SCRIPT_GUI_CONSTANT_SLOT_LORE = §e0-8§7 für den ausgewählten slot.
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME = §7Constant §eslotmaterial
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE = §eMaterial§7 des Items im Slot
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME = §7Constant §eoffhandmaterial
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE = §eMaterial§7 des Items in der Off Hand
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME = §7Constant §ematerialname
SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 des Items im Slot
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 des Items in der Off Hand
SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type
SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eRegionstype§7 der jetztigen Region
SCRIPT_GUI_CONSTANT_REGION_NAME_NAME = §7Constant §eregion_name
SCRIPT_GUI_CONSTANT_REGION_NAME_LORE = §eRegionsname§7 der jetztigen Region
SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps
SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 vom Server
SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit
SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 vom Server
SCRIPT_DEPRECATED=§cDie Funktion §e{0}§c ist veraltet und wird demnächst entfernt. Bitte benutze §e{1}§c.
# Shield Printing
SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starte das Schild drucken
SHIELD_PRINTING_HELP_COPY = §8/§eshieldprinting copy §8- §7Kopiert die Schilder
SHIELD_PRINTING_HELP_APPLY = §8/§eshieldprinting apply §8- §7Wendet die Schilder an
SHIELD_PRINTING_HELP_STOP = §8/§eshieldprinting stop §8- §7Stoppt das Schild drucken
SHIELD_PRINTING_HELP_STEP_1 = §81. §7Füge die Schematic in die Welt ein
SHIELD_PRINTING_HELP_STEP_2 = §82. §7Starte das Schild drucken mit §8/§eshieldprinting start
SHIELD_PRINTING_HELP_STEP_3 = §83. §7Warte bis alle Schilde ausgefahren sind
SHIELD_PRINTING_HELP_STEP_4 = §84. §7Editiere die Schilde wenn nötig
SHIELD_PRINTING_HELP_STEP_5 = §85. §7Kopiere das gedruckte mit §8/§eshieldprinting copy
SHIELD_PRINTING_HELP_STEP_6 = §86. §7Füge die originale Schematic wieder ein
SHIELD_PRINTING_HELP_STEP_7 = §87. §7Wende das gedruckte mit §8/§eshieldprinting apply§7 an
SHIELD_PRINTING_NO_REGION = §cDu bist in keiner Region.
SHIELD_PRINTING_NOT_RUNNING = §cShield printing ist nicht aktiv.
SHIELD_PRINTING_DISALLOWED = §cDu darfst Shield printing nicht benutzen.
SHIELD_PRINTING_BOSSBAR = §fBewegungen: {0}
SHIELD_PRINTING_BOSSBAR_COPIED = §fBewegungen: {0} Kopiert: {1}
SHIELD_PRINTING_GUI_NAME = §7Schild Drucken
SHIELD_PRINTING_GUI_APPLY = §aAnwenden
SHIELD_PRINTING_GUI_STATE_PREVIOUS = §7R-Click§8: §7Vorherige
SHIELD_PRINTING_GUI_STATE_NEXT = §7L-Click§8: §7Nächste
SHIELD_PRINTING_GUI_STATE_ACTIVE = §e> §7{0}
SHIELD_PRINTING_GUI_STATE_INACTIVE = §8> §7{0}
SHIELD_PRINTING_GUI_STATE_FROM_ORIGINAL = Original
SHIELD_PRINTING_GUI_STATE_FROM_COPY = Kopie
SHIELD_PRINTING_GUI_STATE_ALWAYS_ON = An
SHIELD_PRINTING_GUI_STATE_ALWAYS_OFF = Aus
SHIELD_PRINTING_GUI_STATE_ALWAYS_OPEN = Offen
SHIELD_PRINTING_GUI_STATE_ALWAYS_CLOSED = Geschlossen
SHIELD_PRINTING_GUI_STATE_FENCE = §7{0} §fZaun Verbindungen
SHIELD_PRINTING_GUI_STATE_OPENABLE = §7{0} §fGeöffnet
SHIELD_PRINTING_GUI_STATE_PISTON = §7{0} §fAusgefahren
SHIELD_PRINTING_GUI_STATE_POWERABLE = §7{0} §fAktiviert
SHIELD_PRINTING_GUI_STATE_WALL = §7{0} §fWand Verbindungen
SHIELD_PRINTING_START = §aShield printing wurde gestartet.
SHIELD_PRINTING_COPY = §aSchilde wurden kopiert.
@ -578,7 +350,6 @@ SIMULATOR_GUI_TNT_GROUP_LORE_1 = §7Elementanzahl§8: §e{0}
SIMULATOR_GUI_TNT_DISABLED = §cDisabled
SIMULATOR_GUI_NAME = Kanonensimulator
SIMULATOR_GUI_DELETE = §cTNT löschen
SIMULATOR_GUI_START = §eStarten
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eAlle Verschieben
@ -647,26 +418,13 @@ KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus
BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick
BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
BLOCK_COUNTER_MESSAGE = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick
BLOCK_COUNTER_MESSAGE_SECOND = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht
# DepthCounter
DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Aktiviere den Tiefenzähler
DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deaktiviere den Tiefenzähler
DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Zähle aktive Zählmodi auf
DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Stelle einzelne Zählmodi ein
DEPTH_COUNTER_ENABLE_MESSAGE = §7Du hast den Tiefenzähler aktiviert.
DEPTH_COUNTER_DISABLE_MESSAGE = §7Du hast den Tiefenzähler deaktiviert.
DEPTH_COUNTER_ACTIVE_MESSAGE = §7Aktive Zählmodi: §e{0}§8.
DEPTH_COUNTER_MESSAGE = §7Schaden §8> §7{0}
DEPTH_COUNTER_HIGHLIGHT = §e
DEPTH_COUNTER_SEPARATOR = §7 §7
DEPTH_COUNTER_X = X: {0}
DEPTH_COUNTER_Y = Y: {0}
DEPTH_COUNTER_Z = Z: {0}
DEPTH_COUNTER_TNT = §7TNT§8: §e{0}
DEPTH_COUNTER_MESSAGE = §7Tiefe §8> §7
# TPSLimit
TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Spule n Ticks vor
@ -693,7 +451,7 @@ TPSLIMIT_INVALID_FROZEN = §c und '0'
# Trace
TRACE_RECORD=§aan
TRACE_IDLE=§caus
TRACE_HAS_TRACES=§ehat Traces
TRACE_IDLE_SINGLE=§esingle
TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8)
TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8)
@ -709,7 +467,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert
TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet
TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
TRACE_MESSAGE_NO_REGION = §cDu bist in keiner Region
TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen
TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen
@ -749,63 +506,87 @@ TRACE_GUI_POSITION_SOURCE = §7Ursprung§8: §e{0}
TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0}
# Loader
LOADER_OFF = §caus
LOADER_SETUP = §eEinrichtung
LOADER_RUNNING = §aLaufend
LOADER_SINGLE_SIDEBAR = §aEiner
LOADER_PAUSE = §7Pausiert
LOADER_END = §8Beendet
LOADER_MESSAGE_CLEAR = §7Loader gecleart
LOADER_MESSAGE_CLEAR_HELP = §cDu must im Setup-Modus sein um den Loader zu clearen
LOADER_MESSAGE_TNT = §eTNT hinzugefügt {0}
LOADER_MESSAGE_INTERACT = §e{0} hinzugefügt {1}
LOADER_BUTTON_TNT = TNT
LOADER_BUTTON_SWITCH=Hebel
LOADER_BUTTON_WOOD_BUTTON=Knopf
LOADER_BUTTON_STONE_BUTTON=Knopf
LOADER_BUTTON_WOOD_BUTTON=Holzknopf
LOADER_BUTTON_STONE_BUTTON=Steinknopf
LOADER_BUTTON_PRESSURE_PLATE=Druckplatte
LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Druckplatte
LOADER_BUTTON_TRIPWIRE=Tripwire
LOADER_BUTTON_NOTEBLOCK=Noteblock
LOADER_BUTTON_DAYLIGHTSENSOR=Tageslichtsensor
LOADER_BUTTON_INVALID=Invalider
LOADER_BUTTON_DAYLIGHT_DETECTOR=Tageslichtsensor
LOADER_BUTTON_COMPARATOR=Comparator
LOADER_BUTTON_REPEATER=Repeater
LOADER_BUTTON_LECTERN=Lectern
LOADER_BUTTON_TRAPDOOR=Trapdoor
LOADER_BUTTON_DOOR=Door
LOADER_BUTTON_FENCEGATE=Fencegate
LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen
LOADER_HELP_UNDO=§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion
LOADER_SETUP_STOP_FIRST=§cBitte stoppe zuerst den Loader
LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab
LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen
LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen
LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen
LOADER_HELP_RESUME=§8/§7loader resume §8- §7Spielt den Loader weiter ab
LOADER_HELP_GUI=§8/§7loader settings §8- §7Zeigt die Einstellungen an
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen
LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Cleart die Aufnahme
LOADER_HELP_SINGLE=§8/§eloader single §8- §7Spielt die Aufnahme einmal ab
LOADER_HELP_OTHER=§7Der Loader arbeitet mit §eIngame§8-§eTicks §7(20 Ticks pro Sekunde)
LOADER_NO_LOADER=§cDu hast noch keinen Loader. Erstelle dir einen mit /loader setup
LOADER_BACK_SETUP=§7Dein Loader ist nun wieder im Setup
LOADER_NEW=§7Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren.
LOADER_HOW_TO_START=§7Führe dann /§eloader start§7 um den Loader zu starten
LOADER_ACTIVE=§7Der Loader ist nun aktiviert.
LOADER_STOP=§7Der Loader ist nun gestoppt.
LOADER_PAUSED=§7Der Loader ist nun pausiert.
LOADER_RESUME=§7Der Loader läuft nun weiter.
LOADER_SINGLE=§7Der Loader schießt einmal.
LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein
LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}, zuvor {1}
LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0}, zuvor {1}
LOADER_UNDO=§7Undo erfolgreich.
LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen
LOADER_GUI_NAME=§eLoader
LOADER_GUI_NEW=§eNeuer Loader
LOADER_GUI_START=§eLoader starten
LOADER_GUI_PAUSE=§7Loader pausieren
LOADER_GUI_UNDO=§7Letzte Aktion Rückgängig machen
LOADER_GUI_WAIT=§7Schuss Delay
LOADER_GUI_WAIT_LORE=§7Aktuell: §e{0}
LOADER_GUI_WAIT_TITLE=§7Schuss Delay
LOADER_GUI_SPEED=§eGeschwindigkeit
LOADER_GUI_SPEED_LORE=§7Aktuell: §e{0}
LOADER_GUI_SPEED_TITLE=§7Block Platzier Geschwindigkeit
LOADER_GUI_STOP=§eLoader Stoppen
LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen!
LOADER_GUI_TITLE=Loader Einstellungen
LOADER_GUI_SHOW_INTERACTIONS=§eZeige Interaktionen
LOADER_GUI_SHOW_WAITS=§eZeige Wartezeiten
LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time zwischen TNT
LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time alle
LOADER_GUI_SHOW_WAITS_TITLE=§7Wartezeit
LOADER_GUI_SETTINGS_TITLE=Einstellungen
LOADER_GUI_SETTINGS_BACK=§8Zurück
LOADER_GUI_SETTINGS_DELETE=§cLöschen
LOADER_GUI_WAIT_TITLE=Wartezeit
LOADER_GUI_WAIT_BACK=§8Zurück
LOADER_GUI_CLICK_TO_EDIT=§7Click to edit
LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1}
LOADER_SETTING_NAME=§7{0}
LOADER_SETTING_MODES=§7Modes§8: §e{0}
LOADER_SETTING_POWER=§7Power§8: §e{0}
LOADER_SETTING_TICKS=§7Ticks§8: §e{0}
LOADER_SETTING_REPEATER=§7Repeater§8: §e{0}
LOADER_SETTING_WAIT=§7Wait§8: §e{0} Tick(s)
LOADER_SETTING_WAIT_NAME=Wait
LOADER_SETTING_TICKS_NAME=Ticks
LOADER_SETTING_TICKS_REMOVE_ONE=§c-1
LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5
LOADER_SETTING_TICKS_ADD_ONE=§a+1
LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5
LOADER_SETTING_TNT_NAME=§cTNT
LOADER_SETTING_TNT_X=§7X§8: §e{0}
LOADER_SETTING_TNT_Y=§7Y§8: §e{0}
LOADER_SETTING_TNT_Z=§7Z§8: §e{0}
LOADER_INTERACTION_NOOP=NOOP
LOADER_INTERACTION_INTERACT=Interact
LOADER_INTERACTION_POWERED=Powered
LOADER_INTERACTION_UNPOWERED=Unpowered
LOADER_INTERACTION_PAGE_PREV=Previous Page
LOADER_INTERACTION_PAGE_NEXT=Next Page
LOADER_INTERACTION_PAGE=Page {0}
LOADER_INTERACTION_ACTIVE=Active
LOADER_INTERACTION_INACTIVE=Inactive
LOADER_INTERACTION_WAIT_FOR=Wait for
LOADER_INTERACTION_NO_WAIT_FOR=No wait for
LOADER_INTERACTION_OPEN=Open
LOADER_INTERACTION_CLOSED=Closed
# Loadtimer
LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone
LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Startet den einfachen Loadtimer
@ -987,6 +768,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
REGION_FREEZE_NO_PERMS=§cDu darfst diese Welt nicht einfrieren
REGION_FREEZE_ENABLED=§cRegion eingefroren
REGION_FREEZE_DISABLED=§aRegion aufgetaut
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
REGION_ITEMS_NO_PERMS=§cDu darfst hier nicht Items (de-)aktivieren
REGION_ITEMS_ENABLED=§aItems aktiviert in dieser Region
REGION_ITEMS_DISABLED=§cItems deaktiviert in dieser Region
REGION_ITEMS_DISABLED_GLOBAL=§cItems sind auf dem Server deaktiviert.
REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region
REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben
REGION_PROTECT_ENABLE=§aBoden geschützt
@ -1043,6 +829,8 @@ REGION_TB_DONE=§7Testblock zurückgesetzt
REGION_TB_ERROR=§cFehler beim Zurücksetzen des Testblocks
REGION_TB_NO_PERMS=§cDu darfst hier nicht den Testblock zurücksetzen
REGION_TB_NO_REGION=§cDu befindest dich derzeit in keiner Region
REGION_TB_NO_SCHEMSHARING=§cDu kannst aktuell keine Schematics teilen bis {0}.
REGION_TB_NO_SCHEMRECEIVING=§cDer Besitzer dieses Bauservers kann keine Schematics erhalten bis {0}.
REGION_TNT_HELP=§8/§etnt §8- §7Ändere das TNT verhalten
REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus
REGION_TNT_ON=§aTNT-Schaden aktiviert
@ -1050,12 +838,6 @@ REGION_TNT_OFF=§cTNT-Schaden deaktiviert
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert
REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren
REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört
# Team
LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht!
LOCK_SCHEM_NO_SCHEM=§7Dieser Spieler besitzt keine Schematic mit diesem Namen!
LOCK_SCHEM_DIR=§7Die angegebene Schematic ist ein Ordner
LOCK_SCHEM_LOCKED=§e{0} §7von §e{1} §7wurde von §e{2} §7auf §eNORMAL §7zurück gesetzt.
LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] - §7Sperre eine Schematic (Nutzer über Sperrungsgrund informieren!)
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert.
AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt
@ -1249,7 +1031,7 @@ WARP_EXISTS=§7Ein Warp mit dem namen §e{0} §7existiert bereits
WARP_NAME_RESERVED=§7Du kannst nicht §c{0} §7als name für einen Warp nutzen
WARP_CREATED=§7Der Warp §e{0} §7wurde erstellt
WARP_DELETE_HOVER=§e{0} §7löschen
WARP_DELETED=§e{0} §7wurde gelöcht
WARP_DELETED=§e{0} §7wurde gelöscht
WARP_TELEPORT_HOVER=§7Zu §e{0} §7teleportieren
WARP_MATERIAL_CHOOSE=Material auswählen
WARP_GUI_NAME=Warps

Datei anzeigen

@ -21,6 +21,11 @@ package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.tpslimit.FreezeUtils;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
import de.steamwar.bausystem.features.world.RamUsage;
import de.steamwar.bausystem.region.loader.PrototypeLoader;
import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.loader.Updater;
@ -31,11 +36,16 @@ import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.logging.Level;
public class BauSystem extends JavaPlugin implements Listener {
@ -73,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener {
new Updater(RegionLoader.file, RegionLoader::load);
LinkageUtils.link();
RamUsage.init();
// This could disable any watchdog stuff. We need to investigate if this is a problem.
/*
@ -121,4 +132,45 @@ public class BauSystem extends JavaPlugin implements Listener {
}
}));
}
public static BukkitTask runTaskLater(Plugin plugin, Runnable runnable, long delay) {
return new BukkitRunnable() {
private int counter = 1;
@Override
public void run() {
if (FreezeUtils.isFrozen()) return;
if (counter >= delay) {
runnable.run();
cancel();
return;
}
counter++;
}
}.runTaskTimer(plugin, 0, 1);
}
public static BukkitTask runTaskTimer(Plugin plugin, Runnable runnable, long delay, long period) {
return new BukkitRunnable() {
private int counter = 1;
private boolean first = true;
@Override
public void run() {
if (FreezeUtils.isFrozen()) return;
if (counter >= (first ? delay : period)) {
first = false;
runnable.run();
counter = 1;
return;
}
counter++;
}
}.runTaskTimer(plugin, 0, 1);
}
public static void runTaskTimer(Plugin plugin, Consumer<BukkitTask> consumer, long delay, long period) {
AtomicReference<BukkitTask> task = new AtomicReference<>();
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
}
}

Datei anzeigen

@ -88,7 +88,7 @@ public class AutostartListener implements Listener {
} else {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_START", player);
}
regionStartTime.put(region, TPSUtils.currentTick.get());
regionStartTime.put(region, TPSUtils.currentRealTick.get());
}
@EventHandler
@ -101,7 +101,7 @@ public class AutostartListener implements Listener {
if (!regionStartTime.containsKey(region)) return;
if (!region.hasType(RegionType.TESTBLOCK)) return;
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
long tickDiff = TPSUtils.currentTick.get() - regionStartTime.remove(region);
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
RegionUtils.message(region, player -> {
return BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_RESULT1", player, new SimpleDateFormat(BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_DATE_PATTERN", player)).format(new Date(tickDiff * 50)));
});

Datei anzeigen

@ -19,10 +19,15 @@
package de.steamwar.bausystem.features.backup;
import com.sk89q.worldedit.EditSession;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
@ -85,7 +90,14 @@ public class BackupCommand extends SWCommand {
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
return;
}
region.reset(backupFile);
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor())
.minPoint(region.getMinPoint())
.maxPoint(region.getMaxPoint())
.waterLevel(region.getWaterLevel())
.run();
region.remember(editSession);
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
}

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.SteamwarUser;
@ -58,6 +59,9 @@ public class BauInfoBauGuiItem extends BauGuiItem {
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
continue;
}
if (flag == Flag.ITEMS && Core.getVersion() < 19) {
continue;
}
Flag.Value<?> value = region.get(flag);
if (value != null) {
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));

Datei anzeigen

@ -0,0 +1,99 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.cannon;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.cannon.depth.Depth;
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Linked
public class CannonDetector implements Listener {
private Map<TNTPrimed, Vector> velocities = new HashMap<>();
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) {
return;
}
TNTPrimed tnt = (TNTPrimed) event.getEntity();
DepthManager.update(tnt, event.blockList());
List<TNTPrimed> tnts = Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class)
.stream()
.filter(entity -> entity != tnt)
.filter(entity -> entity.getFuseTicks() > 1)
.filter(entity -> entity.getLocation().distance(event.getLocation()) <= 8)
.collect(Collectors.toList());
if (tnts.isEmpty()) {
return;
}
boolean isEmpty = velocities.isEmpty();
tnts.forEach(tntPrimed -> {
velocities.put(tntPrimed, tntPrimed.getVelocity().clone());
});
if (!isEmpty) {
return;
}
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
Map<CannonKey, List<TNTPrimed>> grouped = new HashMap<>();
velocities.forEach((tntPrimed, vector) -> {
grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed);
});
grouped.forEach((cannonKey, tntPrimeds) -> {
if (tntPrimeds.size() <= 5) return;
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
if (region.isGlobal()) return;
if (!region.hasType(RegionType.TESTBLOCK)) return;
Depth depth = new Depth(region);
DepthManager.init(tntPrimeds, depth);
});
velocities.clear();
}, 1);
}
private Vector round(Vector vector) {
vector.multiply(10000);
vector.setX(Math.round(vector.getX()));
vector.setY(Math.round(vector.getY()));
vector.setZ(Math.round(vector.getZ()));
return vector;
}
}

Datei anzeigen

@ -0,0 +1,33 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.cannon;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.bukkit.util.Vector;
@AllArgsConstructor
@EqualsAndHashCode
@Getter
public final class CannonKey {
private Vector locationVector;
private Vector velocityVector;
}

Datei anzeigen

@ -0,0 +1,110 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.cannon.depth;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class Depth {
private Region region;
private Vector minVector = null;
private Vector maxVector = null;
private int tntCount = 0;
public Depth(Region region) {
this.region = region;
}
public void update(List<Block> blocks) {
List<Block> blocksList = blocks.stream()
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
.collect(Collectors.toList());
if (blocksList.isEmpty()) return;
tntCount++;
for (Block block : blocksList) {
internalUpdate(block);
}
}
public void finish() {
if (maxVector == null || minVector == null) return;
Vector dimensions = maxVector.subtract(minVector);
dimensions.setX(Math.abs(dimensions.getX()));
dimensions.setY(Math.abs(dimensions.getY()));
dimensions.setZ(Math.abs(dimensions.getZ()));
RegionUtils.message(region, player -> {
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
});
}
private void internalUpdate(Block block) {
if (minVector == null) {
minVector = block.getLocation().toVector();
}
minVector.setX(Math.min(minVector.getX(), block.getX()));
minVector.setY(Math.min(minVector.getY(), block.getY()));
minVector.setZ(Math.min(minVector.getZ(), block.getZ()));
if (maxVector == null) {
maxVector = block.getLocation().toVector();
}
maxVector.setX(Math.max(maxVector.getX(), block.getX()));
maxVector.setY(Math.max(maxVector.getY(), block.getY()));
maxVector.setZ(Math.max(maxVector.getZ(), block.getZ()));
}
private static BaseComponent[] getMessage(Player player, int x, int y, int z, int tntCount) {
final Set<Integer> dimensions = new HashSet<>();
dimensions.add(x);
dimensions.add(y);
dimensions.add(z);
int max = getMax(dimensions);
TextComponent headerComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_MESSAGE", player));
TextComponent depthComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_COUNT", player, x == max ? "§e" : "§7", x, y == max ? "§e" : "§7", y, z == max ? "§e" : "§7", z));
depthComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_HOVER", player))}));
TextComponent tntComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_TNT", player, tntCount));
return new BaseComponent[]{headerComponent, depthComponent, tntComponent};
}
private static int getMax(Set<Integer> values) {
return values.stream().max(Integer::compare).orElse(0);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.cannon.depth;
import lombok.experimental.UtilityClass;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@UtilityClass
public class DepthManager {
private Map<TNTPrimed, Depth> depths = new HashMap<>();
public void init(List<TNTPrimed> list, Depth depth) {
for (TNTPrimed tnt : list) {
depths.putIfAbsent(tnt, depth);
}
}
public void update(TNTPrimed tnt, List<Block> blocks) {
Depth depth = depths.remove(tnt);
if (depth == null) return;
depth.update(blocks);
if (depths.containsValue(depth)) return;
depth.finish();
}
}

Datei anzeigen

@ -0,0 +1,109 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.design.endstone;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DesignEndStone {
private static final World WORLD = Bukkit.getWorlds().get(0);
private int minX, minY, minZ, maxX, maxY, maxZ;
private REntityServer entityServer = new REntityServer();
private List<REntity> entities = new ArrayList<>();
private Set<Location> locations = new HashSet<>();
private List<Player> players = new ArrayList<>();
public DesignEndStone(Region region) {
this.minX = region.getMinPointBuild().getX();
this.minY = region.getMinPointBuild().getY();
this.minZ = region.getMinPointBuild().getZ();
this.maxX = region.getMaxPointBuild().getX();
this.maxY = region.getMaxPointBuild().getY();
this.maxZ = region.getMaxPointBuild().getZ();
}
private void calc() {
entities.forEach(REntity::die);
entities.clear();
locations.clear();
calc(minX, minY, minZ, maxX, maxY, minZ, 0, 0, 1, maxZ - minZ);
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
// calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY);
calc(minX, maxY, minZ, maxX, maxY, maxZ, 0, -1, 0, maxY - minY);
}
private void calc(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dirX, int dirY, int dirZ, int steps) {
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int step = 0; step < steps; step++) {
int cx = x + step * dirX;
int cy = y + step * dirY;
int cz = z + step * dirZ;
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
if (material == Material.END_STONE || material == Material.END_STONE_BRICKS || material == Material.END_STONE_BRICK_SLAB || material == Material.END_STONE_BRICK_STAIRS || material == Material.END_STONE_BRICK_WALL) {
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
if (locations.contains(location)) break;
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
entity.setNoGravity(true);
entity.setGlowing(true);
entities.add(entity);
break;
} else if (!material.isAir()) {
break;
}
}
}
}
}
}
public void toggle(Player player) {
if (players.contains(player)) {
players.remove(player);
entityServer.removePlayer(player);
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR);
} else {
players.add(player);
entityServer.addPlayer(player);
calc();
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR);
}
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.design.endstone;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
@Linked
public class DesignEndStoneCommand extends SWCommand {
public DesignEndStoneCommand() {
super("designendstone");
}
private Map<Region, DesignEndStone> designEndStoneMap = new HashMap<>();
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
public void genericCommand(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.hasType(RegionType.BUILD)) {
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
return;
}
designEndStoneMap.computeIfAbsent(region, DesignEndStone::new).toggle(player);
}
}

Datei anzeigen

@ -293,7 +293,7 @@ public class KillcheckerVisualizer {
private void updateBossBar(Player player) {
BauSystemBossbar bossbar = bossBarService.get(player, region, "killchecker");
bossbar.setTitle(BauSystem.MESSAGE.parse("KILLCHECKER_BOSSBAR", player, kills, ((int) (percent * 1000) / 10.0), cannonCount));
bossbar.setProgress(percent);
bossbar.setProgress(Math.min(Math.max(percent, 0), 1));
if (percent >= 0.35) {
bossbar.setColor(BarColor.RED);

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,214 +20,223 @@
package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.loader.activations.AbstractLoaderActivation;
import de.steamwar.bausystem.features.loader.activations.BlockPlaceLoaderActivation;
import de.steamwar.bausystem.features.loader.activations.InteractionActivation;
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait;
import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.AccessLevel;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
@Getter
@Setter
public class Loader implements Listener {
private static final Map<Player, Loader> LOADER_MAP = new HashMap<>();
public static Loader getLoader(Player player) {
return LOADER_MAP.get(player);
}
public static void newLoader(Player player) {
LOADER_MAP.put(player, new Loader(player));
}
private final Player p;
private final List<AbstractLoaderActivation> actions = new LinkedList<>();
private int ticksBetweenShots = 80;
private int ticksBetweenBlocks = 1;
private Stage stage;
private int lastActivation = -1;
private int countdown = 0;
@Getter(AccessLevel.PRIVATE)
private final BukkitTask task;
@Getter
private Stage stage = Stage.SETUP;
private LoaderRecorder recorder;
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
private AbstractLoaderActivation current;
private List<LoaderElement> elements = new ArrayList<>();
private int currentElement = 0;
private long waitTime = 0;
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
private ListIterator<AbstractLoaderActivation> iterator;
private Loader(Player p) {
public Loader(Player p) {
this.p = p;
stage = Stage.SETUP;
this.recorder = new LoaderRecorder(p, elements);
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1);
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
if (stage != Stage.RUNNING) return;
if (waitTime > 0) {
waitTime--;
return;
}
public static Loader getLoader(Player p) {
return LOADER_MAP.getOrDefault(p, null);
while (currentElement < elements.size()) {
LoaderElement element = elements.get(currentElement);
currentElement++;
element.execute(delay -> waitTime = delay);
if (waitTime > 0) {
break;
}
public static Loader newLoader(Player p) {
return LOADER_MAP.put(p, new Loader(p));
}
if (currentElement >= elements.size()) {
currentElement = 0;
}
}, 0, 1);
}
public void start() {
if (stage != Stage.SETUP) return;
iterator = actions.listIterator();
countdown = 0;
current = null;
if (stage == Stage.END) return;
if (stage == Stage.RUNNING) return;
stage = Stage.RUNNING;
if (recorder != null) {
recorder.stop();
recorder = null;
}
if (elements.isEmpty()) {
BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p);
stop();
}
}
public void pause() {
if (stage == Stage.RUNNING) {
if (stage == Stage.END) return;
if (stage == Stage.PAUSE) return;
stage = Stage.PAUSE;
if (recorder != null) {
recorder.stop();
recorder = null;
}
}
public void resume() {
if (stage == Stage.PAUSE) {
stage = Stage.RUNNING;
}
}
public void setup() {
stage = Stage.SETUP;
iterator = null;
current = null;
countdown = 0;
}
public void stop() {
stage = Stage.END;
task.cancel();
LOADER_MAP.remove(p, this);
if (recorder != null) {
recorder.stop();
recorder = null;
}
elements.clear();
LOADER_MAP.remove(p);
}
public void clear() {
if (stage == Stage.SETUP) {
actions.clear();
BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR", p);
public void gui(SettingsSorting settingsSorting) {
List<SWListInv.SWListEntry<LoaderElement>> list = new ArrayList<>();
Runnable updateRunnable = () -> {
list.clear();
for (LoaderElement element : elements) {
if (settingsSorting != null) {
if (settingsSorting == SettingsSorting.WAIT && !(element instanceof LoaderWait)) {
continue;
}
if (settingsSorting == SettingsSorting.INTERACTIONS && (element instanceof LoaderWait || element instanceof LoaderTNT)) {
continue;
}
}
SWItem item = element.menu(p);
if (element instanceof LoaderInteractionElement<?>) {
LoaderInteractionElement<?> interactionElement = (LoaderInteractionElement<?>) element;
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_MODES", p, interactionElement.size()), "§8", BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p)));
} else {
BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR_HELP", p);
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p)));
}
list.add(new SWListInv.SWListEntry<>(item, element));
}
};
updateRunnable.run();
public void single() {
if (stage != Stage.PAUSE && stage != Stage.SETUP) return;
if (iterator == null || !iterator.hasNext()) {
iterator = actions.listIterator();
countdown = 0;
current = null;
SWListInv<LoaderElement> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {});
swListInv.setCallback((clickType, entry) -> entry.click(p, () -> {
updateRunnable.run();
swListInv.open();
}));
SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_INTERACTIONS", p), clickType -> {
gui(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS);
});
if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true);
swListInv.setItem(47, onlyInteractionsElements);
SWItem onlyWaitElements = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS", p), clickType -> {
gui(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT);
});
if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true);
swListInv.setItem(48, onlyWaitElements);
if (settingsSorting == SettingsSorting.WAIT) {
SWItem waitBetweenTNT = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT", p), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), "");
swAnvilInv.setCallback(s -> {
try {
long delay = Long.parseLong(s);
if (delay < 0) delay = 0;
for (int i = 1; i < elements.size() - 1; i++) {
if (!(elements.get(i - 1) instanceof LoaderTNT)) continue;
if (!(elements.get(i + 1) instanceof LoaderTNT)) continue;
if (!(elements.get(i) instanceof LoaderWait)) continue;
((LoaderWait) elements.get(i)).setDelay(delay);
}
stage = Stage.SINGLE;
} catch (NumberFormatException ignored) {
}
gui(settingsSorting);
});
updateRunnable.run();
swAnvilInv.open();
});
swListInv.setItem(50, waitBetweenTNT);
public void run() {
if (stage == Stage.SETUP && lastActivation >= 0)
lastActivation++;
if (stage != Stage.RUNNING && stage != Stage.SINGLE) {
return;
SWItem waitTime = new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_ALL", p), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), "");
swAnvilInv.setCallback(s -> {
try {
long delay = Long.parseLong(s);
if (delay < 0) delay = 0;
long finalDelay = delay;
elements.stream()
.filter(LoaderWait.class::isInstance)
.map(LoaderWait.class::cast)
.forEach(loaderWait -> loaderWait.setDelay(finalDelay));
} catch (NumberFormatException ignored) {
}
if (countdown-- > 0) {
return;
}
while (countdown <= 0) {
if (!iterator.hasNext()) {
countdown = getTicksBetweenShots();
iterator = actions.listIterator();
if (stage == Stage.SINGLE) stage = Stage.PAUSE;
return;
}
current = iterator.next();
if (current.execute()) {
countdown = current.delay(this);
gui(settingsSorting);
});
updateRunnable.run();
swAnvilInv.open();
});
swListInv.setItem(51, waitTime);
} else {
countdown = 1;
iterator.previous();
}
}
SWItem empty = new SWItem(Material.STRUCTURE_VOID, "§7", clickType -> {});
swListInv.setItem(50, empty);
swListInv.setItem(51, empty);
}
public void undo() {
if (actions.isEmpty() || stage != Stage.SETUP) {
return;
}
actions.remove(actions.size() - 1);
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getPlayer() != p) {
return;
}
if (stage != Stage.SETUP) {
return;
}
if (event.getBlock().getType() != Material.TNT) {
return;
}
actions.add(new BlockPlaceLoaderActivation(p, event.getBlock().getLocation(), Material.TNT));
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_TNT", p, actions.size()));
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer() != p) {
return;
}
if (stage != Stage.SETUP) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL)
return;
if (event.getClickedBlock().getType() == Material.OBSERVER)
return;
LoaderButton button = LoaderButton.fromBlock(event.getClickedBlock());
if (button != LoaderButton.INVALID) {
actions.add(InteractionActivation.construct(p, event.getClickedBlock().getLocation(), this));
lastActivation = 0;
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", p, BauSystem.MESSAGE.parse(button.getName(), p), actions.size()));
}
swListInv.open();
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() != p) {
return;
}
if (event.getPlayer() != p) return;
stop();
}
public String getProgress() {
return (currentElement + 1) + "§8/§7" + elements.size();
}
public enum SettingsSorting {
WAIT,
INTERACTIONS,
}
@AllArgsConstructor
public enum Stage implements EnumDisplay {
SETUP("LOADER_SETUP"),
RUNNING("LOADER_RUNNING"),
SINGLE("LOADER_SINGLE_SIDEBAR"),
PAUSE("LOADER_PAUSE"),
END("LOADER_END");
@Getter
private String chatValue;
private final String chatValue;
}
}

Datei anzeigen

@ -1,107 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
@Linked
public class LoaderBauGuiItem extends BauGuiItem {
public LoaderBauGuiItem() {
super(9);
}
@Override
public ItemStack getItem(Player player) {
return SWUtils.setCustomModelData(new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)), 1).getItemStack();
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
openLoaderGui(p);
return false;
}
private void openLoaderGui(Player p) {
SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", p));
if (Loader.getLoader(p) == null) {
inv.setItem(4, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("LOADER_GUI_NEW", p), clickType -> {
p.closeInventory();
p.performCommand("loader setup");
}));
} else {
Loader loader = Loader.getLoader(p);
if (loader.getStage() != Loader.Stage.RUNNING) {
inv.setItem(0, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_START", p), clickType -> {
p.closeInventory();
p.performCommand("loader start");
}));
} else {
inv.setItem(0, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_PAUSE", p), clickType -> {
p.closeInventory();
p.performCommand("loader pause");
}));
}
inv.setItem(2, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_UNDO", p), clickType -> {
p.closeInventory();
p.performCommand("loader undo");
}));
inv.setItem(4, new SWItem(Material.COMPASS, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_LORE", p, loader.getTicksBetweenShots())), false, clickType -> {
p.closeInventory();
SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", p));
anvilInv.setItem(Material.CLOCK);
anvilInv.setCallback(s -> p.performCommand("loader delay " + s));
anvilInv.open();
}));
inv.setItem(6, new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_LORE", p, loader.getTicksBetweenBlocks())), false, clickType -> {
p.closeInventory();
SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_TITLE", p));
anvilInv.setItem(Material.CLOCK);
anvilInv.setCallback(s -> p.performCommand("loader speed " + s));
anvilInv.open();
}));
inv.setItem(8, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_STOP", p), clickType -> {
p.closeInventory();
p.performCommand("loader stop");
}));
}
inv.open();
}
@Override
public Permission permission() {
return Permission.WORLD;
}
}

Datei anzeigen

@ -1,79 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.block.Block;
@AllArgsConstructor
@RequiredArgsConstructor
@Getter
public enum LoaderButton {
SWITCH(0, true, "LOADER_BUTTON_SWITCH"),
WOOD_BUTTON(30, "LOADER_BUTTON_WOOD_BUTTON"),
STONE_BUTTON(20, "LOADER_BUTTON_STONE_BUTTON"),
PRESSURE_PLATE(30, "LOADER_BUTTON_PRESSURE_PLATE"),
WEIGHTED_PRESSURE_PLATE(20, "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE"),
TRIPWIRE(30, "LOADER_BUTTON_TRIPWIRE"),
NOTEBLOCK(1, "LOADER_BUTTON_NOTEBLOCK"),
DAYLIGHTSENSOR(0, true, "LOADER_BUTTON_DAYLIGHTSENSOR"),
INVALID(-1, "LOADER_BUTTON_INVALID");
private final int time;
private boolean toggle;
private final String name;
public static LoaderButton fromBlock(Block block) {
switch (block.getType()) {
case LEVER:
return LoaderButton.SWITCH;
case ACACIA_BUTTON:
case BIRCH_BUTTON:
case DARK_OAK_BUTTON:
case JUNGLE_BUTTON:
case OAK_BUTTON:
case SPRUCE_BUTTON:
return LoaderButton.WOOD_BUTTON;
case STONE_BUTTON:
return LoaderButton.STONE_BUTTON;
case ACACIA_PRESSURE_PLATE:
case BIRCH_PRESSURE_PLATE:
case DARK_OAK_PRESSURE_PLATE:
case JUNGLE_PRESSURE_PLATE:
case OAK_PRESSURE_PLATE:
case SPRUCE_PRESSURE_PLATE:
case STONE_PRESSURE_PLATE:
return LoaderButton.PRESSURE_PLATE;
case HEAVY_WEIGHTED_PRESSURE_PLATE:
case LIGHT_WEIGHTED_PRESSURE_PLATE:
return LoaderButton.WEIGHTED_PRESSURE_PLATE;
case TRIPWIRE:
return LoaderButton.TRIPWIRE;
case NOTE_BLOCK:
return LoaderButton.NOTEBLOCK;
case DAYLIGHT_DETECTOR:
return LoaderButton.DAYLIGHTSENSOR;
default:
return LoaderButton.INVALID;
}
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -30,8 +30,7 @@ import org.bukkit.entity.Player;
public class LoaderCommand extends SWCommand {
public LoaderCommand() {
super("loader", "autoloader", "al");
addDefaultHelpMessage("LOADER_HELP_OTHER");
super("loader");
}
private boolean loaderNullCheck(Loader loader, Player p) {
@ -43,112 +42,45 @@ public class LoaderCommand extends SWCommand {
}
@Register(value = "setup", description = "LOADER_HELP_SETUP")
public void setupLoader(@Validator Player p) {
if (Loader.getLoader(p) != null) {
Loader.getLoader(p).setup();
BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p);
} else {
Loader.newLoader(p);
BauSystem.MESSAGE.send("LOADER_NEW", p);
BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p);
public void setupLoader(@Validator Player player) {
if (Loader.getLoader(player) != null) {
BauSystem.MESSAGE.send("LOADER_SETUP_STOP_FIRST", player);
return;
}
Loader.newLoader(player);
BauSystem.MESSAGE.send("LOADER_NEW", player);
BauSystem.MESSAGE.send("LOADER_HOW_TO_START", player);
}
@Register(value = "start", description = "LOADER_HELP_START")
public void startLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
public void startLoader(@Validator Player player) {
Loader loader = Loader.getLoader(player);
if (loaderNullCheck(loader, player)) return;
loader.start();
BauSystem.MESSAGE.send("LOADER_ACTIVE", p);
BauSystem.MESSAGE.send("LOADER_ACTIVE", player);
}
@Register(value = "stop", description = "LOADER_HELP_STOP")
public void stopLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
public void stopLoader(@Validator Player player) {
Loader loader = Loader.getLoader(player);
if (loaderNullCheck(loader, player)) return;
loader.stop();
BauSystem.MESSAGE.send("LOADER_STOP", p);
BauSystem.MESSAGE.send("LOADER_STOP", player);
}
@Register(value = "pause", description = "LOADER_HELP_PAUSE")
public void pauseLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
public void pauseLoader(@Validator Player player) {
Loader loader = Loader.getLoader(player);
if (loaderNullCheck(loader, player)) return;
loader.pause();
BauSystem.MESSAGE.send("LOADER_PAUSED", p);
BauSystem.MESSAGE.send("LOADER_PAUSED", player);
}
@Register(value = "resume", description = "LOADER_HELP_RESUME")
public void resumeLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
loader.resume();
BauSystem.MESSAGE.send("LOADER_RESUME", p);
}
@Register(value = "wait", description = "LOADER_HELP_WAIT")
public void shotDelayLoader(@Validator Player p, int delay) {
if (delay < 1) {
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
return;
}
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots());
loader.setTicksBetweenShots(delay);
}
@Register(value = "speed", description = "LOADER_HELP_SPEED")
public void speedLoader(@Validator Player p, int delay) {
if (delay < 0) {
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
return;
}
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay, loader.getTicksBetweenBlocks());
loader.setTicksBetweenBlocks(delay);
}
@Register(value = "undo", description = "LOADER_HELP_UNDO")
public void undoLast(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
BauSystem.MESSAGE.send("LOADER_UNDO", p);
loader.undo();
}
@Register(value = "clear", description = "LOADER_HELP_CLEAR")
public void clearLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
loader.clear();
}
@Register(value = "single", description = "LOADER_HELP_SINGLE")
public void singleLoader(@Validator Player p) {
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
loader.single();
BauSystem.MESSAGE.send("LOADER_SINGLE", p);
@Register(value = "gui", description = "LOADER_HELP_GUI")
public void guiLoader(@Validator Player player) {
Loader loader = Loader.getLoader(player);
if (loaderNullCheck(loader, player)) return;
loader.gui(null);
}
@ClassValidator(value = Player.class, local = true)

Datei anzeigen

@ -0,0 +1,203 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
import de.steamwar.bausystem.features.loader.elements.impl.*;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.EquipmentSlot;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LoaderRecorder implements Listener {
private Player player;
private List<LoaderElement> loaderElementList;
private long lastInteraction = TPSUtils.currentRealTick.get();
public LoaderRecorder(Player player, List<LoaderElement> loaderElementList) {
this.player = player;
this.loaderElementList = loaderElementList;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
}
public void stop() {
addWaitTime(true);
HandlerList.unregisterAll(this);
player = null;
blockSet.clear();
}
private void addWaitTime(boolean last) {
if (loaderElementList.isEmpty()) {
lastInteraction = TPSUtils.currentRealTick.get();
return;
}
if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) {
return;
}
long diff = TPSUtils.currentRealTick.get() - lastInteraction;
if (last && diff > 160) diff = 160;
lastInteraction = TPSUtils.currentRealTick.get();
loaderElementList.add(new LoaderWait(diff));
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getPlayer() != player) return;
if (event.getBlock().getType() != Material.TNT) return;
addWaitTime(false);
loaderElementList.add(new LoaderTNT(event.getBlock().getLocation()));
message("LOADER_BUTTON_TNT");
}
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEvent event) {
if (event.getPlayer() != player) return;
if (player.isSneaking()) return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return;
if (event.getClickedBlock().getType() == Material.OBSERVER) return;
if (event.getHand() == EquipmentSlot.OFF_HAND) return;
addWaitTime(false);
Block block = event.getClickedBlock();
Material type = block.getType();
switch (type) {
case COMPARATOR:
loaderElementList.add(new LoaderComparator(block.getLocation()));
message("LOADER_BUTTON_COMPARATOR");
break;
case REPEATER:
loaderElementList.add(new LoaderRepeater(block.getLocation()));
message("LOADER_BUTTON_REPEATER");
break;
case NOTE_BLOCK:
loaderElementList.add(new LoaderNoteBlock(block.getLocation()));
message("LOADER_BUTTON_NOTEBLOCK");
break;
case LEVER:
loaderElementList.add(new LoaderLever(block.getLocation()));
message("LOADER_BUTTON_SWITCH");
break;
case DAYLIGHT_DETECTOR:
loaderElementList.add(new LoaderDaylightDetector(block.getLocation()));
message("LOADER_BUTTON_DAYLIGHT_DETECTOR");
break;
case LECTERN:
loaderElementList.add(new LoaderLectern(block.getLocation()));
message("LOADER_BUTTON_LECTERN");
break;
case IRON_TRAPDOOR:
break;
default:
if (type.name().endsWith("_TRAPDOOR")) {
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_TRAPDOOR", type));
message("LOADER_BUTTON_TRAPDOOR");
} else if (type.name().endsWith("_DOOR")) {
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_DOOR", type));
message("LOADER_BUTTON_DOOR");
} else if (type.name().endsWith("FENCE_GATE")) {
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_FENCEGATE", type));
message("LOADER_BUTTON_FENCEGATE");
} else if (type.name().endsWith("STONE_BUTTON")) {
loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_STONE_BUTTON", type, 20));
message("LOADER_BUTTON_STONE_BUTTON");
} else if (type.name().endsWith("BUTTON")) {
loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_WOOD_BUTTON", type, 30));
message("LOADER_BUTTON_WOOD_BUTTON");
}
break;
}
}
private Map<Location, Long> blockSet = new HashMap<>();
private Map<Location, LoaderMovement> movementSet = new HashMap<>();
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if (event.getPlayer() != player) return;
Block fromBlock = event.getFrom().getBlock();
Block toBlock = event.getTo().getBlock();
calcMovementBlocks(fromBlock, toBlock);
fromBlock = fromBlock.getRelative(0, 1, 0);
toBlock = toBlock.getRelative(0, 1, 0);
calcMovementBlocks(fromBlock, toBlock);
}
private void calcMovementBlocks(Block fromBlock, Block toBlock) {
if (!blockSet.containsKey(toBlock.getLocation())) {
Long startTime = blockSet.remove(fromBlock.getLocation());
LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation());
if (loaderMovement != null && startTime != null) {
loaderMovement.setInitialTicks(TPSUtils.currentRealTick.get() - startTime);
}
blockSet.put(toBlock.getLocation(), TPSUtils.currentRealTick.get());
addWaitTime(false);
loaderMovement = null;
Material type = toBlock.getType();
switch (type) {
case TRIPWIRE:
loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_TRIPWIRE", Material.STRING);
message("LOADER_BUTTON_TRIPWIRE");
break;
case LIGHT_WEIGHTED_PRESSURE_PLATE:
case HEAVY_WEIGHTED_PRESSURE_PLATE:
loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE", type);
message("LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE");
break;
default:
if (type.name().endsWith("PRESSURE_PLATE")) {
loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_PRESSURE_PLATE", type);
message("LOADER_BUTTON_PRESSURE_PLATE");
}
break;
}
if (loaderMovement != null) {
movementSet.put(toBlock.getLocation(), loaderMovement);
loaderElementList.add(loaderMovement);
}
}
}
private void message(String type) {
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", player, BauSystem.MESSAGE.parse(type, player), loaderElementList.size()));
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@Linked
public class LoaderScoreboardElement implements ScoreboardElement {
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.OTHER;
}
@Override
public int order() {
return 2;
}
@Override
public String get(Region region, Player p) {
Loader loader = Loader.getLoader(p);
if (loader == null) return null;
if (loader.getStage() == Loader.Stage.RUNNING) {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §a" + loader.getProgress();
} else if (loader.getStage() == Loader.Stage.PAUSE) {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §c" + loader.getProgress();
} else {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p);
}
}
}

Datei anzeigen

@ -1,36 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.activations;
import de.steamwar.bausystem.features.loader.Loader;
import org.bukkit.entity.Player;
public abstract class AbstractLoaderActivation {
Player p;
public AbstractLoaderActivation(Player p) {
this.p = p;
}
public abstract boolean execute();
public abstract int delay(Loader loader);
}

Datei anzeigen

@ -1,57 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.activations;
import de.steamwar.bausystem.features.loader.Loader;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class BlockPlaceLoaderActivation extends AbstractLoaderActivation {
private final Location location;
private final Material material;
public BlockPlaceLoaderActivation(Player p, Location location, Material material) {
super(p);
this.location = location;
if (!material.isBlock()) {
throw new IllegalStateException("Only Blocks, " + material.name() + " is not a Block");
}
this.material = material;
}
@Override
public boolean execute() {
Block currBlock = location.getBlock();
if (currBlock.getType() != Material.AIR && currBlock.getType() != Material.WATER) {
return false;
}
currBlock.setType(material, true);
return true;
}
@Override
public int delay(Loader loader) {
return loader.getTicksBetweenBlocks();
}
}

Datei anzeigen

@ -1,174 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.activations;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.Loader;
import de.steamwar.bausystem.features.loader.LoaderButton;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.*;
import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player;
public abstract class InteractionActivation extends AbstractLoaderActivation {
Location location;
LoaderButton button;
InteractionActivation(Player p, Location location, LoaderButton button) {
super(p);
this.location = location;
this.button = button;
}
public static InteractionActivation construct(Player p, Location location, Loader loader) {
LoaderButton button = LoaderButton.fromBlock(location.getBlock());
if (button.isToggle()) {
return new ToggleActivation(p, location, button, loader.getLastActivation());
} else {
return new TimedActivation(p, location, button);
}
}
void updateButton() {
Block block = location.getBlock();
if (block.getBlockData() instanceof Switch) {
Switch sw = (Switch) block.getBlockData();
FaceAttachable.AttachedFace face = sw.getAttachedFace();
if (face == FaceAttachable.AttachedFace.FLOOR) {
update(block.getRelative(BlockFace.DOWN));
} else if (face == FaceAttachable.AttachedFace.CEILING) {
update(block.getRelative(BlockFace.UP));
} else {
update(block.getRelative(sw.getFacing().getOppositeFace()));
}
} else if (button == LoaderButton.TRIPWIRE) {
update(block);
} else if (button == LoaderButton.PRESSURE_PLATE || button == LoaderButton.WEIGHTED_PRESSURE_PLATE) {
update(block.getRelative(BlockFace.DOWN));
}
}
void update(Block block) {
BlockData data = block.getBlockData();
block.setType(Material.BARRIER, true);
block.setBlockData(data, true);
}
boolean getBlockPower() {
Block block = location.getBlock();
BlockData data = block.getBlockData();
if (data instanceof Powerable) {
Powerable pow = (Powerable) data;
return pow.isPowered();
}
if (data instanceof DaylightDetector) {
DaylightDetector detector = (DaylightDetector) data;
return detector.isInverted();
}
if (data instanceof AnaloguePowerable) {
AnaloguePowerable powerable = (AnaloguePowerable) data;
return powerable.getPower() > 0;
}
return false;
}
void setBlockPower(boolean state) {
Block block = location.getBlock();
BlockData data = block.getBlockData();
if (data instanceof Powerable) {
Powerable pow = (Powerable) data;
pow.setPowered(state);
}
if (data instanceof Openable) {
Openable openable = (Openable) data;
openable.setOpen(state);
}
if (data instanceof DaylightDetector) {
DaylightDetector detector = (DaylightDetector) data;
detector.setInverted(state);
}
if (data instanceof AnaloguePowerable) {
AnaloguePowerable powerable = (AnaloguePowerable) data;
if (block.getType() == Material.REDSTONE_WIRE) {
powerable.setPower(state ? 15 : 0);
} else {
powerable.setPower(state ? 1 : 0);
}
}
block.setBlockData(data);
}
public static class ToggleActivation extends InteractionActivation {
private final int delay;
public ToggleActivation(Player p, Location location, LoaderButton button, int delay) {
super(p, location, button);
this.delay = Math.max(delay, 0);
}
@Override
public boolean execute() {
if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID)
return false;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
setBlockPower(!getBlockPower());
updateButton();
}, delay);
return true;
}
@Override
public int delay(Loader loader) {
return delay;
}
}
public static class TimedActivation extends InteractionActivation {
public TimedActivation(Player p, Location location, LoaderButton button) {
super(p, location, button);
}
@Override
public boolean execute() {
if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID)
return false;
setBlockPower(true);
updateButton();
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
setBlockPower(false);
updateButton();
}, button.getTime());
return true;
}
@Override
public int delay(Loader loader) {
return button.getTime();
}
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,18 +17,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom.event;
package de.steamwar.bausystem.features.loader.elements;
import de.steamwar.bausystem.features.script.custom.Script;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWItem;
import org.bukkit.entity.Player;
import java.util.Map;
import java.util.function.Consumer;
public interface CustomEvent extends Script {
public interface ElementSettings {
SWItem menu(Player player);
void execute(Consumer<Long> delay);
void click(Player player, Runnable backAction, Runnable deleteAction);
String eventName();
boolean execute(Player p, Map<String, Value> variables, Consumer<String> echoConsumer);
default void playerInteract() {}
void noop();
default String translateItemName(String name, String mode, Player player, Object... args) {
return BauSystem.MESSAGE.parse("LOADER_GUI_ITEM_NAME", player, BauSystem.MESSAGE.parse(name, player), BauSystem.MESSAGE.parse(mode, player, args));
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,13 +17,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom;
package de.steamwar.bausystem.features.loader.elements;
import de.steamwar.inventory.SWItem;
import org.bukkit.entity.Player;
import yapion.hierarchy.types.YAPIONMap;
public interface MenuScript {
void save(YAPIONMap yapionMap);
SWItem toItem(Player p);
import java.util.function.Consumer;
public interface LoaderElement {
SWItem menu(Player player);
void execute(Consumer<Long> delay);
void click(Player player, Runnable backAction);
}

Datei anzeigen

@ -0,0 +1,158 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.FaceAttachable;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
public abstract class LoaderInteractionElement<T extends ElementSettings> implements LoaderElement {
protected final Location location;
protected int currentShot = 0;
protected List<T> elements = new ArrayList<>();
protected LoaderInteractionElement(Location location) {
this.location = location;
T element = createNewElement();
element.playerInteract();
elements.add(element);
}
@Override
public void execute(Consumer<Long> delay) {
if (currentShot >= elements.size()) currentShot = 0;
elements.get(currentShot).execute(delay);
currentShot++;
if (currentShot >= elements.size()) currentShot = 0;
}
@Override
public void click(Player player, Runnable backAction) {
List<SWListInv.SWListEntry<T>> entries = new ArrayList<>();
Runnable updateRunnable = () -> {
entries.clear();
for (T element : elements) {
entries.add(new SWListInv.SWListEntry<>(element.menu(player), element));
}
};
updateRunnable.run();
SWListInv<T> listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> {});
listInv.setCallback((clickType, entry) -> {
entry.click(player, () -> {
updateRunnable.run();
listInv.open();
}, () -> {
if (elements.size() == 1) return;
elements.remove(entry);
click(player, backAction);
});
});
listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> {
backAction.run();
}));
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
T element = createNewElement();
elements.add(element);
element.click(player, () -> {
updateRunnable.run();
listInv.open();
}, () -> {
if (elements.size() == 1) return;
elements.remove(element);
click(player, backAction);
});
}));
listInv.setItem(51, new SWItem(Material.STRUCTURE_VOID, "§7Insert NOOP's", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "§7NOOP Count", "1");
anvilInv.setCallback(s -> {
try {
int count = Integer.parseInt(s);
for (int i = 0; i < count; i++) {
T element = createNewElement();
element.noop();
elements.add(element);
}
updateRunnable.run();
listInv.open();
} catch (NumberFormatException e) {
player.sendMessage("§cInvalid Number");
}
});
anvilInv.open();
}));
listInv.open();
}
protected void update(BlockData blockData) {
Material material = blockData.getMaterial();
Block block = location.getBlock();
if (blockData instanceof Switch) {
Switch sw = (Switch) blockData;
updateBlock(block, sw);
FaceAttachable.AttachedFace face = sw.getAttachedFace();
if (face == FaceAttachable.AttachedFace.FLOOR) {
updateBlock(block.getRelative(BlockFace.DOWN));
} else if (face == FaceAttachable.AttachedFace.CEILING) {
updateBlock(block.getRelative(BlockFace.UP));
} else {
updateBlock(block.getRelative(sw.getFacing().getOppositeFace()));
}
} else if (material == Material.TRIPWIRE) {
updateBlock(block, blockData);
} else if (material.name().endsWith("_PLATE")) {
updateBlock(block.getRelative(BlockFace.DOWN));
}
}
protected void updateBlock(Block block) {
updateBlock(block, block.getBlockData());
}
protected void updateBlock(Block block, BlockData data) {
block.setType(Material.BARRIER, true);
block.setBlockData(data, true);
}
public abstract T createNewElement();
protected final String translateItemName(String name, Player player) {
return BauSystem.MESSAGE.parse("LOADER_SETTING_NAME", player, BauSystem.MESSAGE.parse(name, player));
}
public int size() {
return elements.size();
}
}

Datei anzeigen

@ -0,0 +1,142 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.type.Comparator;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderComparator extends LoaderInteractionElement<LoaderComparator.ComparatorSettings> {
public LoaderComparator(Location location) {
super(location);
}
public class ComparatorSettings implements ElementSettings {
private boolean interact = false;
private Comparator.Mode mode = Comparator.Mode.COMPARE;
@Override
public SWItem menu(Player player) {
return menu(player, interact, mode);
}
private SWItem menu(Player player, boolean interact, Comparator.Mode mode) {
SWItem swItem;
if (interact) {
swItem = new SWItem(Material.STICK, "§7Comparator§8: §eInteract");
} else if (mode == null) {
swItem = new SWItem(Material.STRUCTURE_VOID, "§7Comparator§8: §eNOOP");
} else {
swItem = new SWItem(Material.COMPARATOR, "§7Comparator§8: §e" + mode.name());
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != Material.COMPARATOR) return;
Comparator comparator = (Comparator) location.getBlock().getBlockData();
if (interact) {
comparator.setMode(comparator.getMode() == Comparator.Mode.COMPARE ? Comparator.Mode.SUBTRACT : Comparator.Mode.COMPARE);
} else if (mode == null) {
return;
} else {
comparator.setMode(mode);
}
location.getBlock().setBlockData(comparator, true);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, false, null).getItemStack(), clickType -> {
interact = false;
mode = null;
click(player, backAction, deleteAction);
});
swInventory.setItem(3, item(player, true, null).getItemStack(), clickType -> {
interact = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, Comparator.Mode.COMPARE).getItemStack(), clickType -> {
interact = false;
mode = Comparator.Mode.COMPARE;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, Comparator.Mode.SUBTRACT).getItemStack(), clickType -> {
interact = false;
mode = Comparator.Mode.SUBTRACT;
click(player, backAction, deleteAction);
});
swInventory.open();
}
private SWItem item(Player player, boolean interact, Comparator.Mode mode) {
SWItem swItem = menu(player, interact, mode);
if (swItem.getItemStack().equals(menu(player, this.interact, this.mode).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void playerInteract() {
interact = true;
mode = null;
}
@Override
public void noop() {
interact = false;
mode = null;
}
}
@Override
public SWItem menu(Player player) {
SWItem swItem = new SWItem(Material.COMPARATOR, "§7Comparator");
swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit"));
return swItem;
}
@Override
public ComparatorSettings createNewElement() {
return new ComparatorSettings();
}
}

Datei anzeigen

@ -0,0 +1,165 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderDaylightDetector extends LoaderInteractionElement<LoaderDaylightDetector.DaylightDetectorSettings> {
public LoaderDaylightDetector(Location location) {
super(location);
}
public class DaylightDetectorSettings implements ElementSettings {
private boolean noop = false;
private boolean interact = false;
private boolean inverted = true;
private int power = 0;
@Override
public SWItem menu(Player player) {
return menu(player, noop, interact, inverted);
}
private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", "LOADER_INTERACTION_NOOP", player));
} else if (interact) {
swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", "LOADER_INTERACTION_INTERACT", player));
} else {
swItem = new SWItem(Material.DAYLIGHT_DETECTOR, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", powered ? "LOADER_INTERACTION_POWERED": "LOADER_INTERACTION_UNPOWERED", player));
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != Material.DAYLIGHT_DETECTOR) return;
DaylightDetector daylightDetector = (DaylightDetector) location.getBlock().getBlockData();
if (noop) {
return;
} else if (interact) {
daylightDetector.setInverted(!daylightDetector.isInverted());
} else {
daylightDetector.setInverted(inverted);
}
daylightDetector.setPower(daylightDetector.isInverted() ? 15 - power : power);
location.getBlock().setBlockData(daylightDetector);
updateBlock(location.getBlock().getRelative(0, -1, 0));
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 36, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> {
noop = false;
interact = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> {
noop = false;
interact = false;
inverted = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> {
noop = false;
interact = false;
inverted = true;
click(player, backAction, deleteAction);
});
for (int i = 0; i < 16; i++) {
int finalI = i;
int finalI2 = i;
if (i >= 9) finalI2++;
swInventory.setItem(finalI2 + 9, item(player, finalI).getItemStack(), clickType -> {
power = finalI;
click(player, backAction, deleteAction);
});
}
swInventory.open();
}
private SWItem item(Player player, boolean noop, boolean interact, boolean inverted) {
SWItem swItem = menu(player, noop, interact, inverted);
if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.inverted).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
private SWItem item(Player player, int power) {
SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power));
swItem.getItemStack().setAmount(power == 0 ? 1 : power);
if (!this.noop && this.power == power) swItem.setEnchanted(true);
return swItem;
}
@Override
public void playerInteract() {
noop = false;
interact = true;
inverted = false;
}
@Override
public void noop() {
noop = true;
interact = false;
inverted = false;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(Material.DAYLIGHT_DETECTOR, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", player));
}
@Override
public DaylightDetectorSettings createNewElement() {
return new DaylightDetectorSettings();
}
}

Datei anzeigen

@ -0,0 +1,159 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Lectern;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.BookMeta;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderLectern extends LoaderInteractionElement<LoaderLectern.LecternSettings> {
public LoaderLectern(Location location) {
super(location);
}
public class LecternSettings implements ElementSettings {
private boolean noop = true;
private LecternAction action = LecternAction.PAGE_NEXT;
private int page = 0;
@Override
public SWItem menu(Player player) {
return menu(player, noop, action, page);
}
private SWItem menu(Player player, boolean noop, LecternAction action, int page) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_NOOP", player));
} else if (action == LecternAction.PAGE_PREV) {
swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE_PREV", player));
} else if (action == LecternAction.PAGE_NEXT) {
swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE_NEXT", player));
} else {
swItem = new SWItem(Material.LECTERN, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE", player, page));
swItem.getItemStack().setAmount(page);
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != Material.LECTERN) return;
Lectern lectern = (Lectern) location.getBlock().getState();
if (!((org.bukkit.block.data.type.Lectern) lectern.getBlockData()).hasBook()) return;
int pages = ((BookMeta) lectern.getInventory().getItem(0).getItemMeta()).getPages().size();
if (noop) {
return;
} else if (action == LecternAction.PAGE_PREV) {
int page = lectern.getPage();
if (page > 1) lectern.setPage(page - 1);
} else if (action == LecternAction.PAGE_NEXT) {
int page = lectern.getPage();
if (page < pages) lectern.setPage(page + 1);
} else if (action == LecternAction.PAGE_SET) {
if (page <= pages) lectern.setPage(page);
}
lectern.update(false, true);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 36, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, LecternAction.PAGE_PREV, 0).getItemStack(), clickType -> {
noop = false;
action = LecternAction.PAGE_PREV;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, LecternAction.PAGE_NEXT, 0).getItemStack(), clickType -> {
noop = false;
action = LecternAction.PAGE_NEXT;
click(player, backAction, deleteAction);
});
for (int i = 0; i < 15; i++) {
int finalI = i;
int finalI2 = i;
if (i >= 9) finalI2++;
if (i >= 12) finalI2++;
swInventory.setItem(finalI2 + 9, item(player, false, LecternAction.PAGE_SET, finalI + 1).getItemStack(), clickType -> {
noop = false;
action = LecternAction.PAGE_SET;
page = finalI + 1;
click(player, backAction, deleteAction);
});
}
swInventory.open();
}
private SWItem item(Player player, boolean noop, LecternAction action, int page) {
SWItem swItem = menu(player, noop, action, page);
if (swItem.getItemStack().equals(menu(player, this.noop, this.action, this.page).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void noop() {
noop = true;
}
}
public enum LecternAction {
PAGE_NEXT,
PAGE_PREV,
PAGE_SET
}
@Override
public SWItem menu(Player player) {
return new SWItem(Material.LECTERN, translateItemName("LOADER_BUTTON_LECTERN", player));
}
@Override
public LecternSettings createNewElement() {
return new LecternSettings();
}
}

Datei anzeigen

@ -0,0 +1,136 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderLever extends LoaderInteractionElement<LoaderLever.LeverSettings> {
public LoaderLever(Location location) {
super(location);
}
public class LeverSettings implements ElementSettings {
private boolean noop = false;
private boolean interact = false;
private boolean power = false;
@Override
public SWItem menu(Player player) {
return menu(player, noop, interact, power);
}
private SWItem menu(Player player, boolean noop, boolean interact, boolean power) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_SWITCH", "LOADER_INTERACTION_NOOP", player));
} else if (interact) {
swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_SWITCH", "LOADER_INTERACTION_INTERACT", player));
} else {
swItem = new SWItem(Material.LEVER, translateItemName("LOADER_BUTTON_SWITCH", power ? "LOADER_INTERACTION_ACTIVE" : "LOADER_INTERACTION_INACTIVE", player));
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != Material.LEVER) return;
if (noop) return;
Switch lever = (Switch) location.getBlock().getBlockData();
if (interact) {
lever.setPowered(!lever.isPowered());
} else {
lever.setPowered(power);
}
location.getBlock().setBlockData(lever, true);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> {
noop = false;
interact = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> {
noop = false;
interact = false;
power = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> {
noop = false;
interact = false;
power = true;
click(player, backAction, deleteAction);
});
swInventory.open();
}
private SWItem item(Player player, boolean noop, boolean interact, boolean power) {
SWItem swItem = menu(player, noop, interact, power);
if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.power).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void noop() {
noop = true;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(Material.LEVER, translateItemName("LOADER_BUTTON_LECTERN", player));
}
@Override
public LeverSettings createNewElement() {
return new LeverSettings();
}
}

Datei anzeigen

@ -0,0 +1,228 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.AnaloguePowerable;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.MovementSettings> {
private String name;
private Material material;
private boolean analogue;
public LoaderMovement(Location location, String name, Material material) {
super(location);
this.name = name;
this.material = material;
this.analogue = location.getBlock().getBlockData() instanceof AnaloguePowerable;
}
public void setInitialTicks(long ticks) {
if (ticks < 1) ticks = 1;
elements.get(currentShot).ticks = ticks;
}
public class MovementSettings implements ElementSettings {
private boolean noop = false;
private boolean waitFor = false;
private int power = 15;
private long ticks = 1;
@Override
public SWItem menu(Player player) {
return menu(player, noop, waitFor);
}
private SWItem menu(Player player, boolean noop, boolean waitFor) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player));
} else if (waitFor) {
swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_WAIT_FOR", player));
swItem.getItemStack().setAmount((int) Math.min(ticks, 64));
} else {
swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_NO_WAIT_FOR", player));
swItem.getItemStack().setAmount((int) Math.min(ticks, 64));
swItem.setEnchanted(true);
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (!(material == Material.STRING && location.getBlock().getType() == Material.TRIPWIRE) && location.getBlock().getType() != material) return;
if (noop) return;
BlockData blockData = location.getBlock().getBlockData();
if (blockData instanceof AnaloguePowerable) {
AnaloguePowerable analoguePowerable = (AnaloguePowerable) location.getBlock().getBlockData();
analoguePowerable.setPower(power);
location.getBlock().setBlockData(analoguePowerable, true);
update(analoguePowerable);
} else if (blockData instanceof Powerable) {
Powerable powerable = (Powerable) location.getBlock().getBlockData();
if (ticks < 0) {
powerable.setPowered(power > 0);
} else {
powerable.setPowered(true);
}
location.getBlock().setBlockData(powerable, true);
update(powerable);
}
if (ticks >= 0) {
if (waitFor) {
delay.accept(ticks);
}
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
if (blockData instanceof AnaloguePowerable) {
AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData;
analoguePowerable.setPower(0);
location.getBlock().setBlockData(analoguePowerable, true);
update(analoguePowerable);
} else {
Powerable powerable = (Powerable) blockData;
powerable.setPowered(false);
location.getBlock().setBlockData(powerable, true);
update(powerable);
}
}, ticks);
}
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, analogue ? 45 : 27, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = analogue ? 36 : 18; i < (analogue ? 44 : 26); i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(analogue ? 36 : 18, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
if (ticks >= 0) {
swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> {
noop = false;
waitFor = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> {
noop = false;
waitFor = true;
click(player, backAction, deleteAction);
});
}
swInventory.setItem(12, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
ticks -= clickType.isShiftClick() ? 5 : 1;
if (ticks < 1) ticks = 1;
swInventory.setItem(13, item(player));
});
swInventory.setItem(13, item(player).getItemStack(), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), ticks + "");
swAnvilInv.setCallback(s -> {
try {
ticks = Long.parseLong(s);
if (ticks < 1) ticks = 1;
} catch (NumberFormatException ignored) {
}
click(player, backAction, deleteAction);
});
swAnvilInv.open();
});
swInventory.setItem(14, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
ticks += clickType.isShiftClick() ? 5 : 1;
swInventory.setItem(13, item(player));
});
if (analogue) {
for (int i = 0; i < 16; i++) {
int finalI = i;
int finalI2 = i;
if (i >= 9) finalI2++;
swInventory.setItem(finalI2 + 18, item(player, finalI).getItemStack(), clickType -> {
power = finalI;
click(player, backAction, deleteAction);
});
}
}
swInventory.open();
}
private SWItem item(Player player, boolean noop, boolean waitFor) {
SWItem swItem = menu(player, noop, waitFor);
if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
private SWItem item(Player player, int power) {
SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power));
swItem.getItemStack().setAmount(power == 0 ? 1 : power);
if (!this.noop && this.power == power) swItem.setEnchanted(true);
return swItem;
}
private SWItem item(Player player) {
SWItem swItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, ticks));
swItem.getItemStack().setAmount((int) Math.min(ticks, 64));
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void noop() {
noop = true;
waitFor = false;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(material, translateItemName(name, player));
}
@Override
public MovementSettings createNewElement() {
return new MovementSettings();
}
}

Datei anzeigen

@ -0,0 +1,119 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderNoteBlock extends LoaderInteractionElement<LoaderNoteBlock.NoteBlockSettings> {
public LoaderNoteBlock(Location location) {
super(location);
}
public class NoteBlockSettings implements ElementSettings {
private boolean interact = true;
@Override
public SWItem menu(Player player) {
return menu(player, interact);
}
private SWItem menu(Player player, boolean interact) {
SWItem swItem;
if (interact) {
swItem = new SWItem(Material.NOTE_BLOCK, translateItemName("LOADER_BUTTON_NOTEBLOCK", "LOADER_INTERACTION_INTERACT", player));
} else {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_NOTEBLOCK", "LOADER_INTERACTION_NOOP", player));
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != Material.NOTE_BLOCK) return;
NoteBlock noteBlock = (NoteBlock) location.getBlock().getBlockData();
if (interact) {
if (noteBlock.getInstrument() == Instrument.BANJO) noteBlock.setInstrument(Instrument.BIT);
else noteBlock.setInstrument(Instrument.BANJO);
} else {
return;
}
location.getBlock().setBlockData(noteBlock);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, false).getItemStack(), clickType -> {
interact = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(3, item(player, true).getItemStack(), clickType -> {
interact = true;
click(player, backAction, deleteAction);
});
swInventory.open();
}
private SWItem item(Player player, boolean interact) {
SWItem swItem = menu(player, interact);
if (swItem.getItemStack().equals(menu(player, this.interact).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void noop() {
interact = false;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(Material.NOTE_BLOCK, translateItemName("LOADER_BUTTON_NOTEBLOCK", player));
}
@Override
public NoteBlockSettings createNewElement() {
return new NoteBlockSettings();
}
}

Datei anzeigen

@ -0,0 +1,141 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.Openable;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderOpenable extends LoaderInteractionElement<LoaderOpenable.TrapdoorSettings> {
private String name;
private Material material;
public LoaderOpenable(Location location, String name, Material material) {
super(location);
this.name = name;
this.material = material;
}
public class TrapdoorSettings implements ElementSettings {
private boolean noop = false;
private boolean interact = true;
private boolean open = false;
@Override
public SWItem menu(Player player) {
return menu(player, noop, interact, open);
}
private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player));
} else if (interact) {
swItem = new SWItem(Material.STICK, translateItemName(name, "LOADER_INTERACTION_INTERACT", player));
} else {
swItem = new SWItem(material, translateItemName(name, open ? "LOADER_INTERACTION_OPEN" : "LOADER_INTERACTION_CLOSED", player));
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != material) return;
Openable openable = (Openable) location.getBlock().getBlockData();
if (noop) {
return;
} else if (interact) {
openable.setOpen(!openable.isOpen());
} else {
openable.setOpen(open);
}
location.getBlock().setBlockData(openable);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> {
noop = false;
interact = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> {
noop = false;
interact = false;
open = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> {
noop = false;
interact = false;
open = true;
click(player, backAction, deleteAction);
});
swInventory.open();
}
private SWItem item(Player player, boolean noop, boolean interact, boolean open) {
SWItem swItem = menu(player, noop, interact, open);
if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.open).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void noop() {
noop = true;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(material, translateItemName(name, player));
}
@Override
public TrapdoorSettings createNewElement() {
return new TrapdoorSettings();
}
}

Datei anzeigen

@ -0,0 +1,154 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.type.Repeater;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderRepeater extends LoaderInteractionElement<LoaderRepeater.RepeaterSettings> {
public LoaderRepeater(Location location) {
super(location);
}
public class RepeaterSettings implements ElementSettings {
private boolean interact = false;
private int delay = 1;
@Override
public SWItem menu(Player player) {
return menu(player, interact, delay);
}
private SWItem menu(Player player, boolean interact, int delay) {
SWItem swItem;
if (interact) {
swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_REPEATER", "LOADER_INTERACTION_INTERACT", player));
} else if (delay == 0) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_REPEATER", "LOADER_INTERACTION_NOOP", player));
} else {
swItem = new SWItem(Material.REPEATER, BauSystem.MESSAGE.parse("LOADER_SETTING_REPEATER", player, delay));
swItem.getItemStack().setAmount(delay);
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> __) {
if (location.getBlock().getType() != Material.REPEATER) return;
Repeater repeater = (Repeater) location.getBlock().getBlockData();
if (interact) {
int delay = repeater.getDelay();
delay++;
if (delay > 4) delay = 1;
repeater.setDelay(delay);
} else if (delay == 0) {
return;
} else {
repeater.setDelay(delay);
}
location.getBlock().setBlockData(repeater, true);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(1, item(player, false, 0).getItemStack(), clickType -> {
interact = false;
delay = 0;
click(player, backAction, deleteAction);
});
swInventory.setItem(2, item(player, true, -1).getItemStack(), clickType -> {
interact = true;
click(player, backAction, deleteAction);
});
swInventory.setItem(4, item(player, false, 1).getItemStack(), clickType -> {
interact = false;
delay = 1;
click(player, backAction, deleteAction);
});
swInventory.setItem(5, item(player, false, 2).getItemStack(), clickType -> {
interact = false;
delay = 2;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, 3).getItemStack(), clickType -> {
interact = false;
delay = 3;
click(player, backAction, deleteAction);
});
swInventory.setItem(7, item(player, false, 4).getItemStack(), clickType -> {
interact = false;
delay = 4;
click(player, backAction, deleteAction);
});
swInventory.open();
}
private SWItem item(Player player, boolean interact, int delay) {
SWItem swItem = menu(player, interact, delay);
if (swItem.getItemStack().equals(menu(player, this.interact, this.delay).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void playerInteract() {
interact = true;
delay = 0;
}
@Override
public void noop() {
interact = false;
delay = 0;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(Material.REPEATER, translateItemName("LOADER_BUTTON_REPEATER", player));
}
@Override
public RepeaterSettings createNewElement() {
return new RepeaterSettings();
}
}

Datei anzeigen

@ -0,0 +1,63 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.function.Consumer;
public class LoaderTNT implements LoaderElement {
private Location location;
public LoaderTNT(Location location) {
this.location = location;
}
@Override
public SWItem menu(Player player) {
SWItem item = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_NAME", player));
item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_X", player, location.getBlockX()), BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_Y", player, location.getBlockY()), BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_Z", player, location.getBlockZ())));
return item;
}
@Override
public void execute(Consumer<Long> delay) {
Block block = location.getBlock();
if (block.getType() != Material.AIR && block.getType() != Material.WATER) {
delay.accept(1L);
return;
}
block.setType(Material.TNT, true);
}
@Override
public void click(Player player, Runnable backAction) {
}
}

Datei anzeigen

@ -0,0 +1,149 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.ElementSettings;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Consumer;
public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSettings> {
private String name;
private Material material;
private int ticks;
public LoaderTicks(Location location, String name, Material material, int ticks) {
super(location);
this.name = name;
this.material = material;
this.ticks = ticks;
}
public class TicksSettings implements ElementSettings {
private boolean noop = false;
private boolean waitFor = false;
@Override
public SWItem menu(Player player) {
return menu(player, noop, waitFor);
}
private SWItem menu(Player player, boolean noop, boolean waitFor) {
SWItem swItem;
if (noop) {
swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player));
} else if (waitFor) {
swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_WAIT_FOR", player, ticks));
} else {
swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_NO_WAIT_FOR", player, ticks));
swItem.setEnchanted(true);
}
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> delay) {
if (location.getBlock().getType() != material) {
return;
}
if (noop) {
return;
}
Powerable powerable = (Powerable) location.getBlock().getBlockData();
powerable.setPowered(true);
location.getBlock().setBlockData(powerable, true);
update(powerable);
if (waitFor) {
delay.accept((long) ticks);
}
BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
powerable.setPowered(false);
location.getBlock().setBlockData(powerable, true);
update(powerable);
}, ticks);
}
@Override
public void click(Player player, Runnable backAction, Runnable deleteAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run());
swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> {
noop = true;
click(player, backAction, deleteAction);
});
if (ticks >= 0) {
swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> {
noop = false;
waitFor = false;
click(player, backAction, deleteAction);
});
swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> {
noop = false;
waitFor = true;
click(player, backAction, deleteAction);
});
}
swInventory.open();
}
private SWItem item(Player player, boolean noop, boolean waitFor) {
SWItem swItem = menu(player, noop, waitFor);
if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) {
swItem.setEnchanted(true);
}
swItem.setLore(Collections.emptyList());
return swItem;
}
@Override
public void noop() {
noop = true;
}
}
@Override
public SWItem menu(Player player) {
return new SWItem(material, translateItemName(name, player));
}
@Override
public TicksSettings createNewElement() {
return new TicksSettings();
}
}

Datei anzeigen

@ -0,0 +1,89 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.loader.elements.impl;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.function.Consumer;
public class LoaderWait implements LoaderElement {
@Getter
@Setter
private long delay;
public LoaderWait(long delay) {
this.delay = delay;
}
@Override
public SWItem menu(Player player) {
SWItem swItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_WAIT", player, delay));
swItem.getItemStack().setAmount((int) Math.max(Math.min(delay, 64), 1));
if (delay == 0) swItem.setEnchanted(true);
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)));
return swItem;
}
@Override
public void execute(Consumer<Long> wait) {
wait.accept(delay);
}
@Override
public void click(Player player, Runnable backAction) {
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player));
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).getItemStack(), clickType -> backAction.run());
swInventory.setItem(3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
delay -= clickType.isShiftClick() ? 5 : 1;
if (delay < 0) delay = 0;
swInventory.setItem(4, menu(player));
});
swInventory.setItem(4, menu(player).getItemStack(), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_WAIT_NAME", player), delay + "");
swAnvilInv.setCallback(s -> {
try {
delay = Long.parseLong(s);
if (delay < 0) delay = 0;
} catch (NumberFormatException ignored) {
}
click(player, backAction);
});
swAnvilInv.open();
});
swInventory.setItem(5, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
delay += clickType.isShiftClick() ? 5 : 1;
swInventory.setItem(4, menu(player));
});
swInventory.open();
}
}

Datei anzeigen

@ -65,9 +65,9 @@ public class Loadtimer implements Listener {
this.region = region;
this.stage = Stage.WAITING;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
task = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
if (stage == Stage.COUNTING) {
long timeSinceStart = TPSUtils.currentTick.get() - start;
long timeSinceStart = TPSUtils.currentRealTick.get() - start;
long timeSinceHalf = timeSinceStart / 2;
double timeSec = (timeSinceStart / 20d);
String sec = new DecimalFormat("#.#").format(timeSec);
@ -119,7 +119,7 @@ public class Loadtimer implements Listener {
public void onTntPlace(BlockPlaceEvent event) {
if (stage == Stage.WAITING) {
this.stage = Stage.COUNTING;
this.start = TPSUtils.currentTick.get();
this.start = TPSUtils.currentRealTick.get();
}
if (stage == Stage.COUNTING) {
@ -146,9 +146,9 @@ public class Loadtimer implements Listener {
public void onTntSpawn() {
if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) {
stage = Stage.IGNITION;
ignite = TPSUtils.currentTick.get();
ignite = TPSUtils.currentRealTick.get();
if (activate == -1)
activate = TPSUtils.currentTick.get();
activate = TPSUtils.currentRealTick.get();
if (finishOnActive) {
stage = Stage.END;
print();
@ -160,14 +160,14 @@ public class Loadtimer implements Listener {
public void onTntExplode(EntityExplodeEvent event) {
if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) {
stage = Stage.END;
explode = TPSUtils.currentTick.get();
explode = TPSUtils.currentRealTick.get();
print();
delete();
}
}
private void setActivate() {
activate = TPSUtils.currentTick.get();
activate = TPSUtils.currentRealTick.get();
stage = Stage.ACTIVATED;
if (finishOnActive) {
print();

Datei anzeigen

@ -89,18 +89,18 @@ public class RedstonetesterUtils {
tick = null;
return;
}
if (TPSUtils.currentTick.get() - lastTick > 100) {
if (TPSUtils.currentRealTick.get() - lastTick > 100) {
tick = null;
}
if (loc1.equals(location)) {
lastTick = TPSUtils.currentTick.get();
lastTick = TPSUtils.currentRealTick.get();
if (tick == null) {
tick = TPSUtils.currentTick.get();
tick = TPSUtils.currentRealTick.get();
}
return;
}
if (tick != null && loc2.equals(location)) {
BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentTick.get() - tick), ((TPSUtils.currentTick.get() - tick) / 2.0));
BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentRealTick.get() - tick), ((TPSUtils.currentRealTick.get() - tick) / 2.0));
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
@ -64,10 +65,14 @@ public class ColorCommand extends SWCommand {
}
region.set(Flag.COLOR, color);
try {
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, true);
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.ignoreAir(true)
.onlyColors(true)
.color(color.getColor());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
RegionUtils.message(region, "REGION_REGION_COLORED");
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_COLORED", p);
}
}

Datei anzeigen

@ -1,16 +1,19 @@
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockSpreadEvent;
@Linked
public class FireListener implements Listener {
public class FireListener implements Listener, ScoreboardElement {
@EventHandler
public void onFireDamage(BlockBurnEvent e) {
@ -22,4 +25,19 @@ public class FireListener implements Listener {
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 1;
}
@Override
public String get(Region region, Player p) {
if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p);
}
}

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.core.Core;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
@ -11,6 +12,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -21,7 +23,7 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@Linked
public class FreezeListener implements Listener {
public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
@ -98,7 +100,9 @@ public class FreezeListener implements Listener {
@EventHandler
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
if (Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
e.setCancelled(true);
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
e.setCancelled(true);
}
}
@ -182,4 +186,20 @@ public class FreezeListener implements Listener {
event.setCancelled(true);
}
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 2;
}
@Override
public String get(Region region, Player p) {
if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p);
}
}

Datei anzeigen

@ -0,0 +1,82 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.entity.Player;
@Linked
@MinVersion(19)
public class ItemsCommand extends SWCommand {
public ItemsCommand() {
super("items");
}
@Register(description = "REGION_ITEMS_HELP")
public void toggleCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage());
} else {
RegionUtils.actionBar(region, getDisableMessage());
}
}
private String getNoPermMessage() {
return "REGION_ITEMS_NO_PERMS";
}
private String getEnableMessage(){
return "REGION_ITEMS_ENABLED";
}
private String getDisableMessage(){
return "REGION_ITEMS_DISABLED";
}
private boolean toggle(Region region) {
switch (region.getPlain(Flag.ITEMS, ItemMode.class)) {
case ACTIVE:
region.set(Flag.ITEMS, ItemMode.INACTIVE);
return false;
default:
case INACTIVE:
region.set(Flag.ITEMS, ItemMode.ACTIVE);
return true;
}
}
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
};
}
}

Datei anzeigen

@ -0,0 +1,64 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ItemSpawnEvent;
@Linked
@MinVersion(19)
public class ItemsListener implements Listener, ScoreboardElement {
private static ItemMode getMode(Region region) {
return region.getPlain(Flag.ITEMS, ItemMode.class);
}
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) {
event.setCancelled(true);
}
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 3;
}
@Override
public String get(Region region, Player p) {
if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p);
}
}

Datei anzeigen

@ -1,11 +1,14 @@
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
@ -14,7 +17,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.List;
@Linked
public class ProtectListener implements Listener {
public class ProtectListener implements Listener, ScoreboardElement {
private void explode(List<Block> blockList, Location location) {
Region region = Region.getRegion(location);
@ -36,4 +39,21 @@ public class ProtectListener implements Listener {
public void onExplode(EntityExplodeEvent event) {
explode(event.blockList(), event.getLocation());
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 2;
}
@Override
public String get(Region region, Player p) {
if (region.getFloorLevel() == 0) return null;
if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p);
}
}

Datei anzeigen

@ -25,8 +25,11 @@ import de.steamwar.bausystem.features.util.SelectCommand;
import de.steamwar.bausystem.region.Prototype;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
@ -99,9 +102,12 @@ public class RegionCommand extends SWCommand {
if(checkGlobalRegion(region, p)) return;
try {
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, false);
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.ignoreAir(true)
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
}
@ -118,9 +124,12 @@ public class RegionCommand extends SWCommand {
}
try {
region.reset(node, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.ignoreAir(true)
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,39 +17,31 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.items;
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@Linked
public class ScriptMenuBauGuiItem extends BauGuiItem {
public class RegionScoreboardElement implements ScoreboardElement {
public ScriptMenuBauGuiItem() {
super(15);
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.HEADER;
}
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.WRITTEN_BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_ITEM_NAME", player)).getItemStack();
public int order() {
return 1;
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
p.performCommand("script");
return false;
}
@Override
public Permission permission() {
return Permission.MEMBER;
public String get(Region region, Player p) {
if (GlobalRegion.getInstance() == region) return null;
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName();
}
}

Datei anzeigen

@ -21,14 +21,22 @@ package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import de.steamwar.sql.Punishment;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -38,6 +46,9 @@ import java.util.logging.Level;
@Linked
public class ResetCommand extends SWCommand {
@LinkedInstance
public BauServer bauServer;
public ResetCommand() {
super("reset");
}
@ -47,9 +58,11 @@ public class ResetCommand extends SWCommand {
Region region = regionCheck(p);
if (region == null) return;
try {
region.reset(null, RegionType.NORMAL);
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
@ -59,14 +72,26 @@ public class ResetCommand extends SWCommand {
public void schematicResetCommand(@Validator Player p, SchematicNode node) {
Region region = regionCheck(p);
if (region == null) return;
if (!p.getUniqueId().equals(bauServer.getOwner())) {
if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
return;
}
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
return;
}
}
if (node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
return;
}
try {
region.reset(node, RegionType.NORMAL);
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
}

Datei anzeigen

@ -19,14 +19,14 @@
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.features.script.CustomScriptManager;
import de.steamwar.bausystem.features.script.custom.event.EventType;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import org.bukkit.Bukkit;
@ -44,12 +44,9 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@Linked
public class TNTListener implements Listener {
public class TNTListener implements Listener, ScoreboardElement {
@LinkedInstance
public CustomScriptManager customScriptManager;
private void explode(List<Block> blockList, Location location, EventType eventType, Event event) {
private void explode(List<Block> blockList) {
AtomicBoolean inBuild = new AtomicBoolean();
blockList.removeIf(block -> {
Region region = Region.getRegion(block.getLocation());
@ -69,23 +66,30 @@ public class TNTListener implements Listener {
}
return value == TNTMode.DENY;
});
if (inBuild.get()) {
Region region = Region.getRegion(location);
for (Player player : Bukkit.getOnlinePlayers()) {
if (region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
customScriptManager.callEvent(eventType, player, event);
}
}
}
}
@EventHandler
public void onBlockExplode(BlockExplodeEvent event) {
explode(event.blockList(), event.getBlock().getLocation(), null, null);
explode(event.blockList());
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent event) {
explode(event.blockList(), event.getLocation(), EventType.TNTExplodeInBuild, event);
explode(event.blockList());
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 0;
}
@Override
public String get(Region region, Player p) {
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p);
}
}

Datei anzeigen

@ -21,96 +21,145 @@ package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.*;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import de.steamwar.sql.Punishment;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
@Linked
public class TestblockCommand extends SWCommand {
@LinkedInstance
public BauServer bauServer;
public TestblockCommand() {
super("testblock", "tb", "dummy");
}
@Register(description = "REGION_TB_HELP_RESET")
public void genericTestblockCommand(Player p) {
genericTestblockCommand(p, RegionExtensionType.NORMAL);
}
@Register(description = "REGION_TB_HELP_RESET_EXTENSION")
public void genericTestblockCommand(@Validator Player p, RegionExtensionType regionExtensionType) {
Region region = regionCheck(p);
if (region == null) return;
try {
region.reset(RegionType.TESTBLOCK, regionExtensionType);
RegionUtils.message(region, "REGION_TB_DONE");
} catch (IOException e) {
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@Register(description = "REGION_TB_HELP_SCHEMATIC")
public void schematicTestblockCommand(Player p, @Mapper("withPublic") SchematicNode node) {
schematicTestblockCommand(p, node, RegionExtensionType.NORMAL);
@Register
public void schematicTestblockCommand(@Validator Player p, TestblockParameterType... testblockParameterTypes) {
schematicTestblockCommand(p, null, testblockParameterTypes);
}
@Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, @Mapper("withPublic") SchematicNode node) {
schematicTestblockCommand(p, node, regionExtensionType);
public void schematicTestblockCommand(@Validator Player p, @Mapper("withPublic") SchematicNode node, TestblockParameterType... testblockParameterTypes) {
Set<TestblockParameterType> testblockParameterTypesSet = new HashSet<>(Arrays.asList(testblockParameterTypes));
boolean isExtension = testblockParameterTypesSet.contains(TestblockParameterType.EXTENSION);
boolean isIgnoreAir = testblockParameterTypesSet.contains(TestblockParameterType.IGNORE_AIR);
boolean isOnlyColor = testblockParameterTypesSet.contains(TestblockParameterType.ONLY_COLOR);
boolean replaceTNT = testblockParameterTypesSet.contains(TestblockParameterType.TNT);
boolean replaceWater = testblockParameterTypesSet.contains(TestblockParameterType.WATER);
resetRegion(p, node, isExtension ? RegionExtensionType.EXTENSION : RegionExtensionType.NORMAL, isIgnoreAir, isOnlyColor, replaceTNT, replaceWater);
}
@Register(description = "REGION_TB_HELP_SCHEMATIC_EXTENSION")
public void schematicTestblockCommand(@Validator Player p, @Mapper("withPublic") SchematicNode node, RegionExtensionType regionExtensionType) {
private void resetRegion(Player p, SchematicNode node, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors, boolean removeTNT, boolean removeWater) {
Region region = regionCheck(p);
if (region == null) return;
if (node != null) {
if (node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
return;
}
}
if (!p.getUniqueId().equals(bauServer.getOwner())) {
if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
return;
}
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
return;
}
}
try {
region.reset(node, RegionType.TESTBLOCK, regionExtensionType);
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
.ignoreAir(ignoreAir)
.onlyColors(onlyColors)
.removeTNT(removeTNT)
.removeWater(removeWater)
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType);
RegionUtils.message(region, "REGION_TB_DONE");
} catch (IOException e) {
} catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@ClassMapper(value = RegionExtensionType.class, local = true)
private TypeMapper<RegionExtensionType> regionExtensionTypeTypeMapper() {
Map<String, RegionExtensionType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypesMap.put("-normal", RegionExtensionType.NORMAL);
showModeParameterTypesMap.put("-n", RegionExtensionType.NORMAL);
showModeParameterTypesMap.put("-extension", RegionExtensionType.EXTENSION);
showModeParameterTypesMap.put("-e", RegionExtensionType.EXTENSION);
@ClassMapper(value = TestblockParameterType.class, local = true)
public TypeMapper<TestblockParameterType> testblockParameterTypeMapper() {
Map<TestblockParameterType, List<String>> testblockParameterTypeListMap = new EnumMap<>(TestblockParameterType.class);
for (TestblockParameterType value : TestblockParameterType.values()) {
testblockParameterTypeListMap.put(value, value.getTabCompletes());
}
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
Map<String, TestblockParameterType> testblockParameterTypesMap = new HashMap<>();
testblockParameterTypeListMap.forEach((k, v) -> v.forEach(s -> testblockParameterTypesMap.put(s, k)));
return new TypeMapper<TestblockParameterType>() {
@Override
public TestblockParameterType map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
return testblockParameterTypesMap.get(s);
}
@Override
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
Set<TestblockParameterType> testblockParameterTypeSet = new HashSet<>();
previousArguments.getAll(TestblockParameterType.class).forEach(showModeType -> {
testblockParameterTypeSet.addAll(Arrays.asList(showModeType.getRemoved().get()));
});
Arrays.stream(previousArguments.userArgs).map(testblockParameterTypesMap::get).forEach(testblockParameterTypeSet::add);
testblockParameterTypeSet.remove(null);
Set<TestblockParameterType> removed = testblockParameterTypeSet.stream()
.map(TestblockParameterType::getRemoved)
.map(Supplier::get)
.flatMap(Arrays::stream)
.collect(Collectors.toSet());
List<String> tabCompletes = new ArrayList<>();
for (Map.Entry<TestblockParameterType, List<String>> entry : testblockParameterTypeListMap.entrySet()) {
if (removed.contains(entry.getKey()) || testblockParameterTypeSet.contains(entry.getKey())) {
continue;
}
tabCompletes.addAll(entry.getValue());
}
return tabCompletes;
}
};
}
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_TB_NO_PERMS");
};
return (commandSender, player, messageSender) -> !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_TB_NO_PERMS");
}
private Region regionCheck(Player player) {
@ -142,4 +191,67 @@ public class TestblockCommand extends SWCommand {
}
};
}
public static class TestblockParameter {
private boolean water = false;
private boolean tnt = false;
private boolean extension = false;
private boolean onlyColor = false;
private boolean ignoreAir = false;
public void enableWater() {
this.water = true;
}
public void enableTNT() {
this.tnt = true;
}
public void enableExtension() {
this.extension = true;
}
public void enableOnlyColor() {
this.onlyColor = true;
}
public void enableIgnoreAir() {
this.ignoreAir = true;
}
}
public enum TestblockParameterType {
EXTENSION(TestblockParameter::enableExtension, Arrays.asList("-e", "-extension")),
TNT(TestblockParameter::enableTNT, Arrays.asList("-t", "-tnt")),
WATER(TestblockParameter::enableWater, Arrays.asList("-w", "-water")),
IGNORE_AIR(TestblockParameter::enableIgnoreAir, Arrays.asList("-ig", "-ignore_air")),
ONLY_COLOR(TestblockParameter::enableOnlyColor, Arrays.asList("-o", "-color", "-only_color"));
@Getter
private final Consumer<TestblockParameter> testblockParameterConsumer;
@Getter
private List<String> tabCompletes;
@Getter
private final Supplier<TestblockParameterType[]> removed;
private AtomicReference<TestblockParameterType[]> cached = new AtomicReference<>();
TestblockParameterType(Consumer<TestblockParameter> testblockParameterConsumer, List<String> tabCompletes, String... removed) {
this.testblockParameterConsumer = testblockParameterConsumer;
this.tabCompletes = tabCompletes;
this.removed = () -> {
if (cached.get() == null) {
TestblockParameterType[] showModeParameterTypes = new TestblockParameterType[removed.length];
for (int i = 0; i < removed.length; i++) {
showModeParameterTypes[i] = TestblockParameterType.valueOf(removed[i]);
}
cached.set(showModeParameterTypes);
return showModeParameterTypes;
}
return cached.get();
};
}
}
}

Datei anzeigen

@ -51,7 +51,7 @@ public class TestblockBauGuiItem extends BauGuiItem {
public boolean click(ClickType click, Player p) {
if (click == ClickType.LEFT) {
p.closeInventory();
testblockCommand.genericTestblockCommand(p);
testblockCommand.schematicTestblockCommand(p);
} else {
SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> {
p.closeInventory();

Datei anzeigen

@ -1,342 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.custom.MenuScript;
import de.steamwar.bausystem.features.script.custom.Script;
import de.steamwar.bausystem.features.script.custom.command.CustomCommand;
import de.steamwar.bausystem.features.script.custom.command.InventoryCommand;
import de.steamwar.bausystem.features.script.custom.command.MenuCommand;
import de.steamwar.bausystem.features.script.custom.event.CustomEvent;
import de.steamwar.bausystem.features.script.custom.event.EventType;
import de.steamwar.bausystem.features.script.custom.event.InventoryEvent;
import de.steamwar.bausystem.features.script.custom.event.MenuEvent;
import de.steamwar.bausystem.features.script.custom.hotkey.Hotkey;
import de.steamwar.bausystem.features.script.custom.hotkey.Hotkeys;
import de.steamwar.bausystem.features.script.custom.hotkey.InventoryHotkey;
import de.steamwar.bausystem.features.script.custom.hotkey.MenuHotkey;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.UserConfig;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import yapion.hierarchy.output.LengthOutput;
import yapion.hierarchy.output.StringOutput;
import yapion.hierarchy.types.YAPIONArray;
import yapion.hierarchy.types.YAPIONMap;
import yapion.hierarchy.types.YAPIONObject;
import yapion.hierarchy.types.YAPIONValue;
import yapion.parser.YAPIONParser;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@Linked
public class CustomScriptManager implements Listener {
public final Map<Player, List<Script>> playerMap = Collections.synchronizedMap(new HashMap<>()); // new ConcurrentHashMap<>();
private void updateInventory(Player p) {
playerMap.computeIfPresent(p, (player, customCommands) -> {
customCommands.removeIf(script -> !(script instanceof MenuScript));
return customCommands;
});
for (ItemStack item : p.getInventory().getContents()) {
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
continue;
}
BookMeta bookMeta = ((BookMeta) item.getItemMeta());
if (bookMeta.getPageCount() == 0) {
continue;
}
if (bookMeta.getPage(1).isEmpty()) {
continue;
}
String s = bookMeta.getPage(1).split("\n")[0];
if (s.startsWith("#!CMD /")) {
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryCommand(bookMeta, s.substring(6).split(" ")));
} else if (s.startsWith("#!EVENT ")) {
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryEvent(bookMeta, s.substring(8).split(" ")));
} else if (s.startsWith("#!HOTKEY ")) {
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryHotkey(bookMeta, s.substring(9).split(" ")));
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
load(e.getPlayer());
}
private synchronized void load(Player p) {
updateInventory(p);
String s = UserConfig.getConfig(p.getUniqueId(), "bausystem-scripts");
if (s == null) {
s = UserConfig.getConfig(p.getUniqueId(), "bausystem-commands");
UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-commands");
}
YAPIONObject yapionObject;
if (s == null) {
yapionObject = new YAPIONObject();
yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).add("FF", new YAPIONArray().add("#!EVENT FF /gui Script\ngui"));
} else {
yapionObject = YAPIONParser.parse(s);
if (yapionObject.containsKey("")) {
yapionObject.add("commands", yapionObject.getMap(""));
yapionObject.remove("");
yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).add("FF", new YAPIONArray().add("#!EVENT FF /gui Script\ngui"));
}
}
yapionObject.getYAPIONMapOrSetDefault("commands", new YAPIONMap()).forEach((key, value) -> {
String[] command = ((YAPIONValue<String>) key).get().split(" ");
List<String> pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList());
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuCommand(pages, command));
});
yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).forEach((key, value) -> {
String[] event = ((YAPIONValue<String>) key).get().split(" ");
List<String> pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList());
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuEvent(pages, event));
});
yapionObject.getYAPIONMapOrSetDefault("hotkeys", new YAPIONMap()).forEach((key, value) -> {
String[] hotkey = ((YAPIONValue<String>) key).get().split(" ");
List<String> pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList());
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuHotkey(pages, hotkey));
});
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
save(e.getPlayer());
playerMap.remove(e.getPlayer());
}
private YAPIONObject output(Player p) {
if (!playerMap.containsKey(p)) return new YAPIONObject();
YAPIONObject yapionObject = new YAPIONObject();
YAPIONMap commandsMap = new YAPIONMap();
yapionObject.add("commands", commandsMap);
playerMap.get(p).stream().filter(MenuCommand.class::isInstance).map(MenuCommand.class::cast).forEach(menuCommand -> {
menuCommand.save(commandsMap);
});
YAPIONMap eventsMap = new YAPIONMap();
yapionObject.add("events", eventsMap);
playerMap.get(p).stream().filter(MenuEvent.class::isInstance).map(MenuEvent.class::cast).forEach(menuCommand -> {
menuCommand.save(eventsMap);
});
YAPIONMap hotkeysMap = new YAPIONMap();
yapionObject.add("hotkeys", hotkeysMap);
playerMap.get(p).stream().filter(MenuHotkey.class::isInstance).map(MenuHotkey.class::cast).forEach(menuCommand -> {
menuCommand.save(hotkeysMap);
});
return yapionObject;
}
private boolean save(Player p) {
if (!playerMap.containsKey(p)) {
UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-scripts");
return true;
}
YAPIONObject yapionObject = output(p);
if (yapionObject.toYAPION(new LengthOutput()).getLength() > 64 * 1024) {
return false;
}
UserConfig.updatePlayerConfig(p.getUniqueId(), "bausystem-scripts", yapionObject.toYAPION(new StringOutput()).getResult());
return true;
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
if (e.getPlayer() instanceof Player) {
updateInventory((Player) e.getPlayer());
}
}
public void openCommandsMenu(Player p) {
List<SWListInv.SWListEntry<MenuScript>> menuCommands = new ArrayList<>();
playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(MenuScript.class::isInstance).map(MenuScript.class::cast).forEach(menuItem -> {
SWItem swItem = menuItem.toItem(p);
ItemStack itemStack = swItem.getItemStack();
if (menuItem instanceof MenuHotkey) {
itemStack.setType(Material.CHAIN_COMMAND_BLOCK);
} else if (menuItem instanceof MenuEvent) {
itemStack.setType(Material.REPEATING_COMMAND_BLOCK);
} else {
itemStack.setType(Material.COMMAND_BLOCK);
}
swItem.setItemStack(itemStack);
swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_1", p), BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_2", p)));
menuCommands.add(new SWListInv.SWListEntry<>(swItem, menuItem));
});
int length = (int) output(p).toYAPION(new LengthOutput()).getLength();
double percentage = ((int) ((length / 655336.0) * 1000)) / 10.0;
String menuName = BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_NAME", p, percentage > 99 ? "§c" : (percentage >= 75 ? "§6" : "§a"), percentage);
SWListInv<MenuScript> menuCommandSWListInv = new SWListInv<>(p, menuName, false, menuCommands, (clickType, menuCommand) -> {
if (!clickType.isShiftClick()) {
playerMap.get(p).removeIf(customCommand -> customCommand == menuCommand);
}
SWUtils.giveItemToPlayer(p, menuCommand.toItem(p).getItemStack());
p.closeInventory();
save(p);
});
menuCommandSWListInv.setItem(49, new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_LORE", p)), false, clickType -> {
ItemStack item = p.getItemOnCursor();
if (item.getType().isAir()) {
return;
}
if (FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return;
}
BookMeta bookMeta = ((BookMeta) item.getItemMeta());
if (bookMeta.getPageCount() == 0) {
return;
}
if (bookMeta.getPage(1).isEmpty()) {
return;
}
String s = bookMeta.getPage(1).split("\n")[0];
if (s.startsWith("#!CMD /")) {
MenuCommand menuCommand = new MenuCommand(bookMeta.getPages(), s.substring(6).split(" "));
for (Script script : playerMap.computeIfAbsent(p, player -> new ArrayList<>())) {
if (!(script instanceof MenuCommand)) {
continue;
}
if (((MenuCommand) script).equals(menuCommand)) {
BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_DUPLICATE_COMMAND", p, String.join(" ", menuCommand.command()));
return;
}
}
scriptBookLimit(p, menuCommand);
} else if (s.startsWith("#!EVENT ")) {
MenuEvent menuEvent = new MenuEvent(bookMeta.getPages(), s.substring(8).split(" "));
try {
EventType.valueOf(menuEvent.eventName());
} catch (Exception e) {
BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_UNKNOWN_EVENT", p, menuEvent.eventName());
return;
}
scriptBookLimit(p, menuEvent);
} else if (s.startsWith("#!HOTKEY ")) {
scriptBookLimit(p, new MenuHotkey(bookMeta.getPages(), s.substring(9).split(" ")));
}
}));
menuCommandSWListInv.open();
}
private void scriptBookLimit(Player p, Script menuScript) {
playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(menuScript);
if (!save(p)) {
playerMap.get(p).removeIf(script -> script == menuScript);
p.closeInventory();
SWUtils.giveItemToPlayer(p, p.getItemOnCursor());
save(p);
BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_LIMIT", p);
return;
}
p.setItemOnCursor(null);
openCommandsMenu(p);
}
public boolean callCommand(Player p, PlayerCommandPreprocessEvent e, String message) {
List<CustomCommand> customCommands = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomCommand.class::isInstance).map(CustomCommand.class::cast).collect(Collectors.toList());
String[] command = message.split(" ");
for (CustomCommand customCommand : customCommands) {
if (customCommand.execute(command, e)) {
return true;
}
}
return false;
}
public boolean callScoreboard(Player p, Map<String, String> variables, Consumer<String> echoConsumer) {
Map<String, Value> valueMap = new HashMap<>();
for (Map.Entry<String, String> entry : variables.entrySet()) {
valueMap.put(entry.getKey(), new Value.StringValue(entry.getValue()));
}
List<CustomEvent> customEvents = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomEvent.class::isInstance).map(CustomEvent.class::cast).collect(Collectors.toList());
boolean hasScript = false;
for (CustomEvent customEvent : customEvents) {
if (customEvent.eventName().equals(EventType.Scoreboard.name())) {
customEvent.execute(p, valueMap, echoConsumer);
hasScript = true;
}
}
return hasScript;
}
public void callEvent(EventType eventType, Player p, Event e) {
if (eventType == null) return;
if (!eventType.getEventType().equals(e.getClass())) return;
List<CustomEvent> customEvents = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomEvent.class::isInstance).map(CustomEvent.class::cast).collect(Collectors.toList());
for (CustomEvent customEvent : customEvents) {
if (customEvent.eventName().equals(eventType.name())) {
Map<String, Value> variables = eventType.getEventValues().apply(e);
if (variables == null) {
variables = new HashMap<>();
}
if (e instanceof Cancellable) {
variables.put("cancel", new Value.BooleanValue(((Cancellable) e).isCancelled()));
}
customEvent.execute(p, variables, null);
if (variables.containsKey("cancel")) {
Value value = variables.get("cancel");
((Cancellable) e).setCancelled(value.asBoolean());
}
}
}
}
public void callHotkey(int modifiers, char pressedHotkey, Player p, boolean pressed) {
List<Hotkey> hotkeys = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(Hotkey.class::isInstance).map(Hotkey.class::cast).collect(Collectors.toList());
for (Hotkey hotkey : hotkeys) {
if (Hotkeys.isSame(modifiers, pressedHotkey, hotkey.hotkey())) {
hotkey.execute(p, pressed);
}
}
}
}

Datei anzeigen

@ -0,0 +1,77 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@AllArgsConstructor
@Builder
@EqualsAndHashCode
public class Hotkey {
private final int charcode;
private final boolean ctrl;
private final boolean shift;
private final boolean alt;
private final boolean meta;
public static Hotkey fromString(String string) {
String[] parts = string.split("\\+");
HotkeyBuilder builder = Hotkey.builder();
for (String part : parts) {
switch (part.toLowerCase()) {
case "ctrl":
builder.ctrl(true);
break;
case "shift":
builder.shift(true);
break;
case "alt":
builder.alt(true);
break;
case "meta":
builder.meta(true);
break;
default:
if (part.length() == 1) {
builder.charcode(Character.toLowerCase(part.charAt(0)));
} else {
throw new IllegalArgumentException("Invalid hotkey: " + string);
}
}
}
return builder.build();
}
public static Hotkey fromChar(int c, int mods) {
return Hotkey.builder()
.charcode(Character.toLowerCase(c))
.shift((mods & 1) != 0)
.ctrl((mods & 2) != 0)
.alt((mods & 4) != 0)
.meta((mods & 8) != 0)
.build();
}
}

Datei anzeigen

@ -1,20 +1,28 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import static de.steamwar.bausystem.features.script.ScriptExecutor.SPECIAL_COMMANDS;
@Linked
public class ScriptCommand extends SWCommand {
@ -22,142 +30,8 @@ public class ScriptCommand extends SWCommand {
super("script");
}
@LinkedInstance
public CustomScriptManager customScriptManager = null;
private List<String> loreBuilder(Player p, String... strings) {
List<String> result = new ArrayList<>();
for (String s : strings) {
result.addAll(split(BauSystem.MESSAGE.parse(s, p)));
}
return result;
}
@Register(description = "SCRIPT_COMMAND_HELP")
public void menuCommand(Player p) {
List<SWListInv.SWListEntry<SpecialCommand>> swItems = new ArrayList<>();
addEmptyItems(swItems, 2);
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_HOTKEYS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5")), null));
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_COMMANDS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2")), null));
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_EVENTS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_1", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_2", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_3", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_4", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_5", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_6", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_7", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_8", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_9", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_10", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_11", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_12", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_13", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_14", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_15", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_16", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_17", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_18", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1")), null));
addEmptyItems(swItems, 1);
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_OTHER", loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_1", "SCRIPT_GUI_OTHER_LORE_2", "SCRIPT_GUI_OTHER_LORE_3", "SCRIPT_GUI_OTHER_LORE_4", "SCRIPT_GUI_OTHER_LORE_5", "SCRIPT_GUI_OTHER_LORE_6", "SCRIPT_GUI_OTHER_LORE_7", "SCRIPT_GUI_OTHER_LORE_8", "SCRIPT_GUI_OTHER_LORE_9", "SCRIPT_GUI_OTHER_LORE_10", "SCRIPT_GUI_OTHER_LORE_11", "SCRIPT_GUI_OTHER_LORE_12", "SCRIPT_GUI_OTHER_LORE_13", "SCRIPT_GUI_OTHER_LORE_14", "SCRIPT_GUI_OTHER_LORE_15", "SCRIPT_GUI_OTHER_LORE_16", "SCRIPT_GUI_OTHER_LORE_17", "SCRIPT_GUI_OTHER_LORE_18")), null));
addEmptyItems(swItems, 2);
addCustomScriptsItems(swItems, p);
addEmptyItems(swItems, 45 - swItems.size() % 45);
addEmptyItems(swItems, 4);
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_VARIABLES", new ArrayList<>()), null));
addEmptyItems(swItems, 4);
addConstantItem(swItems, p, Material.CLOCK, "SCRIPT_GUI_CONSTANT_TIME_NAME", "SCRIPT_GUI_CONSTANT_TIME_LORE");
addConstantItem(swItems, p, Material.CLOCK, "SCRIPT_GUI_CONSTANT_TICKS_NAME", "SCRIPT_GUI_CONSTANT_TICKS_LORE");
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_NAME", "SCRIPT_GUI_CONSTANT_TRACE_LORE");
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME", "SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE");
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME", "SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE");
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME", "SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE");
addConstantItem(swItems, p, Material.HOPPER, "SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME", "SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE");
addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_TNT_NAME", "SCRIPT_GUI_CONSTANT_TNT_LORE");
addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_ONLY_TB_NAME", "SCRIPT_GUI_CONSTANT_ONLY_TB_LORE");
addConstantItem(swItems, p, Material.GUNPOWDER, "SCRIPT_GUI_CONSTANT_FREEZE_NAME", "SCRIPT_GUI_CONSTANT_FREEZE_LORE");
addConstantItem(swItems, p, Material.FIRE_CHARGE, "SCRIPT_GUI_CONSTANT_FIRE_NAME", "SCRIPT_GUI_CONSTANT_FIRE_LORE");
addConstantItem(swItems, p, Material.OBSIDIAN, "SCRIPT_GUI_CONSTANT_PROTECT_NAME", "SCRIPT_GUI_CONSTANT_PROTECT_LORE");
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_X_NAME", "SCRIPT_GUI_CONSTANT_X_LORE");
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Y_NAME", "SCRIPT_GUI_CONSTANT_Y_LORE");
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Z_NAME", "SCRIPT_GUI_CONSTANT_Z_LORE");
addConstantItem(swItems, p, Material.NAME_TAG, "SCRIPT_GUI_CONSTANT_NAME_NAME", "SCRIPT_GUI_CONSTANT_NAME_LORE");
addConstantItem(swItems, p, Material.IRON_BOOTS, "SCRIPT_GUI_CONSTANT_SNEAK_NAME", "SCRIPT_GUI_CONSTANT_SNEAK_LORE");
addConstantItem(swItems, p, Material.DIAMOND_BOOTS, "SCRIPT_GUI_CONSTANT_SPRINTING_NAME", "SCRIPT_GUI_CONSTANT_SPRINTING_LORE");
addConstantItem(swItems, p, Material.ARROW, "SCRIPT_GUI_CONSTANT_SLOT_NAME", "SCRIPT_GUI_CONSTANT_SLOT_LORE");
addConstantItem(swItems, p, Material.GRASS_BLOCK, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE");
addConstantItem(swItems, p, Material.IRON_BLOCK, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE");
addConstantItem(swItems, p, Material.BIRCH_SIGN, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE");
addConstantItem(swItems, p, Material.ACACIA_SIGN, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE");
addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", "SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE");
addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_NAME_NAME", "SCRIPT_GUI_CONSTANT_REGION_NAME_LORE");
addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_NAME", "SCRIPT_GUI_CONSTANT_TPS_LORE");
addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME", "SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE");
addEmptyItems(swItems, 45 - swItems.size() % 45);
SWListInv<SpecialCommand> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> {
if (o != null) {
BauSystem.MESSAGE.send("SCRIPT_GUI_COMMAND_CHAT", p, o.command());
for (String s : o.description()) {
if (s.isEmpty()) {
BauSystem.MESSAGE.sendPrefixless("PREFIX", p);
} else {
BauSystem.MESSAGE.send(s, p);
}
}
p.closeInventory();
}
});
swListInv.open();
}
private void addEmptyItems(List<SWListInv.SWListEntry<SpecialCommand>> swItems, int count) {
for (int i = 0; i < count; i++) {
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
}), null));
}
}
private SWItem createItem(Player p, Material material, String name, List<String> lore) {
return new SWItem(material, BauSystem.MESSAGE.parse(name, p), lore, false, clickType -> {
});
}
private void addConstantItem(List<SWListInv.SWListEntry<SpecialCommand>> swItems, Player p, Material material, String name, String lore) {
List<String> itemLore = new ArrayList<>();
itemLore.add(BauSystem.MESSAGE.parse(lore, p));
swItems.add(new SWListInv.SWListEntry<>(createItem(p, material, name, itemLore), null));
}
private void addCustomScriptsItems(List<SWListInv.SWListEntry<SpecialCommand>> swItems, Player p) {
List<SpecialCommand> specialCommands = new ArrayList<>(SPECIAL_COMMANDS);
specialCommands.sort(Comparator.comparing(specialCommand -> specialCommand.getClass().getTypeName()));
specialCommands.forEach(specialCommand -> {
List<String> strings = new ArrayList<>();
boolean b = false;
for (String s : specialCommand.description()) {
if (s.isEmpty()) {
b = true;
strings.add("");
continue;
}
s = BauSystem.MESSAGE.parse(s, p);
if (b) {
strings.addAll(split(s));
} else {
strings.add(s);
}
}
SWItem swItem = new SWItem(specialCommand.material(), BauSystem.MESSAGE.parse("SCRIPT_GUI_COMMAND_NAME", p, specialCommand.command()), strings, false, clickType -> {
});
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
});
}
private List<String> split(String s) {
List<String> strings = new ArrayList<>();
while (s.length() > 60) {
int index = s.indexOf(' ', 60);
if (index == -1) {
strings.add("§7" + s);
s = null;
break;
} else {
strings.add("§7" + s.substring(0, index));
s = s.substring(index + 1);
}
}
if (s != null) {
strings.add("§7" + s);
}
return strings;
}
@Register(value = "menu", description = "SCRIPT_COMMAND_HELP_MENU")
public void menuGUICommand(Player p) {
customScriptManager.openCommandsMenu(p);
@Register
public void genericCommand(Player player) {
ScriptGUI.open(player);
}
}

Datei anzeigen

@ -1,304 +0,0 @@
package de.steamwar.bausystem.features.script;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.expression.Expression;
import de.steamwar.bausystem.features.script.expression.UnknownOperatorException;
import de.steamwar.bausystem.features.script.expression.VarNotFoundException;
import de.steamwar.bausystem.features.script.variables.Constants;
import de.steamwar.bausystem.features.script.variables.Context;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.features.world.WorldEditListener;
import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.utils.WorldEditUtils;
import lombok.Getter;
import lombok.Setter;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.meta.BookMeta;
import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Level;
public final class ScriptExecutor {
public static final Set<SpecialCommand> SPECIAL_COMMANDS = new HashSet<>();
static {
LinkageUtils.linkScriptCommands();
}
private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null;
private String specialCommand = null;
@Getter
private final Player player;
@Getter
private final Context localVariables = new Context();
@Getter
private final Context globalVariables;
private final List<String> commands = new ArrayList<>();
@Getter
public final Map<String, Integer> jumpPoints = new HashMap<>();
@Getter
private final LinkedList<Integer> returnStack = new LinkedList<>();
@Getter
@Setter
private int index = 0;
@Getter
private final Consumer<String> echoConsumer;
public ScriptExecutor(BookMeta bookMeta, Player player, Consumer<String> echoConsumer) {
this(bookMeta, player, new HashMap<>(), echoConsumer);
}
public ScriptExecutor(List<String> pages, Player player, Consumer<String> echoConsumer) {
this(pages, player, new HashMap<>(), echoConsumer);
}
public ScriptExecutor(BookMeta bookMeta, Player player, Map<String, Value> localVariables, Consumer<String> echoConsumer) {
this.player = player;
globalVariables = ScriptListener.getGlobalContext(player);
parseMeta(bookMeta);
this.echoConsumer = echoConsumer != null ? echoConsumer : s -> {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_IO_ECHO_MESSAGE", player, s);
};
if (commands.isEmpty()) return;
localVariables.forEach(this.localVariables::putValue);
resume();
}
public ScriptExecutor(List<String> pages, Player player, Map<String, Value> localVariables, Consumer<String> echoConsumer) {
this.player = player;
globalVariables = ScriptListener.getGlobalContext(player);
parseList(pages);
this.echoConsumer = echoConsumer != null ? echoConsumer : s -> {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_IO_ECHO_MESSAGE", player, s);
};
if (commands.isEmpty()) return;
localVariables.forEach(this.localVariables::putValue);
resume();
}
private void parseMeta(BookMeta bookMeta) {
boolean initial = true;
for (String page : bookMeta.getPages()) {
initial = parsePage(page, initial);
}
}
private void parseList(List<String> pages) {
boolean initial = true;
for (String page : pages) {
initial = parsePage(page, initial);
}
}
private boolean parsePage(String page, boolean initial) {
for (String command : page.split("\n")) {
command = command.replaceAll(" +", " ");
if (command.startsWith("#") || command.trim().isEmpty()) {
if (initial && command.startsWith("#!CMD /")) {
specialCommand = command.substring(7).split(" ")[0];
}
initial = false;
continue;
}
initial = false;
if (command.startsWith(".")) {
jumpPoints.put(command.substring(1), commands.size());
continue;
}
commands.add(command);
}
return initial;
}
public void resume() {
if (!player.isOnline()) {
return;
}
int executionPoints = 0;
while (index < commands.size()) {
String command = commands.get(index).trim();
index++;
if (executionPoints++ > 200) {
BauSystem.MESSAGE.send("SCRIPT_SLEEP_ERROR", player);
return;
}
String[] strings = replaceExpressions(command);
if (strings.length == 0) {
return;
}
boolean found = false;
for (SpecialCommand specialCommand : SPECIAL_COMMANDS) {
if (specialCommand.command().equalsIgnoreCase(strings[0])) {
found = true;
if (!specialCommand.execute(strings, this)) {
return;
}
}
}
if (found) {
continue;
}
if (strings[0].contains(":")) {
continue;
}
// Variable Replaces in commands.
command = String.join(" ", strings);
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + (specialCommand != null && command.startsWith(specialCommand) ? "script:" : "") + command);
Bukkit.getServer().getPluginManager().callEvent(preprocessEvent);
if (preprocessEvent.isCancelled()) {
continue;
}
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
if (!strings[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + strings[0])) {
EditSession editSession = WorldEditUtils.getEditSession(player);
Actor actor = BukkitAdapter.adapt(player);
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
editSession.flushSession();
WorldEditUtils.addToPlayer(player, editSession);
} else {
Bukkit.getServer().dispatchCommand(player, command);
}
}
}
private String[] replaceExpressions(String s) {
s = s.replaceAll(" +", " ");
StringBuilder result = new StringBuilder();
int depth = 0;
StringBuilder st = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '{') {
st.append(c);
depth++;
} else if (c == '}') {
st.append(c);
depth--;
if (depth == 0) {
try {
Expression expression = new Expression(player, st.toString(), this);
result.append(expression.eval().asString());
st = new StringBuilder();
} catch (IllegalArgumentException e) {
BauSystem.MESSAGE.send(e.getMessage(), player);
return new String[0];
} catch (VarNotFoundException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_VAR", player, e.getMessage());
return new String[0];
} catch (IndexOutOfBoundsException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_EXPRESSION", player, st.toString());
return new String[0];
} catch (UnknownOperatorException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION", player, e.getMessage());
return new String[0];
}
}
} else if (st.length() > 0) {
st.append(c);
} else {
result.append(c);
}
}
return result.toString().split(" ");
}
public Value getOrItselfValue(String variable) {
if (!isVariable(variable)) {
return Value.parse(variable);
}
if (localVariables.hasValue(variable)) {
return localVariables.getValue(variable);
}
if (globalVariables.hasValue(variable)) {
return globalVariables.getValue(variable);
}
return Constants.getConstant(variable, player);
}
public Value getValueOrNull(String variable) {
if (localVariables.hasValue(variable)) {
return localVariables.getValue(variable);
}
if (globalVariables.hasValue(variable)) {
return globalVariables.getValue(variable);
}
if (Constants.isConstant(variable)) {
return Constants.getConstant(variable, player);
}
return null;
}
public String getOrItself(String variable) {
if (isVariable(variable)) {
return getValue(variable);
}
return variable;
}
public boolean isVariable(String variable) {
return Constants.isConstant(variable) || globalVariables.hasValue(variable) || localVariables.hasValue(variable);
}
public String getValue(String variable) {
if (localVariables.hasValue(variable)) {
return localVariables.getValue(variable).asString();
}
if (globalVariables.hasValue(variable)) {
return globalVariables.getValue(variable).asString();
}
if (Constants.isConstant(variable)) {
return Constants.getConstant(variable, player).asString();
}
return "";
}
public String getConstant(String variable) {
if (Constants.isConstant(variable)) {
return Constants.getConstant(variable, player).asString();
}
return "0";
}
public String getGlobal(String variable) {
if (globalVariables.hasValue(variable)) {
return globalVariables.getValue(variable).asString();
}
return "0";
}
public String getLocal(String variable) {
if (localVariables.hasValue(variable)) {
return localVariables.getValue(variable).asString();
}
return "0";
}
}

Datei anzeigen

@ -0,0 +1,141 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.Script;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.luaj.vm2.Globals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@Linked
public class ScriptGUI implements Listener {
public static void open(Player player) {
open(player, null);
}
private static void open(Player player, ItemStack setCursor) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
List<SWListInv.SWListEntry<Script>> entries = new ArrayList<>();
List<String> lore = new ArrayList<>();
Globals globals = SteamWarPlatform.createGlobalParser(
(eventType, luaFunction) -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_EVENT_ITEM_NAME", player, eventType.name())),
(s, luaFunction) -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_HOTKEY_ITEM_NAME", player, s)),
commandRegister -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_COMMAND_ITEM_NAME", player, commandRegister.getName()))
);
Script.list(user).forEach(script -> {
try {
globals.load(script.getCode()).call();
} catch (Exception e) {
String[] sp = e.getMessage().split(":");
lore.add(BauSystem.MESSAGE.parse("SCRIPT_ERROR_GUI", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length))));
}
if(!lore.isEmpty()) {
lore.add("");
}
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_1", player));
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_2", player));
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_3", player));
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_4", player));
entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.ENCHANTED_BOOK, script.getName(), new ArrayList<>(lore), false, clickType -> {}), script));
lore.clear();
});
SWListInv<Script> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_NAME", player), false, entries, (clickType, script) -> {
ItemStack itemStack = ScriptHelper.getScriptItem(script, clickType.isRightClick());
if(clickType == ClickType.MIDDLE) {
player.openBook(itemStack);
} else if(!clickType.isShiftClick()) {
script.delete();
ScriptRunner.updateGlobalScript(player);
open(player, itemStack);
} else {
player.getOpenInventory().setCursor(itemStack);
}
});
inv.setItem(49, Material.HOPPER, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_LORE", player)), false, click -> {
if(player.getOpenInventory().getCursor() != null) {
ItemStack cursor = player.getOpenInventory().getCursor();
if(!(cursor.getItemMeta() instanceof BookMeta)) {
return;
}
BookMeta meta = (BookMeta) cursor.getItemMeta();
if(meta == null) {
return;
}
saveWithName(player, meta, meta.getTitle());
}
});
inv.open();
if(setCursor != null) {
player.getOpenInventory().setCursor(setCursor);
}
}
private static void saveWithName(Player player, BookMeta meta, String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(name != null && Script.list(user).stream().noneMatch(script -> script.getName().equalsIgnoreCase(name))) {
Script.create(user, name, ScriptHelper.getScriptString(meta.getPages()));
player.getOpenInventory().setCursor(null);
ScriptRunner.updateGlobalScript(player);
open(player);
} else {
SWAnvilInv inv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ENTER_NAME", player), name == null ? "" : name);
AtomicBoolean saved = new AtomicBoolean(false);
ItemStack itemStack = player.getOpenInventory().getCursor();
inv.setCallback(s -> {
saveWithName(player, meta, s);
saved.set(true);
});
inv.addCloseCallback(() -> {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (saved.get()) return;
SWUtils.giveItemToPlayer(player, itemStack);
}, 1);
});
inv.open();
}
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.sql.Script;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class ScriptHelper {
private static final String PAGE_SEPARATOR = "\n\0\n";
public static ItemStack getScriptItem(Script script, boolean writeable) {
ItemStack itemStack = new ItemStack(writeable ? Material.WRITABLE_BOOK : Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) itemStack.getItemMeta();
if(!writeable) {
meta.setTitle(script.getName());
meta.setAuthor(SteamwarUser.get(script.getUserId()).getUserName());
}
meta.setPages(getScriptPages(script));
itemStack.setItemMeta(meta);
return itemStack;
}
public static List<String> getScriptPages(Script script) {
return Arrays.stream(script.getCode().split(PAGE_SEPARATOR)).collect(Collectors.toList());
}
public static String getScriptString(List<String> pages) {
return String.join(PAGE_SEPARATOR, pages);
}
}

Datei anzeigen

@ -1,6 +1,24 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.features.script.variables.Context;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@ -14,17 +32,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked
public class ScriptListener implements Listener {
private static final Map<Player, Context> GLOBAL_CONTEXT = new HashMap<>();
private Set<Player> playerSet = new HashSet<>();
private final Set<Player> playerSet = new HashSet<>();
@EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) {
@ -44,20 +58,16 @@ public class ScriptListener implements Listener {
}
event.setCancelled(true);
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer(), null);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
GLOBAL_CONTEXT.put(event.getPlayer(), new Context());
ScriptRunner.runScript(((BookMeta) item.getItemMeta()).getPages().stream().reduce((s, s2) -> s + "\n" + s2).orElse(null), event.getPlayer());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
GLOBAL_CONTEXT.remove(event.getPlayer());
ScriptRunner.remove(event.getPlayer());
}
public static Context getGlobalContext(Player player) {
return GLOBAL_CONTEXT.computeIfAbsent(player, ignore -> new Context());
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
ScriptRunner.updateGlobalScript(event.getPlayer());
}
}

Datei anzeigen

@ -0,0 +1,207 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.lua.CommandRegister;
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
import de.steamwar.sql.Script;
import de.steamwar.sql.SteamwarUser;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.luaj.vm2.*;
import org.luaj.vm2.lib.OneArgFunction;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@UtilityClass
public class ScriptRunner {
// Script Table
// User
// Key -> bau-script-<BUCH NAME>
// Value -> <LUA Script>
private static final Map<Player, Map<SteamWarGlobalLuaPlugin.EventType, List<LuaFunction>>> EVENT_MAP = new HashMap<>();
private static final Map<Player, Map<Hotkey, List<LuaFunction>>> HOTKEY_MAP = new HashMap<>();
private static final Map<Player, Map<String, CommandRegister>> COMMAND_MAP = new HashMap<>();
public static void runScript(String script, Player player) {
Globals globals = SteamWarPlatform.createClickGlobals(player);
catchScript("SCRIPT_ERROR_CLICK", player, () -> globals.load(script).call());
}
public static void updateGlobalScript(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
ScriptRunner.createGlobalScript(Script.list(user).stream().map(Script::getCode).collect(Collectors.toList()), player);
}
public static void createGlobalScript(List<String> scripts, Player player) {
remove(player);
Globals globals = SteamWarPlatform.createGlobalGlobals(player,
(s, luaFunction) -> EVENT_MAP.computeIfAbsent(player, player1 -> new EnumMap<>(SteamWarGlobalLuaPlugin.EventType.class)).computeIfAbsent(s, s1 -> new ArrayList<>()).add(luaFunction),
(s, luaFunction) -> HOTKEY_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).computeIfAbsent(Hotkey.fromString(s), s1 -> new ArrayList<>()).add(luaFunction),
commandRegister -> COMMAND_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).put(commandRegister.getName(), commandRegister));
for (String script : scripts) {
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> globals.load(script).call());
}
}
public static void remove(Player player) {
EVENT_MAP.remove(player);
COMMAND_MAP.remove(player);
HOTKEY_MAP.remove(player);
}
public static void callEvent(Player player, SteamWarGlobalLuaPlugin.EventType event, LuaValue eventValue, Event wrappedEvent) {
List<LuaFunction> luaFunctions = EVENT_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(event, Collections.emptyList());
if (luaFunctions.isEmpty()) {
if(event == SteamWarGlobalLuaPlugin.EventType.DoubleSwap) {
player.performCommand("gui");
}
return;
}
if (eventValue == LuaValue.NIL) {
eventValue = LuaValue.tableOf();
}
AtomicBoolean cancelled = new AtomicBoolean(false);
if (wrappedEvent instanceof Cancellable) {
eventValue.set("setCancelled", new OneArgFunction() {
@Override
public LuaValue call(LuaValue arg) {
cancelled.set(arg.checkboolean());
return valueOf(cancelled.get());
}
});
} else {
eventValue.set("setCancelled", new OneArgFunction() {
@Override
public LuaValue call(LuaValue arg) {
throw new LuaError("Event is not cancellable");
}
});
}
final LuaValue finalEventValue = eventValue;
for (LuaFunction luaFunction : luaFunctions) {
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> luaFunction.call(finalEventValue));
}
if (wrappedEvent instanceof Cancellable) {
((Cancellable) wrappedEvent).setCancelled(cancelled.get());
}
}
public static boolean callCommand(Player player, String command, String[] argsArray) {
CommandRegister commandRegister = COMMAND_MAP.getOrDefault(player, Collections.emptyMap()).get(command);
if (commandRegister == null) {
return false;
}
LuaValue[] values = new LuaValue[argsArray.length - 1];
for (int i = 1; i < argsArray.length; i++) {
values[i - 1] = LuaValue.valueOf(argsArray[i]);
}
LuaTable args = LuaValue.listOf(values);
args.set("alias", command);
args.set("hasShortFlag", new OneArgFunction() {
@Override
public LuaValue call(LuaValue arg) {
String s = arg.checkjstring();
if (!s.matches("-?[a-zA-Z]")) {
throw new LuaError("Short Flag must be one character");
}
String flag = s.charAt(s.length() - 1) + "";
boolean hasFlag = false;
for (String arg1 : argsArray) {
if (arg1.startsWith("-") && arg1.contains(flag)) {
hasFlag = true;
break;
}
}
return valueOf(hasFlag);
}
});
args.set("removeShortFlag", new OneArgFunction() {
@Override
public LuaValue call(LuaValue arg) {
String s = arg.checkjstring();
if (!s.matches("-?[a-zA-Z]")) {
throw new LuaError("Short Flag must be one character");
}
String flag = s.charAt(s.length() - 1) + "";
boolean hasFlag = false;
for (int i = 0; i < argsArray.length; i++) {
String arg1 = argsArray[i];
if (arg1.startsWith("-") && arg1.contains(flag)) {
String newArg = arg1.replace(flag, "");
if (newArg.equals("-")) {
args.remove(i);
} else {
args.set(i, newArg);
}
hasFlag = true;
break;
}
}
return valueOf(hasFlag);
}
});
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> commandRegister.getFunction().call(args));
return true;
}
public static void callHotkey(int mods, int key, Player player, boolean pressed) {
Hotkey hotkey = Hotkey.fromChar(key, mods);
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> HOTKEY_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed))));
}
public static void catchScript(String errorMsg, Player player, Runnable run) {
try {
run.run();
} catch (Exception e) {
String[] sp = e.getMessage().split(":");
int index = 0;
for (int i = sp.length - 1; i >= 0; i--) {
String[] ss = sp[i].split(" ");
boolean num = ss[0].chars().mapToObj(Character::isDigit).allMatch(b -> b);
if (num && !ss[0].isEmpty()) {
index = i;
break;
}
}
BauSystem.MESSAGE.send(errorMsg, player, String.join(":", Arrays.copyOfRange(sp, index, sp.length)));
}
}
}

Datei anzeigen

@ -1,105 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.custom.event.EventType;
import de.steamwar.bausystem.features.script.expression.Expression;
import de.steamwar.linkage.Linked;
import lombok.SneakyThrows;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import yapion.hierarchy.output.StringOutput;
import yapion.hierarchy.types.YAPIONArray;
import yapion.hierarchy.types.YAPIONObject;
import java.util.Arrays;
@Linked
public class ScriptSyntaxSender implements Listener {
private byte[] syntax;
{
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(BauSystem.getInstance(), "sw:script_syntax");
// Whole Syntax object
YAPIONObject yapionObject = new YAPIONObject();
ScriptExecutor.SPECIAL_COMMANDS.toString();
// Operators
YAPIONArray operators = new YAPIONArray();
yapionObject.add("@operators", operators);
Expression.OPERATORS.forEach((s, operator) -> {
operators.add(s);
});
// Headers
YAPIONArray headers = new YAPIONArray();
yapionObject.add("@headers", headers);
headers.add("CMD /.*");
headers.add("EVENT " + Arrays.stream(EventType.values()).map(Enum::name).reduce((s, s2) -> s + "|" + s2).map(s -> "(" + s + ")").orElse("") + "( .+)?");
headers.add("HOTKEY .+");
// Variable prefixes
YAPIONArray prefixes = new YAPIONArray();
yapionObject.add("@prefixes", prefixes);
prefixes.add("global");
prefixes.add("const");
prefixes.add("local");
// Variable suffixes
YAPIONArray suffixes = new YAPIONArray();
yapionObject.add("@suffixes", suffixes);
suffixes.add("isset");
suffixes.add("type");
suffixes.add("length");
// Commands
ScriptExecutor.SPECIAL_COMMANDS.forEach(specialCommand -> {
YAPIONArray yapionArray = new YAPIONArray();
yapionObject.add(specialCommand.command(), yapionArray);
if (specialCommand.repeating()) {
yapionArray.add(true);
} else {
yapionArray.add(false);
}
for (SpecialCommand.TokenType[] types : specialCommand.getSyntax()) {
YAPIONArray syntax = new YAPIONArray();
yapionArray.add(syntax);
for (SpecialCommand.TokenType type : types) {
syntax.add(type.ordinal());
}
}
});
syntax = yapionObject.toJSONLossy(new StringOutput()).getResult().getBytes();
}
@EventHandler
@SneakyThrows
public void onPlayerJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
event.getPlayer().sendPluginMessage(BauSystem.getInstance(), "sw:script_syntax", syntax);
}, 5);
}
}

Datei anzeigen

@ -1,86 +0,0 @@
package de.steamwar.bausystem.features.script;
import org.bukkit.Material;
public interface SpecialCommand {
default String[] description() {
return new String[0];
}
default Material material() {
return Material.PAPER;
}
String command();
boolean execute(String[] command, ScriptExecutor scriptExecutor);
default boolean repeating() {
return false;
}
TokenType[][] getSyntax();
default long asLong(String value) {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
return 0;
}
}
default boolean asBoolean(String value) {
return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes");
}
default String asString(String value) {
return value;
}
default void jumpToIndex(ScriptExecutor scriptExecutor, String jumpPoint) {
scriptExecutor.jumpPoints.computeIfPresent(jumpPoint, (s, integer) -> {
scriptExecutor.setIndex(integer);
return integer;
});
}
default void jumpToIndexWithMessage(ScriptExecutor scriptExecutor, String jumpPoint, String message) {
Integer jp = scriptExecutor.jumpPoints.getOrDefault(jumpPoint, null);
if (jp == null) {
scriptExecutor.getPlayer().sendMessage(message);
return;
}
scriptExecutor.setIndex(jp);
}
default void jumpToIndexWithMessageAndReturnStack(ScriptExecutor scriptExecutor, String jumpPoint, String message) {
Integer jp = scriptExecutor.jumpPoints.getOrDefault(jumpPoint, null);
if (jp == null) {
scriptExecutor.getPlayer().sendMessage(message);
return;
}
scriptExecutor.getReturnStack().add(scriptExecutor.getIndex());
scriptExecutor.setIndex(jp);
}
default void returnFromStackWithMessage(ScriptExecutor scriptExecutor, String message) {
if (scriptExecutor.getReturnStack().isEmpty()) {
scriptExecutor.getPlayer().sendMessage(message);
return;
}
scriptExecutor.setIndex(scriptExecutor.getReturnStack().pop());
}
enum TokenType {
any, // This does not include jump_point and variable
expression,
jump_point,
variable,
text_type,
number_type,
floating_number_type,
boolean_type,
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -37,7 +37,8 @@ public class UnsignCommand extends SWCommand {
public void unsignCommand(Player p) {
ItemStack itemStack = p.getInventory().getItemInMainHand();
if (FlatteningWrapper.impl.isNoBook(itemStack)) return;
itemStack.setType(Material.WRITABLE_BOOK);
p.getInventory().setItemInMainHand(itemStack);
ItemStack clone = new ItemStack(Material.WRITABLE_BOOK);
clone.setItemMeta(itemStack.getItemMeta());
p.getInventory().setItemInMainHand(clone);
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Call implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_CALL_HELP_1",
"",
"SCRIPT_COMMAND_CALL_HELP_2"
};
}
@Override
public Material material() {
return Material.LEATHER_BOOTS;
}
@Override
public String command() {
return "call";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
return true;
}
jumpToIndexWithMessageAndReturnStack(scriptExecutor, command[1], BauSystem.MESSAGE.parse("SCRIPT_COMMAND_CALL_ERROR", scriptExecutor.getPlayer(), command[1]));
return true;
}
private TokenType[][] syntax = {
{ TokenType.jump_point },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,41 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Exit implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_EXIT_HELP_1",
"",
"SCRIPT_COMMAND_EXIT_HELP_2"
};
}
@Override
public Material material() {
return Material.BARRIER;
}
@Override
public String command() {
return "exit";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
return false;
}
private TokenType[][] syntax = {};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,68 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class If implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_IF_HELP_1",
"SCRIPT_COMMAND_IF_HELP_2",
"",
"SCRIPT_COMMAND_IF_HELP_3"
};
}
@Override
public Material material() {
return Material.OBSERVER;
}
@Override
public String command() {
return "if";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length < 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE", scriptExecutor.getPlayer());
return true;
}
if (command.length < 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
return true;
}
Value v = scriptExecutor.getOrItselfValue(command[1]);
if (!(v instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NO_BOOLEAN", scriptExecutor.getPlayer());
return false;
}
if (v.asBoolean() && command.length > 2) {
jumpToIndex(scriptExecutor, command[2]);
} else if (command.length > 3) {
jumpToIndex(scriptExecutor, command[3]);
}
return true;
}
private TokenType[][] syntax = {
{ TokenType.boolean_type, TokenType.jump_point },
{ TokenType.boolean_type, TokenType.jump_point, TokenType.jump_point },
{ TokenType.expression, TokenType.jump_point },
{ TokenType.expression, TokenType.jump_point, TokenType.jump_point }
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Jump implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_JUMP_HELP_1",
"",
"SCRIPT_COMMAND_JUMP_HELP_2"
};
}
@Override
public Material material() {
return Material.LEATHER_BOOTS;
}
@Override
public String command() {
return "jump";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
return true;
}
jumpToIndexWithMessage(scriptExecutor, command[1], BauSystem.MESSAGE.parse("SCRIPT_COMMAND_JUMP_ERROR", scriptExecutor.getPlayer(), command[1]));
return true;
}
private TokenType[][] syntax = {
{ TokenType.jump_point }
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,43 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Return implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_RETURN_HELP_1",
"",
"SCRIPT_COMMAND_RETURN_HELP_2"
};
}
@Override
public Material material() {
return Material.DIAMOND_BOOTS;
}
@Override
public String command() {
return "return";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
returnFromStackWithMessage(scriptExecutor, BauSystem.MESSAGE.parse("SCRIPT_COMMAND_RETURN_ERROR", scriptExecutor.getPlayer()));
return true;
}
private TokenType[][] syntax = {};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,58 +0,0 @@
package de.steamwar.bausystem.features.script.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@Linked
public class Sleep implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_SLEEP_HELP_1",
"",
"SCRIPT_COMMAND_SLEEP_HELP_2"
};
}
@Override
public Material material() {
return Material.CLOCK;
}
@Override
public String command() {
return "sleep";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER", scriptExecutor.getPlayer());
return true;
}
long sleepTime = asLong(command[1]);
if (sleepTime < 0) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_SLEEP_ERROR", scriptExecutor.getPlayer());
return true;
}
if (sleepTime == 0) {
return true;
}
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), scriptExecutor::resume, sleepTime);
return false;
}
private TokenType[][] syntax = {
{ TokenType.number_type }
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,107 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.arithmetic.other;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Ceil implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE_TORCH;
}
@Override
public String command() {
return "ceil";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1;
Value v2;
if (command.length == 3) {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
v2 = new Value.LongValue(0);
} else {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
}
if (!(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_1", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() < 0) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() == 0) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue((long) Math.ceil(v1.asDouble())));
} else {
double pow = Math.pow(10, v2.asLong());
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(Math.ceil(v1.asDouble() * pow) / pow));
}
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type },
{ TokenType.variable, TokenType.variable, TokenType.number_type },
{ TokenType.variable, TokenType.floating_number_type, TokenType.number_type },
{ TokenType.variable, TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type, TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,107 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.arithmetic.other;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Floor implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE_TORCH;
}
@Override
public String command() {
return "floor";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1;
Value v2;
if (command.length == 3) {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
v2 = new Value.LongValue(0);
} else {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
}
if (!(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_1", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() < 0) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() == 0) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue((long) Math.floor(v1.asDouble())));
} else {
double pow = Math.pow(10, v2.asLong());
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(Math.floor(v1.asDouble() * pow) / pow));
}
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type },
{ TokenType.variable, TokenType.variable, TokenType.number_type },
{ TokenType.variable, TokenType.floating_number_type, TokenType.number_type },
{ TokenType.variable, TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type, TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,107 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.arithmetic.other;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Round implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE_TORCH;
}
@Override
public String command() {
return "round";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1;
Value v2;
if (command.length == 3) {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
v2 = new Value.LongValue(0);
} else {
v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
}
if (!(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_1", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() < 0) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2", scriptExecutor.getPlayer());
return true;
}
if (v2.asLong() == 0) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(Math.round(v1.asDouble())));
} else {
double pow = Math.pow(10, v2.asLong());
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(Math.round(v1.asDouble() * pow) / pow));
}
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type },
{ TokenType.variable, TokenType.variable, TokenType.number_type },
{ TokenType.variable, TokenType.floating_number_type, TokenType.number_type },
{ TokenType.variable, TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.floating_number_type, TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.io;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
@Linked
public class Echo implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_IO_ECHO_HELP_1",
"",
"SCRIPT_COMMAND_IO_ECHO_HELP_2"
};
}
@Override
public Material material() {
return Material.OAK_SIGN;
}
@Override
public String command() {
return "echo";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getEchoConsumer().accept("");
return true;
}
StringBuilder st = new StringBuilder();
for (int i = 1; i < command.length; i++) {
if (i != 1) {
st.append(" ");
}
st.append(command[i]);
}
scriptExecutor.getEchoConsumer().accept(ChatColor.translateAlternateColorCodes('&', st.toString()));
return true;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.io;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
@Linked
public class Echoactionbar implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_1",
"",
"SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2"
};
}
@Override
public Material material() {
return Material.BIRCH_SIGN;
}
@Override
public String command() {
return "echoactionbar";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
SWUtils.sendToActionbar(scriptExecutor.getPlayer(), "");
return true;
}
StringBuilder st = new StringBuilder();
for (int i = 1; i < command.length; i++) {
if (i != 1) {
st.append(" ");
}
st.append(command[i]);
}
SWUtils.sendToActionbar(scriptExecutor.getPlayer(), ChatColor.translateAlternateColorCodes('&', st.toString()));
return true;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,79 +0,0 @@
package de.steamwar.bausystem.features.script.command.io;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.linkage.Linked;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@Linked
public class Input implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_IO_INPUT_HELP_1",
"",
"SCRIPT_COMMAND_IO_INPUT_HELP_2"
};
}
@Override
public Material material() {
return Material.ANVIL;
}
@Override
public String command() {
return "input";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
StringBuilder st = new StringBuilder();
for (int i = 2; i < command.length; i++) {
if (i != 2) {
st.append(" ");
}
st.append(command[i]);
}
SWAnvilInv swAnvilInv = new SWAnvilInv(scriptExecutor.getPlayer(), ChatColor.translateAlternateColorCodes('&', st.toString()));
swAnvilInv.setCallback(s -> {
try {
long value = Long.parseLong(s);
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(value));
} catch (NumberFormatException e) {
if (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.BooleanValue(s.equalsIgnoreCase("true")));
} else {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.StringValue(s));
}
}
scriptExecutor.resume();
});
swAnvilInv.addCloseCallback(scriptExecutor::resume);
swAnvilInv.open();
return false;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,98 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.string;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Insert implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_STRING_INSERT_HELP_1",
"SCRIPT_COMMAND_STRING_INSERT_HELP_2",
"",
"SCRIPT_COMMAND_STRING_INSERT_HELP_3"
};
}
@Override
public Material material() {
return Material.HOPPER;
}
@Override
public String command() {
return "insert";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 3) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER", scriptExecutor.getPlayer());
return true;
}
String resultName = command[1];
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 3]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v3 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v3 instanceof Value.LongValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(resultName, new Value.StringValue(new StringBuilder(v1.asString()).insert((int) v3.asLong(), v2.asString()).toString()));
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable, TokenType.number_type },
{ TokenType.variable, TokenType.variable, TokenType.variable, TokenType.number_type },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,89 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.string;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Remove implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_STRING_REMOVE_HELP_1",
"SCRIPT_COMMAND_STRING_REMOVE_HELP_2",
"",
"SCRIPT_COMMAND_STRING_REMOVE_HELP_3"
};
}
@Override
public Material material() {
return Material.SHEARS;
}
@Override
public String command() {
return "remove";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
String resultName = command[1];
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(resultName, new Value.StringValue(v1.asString().replace(v2.asString(), "")));
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.variable, TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,98 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.string;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Replace implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_STRING_REPLACE_HELP_1",
"SCRIPT_COMMAND_STRING_REPLACE_HELP_2",
"",
"SCRIPT_COMMAND_STRING_REPLACE_HELP_3"
};
}
@Override
public Material material() {
return Material.WOODEN_AXE;
}
@Override
public String command() {
return "replace";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 3) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
String resultName = command[1];
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 3]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v3 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v3 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(resultName, new Value.StringValue(v1.asString().replace(v2.asString(), v3.asString())));
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.variable, TokenType.variable },
{ TokenType.variable, TokenType.variable, TokenType.variable, TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,99 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.string;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Substring implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_STRING_SUBSTRING_HELP_1",
"SCRIPT_COMMAND_STRING_SUBSTRING_HELP_2",
"",
"SCRIPT_COMMAND_STRING_SUBSTRING_HELP_3"
};
}
@Override
public Material material() {
return Material.STICKY_PISTON;
}
@Override
public String command() {
return "substring";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
String resultName = command[1];
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
Value result;
try {
if (v2.asLong() < 0) {
result = new Value.StringValue(v1.asString().substring(v1.asString().length() - 1 - (int) v2.asLong()));
} else {
result = new Value.StringValue(v1.asString().substring((int) v2.asLong()));
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
result = new Value.StringValue("");
}
scriptExecutor.getLocalVariables().putValue(resultName, result);
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.number_type },
{ TokenType.variable, TokenType.variable, TokenType.number_type },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,87 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Constants;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Const implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_CONST_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_CONST_HELP_2"
};
}
@Override
public Material material() {
return Material.STRUCTURE_BLOCK;
}
@Override
public String command() {
return "const";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
String varName = command[1];
StringBuilder varValue = new StringBuilder();
for (int i = 2; i < command.length; i++) {
if (varValue.length() != 0) {
varValue.append(" ");
}
varValue.append(command[i]);
}
Constants.getConstant(varName, scriptExecutor.getPlayer()).fromValue(Value.parse(varValue.toString()));
return true;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,74 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Convert implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2",
};
}
@Override
public Material material() {
return Material.ENDER_CHEST;
}
@Override
public String command() {
return "convert";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], Value.parse(command[2]));
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,67 +0,0 @@
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Global implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2"
};
}
@Override
public Material material() {
return Material.MAP;
}
@Override
public String command() {
return "global";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
String varName = command[1];
StringBuilder varValue = new StringBuilder();
for (int i = 2; i < command.length; i++) {
if (varValue.length() != 0) {
varValue.append(" ");
}
varValue.append(command[i]);
}
scriptExecutor.getGlobalVariables().putValue(varName, Value.parse(varValue.toString()));
return true;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Unglobal implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2"
};
}
@Override
public Material material() {
return Material.BEACON;
}
@Override
public String command() {
return "unglobal";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getGlobalVariables().removeValue(command[1]);
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Unvar implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2"
};
}
@Override
public Material material() {
return Material.STRUCTURE_VOID;
}
@Override
public String command() {
return "unvar";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().removeValue(command[1]);
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,67 +0,0 @@
package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Var implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_VAR_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_VAR_HELP_2"
};
}
@Override
public Material material() {
return Material.STRUCTURE_BLOCK;
}
@Override
public String command() {
return "var";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
String varName = command[1];
StringBuilder varValue = new StringBuilder();
for (int i = 2; i < command.length; i++) {
if (varValue.length() != 0) {
varValue.append(" ");
}
varValue.append(command[i]);
}
scriptExecutor.getLocalVariables().putValue(varName, Value.parse(varValue.toString()));
return true;
}
@Override
public boolean repeating() {
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.any },
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,89 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@Linked
public class GetMaterial implements SpecialCommand {
private final World world = Bukkit.getWorlds().get(0);
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1",
"",
"SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2"
};
}
@Override
public Material material() {
return Material.STICKY_PISTON;
}
@Override
public String command() {
return "getmaterial";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 3) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 4) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
int x = (int) scriptExecutor.getOrItselfValue(command[2]).asLong();
int y = (int) scriptExecutor.getOrItselfValue(command[3]).asLong();
int z = (int) scriptExecutor.getOrItselfValue(command[4]).asLong();
scriptExecutor.getLocalVariables().putValue(command[1], new Value.StringValue(world.getBlockAt(x, y, z).getType().name()));
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.number_type, TokenType.number_type, TokenType.number_type }
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,92 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.command.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@Linked
public class SetMaterial implements SpecialCommand {
private final World world = Bukkit.getWorlds().get(0);
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_1",
"",
"SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2"
};
}
@Override
public Material material() {
return Material.PISTON;
}
@Override
public String command() {
return "setmaterial";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 3) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 4) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE", scriptExecutor.getPlayer());
return true;
}
int x = (int) scriptExecutor.getOrItselfValue(command[2]).asLong();
int y = (int) scriptExecutor.getOrItselfValue(command[3]).asLong();
int z = (int) scriptExecutor.getOrItselfValue(command[4]).asLong();
try {
world.getBlockAt(x, y, z).setType(Material.valueOf(scriptExecutor.getOrItself(command[1])));
} catch (Exception e) {
// Ignored
}
return true;
}
private TokenType[][] syntax = {
{ TokenType.variable, TokenType.number_type, TokenType.number_type, TokenType.number_type }
};
@Override
public TokenType[][] getSyntax() {
return syntax;
}
}

Datei anzeigen

@ -1,23 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom;
public interface Script {
}

Datei anzeigen

@ -1,87 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom.command;
import de.steamwar.bausystem.features.script.custom.Script;
import de.steamwar.bausystem.features.script.variables.Value;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.HashMap;
import java.util.Map;
public interface CustomCommand extends Script {
String[] command();
default Map<String, Value> check(String[] args, String[] command) {
if (args.length < command.length) {
return null;
}
if (!args[0].equals(command[0])) {
return null;
}
Map<String, Value> arguments = new HashMap<>();
if (!check(arguments, args, command, 0, 0)) {
return null;
}
return arguments;
}
default boolean check(Map<String, Value> arguments, String[] args, String[] command, int argsIndex, int commandIndex) {
if (command.length <= commandIndex) {
for (int i = argsIndex; i < args.length; i++) {
if (!(args[i].startsWith("(") && args[i].endsWith(")"))) {
return false;
}
}
return true;
}
if (args.length <= argsIndex) return true;
String currentArg = args[argsIndex];
String currentCommand = command[commandIndex];
if (currentArg.startsWith("<") && currentArg.endsWith(">")) {
arguments.put(trim(currentArg, 1), new Value.StringValue(currentCommand));
return check(arguments, args, command, argsIndex + 1, commandIndex + 1);
} else if (currentArg.startsWith("(<") && currentArg.endsWith(">)")) {
arguments.put(trim(currentArg, 2), new Value.StringValue(currentCommand));
return check(arguments, args, command, argsIndex + 1, commandIndex + 1);
} else if (currentArg.startsWith("(") && currentArg.endsWith(")")) {
if (!trim(currentArg, 1).equals(currentCommand)) {
arguments.put(trim(currentArg, 1), new Value.BooleanValue(false));
return check(arguments, args, command, argsIndex + 1, commandIndex);
} else {
arguments.put(trim(currentArg, 1), new Value.BooleanValue(true));
return check(arguments, args, command, argsIndex + 1, commandIndex + 1);
}
} else {
if (!currentArg.equals(currentCommand)) return false;
return check(arguments, args, command, argsIndex + 1, commandIndex + 1);
}
}
default String trim(String s, int count) {
return s.substring(count, s.length() - count);
}
boolean execute(String[] command, PlayerCommandPreprocessEvent e);
}

Datei anzeigen

@ -1,51 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom.command;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.variables.Value;
import lombok.RequiredArgsConstructor;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.meta.BookMeta;
import java.util.Map;
@RequiredArgsConstructor
public
class InventoryCommand implements CustomCommand {
public final BookMeta bookMeta;
public final String[] args;
@Override
public String[] command() {
return args;
}
public boolean execute(String[] command, PlayerCommandPreprocessEvent e) {
Map<String, Value> arguments = check(args, command);
if (arguments == null) {
return false;
}
e.setCancelled(true);
new ScriptExecutor(bookMeta, e.getPlayer(), arguments, null);
return true;
}
}

Datei anzeigen

@ -1,99 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.script.custom.command;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.custom.MenuScript;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.inventory.SWItem;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.meta.BookMeta;
import yapion.hierarchy.types.YAPIONArray;
import yapion.hierarchy.types.YAPIONMap;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
public
class MenuCommand implements CustomCommand, MenuScript {
public final List<String> pages;
public final String[] args;
@Override
public String[] command() {
return args;
}
public boolean execute(String[] command, PlayerCommandPreprocessEvent e) {
Map<String, Value> arguments = check(args, command);
if (arguments == null) {
return false;
}
e.setCancelled(true);
new ScriptExecutor(pages, e.getPlayer(), arguments, null);
return true;
}
public boolean equals(MenuCommand menuCommand) {
if (menuCommand.args.length != args.length) {
return false;
}
if (!args[0].equals(menuCommand.args[0])) {
return false;
}
for (int i = 0; i < args.length; i++) {
if (i == 0) continue;
String s1 = args[i];
String s2 = menuCommand.args[i];
if (!s1.equals(s2)) {
return false;
}
if (!(s1.startsWith("<") && s1.endsWith(">") && s2.startsWith("<") && s2.endsWith(">"))) {
return false;
}
if (!(s1.startsWith("(<") && s1.endsWith(">)") && s2.startsWith("(<") && s2.endsWith(">)"))) {
return false;
}
}
return true;
}
@Override
public void save(YAPIONMap yapionMap) {
YAPIONArray yapionArray = new YAPIONArray();
pages.forEach(yapionArray::add);
yapionMap.put(String.join(" ", args), yapionArray);
}
@Override
public SWItem toItem(Player p) {
SWItem swItem = new SWItem(Material.WRITABLE_BOOK, BauSystem.MESSAGE.parse("SCRIPT_COMMAND_ITEM_NAME", p, String.join(" ", args)));
BookMeta bookMeta = (BookMeta) swItem.getItemMeta();
bookMeta.setPages(pages.toArray(new String[0]));
swItem.setItemMeta(bookMeta);
return swItem;
}
}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen