SteamWar/BauSystem2.0
Archiviert
12
0

Refactoring #64

Zusammengeführt
YoyoNow hat 8 Commits von refactoring nach master 2022-02-01 09:00:53 +01:00 zusammengeführt
48 geänderte Dateien mit 457 neuen und 763 gelöschten Zeilen
Nur Änderungen aus Commit fbf2789918 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -53,4 +53,5 @@ dependencies {
compileOnly files("${projectDir}/../lib/Spigot-1.15.jar") compileOnly files("${projectDir}/../lib/Spigot-1.15.jar")
compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar")
compileOnly files("${projectDir}/../lib/ProtocolLib.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/>. * 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 net.minecraft.server.v1_15_R1.*;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; 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.entity.Player;
import org.bukkit.util.Vector; 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 static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final Vector position; private final Vector position;
private int references = 0; 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()); super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData());
this.position = position; this.position = position;

Datei anzeigen

@ -17,20 +17,21 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. 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 de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; 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(); 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); super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
this.setNoGravity(true); this.setNoGravity(true);

Datei anzeigen

@ -17,9 +17,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. 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 de.steamwar.bausystem.shared.ReferenceCounter;
import net.minecraft.server.v1_15_R1.ChatComponentText; import net.minecraft.server.v1_15_R1.ChatComponentText;
import org.bukkit.Material; import org.bukkit.Material;
@ -27,12 +28,12 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; 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 boolean exploded = false;
private ReferenceCounter referenceCounter = new ReferenceCounter(); 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); super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
this.setNoGravity(true); this.setNoGravity(true);

Datei anzeigen

@ -17,19 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 net.minecraft.server.v1_15_R1.ChatComponentText;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class WarpEntity_15 extends BaseArmorStand_15 implements AbstractWarpEntity { public class WarpEntity15 extends BaseArmorStand15 implements AbstractWarpEntity {
private String name; private String name;
public WarpEntity_15(World world, Vector position, String name) { public WarpEntity15(World world, Vector position, String name) {
super(world, position); super(world, position);
setInvisible(true); setInvisible(true);
setSmall(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.entity.Player;
import org.bukkit.util.Vector; 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); private static final Vec3D ZERO = new Vec3D(0, 0, 0);
protected Vector position; 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()); super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
this.position = position; 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.entity.Player;
import org.bukkit.util.Vector; 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 static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final IBlockData iBlockData; private final IBlockData iBlockData;
protected Vector position; 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()); super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState(); this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
this.position = position; this.position = position;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * 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 * 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 * 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/>. * 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.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld; 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.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; 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.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; 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.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 javax.annotation.Nullable;
import java.io.File; import java.io.File;
@ -50,8 +62,51 @@ import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@UtilityClass public class FlatteningWrapper15 implements FlatteningWrapper.IFlatteningWrapper {
public class Region_15 {
@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 WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
private static final BaseBlock WOOL2 = Objects.requireNonNull(BlockTypes.YELLOW_WOOL).getDefaultState().toBaseBlock(); private static final BaseBlock WOOL2 = Objects.requireNonNull(BlockTypes.YELLOW_WOOL).getDefaultState().toBaseBlock();
@ -67,17 +122,20 @@ public class Region_15 {
private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).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(); 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<>();
@Override
public void start(String name) { public void start(String name) {
timing.put(name, System.currentTimeMillis()); timing.put(name, System.currentTimeMillis());
} }
@Override
public long stop(String name) { public long stop(String name) {
return System.currentTimeMillis() - timing.getOrDefault(name, System.currentTimeMillis()); 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"); start("clipboardLoad");
Clipboard clipboard; Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
@ -93,7 +151,8 @@ public class Region_15 {
return editSession; 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)) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
start("changeColor"); start("changeColor");
if (pasteOptions.getColor() != Color.YELLOW) { if (pasteOptions.getColor() != Color.YELLOW) {
@ -142,9 +201,9 @@ public class Region_15 {
start("reset"); start("reset");
if (pasteOptions.isReset()) { 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) { 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")); System.out.println("Reset: " + stop("reset"));
@ -157,7 +216,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(); BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock(); 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 clay = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
@ -205,9 +265,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)); 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); BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
ForwardExtentCopy copy = new ForwardExtentCopy( ForwardExtentCopy copy = new ForwardExtentCopy(
@ -228,4 +289,36 @@ public class Region_15 {
return false; 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

@ -23,30 +23,20 @@ import de.steamwar.bausystem.config.BauServer;
import de.steamwar.sql.BauweltMember; import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.function.BiConsumer;
import java.util.function.Predicate; import java.util.function.Predicate;
@AllArgsConstructor @AllArgsConstructor
@RequiredArgsConstructor
public enum Permission { public enum Permission {
WORLD(BauweltMember::isWorld, (player, target) -> { WORLD(BauweltMember::isWorld),
target.setWorld(!target.isWorld()); WORLDEDIT(BauweltMember::isWorldEdit),
sendMessages(player, target.isWorld(), target, "PERMISSION_WORLD");
}),
WORLDEDIT(BauweltMember::isWorldEdit, (player, target) -> {
target.setWorldEdit(!target.isWorldEdit());
sendMessages(player, target.isWorldEdit(), target, "PERMISSION_WORLD_EDIT");
}),
MEMBER(bauweltMember -> true), MEMBER(bauweltMember -> true),
OWNER(bauweltMember -> false); OWNER(bauweltMember -> false);
private final Predicate<BauweltMember> permissionPredicate; private final Predicate<BauweltMember> permissionPredicate;
private BiConsumer<Player, BauweltMember> permissionChange = (player, bauweltMember) -> {};
public boolean hasPermission(Player member) { public boolean hasPermission(Player member) {
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) { 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)); 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

@ -54,7 +54,7 @@ public class BackupCommand extends SWCommand {
return false; return false;
} }
@Register(value = "create", description = "BACKUP_HELP_CREATE") @Register(value = "createWarp", description = "BACKUP_HELP_CREATE")
public void backupCreate(@Guard Player p) { public void backupCreate(@Guard Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {

Datei anzeigen

@ -20,18 +20,16 @@
package de.steamwar.bausystem.features.bau; package de.steamwar.bausystem.features.bau;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.LinkedInstance;
import de.steamwar.command.*; import de.steamwar.command.GuardCheckType;
import de.steamwar.sql.BauweltMember; import de.steamwar.command.GuardChecker;
import de.steamwar.sql.SteamwarUser; import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.stream.Collectors;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
public class BauCommand extends SWCommand { public class BauCommand extends SWCommand {
@ -50,78 +48,6 @@ public class BauCommand extends SWCommand {
infoCommand.sendBauInfo(p); 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) @ClassGuard(value = Player.class, local = true)
public GuardChecker bauGuard() { public GuardChecker bauGuard() {
return (commandSender, guardCheckType, strings, s) -> { 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.autostart.AutostartListener;
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
import de.steamwar.bausystem.features.detonator.storage.ItemStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
import de.steamwar.core.VersionedRunnable; import de.steamwar.bausystem.utils.NMSWrapper;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -40,7 +40,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@UtilityClass @UtilityClass
public class Detonator { public class Detonator {
@ -53,11 +52,8 @@ public class Detonator {
} }
public static void showDetonator(Player p, List<Location> locs) { 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<>(); List<AbstractDetonatorEntity> entities = new LinkedList<>();
VersionedRunnable.call(new VersionedRunnable(() -> { locs.stream().map(Location::toVector).forEach(vector -> entities.add(NMSWrapper.impl.constructDetonator(p.getWorld(), vector.add(HALF))));
vecs.forEach(vector -> entities.add(Detonator_15.constructEntity(p.getWorld(), vector.add(HALF))));
}, 15));
entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p)); entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p));
ENTITIES_MAP.putIfAbsent(p, entities); 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.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.bausystem.utils.ProtocolAPI; import de.steamwar.bausystem.utils.ProtocolAPI;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import lombok.Getter; import lombok.Getter;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; 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) -> { BiFunction<Player, Object, Object> first = (player, o) -> {
if (NOCLIPS.contains(player)) { if (NOCLIPS.contains(player)) {
if (LAST_TICKS.getOrDefault(player, -1L).equals(TPSUtils.currentTick.get())) return o; 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()); LAST_TICKS.put(player, TPSUtils.currentTick.get());
} }
return o; return o;
@ -89,7 +89,7 @@ public class NoClipCommand extends SWCommand implements Listener {
BiFunction<Player, Object, Object> second = (player, o) -> { BiFunction<Player, Object, Object> second = (player, o) -> {
if (NOCLIPS.contains(player)) { 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()); LAST_TICKS.put(player, TPSUtils.currentTick.get());
} }
return o; 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.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; 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.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.UserConfig; import de.steamwar.sql.UserConfig;
@ -72,7 +72,7 @@ public class CustomScriptListener implements Listener {
return customCommands; return customCommands;
}); });
for (ItemStack item : p.getInventory().getContents()) { 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; 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) { public void openCommandsMenu(Player p) {
List<SWListInv.SWListEntry<CustomScript.MenuScript>> menuCommands = new ArrayList<>(); 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 -> { 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()) { if (item.getType().isAir()) {
return; return;
} }
if (isNoBook(item) || item.getItemMeta() == null) { if (FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return; 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.features.script.variables.Context;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; 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.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -30,7 +30,7 @@ public class ScriptListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) { public void onLeftClick(PlayerInteractEvent event) {
ItemStack item = event.getItem(); ItemStack item = event.getItem();
if (item == null || isNoBook(item) || item.getItemMeta() == null) { if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return; return;
} }
@ -48,10 +48,6 @@ public class ScriptListener implements Listener {
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer()); new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
} }
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
}
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
GLOBAL_CONTEXT.put(event.getPlayer(), new Context()); 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.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedCallable;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -37,12 +37,8 @@ public class UnsignCommand extends SWCommand {
@Register(description = "UNSIGN_HELP") @Register(description = "UNSIGN_HELP")
public void unsignCommand(Player p) { public void unsignCommand(Player p) {
ItemStack itemStack = p.getInventory().getItemInMainHand(); ItemStack itemStack = p.getInventory().getItemInMainHand();
if (isNoBook(itemStack)) return; if (FlatteningWrapper.impl.isNoBook(itemStack)) return;
itemStack.setType(Material.WRITABLE_BOOK); itemStack.setType(Material.WRITABLE_BOOK);
p.getInventory().setItemInMainHand(itemStack); 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; package de.steamwar.bausystem.features.simulator.show;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; 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.Position;
import de.steamwar.bausystem.shared.RoundedPosition; import de.steamwar.bausystem.shared.RoundedPosition;
import de.steamwar.bausystem.shared.ShowMode; 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.entity.Player;
import org.bukkit.util.Vector; 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) { 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 @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; 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.PanzernAlgorithm;
import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -46,10 +46,10 @@ public class PistonLine implements PanzernAlgorithm {
} }
BlockData blockData = relativeBlock.getBlockData(); BlockData blockData = relativeBlock.getBlockData();
if (!(blockData instanceof Piston)) { if (!(blockData instanceof Piston)) {
if (MaterialUtils.isUnpusheable(relativeBlock.getType())) { if (FlatteningWrapper.impl.isUnpusheable(relativeBlock.getType())) {
break; break;
} }
if (MaterialUtils.isBreakingOnPush(relativeBlock.getType())) { if (FlatteningWrapper.impl.isBreakingOnPush(relativeBlock.getType())) {
break; break;
} }
continue; continue;

Datei anzeigen

@ -23,12 +23,12 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand; 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 org.bukkit.entity.Player;
import java.sql.Timestamp;
import java.time.Instant;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
public class LockSchemCommand extends SWCommand { public class LockSchemCommand extends SWCommand {
@ -86,7 +86,8 @@ public class LockSchemCommand extends SWCommand {
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(), builder.toString());
schematic.setSchemtype(SchematicType.Normal); schematic.setSchemtype(SchematicType.Normal);
new CheckedSchematic(schematic.getName(), schematic.getOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString()); //TODO: Tansfer command to bungee
//new CheckedSchematic(schematic.getId(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString());
} }
private void sendHelp(Player player) { private void sendHelp(Player player) {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -20,11 +20,10 @@
package de.steamwar.bausystem.features.tracer.gui; package de.steamwar.bausystem.features.tracer.gui;
import de.steamwar.bausystem.BauSystem; 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.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; 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.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -61,7 +60,7 @@ public class TraceShowGui {
swInventory.setItem(6, interpolateY); swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, 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 -> { 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); swInventory.setItem(7, interpolateXZ);
@ -75,7 +74,7 @@ public class TraceShowGui {
private static void setActiveShow(Player player, SWInventory swInventory) { private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) { 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 -> { SWItem shown = new SWItem(showMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_SHOWN", player), new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player); TraceShowManager.hide(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
@ -83,7 +82,7 @@ public class TraceShowGui {
}); });
swInventory.setItem(1, shown); swInventory.setItem(1, shown);
} else { } 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 -> { SWItem hidden = new SWItem(hideMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_HIDDEN", player), new ArrayList<>(), false, clickType -> {
show(player); show(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_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.AbstractTraceEntity;
import de.steamwar.bausystem.features.tracer.TNTPosition; 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.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.shared.RoundedPosition; import de.steamwar.bausystem.shared.RoundedPosition;
import de.steamwar.bausystem.shared.ShowMode; 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.entity.Player;
import org.bukkit.util.Consumer; import org.bukkit.util.Consumer;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -91,11 +91,11 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
} }
private boolean checkWater(Vector position) { 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) { 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) { 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.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.command.GuardCheckType; import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker; import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult; import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
@ -61,7 +61,7 @@ public class SelectCommand extends SWCommand {
Point minPoint = region.getMinPoint(regionType, regionExtensionType); Point minPoint = region.getMinPoint(regionType, regionExtensionType);
Point maxPoint = region.getMaxPoint(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()); BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ());
} }
} }

Datei anzeigen

@ -44,7 +44,7 @@ import java.util.ArrayList;
public class WarpCommand extends SWCommand implements Disable, Enable { public class WarpCommand extends SWCommand implements Disable, Enable {
private static final String[] FORBIDDEN_NAMES = new String[]{ private static final String[] FORBIDDEN_NAMES = new String[]{
"add", "create", "delete", "list", "info", "gui" "add", "createWarp", "delete", "list", "info", "gui"
}; };
protected WarpCommand() { protected WarpCommand() {
@ -62,7 +62,7 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
} }
@Register(value = "add", description = "WARP_HELP_ADD") @Register(value = "add", description = "WARP_HELP_ADD")
@Register("create") @Register("createWarp")
Lixfel markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Finde ich nicht sinnvoll! Warum hier umbennen, aber bei remove nicht, also nein!

Finde ich nicht sinnvoll! Warum hier umbennen, aber bei remove nicht, also nein!
Veraltet
Review

sr, scheint bei einem refactoring-Schritt von IntelliJ miterwischt worden zu sein. War nicht geplant.

sr, scheint bei einem refactoring-Schritt von IntelliJ miterwischt worden zu sein. War nicht geplant.
Veraltet
Review

Krieg ich dafür noch ein commit?

Krieg ich dafür noch ein commit?
public void addWarp(@Guard Player player, String name) { public void addWarp(@Guard Player player, String name) {
for (String forbiddenName : FORBIDDEN_NAMES) { for (String forbiddenName : FORBIDDEN_NAMES) {
if (name.equalsIgnoreCase(forbiddenName)) { if (name.equalsIgnoreCase(forbiddenName)) {

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.VersionedCallable; import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -121,7 +121,7 @@ public class WarpListener implements Listener {
} }
public static AbstractWarpEntity createEntity(Player player, Vector position, String name) { 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 @EventHandler

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -29,7 +29,7 @@ public interface ScoreboardItem {
* If return value contains {@code '?'} it will be replaced to the color * If return value contains {@code '?'} it will be replaced to the color
* code of the current {@link Region}. * code of the current {@link Region}.
* *
* @param player the player to create the scoreboard line for * @param player the player to createWarp the scoreboard line for
Lixfel markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Nichts da!

Nichts da!
* @param region the region the player is in * @param region the region the player is in
* @return the String to send, can be {@code null} * @return the String to send, can be {@code null}
*/ */

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.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.shared.SizedStack; import de.steamwar.bausystem.shared.SizedStack;
import de.steamwar.core.VersionedCallable; import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
@ -546,12 +546,11 @@ public class Region {
} }
final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem");
//noinspection unchecked return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile);
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15));
} }
public static boolean copy(Point minPoint, Point maxPoint, File file) { 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() { 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.BauSystem;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.core.VersionedCallable;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -71,11 +71,11 @@ public class RegionUtils {
} }
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { 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) { 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) { static void save(Region region) {

Datei anzeigen

@ -0,0 +1,65 @@
/*
* 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);
void start(String name);
long stop(String name);
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);
}
}