Merge branch 'main' into FightSystem/tech-hider-hardening

This commit is contained in:
D4rkr34lm
2026-05-15 20:16:20 +02:00
386 changed files with 3585 additions and 21765 deletions
@@ -1,29 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(libs.nms10)
}
@@ -1,61 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_10_R1.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,31 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_8", "default"))
compileOnly(libs.nms12)
compileOnly(libs.worldedit12)
}
@@ -1,61 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_12_R1.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,53 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper12 implements WorldOfColorWrapper {
@Override
public void setTeamColor(Team team, ChatColor color) {
team.setColor(color);
}
@Override
public boolean isInBlock(Projectile e) {
if(e instanceof Arrow)
return ((Arrow) e).isInBlock();
return false;
}
@Override
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
}
@Override
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
player.sendTitle(title, subtitle, start, hold, stop);
}
}
@@ -1,32 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import com.sk89q.worldedit.blocks.BaseBlock;
import org.bukkit.Material;
@SuppressWarnings("deprecation")
public class WorldeditWrapper12 extends WorldeditWrapper8 {
static {
colorBlocks.add(new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE));
colorBlocks.add(new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE));
}
}
@@ -1,34 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_8", "default"))
compileOnly(project(":FightSystem:FightSystem_9", "default"))
compileOnly(libs.nms14)
compileOnly(libs.worldedit15)
compileOnly(libs.fastutil)
}
@@ -1,96 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.Map;
public class BlockIdWrapper14 implements BlockIdWrapper {
private static final Class<?> chunkProviderServer = Reflection.getClass("net.minecraft.server.level.ServerChunkCache");
private static final Reflection.Method getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
private static final Class<?> playerChunkMap = Reflection.getClass("net.minecraft.server.level.ChunkMap");
private static final Reflection.Field<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
private static final Reflection.Field<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
private static final Class<?> block = Reflection.getClass("net.minecraft.world.level.block.Block");
private static final Class<?> iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.BlockState");
private static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPos");
private final Map trackers;
public BlockIdWrapper14() {
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
}
private static final Reflection.Method getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
private static final Reflection.Method getNMS = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock"), "getNMS", iBlockData);
@Override
public int blockToId(Block block) {
return (int) getCombinedId.invoke(null, getNMS.invoke(block));
}
private static final Reflection.Method getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
private static final Reflection.Constructor newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
private static final Reflection.Method getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
private static final Reflection.Method removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
private static final Reflection.Method flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
Object blockData = getByCombinedId.invoke(null, blockState);
Object nworld = getWorldHandle.invoke(world);
Object pos = newBlockPosition.invoke(x, y, z);
removeTileEntity.invoke(nworld, pos);
getTypeAndData.invoke(nworld, pos, blockData, 1042);
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
}
private static final Class<?> entityTracker = Reflection.getClass("net.minecraft.server.level.ChunkMap$TrackedEntity");
private static final Reflection.Method updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
@Override
public void trackEntity(Player player, Entity entity) {
Object tracker = trackers.get(entity.getEntityId());
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.Method clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
@Override
public void untrackEntity(Player player, Entity entity) {
Object tracker = trackers.get(entity.getEntityId());
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.Method getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
private static final Reflection.Method getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
@Override
public Material idToMaterial(int blockState) {
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
}
}
@@ -1,62 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_14_R1.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
chunk.heightMap.clear();
chunk.heightMap.putAll(backupChunk.heightMap);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,116 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.DyeColor;
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.block.data.type.Dispenser;
import org.bukkit.entity.Player;
import org.bukkit.entity.Pose;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Objects;
public class FlatteningWrapper14 implements FlatteningWrapper {
@Override
public DyeColor getSilver() {
return DyeColor.LIGHT_GRAY;
}
@Override
public boolean isWater(Block block) {
if(block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
return ((Waterlogged) data).isWaterlogged();
}
@Override
public boolean removeWater(Block block) {
Material type = block.getType();
if(type == Material.WATER || type == Material.LAVA){
block.setType(Material.AIR);
return true;
}
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
block.setType(Material.AIR);
return true;
}
return false;
}
@Override
public boolean containsBlockMeta(ItemMeta meta) {
return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData();
}
@Override
public boolean hasAttributeModifier(ItemStack stack) {
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
}
@Override
public boolean doRecord(BlockPhysicsEvent e) {
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
}
@Override
public void forceLoadChunk(World world, int cX, int cZ) {
world.setChunkForceLoaded(cX, cZ, true);
}
@Override
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.MOVING_PISTON;
}
@Override
public boolean isFacingWater(Block dispenser) {
return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid();
}
@Override
public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING;
}
@Override
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type.createBlockData());
}
}
@@ -1,40 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.Sound;
public class SWSound14 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
case BLOCK_NOTE_BASS:
return Sound.BLOCK_NOTE_BLOCK_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_BLOCK_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}
}
}
@@ -1,153 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.*;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.NodeData;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
public class WorldeditWrapper14 implements WorldeditWrapper {
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
static {
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet");
}
@Override
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock()));
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
BlockVector3 pos = minimum.add(x, y, z);
BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
if(replacement != null)
clipboard.setBlock(pos, replacement);
}
}
}
}
@Override
public int getWaterDepth(Clipboard clipboard) {
BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1);
int depth = 0;
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
depth++;
it = it.add(0, 1, 0);
}
return depth;
}
@Override
public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) {
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
).toBlockPoint()).build());
e.flushSession();
}
@Override
public Vector getDimensions(Clipboard clipboard) {
BlockVector3 dims = clipboard.getDimensions();
return new Vector(dims.getX(), dims.getY(), dims.getZ());
}
@Override
public Clipboard loadChar(String charName) throws IOException {
File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem");
Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read();
}
return clipboard;
}
@Override
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
World w = new BukkitWorld(Config.world);
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
);
forwardExtentCopy.setCopyingEntities(false);
Operations.complete(forwardExtentCopy);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
writer.write(clipboard);
writer.close();
} catch (IOException e) {
throw new SecurityException(e);
}
SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2);
}
}
@@ -1,30 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(libs.nms15)
compileOnly(libs.worldedit15)
}
@@ -1,62 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_15_R1.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
chunk.heightMap.clear();
chunk.heightMap.putAll(backupChunk.heightMap);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,36 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_14", "default"))
compileOnly(libs.spigotapi)
compileOnly(libs.nms18)
compileOnly(libs.fawe18)
compileOnly(libs.authlib)
compileOnly(libs.fastutil)
}
@@ -1,47 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class BlockIdWrapper18 extends BlockIdWrapper14 {
@Override
public void trackEntity(Player player, Entity entity) {
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
player.showEntity(FightSystem.getPlugin(), entity);
}
@Override
public void untrackEntity(Player player, Entity entity) {
player.hideEntity(FightSystem.getPlugin(), entity);
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
}
}
@@ -1,68 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.ChunkSection;
import net.minecraft.world.level.entity.LevelEntityGetter;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
private static final Reflection.Method getWorld = Reflection.getMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle");
private static final Reflection.Method getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
private static final Reflection.Method getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
private ChunkSection[] getChunkSections(World world, int x, int z) {
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
}
@Override
public void resetChunk(World world, World backup, int x, int z) {
ChunkSection[] sections = getChunkSections(world, x, z);
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
}
private static final Reflection.Method getEntity = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
}
@Override
public float headRotation(Entity e) {
return getEntity(e).ce();
}
private static final Reflection.Method getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
private static final Reflection.Method getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
@Override
public Stream<?> entityIterator() {
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
}
@Override
public void setupGamerule() { }
}
@@ -1,73 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.SectionPosition;
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
import net.minecraft.world.level.block.state.IBlockData;
import java.util.List;
public class HullHiderWrapper18 implements HullHiderWrapper {
private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", IBlockData.class);
@Override
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
Object[] blockdata = new Object[changes.size()];
for(int i = 0; i < blockdata.length; i++) {
Hull.IntVector change = changes.get(i);
blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ()));
}
return generateBlockChangePacket(changes, blockdata);
}
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
if(changes.size() > 1) {
Hull.IntVector section = changes.get(0);
section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
int xOffset = 16*section.getX();
int yOffset = 16*section.getY();
int zOffset = 16*section.getZ();
short[] pos = new short[changes.size()];
for(int i = 0; i < changes.size(); i++) {
Hull.IntVector change = changes.get(i);
pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset));
}
return constructMultiBlockChange(section, pos, blockdata);
} else {
Hull.IntVector pos = changes.get(0);
return new PacketPlayOutBlockChange(new BlockPosition(pos.getX(), pos.getY(), pos.getZ()), (IBlockData) blockdata[0]);
}
}
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length), false);
}
}
@@ -1,31 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_18", "default"))
compileOnly(libs.spigotapi)
compileOnly(libs.nms19)
}
@@ -1,30 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.entity.Entity;
public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 {
@Override
public float headRotation(Entity e) {
return getEntity(e).ck();
}
}
@@ -1,33 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_18", "default"))
compileOnly(libs.spigotapi)
compileOnly(libs.nms20)
compileOnly(libs.fastutil)
}
@@ -1,30 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.entity.Entity;
public class CraftbukkitWrapper20 extends CraftbukkitWrapper18 {
@Override
public float headRotation(Entity e) {
return getEntity(e).cm();
}
}
@@ -1,32 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
import net.minecraft.core.SectionPosition;
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
public class HullHiderWrapper20 extends HullHiderWrapper18 {
@Override
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
}
}
@@ -1,46 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_18", "default"))
compileOnly(project(":SpigotCore", "default"))
compileOnly(libs.paperapi21) {
attributes {
// Very Hacky, but it works
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
}
}
compileOnly(libs.nms21) {
attributes {
// Very Hacky, but it works
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
}
}
compileOnly(libs.fastutil)
compileOnly(libs.authlib)
compileOnly(project(":FightSystem:FightSystem_14"))
}
@@ -1,51 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import net.minecraft.world.entity.projectile.windcharge.WindCharge;
import org.bukkit.Location;
public class WindchargeStopper21 implements WindchargeStopper.IWindchargeStopper {
public WindchargeStopper21() {
new StateDependentTask(true, FightState.Running, this::run, 1, 1);
}
private static final int middleLine = Config.SpecSpawn.getBlockZ();
private static final Class<?> windChargeClass = WindCharge.class;
private void run() {
Recording.iterateOverEntities(windChargeClass::isInstance, entity -> {
Location location = entity.getLocation();
Location prevLocation = location.clone().subtract(entity.getVelocity());
boolean passedMiddle = location.getBlockZ() > middleLine && prevLocation.getBlockZ() > middleLine ||
location.getBlockZ() < middleLine && prevLocation.getBlockZ() < middleLine;
if(!passedMiddle) {
entity.remove();
}
});
}
}
@@ -1,77 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.FightSystem;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class BlockIdWrapper21 implements BlockIdWrapper {
@Override
public Material idToMaterial(int blockState) {
return CraftMagicNumbers.getMaterial(net.minecraft.world.level.block.Block.stateById(blockState)).getItemType();
}
@Override
public int blockToId(Block block) {
return net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle());
}
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
BlockState blockData = net.minecraft.world.level.block.Block.stateById(blockState);
ServerLevel level = ((CraftWorld) world).getHandle();
BlockPos pos = new BlockPos(x, y, z);
level.removeBlockEntity(pos);
level.setBlock(pos, blockData, blockState);
level.getChunkSource().blockChanged(pos);
}
@Override
public void trackEntity(Player player, Entity entity) {
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
player.showEntity(FightSystem.getPlugin(), entity);
}
@Override
public void untrackEntity(Player player, Entity entity) {
player.hideEntity(FightSystem.getPlugin(), entity);
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
}
}
@@ -1,61 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Entity;
import java.util.HashSet;
import java.util.Set;
public class CraftbukkitWrapper21 extends CraftbukkitWrapper18 {
@Override
public float headRotation(Entity e) {
return getEntity(e).getYHeadRot();
}
@Override
public void setupGamerule() {
Config.world.setGameRule(GameRule.LOCATOR_BAR, false);
}
private LevelChunk getChunk(World world, int x, int z) {
return ((CraftWorld) world).getHandle().getChunk(x, z);
}
@Override
public void resetChunk(World world, World backup, int x, int z) {
LevelChunk worldChunk = getChunk(world, x, z);
LevelChunk backupChunk = getChunk(backup, x, z);
LevelChunkSection[] sections = worldChunk.getSections();
System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length);
Set<BlockPos> blocks = new HashSet<>(worldChunk.blockEntities.keySet());
blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity);
worldChunk.heightmaps.clear();
worldChunk.heightmaps.putAll(backupChunk.heightmaps);
}
}
@@ -1,29 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.inventory.ItemStack;
public class FlatteningWrapper21 extends FlatteningWrapper14 {
@Override
public boolean hasAttributeModifier(ItemStack stack) {
return stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers();
}
}
@@ -1,74 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import io.papermc.paper.datacomponent.DataComponentType;
import io.papermc.paper.datacomponent.DataComponentTypes;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class ReflectionWrapper21 implements ReflectionWrapper {
private static final Set<DataComponentType> FORBIDDEN_TYPES = new HashSet<>();
static {
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME);
FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE);
FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA);
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS);
FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA);
FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS);
FORBIDDEN_TYPES.add(DataComponentTypes.TOOL);
FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON);
FORBIDDEN_TYPES.add(DataComponentTypes.FOOD);
FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK);
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON);
FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE);
FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER);
FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN);
FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES);
FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE);
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS);
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION);
FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST);
FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE);
}
@Override
public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) {
return packet;
}
@Override
public boolean hasItems(ItemStack stack) {
FORBIDDEN_TYPES.forEach(stack::resetData);
return false;
}
}
@@ -1,11 +0,0 @@
package de.steamwar.fightsystem.utils;
import net.minecraft.server.MinecraftServer;
public class TpsWarper21 implements TpsWarper {
@Override
public void warp(float tps) {
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
}
}
@@ -1,30 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(libs.nms8)
compileOnly(libs.worldedit12)
}
@@ -1,23 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.listener;
public class WindchargeStopper8 implements WindchargeStopper.IWindchargeStopper {
}
@@ -1,83 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class BlockIdWrapper8 implements BlockIdWrapper {
private static final Class<?> entityTracker = Reflection.getClass("net.minecraft.EntityTracker");
private static final Reflection.Field<?> getEntityTracker = Reflection.getField(worldServer, entityTracker, 0);
private static final Class<?> intHashMap = Reflection.getClass("net.minecraft.IntHashMap");
private static final Reflection.Field<?> getTrackedEntities = Reflection.getField(entityTracker, intHashMap, 0);
private final Object trackers;
public BlockIdWrapper8() {
trackers = getTrackedEntities.get(getEntityTracker.get(getWorldHandle.invoke(Config.world)));
}
@Override
@SuppressWarnings("deprecation")
public int blockToId(Block block) {
return block.getTypeId() << 4 + block.getData();
}
@Override
@SuppressWarnings("deprecation")
public void setBlock(World world, int x, int y, int z, int blockState) {
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
blockState = 0;
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
}
private static final Class<?> entityTrackerEntry = Reflection.getClass("net.minecraft.EntityTrackerEntry");
private static final Reflection.Method get = Reflection.getTypedMethod(intHashMap, "get", Object.class, int.class);
private static final Reflection.Method updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer);
@Override
public void trackEntity(Player player, Entity entity) {
Object tracker = get.invoke(trackers, entity.getEntityId());
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.Method clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer);
@Override
public void untrackEntity(Player player, Entity entity) {
Object tracker = get.invoke(trackers, entity.getEntityId());
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
}
@Override
@SuppressWarnings("deprecation")
public Material idToMaterial(int blockState) {
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
blockState = 0;
return Material.getMaterial(blockState >> 4);
}
}
@@ -1,116 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team;
import java.util.HashSet;
import java.util.Set;
public class BountifulWrapper8 implements BountifulWrapper {
public BountifulWrapper8() {
EntityEnderDragon dragon = new EntityEnderDragon(null);
dragon.setLocation(Config.ArenaRegion.centerX(), -100, Config.ArenaRegion.centerZ(), 0, 0);
this.spawnDragonId = dragon.getId();
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
}
@Override
public boolean mainHand(Object packet) {
return true;
}
@Override
public boolean bowInHand(boolean mainHand, Player p) {
return p.getInventory().getItemInHand().getType() == Material.BOW;
}
@Override
public void setAttackSpeed(Player player) {
// nothing to do
}
@Override
public void setNametagVisibility(Team team) {
//nothing to do
}
@Override
public Listener newDenyArrowPickupListener() {
return new Listener() {};
}
@Override
public Listener newDenyHandSwapListener() {
return new Listener() {};
}
@Override
public void recordHandItems(Player player) {
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInHand()), "MAINHAND");
}
@Override
public Listener newHandSwapRecorder() {
return new Listener() {};
}
@Override
public void spawnParticle(World world, String particleName, double x, double y, double z) {
world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1);
}
private final Set<Player> seesDragon = new HashSet<>();
private final PacketPlayOutSpawnEntityLiving spawnDragon;
private final int spawnDragonId;
@Override
public void sendBar(Player player, FightTeam team, double progress, String text) {
seesDragon.removeIf(p -> !p.isOnline());
if(!seesDragon.contains(player)) {
((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon);
seesDragon.add(player);
}
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 0x20);
watcher.a(2, text);
watcher.a(3, (byte) 1);
watcher.a(4, (byte) 1);
watcher.a(6, (float)(progress * 200));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true));
}
}
@@ -1,58 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.v1_8_R3.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true;
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityList.removeAll(chunk.tileEntities.values());
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,92 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class FlatteningWrapper8 implements FlatteningWrapper {
@Override
public DyeColor getSilver() {
return DyeColor.SILVER;
}
@Override
public boolean isWater(Block block) {
Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA;
}
@Override
public boolean removeWater(Block block) {
if(isWater(block)){
block.setType(Material.AIR);
return true;
}
return false;
}
@Override
public boolean containsBlockMeta(ItemMeta meta) {
return false;
}
@Override
public boolean hasAttributeModifier(ItemStack stack) {
return false;
}
@Override
public boolean doRecord(BlockPhysicsEvent e) {
return e.getChangedType() != e.getBlock().getType();
}
@Override
public void forceLoadChunk(World world, int cX, int cZ) {
world.setKeepSpawnInMemory(true);
}
@Override
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.PISTON_MOVING_PIECE;
}
@Override
public boolean isFacingWater(Block dispenser) {
return false;
}
@Override
public boolean isCrouching(Player player) {
return false;
}
@Override
@SuppressWarnings("deprecation")
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type, (byte)0);
}
}
@@ -1,46 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import java.util.List;
public class HullHiderWrapper8 implements HullHiderWrapper {
private static final Reflection.Constructor newMultiBlockChange = Reflection.getConstructor("net.minecraft.PacketPlayOutMultiBlockChange", int.class, short[].class, Reflection.getClass("net.minecraft.Chunk"));
private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle");
@Override
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
Hull.IntVector chunk = changes.get(0);
chunk = new Hull.IntVector(chunk.getX() >> 4, chunk.getY() >> 4, chunk.getZ() >> 4);
int xOffset = 16*chunk.getX();
int zOffset = 16*chunk.getZ();
short[] pos = new short[changes.size()];
for(int i = 0; i < changes.size(); i++) {
Hull.IntVector change = changes.get(i);
pos[i] = (short) (((change.getX()-xOffset) << 12) + ((change.getZ()-zOffset) << 8) + change.getY());
}
return newMultiBlockChange.invoke(pos.length, pos, getHandle.invoke(Config.world.getChunkAt(chunk.getX(), chunk.getZ())));
}
}
@@ -1,59 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
public class ReflectionWrapper8 implements ReflectionWrapper {
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket");
private static final Reflection.Field<List> explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0);
private static final Function<Object, Location> explosionLocation = HullHider.posPacketToLocation(packetPlayOutExplosion, double.class, 1.0);
@Override
public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) {
if(explosionBlocks.get(packet).isEmpty())
return packetHiderFunction.hide(player, packet, explosionLocation.apply(packet));
return packet;
}
private static final Class<?> itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack");
private static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
private static final Class<?> nbtTagCompound = Reflection.getClass("net.minecraft.nbt.CompoundTag");
private static final Reflection.Method getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound);
private static final Reflection.Method getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class);
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>((Set<String>) getKeys.invoke(getTag.invoke(asNMSCopy.invoke(null, stack))));
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}
@@ -1,40 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.Sound;
public class SWSound8 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.WITHER_DEATH;
case BLOCK_NOTE_BASS:
return Sound.NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.NOTE_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.EXPLODE;
default:
return null;
}
}
}
@@ -1,11 +0,0 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.TPSWarpUtils;
public class TpsWarper8 implements TpsWarper {
@Override
public void warp(float tps) {
TPSWarpUtils.warp(tps);
}
}
@@ -1,50 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper8 implements WorldOfColorWrapper {
@Override
public void setTeamColor(Team team, ChatColor color) {
team.setPrefix("§" + color.getChar());
}
@Override
public boolean isInBlock(Projectile e) {
return false;
}
@Override
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
location.getWorld().playSound(location, sound, volume, pitch);
}
@SuppressWarnings("deprecation")
@Override
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
player.sendTitle(title, subtitle);
}
}
@@ -1,145 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.NodeData;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPInputStream;
@SuppressWarnings("deprecation")
public class WorldeditWrapper8 implements WorldeditWrapper {
protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
protected static final Set<BaseBlock> colorBlocks = new HashSet<>();
static {
colorBlocks.add(new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE));
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE));
colorBlocks.add(new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE));
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE));
colorBlocks.add(new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE));
}
@Override
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
Vector minimum = clipboard.getRegion().getMinimumPoint();
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
colorBlocks.forEach(base -> replaceMap.put(base, new BaseBlock(base.getId(), c.getWoolData())));
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++){
Vector pos = minimum.add(x, y, z);
BaseBlock replacement = replaceMap.get(clipboard.getBlock(pos));
if(replacement != null)
clipboard.setBlock(pos, replacement);
}
}
}
}
@Override
public int getWaterDepth(Clipboard clipboard) {
Vector it = clipboard.getMinimumPoint().add(0, 0, 1);
int depth = 0;
while(!clipboard.getBlock(it).isAir()) {
depth++;
it = it.add(0, 1, 0);
}
return depth;
}
@Override
public void pasteClipboard(Clipboard clipboard, Location position, org.bukkit.util.Vector offset, AffineTransform aT) {
World w = new BukkitWorld(position.getWorld());
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add(
aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()))
).toBlockPoint()).build());
e.flushQueue();
}
@Override
public org.bukkit.util.Vector getDimensions(Clipboard clipboard) {
Vector dims = clipboard.getDimensions();
return new org.bukkit.util.Vector(dims.getBlockX(), dims.getBlockY(), dims.getBlockZ());
}
@Override
public Clipboard loadChar(String charName) throws IOException {
return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Config.world).getWorldData());
}
@Override
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
World w = new BukkitWorld(Config.world);
Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE));
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
);
Operations.complete(forwardExtentCopy);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
writer.write(clipboard, w.getWorldData());
writer.close();
} catch (IOException e) {
throw new SecurityException(e);
}
SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.MCEDIT);
}
}
@@ -1,30 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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 {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
compileOnly(project(":FightSystem:FightSystem_8", "default"))
compileOnly(libs.nms9)
}
@@ -1,170 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.scoreboard.Team;
import java.util.HashMap;
import java.util.Map;
public class BountifulWrapper9 implements BountifulWrapper {
private static final Class<?> enumHand = Reflection.getClass("net.minecraft.world.InteractionHand");
private static final Object mainHand = enumHand.getEnumConstants()[0];
private static final Reflection.Field<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0);
@Override
public boolean mainHand(Object packet) {
return blockPlaceHand.get(packet) == mainHand;
}
@Override
public boolean bowInHand(boolean mainHand, Player p) {
return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW;
}
@Override
public void setAttackSpeed(Player player) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
attribute.setBaseValue(16);
}
@Override
public void setNametagVisibility(Team team) {
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
@Override
public Listener newDenyArrowPickupListener() {
return new Listener() {
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
if(Fight.fighting(e.getPlayer()))
e.setCancelled(true);
}
};
}
@Override
public Listener newDenyHandSwapListener() {
return new Listener() {
@EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) {
if(Fight.fighting(event.getPlayer()))
event.setCancelled(true);
}
};
}
@Override
public void recordHandItems(Player player) {
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
}
@Override
public Listener newHandSwapRecorder() {
return new Listener() {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemSwap(PlayerSwapHandItemsEvent e){
if(Recording.isNotSent(e.getPlayer()))
return;
Player player = e.getPlayer();
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND");
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND");
}
};
}
@Override
public void spawnParticle(World world, String particleName, double x, double y, double z) {
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
}
private final Map<Player, BossBar> barMap = new HashMap<>();
@Override
public void sendBar(Player player, FightTeam team, double progress, String text) {
barMap.keySet().removeIf(p -> !p.isOnline());
if(!barMap.containsKey(player)) {
BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID);
barMap.put(player, bar);
bar.addPlayer(player);
}
BossBar bar = barMap.get(player);
BarColor color = chat2bar(team.getColor());
if(bar.getColor() != color)
bar.setColor(color);
if(bar.getProgress() != progress)
bar.setProgress(progress);
if(!bar.getTitle().equals(text))
bar.setTitle(text);
}
private BarColor chat2bar(ChatColor color) {
switch(color) {
case DARK_BLUE:
case DARK_AQUA:
case BLUE:
case AQUA:
return BarColor.BLUE;
case GREEN:
case DARK_GREEN:
return BarColor.GREEN;
case DARK_RED:
case RED:
return BarColor.RED;
case DARK_PURPLE:
return BarColor.PURPLE;
case GOLD:
case YELLOW:
return BarColor.YELLOW;
case LIGHT_PURPLE:
return BarColor.PINK;
case BLACK:
case WHITE:
case GRAY:
case DARK_GRAY:
default:
return BarColor.WHITE;
}
}
}
@@ -1,61 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_9_R2.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.stream.Stream;
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
}
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream();
}
@Override
public void setupGamerule() { }
}
@@ -1,40 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.utils;
import org.bukkit.Sound;
public class SWSound9 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound){
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
case BLOCK_NOTE_BASS:
return Sound.BLOCK_NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}
}
}
@@ -21,15 +21,20 @@ plugins {
steamwar.java
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
dependencies {
compileOnly(libs.classindex)
annotationProcessor(libs.classindex)
compileOnly(project(":SpigotCore", "default"))
compileOnly(libs.spigotapi)
compileOnly(libs.worldedit15)
compileOnly(libs.netty)
compileOnly(libs.paperapi21)
compileOnly(libs.fastutil)
compileOnly(libs.authlib)
compileOnly(libs.netty)
compileOnly(libs.nms21)
compileOnly(libs.fawe21)
}
@@ -19,7 +19,6 @@
package de.steamwar.fightsystem;
import de.steamwar.sql.GameModeConfig;
import de.steamwar.data.GameModeConfigUtils;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.winconditions.Winconditions;
@@ -23,7 +23,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
@@ -42,7 +42,6 @@ import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public class GUI {
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
@@ -26,7 +26,10 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.*;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -17,7 +17,6 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.core.TPSWarpUtils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,6 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.Commands;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
@@ -22,7 +22,6 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -35,10 +34,12 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
@@ -19,9 +19,16 @@
package de.steamwar.fightsystem.listener;
import java.util.HashSet;
import java.util.Set;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@@ -33,17 +40,8 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import java.util.HashSet;
import java.util.Set;
@Linked
public class Spectator implements Listener {
@@ -19,12 +19,6 @@
package de.steamwar.fightsystem.listener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.events.BoardingEvent;
@@ -37,6 +31,11 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class TeamArea implements Listener {
@@ -19,17 +19,35 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.linkage.Linked;
import org.bukkit.Location;
import org.bukkit.entity.WindCharge;
@Linked
public class WindchargeStopper {
static {
VersionDependent.getVersionImpl(FightSystem.getPlugin());
public WindchargeStopper() {
new StateDependentTask(true, FightState.Running, this::run, 1, 1);
}
public interface IWindchargeStopper {
private static final int middleLine = Config.SpecSpawn.getBlockZ();
private static final Class<?> windChargeClass = WindCharge.class;
private void run() {
Recording.iterateOverEntities(windChargeClass::isInstance, entity -> {
Location location = entity.getLocation();
Location prevLocation = location.clone().subtract(entity.getVelocity());
boolean passedMiddle = location.getBlockZ() > middleLine && prevLocation.getBlockZ() > middleLine ||
location.getBlockZ() < middleLine && prevLocation.getBlockZ() < middleLine;
if(!passedMiddle) {
entity.remove();
}
});
}
}
@@ -25,7 +25,9 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import java.io.*;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
@@ -329,7 +329,7 @@ public class PacketProcessor implements Listener {
ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1);
if(enchanted)
stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
stack.addUnsafeEnchantment(Enchantment.UNBREAKING, 1);
Object slot;
switch(slotName){
@@ -19,29 +19,63 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.Reflection;
import de.steamwar.core.VersionDependent;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.FightSystem;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public interface BlockIdWrapper {
Class<?> worldServer = Reflection.getClass("net.minecraft.server.level.ServerLevel");
Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", worldServer);
public class BlockIdWrapper {
public static final Class<?> worldServer = Reflection.getClass("net.minecraft.server.level.ServerLevel");
public static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", worldServer);
Class<?> craftPlayer = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer");
Class<?> entityPlayer = Reflection.getClass("net.minecraft.server.level.ServerPlayer");
Reflection.Method getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
public static final Class<?> craftPlayer = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer");
public static final Class<?> entityPlayer = Reflection.getClass("net.minecraft.server.level.ServerPlayer");
public static final Reflection.Method getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public static final BlockIdWrapper impl = new BlockIdWrapper();
Material idToMaterial(int blockState);
int blockToId(Block block);
void setBlock(World world, int x, int y, int z, int blockState);
public Material idToMaterial(int blockState) {
return CraftMagicNumbers.getMaterial(net.minecraft.world.level.block.Block.stateById(blockState)).getItemType();
}
void trackEntity(Player player, Entity entity);
void untrackEntity(Player player, Entity entity);
public int blockToId(Block block) {
return net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle());
}
public void setBlock(World world, int x, int y, int z, int blockState) {
BlockState blockData = net.minecraft.world.level.block.Block.stateById(blockState);
ServerLevel level = ((CraftWorld) world).getHandle();
BlockPos pos = new BlockPos(x, y, z);
level.removeBlockEntity(pos);
level.setBlock(pos, blockData, blockState);
level.getChunkSource().blockChanged(pos);
}
public void trackEntity(Player player, Entity entity) {
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
player.showEntity(FightSystem.getPlugin(), entity);
}
public void untrackEntity(Player player, Entity entity) {
player.hideEntity(FightSystem.getPlugin(), entity);
if(entity instanceof Player)
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
}
}
@@ -19,31 +19,143 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.World;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.scoreboard.Team;
public interface BountifulWrapper {
BountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
import java.util.HashMap;
import java.util.Map;
boolean mainHand(Object packet);
boolean bowInHand(boolean mainHand, Player p);
public class BountifulWrapper {
public static final BountifulWrapper impl = new BountifulWrapper();
void setAttackSpeed(Player player);
private static final Class<?> enumHand = Reflection.getClass("net.minecraft.world.InteractionHand");
private static final Object mainHand = enumHand.getEnumConstants()[0];
private static final Reflection.Field<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0);
void setNametagVisibility(Team team);
public boolean mainHand(Object packet) {
return blockPlaceHand.get(packet) == mainHand;
}
Listener newDenyArrowPickupListener();
Listener newDenyHandSwapListener();
public boolean bowInHand(boolean mainHand, Player p) {
return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW;
}
void recordHandItems(Player player);
Listener newHandSwapRecorder();
public void setAttackSpeed(Player player) {
AttributeInstance attribute = player.getAttribute(Attribute.ATTACK_SPEED);
attribute.setBaseValue(16);
}
void spawnParticle(World world, String particleName, double x, double y, double z);
public void setNametagVisibility(Team team) {
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
void sendBar(Player player, FightTeam team, double progress, String text);
public Listener newDenyArrowPickupListener() {
return new Listener() {
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
if(Fight.fighting(e.getPlayer()))
e.setCancelled(true);
}
};
}
public Listener newDenyHandSwapListener() {
return new Listener() {
@EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) {
if(Fight.fighting(event.getPlayer()))
event.setCancelled(true);
}
};
}
public void recordHandItems(Player player) {
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
}
public Listener newHandSwapRecorder() {
return new Listener() {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemSwap(PlayerSwapHandItemsEvent e){
if(Recording.isNotSent(e.getPlayer()))
return;
Player player = e.getPlayer();
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND");
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND");
}
};
}
public void spawnParticle(World world, String particleName, double x, double y, double z) {
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
}
private final Map<Player, BossBar> barMap = new HashMap<>();
public void sendBar(Player player, FightTeam team, double progress, String text) {
barMap.keySet().removeIf(p -> !p.isOnline());
if(!barMap.containsKey(player)) {
BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID);
barMap.put(player, bar);
bar.addPlayer(player);
}
BossBar bar = barMap.get(player);
BarColor color = chat2bar(team.getColor());
if(bar.getColor() != color)
bar.setColor(color);
if(bar.getProgress() != progress)
bar.setProgress(progress);
if(!bar.getTitle().equals(text))
bar.setTitle(text);
}
private BarColor chat2bar(ChatColor color) {
switch(color) {
case DARK_BLUE:
case DARK_AQUA:
case BLUE:
case AQUA:
return BarColor.BLUE;
case GREEN:
case DARK_GREEN:
return BarColor.GREEN;
case DARK_RED:
case RED:
return BarColor.RED;
case DARK_PURPLE:
return BarColor.PURPLE;
case GOLD:
case YELLOW:
return BarColor.YELLOW;
case LIGHT_PURPLE:
return BarColor.PINK;
case BLACK:
case WHITE:
case GRAY:
case DARK_GRAY:
default:
return BarColor.WHITE;
}
}
}
@@ -19,20 +19,65 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.entity.LevelEntityGetter;
import org.bukkit.Chunk;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Entity;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public interface CraftbukkitWrapper {
CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class CraftbukkitWrapper {
public static final CraftbukkitWrapper impl = new CraftbukkitWrapper();
void resetChunk(World world, World backup, int x, int z);
float headRotation(Entity e);
private static final Reflection.Method getWorld = Reflection.getMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle");
private static final Reflection.Method getChunk = Reflection.getTypedMethod(ServerLevel.class, null, LevelChunk.class, int.class, int.class);
private static final Reflection.Method getChunkSections = Reflection.getTypedMethod(LevelChunk.class, null, LevelChunkSection[].class);
private LevelChunkSection[] getChunkSections(World world, int x, int z) {
return (LevelChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
}
Stream<?> entityIterator();
private static final Reflection.Method getEntity = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
}
void setupGamerule();
public float headRotation(Entity e) {
return getEntity(e).getYHeadRot();
}
private static final Reflection.Method getWorldEntities = Reflection.getTypedMethod(ServerLevel.class, null, LevelEntityGetter.class);
private static final Reflection.Method getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
public Stream<?> entityIterator() {
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
}
public void setupGamerule() {
Config.world.setGameRule(GameRule.LOCATOR_BAR, false);
}
private LevelChunk getChunk(World world, int x, int z) {
return ((CraftWorld) world).getHandle().getChunk(x, z);
}
public void resetChunk(World world, World backup, int x, int z) {
LevelChunk worldChunk = getChunk(world, x, z);
LevelChunk backupChunk = getChunk(backup, x, z);
LevelChunkSection[] sections = worldChunk.getSections();
System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length);
Set<BlockPos> blocks = new HashSet<>(worldChunk.blockEntities.keySet());
blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity);
worldChunk.heightmaps.clear();
worldChunk.heightmaps.putAll(backupChunk.heightmaps);
}
}
@@ -19,36 +19,87 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.DyeColor;
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.block.data.type.Dispenser;
import org.bukkit.entity.Player;
import org.bukkit.entity.Pose;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta;
import org.bukkit.inventory.meta.ItemMeta;
public interface FlatteningWrapper {
FlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class FlatteningWrapper {
public static final FlatteningWrapper impl = new FlatteningWrapper();
DyeColor getSilver();
public DyeColor getSilver() {
return DyeColor.LIGHT_GRAY;
}
boolean isWater(Block block);
boolean removeWater(Block block);
public boolean isWater(Block block) {
if(block.getType() == Material.WATER)
return true;
boolean containsBlockMeta(ItemMeta meta);
boolean hasAttributeModifier(ItemStack stack);
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
boolean doRecord(BlockPhysicsEvent e);
return ((Waterlogged) data).isWaterlogged();
}
void forceLoadChunk(World world, int cX, int cZ);
public boolean removeWater(Block block) {
Material type = block.getType();
if(type == Material.WATER || type == Material.LAVA){
block.setType(Material.AIR);
return true;
}
boolean checkPistonMoving(Block block);
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
boolean isFacingWater(Block dispenser);
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
block.setType(Material.AIR);
return true;
}
boolean isCrouching(Player player);
void sendBlockChange(Player player, Block block, Material type);
return false;
}
public boolean containsBlockMeta(ItemMeta meta) {
return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData();
}
public boolean hasAttributeModifier(ItemStack stack) {
return stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers();
}
public boolean doRecord(BlockPhysicsEvent e) {
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
}
public void forceLoadChunk(World world, int cX, int cZ) {
world.setChunkForceLoaded(cX, cZ, true);
}
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.MOVING_PISTON;
}
public boolean isFacingWater(Block dispenser) {
return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid();
}
public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING;
}
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type.createBlockData());
}
}
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.core.Core;
import de.steamwar.entity.REntity;
import de.steamwar.fightsystem.Config;
@@ -49,7 +49,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
@@ -19,13 +19,54 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.Reflection;
import de.steamwar.fightsystem.Config;
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
import net.minecraft.world.level.block.state.BlockState;
import java.util.List;
public interface HullHiderWrapper {
HullHiderWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class HullHiderWrapper {
public static final HullHiderWrapper impl = new HullHiderWrapper();
Object generateBlockChangePacket(List<Hull.IntVector> changes);
private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", BlockState.class);
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
Object[] blockdata = new Object[changes.size()];
for(int i = 0; i < blockdata.length; i++) {
Hull.IntVector change = changes.get(i);
blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ()));
}
return generateBlockChangePacket(changes, blockdata);
}
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
if(changes.size() > 1) {
Hull.IntVector section = changes.get(0);
section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
int xOffset = 16*section.getX();
int yOffset = 16*section.getY();
int zOffset = 16*section.getZ();
short[] pos = new short[changes.size()];
for(int i = 0; i < changes.size(); i++) {
Hull.IntVector change = changes.get(i);
pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset));
}
return constructMultiBlockChange(section, pos, blockdata);
} else {
Hull.IntVector pos = changes.get(0);
return new ClientboundBlockUpdatePacket(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), (BlockState) blockdata[0]);
}
}
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
return new ClientboundSectionBlocksUpdatePacket(SectionPos.of(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
}
}
@@ -44,7 +44,7 @@ public class ItemBuilder {
}
public ItemBuilder enchant() {
meta.addEnchant(Enchantment.DURABILITY, 1, true);
meta.addEnchant(Enchantment.UNBREAKING, 1, true);
return this;
}
@@ -19,17 +19,59 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import io.papermc.paper.datacomponent.DataComponentType;
import io.papermc.paper.datacomponent.DataComponentTypes;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public interface ReflectionWrapper {
ReflectionWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
import java.util.HashSet;
import java.util.Set;
Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction);
boolean hasItems(ItemStack stack);
public class ReflectionWrapper {
public static final ReflectionWrapper impl = new ReflectionWrapper();
private static final Set<DataComponentType> FORBIDDEN_TYPES = new HashSet<>();
static {
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME);
FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE);
FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA);
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS);
FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA);
FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS);
FORBIDDEN_TYPES.add(DataComponentTypes.TOOL);
FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON);
FORBIDDEN_TYPES.add(DataComponentTypes.FOOD);
FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK);
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON);
FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE);
FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER);
FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN);
FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS);
FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES);
FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE);
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS);
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION);
FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE);
FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST);
FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE);
}
public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) {
return packet;
}
public boolean hasItems(ItemStack stack) {
FORBIDDEN_TYPES.forEach(stack::resetData);
return false;
}
public interface PacketHiderFunction {
Object hide(Player player, Object packet, Location location);
@@ -19,8 +19,6 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Sound;
public enum SWSound {
@@ -29,13 +27,18 @@ public enum SWSound {
BLOCK_NOTE_BASS,
ENTITY_GENERIC_EXPLODE;
private static final ISWSound impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public Sound getSound() {
return impl.getSound(this);
}
public interface ISWSound {
Sound getSound(SWSound sound);
switch(this){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
case BLOCK_NOTE_BASS:
return Sound.BLOCK_NOTE_BLOCK_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_BLOCK_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}
}
}
@@ -1,10 +1,11 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import net.minecraft.server.MinecraftServer;
public interface TpsWarper {
TpsWarper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class TpsWarper {
public static final TpsWarper impl = new TpsWarper();
void warp(float tps);
public void warp(float tps) {
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
}
}
@@ -19,22 +19,33 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.scoreboard.Team;
public interface WorldOfColorWrapper {
WorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class WorldOfColorWrapper {
public static final WorldOfColorWrapper impl = new WorldOfColorWrapper();
void setTeamColor(Team team, ChatColor color);
boolean isInBlock(Projectile e);
public void setTeamColor(Team team, ChatColor color) {
team.setColor(color);
}
void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);
public boolean isInBlock(Projectile e) {
if(e instanceof Arrow)
return ((Arrow) e).isInBlock();
return false;
}
void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop);
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
}
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
player.sendTitle(title, subtitle, start, hold, stop);
}
}
@@ -19,25 +19,131 @@
package de.steamwar.fightsystem.utils;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import de.steamwar.core.VersionDependent;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.NodeData;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public interface WorldeditWrapper {
WorldeditWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
public class WorldeditWrapper {
public static final WorldeditWrapper impl = new WorldeditWrapper();
void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;
int getWaterDepth(Clipboard clipboard);
void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
Vector getDimensions(Clipboard clipboard);
Clipboard loadChar(String charName) throws IOException;
void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException;
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
static {
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder");
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet");
}
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock()));
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
BlockVector3 pos = minimum.add(x, y, z);
BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
if(replacement != null)
clipboard.setBlock(pos, replacement);
}
}
}
}
public int getWaterDepth(Clipboard clipboard) {
BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1);
int depth = 0;
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
depth++;
it = it.add(0, 1, 0);
}
return depth;
}
public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) {
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
).toBlockPoint()).build());
e.flushSession();
}
public Vector getDimensions(Clipboard clipboard) {
BlockVector3 dims = clipboard.getDimensions();
return new Vector(dims.getX(), dims.getY(), dims.getZ());
}
public Clipboard loadChar(String charName) throws IOException {
File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem");
Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read();
}
return clipboard;
}
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
World w = new BukkitWorld(Config.world);
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
);
forwardExtentCopy.setCopyingEntities(false);
Operations.complete(forwardExtentCopy);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
writer.write(clipboard);
writer.close();
} catch (IOException e) {
throw new SecurityException(e);
}
SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2);
}
}
@@ -91,7 +91,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (
event.getEntityType() != EntityType.PRIMED_TNT ||
event.getEntityType() != EntityType.TNT ||
!team.getExtendRegion().inRegion(event.getEntity().getLocation()) ||
(!Config.GameModeConfig.WinConditionParams.PercentEntern && !Config.GameModeConfig.EnterStages.isEmpty() && Config.GameModeConfig.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
) {
@@ -29,13 +29,4 @@ tasks.build {
dependencies {
implementation(project(":SpigotCore"))
implementation(project(":FightSystem:FightSystem_Core"))
implementation(project(":FightSystem:FightSystem_8"))
implementation(project(":FightSystem:FightSystem_9"))
implementation(project(":FightSystem:FightSystem_10"))
implementation(project(":FightSystem:FightSystem_12"))
implementation(project(":FightSystem:FightSystem_14"))
implementation(project(":FightSystem:FightSystem_15"))
implementation(project(":FightSystem:FightSystem_18"))
implementation(project(":FightSystem:FightSystem_19"))
implementation(project(":FightSystem:FightSystem_20"))
}
-10
View File
@@ -28,16 +28,6 @@ tasks.build {
dependencies {
implementation(project(":FightSystem:FightSystem_Core"))
implementation(project(":FightSystem:FightSystem_8"))
implementation(project(":FightSystem:FightSystem_9"))
implementation(project(":FightSystem:FightSystem_10"))
implementation(project(":FightSystem:FightSystem_12"))
implementation(project(":FightSystem:FightSystem_14"))
implementation(project(":FightSystem:FightSystem_15"))
implementation(project(":FightSystem:FightSystem_18"))
implementation(project(":FightSystem:FightSystem_19"))
implementation(project(":FightSystem:FightSystem_20"))
implementation(project(":FightSystem:FightSystem_21"))
}
tasks.register<FightServer>("WarGear20") {