Commits vergleichen
90 Commits
Autor | SHA1 | Datum | |
---|---|---|---|
db23ae9cb6 | |||
b9f0039025 | |||
f5a150c203 | |||
bffbd2cc06 | |||
abb7df4e5c | |||
df2ced027b | |||
5394adfd14 | |||
52e3fd754e | |||
ac4babd44a | |||
447c8767f1 | |||
3bd54fcdbd | |||
0c947f0b5b | |||
c3bb34ed6b | |||
e0659c1bb2 | |||
f964f58d93 | |||
e3535c379a | |||
79413434f7 | |||
c17dc43678 | |||
7d7b6226a0 | |||
e0b6c1b931 | |||
39bff371a4 | |||
470f8613cd | |||
46e3c383bd | |||
ace26a7750 | |||
33a84d6a66 | |||
75af1f00ba | |||
2469f1bced | |||
5dfdb8e722 | |||
0db80a56a6 | |||
c8b9263b70 | |||
ba475457db | |||
9d3516152d | |||
053152f392 | |||
edc77ca2d4 | |||
f5419a1a77 | |||
169649204a | |||
e12a7ac7b4 | |||
918f309625 | |||
965bba1ea5 | |||
6d641856fe | |||
faebc3cace | |||
5d9aa147b7 | |||
ed1ab06ce1 | |||
869b883b2f | |||
0edbe4be94 | |||
90d8492d9a | |||
7f9cfe73f7 | |||
7fab960315 | |||
c18de054a8 | |||
6f4e0f0293 | |||
65028799b0 | |||
9b78103592 | |||
ce3384c7e9 | |||
8de15e0af5 | |||
5fab7e5404 | |||
4d5f4e9be6 | |||
29927985b1 | |||
a17bd4c401 | |||
5851d5019b | |||
5e8241605e | |||
0fb7a7b8ce | |||
0a45b161a2 | |||
|
4f65023491 | ||
ad7a42a685 | |||
6396264194 | |||
75152abc0b | |||
d140db2401 | |||
e8b263d841 | |||
|
2e8ad5301e | ||
|
c08cec7cf2 | ||
|
3ee7411591 | ||
|
c0665b1868 | ||
|
8d77f4dcf4 | ||
|
b3ad960973 | ||
ad5a2d4a08 | |||
ef8cdef05c | |||
86de472fe0 | |||
a8112eccc8 | |||
70c86f40c6 | |||
61eb28f78e | |||
7ad5a1dc22 | |||
256239c557 | |||
c87bac641e | |||
3f78a595c2 | |||
0c762e5624 | |||
4b82ea9426 | |||
7dd2cee635 | |||
2cb9c12e46 | |||
230169e163 | |||
cbd5fe407f |
@ -39,7 +39,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
|||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!FightWorld.isPaper()) {
|
if (!FightWorld.isPAPER()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
chunk.tileEntities.clear();
|
||||||
|
@ -39,7 +39,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
|||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!FightWorld.isPaper()) {
|
if (!FightWorld.isPAPER()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
chunk.tileEntities.clear();
|
||||||
|
@ -46,6 +46,8 @@ dependencies {
|
|||||||
implementation project(":FightSystem_9")
|
implementation project(":FightSystem_9")
|
||||||
implementation project(":FightSystem_8")
|
implementation project(":FightSystem_8")
|
||||||
|
|
||||||
|
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||||
|
|
||||||
compileOnly swdep("Spigot-1.14")
|
compileOnly swdep("Spigot-1.14")
|
||||||
compileOnly swdep("WorldEdit-1.15")
|
compileOnly swdep("WorldEdit-1.15")
|
||||||
compileOnly swdep("SpigotCore")
|
compileOnly swdep("SpigotCore")
|
||||||
|
@ -21,17 +21,31 @@ package de.steamwar.fightsystem.utils;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.core.Core;
|
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.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockIdWrapper14 implements BlockIdWrapper {
|
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||||
|
|
||||||
private static final Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
|
|
||||||
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
|
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
|
||||||
|
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
||||||
|
private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
|
||||||
|
private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
|
||||||
|
private static final Reflection.FieldAccessor<? 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("{nms.world.level.block}.Block");
|
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
|
||||||
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
|
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
|
||||||
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||||
|
|
||||||
|
private final Map trackers;
|
||||||
|
public BlockIdWrapper14() {
|
||||||
|
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
||||||
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
|
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
|
||||||
@Override
|
@Override
|
||||||
@ -40,11 +54,9 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
||||||
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
|
|
||||||
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
||||||
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
||||||
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
||||||
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
|
||||||
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||||
@ -56,4 +68,28 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
|
|||||||
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
||||||
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Class<?> entityTracker = Reflection.getClass("{nms.server.level}.PlayerChunkMap$EntityTracker");
|
||||||
|
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
|
||||||
|
@Override
|
||||||
|
public void trackEntity(Player player, int entity) {
|
||||||
|
Object tracker = trackers.get(entity);
|
||||||
|
if(tracker != null)
|
||||||
|
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
|
||||||
|
@Override
|
||||||
|
public void untrackEntity(Player player, int entity) {
|
||||||
|
Object tracker = trackers.get(entity);
|
||||||
|
if(tracker != null)
|
||||||
|
clearPlayer.invoke(tracker, getPlayer.invoke(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
|
||||||
|
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
||||||
|
@Override
|
||||||
|
public Material idToMaterial(int blockState) {
|
||||||
|
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
|||||||
|
|
||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!FightWorld.isPaper()) {
|
if (!FightWorld.isPAPER()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
chunk.tileEntities.clear();
|
||||||
|
@ -108,4 +108,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
|
|||||||
public boolean isCrouching(Player player) {
|
public boolean isCrouching(Player player) {
|
||||||
return player.getPose() == Pose.SWIMMING;
|
return player.getPose() == Pose.SWIMMING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendBlockChange(Player player, Block block, Material type) {
|
||||||
|
player.sendBlockChange(block.getLocation(), type.createBlockData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
|||||||
|
|
||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!FightWorld.isPaper()) {
|
if (!FightWorld.isPAPER()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
chunk.tileEntities.clear();
|
||||||
|
@ -48,6 +48,7 @@ dependencies {
|
|||||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||||
compileOnly 'com.mojang:authlib:1.5.25'
|
compileOnly 'com.mojang:authlib:1.5.25'
|
||||||
|
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||||
|
|
||||||
compileOnly swdep("Spigot-1.18")
|
compileOnly swdep("Spigot-1.18")
|
||||||
compileOnly swdep("WorldEdit-1.15")
|
compileOnly swdep("WorldEdit-1.15")
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.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 org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class HullHiderWrapper18 implements HullHiderWrapper {
|
||||||
|
|
||||||
|
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
|
||||||
|
@Override
|
||||||
|
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||||
|
List<Object> blockdata = new ArrayList<>(changes.size());
|
||||||
|
|
||||||
|
changes.removeIf(change -> {
|
||||||
|
BlockData data = Config.world.getBlockData(change.getX(), change.getY(), change.getZ());
|
||||||
|
boolean unchanged = data.getMaterial() == Config.ObfuscateWith || Config.HiddenBlocks.contains(data.getMaterial());
|
||||||
|
if(!unchanged)
|
||||||
|
blockdata.add(getState.invoke(data));
|
||||||
|
return unchanged;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(changes.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return generateBlockChangePacket(changes, blockdata.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@ dependencies {
|
|||||||
implementation project(":FightSystem_18")
|
implementation project(":FightSystem_18")
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||||
|
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||||
|
|
||||||
compileOnly swdep("Spigot-1.20")
|
compileOnly swdep("Spigot-1.20")
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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));
|
||||||
|
}
|
||||||
|
}
|
@ -19,10 +19,25 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class BlockIdWrapper8 implements BlockIdWrapper {
|
public class BlockIdWrapper8 implements BlockIdWrapper {
|
||||||
|
|
||||||
|
private static final Class<?> entityTracker = Reflection.getClass("{nms}.EntityTracker");
|
||||||
|
private static final Reflection.FieldAccessor<?> getEntityTracker = Reflection.getField(worldServer, entityTracker, 0);
|
||||||
|
private static final Class<?> intHashMap = Reflection.getClass("{nms}.IntHashMap");
|
||||||
|
private static final Reflection.FieldAccessor<?> getTrackedEntities = Reflection.getField(entityTracker, intHashMap, 0);
|
||||||
|
|
||||||
|
private final Object trackers;
|
||||||
|
public BlockIdWrapper8() {
|
||||||
|
trackers = getTrackedEntities.get(getEntityTracker.get(getWorldHandle.invoke(Config.world)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
@ -37,4 +52,31 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
|
|||||||
|
|
||||||
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Class<?> entityTrackerEntry = Reflection.getClass("{nms}.EntityTrackerEntry");
|
||||||
|
private static final Reflection.MethodInvoker get = Reflection.getTypedMethod(intHashMap, "get", Object.class, int.class);
|
||||||
|
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer);
|
||||||
|
@Override
|
||||||
|
public void trackEntity(Player player, int entity) {
|
||||||
|
Object tracker = get.invoke(trackers, entity);
|
||||||
|
if(tracker != null)
|
||||||
|
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer);
|
||||||
|
@Override
|
||||||
|
public void untrackEntity(Player player, int entity) {
|
||||||
|
Object tracker = get.invoke(trackers, entity);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,4 +83,10 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
|
|||||||
public boolean isCrouching(Player player) {
|
public boolean isCrouching(Player player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void sendBlockChange(Player player, Block block, Material type) {
|
||||||
|
player.sendBlockChange(block.getLocation(), type, (byte)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.Reflection;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HullHiderWrapper8 implements HullHiderWrapper {
|
||||||
|
|
||||||
|
private static final Reflection.ConstructorInvoker newMultiBlockChange = Reflection.getConstructor("{nms}.PacketPlayOutMultiBlockChange", int.class, short[].class, Reflection.getClass("{nms}.Chunk"));
|
||||||
|
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
|
||||||
|
@Override
|
||||||
|
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||||
|
changes.removeIf(change -> {
|
||||||
|
Material material = Config.world.getBlockAt(change.getX(), change.getY(), change.getZ()).getType();
|
||||||
|
return material == Config.ObfuscateWith || Config.HiddenBlocks.contains(material);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(changes.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
|||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!FightWorld.isPaper()) {
|
if (!FightWorld.isPAPER()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
chunk.tileEntities.clear();
|
||||||
|
@ -47,6 +47,9 @@ dependencies {
|
|||||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||||
compileOnly 'com.mojang:authlib:1.5.25'
|
compileOnly 'com.mojang:authlib:1.5.25'
|
||||||
|
|
||||||
|
compileOnly 'org.projectlombok:lombok:1.18.30'
|
||||||
|
annotationProcessor 'org.projectlombok:lombok:1.18.30'
|
||||||
|
|
||||||
compileOnly swdep("WorldEdit-1.15")
|
compileOnly swdep("WorldEdit-1.15")
|
||||||
compileOnly swdep("SpigotCore")
|
compileOnly swdep("SpigotCore")
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,14 @@ Schematic:
|
|||||||
z: 0
|
z: 0
|
||||||
# The schematic type that can be chosen in this arena
|
# The schematic type that can be chosen in this arena
|
||||||
Type: Normal # defaults to Normal if missing
|
Type: Normal # defaults to Normal if missing
|
||||||
|
# The schematic types that are also allowed to be chosen in this arena
|
||||||
|
SubTypes: [] # defaults to empty List
|
||||||
# Shortcut of the schematic type
|
# Shortcut of the schematic type
|
||||||
Shortcut: "" # defaults to "" if missing
|
Shortcut: "" # defaults to "" if missing
|
||||||
# Spigot (1.8) material for GUIs
|
# Spigot (1.8) material for GUIs
|
||||||
Material: STONE_BUTTON # defaults to STONE_BUTTON if missing
|
Material: STONE_BUTTON # defaults to STONE_BUTTON if missing
|
||||||
|
# Manual check of schematic necessary
|
||||||
|
ManualCheck: true # defaults to true if missing
|
||||||
# If the schematics should be rotated during pasting
|
# If the schematics should be rotated during pasting
|
||||||
Rotate: true # defaults to true if missing
|
Rotate: true # defaults to true if missing
|
||||||
# If the schematics should be pasted aligned to the borders instead of centered
|
# If the schematics should be pasted aligned to the borders instead of centered
|
||||||
@ -110,8 +114,6 @@ WinConditions: # defaults to none if missing
|
|||||||
# - CAPTAIN_DEAD
|
# - CAPTAIN_DEAD
|
||||||
|
|
||||||
# - PERCENT_SYSTEM
|
# - PERCENT_SYSTEM
|
||||||
# - WHITELIST_PERCENT
|
|
||||||
# - RELATIVE_PERCENT
|
|
||||||
# - POINTS
|
# - POINTS
|
||||||
# - POINTS_AIRSHIP
|
# - POINTS_AIRSHIP
|
||||||
|
|
||||||
@ -121,12 +123,18 @@ WinConditions: # defaults to none if missing
|
|||||||
|
|
||||||
# - HELLS_BELLS
|
# - HELLS_BELLS
|
||||||
# - METEOR
|
# - METEOR
|
||||||
|
# - PERSISTENT_DAMAGE
|
||||||
|
# - TNT_DISTRIBUTION
|
||||||
|
|
||||||
WinConditionParams:
|
WinConditionParams:
|
||||||
# The time of any of the timeout win conditions in seconds
|
# The time of any of the timeout win conditions in seconds
|
||||||
TimeoutTime: 1200 # defaults to 1200 if missing
|
TimeoutTime: 1200 # defaults to 1200 if missing
|
||||||
# The percentage when any of the percent win conditions limits or triggers a win
|
# The percentage when any of the percent win conditions limits or triggers a win
|
||||||
PercentWin: 7.0 # defaults to 7.0 if missing
|
PercentWin: 7.0 # defaults to 7.0 if missing
|
||||||
|
# Does the percentage still change after the start of the enter phase
|
||||||
|
PercentEntern: true # defaults to true if missing
|
||||||
|
# Is Blocks a whitelist (true) or blacklist (false)
|
||||||
|
BlocksWhitelist: false # defaults to false if missing
|
||||||
# Special Blocks (Valid spigot material values) used by the percent win conditions
|
# Special Blocks (Valid spigot material values) used by the percent win conditions
|
||||||
Blocks: [] # defaults to none if missing
|
Blocks: [] # defaults to none if missing
|
||||||
|
|
||||||
|
@ -21,10 +21,7 @@ package de.steamwar.fightsystem;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.*;
|
||||||
import de.steamwar.sql.EventFight;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -83,6 +80,7 @@ public class Config {
|
|||||||
public static final boolean OnlyPublicSchematics;
|
public static final boolean OnlyPublicSchematics;
|
||||||
public static final boolean IgnorePublicOnly;
|
public static final boolean IgnorePublicOnly;
|
||||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
public static final de.steamwar.sql.SchematicType SchematicType;
|
||||||
|
public static final List<de.steamwar.sql.SchematicType> SubTypes;
|
||||||
public static final boolean RedRotate;
|
public static final boolean RedRotate;
|
||||||
public static final boolean BlueRotate;
|
public static final boolean BlueRotate;
|
||||||
public static final boolean PasteAligned;
|
public static final boolean PasteAligned;
|
||||||
@ -106,6 +104,8 @@ public class Config {
|
|||||||
//win condition parameters
|
//win condition parameters
|
||||||
public static final int TimeoutTime;
|
public static final int TimeoutTime;
|
||||||
public static final double PercentWin;
|
public static final double PercentWin;
|
||||||
|
public static final boolean PercentEntern;
|
||||||
|
public static final boolean PercentBlocksWhitelist;
|
||||||
public static final Set<Material> PercentBlocks;
|
public static final Set<Material> PercentBlocks;
|
||||||
|
|
||||||
//default kits
|
//default kits
|
||||||
@ -117,13 +117,13 @@ public class Config {
|
|||||||
|
|
||||||
//tech hider parameter
|
//tech hider parameter
|
||||||
public static final boolean TechhiderActive;
|
public static final boolean TechhiderActive;
|
||||||
public static final Set<String> HiddenBlocks;
|
public static final Set<Material> HiddenBlocks;
|
||||||
public static final Set<String> HiddenBlockEntities;
|
public static final Set<String> HiddenBlockEntities;
|
||||||
public static final String ObfuscateWith;
|
public static final Material ObfuscateWith;
|
||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
private static final int EventKampfID;
|
|
||||||
public static final EventFight EventKampf;
|
public static final EventFight EventKampf;
|
||||||
|
private static final Set<Integer> Referees;
|
||||||
public static final int EventTeamBlueID;
|
public static final int EventTeamBlueID;
|
||||||
public static final int EventTeamRedID;
|
public static final int EventTeamRedID;
|
||||||
public static final boolean BothTeamsPublic;
|
public static final boolean BothTeamsPublic;
|
||||||
@ -138,10 +138,14 @@ public class Config {
|
|||||||
|
|
||||||
//replay system parameter
|
//replay system parameter
|
||||||
public static final String spectateIP = "127.0.0.1";
|
public static final String spectateIP = "127.0.0.1";
|
||||||
public static final int spectatePort = 2222;
|
public static final int SpectatePort;
|
||||||
public static final int ReplayID;
|
public static final int ReplayID;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
|
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||||
|
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||||
|
|
||||||
String configFile = System.getProperty("config", "config.yml");
|
String configFile = System.getProperty("config", "config.yml");
|
||||||
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
||||||
FightSystem.getPlugin().saveDefaultConfig();
|
FightSystem.getPlugin().saveDefaultConfig();
|
||||||
@ -181,6 +185,7 @@ public class Config {
|
|||||||
int schemsizeZ = config.getInt("Schematic.Size.z");
|
int schemsizeZ = config.getInt("Schematic.Size.z");
|
||||||
RanksEnabled = !config.getStringList("Ranks").isEmpty();
|
RanksEnabled = !config.getStringList("Ranks").isEmpty();
|
||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
|
||||||
|
SubTypes = config.getStringList("Schematic.SubTypes").stream().map(de.steamwar.sql.SchematicType::fromDB).collect(Collectors.toList());
|
||||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
|
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
|
||||||
boolean rotate = config.getBoolean("Schematic.Rotate", true);
|
boolean rotate = config.getBoolean("Schematic.Rotate", true);
|
||||||
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
|
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
|
||||||
@ -195,6 +200,8 @@ public class Config {
|
|||||||
|
|
||||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime", 1200);
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime", 1200);
|
||||||
PercentWin = config.getDouble("WinConditionParams.PercentWin", 7.0);
|
PercentWin = config.getDouble("WinConditionParams.PercentWin", 7.0);
|
||||||
|
PercentEntern = config.getBoolean("WinConditionParams.PercentEntern", true);
|
||||||
|
PercentBlocksWhitelist = config.getBoolean("WinConditionParams.BlocksWhitelist", false);
|
||||||
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||||
|
|
||||||
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
||||||
@ -207,8 +214,8 @@ public class Config {
|
|||||||
ForbiddenItems = Collections.unmodifiableSet(config.getStringList("Kits.ForbiddenItems").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
ForbiddenItems = Collections.unmodifiableSet(config.getStringList("Kits.ForbiddenItems").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||||
|
|
||||||
TechhiderActive = config.getBoolean("Techhider.Active", false);
|
TechhiderActive = config.getBoolean("Techhider.Active", false);
|
||||||
ObfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase();
|
ObfuscateWith = Material.getMaterial(config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase());
|
||||||
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
HiddenBlocks = config.getStringList("Techhider.HiddenBlocks").stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet());
|
||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
@ -303,25 +310,25 @@ public class Config {
|
|||||||
RedRotate = teamRedRotate;
|
RedRotate = teamRedRotate;
|
||||||
BlueRotate = teamBlueRotate;
|
BlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
|
|
||||||
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
||||||
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
||||||
ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
||||||
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ);
|
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(EventKampfID >= 1){
|
if(eventKampfID >= 1){
|
||||||
EventFight eventFight = EventFight.get(EventKampfID);
|
EventKampf = EventFight.get(eventKampfID);
|
||||||
if(eventFight == null){
|
if(EventKampf == null){
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert eventFight != null;
|
assert EventKampf != null;
|
||||||
Team team1 = Team.get(eventFight.getTeamBlue());
|
Team team1 = Team.get(EventKampf.getTeamBlue());
|
||||||
Team team2 = Team.get(eventFight.getTeamRed());
|
Team team2 = Team.get(EventKampf.getTeamRed());
|
||||||
|
|
||||||
if(team1 == null || team2 == null){
|
if(team1 == null || team2 == null){
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
||||||
@ -337,9 +344,11 @@ public class Config {
|
|||||||
EventTeamBlueID = team1.getTeamId();
|
EventTeamBlueID = team1.getTeamId();
|
||||||
EventTeamRedID = team2.getTeamId();
|
EventTeamRedID = team2.getTeamId();
|
||||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||||
EventKampf = eventFight;
|
SpectatePort = EventKampf.getSpectatePort();
|
||||||
|
LiveReplay = SpectatePort != 0;
|
||||||
|
Referees = Referee.get(Config.EventKampf.getEventID());
|
||||||
|
|
||||||
Event event = Event.get(eventFight.getEventID());
|
Event event = Event.get(EventKampf.getEventID());
|
||||||
if(BothTeamsPublic) {
|
if(BothTeamsPublic) {
|
||||||
OnlyPublicSchematics = true;
|
OnlyPublicSchematics = true;
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||||
@ -347,7 +356,6 @@ public class Config {
|
|||||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||||
}
|
}
|
||||||
LiveReplay = event.spectateSystem();
|
|
||||||
}else{
|
}else{
|
||||||
//No event
|
//No event
|
||||||
TeamRedColor = config.getString("Red.Prefix", "§c");
|
TeamRedColor = config.getString("Red.Prefix", "§c");
|
||||||
@ -359,8 +367,10 @@ public class Config {
|
|||||||
EventTeamRedID = 0;
|
EventTeamRedID = 0;
|
||||||
EventKampf = null;
|
EventKampf = null;
|
||||||
BothTeamsPublic = true;
|
BothTeamsPublic = true;
|
||||||
|
Referees = Collections.emptySet();
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||||
LiveReplay = false;
|
LiveReplay = false;
|
||||||
|
SpectatePort = -ReplayID;
|
||||||
}
|
}
|
||||||
|
|
||||||
String blueLeader = System.getProperty("blueLeader", null);
|
String blueLeader = System.getProperty("blueLeader", null);
|
||||||
@ -374,17 +384,13 @@ public class Config {
|
|||||||
else
|
else
|
||||||
RedLeader = null;
|
RedLeader = null;
|
||||||
|
|
||||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
|
||||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
|
||||||
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
|
||||||
|
|
||||||
if(CheckSchemID != 0){
|
if(CheckSchemID != 0){
|
||||||
mode = ArenaMode.CHECK;
|
mode = ArenaMode.CHECK;
|
||||||
}else if(PrepareSchemID != 0){
|
}else if(PrepareSchemID != 0){
|
||||||
mode = ArenaMode.PREPARE;
|
mode = ArenaMode.PREPARE;
|
||||||
}else if(EventKampfID >= 1){
|
}else if(eventKampfID >= 1){
|
||||||
mode = ArenaMode.EVENT;
|
mode = ArenaMode.EVENT;
|
||||||
}else if(EventKampfID == -1){
|
}else if(eventKampfID == -1){
|
||||||
mode = ArenaMode.TEST;
|
mode = ArenaMode.TEST;
|
||||||
}else if(ReplayID != 0){
|
}else if(ReplayID != 0){
|
||||||
mode = ArenaMode.REPLAY;
|
mode = ArenaMode.REPLAY;
|
||||||
@ -397,15 +403,13 @@ public class Config {
|
|||||||
return ArenaMode.Test.contains(mode);
|
return ArenaMode.Test.contains(mode);
|
||||||
}
|
}
|
||||||
public static boolean replayserver(){
|
public static boolean replayserver(){
|
||||||
return ReplayID == -1;
|
return ReplayID < 0;
|
||||||
}
|
}
|
||||||
public static boolean blueNegZ(){
|
public static boolean blueNegZ(){
|
||||||
return BlueToRedZ > 0;
|
return BlueToRedZ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReferee(Player player) {
|
public static boolean isReferee(Player player) {
|
||||||
if(EventKampf == null)
|
return Referees.contains(SteamwarUser.get(player.getUniqueId()).getId());
|
||||||
return false;
|
|
||||||
return SteamwarUser.get(player.getUniqueId()).getId() == EventKampf.getKampfleiter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,12 @@ package de.steamwar.fightsystem;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.ai.LixfelAI;
|
|
||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.event.HellsBells;
|
import de.steamwar.fightsystem.event.HellsBells;
|
||||||
import de.steamwar.fightsystem.event.Meteor;
|
import de.steamwar.fightsystem.event.Meteor;
|
||||||
|
import de.steamwar.fightsystem.event.PersistentDamage;
|
||||||
|
import de.steamwar.fightsystem.event.TNTDistributor;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
@ -38,21 +39,25 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
|
|||||||
import de.steamwar.fightsystem.record.LiveRecorder;
|
import de.steamwar.fightsystem.record.LiveRecorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class FightSystem extends JavaPlugin {
|
public class FightSystem extends JavaPlugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
|
|
||||||
private Message message;
|
private Message message;
|
||||||
private FightTeam lastWinner;
|
private FightTeam lastWinner;
|
||||||
private String lastWinreason;
|
private String lastWinreason;
|
||||||
private TechHiderWrapper techHider;
|
private TechHiderWrapper techHider;
|
||||||
|
private HullHider hullHider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
@ -79,7 +84,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
new Chat();
|
new Chat();
|
||||||
new ArenaBorder();
|
new ArenaBorder();
|
||||||
new TeamArea();
|
|
||||||
new IngameDeath();
|
new IngameDeath();
|
||||||
new InFightDamage();
|
new InFightDamage();
|
||||||
new InFightInventory();
|
new InFightInventory();
|
||||||
@ -96,7 +100,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new RunningWorldInteraction();
|
new RunningWorldInteraction();
|
||||||
new PersonalKitCreator();
|
new PersonalKitCreator();
|
||||||
new ArrowStopper();
|
new ArrowStopper();
|
||||||
new ArrowPickup();
|
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
||||||
new BlockFadeListener();
|
new BlockFadeListener();
|
||||||
new LeaveableArena();
|
new LeaveableArena();
|
||||||
new ClickAnalyzer();
|
new ClickAnalyzer();
|
||||||
@ -107,6 +111,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new EnterHandler();
|
new EnterHandler();
|
||||||
techHider = new TechHiderWrapper();
|
techHider = new TechHiderWrapper();
|
||||||
|
hullHider = new HullHider();
|
||||||
new FightWorld();
|
new FightWorld();
|
||||||
new FightUI();
|
new FightUI();
|
||||||
new FightStatistics();
|
new FightStatistics();
|
||||||
@ -116,9 +121,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new WinconditionCaptainDead();
|
new WinconditionCaptainDead();
|
||||||
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
||||||
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
|
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
|
||||||
new WinconditionPercentSystem();
|
new WinconditionPercent(Winconditions.PERCENT_SYSTEM, "Percent");
|
||||||
new WinconditionBlacklistPercent();
|
|
||||||
new WinconditionWhitelistPercent();
|
|
||||||
new WinconditionPoints();
|
new WinconditionPoints();
|
||||||
new WinconditionPointsAirShip();
|
new WinconditionPointsAirShip();
|
||||||
new WinconditionTimeout();
|
new WinconditionTimeout();
|
||||||
@ -129,6 +132,8 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new HellsBells();
|
new HellsBells();
|
||||||
new Meteor();
|
new Meteor();
|
||||||
|
new PersistentDamage();
|
||||||
|
new TNTDistributor();
|
||||||
new WinconditionAmongUs();
|
new WinconditionAmongUs();
|
||||||
|
|
||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
@ -152,6 +157,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new LockschemCommand();
|
new LockschemCommand();
|
||||||
new StateCommand();
|
new StateCommand();
|
||||||
new SkipCommand();
|
new SkipCommand();
|
||||||
|
new TPSWarpCommand();
|
||||||
new UnrankCommand();
|
new UnrankCommand();
|
||||||
new WinCommand();
|
new WinCommand();
|
||||||
|
|
||||||
@ -163,7 +169,15 @@ public class FightSystem extends JavaPlugin {
|
|||||||
if(Config.mode == ArenaMode.EVENT) {
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
}else if(Config.mode == ArenaMode.CHECK){
|
}else if(Config.mode == ArenaMode.CHECK){
|
||||||
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
|
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
|
||||||
|
Fight.getBlueTeam().setSchem(checkSchematicNode);
|
||||||
|
|
||||||
|
if (checkSchematicNode.getName().endsWith("-prepared")) {
|
||||||
|
SchematicNode unpreparedSchematicNode = SchematicNode.getSchematicNode(checkSchematicNode.getOwner(), checkSchematicNode.getName().substring(0, checkSchematicNode.getName().length() - 9), checkSchematicNode.getParent());
|
||||||
|
if (unpreparedSchematicNode != null) {
|
||||||
|
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||||
}
|
}
|
||||||
@ -183,15 +197,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightSystem getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void broadcast(String msg, Object... params) {
|
|
||||||
getMessage().broadcast(msg, params);
|
|
||||||
GlobalRecorder.getInstance().system(msg, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Message getMessage() {
|
public static Message getMessage() {
|
||||||
return plugin.message;
|
return plugin.message;
|
||||||
}
|
}
|
||||||
@ -208,6 +213,10 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return plugin.techHider;
|
return plugin.techHider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HullHider getHullHider() {
|
||||||
|
return plugin.hullHider;
|
||||||
|
}
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
//Staggered kick to prevent lobby overloading
|
//Staggered kick to prevent lobby overloading
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty()){
|
if(Bukkit.getOnlinePlayers().isEmpty()){
|
||||||
|
@ -51,6 +51,9 @@ INFO_RANKED=§7Ranked§8: §e{0}
|
|||||||
INFO_LEADER=§7Leader {0}§8: {1}
|
INFO_LEADER=§7Leader {0}§8: {1}
|
||||||
INFO_SCHEMATIC=§7Schematic {0}§8: §e{1} §7from {2}, Rank: {3}
|
INFO_SCHEMATIC=§7Schematic {0}§8: §e{1} §7from {2}, Rank: {3}
|
||||||
|
|
||||||
|
TPSWARP_HELP=§8/§7tpswarp §8[§eticks per second§8]
|
||||||
|
TPSWARP_SET=§7TPS set to §e{0}
|
||||||
|
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
STATE_TITLE=Fight state
|
STATE_TITLE=Fight state
|
||||||
@ -75,6 +78,7 @@ KITSEARCH_TITLE=Search for kit
|
|||||||
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
||||||
SCHEM_TITLE={0} selection
|
SCHEM_TITLE={0} selection
|
||||||
SCHEM_PUBLIC=§ePublic {0}
|
SCHEM_PUBLIC=§ePublic {0}
|
||||||
|
SCHEM_UNCHECKED=§eUnchecked {0}
|
||||||
SCHEM_PRIVATE=§ePrivate {0}
|
SCHEM_PRIVATE=§ePrivate {0}
|
||||||
SCHEM_NO_PRIVATE=§7No private {0} present
|
SCHEM_NO_PRIVATE=§7No private {0} present
|
||||||
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
|
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
|
||||||
@ -99,6 +103,7 @@ SPECTATE_COUNTDOWN=until the arena is reset
|
|||||||
# Fight
|
# Fight
|
||||||
SCHEMATIC_UNLOADABLE=§cUnable to load schematic
|
SCHEMATIC_UNLOADABLE=§cUnable to load schematic
|
||||||
SCHEMATIC_CHOSEN=§7{0} §e{1} §7chosen
|
SCHEMATIC_CHOSEN=§7{0} §e{1} §7chosen
|
||||||
|
SCHEMATIC_UNCHECKED=§7Team {0} §7has chosen an §eunchecked §7schematic§8!
|
||||||
TEAM_READY=§aTeam ready
|
TEAM_READY=§aTeam ready
|
||||||
TEAM_NOT_READY=§c§mTeam ready
|
TEAM_NOT_READY=§c§mTeam ready
|
||||||
SKIP_READY=§aSkipping to next event
|
SKIP_READY=§aSkipping to next event
|
||||||
|
@ -45,6 +45,9 @@ REMOVE_HELP=§8/§eremove §8[§eSpieler§8]
|
|||||||
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
|
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
|
||||||
WIN_HELP=§8/§7win §8[§eTeam §8oder §etie§8]
|
WIN_HELP=§8/§7win §8[§eTeam §8oder §etie§8]
|
||||||
|
|
||||||
|
TPSWARP_HELP=§8/§7tpswarp §8[§eTicks pro Sekunde§8]
|
||||||
|
TPSWARP_SET=§7TPS auf §e{0} §7gesetzt
|
||||||
|
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
STATE_TITLE=Kampfstatus
|
STATE_TITLE=Kampfstatus
|
||||||
@ -69,6 +72,7 @@ KITSEARCH_TITLE=Nach Kit suchen
|
|||||||
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
||||||
SCHEM_TITLE={0}-Auswahl
|
SCHEM_TITLE={0}-Auswahl
|
||||||
SCHEM_PUBLIC=§eÖffentliches {0}
|
SCHEM_PUBLIC=§eÖffentliches {0}
|
||||||
|
SCHEM_UNCHECKED=§eUngeprüftes {0}
|
||||||
SCHEM_PRIVATE=§ePrivates {0}
|
SCHEM_PRIVATE=§ePrivates {0}
|
||||||
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
|
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
|
||||||
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
|
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
|
||||||
@ -93,6 +97,7 @@ SPECTATE_COUNTDOWN=bis die Arena zurückgesetzt wird
|
|||||||
# Fight
|
# Fight
|
||||||
SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden
|
SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden
|
||||||
SCHEMATIC_CHOSEN=§7{0} §e{1} §7gewählt
|
SCHEMATIC_CHOSEN=§7{0} §e{1} §7gewählt
|
||||||
|
SCHEMATIC_UNCHECKED=§7Team {0} §7hat eine §eungeprüfte §7Schematic gewählt§8!
|
||||||
TEAM_READY=§aTeam bereit
|
TEAM_READY=§aTeam bereit
|
||||||
TEAM_NOT_READY=§c§mTeam bereit
|
TEAM_NOT_READY=§c§mTeam bereit
|
||||||
SKIP_READY=§aBeschleunigung zum nächsten Event
|
SKIP_READY=§aBeschleunigung zum nächsten Event
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class CommandInjector {
|
|
||||||
|
|
||||||
private CommandInjector(){}
|
|
||||||
|
|
||||||
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
|
|
||||||
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);
|
|
||||||
|
|
||||||
public static void injectCommand(Command cmd) throws Exception {
|
|
||||||
Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
|
|
||||||
Field f1 = serverClass.getDeclaredField("commandMap");
|
|
||||||
f1.setAccessible(true);
|
|
||||||
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
|
|
||||||
commandMap.register("BauSystem", cmd);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
@ -28,12 +29,20 @@ import de.steamwar.fightsystem.fight.Kit;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
public class Commands {
|
public class Commands {
|
||||||
private Commands(){}
|
|
||||||
|
private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
|
||||||
|
public static void injectCommand(Command cmd) {
|
||||||
|
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
private static void errNoTeam(Player p){
|
private static void errNoTeam(Player p){
|
||||||
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.*;
|
import de.steamwar.fightsystem.fight.*;
|
||||||
@ -29,6 +30,7 @@ import de.steamwar.inventory.*;
|
|||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -48,7 +50,8 @@ public class GUI {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
||||||
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
|
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
|
||||||
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> {
|
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
|
||||||
|
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
new JoinRequest(p, team);
|
new JoinRequest(p, team);
|
||||||
});
|
});
|
||||||
@ -167,27 +170,47 @@ public class GUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName));
|
int invSize = (Config.SubTypes.size() + 1) * 9;
|
||||||
inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> {
|
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
|
||||||
p.closeInventory();
|
setupSchemTypeRow(p, inv, Config.SchematicType, 0);
|
||||||
schemDialog(p, true);
|
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
||||||
});
|
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
||||||
if(Fight.getMaxRank() == 0){
|
|
||||||
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, Config.GameName), (ClickType click)->{});
|
|
||||||
}else if(SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB()).isEmpty() && !Config.test()){
|
|
||||||
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, Config.GameName), (ClickType click)->{});
|
|
||||||
}else{
|
|
||||||
inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, Config.GameName), (ClickType click) -> {
|
|
||||||
p.closeInventory();
|
|
||||||
schemDialog(p, false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void schemDialog(Player p, boolean publicSchems){
|
private static void setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) {
|
||||||
SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(Config.SchematicType, Fight.getMaxRank()), node -> {
|
inv.setItem(row * 9 + 8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, type.name()), (ClickType click) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
schemDialog(p, type, true, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Fight.publicOnly()) {
|
||||||
|
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, type.name()), (ClickType click)->{});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(Config.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
|
||||||
|
inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, type.name()), (ClickType click) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
schemDialog(p, type, false, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) {
|
||||||
|
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click)->{});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
inv.setItem(row * 9, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, type.name()), (ClickType click) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
schemDialog(p, type, false, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
|
||||||
|
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||||
if(fightTeam == null)
|
if(fightTeam == null)
|
||||||
return;
|
return;
|
||||||
|
@ -47,10 +47,10 @@ public class GamemodeCommand extends BukkitCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeAll("gamemode");
|
CommandRemover.removeAll("gamemode");
|
||||||
CommandInjector.injectCommand(this);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
}
|
}
|
||||||
|
Commands.injectCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class LockschemCommand implements CommandExecutor {
|
public class LockschemCommand implements CommandExecutor {
|
||||||
|
|
||||||
public LockschemCommand() {
|
public LockschemCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
|
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.core.TPSWarpUtils;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class TPSWarpCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public TPSWarpCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
|
||||||
|
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
double tps;
|
||||||
|
try {
|
||||||
|
tps = Double.parseDouble(args[0]);
|
||||||
|
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
||||||
|
FightSystem.getMessage().send("TPSWARP_HELP", sender);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TPSWarpUtils.warp(tps);
|
||||||
|
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -83,8 +83,6 @@ public abstract class Countdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Countdown countdown : new ArrayList<>(currentCountdowns)) {
|
for(Countdown countdown : new ArrayList<>(currentCountdowns)) {
|
||||||
if(countdown.time - smallestTime <= 1)
|
|
||||||
countdown.prepareFinish();
|
|
||||||
countdown.time -= smallestTime;
|
countdown.time -= smallestTime;
|
||||||
countdown.show();
|
countdown.show();
|
||||||
}
|
}
|
||||||
@ -104,8 +102,6 @@ public abstract class Countdown {
|
|||||||
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
|
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prepareFinish() {}
|
|
||||||
|
|
||||||
public int getTimeLeft(){
|
public int getTimeLeft(){
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
@ -124,7 +120,6 @@ public abstract class Countdown {
|
|||||||
broadcast("COUNTDOWN_SECONDS", 1);
|
broadcast("COUNTDOWN_SECONDS", 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
prepareFinish();
|
|
||||||
broadcast("COUNTDOWN_SECOND", 1);
|
broadcast("COUNTDOWN_SECOND", 1);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -21,21 +21,23 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import de.steamwar.techhider.ProtocolUtils;
|
import de.steamwar.techhider.ProtocolUtils;
|
||||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EnternCountdown extends Countdown {
|
public class EnternCountdown extends Countdown {
|
||||||
|
|
||||||
private static int calcTime(FightPlayer fp) {
|
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
||||||
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
|
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
|
||||||
|
|
||||||
Countdown countdown = Wincondition.getTimeOverCountdown();
|
|
||||||
if(countdown != null) {
|
if(countdown != null) {
|
||||||
time -= Config.TimeoutTime - countdown.getTimeLeft();
|
time -= Config.TimeoutTime - countdown.getTimeLeft();
|
||||||
|
|
||||||
@ -49,21 +51,20 @@ public class EnternCountdown extends Countdown {
|
|||||||
private final FightPlayer fightPlayer;
|
private final FightPlayer fightPlayer;
|
||||||
private List<ProtocolUtils.ChunkPos> chunkPos;
|
private List<ProtocolUtils.ChunkPos> chunkPos;
|
||||||
|
|
||||||
public EnternCountdown(FightPlayer fp) {
|
public EnternCountdown(FightPlayer fp, Countdown countdown) {
|
||||||
super(calcTime(fp), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||||
fightPlayer = fp;
|
fightPlayer = fp;
|
||||||
enable();
|
enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
|
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
|
||||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
|
||||||
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunkPos, false));
|
fightPlayer.ifPlayer(player -> {
|
||||||
}
|
FightSystem.getHullHider().updatePlayer(player);
|
||||||
|
FightSystem.getTechHider().reloadChunks(player, Fight.getOpposite(fightPlayer.getTeam()).getExtendRegion(), Region.EMPTY);
|
||||||
@Override
|
});
|
||||||
protected void prepareFinish() {
|
|
||||||
chunkPos = FightSystem.getTechHider().prepareChunkReload(fightPlayer.getEntity(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.event;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
|
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||||
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class PersistentDamage {
|
||||||
|
|
||||||
|
public PersistentDamage() {
|
||||||
|
if(!ArenaMode.SeriousFight.contains(Config.mode))
|
||||||
|
return;
|
||||||
|
|
||||||
|
new OneShotStateDependent(Winconditions.PERSISTENT_DAMAGE, FightState.Spectate, () -> Fight.teams().forEach(team -> {
|
||||||
|
try{
|
||||||
|
WorldeditWrapper.impl.saveSchem(SchematicNode.getSchematicNode(team.getSchematic()), team.getExtendRegion(), team.getSchemRegion().getMinY());
|
||||||
|
}catch(WorldEditException e){
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not persist schematic state", e);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.event;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class TNTDistributor {
|
||||||
|
|
||||||
|
public TNTDistributor() {
|
||||||
|
new StateDependentTask(Winconditions.TNT_DISTRIBUTION, FightState.Running, () -> Fight.teams().forEach(team -> team.getPlayers().forEach(fp -> {
|
||||||
|
if(!fp.isLiving())
|
||||||
|
return;
|
||||||
|
|
||||||
|
fp.ifPlayer(player -> player.getInventory().addItem(new ItemStack(Material.TNT, 20)));
|
||||||
|
})), 300, 300);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.events;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BoardingEvent extends Event {
|
||||||
|
@Getter
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
|
||||||
|
private final FightPlayer fightPlayer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.events;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TeamDeathEvent extends Event {
|
||||||
|
@Getter
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
|
||||||
|
private final FightPlayer fightPlayer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.events;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TeamLeaveEvent extends Event {
|
||||||
|
@Getter
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
|
||||||
|
private final FightPlayer fightPlayer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.events;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TeamSpawnEvent extends Event {
|
||||||
|
@Getter
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
|
||||||
|
private final FightPlayer fightPlayer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -21,11 +21,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.ProtocolWrapper;
|
import de.steamwar.core.ProtocolWrapper;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -38,7 +40,9 @@ import java.util.HashSet;
|
|||||||
public class Fight {
|
public class Fight {
|
||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||||
|
@Getter
|
||||||
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
||||||
private static final Collection<FightTeam> teams = new HashSet<>();
|
private static final Collection<FightTeam> teams = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
@ -75,14 +79,6 @@ public class Fight {
|
|||||||
return getPlayerTeam(player) != null;
|
return getPlayerTeam(player) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightTeam getRedTeam() {
|
|
||||||
return redTeam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightTeam getBlueTeam() {
|
|
||||||
return blueTeam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Collection<FightTeam> teams() {
|
public static Collection<FightTeam> teams() {
|
||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
@ -94,7 +90,10 @@ public class Fight {
|
|||||||
public static void playSound(Sound sound, float volume, float pitch) {
|
public static void playSound(Sound sound, float volume, float pitch) {
|
||||||
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
||||||
//volume: max. 100, pitch: max. 2
|
//volume: max. 100, pitch: max. 2
|
||||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
if(Core.getVersion() >= 18)
|
||||||
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
|
||||||
|
else
|
||||||
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightTeam getTeamByName(String name) {
|
public static FightTeam getTeamByName(String name) {
|
||||||
@ -124,7 +123,7 @@ public class Fight {
|
|||||||
if(!player.isOnline())
|
if(!player.isOnline())
|
||||||
return;
|
return;
|
||||||
pseudoSpectator(player, true);
|
pseudoSpectator(player, true);
|
||||||
}, 2);
|
}, 1);
|
||||||
}else if(gameMode == GameMode.SURVIVAL) {
|
}else if(gameMode == GameMode.SURVIVAL) {
|
||||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||||
@ -139,21 +138,16 @@ public class Fight {
|
|||||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
|
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxRank(){
|
public static boolean publicOnly() {
|
||||||
/* MaxRank of 0 is Pubonly*/
|
if (Config.OnlyPublicSchematics) {
|
||||||
if(Config.OnlyPublicSchematics){
|
return true;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
|
||||||
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
|
return false;
|
||||||
return 1000;
|
|
||||||
}
|
}
|
||||||
|
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
|
||||||
|
return false;
|
||||||
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
|
|
||||||
return 1000;
|
|
||||||
}
|
}
|
||||||
|
return redTeam.isPublicsOnly() || blueTeam.isPublicsOnly();
|
||||||
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.ai.AI;
|
import de.steamwar.fightsystem.ai.AI;
|
||||||
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||||
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -34,9 +38,13 @@ public class FightPlayer {
|
|||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private LivingEntity entity;
|
private LivingEntity entity;
|
||||||
|
@Getter
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private boolean isOut;
|
private boolean isOut;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private Kit kit;
|
private Kit kit;
|
||||||
|
@Getter
|
||||||
private int kills;
|
private int kills;
|
||||||
private EnternCountdown enternCountdown = null;
|
private EnternCountdown enternCountdown = null;
|
||||||
|
|
||||||
@ -61,13 +69,14 @@ public class FightPlayer {
|
|||||||
|
|
||||||
public void setOut() {
|
public void setOut() {
|
||||||
isOut = true;
|
isOut = true;
|
||||||
|
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
|
||||||
stopEnternCountdown();
|
stopEnternCountdown();
|
||||||
ifAI(AI::stop);
|
ifAI(AI::stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startEnternCountdown() {
|
public void startEnternCountdown(Countdown countdown) {
|
||||||
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
|
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
|
||||||
enternCountdown = new EnternCountdown(this);
|
enternCountdown = new EnternCountdown(this, countdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEnternCountdown(){
|
public void stopEnternCountdown(){
|
||||||
@ -110,22 +119,6 @@ public class FightPlayer {
|
|||||||
return leader != null && leader.getEntity() == entity;
|
return leader != null && leader.getEntity() == entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kit getKit() {
|
|
||||||
return kit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKit(Kit kit) {
|
|
||||||
this.kit = kit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightTeam getTeam(){
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKills(){
|
|
||||||
return kills;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addKill(){
|
public void addKill(){
|
||||||
kills++;
|
kills++;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import de.steamwar.fightsystem.utils.Region;
|
|||||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -100,8 +101,17 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
if(clipboard == null){
|
if(clipboard == null){
|
||||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
||||||
if(publics.isEmpty())
|
if(publics.isEmpty()) {
|
||||||
return;
|
for (SchematicType type : Config.SubTypes) {
|
||||||
|
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
||||||
|
if (!publics.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (publics.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||||
}
|
}
|
||||||
@ -138,6 +148,9 @@ public class FightSchematic extends StateDependent {
|
|||||||
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
|
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
|
||||||
new AffineTransform().rotateY(rotate ? 180 : 0)
|
new AffineTransform().rotateY(rotate ? 180 : 0)
|
||||||
);
|
);
|
||||||
|
FightSystem.getHullHider().initialize(team);
|
||||||
|
if(ArenaMode.Check.contains(Config.mode) && !team.isBlue())
|
||||||
|
replaceSync(Material.TNT, Material.OBSIDIAN);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||||
@ -187,7 +200,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
length -= 1;
|
length -= 1;
|
||||||
AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
|
AffineTransform aT = new AffineTransform().rotateY(((team == Fight.getRedTeam()) == (Config.BlueToRedZ > 0)) ? 180 : 0);
|
||||||
Location base = new Location(Config.world, region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
Location base = new Location(Config.world, region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
||||||
for(int i = 0; i < characters.length; i++){
|
for(int i = 0; i < characters.length; i++){
|
||||||
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);
|
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);
|
||||||
|
@ -25,22 +25,24 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
import de.steamwar.fightsystem.listener.Permanent;
|
import de.steamwar.fightsystem.listener.Permanent;
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
import de.steamwar.fightsystem.listener.TeamArea;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
|
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.techhider.ProtocolUtils;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
@ -54,7 +56,7 @@ public class FightTeam {
|
|||||||
|
|
||||||
private static void setKitButton(HotbarKit kit, boolean leader) {
|
private static void setKitButton(HotbarKit kit, boolean leader) {
|
||||||
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
|
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
|
||||||
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, ""));
|
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
|
||||||
else
|
else
|
||||||
kit.setItem(1, null, null, null);
|
kit.setItem(1, null, null, null);
|
||||||
}
|
}
|
||||||
@ -62,50 +64,61 @@ public class FightTeam {
|
|||||||
private static final HotbarKit memberKit = new HotbarKit();
|
private static final HotbarKit memberKit = new HotbarKit();
|
||||||
static {
|
static {
|
||||||
setKitButton(memberKit, false);
|
setKitButton(memberKit, false);
|
||||||
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
|
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
|
||||||
}
|
}
|
||||||
private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
|
private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
|
||||||
static {
|
static {
|
||||||
setKitButton(notReadyKit, true);
|
setKitButton(notReadyKit, true);
|
||||||
|
|
||||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseJoinRequests);
|
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
|
||||||
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove);
|
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.test())
|
if(Config.test())
|
||||||
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
|
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
|
||||||
|
|
||||||
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
|
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
|
||||||
}
|
}
|
||||||
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
|
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
|
||||||
static {
|
static {
|
||||||
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
|
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
|
||||||
}
|
}
|
||||||
private static final HotbarKit readyKit = new HotbarKit(memberKit);
|
private static final HotbarKit readyKit = new HotbarKit(memberKit);
|
||||||
static {
|
static {
|
||||||
readyKit.setItem(1, null, null, null);
|
readyKit.setItem(1, null, null, null);
|
||||||
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
|
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private UUID designatedLeader;
|
private UUID designatedLeader;
|
||||||
|
@Getter
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
private int schemRank;
|
@Getter
|
||||||
|
private boolean publicsOnly;
|
||||||
|
|
||||||
private final Map<UUID, FightPlayer> players = new HashMap<>();
|
private final Map<UUID, FightPlayer> players = new HashMap<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
private String name;
|
private String name;
|
||||||
|
@Getter
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
@Getter
|
||||||
private ChatColor color;
|
private ChatColor color;
|
||||||
private final FightSchematic schematic;
|
private final FightSchematic schematic;
|
||||||
private final Team team;
|
private final Team team;
|
||||||
|
@Getter
|
||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
private boolean skip;
|
private boolean skip;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final Location spawn;
|
private final Location spawn;
|
||||||
|
@Getter
|
||||||
private final Region schemRegion;
|
private final Region schemRegion;
|
||||||
|
@Getter
|
||||||
private final Region extendRegion;
|
private final Region extendRegion;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -113,7 +126,7 @@ public class FightTeam {
|
|||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.schemRegion = schemRegion;
|
this.schemRegion = schemRegion;
|
||||||
this.extendRegion = extendRegion;
|
this.extendRegion = extendRegion;
|
||||||
this.schemRank = 0;
|
this.publicsOnly = false;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.skip = false;
|
this.skip = false;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
@ -122,6 +135,7 @@ public class FightTeam {
|
|||||||
this.schematic = new FightSchematic(this, rotate);
|
this.schematic = new FightSchematic(this, rotate);
|
||||||
new KitLoader();
|
new KitLoader();
|
||||||
new SpectateHandler();
|
new SpectateHandler();
|
||||||
|
new TeamArea(this);
|
||||||
|
|
||||||
team = FightScoreboard.getBukkitTeam(name);
|
team = FightScoreboard.getBukkitTeam(name);
|
||||||
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
||||||
@ -145,26 +159,10 @@ public class FightTeam {
|
|||||||
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDesignatedLeader(){
|
|
||||||
return designatedLeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Region getSchemRegion() {
|
|
||||||
return schemRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Region getExtendRegion() {
|
|
||||||
return extendRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canbeLeader(Player p){
|
public boolean canbeLeader(Player p){
|
||||||
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSchemRank() {
|
|
||||||
return schemRank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
public void teleportToSpawn(){
|
||||||
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
|
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
|
||||||
}
|
}
|
||||||
@ -202,13 +200,16 @@ public class FightTeam {
|
|||||||
schematic.reset();
|
schematic.reset();
|
||||||
|
|
||||||
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
||||||
for(UUID uuid : playerSet){
|
playerSet.removeIf(uuid -> {
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
if(player == null)
|
if(player == null) {
|
||||||
removePlayer(players.get(uuid).getEntity());
|
removePlayer(players.get(uuid).getEntity());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
FightPlayer leaderBackup = leader;
|
FightPlayer leaderBackup = leader;
|
||||||
playerSet.removeIf(uuid -> Bukkit.getPlayer(uuid) == null);
|
|
||||||
players.clear();
|
players.clear();
|
||||||
leader = null;
|
leader = null;
|
||||||
|
|
||||||
@ -260,10 +261,11 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) {
|
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) {
|
||||||
final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, false);
|
|
||||||
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
|
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
|
||||||
fightPlayer.revive();
|
fightPlayer.revive();
|
||||||
players.put(entity.getUniqueId(), fightPlayer);
|
players.put(entity.getUniqueId(), fightPlayer);
|
||||||
|
Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer));
|
||||||
|
|
||||||
Permanent.getSpectatorTeam().removeEntry(entity.getName());
|
Permanent.getSpectatorTeam().removeEntry(entity.getName());
|
||||||
team.addEntry(entity.getName());
|
team.addEntry(entity.getName());
|
||||||
|
|
||||||
@ -274,6 +276,7 @@ public class FightTeam {
|
|||||||
BountifulWrapper.impl.setAttackSpeed(player);
|
BountifulWrapper.impl.setAttackSpeed(player);
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
FightSystem.getHullHider().updatePlayer(player);
|
||||||
|
|
||||||
if(FightState.Spectate.contains(FightState.getFightState())) {
|
if(FightState.Spectate.contains(FightState.getFightState())) {
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
@ -284,10 +287,9 @@ public class FightTeam {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(FightState.Running.contains(FightState.getFightState()))
|
if(FightState.Running.contains(FightState.getFightState()))
|
||||||
fightPlayer.startEnternCountdown();
|
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
|
||||||
|
|
||||||
GlobalRecorder.getInstance().playerJoins(entity, user);
|
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, fightPlayer.canEntern() ? Region.EMPTY : Fight.getOpposite(this).getExtendRegion()));
|
||||||
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunksToReload, false));
|
|
||||||
|
|
||||||
if(isLeaderless())
|
if(isLeaderless())
|
||||||
setLeader(fightPlayer, silent);
|
setLeader(fightPlayer, silent);
|
||||||
@ -297,9 +299,9 @@ public class FightTeam {
|
|||||||
|
|
||||||
public void removePlayer(LivingEntity entity) {
|
public void removePlayer(LivingEntity entity) {
|
||||||
FightPlayer fightPlayer = getFightPlayer(entity);
|
FightPlayer fightPlayer = getFightPlayer(entity);
|
||||||
|
Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
|
||||||
|
|
||||||
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||||
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, true);
|
|
||||||
players.remove(entity.getUniqueId());
|
players.remove(entity.getUniqueId());
|
||||||
team.removeEntry(entity.getName());
|
team.removeEntry(entity.getName());
|
||||||
Permanent.getSpectatorTeam().addEntry(entity.getName());
|
Permanent.getSpectatorTeam().addEntry(entity.getName());
|
||||||
@ -309,7 +311,6 @@ public class FightTeam {
|
|||||||
if(fightPlayer.equals(leader))
|
if(fightPlayer.equals(leader))
|
||||||
removeLeader();
|
removeLeader();
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityDespawns(entity);
|
|
||||||
entity.teleport(Config.SpecSpawn);
|
entity.teleport(Config.SpecSpawn);
|
||||||
|
|
||||||
fightPlayer.ifPlayer(player -> {
|
fightPlayer.ifPlayer(player -> {
|
||||||
@ -317,7 +318,8 @@ public class FightTeam {
|
|||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
if(player.isOnline()){
|
if(player.isOnline()){
|
||||||
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
|
FightSystem.getHullHider().updatePlayer(player);
|
||||||
|
FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, Fight.getOpposite(this).getExtendRegion());
|
||||||
|
|
||||||
if(ArenaMode.VariableTeams.contains(Config.mode))
|
if(ArenaMode.VariableTeams.contains(Config.mode))
|
||||||
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
||||||
@ -329,14 +331,6 @@ public class FightTeam {
|
|||||||
return leader == null;
|
return leader == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlue(){
|
|
||||||
return blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightPlayer getLeader() {
|
|
||||||
return leader;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeLeader() {
|
private void removeLeader() {
|
||||||
this.leader = null;
|
this.leader = null;
|
||||||
if(!players.isEmpty()) {
|
if(!players.isEmpty()) {
|
||||||
@ -357,11 +351,7 @@ public class FightTeam {
|
|||||||
if(!silent)
|
if(!silent)
|
||||||
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
||||||
|
|
||||||
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
|
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty();
|
||||||
if(Config.RanksEnabled)
|
|
||||||
schemRank = maxRank.orElse(1);
|
|
||||||
else
|
|
||||||
schemRank = maxRank.isPresent() ? 1 : 0;
|
|
||||||
|
|
||||||
if(!Config.PersonalKits)
|
if(!Config.PersonalKits)
|
||||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||||
@ -384,15 +374,16 @@ public class FightTeam {
|
|||||||
return players.values();
|
return players.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReady() {
|
|
||||||
return ready;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pasteSchem() {
|
public void pasteSchem() {
|
||||||
testPasteAction();
|
testPasteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pasteSchem(SchematicNode schematic){
|
public void pasteSchem(SchematicNode schematic){
|
||||||
|
if(schematic.getSchemtype().check()) {
|
||||||
|
FightStatistics.unrank();
|
||||||
|
FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName());
|
||||||
|
}
|
||||||
|
|
||||||
setSchem(schematic);
|
setSchem(schematic);
|
||||||
testPasteAction();
|
testPasteAction();
|
||||||
}
|
}
|
||||||
@ -453,26 +444,14 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColoredName() {
|
public String getColoredName() {
|
||||||
return prefix + name;
|
return prefix + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSchematic() {
|
public int getSchematic() {
|
||||||
return schematic.getId();
|
return schematic.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getSpawn() {
|
|
||||||
return spawn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getCurrentHearts() {
|
public double getCurrentHearts() {
|
||||||
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
||||||
}
|
}
|
||||||
@ -490,10 +469,6 @@ public class FightTeam {
|
|||||||
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
|
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -21,11 +21,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.listener.Recording;
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
@ -39,11 +41,8 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class FightWorld extends StateDependent {
|
public class FightWorld extends StateDependent {
|
||||||
|
|
||||||
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
@Getter
|
||||||
|
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
|
||||||
public static boolean isPaper(){
|
|
||||||
return paper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightWorld() {
|
public FightWorld() {
|
||||||
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);
|
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);
|
||||||
@ -57,7 +56,7 @@ public class FightWorld extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
resetWorld();
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightWorld::resetWorld); //Delay to prevent raceconditions with techhider and hullhider
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void forceLoad(){
|
public static void forceLoad(){
|
||||||
|
@ -51,7 +51,7 @@ public class HotbarKit extends Kit {
|
|||||||
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
|
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
|
||||||
static {
|
static {
|
||||||
for(int i = 0; i < 9; i++)
|
for(int i = 0; i < 9; i++)
|
||||||
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::joinRequest);
|
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int HOTBAR_SIZE = 9;
|
private static final int HOTBAR_SIZE = 9;
|
||||||
|
@ -30,6 +30,7 @@ import de.steamwar.inventory.SWInventory;
|
|||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -69,11 +70,19 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@Getter
|
||||||
private final ItemStack[] inventory;
|
private final ItemStack[] inventory;
|
||||||
|
@Getter
|
||||||
private final ItemStack[] armor;
|
private final ItemStack[] armor;
|
||||||
|
@Getter
|
||||||
private final Collection<PotionEffect> effects;
|
private final Collection<PotionEffect> effects;
|
||||||
|
/* In which stage is entern allowed? */
|
||||||
|
@Getter
|
||||||
private final int enterStage;
|
private final int enterStage;
|
||||||
|
/* Is this kit allowed to set/handle tnt? */
|
||||||
|
@Getter
|
||||||
private final boolean tnt;
|
private final boolean tnt;
|
||||||
private final boolean leaderAllowed;
|
private final boolean leaderAllowed;
|
||||||
private final boolean memberAllowed;
|
private final boolean memberAllowed;
|
||||||
@ -140,10 +149,6 @@ public class Kit {
|
|||||||
return kits;
|
return kits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUseKit(boolean leader){
|
public boolean canUseKit(boolean leader){
|
||||||
if (leader) {
|
if (leader) {
|
||||||
return leaderAllowed;
|
return leaderAllowed;
|
||||||
@ -156,10 +161,6 @@ public class Kit {
|
|||||||
return !memberAllowed;
|
return !memberAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getInventory() {
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(ItemStack stack) {
|
public boolean contains(ItemStack stack) {
|
||||||
for(ItemStack i : inventory) {
|
for(ItemStack i : inventory) {
|
||||||
if(similar(i, stack))
|
if(similar(i, stack))
|
||||||
@ -172,24 +173,6 @@ public class Kit {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getArmor() {
|
|
||||||
return armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<PotionEffect> getEffects() {
|
|
||||||
return effects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is this kit allowed to set/handle tnt? */
|
|
||||||
public boolean isTnt(){
|
|
||||||
return tnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In which stage is entern allowed? */
|
|
||||||
public int getEnterStage() {
|
|
||||||
return enterStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toPersonalKit(PersonalKit kit) {
|
public void toPersonalKit(PersonalKit kit) {
|
||||||
kit.setContainer(inventory, armor);
|
kit.setContainer(inventory, armor);
|
||||||
}
|
}
|
||||||
|
@ -21,52 +21,72 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class ArenaBorder implements Listener {
|
public class ArenaBorder implements Listener {
|
||||||
|
|
||||||
|
private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING", "ArenaBorder.spectatorBorder");
|
||||||
|
private final Border playerBorder = new Border(Config.PlayerRegion.to2d(), true, 5, "NO_ARENA_LEAVING", "ArenaBorder.playerBorder");
|
||||||
|
|
||||||
public ArenaBorder() {
|
public ArenaBorder() {
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
|
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
|
||||||
|
new StateDependentListener(!Config.GroundWalkable, FightState.AntiRunning, new Listener() {
|
||||||
|
@EventHandler
|
||||||
|
public void onMove(PlayerMoveEvent e) {
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
if(e.getTo().getY() <= Config.PlayerRegion.getMinY() && playerBorder.contains(player))
|
||||||
|
player.teleport(Fight.getPlayerTeam(player).getSpawn());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void arenaBorder(PlayerMoveEvent event){
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
Player player = event.getPlayer();
|
addToSpectator(e.getPlayer());
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
}
|
||||||
|
|
||||||
if(Config.ArenaLeaveable && team == null)
|
@EventHandler
|
||||||
return;
|
public void onTeamJoin(TeamSpawnEvent e) {
|
||||||
|
e.getFightPlayer().ifPlayer(player -> {
|
||||||
|
spectatorBorder.removePlayer(player);
|
||||||
|
playerBorder.addPlayer(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Location to = event.getTo();
|
@EventHandler
|
||||||
assert to != null;
|
public void onTeamDeath(TeamDeathEvent e) {
|
||||||
|
e.getFightPlayer().ifPlayer(player -> {
|
||||||
|
playerBorder.removePlayer(player);
|
||||||
|
addToSpectator(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(Config.PlayerRegion.inRegion(to))
|
@EventHandler
|
||||||
return;
|
public void onTeamLeave(TeamLeaveEvent e) {
|
||||||
|
e.getFightPlayer().ifPlayer(player -> {
|
||||||
|
playerBorder.removePlayer(player);
|
||||||
|
addToSpectator(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) {
|
@EventHandler
|
||||||
if(!Config.GroundWalkable && !FightState.infight())
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
player.teleport(team.getSpawn());
|
spectatorBorder.removePlayer(e.getPlayer());
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.teleport(event.getFrom());
|
|
||||||
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void damage() {
|
private void damage() {
|
||||||
@ -78,4 +98,11 @@ public class ArenaBorder implements Listener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addToSpectator(Player player) {
|
||||||
|
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
spectatorBorder.addPlayer(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
|
||||||
|
|
||||||
public class ArrowPickup {
|
|
||||||
|
|
||||||
public ArrowPickup() {
|
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
|
||||||
}
|
|
||||||
}
|
|
@ -85,7 +85,7 @@ public class ArrowStopper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBlock(Block block) {
|
private boolean checkBlock(Block block) {
|
||||||
return Config.HiddenBlocks.contains(block.getType().name().toLowerCase());
|
return Config.HiddenBlocks.contains(block.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidEntity(Projectile entity) {
|
private boolean invalidEntity(Projectile entity) {
|
||||||
|
148
FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java
Normale Datei
148
FightSystem_Core/src/de/steamwar/fightsystem/listener/Border.java
Normale Datei
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
|
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Border {
|
||||||
|
|
||||||
|
private final Map<UUID, Set<Block>> ghostBarriers = new HashMap<>();
|
||||||
|
private final Map<UUID, Location> lastLocation = new HashMap<>();
|
||||||
|
private final boolean contain;
|
||||||
|
private final String resetMessage;
|
||||||
|
private final String name;
|
||||||
|
private final Region region;
|
||||||
|
private final int ghostRange;
|
||||||
|
private final int ghostSize;
|
||||||
|
|
||||||
|
public Border(Region region, boolean contain, int ghostRange, String resetMessage, String name) {
|
||||||
|
this.contain = contain;
|
||||||
|
this.resetMessage = resetMessage;
|
||||||
|
this.name = name;
|
||||||
|
this.region = region;
|
||||||
|
this.ghostRange = ghostRange;
|
||||||
|
this.ghostSize = 2*ghostRange + 1;
|
||||||
|
|
||||||
|
new StateDependentTask(ArenaMode.All, FightState.All, this::run, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(Player player) {
|
||||||
|
if(ghostBarriers.containsKey(player.getUniqueId()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
|
||||||
|
lastLocation.put(player.getUniqueId(), player.getLocation());
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Player player) {
|
||||||
|
return ghostBarriers.containsKey(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player player) {
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
|
||||||
|
lastLocation.remove(player.getUniqueId());
|
||||||
|
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
|
||||||
|
if(blocks == null || !player.isOnline())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(Block block : blocks)
|
||||||
|
sendChange(player, block, Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run() {
|
||||||
|
List<UUID> offline = new ArrayList<>();
|
||||||
|
for(Map.Entry<UUID, Set<Block>> entry : ghostBarriers.entrySet()) {
|
||||||
|
UUID uuid = entry.getKey();
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if(player == null) {
|
||||||
|
offline.add(uuid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = player.getLocation();
|
||||||
|
if(region.playerInRegion(location) != contain) {
|
||||||
|
player.teleport(lastLocation.get(uuid));
|
||||||
|
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Block> ghostBlocks = entry.getValue();
|
||||||
|
Region ghostRegion = Region.fromSize(location.getBlockX() - ghostRange, location.getBlockY() - ghostRange, location.getBlockZ() - ghostRange, ghostSize, ghostSize, ghostSize);
|
||||||
|
ghostBlocks.removeIf(block -> {
|
||||||
|
if(!ghostRegion.inRegion(block)) {
|
||||||
|
sendChange(player, block, Material.AIR);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(contain) {
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||||
|
} else {
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||||
|
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLocation.put(entry.getKey(), location);
|
||||||
|
}
|
||||||
|
|
||||||
|
offline.forEach(uuid -> FightSystem.getPlugin().getLogger().log(Level.INFO, () -> uuid + " was removed from border " + name));
|
||||||
|
offline.forEach(ghostBarriers::remove);
|
||||||
|
offline.forEach(lastLocation::remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {
|
||||||
|
border.forEach((x, y, z) -> {
|
||||||
|
Block block = Config.world.getBlockAt(x, y, z);
|
||||||
|
if(ghostBlocks.add(block))
|
||||||
|
sendChange(player, block, Material.BARRIER);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendChange(Player player, Block block, Material type) {
|
||||||
|
if(block.getType() == Material.AIR)
|
||||||
|
FlatteningWrapper.impl.sendBlockChange(player, block, type);
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
@ -153,14 +154,6 @@ public class Permanent implements Listener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onBlockBreak(BlockBreakEvent e) {
|
|
||||||
Block block = e.getBlock();
|
|
||||||
for(ItemStack stack : block.getDrops(e.getPlayer().getItemInHand()))
|
|
||||||
Config.world.dropItemNaturally(block.getLocation(), stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDropPickup(PlayerPickupItemEvent e) {
|
public void onDropPickup(PlayerPickupItemEvent e) {
|
||||||
if(!(Config.ArenaRegion.inRegion(e.getItem().getLocation())))
|
if(!(Config.ArenaRegion.inRegion(e.getItem().getLocation())))
|
||||||
@ -226,4 +219,25 @@ public class Permanent implements Listener {
|
|||||||
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
|
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockPlace(BlockPlaceEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Block block = event.getBlock();
|
||||||
|
if(Fight.teams().stream().anyMatch(team -> team.getExtendRegion().inRegion(block)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockBreak(BlockBreakEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
if(Config.BlueExtendRegion.getMinY() <= block.getY())
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@ import com.comphenix.tinyprotocol.Reflection;
|
|||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
@ -142,6 +145,11 @@ public class Recording implements Listener {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerSpawn(TeamSpawnEvent e) {
|
||||||
|
GlobalRecorder.getInstance().playerJoins(e.getFightPlayer().getEntity(), e.getFightPlayer().getUser());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerMove(PlayerMoveEvent e){
|
public void onPlayerMove(PlayerMoveEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
@ -151,19 +159,13 @@ public class Recording implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
public void onPlayerDeath(TeamDeathEvent e) {
|
||||||
if(isNotSent(e.getEntity()))
|
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
|
||||||
return;
|
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent e){
|
public void onPlayerLeave(TeamLeaveEvent e) {
|
||||||
if(isNotSent(e.getPlayer()))
|
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
|
||||||
return;
|
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
@ -22,109 +22,122 @@ package de.steamwar.fightsystem.listener;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class TeamArea implements Listener {
|
public class TeamArea implements Listener {
|
||||||
|
|
||||||
private static final Set<Player> realSpectator = new HashSet<>();
|
private final FightTeam team;
|
||||||
|
private final Border spectatorBorder;
|
||||||
|
private final Border bordingBorder;
|
||||||
|
private final Set<Player> realSpectator = new HashSet<>();
|
||||||
|
|
||||||
|
public TeamArea(FightTeam team) {
|
||||||
|
this.team = team;
|
||||||
|
this.spectatorBorder = new Border(team.getExtendRegion(), false, 5, "NO_TEAMAREA", team.getName() + ".spectatorBorder");
|
||||||
|
this.bordingBorder = new Border(team.getExtendRegion().to2d(), true, 1, "NO_ENTERN", team.getName() + ".boardingBorder");
|
||||||
|
|
||||||
public TeamArea() {
|
|
||||||
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
|
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
|
||||||
|
new StateDependentTask(ArenaMode.AntiTest, FightState.TeamFix, this::realSpectatorCheck, 1, 1);
|
||||||
|
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Spectate, () -> Fight.teams().forEach(t -> t.getPlayers().forEach(this::teamSpectator)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void teamAreas(PlayerMoveEvent event) {
|
public void playerJoin(PlayerJoinEvent e) {
|
||||||
Player player = event.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if(Config.isReferee(player))
|
if(Fight.getPlayerTeam(player) != team && !Config.isReferee(player))
|
||||||
return;
|
spectatorBorder.addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
@EventHandler
|
||||||
Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
|
public void teamJoin(TeamSpawnEvent e) {
|
||||||
|
FightPlayer fightPlayer = e.getFightPlayer();
|
||||||
|
if(fightPlayer.getTeam() == team) {
|
||||||
|
fightPlayer.ifPlayer(player -> {
|
||||||
|
spectatorBorder.removePlayer(player);
|
||||||
|
bordingBorder.addPlayer(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamLeave(TeamLeaveEvent e) {
|
||||||
|
FightPlayer fightPlayer = e.getFightPlayer();
|
||||||
|
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
|
||||||
|
if(fightPlayer.getTeam() == team)
|
||||||
|
fightPlayer.ifPlayer(bordingBorder::removePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void boarding(BoardingEvent e) {
|
||||||
|
FightPlayer fightPlayer = e.getFightPlayer();
|
||||||
|
if(fightPlayer.getTeam() == team) {
|
||||||
|
fightPlayer.ifPlayer(bordingBorder::removePlayer);
|
||||||
|
} else {
|
||||||
|
fightPlayer.ifPlayer(spectatorBorder::removePlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamDeath(TeamDeathEvent e) {
|
||||||
|
teamSpectator(e.getFightPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void teamSpectator(FightPlayer fightPlayer) {
|
||||||
|
if(fightPlayer.getTeam() == team) {
|
||||||
|
fightPlayer.ifPlayer(bordingBorder::removePlayer);
|
||||||
|
} else {
|
||||||
|
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerQuit(PlayerQuitEvent e) {
|
public void playerQuit(PlayerQuitEvent e) {
|
||||||
realSpectator.remove(e.getPlayer());
|
Player player = e.getPlayer();
|
||||||
|
spectatorBorder.removePlayer(player);
|
||||||
|
bordingBorder.removePlayer(player);
|
||||||
|
realSpectator.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
private void realSpectatorCheck() {
|
||||||
public void blockPlace(BlockPlaceEvent event) {
|
for(FightPlayer fightPlayer : team.getPlayers()) {
|
||||||
Player player = event.getPlayer();
|
if(fightPlayer.isLiving())
|
||||||
Block block = event.getBlock();
|
continue;
|
||||||
if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
fightPlayer.ifPlayer(player -> {
|
||||||
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
|
boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation());
|
||||||
}
|
if(inRegion && !realSpectator.contains(player)) {
|
||||||
|
realSpectator.add(player);
|
||||||
|
|
||||||
@EventHandler
|
//Later to prevent race condition with Fight.setSpecatator() during respawn
|
||||||
public void blockBreak(BlockBreakEvent event) {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
Block block = event.getBlock();
|
if(!player.isOnline())
|
||||||
if(Config.BlueExtendRegion.getMinY() <= block.getY())
|
return;
|
||||||
return;
|
Fight.pseudoSpectator(player, false);
|
||||||
|
}, 2);
|
||||||
event.setCancelled(true);
|
}else if(!inRegion && realSpectator.contains(player)) {
|
||||||
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
|
Fight.pseudoSpectator(player, true);
|
||||||
}
|
realSpectator.remove(player);
|
||||||
|
}
|
||||||
private void checkInTeamRegion(PlayerMoveEvent event, FightTeam team, Player player, FightTeam playerTeam) {
|
});
|
||||||
boolean spectator = player.getGameMode() == GameMode.SPECTATOR;
|
|
||||||
if(!spectator && playerTeam != null && playerTeam.canPlayerEntern(player))
|
|
||||||
return; // Player can entern
|
|
||||||
|
|
||||||
Region region = team.getExtendRegion();
|
|
||||||
boolean inRegion = region.in2dRegion(event.getTo());
|
|
||||||
if(team == playerTeam) {
|
|
||||||
if(spectator) {
|
|
||||||
realSpectator(inRegion, player);
|
|
||||||
} else if (!playerTeam.canPlayerEntern(player) && !inRegion) {
|
|
||||||
reset(event, "NO_ENTERN"); // Leaving prior to entern
|
|
||||||
}
|
|
||||||
return; // Always allowed in own region
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(region.playerInRegion(event.getTo())) {
|
|
||||||
reset(event, "NO_TEAMAREA"); // Not allowed in region
|
|
||||||
if(team.getSchemRegion().playerInRegion(event.getTo()) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
|
|
||||||
player.kickPlayer(null);
|
|
||||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " has entered a team area");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void realSpectator(boolean inRegion, Player player) {
|
|
||||||
if(inRegion && !realSpectator.contains(player)) {
|
|
||||||
Fight.pseudoSpectator(player, false);
|
|
||||||
realSpectator.add(player);
|
|
||||||
}else if(!inRegion && realSpectator.contains(player)) {
|
|
||||||
Fight.pseudoSpectator(player, true);
|
|
||||||
realSpectator.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reset(PlayerMoveEvent event, String message){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.teleport(event.getFrom());
|
|
||||||
FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,19 +71,27 @@ public class WaterRemover implements Listener {
|
|||||||
event.setYield(0); //No drops (additionally to world config)
|
event.setYield(0); //No drops (additionally to world config)
|
||||||
|
|
||||||
FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
|
FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
|
||||||
if(spawn != null && event.blockList().isEmpty() && Fight.getOpposite(spawn).getExtendRegion().inRegion(event.getLocation())) {
|
if(spawn != null && !spawn.getExtendRegion().inRegion(event.getLocation())) {
|
||||||
checkBlock(event.getLocation().getBlock());
|
Block b = event.getLocation().getBlock();
|
||||||
|
for(int y = -1; y <= 1; y++) {
|
||||||
|
for(int z = -1; z <= 1; z++) {
|
||||||
|
for(int x = -1; x <= 1; x++) {
|
||||||
|
checkBlock(b.getRelative(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Block b : event.blockList()){
|
event.blockList().forEach(this::checkNeighbours);
|
||||||
//b cannot be water or air due to current explosion
|
}
|
||||||
|
|
||||||
checkBlock(b.getRelative(BlockFace.UP));
|
private void checkNeighbours(Block b) {
|
||||||
checkBlock(b.getRelative(BlockFace.EAST));
|
checkBlock(b.getRelative(BlockFace.UP));
|
||||||
checkBlock(b.getRelative(BlockFace.WEST));
|
checkBlock(b.getRelative(BlockFace.EAST));
|
||||||
checkBlock(b.getRelative(BlockFace.NORTH));
|
checkBlock(b.getRelative(BlockFace.WEST));
|
||||||
checkBlock(b.getRelative(BlockFace.SOUTH));
|
checkBlock(b.getRelative(BlockFace.NORTH));
|
||||||
}
|
checkBlock(b.getRelative(BlockFace.SOUTH));
|
||||||
|
checkBlock(b.getRelative(BlockFace.DOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBlock(Block b) {
|
private void checkBlock(Block b) {
|
||||||
@ -98,10 +106,6 @@ public class WaterRemover implements Listener {
|
|||||||
if(b.getY() < MIN_Y)
|
if(b.getY() < MIN_Y)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
checkBlock(b.getRelative(BlockFace.UP));
|
checkNeighbours(b);
|
||||||
checkBlock(b.getRelative(BlockFace.EAST));
|
|
||||||
checkBlock(b.getRelative(BlockFace.WEST));
|
|
||||||
checkBlock(b.getRelative(BlockFace.NORTH));
|
|
||||||
checkBlock(b.getRelative(BlockFace.SOUTH));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,17 @@ package de.steamwar.fightsystem.record;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class FileRecorder extends StateDependent implements Recorder {
|
public class FileRecorder extends StateDependent implements Recorder {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
|
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
|
||||||
private DataOutputStream outputStream;
|
private DataOutputStream outputStream;
|
||||||
|
|
||||||
public static File getFile() {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileRecorder(){
|
public FileRecorder(){
|
||||||
super(Config.ReplayID == 0, FightState.Recording);
|
super(Config.ReplayID == 0, FightState.Recording);
|
||||||
register();
|
register();
|
||||||
|
@ -41,7 +41,7 @@ public class LiveRecorder extends StateDependent implements Recorder {
|
|||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
try {
|
try {
|
||||||
socket = new Socket(Config.spectateIP, Config.spectatePort);
|
socket = new Socket(Config.spectateIP, Config.SpectatePort);
|
||||||
socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
|
socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
|
||||||
socket.setSoLinger(true, 1); // Wait a maximum of 1ms on disable
|
socket.setSoLinger(true, 1); // Wait a maximum of 1ms on disable
|
||||||
socket.setTcpNoDelay(true); // Don't wait on ack
|
socket.setTcpNoDelay(true); // Don't wait on ack
|
||||||
|
@ -33,7 +33,7 @@ public class LiveServer {
|
|||||||
private final ServerSocket socket;
|
private final ServerSocket socket;
|
||||||
|
|
||||||
public LiveServer() throws IOException {
|
public LiveServer() throws IOException {
|
||||||
socket = new ServerSocket(Config.spectatePort);
|
socket = new ServerSocket(Config.SpectatePort);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::acceptConnections);
|
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::acceptConnections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ public class PacketProcessor implements Listener {
|
|||||||
private final PacketSource source;
|
private final PacketSource source;
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final LinkedList<Runnable> syncList = new LinkedList<>();
|
private final LinkedList<Runnable> syncList = new LinkedList<>();
|
||||||
private final Set<Integer> hiddenBlockIds = Config.HiddenBlocks.stream().map(String::toUpperCase).map(Material::getMaterial).flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
|
private final Set<Integer> hiddenBlockIds = Config.HiddenBlocks.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
|
||||||
private final int obfuscateWith = BlockIds.impl.materialToId(Material.getMaterial(Config.ObfuscateWith.toUpperCase()));
|
private final int obfuscateWith = BlockIds.impl.materialToId(Config.ObfuscateWith);
|
||||||
private final FreezeWorld freezer = new FreezeWorld();
|
private final FreezeWorld freezer = new FreezeWorld();
|
||||||
private final REntityServer entityServer = new REntityServer();
|
private final REntityServer entityServer = new REntityServer();
|
||||||
private final Map<Integer, REntity> entities = new HashMap<>();
|
private final Map<Integer, REntity> entities = new HashMap<>();
|
||||||
@ -165,6 +165,11 @@ public class PacketProcessor implements Listener {
|
|||||||
entityServer.addPlayer(player);
|
entityServer.addPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addREntity(int entityId, REntity entity) {
|
||||||
|
entities.put(entityId, entity);
|
||||||
|
FightSystem.getHullHider().updateREntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
entityServer.addPlayer(e.getPlayer());
|
entityServer.addPlayer(e.getPlayer());
|
||||||
@ -235,7 +240,7 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
SteamwarUser user = SteamwarUser.get(userId);
|
SteamwarUser user = SteamwarUser.get(userId);
|
||||||
entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
|
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
|
||||||
team.addEntry(user.getUserName());
|
team.addEntry(user.getUserName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -257,8 +262,10 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
REntity entity = entities.get(entityId);
|
REntity entity = entities.get(entityId);
|
||||||
if(entity != null)
|
if(entity != null) {
|
||||||
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
|
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
|
||||||
|
FightSystem.getHullHider().updateREntity(entity);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +274,10 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
REntity entity = entities.remove(entityId);
|
REntity entity = entities.remove(entityId);
|
||||||
if(entity != null)
|
if(entity != null) {
|
||||||
|
FightSystem.getHullHider().despawnREntity(entity);
|
||||||
entity.die();
|
entity.die();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +298,7 @@ public class PacketProcessor implements Listener {
|
|||||||
private void tntSpawn() throws IOException {
|
private void tntSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
int entityId = source.readInt();
|
||||||
|
|
||||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
|
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entityVelocity() throws IOException {
|
private void entityVelocity() throws IOException {
|
||||||
@ -344,13 +353,13 @@ public class PacketProcessor implements Listener {
|
|||||||
private void arrowSpawn() throws IOException {
|
private void arrowSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
int entityId = source.readInt();
|
||||||
|
|
||||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
|
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireballSpawn() throws IOException {
|
private void fireballSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
int entityId = source.readInt();
|
||||||
|
|
||||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
|
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send(ChatMessageType type) throws IOException {
|
private void send(ChatMessageType type) throws IOException {
|
||||||
@ -437,7 +446,10 @@ public class PacketProcessor implements Listener {
|
|||||||
if(!Config.ArenaRegion.in2dRegion(x, z))
|
if(!Config.ArenaRegion.in2dRegion(x, z))
|
||||||
return; //Outside of the arena
|
return; //Outside of the arena
|
||||||
|
|
||||||
execSync(() -> BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
execSync(() -> {
|
||||||
|
BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState);
|
||||||
|
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), BlockIdWrapper.impl.idToMaterial(blockState));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void particle() throws IOException {
|
private void particle() throws IOException {
|
||||||
@ -578,6 +590,7 @@ public class PacketProcessor implements Listener {
|
|||||||
private void endReplay() {
|
private void endReplay() {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
entityServer.close();
|
entityServer.close();
|
||||||
|
entities.values().forEach(FightSystem.getHullHider()::despawnREntity);
|
||||||
entities.clear();
|
entities.clear();
|
||||||
|
|
||||||
freezer.disable();
|
freezer.disable();
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.states;
|
package de.steamwar.fightsystem.states;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public enum FightState {
|
public enum FightState {
|
||||||
@ -48,12 +50,9 @@ public enum FightState {
|
|||||||
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
|
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
|
||||||
|
|
||||||
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||||
|
@Getter
|
||||||
private static FightState fightState = PRE_LEADER_SETUP;
|
private static FightState fightState = PRE_LEADER_SETUP;
|
||||||
|
|
||||||
public static FightState getFightState() {
|
|
||||||
return fightState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerStateDependent(IStateDependent stateDependent){
|
public static void registerStateDependent(IStateDependent stateDependent){
|
||||||
if(stateDependent.enabled().isEmpty())
|
if(stateDependent.enabled().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -19,14 +19,28 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface BlockIdWrapper {
|
public interface BlockIdWrapper {
|
||||||
|
Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
|
||||||
|
Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
|
||||||
|
|
||||||
|
Class<?> craftPlayer = Reflection.getClass("{obc}.entity.CraftPlayer");
|
||||||
|
Class<?> entityPlayer = Reflection.getClass("{nms.server.level}.EntityPlayer");
|
||||||
|
Reflection.MethodInvoker getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
|
||||||
|
|
||||||
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
|
Material idToMaterial(int blockState);
|
||||||
int blockToId(Block block);
|
int blockToId(Block block);
|
||||||
void setBlock(World world, int x, int y, int z, int blockState);
|
void setBlock(World world, int x, int y, int z, int blockState);
|
||||||
|
|
||||||
|
void trackEntity(Player player, int entity);
|
||||||
|
void untrackEntity(Player player, int entity);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class EnterHandler implements IStateDependent {
|
|||||||
|
|
||||||
private void registerTeam(FightTeam team){
|
private void registerTeam(FightTeam team){
|
||||||
for(FightPlayer fp : team.getPlayers()){
|
for(FightPlayer fp : team.getPlayers()){
|
||||||
fp.startEnternCountdown();
|
fp.startEnternCountdown(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import de.steamwar.network.packets.common.FightEndsPacket;
|
|||||||
import de.steamwar.sql.Replay;
|
import de.steamwar.sql.Replay;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -46,6 +47,7 @@ import static de.steamwar.sql.Fight.create;
|
|||||||
|
|
||||||
public class FightStatistics {
|
public class FightStatistics {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static boolean unranked = false;
|
private static boolean unranked = false;
|
||||||
|
|
||||||
public static void unrank() {
|
public static void unrank() {
|
||||||
@ -53,10 +55,6 @@ public class FightStatistics {
|
|||||||
FightUI.addSubtitle("UI_UNRANKED");
|
FightUI.addSubtitle("UI_UNRANKED");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUnranked() {
|
|
||||||
return unranked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Timestamp starttime = Timestamp.from(Instant.now());
|
private Timestamp starttime = Timestamp.from(Instant.now());
|
||||||
|
|
||||||
public FightStatistics() {
|
public FightStatistics() {
|
||||||
@ -98,12 +96,12 @@ public class FightStatistics {
|
|||||||
Integer redSchem;
|
Integer redSchem;
|
||||||
try {
|
try {
|
||||||
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
|
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
|
||||||
} catch (SecurityException e) {
|
} catch (NullPointerException e) {
|
||||||
blueSchem = null;
|
blueSchem = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
|
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
|
||||||
} catch (SecurityException e) {
|
} catch (NullPointerException e) {
|
||||||
redSchem = null;
|
redSchem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
|
|||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -43,10 +44,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class FightUI {
|
public class FightUI {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static FightUI instance;
|
private static FightUI instance;
|
||||||
public static FightUI getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FightUI() {
|
public FightUI() {
|
||||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
|
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.fightsystem.utils;
|
|||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -49,4 +50,5 @@ public interface FlatteningWrapper {
|
|||||||
boolean isFacingWater(Block dispenser);
|
boolean isFacingWater(Block dispenser);
|
||||||
|
|
||||||
boolean isCrouching(Player player);
|
boolean isCrouching(Player player);
|
||||||
|
void sendBlockChange(Player player, Block block, Material type);
|
||||||
}
|
}
|
||||||
|
379
FightSystem_Core/src/de/steamwar/fightsystem/utils/Hull.java
Normale Datei
379
FightSystem_Core/src/de/steamwar/fightsystem/utils/Hull.java
Normale Datei
@ -0,0 +1,379 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Hull {
|
||||||
|
|
||||||
|
private static boolean isOccluding(Material material) {
|
||||||
|
return material.isOccluding() || Config.HiddenBlocks.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Region region;
|
||||||
|
private final boolean groundVisible;
|
||||||
|
|
||||||
|
private final BitSet occluding;
|
||||||
|
private final BitSet visibility;
|
||||||
|
private final Map<IntVector, Map<IntVector, BitSet>> blockVisibility = new HashMap<>();
|
||||||
|
private final Set<IntVector> uncoveredSurface = new HashSet<>();
|
||||||
|
|
||||||
|
private final HashSet<Player> players = new HashSet<>();
|
||||||
|
private final Set<Entity> entities = new HashSet<>();
|
||||||
|
private final Set<REntity> rentities = new HashSet<>();
|
||||||
|
|
||||||
|
public Hull(FightTeam team) {
|
||||||
|
this.region = team.getSchemRegion();
|
||||||
|
this.groundVisible = region.getMinY() != Config.PlayerRegion.getMinY();
|
||||||
|
this.occluding = new BitSet(region.volume());
|
||||||
|
this.visibility = new BitSet(region.volume());
|
||||||
|
|
||||||
|
IntVector[] directions;
|
||||||
|
if (groundVisible) {
|
||||||
|
directions = new IntVector[]{
|
||||||
|
new IntVector(1, 0, 0),
|
||||||
|
new IntVector(-1, 0, 0),
|
||||||
|
new IntVector(0, 1, 0),
|
||||||
|
new IntVector(0, -1, 0),
|
||||||
|
new IntVector(0, 0, 1),
|
||||||
|
new IntVector(0, 0, -1)
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
directions = new IntVector[]{
|
||||||
|
new IntVector(1, 0, 0),
|
||||||
|
new IntVector(-1, 0, 0),
|
||||||
|
new IntVector(0, -1, 0),
|
||||||
|
new IntVector(0, 0, 1),
|
||||||
|
new IntVector(0, 0, -1)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate quadrants for each direction
|
||||||
|
for (IntVector direction : directions) {
|
||||||
|
Map<IntVector, BitSet> map = new HashMap<>();
|
||||||
|
for (int z = (direction.z == 0 ? -1 : 0); z <= 1; z += 2) {
|
||||||
|
for (int y = (direction.y == 0 ? -1 : 0); y <= 1; y += 2) {
|
||||||
|
for (int x = (direction.x == 0 ? -1 : 0); x <= 1; x += 2) {
|
||||||
|
map.put(new IntVector(x, y, z), new BitSet(region.volume()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blockVisibility.put(direction, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||||
|
return players.contains(player) && !region.chunkSectionOutside(chunkX, chunkY, chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||||
|
return region.inRegion(x, y, z) && players.contains(player) && !visibility.get(((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocationHidden(Player player, Location location) {
|
||||||
|
return players.contains(player) && region.inRegion(location) && !visibility.get(new IntVector(location).toId(region));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(Player player) {
|
||||||
|
if(players.add(player)) {
|
||||||
|
for(Entity entity : entities)
|
||||||
|
BlockIdWrapper.impl.untrackEntity(player, entity.getEntityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player player, boolean activeRemoval) {
|
||||||
|
if(players.remove(player) && activeRemoval) {
|
||||||
|
for(Entity entity : entities)
|
||||||
|
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
|
||||||
|
// techhider triggers block change sending
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkEntity(Entity entity) {
|
||||||
|
Location location = entity.getLocation();
|
||||||
|
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
|
||||||
|
if(entities.add(entity)) {
|
||||||
|
for(Player player : players)
|
||||||
|
BlockIdWrapper.impl.untrackEntity(player, entity.getEntityId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(entities.remove(entity)) {
|
||||||
|
for(Player player : players)
|
||||||
|
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEntity(Entity entity) {
|
||||||
|
entities.remove(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkREntity(REntity entity) {
|
||||||
|
Location location = new Location(Config.world, entity.getX(), entity.getY(), entity.getZ());
|
||||||
|
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
|
||||||
|
if(rentities.add(entity))
|
||||||
|
entity.hide(true);
|
||||||
|
} else {
|
||||||
|
if(rentities.remove(entity))
|
||||||
|
entity.hide(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeREntity(REntity entity) {
|
||||||
|
rentities.remove(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
visibility.clear();
|
||||||
|
occluding.clear();
|
||||||
|
uncoveredSurface.clear();
|
||||||
|
for (Map<IntVector, BitSet> direction : blockVisibility.values()) {
|
||||||
|
for (BitSet set : direction.values())
|
||||||
|
set.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
region.forEach((x, y, z) -> {
|
||||||
|
IntVector block = new IntVector(x, y, z);
|
||||||
|
if (isOccluding(Config.world.getBlockAt(x, y, z).getType()))
|
||||||
|
occluding.set(block.toId(region));
|
||||||
|
});
|
||||||
|
forEachBorder((root, direction) -> {
|
||||||
|
for (Map.Entry<IntVector, BitSet> quadrant : blockVisibility.get(direction).entrySet()) {
|
||||||
|
checkBlock(new NullList<>(), root, direction, quadrant.getKey(), quadrant.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> "[HullHider] initialisation finished: " + (System.currentTimeMillis() - start) + " ms, visible blocks: " + visibility.cardinality());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateBlockVisibility(Block b, Material changedType) {
|
||||||
|
IntVector root = new IntVector(b.getX(), b.getY(), b.getZ());
|
||||||
|
if (root.notInRegion(region))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int id = root.toId(region);
|
||||||
|
if (!occluding.get(id) || isOccluding(changedType))
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<IntVector> uncovered = new ArrayList<>();
|
||||||
|
occluding.clear(id);
|
||||||
|
for (Map.Entry<IntVector, Map<IntVector, BitSet>> direction : blockVisibility.entrySet()) {
|
||||||
|
for (Map.Entry<IntVector, BitSet> quadrant : direction.getValue().entrySet()) {
|
||||||
|
if (quadrant.getValue().get(id)) {
|
||||||
|
quadrant.getValue().clear(id);
|
||||||
|
checkBlock(uncovered, root, direction.getKey(), quadrant.getKey(), quadrant.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(uncovered.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Set<IntVector> uncoveredSet = new HashSet<>(uncovered);
|
||||||
|
Iterator<Entity> it = entities.iterator();
|
||||||
|
while(it.hasNext()) {
|
||||||
|
Entity entity = it.next();
|
||||||
|
if(uncoveredSet.contains(new IntVector(entity.getLocation()))) { //TODO more precise
|
||||||
|
it.remove();
|
||||||
|
for(Player player : players)
|
||||||
|
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<REntity> rit = rentities.iterator();
|
||||||
|
while(rit.hasNext()) {
|
||||||
|
REntity entity = rit.next();
|
||||||
|
if(uncoveredSet.contains(new IntVector(new Location(Config.world, entity.getX(), entity.getY(), entity.getZ())))) { //TODO more precise
|
||||||
|
rit.remove();
|
||||||
|
entity.hide(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uncoveredSurface.addAll(uncoveredSet);
|
||||||
|
uncoveredSurface.remove(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendUncoveredBlocks() {
|
||||||
|
Map<IntVector, List<IntVector>> sectionWise = new HashMap<>();
|
||||||
|
|
||||||
|
for(IntVector uncovered : uncoveredSurface) {
|
||||||
|
sectionWise.computeIfAbsent(new IntVector(uncovered.x >> 4, uncovered.y >> 4, uncovered.z >> 4), section -> new ArrayList<>()).add(uncovered);
|
||||||
|
}
|
||||||
|
uncoveredSurface.clear();
|
||||||
|
|
||||||
|
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
|
||||||
|
Object packet = HullHiderWrapper.impl.generateBlockChangePacket(entry.getValue());
|
||||||
|
if(packet == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
players.forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forEachBorder(BiConsumer<IntVector, IntVector> f) {
|
||||||
|
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||||
|
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||||
|
if (groundVisible)
|
||||||
|
f.accept(new IntVector(x, region.getMinY(), z), new IntVector(0, 1, 0));
|
||||||
|
f.accept(new IntVector(x, region.getMaxY() - 1, z), new IntVector(0, -1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||||
|
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||||
|
f.accept(new IntVector(x, y, region.getMinZ()), new IntVector(0, 0, 1));
|
||||||
|
f.accept(new IntVector(x, y, region.getMaxZ() - 1), new IntVector(0, 0, -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||||
|
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||||
|
f.accept(new IntVector(region.getMinX(), y, z), new IntVector(1, 0, 0));
|
||||||
|
f.accept(new IntVector(region.getMaxX() - 1, y, z), new IntVector(-1, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkBlock(List<IntVector> uncovered, IntVector block, IntVector direction, IntVector quadrant, BitSet quadVisibility) {
|
||||||
|
if (block.notInRegion(region))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int id = block.toId(region);
|
||||||
|
if (quadVisibility.get(id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
quadVisibility.set(id);
|
||||||
|
if (!visibility.get(id)) {
|
||||||
|
visibility.set(id);
|
||||||
|
uncovered.add(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (occluding.get(id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
IntVector neighbour = block.add(direction);
|
||||||
|
checkBlock(uncovered, neighbour, direction, quadrant, quadVisibility);
|
||||||
|
boolean neigbourTransparent = boundedNonOccluding(neighbour);
|
||||||
|
boolean diagonalReachable = false;
|
||||||
|
if (direction.x == 0 && (neigbourTransparent || boundedNonOccluding(block.add(quadrant.x, 0, 0)))) {
|
||||||
|
checkBlock(uncovered, neighbour.add(quadrant.x, 0, 0), direction, quadrant, quadVisibility);
|
||||||
|
diagonalReachable = boundedNonOccluding(neighbour.add(quadrant.x, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction.y == 0 && (neigbourTransparent || boundedNonOccluding(block.add(0, quadrant.y, 0)))) {
|
||||||
|
checkBlock(uncovered, neighbour.add(0, quadrant.y, 0), direction, quadrant, quadVisibility);
|
||||||
|
diagonalReachable = diagonalReachable || boundedNonOccluding(neighbour.add(0, quadrant.y, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction.z == 0 && (neigbourTransparent || boundedNonOccluding(block.add(0, 0, quadrant.z)))) {
|
||||||
|
checkBlock(uncovered, neighbour.add(0, 0, quadrant.z), direction, quadrant, quadVisibility);
|
||||||
|
diagonalReachable = diagonalReachable || boundedNonOccluding(neighbour.add(0, 0, quadrant.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diagonalReachable)
|
||||||
|
checkBlock(uncovered, neighbour.add(quadrant), direction, quadrant, quadVisibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean boundedNonOccluding(IntVector block) {
|
||||||
|
return !(block.notInRegion(region) || occluding.get(block.toId(region)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class IntVector {
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
public IntVector(Location location) {
|
||||||
|
this.x = location.getBlockX();
|
||||||
|
this.y = location.getBlockY();
|
||||||
|
this.z = location.getBlockZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean notInRegion(Region region) {
|
||||||
|
return !region.inRegion(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int toId(Region region) {
|
||||||
|
return ((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntVector add(int x, int y, int z) {
|
||||||
|
return new IntVector(this.x + x, this.y + y, this.z + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntVector add(IntVector v) {
|
||||||
|
return add(v.x, v.y, v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return y << 24 ^ x << 12 ^ z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if(o == null || this.getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IntVector v = (IntVector) o;
|
||||||
|
return x == v.x && y == v.y && z == v.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return x + "," + y + "," + z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class NullList<E> extends AbstractList<E> {
|
||||||
|
@Override
|
||||||
|
public void add(int index, E element) {
|
||||||
|
// Straight to /dev/null!
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E get(int index) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
241
FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java
Normale Datei
241
FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java
Normale Datei
@ -0,0 +1,241 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
|
import de.steamwar.techhider.TechHider;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
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;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class HullHider implements Listener {
|
||||||
|
|
||||||
|
private final Map<FightTeam, Hull> hullMap = new HashMap<>();
|
||||||
|
private final Hull[] hulls;
|
||||||
|
private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>();
|
||||||
|
|
||||||
|
public HullHider() {
|
||||||
|
if(!TechHiderWrapper.ENABLED) {
|
||||||
|
hulls = new Hull[0];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Fight.teams().forEach(team -> hullMap.put(team, new Hull(team)));
|
||||||
|
hulls = hullMap.values().toArray(new Hull[0]);
|
||||||
|
|
||||||
|
packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider);
|
||||||
|
packetHiders.put(packetPlayOutExplosion, this::explosionHider);
|
||||||
|
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutWorldParticles", Core.getVersion() >= 18 ? double.class : float.class, 1.0);
|
||||||
|
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutNamedSoundEffect", int.class, 8.0);
|
||||||
|
if(Core.getVersion() >= 9 && Core.getVersion() < 18)
|
||||||
|
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutCustomSoundEffect", int.class, 8.0);
|
||||||
|
|
||||||
|
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this);
|
||||||
|
new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) {
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
packetHiders.forEach(TinyProtocol.instance::addFilter);
|
||||||
|
Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true));
|
||||||
|
packetHiders.forEach(TinyProtocol.instance::removeFilter);
|
||||||
|
}
|
||||||
|
}.register();
|
||||||
|
new StateDependentTask(TechHiderWrapper.ENABLED, FightState.Schem, this::onTick, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(FightTeam team) {
|
||||||
|
if(!TechHiderWrapper.ENABLED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
hullMap.get(team).initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
updatePlayer(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
|
removePlayer(e.getPlayer(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePlayer(Player player) {
|
||||||
|
if(!TechHiderWrapper.ENABLED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
FightPlayer fp = Fight.getFightPlayer(player);
|
||||||
|
for(Map.Entry<FightTeam, Hull> hull : hullMap.entrySet()) {
|
||||||
|
if(Config.isReferee(player) || hull.getKey() == team || (fp != null && fp.canEntern())) {
|
||||||
|
hull.getValue().removePlayer(player, true);
|
||||||
|
} else {
|
||||||
|
hull.getValue().addPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePlayer(Player player, boolean activeRemoval) {
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
hull.removePlayer(player, activeRemoval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||||
|
if(FlatteningWrapper.impl.doRecord(e))
|
||||||
|
blockUpdate(e.getBlock(), e.getChangedType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void blockUpdate(Block block, Material changedType) {
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
hull.updateBlockVisibility(block, changedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||||
|
if(!TechHiderWrapper.ENABLED)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
if(hull.isBlockHidden(player, x, y, z))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||||
|
if(!TechHiderWrapper.ENABLED)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
if(hull.blockPrecise(player, chunkX, chunkY, chunkZ))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onSpawn(EntitySpawnEvent e) {
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
hull.checkEntity(e.getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onTick() {
|
||||||
|
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
hull.checkEntity(entity);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (Hull hull : hulls)
|
||||||
|
hull.sendUncoveredBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onDeath(EntityDeathEvent e) {
|
||||||
|
for(Hull hull : hulls)
|
||||||
|
hull.removeEntity(e.getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateREntity(REntity e) {
|
||||||
|
for(Hull hull : hulls)
|
||||||
|
hull.checkREntity(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void despawnREntity(REntity e) {
|
||||||
|
for(Hull hull : hulls)
|
||||||
|
hull.removeREntity(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final Class<?> packetPlayOutWorldEvent = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutWorldEvent");
|
||||||
|
private static final Reflection.FieldAccessor<?> worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0);
|
||||||
|
public static final Reflection.FieldAccessor<Integer> blockPositionY = Reflection.getField("{nms.core}.BaseBlockPosition", int.class, 1);
|
||||||
|
private Object worldEventHider(Player player, Object packet) {
|
||||||
|
Object baseBlock = worldEventPosition.get(packet);
|
||||||
|
return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||||
|
private static final Reflection.FieldAccessor<List> explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0);
|
||||||
|
private static final Function<Object, Location> explosionLocation = posPacketToLocation(packetPlayOutExplosion, double.class, 1.0);
|
||||||
|
private Object explosionHider(Player player, Object packet) {
|
||||||
|
if(explosionBlocks.get(packet).isEmpty())
|
||||||
|
return packetHider(player, packet, explosionLocation.apply(packet));
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void posHiderGenerator(String typeName, Class<? extends Number> posType, double factor) {
|
||||||
|
Class<?> type = Reflection.getClass(typeName);
|
||||||
|
Function<Object, Location> location = posPacketToLocation(type, posType, factor);
|
||||||
|
packetHiders.put(type, (player, packet) -> packetHider(player, packet, location.apply(packet)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Function<Object, Location> posPacketToLocation(Class<?> type, Class<? extends Number> posType, double factor) {
|
||||||
|
Reflection.FieldAccessor<? extends Number> x = Reflection.getField(type, posType, 0);
|
||||||
|
Reflection.FieldAccessor<? extends Number> y = Reflection.getField(type, posType, 1);
|
||||||
|
Reflection.FieldAccessor<? extends Number> z = Reflection.getField(type, posType, 2);
|
||||||
|
|
||||||
|
return packet -> new Location(Config.world, x.get(packet).doubleValue()/factor, y.get(packet).doubleValue()/factor, z.get(packet).doubleValue()/factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object packetHider(Player player, Object packet, Location location) {
|
||||||
|
for(Hull hull : hulls) {
|
||||||
|
if(hull.isLocationHidden(player, location))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.core.VersionDependent;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface HullHiderWrapper {
|
||||||
|
HullHiderWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
|
Object generateBlockChangePacket(List<Hull.IntVector> changes);
|
||||||
|
}
|
@ -25,51 +25,26 @@ import org.bukkit.inventory.ItemFlag;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemBuilder {
|
public class ItemBuilder {
|
||||||
|
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
private final ItemMeta meta;
|
private final ItemMeta meta;
|
||||||
|
|
||||||
public ItemBuilder(Material matrial) {
|
public ItemBuilder(Material material) {
|
||||||
item = new ItemStack(matrial);
|
item = new ItemStack(material);
|
||||||
meta = item.getItemMeta();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder(Material matrial, int amount) {
|
|
||||||
item = new ItemStack(matrial, amount);
|
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
|
meta.addItemFlags(ItemFlag.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ItemBuilder(Material matrial, short subid) {
|
public ItemBuilder(Material material, short subid) {
|
||||||
item = new ItemStack(matrial, 1, subid);
|
item = new ItemStack(material, 1, subid);
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
|
meta.addItemFlags(ItemFlag.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder removeAllAttributes() {
|
public ItemBuilder enchant() {
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder setDisplayName(String name) {
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder addLore(List<String> lore) {
|
|
||||||
meta.setLore(lore);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
|
|
||||||
meta.addEnchant(enchantment, level, true);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,5 +52,4 @@ public class ItemBuilder {
|
|||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
private final String msg;
|
private final String msg;
|
||||||
private final Object[] params;
|
private final Object[] params;
|
||||||
|
|
||||||
@ -27,12 +31,4 @@ public class Message {
|
|||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[] getParams() {
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,28 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.techhider.ProtocolUtils;
|
import de.steamwar.techhider.ProtocolUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import java.util.function.ObjIntConsumer;
|
import java.util.function.ObjIntConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
public class Region {
|
public class Region {
|
||||||
|
|
||||||
|
public static final Region EMPTY = Region.fromSize(-10000, -10000, -10000, 0, 0, 0);
|
||||||
|
|
||||||
|
public static Region withExtension(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
|
||||||
|
return Region.fromSize(minX - extendX, minY - extendY, minZ - extendZ,
|
||||||
|
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Region fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||||
|
return new Region(minX, minY, minZ, minX+sizeX, minY+sizeY, minZ+sizeZ);
|
||||||
|
}
|
||||||
|
|
||||||
private final int minX;
|
private final int minX;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
private final int minZ;
|
private final int minZ;
|
||||||
@ -34,48 +49,14 @@ public class Region {
|
|||||||
private final int maxY;
|
private final int maxY;
|
||||||
private final int maxZ;
|
private final int maxZ;
|
||||||
|
|
||||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
|
|
||||||
this(minX - extendX, minY - extendY, minZ - extendZ,
|
|
||||||
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
|
||||||
this.minX = minX;
|
|
||||||
this.minY = minY;
|
|
||||||
this.minZ = minZ;
|
|
||||||
this.maxX = minX + sizeX;
|
|
||||||
this.maxY = minY + sizeY;
|
|
||||||
this.maxZ = minZ + sizeZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinX() {
|
|
||||||
return minX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinY() {
|
|
||||||
return minY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinZ() {
|
|
||||||
return minZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxX() {
|
|
||||||
return maxX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxY() {
|
|
||||||
return maxY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxZ() {
|
|
||||||
return maxZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSizeX() {
|
public int getSizeX() {
|
||||||
return maxX - minX;
|
return maxX - minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSizeY() {
|
||||||
|
return maxY - minY;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSizeZ() {
|
public int getSizeZ() {
|
||||||
return maxZ - minZ;
|
return maxZ - minZ;
|
||||||
}
|
}
|
||||||
@ -101,6 +82,12 @@ public class Region {
|
|||||||
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean chunkSectionOutside(int cX, int cY, int cZ) {
|
||||||
|
return getMinChunkX() > cX || cX > getMaxChunkX() ||
|
||||||
|
ProtocolUtils.posToChunk(minY) > cY || cY > ProtocolUtils.posToChunk(maxY) ||
|
||||||
|
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||||
|
}
|
||||||
|
|
||||||
public void forEachChunk(ObjIntConsumer<Integer> executor) {
|
public void forEachChunk(ObjIntConsumer<Integer> executor) {
|
||||||
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
|
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
|
||||||
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
|
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
|
||||||
@ -110,7 +97,7 @@ public class Region {
|
|||||||
public void forEach(TriConsumer<Integer, Integer, Integer> executor) {
|
public void forEach(TriConsumer<Integer, Integer, Integer> executor) {
|
||||||
for(int x = minX; x < maxX; x++) {
|
for(int x = minX; x < maxX; x++) {
|
||||||
for(int y = minY; y < maxY; y++) {
|
for(int y = minY; y < maxY; y++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z < maxZ; z++) {
|
||||||
executor.accept(x, y, z);
|
executor.accept(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +125,7 @@ public class Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerInRegion(Location location){
|
public boolean playerInRegion(Location location){
|
||||||
return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY;
|
return in2dRegion(location) && minY <= location.getY() && location.getY() < maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean in2dRegion(Block block){
|
public boolean in2dRegion(Block block){
|
||||||
@ -146,13 +133,29 @@ public class Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean in2dRegion(int x, int z) {
|
public boolean in2dRegion(int x, int z) {
|
||||||
return minX <= x && x < maxX && minZ <= z && z <= maxZ;
|
return minX <= x && x < maxX && minZ <= z && z < maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inRegion(Block block){
|
public boolean inRegion(Block block){
|
||||||
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
|
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean inRegion(int x, int y, int z) {
|
||||||
|
return in2dRegion(x, z) && minY <= y && y < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Region intersection(Region other) {
|
||||||
|
int x = Math.max(minX, other.minX);
|
||||||
|
int y = Math.max(minY, other.minY);
|
||||||
|
int z = Math.max(minZ, other.minZ);
|
||||||
|
|
||||||
|
return new Region(x, y, z, Math.min(maxX, other.maxX), Math.min(maxY, other.maxY), Math.min(maxZ, other.maxZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Region to2d() {
|
||||||
|
return new Region(minX, Integer.MIN_VALUE/2, minZ, maxX, Integer.MAX_VALUE/2, maxZ);
|
||||||
|
}
|
||||||
|
|
||||||
public interface TriConsumer<T, V, U>{
|
public interface TriConsumer<T, V, U>{
|
||||||
void accept(T x, V y, U z);
|
void accept(T x, V y, U z);
|
||||||
}
|
}
|
||||||
|
@ -22,30 +22,34 @@ package de.steamwar.fightsystem.utils;
|
|||||||
import de.steamwar.core.CraftbukkitWrapper;
|
import de.steamwar.core.CraftbukkitWrapper;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
|
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.techhider.ProtocolUtils;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.techhider.TechHider;
|
import de.steamwar.techhider.TechHider;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TechHiderWrapper extends StateDependent {
|
public class TechHiderWrapper extends StateDependent implements TechHider.LocationEvaluator, Listener {
|
||||||
|
|
||||||
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
||||||
private final TechHider techHider;
|
private final TechHider techHider;
|
||||||
|
|
||||||
public TechHiderWrapper() {
|
public TechHiderWrapper() {
|
||||||
super(ENABLED, FightState.Schem);
|
super(ENABLED, FightState.Schem);
|
||||||
techHider = new TechHider(this::bypass, Material.getMaterial(Config.ObfuscateWith), Config.HiddenBlocks.stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet()), Config.HiddenBlockEntities);
|
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
|
||||||
|
|
||||||
|
new StateDependentListener(ENABLED, FightState.Schem, this);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,43 +61,82 @@ public class TechHiderWrapper extends StateDependent {
|
|||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
techHider.disable();
|
techHider.disable();
|
||||||
|
hiddenRegion.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProtocolUtils.ChunkPos> prepareChunkReload(LivingEntity p, boolean hide) {
|
@EventHandler
|
||||||
if(!ENABLED || !(p instanceof Player))
|
public void teamJoin(TeamSpawnEvent e) {
|
||||||
return Collections.emptyList();
|
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
|
||||||
|
}
|
||||||
|
|
||||||
List<ProtocolUtils.ChunkPos> chunksToReload = new ArrayList<>();
|
@EventHandler
|
||||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
public void boarding(BoardingEvent e) {
|
||||||
if(bypass((Player) p, x, z) == hide)
|
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
|
||||||
chunksToReload.add(new ProtocolUtils.ChunkPos(x, z));
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamLeave(TeamLeaveEvent e) {
|
||||||
|
e.getFightPlayer().ifPlayer(player -> {
|
||||||
|
if(player.isOnline())
|
||||||
|
hiddenRegion.put(player, getHiddenRegion(player));
|
||||||
});
|
});
|
||||||
return chunksToReload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadChunks(Player p, List<ProtocolUtils.ChunkPos> chunksToReload, boolean hide) {
|
@EventHandler
|
||||||
if(!ENABLED || !FightState.Schem.contains(FightState.getFightState()))
|
public void playerQuit(PlayerQuitEvent e) {
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
hiddenRegion.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadChunks(Player player, Region region, Region exclusion) {
|
||||||
|
if(!ENABLED || !FightState.Schem.contains(FightState.getFightState()) || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
region.forEachChunk((chunkX, chunkZ) -> {
|
||||||
for(ProtocolUtils.ChunkPos chunk : chunksToReload){
|
if(exclusion.chunkOutside(chunkX, chunkZ))
|
||||||
if(bypass(p, chunk.x(), chunk.z()) != hide)
|
CraftbukkitWrapper.impl.sendChunk(player, chunkX, chunkZ);
|
||||||
CraftbukkitWrapper.impl.sendChunk(p, chunk.x(), chunk.z());
|
});
|
||||||
}
|
|
||||||
}, 40);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean bypass(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
if(Config.isReferee(p))
|
public boolean skipChunk(Player player, int chunkX, int chunkZ) {
|
||||||
return true;
|
return getHiddenRegion(player).chunkOutside(chunkX, chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
FightTeam ft = Fight.getPlayerTeam(p);
|
@Override
|
||||||
if(ft == null){
|
public boolean skipChunkSection(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||||
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
return getHiddenRegion(player).chunkSectionOutside(chunkX, chunkY, chunkZ);
|
||||||
}else if(ft.isBlue()){
|
}
|
||||||
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
|
||||||
}else{
|
@Override
|
||||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
public TechHider.State check(Player player, int x, int y, int z) {
|
||||||
|
if(hiddenRegion.computeIfAbsent(player, this::getHiddenRegion).inRegion(x, y, z)) {
|
||||||
|
if(FightSystem.getHullHider().isBlockHidden(player, x, y, z)) {
|
||||||
|
return TechHider.State.HIDE;
|
||||||
|
} else {
|
||||||
|
return TechHider.State.CHECK;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return TechHider.State.SKIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||||
|
return FightSystem.getHullHider().blockPrecise(player, chunkX, chunkY, chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Region getHiddenRegion(Player player) {
|
||||||
|
if(Config.isReferee(player))
|
||||||
|
return Region.EMPTY;
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null)
|
||||||
|
return Config.ArenaRegion;
|
||||||
|
|
||||||
|
if(team.canPlayerEntern(player))
|
||||||
|
return Region.EMPTY;
|
||||||
|
|
||||||
|
return Fight.getOpposite(team).getExtendRegion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.countdown.Countdown;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
@ -34,8 +35,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public abstract class Wincondition {
|
public abstract class Wincondition {
|
||||||
|
|
||||||
protected static PercentWincondition percentWincondition = null;
|
@Getter
|
||||||
|
protected static WinconditionPercent percentWincondition = null;
|
||||||
protected static StateDependentCountdown timeOverCountdown = null;
|
protected static StateDependentCountdown timeOverCountdown = null;
|
||||||
|
@Getter
|
||||||
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
|
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
|
||||||
|
|
||||||
private final String windescription;
|
private final String windescription;
|
||||||
@ -61,14 +64,6 @@ public abstract class Wincondition {
|
|||||||
return Fight.getPlayerTeam((LivingEntity) player);
|
return Fight.getPlayerTeam((LivingEntity) player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<PrintableWincondition> getPrintableWinconditions(){
|
|
||||||
return printableWinconditions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PercentWincondition getPercentWincondition() {
|
|
||||||
return percentWincondition;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
|
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
|
||||||
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
|
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
|
||||||
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());
|
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());
|
||||||
|
@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class WinconditionAllDead extends Wincondition implements Listener {
|
public class WinconditionAllDead extends Wincondition implements Listener {
|
||||||
|
|
||||||
@ -38,25 +35,12 @@ public class WinconditionAllDead extends Wincondition implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(EntityDeathEvent event) {
|
public void handlePlayerDeath(TeamDeathEvent event) {
|
||||||
handleDeath(event.getEntity());
|
FightTeam team = event.getFightPlayer().getTeam();
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
if(team.getAlivePlayers() > 0)
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
||||||
handleDeath(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDeath(Entity player){
|
|
||||||
FightTeam team = isTarget(player);
|
|
||||||
if(team == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(FightPlayer fp : team.getPlayers()) {
|
|
||||||
if(fp.isLiving() && fp.getEntity() != player)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
|
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
|
||||||
|
|
||||||
public class WinconditionBlacklistPercent extends PercentWincondition {
|
|
||||||
|
|
||||||
public WinconditionBlacklistPercent(){
|
|
||||||
super("RelativePercent", Winconditions.RELATIVE_PERCENT);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,16 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class WinconditionCaptainDead extends Wincondition implements Listener {
|
public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||||
|
|
||||||
@ -38,22 +36,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(EntityDeathEvent event) {
|
public void handlePlayerDeath(TeamDeathEvent event) {
|
||||||
handleDeath(event.getEntity());
|
FightPlayer leader = event.getFightPlayer();
|
||||||
}
|
if(!leader.isLeader())
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
||||||
handleDeath(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDeath(Entity player){
|
|
||||||
FightTeam team = isTarget(player);
|
|
||||||
if(team == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(team.isPlayerLeader((LivingEntity) player)) {
|
FightTeam team = leader.getTeam();
|
||||||
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getEntity().getName());
|
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -34,27 +33,12 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.BooleanSupplier;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.function.ToIntFunction;
|
|
||||||
|
|
||||||
public class PercentWincondition extends Wincondition implements PrintableWincondition {
|
public class WinconditionPercent extends Wincondition implements PrintableWincondition {
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||||
|
|
||||||
protected BooleanSupplier explosionFilter = () -> !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft();
|
|
||||||
protected Predicate<Material> testBlock = type -> !Config.PercentBlocks.contains(type);
|
|
||||||
protected ToIntFunction<FightTeam> totalBlockCalc = team -> {
|
|
||||||
AtomicInteger blocks = new AtomicInteger();
|
|
||||||
team.getSchemRegion().forEach((x, y, z) -> {
|
|
||||||
if (testBlock.test(Config.world.getBlockAt(x, y, z).getType())) {
|
|
||||||
blocks.getAndIncrement();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return blocks.get();
|
|
||||||
};
|
|
||||||
protected Consumer<FightTeam> checkWin = team -> {
|
protected Consumer<FightTeam> checkWin = team -> {
|
||||||
if (getPercent(team) >= Config.PercentWin) {
|
if (getPercent(team) >= Config.PercentWin) {
|
||||||
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
|
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
|
||||||
@ -62,7 +46,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
};
|
};
|
||||||
protected Consumer<FightTeam> postEnable = team -> {};
|
protected Consumer<FightTeam> postEnable = team -> {};
|
||||||
|
|
||||||
public PercentWincondition(String windescription, Winconditions wincondition) {
|
public WinconditionPercent(Winconditions wincondition, String windescription) {
|
||||||
super(windescription);
|
super(windescription);
|
||||||
|
|
||||||
if (Config.ActiveWinconditions.contains(wincondition)) {
|
if (Config.ActiveWinconditions.contains(wincondition)) {
|
||||||
@ -74,7 +58,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Message getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0));
|
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.PercentWin)) / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPercent(FightTeam team) {
|
public double getPercent(FightTeam team) {
|
||||||
@ -105,12 +89,16 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
if (event.getEntityType() == EntityType.FIREBALL || explosionFilter.getAsBoolean() || !team.getExtendRegion().inRegion(event.getEntity().getLocation())) {
|
if (
|
||||||
|
event.getEntityType() == EntityType.FIREBALL ||
|
||||||
|
!team.getExtendRegion().inRegion(event.getEntity().getLocation()) ||
|
||||||
|
(!Config.PercentEntern && !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
if (testBlock.test(block.getType())) {
|
if (Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
||||||
currentBlocks--;
|
currentBlocks--;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -119,7 +107,11 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enable() {
|
private void enable() {
|
||||||
totalBlocks = totalBlockCalc.applyAsInt(team);
|
totalBlocks = 0;
|
||||||
|
team.getSchemRegion().forEach((x, y, z) -> {
|
||||||
|
if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist)
|
||||||
|
totalBlocks++;
|
||||||
|
});
|
||||||
currentBlocks = totalBlocks;
|
currentBlocks = totalBlocks;
|
||||||
postEnable.accept(team);
|
postEnable.accept(team);
|
||||||
}
|
}
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
|
||||||
|
|
||||||
public class WinconditionPercentSystem extends PercentWincondition {
|
|
||||||
|
|
||||||
public WinconditionPercentSystem() {
|
|
||||||
super("Percent", Winconditions.PERCENT_SYSTEM);
|
|
||||||
|
|
||||||
totalBlockCalc = team -> team.getSchemRegion().volume();
|
|
||||||
explosionFilter = () -> false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,12 +36,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WinconditionPoints extends PercentWincondition implements Listener {
|
public class WinconditionPoints extends WinconditionPercent implements Listener {
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
||||||
|
|
||||||
public WinconditionPoints(){
|
public WinconditionPoints(){
|
||||||
super("Points", Winconditions.POINTS);
|
super(Winconditions.POINTS, "Points");
|
||||||
|
|
||||||
checkWin = team -> {};
|
checkWin = team -> {};
|
||||||
postEnable = this::pointInit;
|
postEnable = this::pointInit;
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class WinconditionPointsAirShip extends PercentWincondition implements Listener {
|
public class WinconditionPointsAirShip extends WinconditionPercent implements Listener {
|
||||||
|
|
||||||
private double[] as = new double[] {
|
private double[] as = new double[] {
|
||||||
0.5,
|
0.5,
|
||||||
@ -56,7 +56,7 @@ public class WinconditionPointsAirShip extends PercentWincondition implements Li
|
|||||||
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
||||||
|
|
||||||
public WinconditionPointsAirShip(){
|
public WinconditionPointsAirShip(){
|
||||||
super("Points", Winconditions.POINTS_AIRSHIP);
|
super(Winconditions.POINTS_AIRSHIP, "Points");
|
||||||
|
|
||||||
checkWin = team -> {
|
checkWin = team -> {
|
||||||
if (teamMap.get(team).getPoints() > TeamPoints.WIN_POINTS) {
|
if (teamMap.get(team).getPoints() > TeamPoints.WIN_POINTS) {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2021 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
|
|
||||||
public class WinconditionWhitelistPercent extends PercentWincondition {
|
|
||||||
|
|
||||||
public WinconditionWhitelistPercent() {
|
|
||||||
super("WhitelistPercent", Winconditions.WHITELIST_PERCENT);
|
|
||||||
|
|
||||||
testBlock = Config.PercentBlocks::contains;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,8 +28,6 @@ public enum Winconditions {
|
|||||||
CAPTAIN_DEAD,
|
CAPTAIN_DEAD,
|
||||||
|
|
||||||
PERCENT_SYSTEM,
|
PERCENT_SYSTEM,
|
||||||
WHITELIST_PERCENT,
|
|
||||||
RELATIVE_PERCENT,
|
|
||||||
POINTS,
|
POINTS,
|
||||||
POINTS_AIRSHIP,
|
POINTS_AIRSHIP,
|
||||||
|
|
||||||
@ -39,5 +37,7 @@ public enum Winconditions {
|
|||||||
|
|
||||||
HELLS_BELLS,
|
HELLS_BELLS,
|
||||||
METEOR,
|
METEOR,
|
||||||
AMONG_US
|
AMONG_US,
|
||||||
|
PERSISTENT_DAMAGE,
|
||||||
|
TNT_DISTRIBUTION
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,6 @@ commands:
|
|||||||
win:
|
win:
|
||||||
resetwg:
|
resetwg:
|
||||||
resettb:
|
resettb:
|
||||||
|
tpslimit:
|
||||||
|
tpswarp:
|
||||||
unrank:
|
unrank:
|
@ -46,11 +46,6 @@ mainClassName = ''
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
|
||||||
|
|
||||||
maven {
|
|
||||||
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
|
|
||||||
}
|
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren