SteamWar/BauSystem
Archiviert
13
0

Removing usage of all deprecated SpigotCore-APIs

Dieser Commit ist enthalten in:
Lixfel 2021-10-26 18:42:45 +02:00
Ursprung 06f82e4a2f
Commit 21f5f22bf0
57 geänderte Dateien mit 652 neuen und 1341 gelöschten Zeilen

Datei anzeigen

@ -48,7 +48,7 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.6'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.6'
implementation project(":BauSystem_API")
implementation project(":BauSystem_Main")
compileOnly files("${project.rootDir}/lib/Spigot-1.12.jar")
compileOnly files("${project.rootDir}/lib/WorldEdit-1.12.jar")

Datei anzeigen

@ -0,0 +1,80 @@
/*
* 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;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.world.TPSUtils;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
private final List<Packet<?>> packets = new ArrayList<>();
@Override
public void initTPS() {
TPSUtils.disableWarp();
}
@Override
public void createTickCache(World world) {
packets.clear();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0));
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
if (entity instanceof TNTPrimed) {
net.minecraft.server.v1_12_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);
}
});
}
@Override
public void openSignEditor(Player player, Location location) {
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
@Override
public AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity12(world, tntPosition, tnt);
}
}

Datei anzeigen

@ -1,42 +1,45 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
/*
* 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/>.
*/
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.world;
package de.steamwar.bausystem;
import de.steamwar.bausystem.world.Detoloader;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.stream.Collectors;
public class FlatteningWrapper12 implements FlatteningWrapper.IFlatteningWrapper {
class AutoLoader_12 {
private AutoLoader_12() {
}
static boolean tntPlaceActionPerform(Location location) {
@Override
public boolean tntPlaceActionPerform(Location location) {
Material m = location.getBlock().getType();
if (m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER)
return false;
@ -45,8 +48,9 @@ class AutoLoader_12 {
return true;
}
@Override
@SuppressWarnings("deprecation")
static boolean setRedstone(Location location, boolean active) {
public boolean setRedstone(Location location, boolean active) {
Block block = location.getBlock();
Material material = block.getType();
if (material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON) {
@ -67,7 +71,7 @@ class AutoLoader_12 {
armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ());
} else {
List<Entity> entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity ->
entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()))
entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()))
.limit(1)
.collect(Collectors.toList());
if (entityList.isEmpty()) return false;
@ -80,8 +84,9 @@ class AutoLoader_12 {
return true;
}
@Override
@SuppressWarnings("deprecation")
static Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
public Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Material material = block.getType();
if (material == Material.LEVER) {
@ -104,7 +109,40 @@ class AutoLoader_12 {
return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false);
}
static boolean getLever(Block block) {
@Override
@SuppressWarnings("deprecation")
public boolean getLever(Block block) {
return (block.getData() & 8) == 8;
}
@Override
public boolean isNoBook(ItemStack item) {
return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK;
}
@Override
public boolean inWater(World world, Vector tntPosition) {
Material material = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()).getType();
return material == Material.WATER || material == Material.STATIONARY_WATER;
}
@Override
public Material getTraceShowMaterial() {
return Material.CONCRETE;
}
@Override
public Material getTraceHideMaterial() {
return Material.CONCRETE;
}
@Override
public Material getTraceXZMaterial() {
return Material.STEP;
}
@Override
public void giveStick(Player player) {
player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12.");
}
}

Datei anzeigen

@ -1,24 +1,25 @@
/*
This file is a part of the SteamWar software.
* 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/>.
*/
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.tracer;
package de.steamwar.bausystem;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
@ -26,12 +27,12 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
class TraceEntity12 extends EntityFallingBlock implements AbstractTraceEntity {
private boolean exploded;
private int references;
public TraceEntity_12(World world, Vector position, boolean tnt) {
public TraceEntity12(World world, Vector position, boolean tnt) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData());
this.setNoGravity(true);

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
* 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
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world.regions;
package de.steamwar.bausystem;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -26,25 +26,37 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.operation.Operations;
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 de.steamwar.bausystem.world.regions.PasteOptions;
import de.steamwar.bausystem.world.regions.Point;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
class Region_12 {
private Region_12() {
public class WorldeditWrapper12 implements WorldeditWrapper.IWorldeditWrapper {
private final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
private 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, toVector(minPoint), toVector(maxPoint)));
}
static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) throws MaxChangedBlocksException {
@Override
public EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Clipboard clipboard;
try {
@ -56,7 +68,8 @@ class Region_12 {
return paste(clipboard, x, y, z, pasteOptions);
}
static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) throws MaxChangedBlocksException {
@Override
public EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions();
@ -75,9 +88,27 @@ class Region_12 {
ch.setTransform(aT);
if (pasteOptions.isReset()) {
e.setBlocks(new CuboidRegion(RegionUtils_12.toVector(pasteOptions.getMinPoint()), RegionUtils_12.toVector(pasteOptions.getMaxPoint())), new BaseBlock(BlockID.AIR));
try {
e.setBlocks(new CuboidRegion(toVector(pasteOptions.getMinPoint()), toVector(pasteOptions.getMaxPoint())), new BaseBlock(BlockID.AIR));
} catch (MaxChangedBlocksException ex) {
throw new SecurityException("Max blocks changed?", ex);
}
}
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
return e;
}
@Override
public boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
.getCommandManager().getDispatcher().get(command) != null;
}
private Vector toVector(Point point) {
return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ());
}
}

Datei anzeigen

@ -1,40 +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.commands;
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.world.regions.Point;
import de.steamwar.bausystem.world.regions.RegionUtils_12;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
class CommandSelect_12 {
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_12.toVector(minPoint), RegionUtils_12.toVector(maxPoint)));
}
}

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.commands;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.List;
class TPSLimit_12 {
private static List<Packet<?>> packets = new ArrayList<>();
static void createTickCache(World world) {
packets.clear();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0));
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
if (entity instanceof TNTPrimed) {
net.minecraft.server.v1_12_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,49 +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.tracer;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.util.Vector;
public class TNTTracer_12 {
public static AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity_12(world, tntPosition, tnt);
}
public static boolean inWater(World world, Vector tntPosition) {
Material material = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()).getType();
return material == Material.WATER || material == Material.STATIONARY_WATER;
}
public static Material getTraceShowMaterial() {
return Material.CONCRETE;
}
public static Material getTraceHideMaterial() {
return Material.CONCRETE;
}
public static Material getTraceXZMaterial() {
return Material.STEP;
}
}

Datei anzeigen

@ -1,47 +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.world;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenSignEditor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
class RegionListener_12 {
private RegionListener_12() {
}
static boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
.getCommandManager().getDispatcher().get(command) != null;
}
static void openSignEditor(Player player, Location location) {
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

Datei anzeigen

@ -1,32 +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.world;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_12 {
private ScriptListener_12() {
}
static boolean isNoBook(ItemStack item) {
return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -1,32 +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.world.regions;
import com.sk89q.worldedit.Vector;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionUtils_12 {
public Vector toVector(Point point) {
return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ());
}
}

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,91 @@
/*
* 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;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.world.TPSUtils;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
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 org.bukkit.util.Vector;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
private final List<Packet<?>> packets = new ArrayList<>();
@Override
public void initTPS() {
SystemUtils.a = () -> System.nanoTime() + TPSUtils.getNanoOffset();
}
@Override
public void createTickCache(World world) {
packets.clear();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), Vec3D.a));
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);
}
});
}
@Override
public void openSignEditor(Player player, Location location) {
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
signOpen.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, signOpen);
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
}
}
@Override
public AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity15(world, tntPosition, tnt);
}
}

Datei anzeigen

@ -1,40 +1,44 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
/*
* 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/>.
*/
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.world;
package de.steamwar.bausystem;
import de.steamwar.bausystem.world.Detoloader;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
class AutoLoader_15 {
public class FlatteningWrapper15 implements FlatteningWrapper.IFlatteningWrapper {
private AutoLoader_15() {
}
static boolean tntPlaceActionPerform(Location location) {
@Override
public boolean tntPlaceActionPerform(Location location) {
Material m = location.getBlock().getType();
if (m != Material.AIR && m != Material.WATER)
return false;
@ -43,7 +47,8 @@ class AutoLoader_15 {
return true;
}
static boolean setRedstone(Location location, boolean active) {
@Override
public boolean setRedstone(Location location, boolean active) {
Block block = location.getBlock();
BlockData data = block.getBlockData();
if (!(data instanceof Powerable))
@ -81,14 +86,14 @@ class AutoLoader_15 {
return true;
}
static void updateBlock(Block block) {
private void updateBlock(Block block) {
BlockData data = block.getBlockData();
block.setType(Material.BARRIER, true);
block.setBlockData(data, true);
}
static Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
@Override
public Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
assert block != null;
BlockData data = block.getBlockData();
@ -114,9 +119,48 @@ class AutoLoader_15 {
}
}
static boolean getLever(Block block) {
@Override
public boolean getLever(Block block) {
if (!(block.getBlockData() instanceof Powerable))
return false;
return ((Powerable) block.getBlockData()).isPowered();
}
@Override
public boolean isNoBook(ItemStack item) {
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
@Override
public 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();
}
@Override
public Material getTraceShowMaterial() {
return Material.LIME_CONCRETE;
}
@Override
public Material getTraceHideMaterial() {
return Material.RED_CONCRETE;
}
@Override
public Material getTraceXZMaterial() {
return Material.QUARTZ_SLAB;
}
@Override
public void giveStick(Player player) {
SWUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
}
}

Datei anzeigen

@ -1,24 +1,25 @@
/*
This file is a part of the SteamWar software.
* 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/>.
*/
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.tracer;
package de.steamwar.bausystem;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
@ -26,7 +27,7 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
class TraceEntity15 extends EntityFallingBlock implements AbstractTraceEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final Vector position;
@ -35,7 +36,7 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
private boolean exploded = false;
private int references = 0;
public TraceEntity_15(World world, Vector position, boolean tnt) {
public TraceEntity15(World world, Vector position, boolean tnt) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.WHITE_STAINED_GLASS.getBlockData());
this.position = position;
this.tnt = tnt;

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
* 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
@ -17,12 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world.regions;
package de.steamwar.bausystem;
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.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
@ -30,24 +31,35 @@ 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.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.regions.PasteOptions;
import de.steamwar.bausystem.world.regions.Point;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
class Region_15 {
public class WorldeditWrapper15 implements WorldeditWrapper.IWorldeditWrapper {
private Region_15() {
private final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
private 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)));
}
static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) {
@Override
public EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) {
Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read();
@ -58,7 +70,8 @@ class Region_15 {
return paste(clipboard, x, y, z, pasteOptions);
}
static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
@Override
public EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
changeColor(clipboard, pasteOptions.getColor());
@ -74,9 +87,9 @@ class Region_15 {
}
if (pasteOptions.isReset()) {
e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), BlockTypes.AIR.getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint())), 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())), BlockTypes.WATER.getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(toBlockVector3(pasteOptions.getMinPoint()), toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), BlockTypes.WATER.getDefaultState().toBaseBlock());
}
}
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
@ -86,7 +99,20 @@ class Region_15 {
}
}
static void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
@Override
public boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
}
private BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
private void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
@ -102,7 +128,7 @@ class Region_15 {
}
}
private static BlockType mapColor(BlockType original, Color color) {
private BlockType mapColor(BlockType original, Color color) {
switch (color) {
case WHITE:
if (original == BlockTypes.YELLOW_CONCRETE) {

Datei anzeigen

@ -1,34 +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.commands;
import de.steamwar.bausystem.SWUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
class CommandDebugStick_15 {
private CommandDebugStick_15() {
}
static void giveStick(Player player){
SWUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
}
}

Datei anzeigen

@ -1,40 +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.commands;
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.world.regions.Point;
import de.steamwar.bausystem.world.regions.RegionUtils_15;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
class CommandSelect_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,60 +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.commands;
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;
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,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.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,55 +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.world;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.sk89q.worldedit.WorldEdit;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
class RegionListener_15 {
private RegionListener_15() {
}
static boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
}
static void openSignEditor(Player player, Location location) {
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
signOpen.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, signOpen);
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
}
}
}

Datei anzeigen

@ -1,32 +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.world;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_15 {
private ScriptListener_15() {
}
static boolean isNoBook(ItemStack item) {
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,32 +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.world.regions;
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

@ -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.6'
testCompileOnly 'org.projectlombok:lombok:1.18.6'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.6'
compileOnly files("${project.rootDir}/lib/Spigot-1.12.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,10 +43,6 @@ sourceSets {
}
dependencies {
implementation project(":BauSystem_12")
implementation project(":BauSystem_15")
implementation project(":BauSystem_API")
compileOnly 'org.projectlombok:lombok:1.18.6'
testCompileOnly 'org.projectlombok:lombok:1.18.6'
annotationProcessor 'org.projectlombok:lombok:1.18.6'

Datei anzeigen

@ -23,7 +23,6 @@ import de.steamwar.bausystem.commands.*;
import de.steamwar.bausystem.world.*;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.core.Core;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
@ -71,7 +70,6 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandReset();
new CommandSpeed();
new CommandTNT();
new CommandBau();
new CommandGamemode();
new CommandClear();
new CommandTime();
@ -97,11 +95,11 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandSelect();
new CommandKillAll();
VersionedRunnable.call(new VersionedRunnable(() -> {
if (Region.buildAreaEnabled()) {
new CommandColor();
}
}, 15));
if (Core.getVersion() > 14 && Region.buildAreaEnabled()) {
new CommandColor();
Bukkit.getPluginManager().registerEvents(new RedstoneListener(), this);
Bukkit.getPluginManager().registerEvents(new TNTSimulatorListener(), this);
}
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
@ -111,10 +109,6 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new CommandGUI(), this);
Bukkit.getPluginManager().registerEvents(new DetonatorListener(), this);
Bukkit.getPluginManager().registerEvents(new ItemFrameListener(), this);
VersionedRunnable.call(new VersionedRunnable(() -> {
Bukkit.getPluginManager().registerEvents(new RedstoneListener(), this);
Bukkit.getPluginManager().registerEvents(new TNTSimulatorListener(), this);
}, 15));
new AFKStopper();
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);

Datei anzeigen

@ -0,0 +1,43 @@
/*
* 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;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.core.VersionDependent;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class CraftbukkitWrapper {
private CraftbukkitWrapper() {}
public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface ICraftbukkitWrapper {
void initTPS();
void createTickCache(World world);
void sendTickPackets();
void openSignEditor(Player player, Location location);
AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt);
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* 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;
import de.steamwar.bausystem.world.Detoloader;
import de.steamwar.core.VersionDependent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class FlatteningWrapper {
private FlatteningWrapper(){}
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface IFlatteningWrapper {
boolean tntPlaceActionPerform(Location location);
boolean setRedstone(Location location, boolean active);
Detoloader onPlayerInteractLoader(PlayerInteractEvent event);
boolean getLever(Block block);
boolean isNoBook(ItemStack item);
boolean inWater(World world, Vector tntPosition);
Material getTraceShowMaterial();
Material getTraceHideMaterial();
Material getTraceXZMaterial();
void giveStick(Player player);
}
}

Datei anzeigen

@ -0,0 +1,44 @@
/*
* 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;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.world.regions.PasteOptions;
import de.steamwar.bausystem.world.regions.Point;
import de.steamwar.core.VersionDependent;
import org.bukkit.entity.Player;
import java.io.File;
public class WorldeditWrapper {
private WorldeditWrapper() {}
public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface IWorldeditWrapper {
void setSelection(Player p, Point minPoint, Point maxPoint);
EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions);
EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions);
boolean isWorldEditCommand(String command);
}
}

Datei anzeigen

@ -1,128 +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.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import java.util.stream.Collectors;
import org.bukkit.entity.Player;
public class CommandBau extends SWCommand {
public CommandBau() {
super("bau", "b", "gs");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers");
p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers");
}
@Register("info")
public void infoCommand(Player p) {
CommandInfo.sendBauInfo(p);
}
@Register("togglewe")
public void toggleWECommand(Player p, SteamwarUser user) {
if (!permissionCheck(p)) {
return;
}
onToggleWE(p, user);
}
@Register("toggleworld")
public void toggleWorldCommand(Player p, SteamwarUser user) {
if (!permissionCheck(p)) {
return;
}
onToggleWorld(p, user);
}
private void onToggleWE(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) {
return;
}
BauweltMember target = BauweltMember.getBauMember(BauSystem.getOwnerID(), id.getId());
Welt.toggleWE(p, target);
}
private void onToggleWorld(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) {
return;
}
BauweltMember target = BauweltMember.getBauMember(BauSystem.getOwnerID(), id.getId());
Welt.toggleWorld(p, target);
}
private boolean negativeToggleCheck(Player p, SteamwarUser id) {
if (id == null) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
return true;
}
BauweltMember target = BauweltMember.getBauMember(BauSystem.getOwnerID(), id.getId());
if (target == null) {
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt!");
return true;
}
return false;
}
private boolean permissionCheck(Player p) {
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
return false;
} else {
return true;
}
}
@ClassMapper(value = SteamwarUser.class, local = true)
private TypeMapper<SteamwarUser> steamwarUserTypeMapper() {
return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.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());
});
}
}

Datei anzeigen

@ -19,9 +19,8 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player;
public class CommandDebugStick extends SWCommand {
@ -37,7 +36,6 @@ public class CommandDebugStick extends SWCommand {
@Register
public void genericCommand(Player p) {
VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8),
new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15));
FlatteningWrapper.impl.giveStick(p);
}
}

Datei anzeigen

@ -156,10 +156,6 @@ public class CommandGUI extends SWCommand implements Listener {
skullLore.add("§7Fire: §e" + (region.isFire() ? "Ausgeschaltet" : "Eingeschaltet"));
skullLore.add("§7Members: §e" + (BauweltMember.getMembers(BauSystem.getOwnerID()).size() - 1));
skull.setLore(skullLore);
skull.setCallback(clickType -> {
player.closeInventory();
bauManagementGUI(player);
});
inv.setItem(4, skull);
}
@ -458,90 +454,6 @@ public class CommandGUI extends SWCommand implements Listener {
inv.open();
}
private static void bauManagementGUI(Player player) {
bauManagementGUI(player, "");
}
private static void bauManagementGUI(Player player, String search) {
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
List<SWListInv.SWListEntry<BauweltMember>> items = new ArrayList<>();
members.forEach(member -> {
if (member.getMemberID() == BauSystem.getOwnerID())
return;
SteamwarUser user = SteamwarUser.get(member.getMemberID());
if (!user.getUserName().toLowerCase().contains(search.toLowerCase()))
return;
SWItem item = SWItem.getPlayerSkull(user.getUserName());
item.setName("§7" + user.getUserName());
List<String> lore = new ArrayList<>();
lore.add("§7Online: §e" + (Bukkit.getPlayer(user.getUUID()) == null ? "Offline" : "Online"));
lore.add("§7Worldedit: §e" + (member.isWorldEdit() ? "Ja" : "Nein"));
lore.add("§7World: §e" + (member.isWorld() ? "Ja" : "Nein"));
item.setLore(lore);
items.add(new SWListInv.SWListEntry<>(item, member));
});
SWListInv<BauweltMember> inv = new SWListInv<>(player, "Bauweltmembers", false, items, (clickType, member) -> bauweltMemberGUI(player, member));
inv.setItem(48, Material.NETHER_STAR, "§7Member hinzufühgen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Member hinzufühgen");
anvilInv.setItem(Material.NAME_TAG);
anvilInv.setCallback(s -> {
player.closeInventory();
confirmChatMessage(player, "/bau addmember " + s);
});
anvilInv.open();
});
inv.setItem(50, Material.NAME_TAG, "§7Suchen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Member suchen");
anvilInv.setItem(Material.PAPER);
anvilInv.setCallback(s -> {
player.closeInventory();
bauManagementGUI(player, s);
});
anvilInv.open();
});
inv.open();
}
private static void bauweltMemberGUI(Player player, BauweltMember member) {
SteamwarUser user = SteamwarUser.get(member.getMemberID());
SWInventory inv = new SWInventory(player, 9, "Member: " + user.getUserName());
if (member.isWorldEdit()) {
inv.setItem(1, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(false);
bauweltMemberGUI(player, member);
});
} else {
inv.setItem(1, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(true);
bauweltMemberGUI(player, member);
});
}
if (member.isWorld()) {
inv.setItem(3, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7World", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> {
member.setWorld(false);
bauweltMemberGUI(player, member);
});
} else {
inv.setItem(3, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> {
member.setWorld(true);
bauweltMemberGUI(player, member);
});
}
inv.setItem(5, Material.BARRIER, "§7Member entfernen", clickType -> {
player.closeInventory();
confirmChatMessage(player, "/bau delmember " + user.getUserName());
});
inv.setItem(7, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player));
inv.open();
}
private static void confirmChatMessage(Player player, String command) {
player.sendMessage(BauSystem.PREFIX + "§7Klicke auf die Nachricht zum bestätigen");

Datei anzeigen

@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.world.RedstoneListener;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player;
public class CommandRedstoneTester extends SWCommand {
@ -39,12 +38,8 @@ public class CommandRedstoneTester extends SWCommand {
@Register
public void genericCommand(Player p) {
VersionedRunnable.call(new VersionedRunnable(() -> {
p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar");
}, 8), new VersionedRunnable(() -> {
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
SWUtils.giveItemToPlayer(p, RedstoneListener.WAND);
}, 15));
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
SWUtils.giveItemToPlayer(p, RedstoneListener.WAND);
}

Datei anzeigen

@ -2,10 +2,10 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.WorldeditWrapper;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.*;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import lombok.Getter;
import org.bukkit.entity.Player;
@ -118,8 +118,7 @@ public class CommandSelect extends SWCommand {
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
VersionedRunnable.call(new VersionedRunnable(() -> CommandSelect_12.setSelection(p, minPoint, maxPoint), 12),
new VersionedRunnable(() -> CommandSelect_15.setSelection(p, minPoint, maxPoint), 15));
WorldeditWrapper.impl.setSelection(p, minPoint, maxPoint);
p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt");
}
}

Datei anzeigen

@ -20,13 +20,13 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.TPSUtils;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.core.VersionedRunnable;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -135,13 +135,11 @@ public class CommandTPSLimiter extends SWCommand {
} else {
if (tpsLimiter != null) return;
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(WORLD), 8),
new VersionedRunnable(() -> TPSLimit_15.createTickCache(WORLD), 14));
CraftbukkitWrapper.impl.createTickCache(WORLD);
for (int i = 0; i < loops; i++) {
sleepUntilNextTick(sleepDelay);
VersionedRunnable.call(new VersionedRunnable(TPSLimit_12::sendTickPackets, 8),
new VersionedRunnable(TPSLimit_15::sendTickPackets, 14));
CraftbukkitWrapper.impl.sendTickPackets();
}
}, 0, 1);
}

Datei anzeigen

@ -22,12 +22,10 @@
package de.steamwar.bausystem.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.TNTTracer_12;
import de.steamwar.bausystem.tracer.TNTTracer_15;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
@ -66,7 +64,7 @@ public class GuiTraceShow {
swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
Material xzMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceXZMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceXZMaterial, 14));
Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial();
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {
});
swInventory.setItem(7, interpolateXZ);
@ -80,7 +78,7 @@ public class GuiTraceShow {
private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) {
Material showMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceShowMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceShowMaterial, 14));
Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial();
SWItem shown = new SWItem(showMaterial, (byte) 5, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player);
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
@ -88,7 +86,7 @@ public class GuiTraceShow {
});
swInventory.setItem(1, shown);
} else {
Material hideMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceHideMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceHideMaterial, 14));
Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial();
SWItem hidden = new SWItem(hideMaterial, (byte) 14, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> {
show(player);
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");

Datei anzeigen

@ -21,10 +21,13 @@
package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.tracer.*;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.tracer.RoundedTNTPosition;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.show.ShowMode;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.core.VersionedCallable;
import org.bukkit.entity.Player;
import org.bukkit.util.Consumer;
import org.bukkit.util.Vector;
@ -78,13 +81,11 @@ public class EntityShowMode implements ShowMode {
}
private boolean checkWater(Vector position) {
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14));
return FlatteningWrapper.impl.inWater(player.getWorld(), position);
}
public static AbstractTraceEntity createEntity(Player player, Vector position, boolean tnt) {
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, tnt), 8),
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 14));
return CraftbukkitWrapper.impl.create(player.getWorld(), position, tnt);
}
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.VersionedCallable;
import de.steamwar.bausystem.FlatteningWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -175,10 +175,7 @@ public class AutoLoader extends AbstractAutoLoader implements Listener {
if (!setup || !event.getPlayer().equals(player))
return;
Detoloader detoloader = VersionedCallable.call(
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event);
if (detoloader == null || detoloader.getActivation() < 0) return;
if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return;
@ -232,8 +229,7 @@ public class AutoLoader extends AbstractAutoLoader implements Listener {
@Override
boolean setRedstone(Location location, boolean active){
return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.setRedstone(location, active), 8),
new VersionedCallable<>(() -> AutoLoader_15.setRedstone(location, active), 15));
return FlatteningWrapper.impl.setRedstone(location, active);
}
@Override
@ -259,8 +255,7 @@ public class AutoLoader extends AbstractAutoLoader implements Listener {
@Override
public boolean perform() {
return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.tntPlaceActionPerform(location), 8),
new VersionedCallable<>(() -> AutoLoader_15.tntPlaceActionPerform(location), 15));
return FlatteningWrapper.impl.tntPlaceActionPerform(location);
}
@Override

Datei anzeigen

@ -20,27 +20,22 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.VersionedCallable;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.bausystem.FlatteningWrapper;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import java.util.*;
public class Detonator implements Listener {
public static final ItemStack WAND;
private static final String DETO_PREFIX = "deto-loc-";
public static final Map<Player, Set<Detoloader.DetonatorActivation>> PLAYER_LOCS = new HashMap<>();
@ -50,12 +45,6 @@ public class Detonator implements Listener {
im.setDisplayName("§eFernzünder");
VersionedRunnable.call(
new VersionedRunnable(() -> {
im.getPersistentDataContainer().set(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE, (byte) 1);
im.getPersistentDataContainer().set(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER, 0);
}, 15));
List<String> lorelist = Arrays.asList("§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren",
"§eLinks Klick + Shift §8- §7Füge einen Punkt hinzu", "§eRechts Klick §8- §7Löse alle Punkte aus");
im.setLore(lorelist);
@ -64,239 +53,58 @@ public class Detonator implements Listener {
}
public static Detonator getDetonator(Player player, ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> {
return new Detonator(player, PLAYER_LOCS.get(player));
}, 12), new VersionedCallable<>(() -> {
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
List<int[]> locs = new ArrayList<>();
for (int i = 0; i < getDetoLocs(container); i++) {
NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i);
if (container.has(key, PersistentDataType.INTEGER_ARRAY))
locs.add(container.get(key, PersistentDataType.INTEGER_ARRAY));
}
return new Detonator(player, locs.toArray(new int[0][0]));
}, 15));
return new Detonator(player, PLAYER_LOCS.get(player));
}
public static ItemStack setLocation(Player player, ItemStack item, Detoloader.DetonatorActivation detoloader) {
return VersionedCallable.call(new VersionedCallable<>(() -> {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear();
PLAYER_LOCS.get(player).add(detoloader);
return item;
}, 12), new VersionedCallable<>(() -> {
try {
return pushLocToDetonator(clearDetonator(item), detoloader);
}catch (SecurityException e){
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
return item;
}
}, 15));
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear();
PLAYER_LOCS.get(player).add(detoloader);
return item;
}
public static ItemStack toggleLocation(ItemStack item, Player player, Detoloader detoloader, Location location) {
if (VersionedCallable.call(new VersionedCallable<>(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location)), 12),
new VersionedCallable<>(() -> hasLocation(item, location), 15))) {
if (PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location))) {
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() - 1);
return VersionedCallable.call(new VersionedCallable<>(() -> {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location));
return item;
}, 12), new VersionedCallable<>(() -> removeLocation(item, location), 15));
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location));
return item;
} else {
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() + 1);
if (detoloader.getActivation() == 0)
return VersionedCallable.call(new VersionedCallable<>(() -> {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location));
return item;
}, 12), new VersionedCallable<>(() -> {
try {
return pushLocToDetonator(item, new Detoloader.DetonatorActivation(location));
}catch (SecurityException e){
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
return item;
}
}, 15));
else
return VersionedCallable.call(new VersionedCallable<>(() -> {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(detoloader.getActivation(), location));
return item;
}, 12), new VersionedCallable<>(() -> {
try {
return pushLocToDetonator(item, new Detoloader.DetonatorActivation(detoloader.getActivation(), location));
}catch (SecurityException e){
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
return item;
}
}, 15));
if (detoloader.getActivation() == 0) {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location));
return item;
} else {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(detoloader.getActivation(), location));
return item;
}
}
}
public static void execute(Player player) {
VersionedRunnable.call(new VersionedRunnable(() -> execute(player, PLAYER_LOCS.get(player)), 12), new VersionedRunnable(() -> {
try {
ItemStack item = getNextBestDetonator(player);
if (item == null)
return;
Detonator detonator = getDetonator(player, item);
execute(player, detonator.getLocs());
} catch (SecurityException e) {
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
}
}, 15));
}
private static ItemStack getNextBestDetonator(Player player) {
if (player.getInventory().getItemInMainHand().getItemMeta() != null && player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
return player.getInventory().getItemInMainHand();
}
if(player.getInventory().getItemInOffHand().getItemMeta() != null && player.getInventory().getItemInOffHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
return player.getInventory().getItemInOffHand();
}
for (ItemStack item : player.getInventory().getContents()) {
if (item == null)
continue;
if (item.getItemMeta() != null &&
item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
return item;
}
}
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen Detonator im Inventar");
return null;
execute(player, PLAYER_LOCS.get(player));
}
private static void execute(Player player, Set<Detoloader.DetonatorActivation> locs) {
for (Detoloader.DetonatorActivation activation : locs) {
if (activation.activation == -1) {
VersionedRunnable.call(new VersionedRunnable(() -> {
boolean powered = AutoLoader_12.getLever(activation.location.getBlock());
AutoLoader_12.setRedstone(activation.location, !powered);
}, 12), new VersionedRunnable(() -> {
boolean powered = AutoLoader_15.getLever(activation.location.getBlock());
AutoLoader_15.setRedstone(activation.location, !powered);
}, 15));
FlatteningWrapper.impl.setRedstone(activation.location, !FlatteningWrapper.impl.getLever(activation.location.getBlock()));
} else {
VersionedRunnable.call(new VersionedRunnable(() -> {
AutoLoader_12.setRedstone(activation.location, true);
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_12.setRedstone(activation.location, false), activation.activation);
}, 12), new VersionedRunnable(() -> {
AutoLoader_15.setRedstone(activation.location, true);
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_15.setRedstone(activation.location, false), activation.activation);
}, 15));
FlatteningWrapper.impl.setRedstone(activation.location, true);
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> FlatteningWrapper.impl.setRedstone(activation.location, false), activation.activation);
}
}
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§e" + locs.size() + " §7Punkt" + (locs.size() > 1 ? "e" : "") + " ausgelöst!"));
}
private static int getFreeSlot(ItemStack item) {
ItemMeta meta = item.getItemMeta();
if (meta == null) {
throw new SecurityException("Das Item ist kein Detonator");
}
PersistentDataContainer container = meta.getPersistentDataContainer();
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
for (int i = 0; i < getDetoLocs(container) + 1; i++) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i), PersistentDataType.INTEGER_ARRAY)) {
return i;
}
}
return -1;
}
private static int getDetoLocs(PersistentDataContainer container) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
return container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER);
}
private static void increaseLocsSize(PersistentDataContainer container, int to) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
if (container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER) < to) {
container.set(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER, to);
}
}
public static ItemStack pushLocToDetonator(ItemStack item, Detoloader.DetonatorActivation detoloader) {
int slot = getFreeSlot(item);
if (slot == -1)
throw new SecurityException("Mit dem Detonator stimmt etwas nicht. Nimm dir einen neuen mit /dt wand. Wenn es dann immer nicht nicht tut, wende dich an einen Developer");
ItemMeta meta = item.getItemMeta();
Location block = detoloader.location;
meta.getPersistentDataContainer().set(new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + slot), PersistentDataType.INTEGER_ARRAY, new int[]
{block.getBlockX(), block.getBlockY(), block.getBlockZ(), detoloader.activation});
increaseLocsSize(meta.getPersistentDataContainer(), slot + 1);
item.setItemMeta(meta);
return item;
}
public static void clear(Player player) {
VersionedRunnable.call(new VersionedRunnable(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear(), 12), new VersionedRunnable(() -> {
if (player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen Detonator im Inventar");
return;
}
player.getInventory().setItemInMainHand(clearDetonator(player.getInventory().getItemInMainHand()));
}, 15));
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear();
}
public static ItemStack clearDetonator(ItemStack item) {
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
container.set(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER, 0);
for (int i = 0; i < getDetoLocs(container); i++) {
NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i);
container.remove(key);
}
item.setItemMeta(meta);
return item;
}
public static boolean hasLocation(ItemStack item, Location location) {
return getSlotOfLocation(item, location) != -1;
}
private static int getSlotOfLocation(ItemStack item, Location location) {
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
for (int i = 0; i < getDetoLocs(container); i++) {
NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i);
if (container.has(key, PersistentDataType.INTEGER_ARRAY)) {
int[] locs = container.get(key, PersistentDataType.INTEGER_ARRAY);
if (locs[0] == location.getBlockX() && locs[1] == location.getBlockY() && locs[2] == location.getBlockZ())
return i;
}
}
return -1;
}
public static ItemStack removeLocation(ItemStack item, Location location) {
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
container.remove(new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + getSlotOfLocation(item, location)));
item.setItemMeta(meta);
return item;
}
private Set<Detoloader.DetonatorActivation> locs = new HashSet<>();
private final Set<Detoloader.DetonatorActivation> locs;
private final Player player;
private Detonator(Player player, int[][] activations) {
this.player = player;
for (int[] activation : activations) {
locs.add(new Detoloader.DetonatorActivation(activation[3], new Location(player.getWorld(), activation[0], activation[1], activation[2])));
}
}
private Detonator(Player player, Set<Detoloader.DetonatorActivation> locs) {
this.player = player;
this.locs = locs;

Datei anzeigen

@ -1,25 +1,22 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.Permission;
import de.steamwar.core.VersionedCallable;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
public class DetonatorListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() == null) return;
if (VersionedCallable.call(new VersionedCallable<>(() -> event.getItem().isSimilar(Detonator.WAND), 12),
new VersionedCallable<>(() -> event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE), 15))) {
if (event.getItem().isSimilar(Detonator.WAND)) {
Player player = event.getPlayer();
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
@ -29,9 +26,7 @@ public class DetonatorListener implements Listener {
event.setCancelled(true);
switch (event.getAction()) {
case LEFT_CLICK_BLOCK:
Detoloader detoloader = VersionedCallable.call(
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event);
if (detoloader == null) {
return;

Datei anzeigen

@ -26,9 +26,9 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.BlockPosition;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.Permission;
import de.steamwar.core.VersionedCallable;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.bausystem.WorldeditWrapper;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -38,7 +38,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -64,8 +65,7 @@ public class RegionListener implements Listener {
if (command.startsWith(shortcut))
return true;
return VersionedCallable.call(new VersionedCallable<>(() -> RegionListener_12.isWorldEditCommand(command), 8),
new VersionedCallable<>(() -> RegionListener_15.isWorldEditCommand(command), 15));
return WorldeditWrapper.impl.isWorldEditCommand(command);
}
@EventHandler
@ -95,8 +95,7 @@ public class RegionListener implements Listener {
}
sign.update();
VersionedRunnable.call(new VersionedRunnable(() -> RegionListener_12.openSignEditor(player, event.getClickedBlock().getLocation()), 12),
new VersionedRunnable(() -> RegionListener_15.openSignEditor(player, event.getClickedBlock().getLocation()), 15));
CraftbukkitWrapper.impl.openSignEditor(player, event.getClickedBlock().getLocation());
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) {
@Override

Datei anzeigen

@ -20,11 +20,11 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.commands.CommandScript;
import de.steamwar.bausystem.commands.CommandTNT;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.core.VersionedCallable;
import de.steamwar.inventory.SWAnvilInv;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -97,8 +97,7 @@ public class ScriptListener implements Listener {
}
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_12.isNoBook(item), 8),
new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
return FlatteningWrapper.impl.isNoBook(item);
}
private static class ScriptExecutor {

Datei anzeigen

@ -3,14 +3,13 @@ package de.steamwar.bausystem.world;
@SuppressWarnings({"unused", "UnusedReturnValue"})
public class SizedStack<T> {
private int maxSize;
private T[] data;
private final int maxSize;
private final T[] data;
private int size;
private int head;
public SizedStack(int size) {
this.maxSize = size;
//noinspection unchecked
this.data = (T[]) new Object[this.maxSize];
this.head = 0;
this.size = 0;

Datei anzeigen

@ -21,9 +21,9 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.commands.CommandTPSLimiter;
import de.steamwar.core.TPSWatcher;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.Bukkit;
import java.util.function.Supplier;
@ -38,19 +38,21 @@ public class TPSUtils {
private static long nanoOffset = 0;
private static long nanoDOffset = 0;
public static void disableWarp() {
warp = false;
}
public static long getNanoOffset() {
return nanoOffset;
}
private static long ticksSinceServerStart = 0;
public static final Supplier<Long> currentTick = () -> ticksSinceServerStart;
public static void init() {
VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8),
new VersionedRunnable(() -> {
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1);
TPSUtils_15.init(() -> nanoOffset);
}, 15));
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
ticksSinceServerStart++;
}, 1, 1);
CraftbukkitWrapper.impl.initTPS();
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1);
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> ticksSinceServerStart++, 1, 1);
}
public static void setTPS(double tps) {

Datei anzeigen

@ -22,8 +22,6 @@ package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Welt {
@ -50,30 +48,4 @@ public class Welt {
return true;
}
}
private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what) {
Player z = Bukkit.getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
if (z != null) {
if (ableTo) {
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a " + what);
} else {
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c " + what);
}
}
if (ableTo) {
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun " + what);
} else {
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr " + what);
}
}
public static void toggleWE(Player p, BauweltMember target) {
target.setWorldEdit(!target.isWorldEdit());
sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden");
}
public static void toggleWorld(Player p, BauweltMember target) {
target.setWorld(!target.isWorld());
sendMessages(p, target.isWorld(), target, "Einstellungen vornehmen");
}
}

Datei anzeigen

@ -21,8 +21,8 @@ package de.steamwar.bausystem.world.regions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.WorldeditWrapper;
import de.steamwar.bausystem.world.Color;
import de.steamwar.core.VersionedCallable;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Location;
@ -194,12 +194,10 @@ public class Prototype {
}
private static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { //Type of protect
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, pasteOptions), 8),
new VersionedCallable(() -> Region_15.paste(file, x, y, z, pasteOptions), 15));
return WorldeditWrapper.impl.paste(file, x, y, z, pasteOptions);
}
private static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, pasteOptions), 8),
new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, pasteOptions), 15));
return WorldeditWrapper.impl.paste(clipboard, x, y, z, pasteOptions);
}
}

Datei anzeigen

@ -71,6 +71,12 @@ allprojects {
mavenCentral()
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
dependencies {

Datei anzeigen

@ -21,5 +21,4 @@ rootProject.name = 'BauSystem'
include 'BauSystem_12'
include 'BauSystem_15'
include 'BauSystem_API'
include 'BauSystem_Main'