SteamWar/BauSystem2.0
Archiviert
12
0

Merge branch 'master' into use_spigotcore_data
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
YoyoNow 2022-02-01 09:01:53 +01:00
Commit 0ff2713e52
66 geänderte Dateien mit 528 neuen und 884 gelöschten Zeilen

Datei anzeigen

@ -48,9 +48,9 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation project(":BauSystem_API")
implementation project(":BauSystem_Main")
compileOnly files("${projectDir}/../lib/Spigot-1.15.jar")
compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar")
compileOnly files("${projectDir}/../lib/ProtocolLib.jar")
compileOnly files("${projectDir}/../lib/SpigotCore.jar")
}

Datei anzeigen

@ -17,8 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.detonator;
package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
@ -26,13 +27,13 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class DetonatorEntity_15 extends EntityFallingBlock implements AbstractDetonatorEntity {
public class DetonatorEntity15 extends EntityFallingBlock implements AbstractDetonatorEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final Vector position;
private int references = 0;
public DetonatorEntity_15(World world, Vector position) {
public DetonatorEntity15(World world, Vector position) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData());
this.position = position;

Datei anzeigen

@ -17,20 +17,21 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.shared.BaseEntity_15;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.BaseEntity15;
import de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class SimulatorEntity_15 extends BaseEntity_15 implements AbstractSimulatorEntity {
public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity {
private ReferenceCounter referenceCounter = new ReferenceCounter();
public SimulatorEntity_15(World world, Vector position, boolean highlight) {
public SimulatorEntity15(World world, Vector position, boolean highlight) {
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
this.setNoGravity(true);

Datei anzeigen

@ -17,9 +17,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tracer;
package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.shared.BaseEntity_15;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.shared.BaseEntity15;
import de.steamwar.bausystem.shared.ReferenceCounter;
import net.minecraft.server.v1_15_R1.ChatComponentText;
import org.bukkit.Material;
@ -27,12 +28,12 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class TraceEntity_15 extends BaseEntity_15 implements AbstractTraceEntity {
public class TraceEntity15 extends BaseEntity15 implements AbstractTraceEntity {
private boolean exploded = false;
private ReferenceCounter referenceCounter = new ReferenceCounter();
public TraceEntity_15(World world, Vector position, boolean tnt) {
public TraceEntity15(World world, Vector position, boolean tnt) {
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
this.setNoGravity(true);

Datei anzeigen

@ -17,19 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.warp;
package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.shared.BaseArmorStand_15;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.bausystem.shared.BaseArmorStand15;
import net.minecraft.server.v1_15_R1.ChatComponentText;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class WarpEntity_15 extends BaseArmorStand_15 implements AbstractWarpEntity {
public class WarpEntity15 extends BaseArmorStand15 implements AbstractWarpEntity {
private String name;
public WarpEntity_15(World world, Vector position, String name) {
public WarpEntity15(World world, Vector position, String name) {
super(world, position);
setInvisible(true);
setSmall(true);

Datei anzeigen

@ -1,30 +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.detonator;
import org.bukkit.World;
import org.bukkit.util.Vector;
public class Detonator_15 {
static AbstractDetonatorEntity constructEntity(World world, Vector position) {
return new DetonatorEntity_15(world, position);
}
}

Datei anzeigen

@ -1,53 +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.other;
import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.EnumGamemode;
import net.minecraft.server.v1_15_R1.PlayerInteractManager;
import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
@UtilityClass
public class NoClipCommand_15 {
private Field gameModeField;
public void setGameModeInternal(Player player, GameMode gameMode) {
CraftPlayer craftPlayer = (CraftPlayer) player;
EnumGamemode enumGamemode = EnumGamemode.getById(gameMode.getValue());
try {
checkCache();
gameModeField.set(craftPlayer.getHandle().playerInteractManager, enumGamemode);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new SecurityException("Could not find Field?");
}
}
private void checkCache() throws NoSuchFieldException {
if (gameModeField == null) {
gameModeField = PlayerInteractManager.class.getDeclaredField("gamemode");
gameModeField.setAccessible(true);
}
}
}

Datei anzeigen

@ -1,14 +0,0 @@
package de.steamwar.bausystem.features.script;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@UtilityClass
public class ScriptListener_15 {
static boolean isNoBook(ItemStack item) {
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -1,31 +0,0 @@
/*
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/>.
*/
package de.steamwar.bausystem.features.simulator;
import org.bukkit.World;
import org.bukkit.util.Vector;
public class Simulator_15 {
public static AbstractSimulatorEntity create(World world, Vector tntPosition, boolean highlight) {
return new SimulatorEntity_15(world, tntPosition, highlight);
}
}

Datei anzeigen

@ -1,53 +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.slaves;
import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.WorldGenVines;
import org.bukkit.Material;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@UtilityClass
public class MaterialUtils_15 {
private static Set<Material> unpushable = new HashSet<>(Arrays.asList(Material.BARRIER, Material.BEACON, Material.COMMAND_BLOCK, Material.CHAIN_COMMAND_BLOCK, Material.REPEATING_COMMAND_BLOCK, Material.ENCHANTING_TABLE, Material.END_GATEWAY, Material.END_PORTAL, Material.ENDER_CHEST, Material.GRINDSTONE, Material.JIGSAW, Material.JUKEBOX, Material.NETHER_PORTAL, Material.OBSIDIAN, Material.STRUCTURE_VOID, Material.BARREL, Material.BEEHIVE, Material.BEE_NEST, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CHEST, Material.DAYLIGHT_DETECTOR, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.LECTERN, Material.SMOKER, Material.TRAPPED_CHEST));
// TODO: FLOWER
private static Set<Material> breaking = new HashSet<>(Arrays.asList(Material.BAMBOO, Material.CACTUS, Material.CAKE, Material.CARVED_PUMPKIN, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.COBWEB, Material.COCOA, Material.DRAGON_EGG, Material.FIRE, Material.FLOWER_POT, Material.JACK_O_LANTERN, Material.LADDER, Material.LAVA, Material.LAVA, Material.LEVER, Material.LILY_PAD, Material.MELON, Material.NETHER_WART, Material.PUMPKIN, Material.COMPARATOR, Material.REDSTONE_WIRE, Material.REPEATER, Material.TORCH, Material.STRUCTURE_VOID, Material.SCAFFOLDING, Material.SEA_PICKLE, Material.SNOW, Material.SUGAR_CANE, Material.TORCH, Material.TRIPWIRE, Material.TRIPWIRE_HOOK, Material.TURTLE_EGG, Material.VINE, Material.WATER, Material.WHEAT));
static boolean isUnpusheable(Material material) {
if (unpushable.contains(material)) {
return true;
}
String name = material.name();
return name.contains("BANNER") || name.contains("SIGN");
}
static boolean isBreakingOnPush(Material material) {
if (breaking.contains(material)) {
return true;
}
String name = material.name();
return name.contains("BED") || name.contains("BUTTON") || name.contains("CARPET") || (name.contains("DOOR") && !name.contains("TRAPDOOR")) || name.contains("HEAD") || name.contains("LEAVES") || name.contains("MUSHROOM") || name.contains("PRESSURE_PLATE") || name.contains("SHULKER_BOX");
}
}

Datei anzeigen

@ -1,61 +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.tpslimit;
import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.List;
@UtilityClass
public class TPSLimit_15 {
private static List<Packet<?>> packets = new ArrayList<>();
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
static 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.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle();
packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true));
}
});
}
static void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet<?> p : packets) {
connection.sendPacket(p);
}
});
}
}

Datei anzeigen

@ -1,34 +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.tpslimit;
import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.SystemUtils;
import java.util.function.LongSupplier;
@UtilityClass
public class TPSUtils_15 {
public static void init(LongSupplier longSupplier) {
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
}
}

Datei anzeigen

@ -1,59 +0,0 @@
/*
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/>.
*/
package de.steamwar.bausystem.features.tracer;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.util.Vector;
public class TNTTracer_15 {
public static AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity_15(world, tntPosition, tnt);
}
public static boolean inWater(World world, Vector tntPosition) {
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
if (block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if (!(data instanceof Waterlogged))
return false;
return ((Waterlogged) data).isWaterlogged();
}
public static Material getTraceShowMaterial() {
return Material.LIME_CONCRETE;
}
public static Material getTraceHideMaterial() {
return Material.RED_CONCRETE;
}
public static Material getTraceXZMaterial() {
return Material.QUARTZ_SLAB;
}
}

Datei anzeigen

@ -1,21 +0,0 @@
package de.steamwar.bausystem.features.util;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.RegionUtils_15;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class SelectCommand_15 {
static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
static void setSelection(Player p, Point minPoint, Point maxPoint) {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, RegionUtils_15.toBlockVector3(minPoint), RegionUtils_15.toBlockVector3(maxPoint)));
}
}

Datei anzeigen

@ -1,30 +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.warp;
import org.bukkit.World;
import org.bukkit.util.Vector;
public class WarpListener_15 {
public static AbstractWarpEntity create(World world, Vector position, String name) {
return new WarpEntity_15(world, position, name);
}
}

Datei anzeigen

@ -1,67 +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.world;
import net.minecraft.server.v1_15_R1.NBTBase;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagList;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class InventoryListener_15 {
private static final int threshold = 2048;
public static boolean checkItemStack(ItemStack item) {
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.getTag();
if (tag != null && tag.hasKey("BlockEntityTag")) {
NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
if (blockTag.hasKey("Items")) {
return drillDown(blockTag.getList("Items", 10), 0, 0) > threshold;
}
}
return false;
}
private static 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.hasKey("tag")) {
invalid += slot.getByte("Count");
NBTTagCompound iTag = slot.getCompound("tag");
if (iTag.hasKey("BlockEntityTag")) {
NBTTagCompound blockTag = iTag.getCompound("BlockEntityTag");
if (blockTag.hasKey("Items")) {
invalid = drillDown(blockTag.getList("Items", 10), layer + 1, invalid);
}
}
}
if (invalid > threshold)
break;
}
return invalid;
}
}

Datei anzeigen

@ -1,33 +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.world;
import com.sk89q.worldedit.WorldEdit;
public class WorldEditListener_15 {
static boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
}
}

Datei anzeigen

@ -1,31 +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.region;
import com.sk89q.worldedit.math.BlockVector3;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionUtils_15 {
public BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
}

Datei anzeigen

@ -26,13 +26,13 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class BaseArmorStand_15 extends EntityArmorStand implements AbstractEntity {
public class BaseArmorStand15 extends EntityArmorStand implements AbstractEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
protected Vector position;
public BaseArmorStand_15(World world, Vector position) {
public BaseArmorStand15(World world, Vector position) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
this.position = position;

Datei anzeigen

@ -28,14 +28,14 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class BaseEntity_15 extends EntityFallingBlock implements AbstractEntity {
public class BaseEntity15 extends EntityFallingBlock implements AbstractEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final IBlockData iBlockData;
protected Vector position;
public BaseEntity_15(World world, Vector position, Material blockType) {
public BaseEntity15(World world, Vector position, Material blockType) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
this.position = position;

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* 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
@ -17,12 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.region;
package de.steamwar.bausystem.utils;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
@ -36,11 +37,22 @@ 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.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 lombok.experimental.UtilityClass;
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;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import javax.annotation.Nullable;
import java.io.File;
@ -50,8 +62,51 @@ import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
@UtilityClass
public class Region_15 {
public class FlatteningWrapper15 implements FlatteningWrapper.IFlatteningWrapper {
@Override
public boolean isNoBook(ItemStack item) {
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
private static final Set<Material> unpushable = new HashSet<>(Arrays.asList(Material.BARRIER, Material.BEACON, Material.COMMAND_BLOCK, Material.CHAIN_COMMAND_BLOCK, Material.REPEATING_COMMAND_BLOCK, Material.ENCHANTING_TABLE, Material.END_GATEWAY, Material.END_PORTAL, Material.ENDER_CHEST, Material.GRINDSTONE, Material.JIGSAW, Material.JUKEBOX, Material.NETHER_PORTAL, Material.OBSIDIAN, Material.STRUCTURE_VOID, Material.BARREL, Material.BEEHIVE, Material.BEE_NEST, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CHEST, Material.DAYLIGHT_DETECTOR, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.LECTERN, Material.SMOKER, Material.TRAPPED_CHEST));
// TODO: FLOWER
private static final Set<Material> breaking = new HashSet<>(Arrays.asList(Material.BAMBOO, Material.CACTUS, Material.CAKE, Material.CARVED_PUMPKIN, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.COBWEB, Material.COCOA, Material.DRAGON_EGG, Material.FIRE, Material.FLOWER_POT, Material.JACK_O_LANTERN, Material.LADDER, Material.LAVA, Material.LAVA, Material.LEVER, Material.LILY_PAD, Material.MELON, Material.NETHER_WART, Material.PUMPKIN, Material.COMPARATOR, Material.REDSTONE_WIRE, Material.REPEATER, Material.TORCH, Material.STRUCTURE_VOID, Material.SCAFFOLDING, Material.SEA_PICKLE, Material.SNOW, Material.SUGAR_CANE, Material.TORCH, Material.TRIPWIRE, Material.TRIPWIRE_HOOK, Material.TURTLE_EGG, Material.VINE, Material.WATER, Material.WHEAT));
@Override
public boolean isUnpusheable(Material material) {
if (unpushable.contains(material)) {
return true;
}
String name = material.name();
return name.contains("BANNER") || name.contains("SIGN");
}
@Override
public boolean isBreakingOnPush(Material material) {
if (breaking.contains(material)) {
return true;
}
String name = material.name();
return name.contains("BED") || name.contains("BUTTON") || name.contains("CARPET") || (name.contains("DOOR") && !name.contains("TRAPDOOR")) || name.contains("HEAD") || name.contains("LEAVES") || name.contains("MUSHROOM") || name.contains("PRESSURE_PLATE") || name.contains("SHULKER_BOX");
}
@Override
public boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
}
private static final WorldEditPlugin WORLDEDIT_PLUGIN = Objects.requireNonNull((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
private static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
@Override
public void setSelection(Player p, Point minPoint, Point maxPoint) {
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 WOOL2 = Objects.requireNonNull(BlockTypes.YELLOW_WOOL).getDefaultState().toBaseBlock();
@ -67,17 +122,18 @@ public class Region_15 {
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();
private Map<String, Long> timing = new HashMap<>();
private final Map<String, Long> timing = new HashMap<>();
public void start(String name) {
private void start(String name) {
timing.put(name, System.currentTimeMillis());
}
public long stop(String name) {
private long stop(String name) {
return System.currentTimeMillis() - timing.getOrDefault(name, System.currentTimeMillis());
}
EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
@Override
public EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
start("clipboardLoad");
Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
@ -93,7 +149,8 @@ public class Region_15 {
return editSession;
}
EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
@Override
public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
start("changeColor");
if (pasteOptions.getColor() != Color.YELLOW) {
@ -142,9 +199,9 @@ public class Region_15 {
start("reset");
if (pasteOptions.isReset()) {
e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
if (pasteOptions.getWaterLevel() != 0) {
e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
}
}
System.out.println("Reset: " + stop("reset"));
@ -157,7 +214,8 @@ public class Region_15 {
}
}
void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
@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();
@ -205,9 +263,10 @@ public class Region_15 {
}
}
boolean backup(Point minPoint, Point maxPoint, File file) {
@Override
public boolean backup(Point minPoint, Point maxPoint, File file) {
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
CuboidRegion region = new CuboidRegion(bukkitWorld, RegionUtils_15.toBlockVector3(minPoint), RegionUtils_15.toBlockVector3(maxPoint));
CuboidRegion region = new CuboidRegion(bukkitWorld, toBlockVector3(minPoint), toBlockVector3(maxPoint));
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
ForwardExtentCopy copy = new ForwardExtentCopy(
@ -228,4 +287,36 @@ public class Region_15 {
return false;
}
}
}
private BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
@Override
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
if (block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if (!(data instanceof Waterlogged))
return false;
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

@ -0,0 +1,144 @@
/*
* 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 de.steamwar.bausystem.entities.DetonatorEntity15;
import de.steamwar.bausystem.entities.SimulatorEntity15;
import de.steamwar.bausystem.entities.TraceEntity15;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.bausystem.entities.WarpEntity15;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.function.LongSupplier;
public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, "gamemode", EnumGamemode.class);
@Override
@SuppressWarnings("deprecation")
public void setInternalGameMode(Player player, GameMode gameMode) {
playerGameMode.set(((CraftPlayer) player).getHandle().playerInteractManager, EnumGamemode.getById(gameMode.getValue()));
}
@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.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle();
packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true));
}
});
}
@Override
public void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet<?> p : packets) {
connection.sendPacket(p);
}
});
}
private static final int threshold = 2048;
@Override
public boolean checkItemStack(ItemStack item) {
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.getTag();
if (tag != null && tag.hasKey("BlockEntityTag")) {
NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
if (blockTag.hasKey("Items")) {
return drillDown(blockTag.getList("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.hasKey("tag")) {
invalid += slot.getByte("Count");
NBTTagCompound iTag = slot.getCompound("tag");
if (iTag.hasKey("BlockEntityTag")) {
NBTTagCompound blockTag = iTag.getCompound("BlockEntityTag");
if (blockTag.hasKey("Items")) {
invalid = drillDown(blockTag.getList("Items", 10), layer + 1, invalid);
}
}
}
if (invalid > threshold)
break;
}
return invalid;
}
@Override
public AbstractWarpEntity createWarp(World world, Vector position, String name) {
return new WarpEntity15(world, position, name);
}
@Override
public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) {
return new SimulatorEntity15(world, tntPosition, highlight);
}
@Override
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
return new DetonatorEntity15(world, position);
}
@Override
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity15(world, tntPosition, tnt);
}
}

Datei anzeigen

@ -1,52 +0,0 @@
/*
* 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'
compileOnly files("${projectDir}/../lib/Spigot-1.15.jar")
}

Datei anzeigen

@ -1,20 +0,0 @@
/*
* 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/>.
*/
rootProject.name = 'BauSystem_API'

Datei anzeigen

@ -43,9 +43,6 @@ sourceSets {
}
dependencies {
implementation project(":BauSystem_15")
implementation project(":BauSystem_API")
implementation 'yoyosource:YAPION:0.25.3'
// implementation files("${projectDir}/../lib/YAPION-SNAPSHOT.jar")

Datei anzeigen

@ -1077,8 +1077,8 @@ REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört
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 gesetz. §f§lGrund: §f{3}
LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] [§7Grund§8] - §7Sperre eine Schematic
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

Datei anzeigen

@ -23,30 +23,20 @@ import de.steamwar.bausystem.config.BauServer;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
@AllArgsConstructor
@RequiredArgsConstructor
public enum Permission {
WORLD(BauweltMember::isWorld, (player, target) -> {
target.setWorld(!target.isWorld());
sendMessages(player, target.isWorld(), target, "PERMISSION_WORLD");
}),
WORLDEDIT(BauweltMember::isWorldEdit, (player, target) -> {
target.setWorldEdit(!target.isWorldEdit());
sendMessages(player, target.isWorldEdit(), target, "PERMISSION_WORLD_EDIT");
}),
WORLD(BauweltMember::isWorld),
WORLDEDIT(BauweltMember::isWorldEdit),
MEMBER(bauweltMember -> true),
OWNER(bauweltMember -> false);
private final Predicate<BauweltMember> permissionPredicate;
private BiConsumer<Player, BauweltMember> permissionChange = (player, bauweltMember) -> {};
public boolean hasPermission(Player member) {
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
@ -80,12 +70,4 @@ public enum Permission {
BauSystem.MESSAGE.send("PERMISSION_CHANGE_YOU_DISABLE", player, BauSystem.MESSAGE.parse(what, player));
}
}
public void toggle(Player player, BauweltMember target) {
permissionChange.accept(player, target);
}
public static void toggle(Player player, BauweltMember target, Permission permission) {
permission.toggle(player, target);
}
}

Datei anzeigen

@ -20,18 +20,16 @@
package de.steamwar.bausystem.features.bau;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance;
import de.steamwar.command.*;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
import java.util.stream.Collectors;
@Linked(LinkageType.COMMAND)
public class BauCommand extends SWCommand {
@ -50,78 +48,6 @@ public class BauCommand extends SWCommand {
infoCommand.sendBauInfo(p);
}
@Register(value = "togglewe", description = "BAU_COMMAND_HELP_TOGGLEWE")
public void toggleWECommand(@Guard Player p, SteamwarUser user) {
onToggleWE(p, user);
}
@Register(value = "toggleworld", description = "BAU_COMMAND_HELP_TOGGLEWORLD")
public void toggleWorldCommand(@Guard Player p, SteamwarUser user) {
onToggleWorld(p, user);
}
@Register("delmember")
public void delMemberCommand(Player p, SteamwarUser user) {
}
@Register("addmember")
public void addMemberCommand(Player p, String s) {
}
private void onToggleWE(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) {
return;
}
BauweltMember target = BauweltMember.getBauMember(bauServer.getOwnerID(), id.getId());
Permission.WORLDEDIT.toggle(p, target);
}
private void onToggleWorld(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) {
return;
}
BauweltMember target = BauweltMember.getBauMember(bauServer.getOwnerID(), id.getId());
Permission.WORLD.toggle(p, target);
}
private boolean negativeToggleCheck(Player p, SteamwarUser id) {
if (id == null) {
BauSystem.MESSAGE.send("BAU_UNKNOWN_PLAYER", p);
return true;
}
BauweltMember target = BauweltMember.getBauMember(bauServer.getOwnerID(), id.getId());
if (target == null) {
BauSystem.MESSAGE.send("BAU_NO_PLAYER", p);
return true;
}
return false;
}
@ClassMapper(value = SteamwarUser.class, local = true)
private TypeMapper<SteamwarUser> steamwarUserTypeMapper() {
return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(bauServer.getOwnerID())
.stream()
.map(m -> SteamwarUser.get(m.getMemberID()))
.filter(u -> u.getUserName().equals(s))
.findFirst()
.orElse(null),
(c, s) -> {
if (!(c instanceof Player)) {
return null;
}
Player p = (Player) c;
return BauweltMember.getMembers(SteamwarUser.get(p.getUniqueId()).getId())
.stream()
.map(m -> SteamwarUser.get(m.getMemberID()).getUserName())
.collect(Collectors.toList());
});
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker bauGuard() {
return (commandSender, guardCheckType, strings, s) -> {

Datei anzeigen

@ -25,7 +25,7 @@ import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.autostart.AutostartListener;
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.bausystem.utils.NMSWrapper;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -40,7 +40,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.stream.Collectors;
@UtilityClass
public class Detonator {
@ -53,11 +52,8 @@ public class Detonator {
}
public static void showDetonator(Player p, List<Location> locs) {
List<Vector> vecs = locs.stream().map(Location::toVector).collect(Collectors.toList());
List<AbstractDetonatorEntity> entities = new LinkedList<>();
VersionedRunnable.call(new VersionedRunnable(() -> {
vecs.forEach(vector -> entities.add(Detonator_15.constructEntity(p.getWorld(), vector.add(HALF))));
}, 15));
locs.stream().map(Location::toVector).forEach(vector -> entities.add(NMSWrapper.impl.constructDetonator(p.getWorld(), vector.add(HALF))));
entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p));
ENTITIES_MAP.putIfAbsent(p, entities);
}

Datei anzeigen

@ -25,9 +25,9 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.bausystem.utils.ProtocolAPI;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import lombok.Getter;
import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
@ -79,7 +79,7 @@ public class NoClipCommand extends SWCommand implements Listener {
BiFunction<Player, Object, Object> first = (player, o) -> {
if (NOCLIPS.contains(player)) {
if (LAST_TICKS.getOrDefault(player, -1L).equals(TPSUtils.currentTick.get())) return o;
VersionedRunnable.call(new VersionedRunnable(() -> NoClipCommand_15.setGameModeInternal(player, GameMode.SPECTATOR), 15));
NMSWrapper.impl.setInternalGameMode(player, GameMode.SPECTATOR);
LAST_TICKS.put(player, TPSUtils.currentTick.get());
}
return o;
@ -89,7 +89,7 @@ public class NoClipCommand extends SWCommand implements Listener {
BiFunction<Player, Object, Object> second = (player, o) -> {
if (NOCLIPS.contains(player)) {
VersionedRunnable.call(new VersionedRunnable(() -> NoClipCommand_15.setGameModeInternal(player, GameMode.CREATIVE), 15));
NMSWrapper.impl.setInternalGameMode(player, GameMode.CREATIVE);
LAST_TICKS.put(player, TPSUtils.currentTick.get());
}
return o;

Datei anzeigen

@ -27,7 +27,7 @@ import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.UserConfig;
@ -72,7 +72,7 @@ public class CustomScriptListener implements Listener {
return customCommands;
});
for (ItemStack item : p.getInventory().getContents()) {
if (item == null || isNoBook(item) || item.getItemMeta() == null) {
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
continue;
}
@ -173,10 +173,6 @@ public class CustomScriptListener implements Listener {
}
}
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
}
public void openCommandsMenu(Player p) {
List<SWListInv.SWListEntry<CustomScript.MenuScript>> menuCommands = new ArrayList<>();
playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomScript.MenuScript.class::isInstance).map(CustomScript.MenuScript.class::cast).forEach(menuItem -> {
@ -210,7 +206,7 @@ public class CustomScriptListener implements Listener {
if (item.getType().isAir()) {
return;
}
if (isNoBook(item) || item.getItemMeta() == null) {
if (FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return;
}

Datei anzeigen

@ -3,7 +3,7 @@ package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.features.script.variables.Context;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -30,7 +30,7 @@ public class ScriptListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) {
ItemStack item = event.getItem();
if (item == null || isNoBook(item) || item.getItemMeta() == null) {
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return;
}
@ -48,10 +48,6 @@ public class ScriptListener implements Listener {
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
}
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
GLOBAL_CONTEXT.put(event.getPlayer(), new Context());

Datei anzeigen

@ -21,8 +21,8 @@ package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedCallable;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -37,12 +37,8 @@ public class UnsignCommand extends SWCommand {
@Register(description = "UNSIGN_HELP")
public void unsignCommand(Player p) {
ItemStack itemStack = p.getInventory().getItemInMainHand();
if (isNoBook(itemStack)) return;
if (FlatteningWrapper.impl.isNoBook(itemStack)) return;
itemStack.setType(Material.WRITABLE_BOOK);
p.getInventory().setItemInMainHand(itemStack);
}
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
}
}

Datei anzeigen

@ -20,11 +20,10 @@
package de.steamwar.bausystem.features.simulator.show;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.simulator.Simulator_15;
import de.steamwar.bausystem.shared.Position;
import de.steamwar.bausystem.shared.RoundedPosition;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -49,7 +48,7 @@ public class SimulatorEntityShowMode implements ShowMode<Position> {
}
public static AbstractSimulatorEntity createEntity(Player player, Vector position, boolean highlight) {
return VersionedCallable.call(new VersionedCallable<>(() -> Simulator_15.create(player.getWorld(), position, highlight), 15));
return NMSWrapper.impl.createSimulator(player.getWorld(), position, highlight);
}
@Override

Datei anzeigen

@ -1,38 +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.slaves;
import de.steamwar.core.VersionedCallable;
import org.bukkit.Material;
public class MaterialUtils {
public static boolean isUnpusheable(Material material) {
return VersionedCallable.call(
new VersionedCallable<>(() -> MaterialUtils_15.isUnpusheable(material), 15)
);
}
public static boolean isBreakingOnPush(Material material) {
return VersionedCallable.call(
new VersionedCallable<>(() -> MaterialUtils_15.isBreakingOnPush(material), 15)
);
}
}

Datei anzeigen

@ -19,11 +19,11 @@
package de.steamwar.bausystem.features.slaves.panzern.algorithms;
import de.steamwar.bausystem.features.slaves.MaterialUtils;
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -46,10 +46,10 @@ public class PistonLine implements PanzernAlgorithm {
}
BlockData blockData = relativeBlock.getBlockData();
if (!(blockData instanceof Piston)) {
if (MaterialUtils.isUnpusheable(relativeBlock.getType())) {
if (FlatteningWrapper.impl.isUnpusheable(relativeBlock.getType())) {
break;
}
if (MaterialUtils.isBreakingOnPush(relativeBlock.getType())) {
if (FlatteningWrapper.impl.isBreakingOnPush(relativeBlock.getType())) {
break;
}
continue;

Datei anzeigen

@ -23,12 +23,12 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.*;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.entity.Player;
import java.sql.Timestamp;
import java.time.Instant;
@Linked(LinkageType.COMMAND)
public class LockSchemCommand extends SWCommand {
@ -52,7 +52,7 @@ public class LockSchemCommand extends SWCommand {
}
@Register
public void genericCommand(Player p, String owner, String schematicName, String... reason) {
public void genericCommand(Player p, String owner, String schematicName) {
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
@ -79,14 +79,8 @@ public class LockSchemCommand extends SWCommand {
return;
}
StringBuilder builder = new StringBuilder();
for (String s : reason) {
builder.append(s).append(" ");
}
BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), schemOwner.getUserName(), schematic.getSchemtype().name(), builder.toString());
BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), schemOwner.getUserName(), schematic.getSchemtype().name());
schematic.setSchemtype(SchematicType.Normal);
new CheckedSchematic(schematic.getName(), schematic.getOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString());
}
private void sendHelp(Player player) {

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.bausystem.features.tpslimit;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.bausystem.utils.NMSWrapper;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -50,11 +50,11 @@ public class TPSLimitUtils {
tpsLimiter = null;
} else {
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_15.createTickCache(WORLD), 15));
NMSWrapper.impl.createTickCache(WORLD);
for (int i = 0; i < loops; i++) {
sleepUntilNextTick(sleepDelay);
VersionedRunnable.call(new VersionedRunnable(TPSLimit_15::sendTickPackets, 15));
NMSWrapper.impl.sendTickPackets();
}
}, 0, 1);
}

Datei anzeigen

@ -20,9 +20,9 @@
package de.steamwar.bausystem.features.tpslimit;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.core.Core;
import de.steamwar.core.TPSWatcher;
import de.steamwar.core.VersionedRunnable;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
@ -36,10 +36,7 @@ public class TPSWarpUtils {
private static BukkitTask bukkitTask = null;
static void init() {
VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8),
new VersionedRunnable(() -> {
TPSUtils_15.init(() -> nanoOffset);
}, 15));
NMSWrapper.impl.init(() -> nanoOffset);
}
public static void setTPS(double tps) {

Datei anzeigen

@ -20,11 +20,10 @@
package de.steamwar.bausystem.features.tracer.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTTracer_15;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import lombok.experimental.UtilityClass;
@ -61,7 +60,7 @@ public class TraceShowGui {
swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
Material xzMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceXZMaterial, 14));
Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial();
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2", player)), false, clickType -> {
});
swInventory.setItem(7, interpolateXZ);
@ -75,7 +74,7 @@ public class TraceShowGui {
private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) {
Material showMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceShowMaterial, 14));
Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial();
SWItem shown = new SWItem(showMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_SHOWN", player), new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
@ -83,7 +82,7 @@ public class TraceShowGui {
});
swInventory.setItem(1, shown);
} else {
Material hideMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_15::getTraceHideMaterial, 14));
Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial();
SWItem hidden = new SWItem(hideMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_HIDDEN", player), new ArrayList<>(), false, clickType -> {
show(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);

Datei anzeigen

@ -21,11 +21,11 @@ package de.steamwar.bausystem.features.tracer.show.mode;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.TNTTracer_15;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.shared.RoundedPosition;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.entity.Player;
import org.bukkit.util.Consumer;
import org.bukkit.util.Vector;
@ -91,11 +91,11 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
}
private boolean checkWater(Vector position) {
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 15));
return FlatteningWrapper.impl.inWater(player.getWorld(), position);
}
public static AbstractTraceEntity createEntity(Player player, Vector position, boolean tnt) {
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 15));
return NMSWrapper.impl.createTrace(player.getWorld(), position, tnt);
}
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {

Datei anzeigen

@ -8,11 +8,11 @@ import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND)
@ -61,7 +61,7 @@ public class SelectCommand extends SWCommand {
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
VersionedRunnable.call(new VersionedRunnable(() -> SelectCommand_15.setSelection(p, minPoint, maxPoint), 15));
FlatteningWrapper.impl.setSelection(p, minPoint, maxPoint);
BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ());
}
}

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -121,7 +121,7 @@ public class WarpListener implements Listener {
}
public static AbstractWarpEntity createEntity(Player player, Vector position, String name) {
return VersionedCallable.call(new VersionedCallable<>(() -> WarpListener_15.create(player.getWorld(), position, name), 15));
return NMSWrapper.impl.createWarp(player.getWorld(), position, name);
}
@EventHandler

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -58,7 +58,7 @@ public class InventoryListener implements Listener {
}
stack.setItemMeta(meta);
}
if (VersionedCallable.<Boolean>call(new VersionedCallable<Boolean>(() -> InventoryListener_15.checkItemStack(stack), 15))) {
if (NMSWrapper.impl.checkItemStack(stack)) {
e.setCurrentItem(null);
e.setCancelled(true);
return;
@ -74,7 +74,7 @@ public class InventoryListener implements Listener {
for (int i = 0; i < content.length; i++) {
if (content[i] == null) continue;
int finalI = i;
if (VersionedCallable.<Boolean>call(new VersionedCallable<Boolean>(() -> InventoryListener_15.checkItemStack(content[finalI]), 15))) {
if (NMSWrapper.impl.checkItemStack(content[finalI])) {
p.getInventory().setItem(i, null);
}
}
@ -83,7 +83,7 @@ public class InventoryListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Player p = event.getPlayer();
if (VersionedCallable.<Boolean>call(new VersionedCallable<Boolean>(() -> InventoryListener_15.checkItemStack(event.getItemInHand()), 15))) {
if (NMSWrapper.impl.checkItemStack(event.getItemInHand())) {
event.setCancelled(true);
event.setBuild(false);
p.getInventory().setItemInMainHand(null);

Datei anzeigen

@ -23,7 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -50,6 +50,6 @@ public class WorldEditListener implements Listener {
if (command.startsWith(shortcut)) return true;
}
return VersionedCallable.call(new VersionedCallable<>(() -> WorldEditListener_15.isWorldEditCommand(command), 15));
return FlatteningWrapper.impl.isWorldEditCommand(command);
}
}

Datei anzeigen

@ -20,6 +20,8 @@
package de.steamwar.bausystem.linkage;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.utils.NMSWrapper;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
@ -39,6 +41,12 @@ public class LinkageUtils {
private Map<Class<?>, Object> objectMap = new HashMap<>();
private Set<Field> fieldsToLink = new HashSet<>();
{
objectMap.put(BauSystem.class, BauSystem.getInstance());
objectMap.put(FlatteningWrapper.IFlatteningWrapper.class, FlatteningWrapper.impl);
objectMap.put(NMSWrapper.INMSWrapper.class, NMSWrapper.impl);
}
public void link() {
internalLinkOrUnlink(false, Linked.class);
internalLinkFields();

Datei anzeigen

@ -28,7 +28,7 @@ import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.shared.SizedStack;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.sql.SchematicNode;
import lombok.AccessLevel;
import lombok.Getter;
@ -546,12 +546,11 @@ public class Region {
}
final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem");
//noinspection unchecked
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15));
return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile);
}
public static boolean copy(Point minPoint, Point maxPoint, File file) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, file), 15));
return FlatteningWrapper.impl.backup(minPoint, maxPoint, file);
}
public List<String> listBackup() {

Datei anzeigen

@ -24,8 +24,8 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.core.VersionedCallable;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
@ -71,11 +71,11 @@ public class RegionUtils {
}
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
return FlatteningWrapper.impl.paste(file, pastePoint, pasteOptions);
}
static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
return FlatteningWrapper.impl.paste(clipboard, pastePoint, pasteOptions);
}
static void save(Region region) {

Datei anzeigen

@ -0,0 +1,63 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.utils;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.region.PasteOptions;
import de.steamwar.bausystem.region.Point;
import de.steamwar.core.VersionDependent;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.io.File;
public class FlatteningWrapper {
private FlatteningWrapper() {}
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
public interface IFlatteningWrapper {
boolean isNoBook(ItemStack item);
boolean isUnpusheable(Material material);
boolean isBreakingOnPush(Material material);
boolean isWorldEditCommand(String command);
void setSelection(Player p, Point minPoint, Point maxPoint);
EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions);
EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions);
void changeColor(Clipboard clipboard, Color color) throws WorldEditException;
boolean backup(Point minPoint, Point maxPoint, File file);
boolean inWater(World world, Vector tntPosition);
Material getTraceShowMaterial();
Material getTraceHideMaterial();
Material getTraceXZMaterial();
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.utils;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.core.VersionDependent;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.function.LongSupplier;
public class NMSWrapper {
private NMSWrapper() {}
public static final INMSWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
public interface INMSWrapper {
void setInternalGameMode(Player player, GameMode gameMode);
void init(LongSupplier longSupplier);
void createTickCache(World world);
void sendTickPackets();
boolean checkItemStack(ItemStack item);
AbstractWarpEntity createWarp(World world, Vector position, String name);
AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight);
AbstractDetonatorEntity constructDetonator(World world, Vector position);
AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt);
}
}

Datei anzeigen

@ -80,6 +80,7 @@ allprojects {
dependencies {
implementation project(":BauSystem_Main")
implementation project(":BauSystem_15")
}
task buildResources(type: Copy) {

Datei anzeigen

@ -29,18 +29,29 @@
name(Nostalgic WG)
schematic(sections4/custom/Nostalgic WG/WGArena.schem)
testblockSchematic(sections4/custom/Nostalgic WG/WGTestblock.schem)
},
{
name(Darkness)
creator(TheBreadBeard & LordMainex)
schematic(sections4/custom/Darkness/WGArena.schem)
testblockSchematic(sections4/custom/Darkness/WGTestblock.schem)
},
{
name(Nostalgic WG Old)
schematic(sections4/custom/Nostalgic WG Old/WGArena.schem)
testblockSchematic(sections4/custom/Nostalgic WG Old/WGTestblock.schem)
}
]
sizeX(178)
sizeY(119)
sizeY(120)
sizeZ(221)
floorOffset(45)
floorOffset(46)
testblock{
sizeX(67)
sizeY(41)
sizeZ(47)
offsetX(56)
offsetY(45)
offsetY(46)
offsetZ(135)
extensionX(20)
extensionPositiveY(20)
@ -52,7 +63,7 @@
sizeY(41)
sizeZ(47)
offsetX(56)
offsetY(45)
offsetY(46)
offsetZ(38)
extensionX(20)
extensionPositiveY(20)
@ -76,7 +87,7 @@
}
]
sizeX(178)
sizeY(119)
sizeY(120)
sizeZ(221)
floorOffset(45)
testblock{
@ -84,7 +95,7 @@
sizeY(41)
sizeZ(37)
offsetX(56)
offsetY(45)
offsetY(46)
offsetZ(135)
extensionX(20)
extensionPositiveY(20)
@ -96,7 +107,7 @@
sizeY(41)
sizeZ(37)
offsetX(56)
offsetY(45)
offsetY(46)
offsetZ(48)
extensionX(20)
extensionPositiveY(20)
@ -139,10 +150,27 @@
name(Nostalgic MWG)
schematic(sections4/custom/Nostalgic MWG/MWGArena.schem)
testblockSchematic(sections4/custom/Nostalgic MWG/MWGTestblock.schem)
},
{
name(Steam Cliffs)
creator(TheBreadBeard)
schematic(sections4/custom/Steam Cliffs/MWGArena.schem)
testblockSchematic(sections4/custom/Steam Cliffs/MWGTestblock.schem)
},
{
name(Darkness)
creator(TheBreadBeard & LordMainex)
schematic(sections4/custom/Darkness/MWGArena.schem)
testblockSchematic(sections4/custom/Darkness/MWGTestblock.schem)
},
{
name(Nostalgic MWG Old)
schematic(sections4/custom/Nostalgic MWG Old/MWGArena.schem)
testblockSchematic(sections4/custom/Nostalgic MWG Old/MWGTestblock.schem)
}
]
sizeX(107)
sizeY(94)
sizeY(95)
sizeZ(141)
floorOffset(45)
testblock{
@ -150,7 +178,7 @@
sizeY(26)
sizeZ(22)
offsetX(35)
offsetY(45)
offsetY(46)
offsetZ(95)
extensionX(7)
extensionPositiveY(7)
@ -162,7 +190,7 @@
sizeY(26)
sizeZ(22)
offsetX(35)
offsetY(45)
offsetY(46)
offsetZ(23)
extensionX(7)
extensionPositiveY(7)

Datei anzeigen

@ -1,134 +1,134 @@
{
wg11{
minX(-188)
minY(1)
minY(0)
minZ(26)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
wg12{
minX(-188)
minY(1)
minY(0)
minZ(248)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
wg21{
minX(-367)
minY(1)
minY(0)
minZ(26)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
wg22{
minX(-367)
minY(1)
minY(0)
minZ(248)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
wg31{
minX(-546)
minY(1)
minY(0)
minZ(26)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
wg32{
minX(-546)
minY(1)
minY(0)
minZ(248)
prototype(wg)
prototypes[wg, wg35]
prototypes[wg]
}
mwg11{
minX(-119)
minY(1)
minY(0)
minZ(-164)
prototype(mwg)
}
mwg12{
minX(-119)
minY(1)
minY(0)
minZ(-306)
prototype(mwg)
}
mwg13{
minX(-119)
minY(1)
minY(0)
minZ(-448)
prototype(mwg)
}
mwg21{
minX(-225)
minY(1)
minY(0)
minZ(-164)
prototype(mwg)
}
mwg22{
minX(-225)
minY(1)
minY(0)
minZ(-306)
prototype(mwg)
}
mwg23{
minX(-225)
minY(1)
minY(0)
minZ(-448)
prototype(mwg)
}
mwg31{
minX(-331)
minY(1)
minY(0)
minZ(-164)
prototype(mwg)
}
mwg32{
minX(-331)
minY(1)
minY(0)
minZ(-306)
prototype(mwg)
}
mwg33{
minX(-331)
minY(1)
minY(0)
minZ(-448)
prototype(mwg)
}
mwg41{
minX(-437)
minY(1)
minY(0)
minZ(-164)
prototype(mwg)
}
mwg42{
minX(-437)
minY(1)
minY(0)
minZ(-306)
prototype(mwg)
}
mwg43{
minX(-437)
minY(1)
minY(0)
minZ(-448)
prototype(mwg)
}
mwg51{
minX(-543)
minY(1)
minY(0)
minZ(-164)
prototype(mwg)
}
mwg52{
minX(-543)
minY(1)
minY(0)
minZ(-306)
prototype(mwg)
}
mwg53{
minX(-543)
minY(1)
minY(0)
minZ(-448)
prototype(mwg)
}