SteamWar/FightSystem
Archiviert
13
1

Commits vergleichen

..

3 Commits

Autor SHA1 Nachricht Datum
64d34063b8 Remove nocom detection
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-02-17 15:15:08 +01:00
75e3096b55 Merge branch 'master' into antiCheat
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
2023-01-17 16:58:45 +01:00
36fd4941b5 WIP anti cheat
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2022-12-07 12:02:26 +01:00
123 geänderte Dateien mit 1960 neuen und 3585 gelöschten Zeilen

Datei anzeigen

@ -25,8 +25,14 @@ import net.minecraft.server.v1_10_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper10 implements CraftbukkitWrapper { public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
@ -39,18 +45,31 @@ 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();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -25,8 +25,14 @@ import net.minecraft.server.v1_12_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper12 implements CraftbukkitWrapper { public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
@ -39,18 +45,31 @@ 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();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -46,8 +46,6 @@ 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")

Datei anzeigen

@ -19,77 +19,32 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection; import net.minecraft.server.v1_14_R1.*;
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 org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
import java.util.Map; import java.util.Objects;
public class BlockIdWrapper14 implements BlockIdWrapper { public class BlockIdWrapper14 implements BlockIdWrapper {
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<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
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 getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
@Override @Override
public int blockToId(Block block) { public int blockToId(Block block) {
return (int) getCombinedId.invoke(null, getNMS.invoke(block)); return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
} }
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, 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 removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", 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) {
Object blockData = getByCombinedId.invoke(null, blockState); IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.fromId(blockState));
Object nworld = getWorldHandle.invoke(world); WorldServer cworld = ((CraftWorld)world).getHandle();
Object pos = newBlockPosition.invoke(x, y, z); BlockPosition pos = new BlockPosition(x, y, z);
cworld.removeTileEntity(pos);
removeTileEntity.invoke(nworld, pos); cworld.setTypeAndData(pos, blockData, 1042);
getTypeAndData.invoke(nworld, pos, blockData, 1042); cworld.getChunkProvider().flagDirty(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 @Override
public void trackEntity(Player player, int entity) { public Object getPose(boolean sneaking) {
Object tracker = trackers.get(entity); return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING;
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)));
} }
} }

Datei anzeigen

@ -25,8 +25,14 @@ import net.minecraft.server.v1_14_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper14 implements CraftbukkitWrapper { public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
@ -38,7 +44,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();
@ -47,11 +53,24 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
chunk.heightMap.putAll(backupChunk.heightMap); chunk.heightMap.putAll(backupChunk.heightMap);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();

Datei anzeigen

@ -25,9 +25,6 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Dispenser;
import org.bukkit.entity.Player;
import org.bukkit.entity.Pose;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.BlockDataMeta;
@ -55,8 +52,7 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
@Override @Override
public boolean removeWater(Block block) { public boolean removeWater(Block block) {
Material type = block.getType(); if(block.getType() == Material.WATER){
if(type == Material.WATER || type == Material.LAVA){
block.setType(Material.AIR); block.setType(Material.AIR);
return true; return true;
} }
@ -84,6 +80,23 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers(); return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
} }
@Override
public ItemStack onBreak(Block block) {
Material type = block.getType();
switch(type){
case REDSTONE_WIRE:
type = Material.REDSTONE;
break;
case PISTON_HEAD:
type = Material.PISTON;
break;
case ICE:
type = Material.AIR;
break;
}
return new ItemStack(type);
}
@Override @Override
public boolean doRecord(BlockPhysicsEvent e) { public boolean doRecord(BlockPhysicsEvent e) {
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR; return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
@ -98,19 +111,4 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
public boolean checkPistonMoving(Block block) { public boolean checkPistonMoving(Block block) {
return block.getType() == Material.MOVING_PISTON; return block.getType() == Material.MOVING_PISTON;
} }
@Override
public boolean isFacingWater(Block dispenser) {
return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid();
}
@Override
public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING;
}
@Override
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type.createBlockData());
}
} }

Datei anzeigen

@ -0,0 +1,50 @@
/*
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.utils;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import java.util.Objects;
public class BlockIdWrapper15 implements BlockIdWrapper {
@Override
public int blockToId(Block block) {
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
}
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.fromId(blockState));
WorldServer cworld = ((CraftWorld)world).getHandle();
BlockPosition pos = new BlockPosition(x, y, z);
cworld.removeTileEntity(pos);
cworld.setTypeAndData(pos, blockData, 1042);
cworld.getChunkProvider().flagDirty(pos);
}
@Override
public Object getPose(boolean sneaking) {
return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING;
}
}

Datei anzeigen

@ -25,8 +25,14 @@ import net.minecraft.server.v1_15_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper15 implements CraftbukkitWrapper { public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
@ -38,7 +44,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();
@ -47,11 +53,24 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
chunk.heightMap.putAll(backupChunk.heightMap); chunk.heightMap.putAll(backupChunk.heightMap);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();

Datei anzeigen

@ -48,7 +48,6 @@ 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")

Datei anzeigen

@ -0,0 +1,54 @@
/*
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.utils;
import net.minecraft.core.BlockPosition;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.EntityPose;
import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
import java.util.Objects;
public class BlockIdWrapper18 implements BlockIdWrapper {
@Override
public int blockToId(Block block) {
return net.minecraft.world.level.block.Block.i(((CraftBlock)block).getNMS());
}
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
IBlockData blockData = Objects.requireNonNull(net.minecraft.world.level.block.Block.a(blockState));
WorldServer cworld = ((CraftWorld)world).getHandle();
BlockPosition pos = new BlockPosition(x, y, z);
cworld.m(pos);
cworld.a(pos, blockData, 1042);
cworld.k().a(pos);
}
@Override
public Object getPose(boolean sneaking) {
return sneaking ? EntityPose.f : EntityPose.a;
}
}

Datei anzeigen

@ -19,47 +19,53 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.chunk.Chunk; import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.ChunkSection;
import net.minecraft.world.level.entity.LevelEntityGetter;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
public class CraftbukkitWrapper18 implements CraftbukkitWrapper { public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle"); @Override
private static final Reflection.MethodInvoker getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class); public void resetChunk(World world, World backup, int x, int z) {
private static final Reflection.MethodInvoker getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class); net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
private ChunkSection[] getChunkSections(World world, int x, int z) { Chunk chunk = w.d(x, z);
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z)); Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
} }
@Override @Override
public void resetChunk(World world, World backup, int x, int z) { public void sendResourcePack(Player player, String pack, String sha1) {
ChunkSection[] sections = getChunkSections(world, x, z); ((CraftPlayer)player).getHandle().a(pack, sha1, true, null);
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
}
private static final Reflection.MethodInvoker getEntity = Reflection.getTypedMethod(Reflection.getClass("{obc}.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
} }
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return getEntity(e).ce(); return ((CraftEntity)e).getHandle().ce();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).t().d());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
} }
private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false); return StreamSupport.stream(((CraftWorld) Config.world).getHandle().H().a().spliterator(), false);
} }
} }

Datei anzeigen

@ -1,82 +0,0 @@
/*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
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.utils;
import net.minecraft.core.BlockPosition;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.EntityPose;
import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock;
import java.util.Objects;
public class BlockIdWrapper19 implements BlockIdWrapper {
@Override
public int blockToId(Block block) {
return net.minecraft.world.level.block.Block.i(((CraftBlock)block).getNMS());
}
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
IBlockData blockData = Objects.requireNonNull(net.minecraft.world.level.block.Block.a(blockState));
WorldServer cworld = ((CraftWorld)world).getHandle();
BlockPosition pos = new BlockPosition(x, y, z);
cworld.m(pos);
cworld.a(pos, blockData, 1042);
cworld.k().a(pos);
}
@Override
public Object getPose(boolean sneaking) {
return sneaking ? EntityPose.f : EntityPose.a;
}
}

Datei anzeigen

@ -19,12 +19,53 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import net.minecraft.world.level.chunk.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 { import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class CraftbukkitWrapper19 implements CraftbukkitWrapper {
@Override
public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.d(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
}
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().a(pack, sha1, true, null);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return getEntity(e).ck(); return ((CraftEntity)e).getHandle().cg();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).u().d());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override
public Stream<?> entityIterator() {
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().F().a().spliterator(), false);
} }
} }

Datei anzeigen

@ -1,52 +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/>.
*/
plugins {
id 'java'
}
group 'steamwar'
version '1.0'
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDirs = ['src/']
}
resources {
srcDirs = ['src/']
exclude '**/*.java', '**/*.kt'
}
}
}
dependencies {
implementation project(":FightSystem_Core")
implementation project(":FightSystem_18")
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly swdep("Spigot-1.20")
}

Datei anzeigen

@ -1,32 +0,0 @@
/*
* 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));
}
}

Datei anzeigen

@ -19,25 +19,10 @@
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) {
@ -53,30 +38,8 @@ 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 @Override
public void trackEntity(Player player, int entity) { public Object getPose(boolean sneaking) {
Object tracker = get.invoke(trackers, entity); return Byte.valueOf((byte)(sneaking ? 2 : 0));
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);
} }
} }

Datei anzeigen

@ -24,8 +24,14 @@ import net.minecraft.server.v1_8_R3.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper8 implements CraftbukkitWrapper { public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
@ -43,11 +49,24 @@ public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -23,7 +23,6 @@ import org.bukkit.DyeColor;
import org.bukkit.Material; 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.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -37,7 +36,7 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
@Override @Override
public boolean isWater(Block block) { public boolean isWater(Block block) {
Material type = block.getType(); Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA; return type == Material.WATER || type == Material.STATIONARY_WATER;
} }
@Override @Override
@ -59,6 +58,11 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
return false; return false;
} }
@Override
public ItemStack onBreak(Block block) {
return block.getDrops().stream().findAny().orElse(new ItemStack(Material.AIR));
}
@Override @Override
public boolean doRecord(BlockPhysicsEvent e) { public boolean doRecord(BlockPhysicsEvent e) {
return e.getChangedType() != e.getBlock().getType(); return e.getChangedType() != e.getBlock().getType();
@ -73,20 +77,4 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
public boolean checkPistonMoving(Block block) { public boolean checkPistonMoving(Block block) {
return block.getType() == Material.PISTON_MOVING_PIECE; return block.getType() == Material.PISTON_MOVING_PIECE;
} }
@Override
public boolean isFacingWater(Block dispenser) {
return false;
}
@Override
public boolean isCrouching(Player player) {
return false;
}
@Override
@SuppressWarnings("deprecation")
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type, (byte)0);
}
} }

Datei anzeigen

@ -1,55 +0,0 @@
/*
* 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())));
}
}

Datei anzeigen

@ -25,8 +25,14 @@ import net.minecraft.server.v1_9_R2.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
public class CraftbukkitWrapper9 implements CraftbukkitWrapper { public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
@ -39,18 +45,31 @@ 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();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); return ((CraftEntity)e).getHandle().getHeadRotation();
} }
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
@Override @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -47,9 +47,6 @@ 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")
} }

Datei anzeigen

@ -20,7 +20,7 @@ Ranks: [] # Disables ranks for this schematic type if missing
Times: Times:
# Time in seconds the server stops after starting if nobody joins # Time in seconds the server stops after starting if nobody joins
NoPlayersOnlineDuration: 300 # defaults to 300 if missing NoPlayersOnlineDuration: 30 # defaults to 30 if missing
# Time in seconds the team leaders have to choose their schematic # Time in seconds the team leaders have to choose their schematic
PreSchemPasteDuration: 120 # defaults to 120 if missing PreSchemPasteDuration: 120 # defaults to 120 if missing
# Time in seconds for preparing # Time in seconds for preparing
@ -37,11 +37,6 @@ Arena:
Schem2Border: Schem2Border:
x: 24 # defaults to 24 if missing x: 24 # defaults to 24 if missing
z: 24 # defaults to 24 if missing z: 24 # defaults to 24 if missing
# The offset the teams spawn relative to the center of their area
SpawnOffset:
x: 0 # defaults to 0 if missing
y: 0 # defaults to Schematic.Size.y if missing
z: 0 # defaults to 0 if missing
# The size of the team areas are expanded around the schematics # The size of the team areas are expanded around the schematics
BorderFromSchematic: 12 # defaults to 12 if missing BorderFromSchematic: 12 # defaults to 12 if missing
# If ground walkable, teams can walk below the lower arena border during setup # If ground walkable, teams can walk below the lower arena border during setup
@ -61,14 +56,10 @@ 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
@ -81,8 +72,6 @@ Schematic:
ReplaceObsidianBedrock: false # defaults to false if missing ReplaceObsidianBedrock: false # defaults to false if missing
# If the replacement should happen with block updates # If the replacement should happen with block updates
ReplaceWithBlockupdates: false # defaults to false if missing ReplaceWithBlockupdates: false # defaults to false if missing
# If the schematic perparation arena mode is time limited
UnlimitedPrepare: false # defaults to false if missing
# Maximal amount of blocks allowed in the schematic # Maximal amount of blocks allowed in the schematic
MaxBlocks: 0 # defaults to 0 (ignored) if missing MaxBlocks: 0 # defaults to 0 (ignored) if missing
# Maximal amount of items per dispenser # Maximal amount of items per dispenser
@ -114,6 +103,8 @@ WinConditions: # defaults to none if missing
# - CAPTAIN_DEAD # - CAPTAIN_DEAD
# - PERCENT_SYSTEM # - PERCENT_SYSTEM
# - WHITELIST_PERCENT
# - RELATIVE_PERCENT
# - POINTS # - POINTS
# - POINTS_AIRSHIP # - POINTS_AIRSHIP
@ -123,18 +114,12 @@ 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
@ -178,3 +163,8 @@ Techhider:
# x: 0 # defaults to 0 if missing # x: 0 # defaults to 0 if missing
# y: 0 # defaults to 0 if missing # y: 0 # defaults to 0 if missing
# z: 0 # defaults to Schematic.Size.z + 50 if missing # z: 0 # defaults to Schematic.Size.z + 50 if missing
# # The offset the teams spawn relative to the center of their area
# SpawnOffset:
# x: 0 # defaults to 0 if missing
# y: 0 # defaults to Schematic.Size.y if missing
# z: 0 # defaults to 0 if missing

Datei anzeigen

@ -43,10 +43,8 @@ public enum ArenaMode {
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY))); public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK))); public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT))); public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
public static final Set<ArenaMode> AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE))); public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY, CHECK))); public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> ManualTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY)); public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST)); public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST));
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY)); public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));

Datei anzeigen

@ -21,7 +21,10 @@ 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.*; import de.steamwar.sql.Event;
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;
@ -58,7 +61,6 @@ public class Config {
public static final Region BlueExtendRegion; public static final Region BlueExtendRegion;
public static final Region RedExtendRegion; public static final Region RedExtendRegion;
public static final Region ArenaRegion; public static final Region ArenaRegion;
public static final Region PlayerRegion;
public static final Location TeamBlueSpawn; public static final Location TeamBlueSpawn;
public static final Location TeamRedSpawn; public static final Location TeamRedSpawn;
@ -80,13 +82,11 @@ 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;
public static final boolean ReplaceObsidianBedrock; public static final boolean ReplaceObsidianBedrock;
public static final boolean ReplaceWithBlockupdates; public static final boolean ReplaceWithBlockupdates;
public static final boolean UnlimitedPrepare;
//team parameter //team parameter
public static final String TeamRedName; public static final String TeamRedName;
@ -104,8 +104,6 @@ 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 +115,13 @@ public class Config {
//tech hider parameter //tech hider parameter
public static final boolean TechhiderActive; public static final boolean TechhiderActive;
public static final Set<Material> HiddenBlocks; public static final Set<String> HiddenBlocks;
public static final Set<String> HiddenBlockEntities; public static final Set<String> HiddenBlockEntities;
public static final Material ObfuscateWith; public static final String 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,14 +136,10 @@ 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; public static final int spectatePort = 2222;
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();
@ -161,7 +155,7 @@ public class Config {
} }
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile); FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 300); NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 30);
PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120); PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120);
SetupDuration = config.getInt("Times.SetupDuration", 300); SetupDuration = config.getInt("Times.SetupDuration", 300);
PreFightDuration = config.getInt("Times.PreFightDuration", 30); PreFightDuration = config.getInt("Times.PreFightDuration", 30);
@ -185,13 +179,11 @@ 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);
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false); ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false);
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false); ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
GameName = config.getString("GameName", "WarGear"); GameName = config.getString("GameName", "WarGear");
TeamChatDetection = config.getString("TeamChatPrefix", "+"); TeamChatDetection = config.getString("TeamChatPrefix", "+");
@ -200,8 +192,6 @@ 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"));
@ -214,8 +204,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 = Material.getMaterial(config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase()); ObfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase();
HiddenBlocks = config.getStringList("Techhider.HiddenBlocks").stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet()); HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
if(schemsizeX < 0){ if(schemsizeX < 0){
@ -234,9 +224,9 @@ public class Config {
BlueToRedX = worldconfig.getInt("BlueToRed.x", 0); BlueToRedX = worldconfig.getInt("BlueToRed.x", 0);
BlueToRedY = worldconfig.getInt("BlueToRed.y", 0); BlueToRedY = worldconfig.getInt("BlueToRed.y", 0);
BlueToRedZ = worldconfig.getInt("BlueToRed.z", schemsizeZ + 50); BlueToRedZ = worldconfig.getInt("BlueToRed.z", schemsizeZ + 50);
double teamBlueSpawnOffsetX = config.getDouble("Arena.SpawnOffset.x", 0); double teamBlueSpawnOffsetX = worldconfig.getDouble("SpawnOffset.x", 0);
double teamBlueSpawnOffsetY = config.getDouble("Arena.SpawnOffset.y", schemsizeY); double teamBlueSpawnOffsetY = worldconfig.getDouble("SpawnOffset.y", schemsizeY);
double teamBlueSpawnOffsetZ = config.getDouble("Arena.SpawnOffset.z", 0); double teamBlueSpawnOffsetZ = worldconfig.getDouble("SpawnOffset.z", 0);
int teamRedCornerX = BlueToRedX + blueCornerX; int teamRedCornerX = BlueToRedX + blueCornerX;
int teamRedCornerY = BlueToRedY + blueCornerY; int teamRedCornerY = BlueToRedY + blueCornerY;
@ -310,25 +300,26 @@ public class Config {
RedRotate = teamRedRotate; RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate; BlueRotate = teamBlueRotate;
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); int arenaYSize = blueCornerY - underBorder + schemsizeY + PreperationArea;
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
if(eventKampfID >= 1){ BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
EventKampf = EventFight.get(eventKampfID); ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ);
if(EventKampf == null){
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){
EventFight eventFight = EventFight.get(EventKampfID);
if(eventFight == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight"); Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
Bukkit.shutdown(); Bukkit.shutdown();
} }
assert EventKampf != null; assert eventFight != null;
Team team1 = Team.get(EventKampf.getTeamBlue()); Team team1 = Team.get(eventFight.getTeamBlue());
Team team2 = Team.get(EventKampf.getTeamRed()); Team team2 = Team.get(eventFight.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");
@ -344,11 +335,9 @@ 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;
SpectatePort = EventKampf.getSpectatePort(); EventKampf = eventFight;
LiveReplay = SpectatePort != 0;
Referees = Referee.get(Config.EventKampf.getEventID());
Event event = Event.get(EventKampf.getEventID()); Event event = Event.get(eventFight.getEventID());
if(BothTeamsPublic) { if(BothTeamsPublic) {
OnlyPublicSchematics = true; OnlyPublicSchematics = true;
MaximumTeamMembers = Integer.MAX_VALUE; MaximumTeamMembers = Integer.MAX_VALUE;
@ -356,6 +345,7 @@ 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");
@ -367,10 +357,8 @@ 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);
@ -384,13 +372,17 @@ 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;
@ -403,13 +395,15 @@ public class Config {
return ArenaMode.Test.contains(mode); return ArenaMode.Test.contains(mode);
} }
public static boolean replayserver(){ public static boolean replayserver(){
return ReplayID < 0; return ReplayID == -1;
} }
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) {
return Referees.contains(SteamwarUser.get(player.getUniqueId()).getId()); if(EventKampf == null)
return false;
return SteamwarUser.get(player.getUniqueId()).getId() == EventKampf.getKampfleiter();
} }
} }

Datei anzeigen

@ -25,39 +25,30 @@ 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;
import de.steamwar.fightsystem.fight.HotbarKit; import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.listener.Shutdown; import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.FileRecorder; import de.steamwar.fightsystem.record.*;
import de.steamwar.fightsystem.record.FileSource;
import de.steamwar.fightsystem.record.GlobalRecorder;
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() {
@ -76,14 +67,10 @@ public class FightSystem extends JavaPlugin {
new EntityDamage(); new EntityDamage();
new WaterRemover(); new WaterRemover();
new Permanent(); new Permanent();
new PistonListener(ArenaMode.AntiTestCheckPrepare, e -> e.setCancelled(true)); new PistonListener();
new PistonListener(ArenaMode.Test, e -> getMessage().broadcastActionbar("PISTON_PUSHED_OUTSIDE"));
new PistonListener(ArenaMode.Prepare, e -> {
getMessage().broadcast("PISTON_PUSHED_OUTSIDE");
shutdown();
});
new Chat(); new Chat();
new ArenaBorder(); new ArenaBorder();
new TeamArea();
new IngameDeath(); new IngameDeath();
new InFightDamage(); new InFightDamage();
new InFightInventory(); new InFightInventory();
@ -100,18 +87,16 @@ public class FightSystem extends JavaPlugin {
new RunningWorldInteraction(); new RunningWorldInteraction();
new PersonalKitCreator(); new PersonalKitCreator();
new ArrowStopper(); new ArrowStopper();
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); new ArrowPickup();
new BlockFadeListener(); new BlockFadeListener();
new LeaveableArena(); new LeaveableArena();
new ClickAnalyzer(); new ClickAnalyzer();
new BlockPlaceCollision();
new HotbarKit.HotbarKitListener(); new HotbarKit.HotbarKitListener();
new JoinRequestListener();
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
new AntiCheat();
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();
@ -121,7 +106,9 @@ 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 WinconditionPercent(Winconditions.PERCENT_SYSTEM, "Percent"); new WinconditionPercentSystem();
new WinconditionBlacklistPercent();
new WinconditionWhitelistPercent();
new WinconditionPoints(); new WinconditionPoints();
new WinconditionPointsAirShip(); new WinconditionPointsAirShip();
new WinconditionTimeout(); new WinconditionTimeout();
@ -132,8 +119,6 @@ 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();
@ -146,18 +131,18 @@ public class FightSystem extends JavaPlugin {
new LeaveCommand(); new LeaveCommand();
new KitCommand(); new KitCommand();
new RemoveCommand(); new RemoveCommand();
new RequestsCommand(); new AcceptCommand();
new InfoCommand();
new WGCommand(); new WGCommand();
new TBCommand(); new TBCommand();
new DeclineCommand();
new GamemodeCommand(); new GamemodeCommand();
new InviteCommand();
new ReadyCommand(); new ReadyCommand();
new AkCommand(); new AkCommand();
new LeaderCommand(); new LeaderCommand();
new LockschemCommand(); new LockschemCommand();
new StateCommand(); new StateCommand();
new SkipCommand(); new SkipCommand();
new TPSWarpCommand();
new UnrankCommand(); new UnrankCommand();
new WinCommand(); new WinCommand();
@ -169,15 +154,7 @@ 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){
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID); Fight.getBlueTeam().setSchem(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));
} }
@ -197,6 +174,15 @@ 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;
} }
@ -213,10 +199,6 @@ 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()){

Datei anzeigen

@ -25,6 +25,13 @@ FIGHT_ALREADY_STARTED=§cThe fight already started
NOT_LEADER=§cYou aren't a leader NOT_LEADER=§cYou aren't a leader
PLAYER_UNAVAILABLE=§cThe player is not in an arena PLAYER_UNAVAILABLE=§cThe player is not in an arena
NO_INVITATION=§cYou weren't invited by any team
INVITATION_DECLINED=§cInvitation declined
INVITATION_DECLINED_TEAM=§e{0} §chas declined the invitation
PLAYER_IN_TEAM=§e{0} §cis already in a team
ALREADY_INVITED=§e{0} §cwas invited
INVITATION_SENT=§e{0} §7invited
NOT_IN_TEAM=§e{0} §cis not in your team NOT_IN_TEAM=§e{0} §cis not in your team
KIT_UNAVAILABLE=§cThis kit does not exist KIT_UNAVAILABLE=§cThis kit does not exist
@ -34,6 +41,8 @@ GAMEMODE_NOT_ALLOWED=§cChanging gamemode is not permitted
GAMEMODE_UNKNOWN=§cUnknown gamemode {0} GAMEMODE_UNKNOWN=§cUnknown gamemode {0}
GAMEMODE_HELP=§8/§7gm §8[§egamemode§8] GAMEMODE_HELP=§8/§7gm §8[§egamemode§8]
INVITE_HELP=§8/§einvite §8[§eplayer§8]
LEADER_FULL=§cAll teams already have a leader LEADER_FULL=§cAll teams already have a leader
ALREADY_IN_TEAM=§cYou are already in a team ALREADY_IN_TEAM=§cYou are already in a team
@ -47,15 +56,14 @@ REMOVE_HELP=§8/§eremove §8[§eplayer§8]
NOT_FIGHTLEADER=§cYou are not the fight leader NOT_FIGHTLEADER=§cYou are not the fight leader
WIN_HELP=§8/§7win §8[§eteam §8or §etie§8] WIN_HELP=§8/§7win §8[§eteam §8or §etie§8]
INFO_RANKED=§7Ranked§8: §e{0}
INFO_LEADER=§7Leader {0}§8: {1}
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
INVITATION_TITLE=Invitation from {0}
INVITATION_ACCEPT=§aAccept
INVITATION_DECLINE=§cDecline
INVITATION_CHAT_ACCEPT=§8/§aaccept§8, §7to §aaccept§7 the invitation
INVITATION_CHAT_DECLINE=§8/§cdecline§8, §7to §cdecline§7 the invitation
STATE_TITLE=Fight state STATE_TITLE=Fight state
STATE_PRE_LEADER_SETUP=§7Team leader waiting phase STATE_PRE_LEADER_SETUP=§7Team leader waiting phase
STATE_PRE_SCHEM_SETUP=§7Schematic selection phase STATE_PRE_SCHEM_SETUP=§7Schematic selection phase
@ -65,6 +73,8 @@ STATE_RUNNING=§eFighting phase
STATE_SPECTATE_WIN=§7Victory {0} STATE_SPECTATE_WIN=§7Victory {0}
STATE_SPECTATE_TIE=§7Draw STATE_SPECTATE_TIE=§7Draw
INVITE_TITLE=Invite player
REMOVE_TITLE=Kick player REMOVE_TITLE=Kick player
KIT_SELECTION_TITLE=Kit selection KIT_SELECTION_TITLE=Kit selection
@ -78,7 +88,6 @@ 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
@ -103,7 +112,6 @@ 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
@ -111,6 +119,7 @@ SKIP_NOT_READY=§c§mSkipping to next event
TEAM_CHAT={0}{1}§8» {0}{2} TEAM_CHAT={0}{1}§8» {0}{2}
CHOOSE_KIT=§eChoose kit CHOOSE_KIT=§eChoose kit
RESPAWN=§eRespawn RESPAWN=§eRespawn
INVITE_PLAYERS=§eInvite player
REMOVE_PLAYERS=§cKick player REMOVE_PLAYERS=§cKick player
CHOOSE_SCHEMATIC=§eChoose {0} CHOOSE_SCHEMATIC=§eChoose {0}
SCHEMATIC_REQUIRED=§cChoose a schematic first SCHEMATIC_REQUIRED=§cChoose a schematic first
@ -147,7 +156,6 @@ PREPARE_SENT_IN=§aA team member will review the schematic soon
PARTICIPANT_CHAT={0} {1}§8» §7{2} PARTICIPANT_CHAT={0} {1}§8» §7{2}
FIGHTLEADER_CHAT=§e{0}§8» §e{1} FIGHTLEADER_CHAT=§e{0}§8» §e{1}
SPECTATOR_CHAT=§7{0}§8» §7{1} SPECTATOR_CHAT=§7{0}§8» §7{1}
PISTON_PUSHED_OUTSIDE=§cA piston pushed a block outside the allowed area!
# Replay # Replay
@ -235,22 +243,3 @@ WIN_CREWMATE_DEAD={0} §7killed all team mates
AMONG_US_IMPOSTER_MESSAGE = §4You are the Imposter§8! §7Kill all your team mates to win the game! AMONG_US_IMPOSTER_MESSAGE = §4You are the Imposter§8! §7Kill all your team mates to win the game!
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill him to win the game! AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill him to win the game!
# Invites
JOIN_REQUEST=§7Request join
JOIN_REQUEST_TITLE=Request join
JOIN_REQUEST_ALREADY=§cYou have already sent a join request
JOIN_REQUEST_TEAM=§7Join {0}
JOIN_REQUEST_CONFIRMATION=§7Join request submitted
JOIN_REQUEST_NOTIFICATION=§e{0} §7requests joining team {1}§8. §7Accept or decline using §8/§erequests
REQUESTS=§7Open join requests
REQUESTS_TITLE=Open join requests
REQUEST_DECLINED=§cJoin of {0} declined
REQUEST_YOUR_DECLINED=§cYour join request was declined
REQUESTS_LEFT_CLICK=§eLeft click §7to §eaccept§8!
REQUESTS_RIGHT_CLICK=§eRight click §7to §edecline§8!
NO_JOIN_REQUEST=§cThe player did not request joining
NO_CONFIRMATION=§cNo confirmation necessary

Datei anzeigen

@ -23,6 +23,13 @@ FIGHT_ALREADY_STARTED=§cDer Kampf hat bereits begonnen
NOT_LEADER=§cDu bist kein Leader NOT_LEADER=§cDu bist kein Leader
PLAYER_UNAVAILABLE=§cDer Spieler ist nicht in der Arena PLAYER_UNAVAILABLE=§cDer Spieler ist nicht in der Arena
NO_INVITATION=§cDu wurdest von keinem Team eingeladen
INVITATION_DECLINED=§cEinladung abgelehnt
INVITATION_DECLINED_TEAM=§e{0} §chat die Einladung abgelehnt
PLAYER_IN_TEAM=§e{0} §cist bereits in einem Team
ALREADY_INVITED=§e{0} §cwurde bereits eingeladen
INVITATION_SENT=§e{0} §7eingeladen
NOT_IN_TEAM=§e{0} §cist nicht in deinem Team NOT_IN_TEAM=§e{0} §cist nicht in deinem Team
KIT_UNAVAILABLE=§cDieses Kit gibt es nicht KIT_UNAVAILABLE=§cDieses Kit gibt es nicht
@ -32,6 +39,8 @@ GAMEMODE_NOT_ALLOWED=§cSpielmodusänderung verboten
GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus {0} GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus {0}
GAMEMODE_HELP=§8/§7gm §8[§eSpielmodus§8] GAMEMODE_HELP=§8/§7gm §8[§eSpielmodus§8]
INVITE_HELP=§8/§einvite §8[§eSpieler§8]
LEADER_FULL=§cAlle Teams haben bereits einen Leader LEADER_FULL=§cAlle Teams haben bereits einen Leader
ALREADY_IN_TEAM=§cDu bist bereits in einem Team ALREADY_IN_TEAM=§cDu bist bereits in einem Team
@ -45,11 +54,14 @@ 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
INVITATION_TITLE=Einladung von {0}
INVITATION_ACCEPT=§aAnnehmen
INVITATION_DECLINE=§cAblehnen
INVITATION_CHAT_ACCEPT=§8/§aaccept§8, §7um die Einladung §aanzunehmen
INVITATION_CHAT_DECLINE=§8/§cdecline§8, §7um die Einladung §cabzulehnen
STATE_TITLE=Kampfstatus STATE_TITLE=Kampfstatus
STATE_PRE_LEADER_SETUP=§7Teamleaderwartephase STATE_PRE_LEADER_SETUP=§7Teamleaderwartephase
STATE_PRE_SCHEM_SETUP=§7Schemauswahlphase STATE_PRE_SCHEM_SETUP=§7Schemauswahlphase
@ -59,6 +71,8 @@ STATE_RUNNING=§eKampfphase
STATE_SPECTATE_WIN=§7Sieg {0} STATE_SPECTATE_WIN=§7Sieg {0}
STATE_SPECTATE_TIE=§7Unentschieden STATE_SPECTATE_TIE=§7Unentschieden
INVITE_TITLE=Spieler einladen
REMOVE_TITLE=Spieler rauswerfen REMOVE_TITLE=Spieler rauswerfen
KIT_SELECTION_TITLE=Kitauswahl KIT_SELECTION_TITLE=Kitauswahl
@ -72,7 +86,6 @@ 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
@ -97,13 +110,13 @@ 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
SKIP_NOT_READY=§c§mBeschleunigung zum nächsten Event SKIP_NOT_READY=§c§mBeschleunigung zum nächsten Event
CHOOSE_KIT=§eKit wählen CHOOSE_KIT=§eKit wählen
RESPAWN=§eRespawn RESPAWN=§eRespawn
INVITE_PLAYERS=§eSpieler einladen
REMOVE_PLAYERS=§cSpieler rauswerfen REMOVE_PLAYERS=§cSpieler rauswerfen
CHOOSE_SCHEMATIC=§e{0} wählen CHOOSE_SCHEMATIC=§e{0} wählen
SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein
@ -137,7 +150,6 @@ PREPARE_SCHEM_EXISTS=§cEs existiert bereits eine Schem mit Namenszusatz -prepar
PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen. PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen.
PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen. PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen.
PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft
PISTON_PUSHED_OUTSIDE=§cEin Kolben hat einen Block aus dem erlaubten Bereich geschoben!
# Replay # Replay
@ -216,21 +228,3 @@ WIN_CREWMATE_DEAD={0} §7 hat alle Kameraden getötet
AMONG_US_IMPOSTER_MESSAGE = §4Du bist ein Imposter§8! §7Du musst alle Kameraden töten, um zu gewinnen. AMONG_US_IMPOSTER_MESSAGE = §4Du bist ein Imposter§8! §7Du musst alle Kameraden töten, um zu gewinnen.
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4Es ist ein Imposter unter uns§8! §7Tötet ihn, um das Spiel zu gewinnen! AMONG_US_IMPOSTER_AMONG_MESSAGE = §4Es ist ein Imposter unter uns§8! §7Tötet ihn, um das Spiel zu gewinnen!
# Invites
JOIN_REQUEST=§7Teambeitritt anfragen
JOIN_REQUEST_TITLE=Teambeitritt anfragen
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
JOIN_REQUEST_TEAM={0} §7beitreten
JOIN_REQUEST_CONFIRMATION=§7Teambeitritt angefragt
JOIN_REQUEST_NOTIFICATION=§e{0} §7möchte Team {1} §7beitreten§8. §7Akzeptiere oder lehne ab mit §8/§erequests
REQUESTS=§7Offene Beitrittsanfragen
REQUESTS_TITLE=Offene Beitrittsanfragen
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
REQUEST_YOUR_DECLINED=§cDeine Betrittsanfrage wurde abgelehnt
REQUESTS_LEFT_CLICK=§eLinksklick §7um §eanzunehmen§8!
REQUESTS_RIGHT_CLICK=§eRechtsklick §7um §eabzulehnen§8!
NO_JOIN_REQUEST=§cDer Spieler hat noch keinen Beitritt angefragt
NO_CONFIRMATION=§cKeine Zustimmung nötig

Datei anzeigen

@ -1,294 +0,0 @@
/*
* 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.ai;
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.fight.FightTeam;
import de.steamwar.fightsystem.listener.Chat;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.Lectern;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.Comparator;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.block.data.type.Repeater;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.logging.Level;
public abstract class AI {
private static final Map<UUID, AI> ais = new HashMap<>();
static {
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
ais.values().forEach(AI::stop);
ais.clear();
});
}
public static AI getAI(UUID uuid) {
return ais.get(uuid);
}
private final FightTeam team;
private final LivingEntity entity;
private final BukkitTask task;
private final Queue<Action> queue = new ArrayDeque<>();
protected AI(FightTeam team, SteamwarUser user) {
this.team = team;
entity = (LivingEntity) Config.world.spawnEntity(Config.SpecSpawn, EntityType.VILLAGER);
entity.setCustomName(user.getUserName());
((Villager)entity).setAware(false);
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
ais.put(entity.getUniqueId(), this);
team.addMember(entity, user);
}
public abstract SchematicNode chooseSchematic();
public boolean acceptJoinRequest(Player player, FightTeam team) {
return true;
}
protected abstract void plan();
public void stop() {
if(!entity.isDead())
entity.remove();
if(!task.isCancelled())
task.cancel();
}
public LivingEntity getEntity() {
return entity;
}
protected void setReady() {
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
return;
if(team.getLeader().getEntity() != entity)
return;
team.setReady(true);
}
protected void chat(String message) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
}
protected Vector getPosition() {
Location location = entity.getLocation();
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Vector(
location.getX() - extend.getMinX(),
location.getY() - team.getSchemRegion().getMinY(),
location.getZ() - extend.getMinZ()
);
else
return new Vector(
extend.getMaxX() - location.getX(),
location.getY() - team.getSchemRegion().getMinY(),
extend.getMaxZ() - location.getZ()
);
}
protected Material getBlock(Vector pos) {
queue.add(new Action(1));
return translate(pos, true).getBlock().getType();
}
protected boolean isPowered(Vector pos) {
queue.add(new Action(1));
return translate(pos, true).getBlock().isBlockPowered();
}
protected void setTNT(Vector pos) {
queue.add(new Action(1) {
@Override
public void run() {
if(FightState.getFightState() != FightState.RUNNING)
return;
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
Block block = location.getBlock();
if(block.getType() == Material.AIR)
block.setType(Material.TNT);
}
});
}
protected void interact(Vector pos) {
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
interact(location.getBlock());
}
});
}
protected void interact(Vector pos, int n) {
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if (interactionDistanceViolation(location))
return;
Block block = location.getBlock();
BlockData data = block.getBlockData();
if (data instanceof Repeater) {
Repeater repeater = (Repeater) data;
repeater.setDelay(n);
} else if (data instanceof Lectern) {
Lectern lectern = (Lectern) data;
lectern.setPage(n);
}
block.setBlockData(data);
}
});
}
protected void move(Vector pos) {
queue.add(new Action(2) {
@Override
public void run() {
Location location = entity.getLocation();
Location target = translate(pos, false);
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
return;
}
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
return;
entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
}
});
}
private boolean interactionDistanceViolation(Location location) {
return location.distance(entity.getEyeLocation()) > 5;
}
private void interact(Block block) {
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
if (data instanceof NoteBlock) {
NoteBlock noteBlock = (NoteBlock) data;
Note note = noteBlock.getNote();
noteBlock.setNote(note.isSharped() ? note.flattened() : note.sharped());
} else if (data instanceof Openable) {
Openable openable = (Openable) data;
openable.setOpen(!openable.isOpen());
} else if (data instanceof Comparator) {
Comparator comparator = (Comparator) data;
comparator.setMode(Comparator.Mode.values()[1 - comparator.getMode().ordinal()]);
} else if (data instanceof Powerable) {
Material type = block.getType();
Powerable powerable = (Powerable) data;
boolean isPowered = powerable.isPowered();
if(type.name().endsWith("BUTTON")) {
if(isPowered)
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!block.getType().name().endsWith("BUTTON"))
return;
powerable.setPowered(false);
block.setBlockData(powerable);
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
}
powerable.setPowered(!isPowered);
}
block.setBlockData(data);
}
private void run() {
if(queue.isEmpty())
plan();
if(!queue.isEmpty() && --queue.peek().delay == 0)
queue.poll().run();
}
private Location translate(Vector pos, boolean blockPos) {
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Location(
Config.world,
pos.getX() + extend.getMinX(),
pos.getY() + team.getSchemRegion().getMinY(),
pos.getZ() + extend.getMinZ()
);
else
return new Location(
Config.world,
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
pos.getY() + team.getSchemRegion().getMinY(),
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
);
}
private static class Action {
private int delay;
public Action(int delay) {
this.delay = delay;
}
public void run() {}
}
}

Datei anzeigen

@ -1,60 +0,0 @@
/*
* 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.ai;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.Random;
public class LixfelAI extends AI {
private final Random random = new Random();
private LixfelPathplanner pathplanner;
public LixfelAI(FightTeam team, String user) {
super(team, SteamwarUser.get(user));
}
@Override
public SchematicNode chooseSchematic() {
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
SchematicNode schem = publics.get(new Random().nextInt(publics.size()));
pathplanner = new LixfelPathplanner(schem);
return schem;
}
@Override
protected void plan() {
setReady();
Vector destination = pathplanner.getWalkable().get(random.nextInt(pathplanner.getWalkable().size()));
List<Vector> path = pathplanner.plan(getPosition(), destination);
if(!path.isEmpty())
chat("Path size: " + path.size());
for(Vector p : path) {
move(p);
}
}
}

Datei anzeigen

@ -1,141 +0,0 @@
/*
* 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.ai;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockType;
import de.steamwar.fightsystem.Config;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import org.bukkit.util.Vector;
import java.io.IOException;
import java.util.*;
public class LixfelPathplanner {
private static BlockType getBlockType(Clipboard clipboard, BlockVector3 vector) {
return clipboard.getBlock(vector).getBlockType();
}
private static boolean nonsolid(Clipboard clipboard, BlockVector3 vector) {
return !getBlockType(clipboard, vector).getMaterial().isSolid();
}
private static Vector toBukkit(BlockVector3 vector) {
return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
}
private final List<Vector> walkable = new ArrayList<>();
private final Map<Vector, Vector[]> neighbours = new HashMap<>();
public LixfelPathplanner(SchematicNode schem) {
try {
fillWalkable(new SchematicData(schem).load());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public List<Vector> getWalkable() {
return walkable;
}
private void fillWalkable(Clipboard clipboard) {
BlockVector3 min = clipboard.getRegion().getMinimumPoint().subtract(Config.PreperationArea, 0, Config.PreperationArea); //TODO assumes nonextended Schematic with maximal size
Region region = clipboard.getRegion();
clipboard.getRegion().forEach(vector -> {
BlockVector3 below = vector.subtract(0, 1, 0);
if(!region.contains(below))
return;
BlockType belowMaterial = getBlockType(clipboard, below);
BlockVector3 above = vector.add(0, 1, 0);
if(nonsolid(clipboard, vector)) {
if(
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
(!region.contains(above) || nonsolid(clipboard, above))
)
walkable.add(toBukkit(vector.subtract(min)));
} else {
if(!region.contains(above))
walkable.add(toBukkit(above.subtract(min)));
}
});
for(Vector vector : walkable) {
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new));
}
}
public List<Vector> planToAnywhere(Vector start, Vector destination) {
Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null);
if(intermediate == null)
return Collections.emptyList();
List<Vector> plan = plan(start, intermediate);
plan.add(destination);
return plan;
}
public List<Vector> plan(Vector start, Vector destination) {
if(neighbouring(start, destination))
return Collections.singletonList(destination);
Map<Vector, Vector> approach = new HashMap<>();
Set<Vector> checking = Collections.singleton(destination);
while(!checking.isEmpty()) {
Set<Vector> toCheck = new HashSet<>();
for(Vector current : checking) {
Vector firstStep = Arrays.stream(neighbours.get(current))
.filter(vector -> !approach.containsKey(vector))
.filter(next -> {
approach.put(next, current);
toCheck.add(next);
return neighbouring(next, start);
})
.findAny().orElse(null);
if(firstStep != null) {
List<Vector> path = new ArrayList<>();
path.add(firstStep);
while(path.get(path.size()-1) != destination) {
path.add(approach.get(path.get(path.size()-1)));
}
return path;
}
}
checking = toCheck;
}
return Collections.emptyList();
}
private boolean neighbouring(Vector a, Vector b) {
return Math.abs(a.getX() - b.getX()) <= 1 && Math.abs(a.getY() - b.getY()) <= 1 && Math.abs(a.getZ() - b.getZ()) <= 1;
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
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 de.steamwar.fightsystem.ArenaMode;
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;
import org.bukkit.entity.Player;
public class AcceptCommand implements CommandExecutor {
public AcceptCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
Commands.acceptInvitation(player);
return false;
}
}

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm; import de.steamwar.sql.UserGroup;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -47,7 +47,7 @@ public class AkCommand implements CommandExecutor {
if(!player.isOp()) if(!player.isOp())
return false; return false;
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()){ if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer && Core.getInstance() != FightSystem.getPlugin()){
return false; return false;
} }

Datei anzeigen

@ -0,0 +1,42 @@
/*
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);
}
}

Datei anzeigen

@ -19,7 +19,6 @@
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;
@ -29,20 +28,12 @@ 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);
@ -56,6 +47,14 @@ public class Commands {
return false; return false;
} }
private static FightTeam checkGetInvitedTeam(Player p){
FightTeam fightTeam = Fight.getInvitedTeam(p);
if(fightTeam == null){
FightSystem.getMessage().sendPrefixless("NO_INVITATION", p, ChatMessageType.ACTION_BAR);
}
return fightTeam;
}
private static FightPlayer checkGetPlayer(Player p){ private static FightPlayer checkGetPlayer(Player p){
FightPlayer fightPlayer = Fight.getFightPlayer(p); FightPlayer fightPlayer = Fight.getFightPlayer(p);
if(fightPlayer == null){ if(fightPlayer == null){
@ -105,6 +104,30 @@ public class Commands {
fightTeam.skip(); fightTeam.skip();
} }
static void acceptInvitation(Player p){
if(checkSetup(p))
return;
FightTeam team = checkGetInvitedTeam(p);
if(team == null)
return;
team.addMember(p);
}
static void declineInvitation(Player p){
if(checkSetup(p))
return;
FightTeam team = checkGetInvitedTeam(p);
if(team == null)
return;
FightSystem.getMessage().sendPrefixless("INVITATION_DECLINED", p, ChatMessageType.ACTION_BAR);
team.broadcast("INVITATION_DECLINED_TEAM", p.getName());
team.getInvited().remove(p);
}
static void leaveTeam(Player p){ static void leaveTeam(Player p){
if(checkSetup(p)) if(checkSetup(p))
return; return;
@ -116,6 +139,37 @@ public class Commands {
fightTeam.removePlayer(p); fightTeam.removePlayer(p);
} }
static void invite(Player p, String invited){
if(checkSetup(p))
return;
FightTeam fightTeam = checkGetTeam(p);
if(fightTeam == null)
return;
FightPlayer fightPlayer = checkGetLeader(p);
if(fightPlayer == null)
return;
Player target = checkGetPlayer(p, invited);
if(target == null)
return;
if(Fight.getPlayerTeam(target) != null) {
FightSystem.getMessage().sendPrefixless("PLAYER_IN_TEAM", p, ChatMessageType.ACTION_BAR, target.getName());
return;
}
if(Fight.getOpposite(fightTeam).getInvited().contains(target) || fightTeam.getInvited().contains(target)) {
FightSystem.getMessage().sendPrefixless("ALREADY_INVITED", p, ChatMessageType.ACTION_BAR, target.getName());
return;
}
FightSystem.getMessage().sendPrefixless("INVITATION_SENT", p, ChatMessageType.ACTION_BAR, target.getName());
fightTeam.getInvited().add(target);
GUI.invitation(p, target);
}
static void kick(Player p, String kicked){ static void kick(Player p, String kicked){
if(checkSetup(p)) if(checkSetup(p))
return; return;

Datei anzeigen

@ -0,0 +1,46 @@
/*
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 de.steamwar.fightsystem.ArenaMode;
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;
import org.bukkit.entity.Player;
public class DeclineCommand implements CommandExecutor {
public DeclineCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "decline", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
Commands.declineInvitation(player);
return false;
}
}

Datei anzeigen

@ -19,18 +19,18 @@
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.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.inventory.*; 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;
@ -47,28 +47,23 @@ public class GUI {
private static final Message msg = FightSystem.getMessage(); private static final Message msg = FightSystem.getMessage();
@SuppressWarnings("deprecation") static void invitation(Player p, Player target){
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) { SWInventory inv = new SWInventory(target, 9, msg.parse("INVITATION_TITLE", target, p.getName()));
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData(); inv.setItem(0, SWItem.getDye(10), (byte)10, msg.parse("INVITATION_ACCEPT", target), (ClickType click) ->{
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName(); Commands.acceptInvitation(target);
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> { target.closeInventory();
p.closeInventory();
new JoinRequest(p, team);
}); });
} inv.setItem(8, SWItem.getDye(1), (byte)1, msg.parse("INVITATION_DECLINE", target), (ClickType click) ->{
Commands.declineInvitation(target);
public static void joinRequest(Player p) { target.closeInventory();
if(JoinRequest.get(p) != null) { });
msg.sendPrefixless("JOIN_REQUEST_ALREADY", p, ChatMessageType.ACTION_BAR); inv.addCloseCallback((ClickType click) ->{
return; if(Fight.getInvitedTeam(target) != null){
} msg.sendPrefixless("INVITATION_CHAT_ACCEPT", target);
msg.sendPrefixless("INVITATION_CHAT_DECLINE", target);
SWInventory inv = new SWInventory(p, 9, msg.parse("JOIN_REQUEST_TITLE", p)); }
FightTeam team = Fight.getPlayerTeam(p); });
if(team != Fight.getRedTeam()) inv.setCallback(-999, (ClickType click) -> target.closeInventory());
addTeamRequest(p, inv, team == null ? 0 : 4, Fight.getBlueTeam());
if(team != Fight.getBlueTeam())
addTeamRequest(p, inv, team == null ? 8 : 4, Fight.getRedTeam());
inv.open(); inv.open();
} }
@ -89,11 +84,12 @@ public class GUI {
inv.open(); inv.open();
} }
public static void chooseJoinRequests(Player p){ public static void chooseInvitation(Player p){
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p)); List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> { players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("INVITE_TITLE", p), players, (ClickType click, UUID player) -> {
Commands.invite(p, SteamwarUser.get(player).getUserName());
p.closeInventory(); p.closeInventory();
RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
}); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
@ -170,47 +166,27 @@ public class GUI {
return; return;
} }
int invSize = (Config.SubTypes.size() + 1) * 9; SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName));
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName)); inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> {
setupSchemTypeRow(p, inv, Config.SchematicType, 0); p.closeInventory();
for (int i = 0; i < Config.SubTypes.size(); i++) { schemDialog(p, true);
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 setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) { private static void schemDialog(Player p, boolean publicSchems){
inv.setItem(row * 9 + 8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, type.name()), (ClickType click) -> { SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(Config.SchematicType, Fight.getMaxRank()), node -> {
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;

Datei anzeigen

@ -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

Datei anzeigen

@ -1,64 +0,0 @@
/*
* 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.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class InfoCommand implements CommandExecutor {
public InfoCommand() {
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK))
return false;
FightSystem.getMessage().send("INFO_RANKED", player, !FightStatistics.isUnranked());
for(FightTeam team : Fight.teams()) {
if(!team.isLeaderless())
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
if(team.getSchematic() != 0) {
SchematicNode schematic = SchematicNode.getSchematicNode(team.getSchematic());
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getRank());
}
}
return false;
}
}

Datei anzeigen

@ -21,10 +21,6 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.JoinRequest;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -32,46 +28,25 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.function.BiConsumer; public class InviteCommand implements CommandExecutor {
public class RequestsCommand implements CommandExecutor { public InviteCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "invite", this);
public RequestsCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) if(!(sender instanceof Player)) {
return false; return false;
}
Player player = (Player) sender; Player player = (Player) sender;
FightPlayer fp = Fight.getFightPlayer(player);
if(fp == null || !(fp.isLeader() || fp.isLiving())) { if(args.length != 1){
GUI.joinRequest(player); FightSystem.getMessage().sendPrefixless("INVITE_HELP", player);
return false; return false;
} }
if(Commands.checkGetLeader(player) == null) Commands.invite(player, args[0]);
return false;
GUI.chooseJoinRequests(player);
return false; return false;
} }
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
JoinRequest request = JoinRequest.get(target);
if(request == null) {
FightSystem.getMessage().send("NO_JOIN_REQUEST", player);
return;
}
FightTeam team = Fight.getPlayerTeam(player);
if(!request.required(team)) {
FightSystem.getMessage().send("NO_CONFIRMATION", player);
return;
}
handleJoinRequest.accept(request, team);
}
} }

Datei anzeigen

@ -34,7 +34,7 @@ import org.bukkit.entity.Player;
public class LeaderCommand implements CommandExecutor { public class LeaderCommand implements CommandExecutor {
public LeaderCommand() { public LeaderCommand() {
new StateDependentCommand(ArenaMode.ManualTeams, FightState.Setup, "leader", this); new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "leader", this);
} }
@Override @Override

Datei anzeigen

@ -25,7 +25,10 @@ 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.StateDependentCommand; import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.*; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -35,7 +38,7 @@ import org.bukkit.entity.Player;
public class LockschemCommand implements CommandExecutor { public class LockschemCommand implements CommandExecutor {
public LockschemCommand() { public LockschemCommand() {
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this); new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
} }
@Override @Override
@ -44,9 +47,13 @@ public class LockschemCommand implements CommandExecutor {
return false; return false;
Player player = (Player) sender; Player player = (Player) sender;
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if(!userGroup.isCheckSchematics())
return false; return false;
if(args.length != 1) { if(args.length != 1) {
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player); FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
return false; return false;

Datei anzeigen

@ -1,52 +0,0 @@
/*
* 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;
}
}

Datei anzeigen

@ -83,6 +83,8 @@ 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();
} }
@ -102,6 +104,8 @@ 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;
} }
@ -120,6 +124,7 @@ 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:

Datei anzeigen

@ -21,57 +21,39 @@ 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 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, Countdown countdown) {
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
if(countdown != null) {
time -= Config.TimeoutTime - countdown.getTimeLeft();
if(time < 0)
time = 0;
}
return time;
}
private final FightPlayer fightPlayer; private final FightPlayer fightPlayer;
private List<ProtocolUtils.ChunkPos> chunkPos; private List<ProtocolUtils.ChunkPos> chunkPos;
public EnternCountdown(FightPlayer fp, Countdown countdown) { public EnternCountdown(FightPlayer fp) {
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false); super(Config.EnterStages.get(fp.getKit().getEnterStage()), 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.getPlayer(), ChatMessageType.ACTION_BAR);
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR); FightSystem.getTechHider().reloadChunks(fightPlayer.getPlayer(), 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.getPlayer(), false);
} }
@Override @Override
protected void broadcast(String message, int divisor) { protected void broadcast(String message, int divisor) {
fightPlayer.ifPlayer(player -> { fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f);
player.playSound(player.getLocation(), sound, 100.0f, 1.0f); sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, appendix);
sendCountdownMessage(player, message, time / divisor, appendix);
});
} }
} }

Datei anzeigen

@ -23,16 +23,31 @@ import de.steamwar.fightsystem.ArenaMode;
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.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.Message;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class NoPlayersOnlineCountdown extends Countdown { public class NoPlayersOnlineCountdown extends Countdown implements Listener {
public NoPlayersOnlineCountdown() { public NoPlayersOnlineCountdown() {
super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false); super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
if (!Config.ArenaLeaveable) new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this) {
@Override
public void enable() {
if(Bukkit.getOnlinePlayers().isEmpty())
super.enable();
}
};
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
disable();
} }
@Override @Override

Datei anzeigen

@ -29,9 +29,6 @@ public class PostSchemCountdown extends Countdown {
public PostSchemCountdown() { public PostSchemCountdown() {
super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false); super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
if(Config.mode == ArenaMode.PREPARE && Config.UnlimitedPrepare)
return;
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this); new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
} }

Datei anzeigen

@ -1,49 +0,0 @@
/*
* 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);
}
}));
}
}

Datei anzeigen

@ -1,39 +0,0 @@
/*
* 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);
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* 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;
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* 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;
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* 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;
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* 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;
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import com.comphenix.tinyprotocol.Reflection;
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.Core;
@ -27,22 +28,20 @@ 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;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
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 {
@ -50,7 +49,7 @@ public class Fight {
teams.add(blueTeam); teams.add(blueTeam);
} }
public static FightTeam getPlayerTeam(LivingEntity player) { public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player)) if(redTeam.isPlayerInTeam(player))
return redTeam; return redTeam;
if(blueTeam.isPlayerInTeam(player)) if(blueTeam.isPlayerInTeam(player))
@ -67,7 +66,15 @@ public class Fight {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
public static FightPlayer getFightPlayer(LivingEntity player) { public static FightTeam getInvitedTeam(Player player){
if(redTeam.getInvited().contains(player))
return redTeam;
else if(blueTeam.getInvited().contains(player))
return blueTeam;
return null;
}
public static FightPlayer getFightPlayer(Player player) {
if(redTeam.isPlayerInTeam(player)) if(redTeam.isPlayerInTeam(player))
return redTeam.getFightPlayer(player); return redTeam.getFightPlayer(player);
if(blueTeam.isPlayerInTeam(player)) if(blueTeam.isPlayerInTeam(player))
@ -75,25 +82,30 @@ public class Fight {
return null; return null;
} }
public static boolean fighting(LivingEntity player) { public static boolean fighting(Player player) {
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;
} }
public static FightTeam getUnrotated() { public static FightTeam getUnrotated() {
return Config.blueNegZ() ? Fight.getBlueTeam() : Fight.getRedTeam(); return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
} }
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
if(Core.getVersion() >= 18) Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
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) {
@ -123,7 +135,7 @@ public class Fight {
if(!player.isOnline()) if(!player.isOnline())
return; return;
pseudoSpectator(player, true); pseudoSpectator(player, true);
}, 1); }, 2);
}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) {
@ -134,20 +146,39 @@ public class Fight {
} }
} }
private static final Class<?> playerInfoActionClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction");
private static final Reflection.FieldAccessor<?> playerInfoAction = Reflection.getField(ProtocolWrapper.playerInfoPacket, playerInfoActionClass, 0);
private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1];
private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(ProtocolWrapper.playerInfoPacket, List.class, 0);
public static final Object creative = ProtocolWrapper.enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 1 : 2];
private static final Object spectator = ProtocolWrapper.enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 3 : 4];
public static void pseudoSpectator(Player player, boolean enable) { public static void pseudoSpectator(Player player, boolean enable) {
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, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator));
} }
public static boolean publicOnly() { public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
if (Config.OnlyPublicSchematics) { Object packet = Reflection.newInstance(ProtocolWrapper.playerInfoPacket);
return true; playerInfoAction.set(packet, action);
playerInfoData.set(packet, Collections.singletonList(ProtocolWrapper.impl.playerInfoDataConstructor(packet, profile, mode)));
return packet;
}
public static int getMaxRank(){
/* MaxRank of 0 is Pubonly*/
if(Config.OnlyPublicSchematics){
return 0;
} }
if (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
return false; if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
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());
} }
} }

Datei anzeigen

@ -20,42 +20,27 @@
package de.steamwar.fightsystem.fight; 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.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.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.function.Consumer;
public class FightPlayer { public class FightPlayer {
private final int id; private final Player player;
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;
FightPlayer(LivingEntity entity, SteamwarUser user, FightTeam team) { FightPlayer(Player player, FightTeam team) {
this.id = user.getId(); this.player = player;
this.entity = entity;
this.team = team; this.team = team;
this.isOut = false; this.isOut = false;
kit = Kit.getKitByName(Config.MemberDefault); kit = Kit.getKitByName(Config.MemberDefault);
if(Config.PersonalKits){ if(Config.PersonalKits){
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.SchematicType.toDB()); PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB());
if(personalKit != null){ if(personalKit != null){
kit = new Kit(personalKit); kit = new Kit(personalKit);
} }
@ -63,20 +48,13 @@ public class FightPlayer {
kills = 0; kills = 0;
} }
public void revive() {
isOut = false;
}
public void setOut() { public void setOut() {
isOut = true; isOut = true;
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
stopEnternCountdown(); stopEnternCountdown();
ifAI(AI::stop);
} }
public void startEnternCountdown(Countdown countdown) { public void setEnternCountdown(EnternCountdown countdown){
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0) enternCountdown = countdown;
enternCountdown = new EnternCountdown(this, countdown);
} }
public void stopEnternCountdown(){ public void stopEnternCountdown(){
@ -86,28 +64,8 @@ public class FightPlayer {
enternCountdown = null; enternCountdown = null;
} }
public LivingEntity getEntity() { public Player getPlayer() {
LivingEntity bukkit = Bukkit.getPlayer(entity.getUniqueId()); return this.player;
if(bukkit != null)
entity = bukkit;
return entity;
}
public SteamwarUser getUser() {
return SteamwarUser.get(id);
}
public void ifAI(Consumer<AI> function) {
if(entity instanceof Player)
return;
AI ai = AI.getAI(entity.getUniqueId());
if(ai != null)
function.accept(ai);
}
public void ifPlayer(Consumer<Player> function) {
if(entity instanceof Player)
function.accept((Player) entity);
} }
public boolean isLiving() { public boolean isLiving() {
@ -116,7 +74,23 @@ public class FightPlayer {
public boolean isLeader() { public boolean isLeader() {
FightPlayer leader = team.getLeader(); FightPlayer leader = team.getLeader();
return leader != null && leader.getEntity() == entity; return leader != null && leader.getPlayer() == player;
}
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(){

Datei anzeigen

@ -33,12 +33,9 @@ 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.*;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.io.IOException; import java.io.IOException;
@ -101,17 +98,8 @@ 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())
for (SchematicType type : Config.SubTypes) { return;
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())));
} }
@ -148,9 +136,6 @@ 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);
@ -158,7 +143,7 @@ public class FightSchematic extends StateDependent {
@Override @Override
public void disable() { public void disable() {
if(!Config.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE) if(!Config.ReplaceObsidianBedrock)
return; return;
FreezeWorld freezer = null; FreezeWorld freezer = null;
@ -169,7 +154,7 @@ public class FightSchematic extends StateDependent {
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK); replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
if(!Config.ReplaceWithBlockupdates) if(!Config.ReplaceWithBlockupdates)
freezer.disable(); HandlerList.unregisterAll(freezer);
} }
public void pasteTeamName(){ public void pasteTeamName(){
@ -200,7 +185,7 @@ public class FightSchematic extends StateDependent {
} }
length -= 1; length -= 1;
AffineTransform aT = new AffineTransform().rotateY(((team == Fight.getRedTeam()) == (Config.BlueToRedZ > 0)) ? 180 : 0); AffineTransform aT = new AffineTransform().rotateY(rotate ? 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);

Datei anzeigen

@ -25,38 +25,33 @@ 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.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.listener.TeamArea; import de.steamwar.fightsystem.record.GlobalRecorder;
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 lombok.Getter; import de.steamwar.techhider.ProtocolUtils;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.LivingEntity; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
public class FightTeam { 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).enchant().build(), player -> GUI.kitSelection(player, "")); kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, ""));
else else
kit.setItem(1, null, null, null); kit.setItem(1, null, null, null);
} }
@ -64,61 +59,51 @@ 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).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn())); memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().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).build(), GUI::chooseJoinRequests); notReadyKit.setItem(2, "INVITE_PLAYERS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseInvitation);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove); notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove);
} }
if(Config.test()) if(Config.test())
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog); notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true)); 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));
} }
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")).enchant().build(), GUI::preSchemDialog); chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).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).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false)); 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));
} }
@Getter
private UUID designatedLeader; private UUID designatedLeader;
@Getter
private FightPlayer leader; private FightPlayer leader;
@Getter private int schemRank;
private boolean publicsOnly;
private final Map<UUID, FightPlayer> players = new HashMap<>(); private final Map<Player, FightPlayer> players = new HashMap<>();
private final Set<Player> invited = new HashSet<>();
@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")
@ -126,7 +111,7 @@ public class FightTeam {
this.spawn = spawn; this.spawn = spawn;
this.schemRegion = schemRegion; this.schemRegion = schemRegion;
this.extendRegion = extendRegion; this.extendRegion = extendRegion;
this.publicsOnly = false; this.schemRank = 0;
this.ready = false; this.ready = false;
this.skip = false; this.skip = false;
this.blue = blue; this.blue = blue;
@ -135,9 +120,12 @@ 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); if(FightScoreboard.getBukkit().getTeam(name) == null)
team = FightScoreboard.getBukkit().registerNewTeam(name);
else
team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
WorldOfColorWrapper.impl.setTeamColor(team, color); WorldOfColorWrapper.impl.setTeamColor(team, color);
BountifulWrapper.impl.setNametagVisibility(team); BountifulWrapper.impl.setNametagVisibility(team);
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
@ -149,7 +137,7 @@ public class FightTeam {
new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset)); new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> { new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
if(leader != null) if(leader != null)
leader.ifPlayer(notReadyKit::loadToPlayer); notReadyKit.loadToPlayer(leader.getPlayer());
}); });
} }
@ -159,16 +147,32 @@ 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 void teleportToSpawn(){ public int getSchemRank() {
players.forEach((player, fp) -> fp.getEntity().teleport(spawn)); return schemRank;
} }
public FightPlayer getFightPlayer(LivingEntity player) { public void teleportToSpawn(){
return players.get(player.getUniqueId()); players.forEach((player, fp) -> player.teleport(spawn));
}
public FightPlayer getFightPlayer(Player player) {
return players.get(player);
} }
public boolean allPlayersOut() { public boolean allPlayersOut() {
@ -179,17 +183,17 @@ public class FightTeam {
return true; return true;
} }
public boolean isPlayerInTeam(LivingEntity player) { public boolean isPlayerInTeam(Player player) {
return players.containsKey(player.getUniqueId()); return players.containsKey(player);
} }
public boolean canPlayerEntern(LivingEntity player) { public boolean canPlayerEntern(Player player) {
return getFightPlayer(player).canEntern(); return getFightPlayer(player).canEntern();
} }
public boolean isPlayerLeader(LivingEntity player) { public boolean isPlayerLeader(Player player) {
if(leader != null) if(leader != null)
return leader.getEntity().equals(player); return leader.getPlayer().equals(player);
else else
return false; return false;
} }
@ -198,32 +202,27 @@ public class FightTeam {
skip = false; skip = false;
ready = false; ready = false;
schematic.reset(); schematic.reset();
invited.clear();
Set<UUID> playerSet = new HashSet<>(players.keySet()); Set<Player> playerSet = new HashSet<>(players.keySet());
playerSet.removeIf(uuid -> { for(Player player : playerSet){
Player player = Bukkit.getPlayer(uuid); if(!Bukkit.getOnlinePlayers().contains(player))
if(player == null) { removePlayer(player);
removePlayer(players.get(uuid).getEntity()); }
return true;
}
return false;
});
FightPlayer leaderBackup = leader; FightPlayer leaderBackup = leader;
playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player));
players.clear(); players.clear();
leader = null; leader = null;
if(leaderBackup != null){ if(leaderBackup != null){
playerSet.remove(leaderBackup.getEntity().getUniqueId()); playerSet.remove(leaderBackup.getPlayer());
addMember(leaderBackup.getEntity(), leaderBackup.getUser(), true); addMember(leaderBackup.getPlayer(), true);
} }
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true)); playerSet.forEach(p -> addMember(p, true));
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){ if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers()); for(Player player : Bukkit.getOnlinePlayers()){
Collections.shuffle(onlinePlayers);
for(Player player : onlinePlayers) {
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){ if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
addMember(player); addMember(player);
break; break;
@ -233,104 +232,79 @@ public class FightTeam {
} }
public void broadcast(String message, Object... params) { public void broadcast(String message, Object... params) {
broadcast(player -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params)); players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params));
} }
public void broadcastSystem(String message, Object... params) { public void broadcastSystem(String message, Object... params) {
broadcast(player -> FightSystem.getMessage().send(message, player, params)); players.forEach((player, fp) -> FightSystem.getMessage().send(message, player, params));
} }
public void broadcastChat(Player sender, String message) { public void broadcastChat(Player sender, String message) {
broadcast(player -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message)); players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message));
}
private void broadcast(Consumer<Player> f) {
players.forEach((uuid, fightPlayer) -> {
Player player = Bukkit.getPlayer(uuid);
if(player != null)
f.accept(player);
});
} }
public void addMember(Player player) { public void addMember(Player player) {
addMember(player, SteamwarUser.get(player.getUniqueId()), false); addMember(player, false);
} }
public void addMember(LivingEntity entity, SteamwarUser user) { public void addMember(Player player, boolean silent) {
addMember(entity, user, false); final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, false);
} FightPlayer fightPlayer = new FightPlayer(player, this);
players.put(player, fightPlayer);
invited.remove(player);
team.addEntry(player.getName());
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) { Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this); player.setHealth(20);
fightPlayer.revive(); player.setFoodLevel(20);
players.put(entity.getUniqueId(), fightPlayer); player.getInventory().clear();
Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer)); BountifulWrapper.impl.setAttackSpeed(player);
player.teleport(spawn);
Permanent.getSpectatorTeam().removeEntry(entity.getName()); memberKit.loadToPlayer(player);
team.addEntry(entity.getName()); GlobalRecorder.getInstance().playerJoins(player);
FightSystem.getTechHider().reloadChunks(player, chunksToReload, false);
entity.setHealth(20);
entity.teleport(spawn);
fightPlayer.ifPlayer(player -> {
BountifulWrapper.impl.setAttackSpeed(player);
player.setFoodLevel(20);
player.getInventory().clear();
FightSystem.getHullHider().updatePlayer(player);
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
}
});
if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, fightPlayer.canEntern() ? Region.EMPTY : Fight.getOpposite(this).getExtendRegion()));
if(isLeaderless()) if(isLeaderless())
setLeader(fightPlayer, silent); setLeader(fightPlayer, silent);
else if(!silent) else if(!silent)
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, entity.getName()); FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
} }
public void removePlayer(LivingEntity entity) { public void removePlayer(Player player) {
FightPlayer fightPlayer = getFightPlayer(entity); FightPlayer fightPlayer = getFightPlayer(player);
Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator); PersonalKitCreator.closeIfInKitCreator(player);
players.remove(entity.getUniqueId()); List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
team.removeEntry(entity.getName()); players.remove(player);
Permanent.getSpectatorTeam().addEntry(entity.getName()); team.removeEntry(player.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, entity.getName()); FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName());
if(fightPlayer.equals(leader)) if(fightPlayer.equals(leader))
removeLeader(); removeLeader();
entity.teleport(Config.SpecSpawn); GlobalRecorder.getInstance().entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
player.getInventory().clear();
fightPlayer.ifPlayer(player -> { if(player.isOnline()){
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
player.getInventory().clear(); }
if(player.isOnline()){
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, Fight.getOpposite(this).getExtendRegion());
if(ArenaMode.VariableTeams.contains(Config.mode))
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
});
} }
public boolean isLeaderless() { public boolean isLeaderless() {
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()) {
@ -341,7 +315,7 @@ public class FightTeam {
} }
private void setLeader(FightPlayer leader, boolean silent) { private void setLeader(FightPlayer leader, boolean silent) {
leader.ifPlayer(PersonalKitCreator::closeIfInKitCreator); PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
this.leader = leader; this.leader = leader;
designatedLeader = null; designatedLeader = null;
@ -349,41 +323,41 @@ public class FightTeam {
setReady(false); setReady(false);
if(!silent) if(!silent)
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName()); FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getPlayer().getName());
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty(); Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
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));
leader.ifPlayer(player -> { Player player = leader.getPlayer();
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP) if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
chooseSchemKit.loadToPlayer(player); chooseSchemKit.loadToPlayer(player);
else else
notReadyKit.loadToPlayer(player); notReadyKit.loadToPlayer(player);
});
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){ if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
FightState.setFightState(FightState.PRE_SCHEM_SETUP); FightState.setFightState(FightState.PRE_SCHEM_SETUP);
} }
leader.ifAI(ai -> pasteSchem(ai.chooseSchematic()));
} }
public Collection<FightPlayer> getPlayers() { public Collection<FightPlayer> getPlayers() {
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();
} }
@ -411,7 +385,7 @@ public class FightTeam {
} }
public void setReady(boolean ready) { public void setReady(boolean ready) {
LivingEntity l = leader.getEntity(); Player l = leader.getPlayer();
if(!schematic.hasSchematic()){ if(!schematic.hasSchematic()){
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR); FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
@ -421,12 +395,12 @@ public class FightTeam {
this.ready = ready; this.ready = ready;
if(ready) { if(ready) {
broadcast("TEAM_READY"); broadcast("TEAM_READY");
leader.ifPlayer(readyKit::loadToPlayer); readyKit.loadToPlayer(l);
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode)) if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
FightState.setFightState(FightState.PRE_RUNNING); FightState.setFightState(FightState.PRE_RUNNING);
} else { } else {
broadcast("TEAM_NOT_READY"); broadcast("TEAM_NOT_READY");
leader.ifPlayer(notReadyKit::loadToPlayer); notReadyKit.loadToPlayer(l);
} }
} }
@ -444,16 +418,32 @@ public class FightTeam {
} }
} }
public Set<Player> getInvited() {
return invited;
}
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.getPlayer().getHealth()).sum();
} }
public double getHeartRatio(){ public double getHeartRatio(){
@ -469,6 +459,10 @@ 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;
@ -483,18 +477,17 @@ public class FightTeam {
@Override @Override
public void enable() { public void enable() {
for(FightPlayer fightPlayer : players.values()) { for(FightPlayer fightPlayer : players.values()) {
fightPlayer.ifPlayer(player -> { Player player = fightPlayer.getPlayer();
PersonalKitCreator.closeIfInKitCreator(player); PersonalKitCreator.closeIfInKitCreator(player);
player.closeInventory(); player.closeInventory();
fightPlayer.getKit().loadToPlayer(player); fightPlayer.getKit().loadToPlayer(player);
});
} }
} }
@Override @Override
public void disable() { public void disable() {
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(p -> p.getInventory().clear())); players.values().forEach(fightPlayer -> fightPlayer.getPlayer().getInventory().clear());
} }
} }
@ -507,14 +500,14 @@ public class FightTeam {
@Override @Override
public void enable() { public void enable() {
players.values().forEach(fightPlayer -> { players.values().forEach(fightPlayer -> {
fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR)); Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR);
fightPlayer.getEntity().teleport(FightTeam.this.spawn); fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
}); });
} }
@Override @Override
public void disable() { public void disable() {
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL))); players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SURVIVAL));
} }
} }
} }

Datei anzeigen

@ -21,13 +21,11 @@ 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;
@ -41,8 +39,11 @@ import java.util.Objects;
public class FightWorld extends StateDependent { public class FightWorld extends StateDependent {
@Getter private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
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);
@ -56,7 +57,7 @@ public class FightWorld extends StateDependent {
@Override @Override
public void disable() { public void disable() {
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightWorld::resetWorld); //Delay to prevent raceconditions with techhider and hullhider resetWorld();
} }
public static void forceLoad(){ public static void forceLoad(){

Datei anzeigen

@ -27,7 +27,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.*;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -84,10 +83,6 @@ public class FreezeWorld implements Listener {
public void onBlockExplosion(BlockExplodeEvent e){ public void onBlockExplosion(BlockExplodeEvent e){
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler
public void onBlockExplosion(ItemSpawnEvent e){
e.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {

Datei anzeigen

@ -23,13 +23,9 @@ import de.steamwar.core.Core;
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.commands.GUI;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
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.utils.ItemBuilder;
import org.bukkit.Material;
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;
@ -41,19 +37,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
public class HotbarKit extends Kit { public class HotbarKit extends Kit {
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
static {
for(int i = 0; i < 9; i++)
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;
private final String[] nameTags; private final String[] nameTags;
@ -93,11 +81,8 @@ public class HotbarKit extends Kit {
public static class HotbarKitListener implements Listener { public static class HotbarKitListener implements Listener {
private static final Set<Player> clicked = new HashSet<>();
public HotbarKitListener() { public HotbarKitListener() {
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this); new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, clicked::clear, 10, 10);
} }
@EventHandler @EventHandler
@ -112,9 +97,6 @@ public class HotbarKit extends Kit {
return; return;
event.setCancelled(true); event.setCancelled(true);
if(!clicked.add(player))
return;
((HotbarKit)activeKit).onClicks[slot].accept(player); ((HotbarKit)activeKit).onClicks[slot].accept(player);
} }
} }

Datei anzeigen

@ -1,110 +0,0 @@
/*
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.fight;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.stream.Collectors;
public class JoinRequest {
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
return activeRequests.values().stream().filter(
request -> request.waitOnApproval.contains(team)
).map(request -> {
SWItem item = SWItem.getPlayerSkull(request.player);
item.setLore(Arrays.asList(
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
));
return new SWListInv.SWListEntry<>(item, request.player);
}).collect(Collectors.toList());
}
public static void clearRequests() {
activeRequests.clear();
}
public static JoinRequest get(Player player) {
return activeRequests.get(player);
}
private final Player player;
private final FightTeam team;
private final Set<FightTeam> waitOnApproval;
public JoinRequest(Player player, FightTeam team) {
this.player = player;
this.team = team;
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
Set<FightTeam> alreadyAccepted = new HashSet<>();
activeRequests.put(player, this);
for(FightTeam t : waitOnApproval) {
FightPlayer leader = t.getLeader();
if(leader == null)
continue;
if(leader.getEntity() == null)
continue;
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
leader.ifAI(ai -> {
if(ai.acceptJoinRequest(player, team))
alreadyAccepted.add(t);
});
}
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR);
alreadyAccepted.forEach(this::accept);
}
public boolean required(FightTeam decider) {
return waitOnApproval.contains(decider);
}
public void accept(FightTeam acceptor) {
waitOnApproval.remove(acceptor);
if(waitOnApproval.isEmpty()) {
team.addMember(player);
activeRequests.remove(player);
}
}
public void decline(FightTeam declinor) {
FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR);
waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", player.getName()));
silentDecline();
}
public void silentDecline() {
activeRequests.remove(player);
}
}

Datei anzeigen

@ -19,18 +19,17 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
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.commands.Commands; import de.steamwar.fightsystem.commands.Commands;
import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory; 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;
@ -70,19 +69,11 @@ 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;
@ -149,6 +140,10 @@ 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;
@ -161,16 +156,26 @@ public class Kit {
return !memberAllowed; return !memberAllowed;
} }
public boolean contains(ItemStack stack) { public ItemStack[] getInventory() {
for(ItemStack i : inventory) { return inventory;
if(similar(i, stack)) }
return true;
} public ItemStack[] getArmor() {
for(ItemStack i : armor) { return armor;
if(similar(i, stack)) }
return true;
} public Collection<PotionEffect> getEffects() {
return false; 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) {
@ -206,7 +211,7 @@ public class Kit {
if(FlatteningWrapper.impl.containsBlockMeta(meta)) if(FlatteningWrapper.impl.containsBlockMeta(meta))
return true; //Blocks always upwards slabs etc. return true; //Blocks always upwards slabs etc.
if(hasItems(stack)) if(CraftbukkitWrapper.impl.hasItems(stack))
return true; //Blocks prefilled inventories return true; //Blocks prefilled inventories
} }
@ -215,18 +220,6 @@ public class Kit {
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty(); return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
} }
private static final Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
private static final Class<?> nbtTagCompound = Reflection.getClass("{nms.nbt}.NBTTagCompound");
private static final Reflection.MethodInvoker getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound);
private static final Reflection.MethodInvoker getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class);
public static boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>((Set<String>) getKeys.invoke(getTag.invoke(asNMSCopy.invoke(null, stack))));
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
private boolean isEnchantmentInKit(ItemStack stack){ private boolean isEnchantmentInKit(ItemStack stack){
for(ItemStack is : inventory){ for(ItemStack is : inventory){
if(similar(stack, is)) if(similar(stack, is))

Datei anzeigen

@ -0,0 +1,99 @@
/*
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.listener;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
public class AntiCheat {
public AntiCheat() {
TinyProtocol.instance.addFilter(teleport, this::onTeleport);
TinyProtocol.instance.addFilter(position, this::onMove);
TinyProtocol.instance.addFilter(positionLook, this::onMove);
}
private static final Class<?> flying = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying");
private static final Reflection.FieldAccessor<Double> moveX = Reflection.getField(flying, double.class, 0);
private static final Reflection.FieldAccessor<Double> moveY = Reflection.getField(flying, double.class, 1);
private static final Reflection.FieldAccessor<Double> moveZ = Reflection.getField(flying, double.class, 2);
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
private static final Class<?> teleport = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPosition");
private static final Reflection.FieldAccessor<Double> tpX = Reflection.getField(teleport, double.class, 0);
private static final Reflection.FieldAccessor<Double> tpY = Reflection.getField(teleport, double.class, 1);
private static final Reflection.FieldAccessor<Double> tpZ = Reflection.getField(teleport, double.class, 2);
private final ConcurrentHashMap<Player, Movement> lastMovement = new ConcurrentHashMap<>();
private Object onTeleport(Player player, Object packet) {
//TODO Possible false flag through crouching into forbidden area?
//TODO circumvention through fast consecutive movements? (checks are synchronous)
//TODO uncertainty through moving pistons/desync etc.? (slow limit with timer to check for occurances?)
//TODO: Clearing with movement events?
Movement last = lastMovement.get(player);
if(last != null && tpX.get(packet) == last.x && tpY.get(packet) == last.y && tpZ.get(packet) == last.z) {
FightSystem.getPlugin().getLogger().log(Level.INFO, player.getName() + " was backported after small movement");
}
return packet;
}
private Object onMove(Player player, Object packet) {
//TODO Idee: Messung kleiner Movements, bei nächstem Movement mit folgendem Teleport für illegal movement trigger
Location location = player.getLocation();
double x = moveX.get(packet);
double dx = x - location.getX();
double y = moveY.get(packet);
double dy = x - location.getY();
double z = moveZ.get(packet);
double dz = z - location.getZ();
double lSqared = dx*dx + dy*dy + dz*dz;
lastMovement.compute(player, (p, previous) -> {
if(lSqared <= 0.00390625) {
return new Movement(x, y, z);
} else if(previous != null && previous.last) {
previous.last = false;
return previous;
}
return null;
});
return packet;
}
private static class Movement {
private final double x;
private final double y;
private final double z;
private boolean last;
private Movement(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
last = true;
}
}
}

Datei anzeigen

@ -21,88 +21,57 @@ 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.events.TeamDeathEvent; import de.steamwar.fightsystem.FightSystem;
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.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 net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.LivingEntity; import org.bukkit.GameMode;
import org.bukkit.Location;
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 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 onPlayerJoin(PlayerJoinEvent e) { public void arenaBorder(PlayerMoveEvent event){
addToSpectator(e.getPlayer()); Player player = event.getPlayer();
} if(Config.ArenaLeaveable && !Fight.fighting(player))
@EventHandler
public void onTeamJoin(TeamSpawnEvent e) {
e.getFightPlayer().ifPlayer(player -> {
spectatorBorder.removePlayer(player);
playerBorder.addPlayer(player);
});
}
@EventHandler
public void onTeamDeath(TeamDeathEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
@EventHandler
public void onTeamLeave(TeamLeaveEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
spectatorBorder.removePlayer(e.getPlayer());
}
private void damage() {
Fight.teams().forEach(team -> {
for(FightPlayer fp : team.getPlayers()) {
LivingEntity entity = fp.getEntity();
if(fp.isLiving() && entity.getLocation().getY() <= Config.PlayerRegion.getMinY())
entity.damage(1);
}
});
}
private void addToSpectator(Player player) {
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
return; return;
spectatorBorder.addPlayer(player); Location to = event.getTo();
assert to != null;
if(!Config.ArenaRegion.in2dRegion(to)){
reset(event);
return;
}
FightTeam team = Fight.getPlayerTeam(player);
if(team == null || player.getGameMode() == GameMode.SPECTATOR){
if(to.getY() <= Config.ArenaRegion.getMinY())
reset(event);
return;
}
if(to.getY() <= Config.ArenaRegion.getMinY()) {
if(FightState.infight())
player.damage(2);
else if(!Config.GroundWalkable)
player.teleport(team.getSpawn());
}
}
private void reset(PlayerMoveEvent event){
Player player = event.getPlayer();
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
} }
} }

Datei anzeigen

@ -0,0 +1,32 @@
/*
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());
}
}

Datei anzeigen

@ -85,7 +85,7 @@ public class ArrowStopper {
} }
private boolean checkBlock(Block block) { private boolean checkBlock(Block block) {
return Config.HiddenBlocks.contains(block.getType()); return Config.HiddenBlocks.contains(block.getType().name().toLowerCase());
} }
private boolean invalidEntity(Projectile entity) { private boolean invalidEntity(Projectile entity) {

Datei anzeigen

@ -1,61 +0,0 @@
/*
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.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class BlockPlaceCollision implements Listener {
public BlockPlaceCollision() {
new StateDependentListener(ArenaMode.All, FightState.All, this);
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
if(!block.getType().isSolid())
return;
// Hitbox size: 0.6xz, 1.8y, 1.5y when sneaking
Player player = event.getPlayer();
Location min = player.getLocation().add(-0.3, 0, -0.3);
Location max = player.getLocation().add(0.3, FlatteningWrapper.impl.isCrouching(player) ? 0.6 : (player.isSneaking() ? 1.5 : 1.8), 0.3);
Location blockmin = block.getLocation();
Location blockmax = block.getLocation().add(1.0, 1.0, 1.0);
if(
max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() ||
max.getY() <= blockmin.getY() || min.getY() >= blockmax.getY() ||
max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ()
)
return;
event.setCancelled(true);
}
}

Datei anzeigen

@ -1,148 +0,0 @@
/*
* 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);
}
}

Datei anzeigen

@ -63,7 +63,7 @@ public class Chat implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
public static void broadcastChat(String message, Object... params) { private void broadcastChat(String message, Object... params) {
GlobalRecorder.getInstance().chat(message, params); GlobalRecorder.getInstance().chat(message, params);
FightSystem.getMessage().chat(message, params); FightSystem.getMessage().chat(message, params);
} }

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm; import de.steamwar.sql.UserGroup;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -47,7 +47,7 @@ public class Check implements Listener {
Player player = e.getPlayer(); Player player = e.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(user.hasPerm(UserPerm.CHECK)) if(allowedToCheck(user))
return; return;
SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID); SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID);
@ -68,4 +68,11 @@ public class Check implements Listener {
FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player); FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player);
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!"); Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
} }
private boolean allowedToCheck(SteamwarUser user) {
return user.getUserGroup() == UserGroup.Supporter ||
user.getUserGroup() == UserGroup.Developer ||
user.getUserGroup() == UserGroup.Moderator ||
user.getUserGroup() == UserGroup.Admin;
}
} }

Datei anzeigen

@ -19,9 +19,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,14 +40,10 @@ public class ClickAnalyzer {
public ClickAnalyzer() { public ClickAnalyzer() {
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
if(Core.getVersion() > 8)
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"), this::onBlockPlace);
} }
public Object onBlockPlace(Player player, Object packet) { public Object onBlockPlace(Player player, Object packet) {
synchronized(output) { output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch());
output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch());
}
return packet; return packet;
} }

Datei anzeigen

@ -27,7 +27,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
public class DenyInventoryMovement implements Listener { public class DenyInventoryMovement implements Listener {
@ -49,9 +48,4 @@ public class DenyInventoryMovement implements Listener {
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked())) if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event) {
event.setCancelled(true);
}
} }

Datei anzeigen

@ -35,7 +35,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
public class DenyWorldInteraction implements Listener { public class DenyWorldInteraction implements Listener {
@ -54,14 +53,6 @@ public class DenyWorldInteraction implements Listener {
} }
} }
@EventHandler
public void handleItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
if(Fight.fighting(player)) {
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void handleHangingBreak(HangingBreakEvent event) { public void handleHangingBreak(HangingBreakEvent event) {
if(Config.ArenaRegion.inRegion(event.getEntity().getLocation())) { if(Config.ArenaRegion.inRegion(event.getEntity().getLocation())) {

Datei anzeigen

@ -30,20 +30,14 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects; import java.util.Objects;
public class FightScoreboard implements Listener, ScoreboardCallback { public class FightScoreboard implements Listener, ScoreboardCallback {
public static Team getBukkitTeam(String name) { public static Scoreboard getBukkit() {
Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
Team team = scoreboard.getTeam(name);
if(team != null)
return team;
return scoreboard.registerNewTeam(name);
} }
private static FightScoreboard scoreboard; private static FightScoreboard scoreboard;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
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.Fight; import de.steamwar.fightsystem.fight.Fight;
@ -27,7 +28,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.winconditions.Winconditions; import de.steamwar.fightsystem.winconditions.Winconditions;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; 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.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -42,25 +43,25 @@ public class InFightDamage implements Listener {
@EventHandler @EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) { public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof LivingEntity)) if(!(event.getEntity() instanceof Player))
//Target is not a player //Target is not a player
return; return;
LivingEntity player = ((LivingEntity) event.getEntity()); Player player = ((Player) event.getEntity());
if(!Fight.fighting(player)) if(!Fight.fighting(player))
return; return;
LivingEntity damager; Player damager;
if(event.getDamager() instanceof LivingEntity) { if(event.getDamager() instanceof Player) {
damager = (LivingEntity) event.getDamager(); damager = ((Player) event.getDamager()).getPlayer();
}else if(event.getDamager() instanceof Arrow) { }else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager(); Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof LivingEntity)) if(!(damagerArrow.getShooter() instanceof Player))
//Shooter is not a player //Shooter is not a player
return; return;
damager = (LivingEntity) damagerArrow.getShooter(); damager = (Player) damagerArrow.getShooter();
}else{ }else{
//Damager is not a player //Damager is not a player
return; return;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
@ -27,6 +28,7 @@ import org.bukkit.Material;
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.BlockDispenseEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
@ -72,4 +74,10 @@ public class InFightInventory implements Listener {
} }
} }
} }
@EventHandler
public void onBlockDispense(BlockDispenseEvent e) {
if(Config.ArenaRegion.inRegion(e.getBlock()) && e.getItem().getType() == Material.TNT)
e.setCancelled(true);
}
} }

Datei anzeigen

@ -26,12 +26,11 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FightUI; import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.entity.Entity; import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -43,20 +42,20 @@ public class IngameDeath implements Listener {
} }
@EventHandler @EventHandler
public void broadcastDeath(EntityDeathEvent event) { public void broadcastDeath(PlayerDeathEvent event) {
onPlayerEnd(event.getEntity(), fightPlayer -> { onPlayerEnd(event.getEntity(), fightPlayer -> {
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName()); FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F); Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
}); });
} }
@EventHandler @EventHandler
public void broadcastQuit(PlayerQuitEvent event) { public void broadcastQuit(PlayerQuitEvent event) {
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName())); onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName()));
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerDeath(EntityDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
onPlayerEnd(event.getEntity(), FightPlayer::setOut); onPlayerEnd(event.getEntity(), FightPlayer::setOut);
} }
@ -65,11 +64,8 @@ public class IngameDeath implements Listener {
onPlayerEnd(event.getPlayer(), FightPlayer::setOut); onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
} }
private void onPlayerEnd(Entity player, Consumer<FightPlayer> withLivingPlayer) { private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
if(!(player instanceof LivingEntity)) FightPlayer fightPlayer = Fight.getFightPlayer(player);
return;
FightPlayer fightPlayer = Fight.getFightPlayer((LivingEntity) player);
if(fightPlayer == null || !fightPlayer.isLiving()) if(fightPlayer == null || !fightPlayer.isLiving())
return; return;

Datei anzeigen

@ -1,74 +0,0 @@
/*
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.listener;
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.fight.FightPlayer;
import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.fight.JoinRequest;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
public class JoinRequestListener implements Listener {
public JoinRequestListener() {
new OneShotStateDependent(ArenaMode.VariableTeams, FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), JoinRequest::clearRequests));
new OneShotStateDependent(ArenaMode.VariableTeams, FightState.PreRunning, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), JoinRequest::clearRequests));
new StateDependentListener(ArenaMode.VariableTeams, FightState.All, this);
}
@EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightPlayer fp = Fight.getFightPlayer(player);
if (!Config.ArenaLeaveable && (fp == null || !fp.isLiving())) {
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
}
@EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if(Fight.fighting(player)) {
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
JoinRequest request = JoinRequest.get(event.getPlayer());
if(request != null)
request.silentDecline();
}
}

Datei anzeigen

@ -23,49 +23,29 @@ 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.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 de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
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.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
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.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent; import org.bukkit.event.entity.SpawnerSpawnEvent;
import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
public class Permanent implements Listener { public class Permanent implements Listener {
private static final Team spectatorTeam = FightScoreboard.getBukkitTeam("Spectator");
static {
BountifulWrapper.impl.setNametagVisibility(spectatorTeam);
spectatorTeam.setNameTagVisibility(NameTagVisibility.NEVER);
}
public static Team getSpectatorTeam() {
return spectatorTeam;
}
public Permanent() { public Permanent() {
new StateDependentListener(ArenaMode.All, FightState.All, this); new StateDependentListener(ArenaMode.All, FightState.All, this);
} }
@ -95,15 +75,10 @@ public class Permanent implements Listener {
event.setJoinMessage(null); event.setJoinMessage(null);
Player player = event.getPlayer(); Player player = event.getPlayer();
FightPlayer fp = Fight.getFightPlayer(player);
if (!Config.ArenaLeaveable && fp == null) { if (!Config.ArenaLeaveable && !Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
spectatorTeam.addEntry(player.getName());
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
} else if(fp != null && !fp.isLiving()) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(fp.getTeam().getSpawn());
} }
} }
@ -143,7 +118,7 @@ public class Permanent implements Listener {
} }
@EventHandler @EventHandler
public void onCrafting(CraftItemEvent e) { public void onCrafting(CraftItemEvent e){
if(Fight.fighting((Player) e.getWhoClicked())) if(Fight.fighting((Player) e.getWhoClicked()))
e.setCancelled(true); e.setCancelled(true);
} }
@ -155,37 +130,15 @@ public class Permanent implements Listener {
} }
@EventHandler @EventHandler
public void onDropPickup(PlayerPickupItemEvent e) { public void onDropPickup(InventoryPickupItemEvent e){
if(!(Config.ArenaRegion.inRegion(e.getItem().getLocation()))) if(Config.ArenaRegion.inRegion(e.getItem().getLocation()))
return; e.setCancelled(true);
Player player = e.getPlayer();
ItemStack stack = e.getItem().getItemStack();
if(Config.PersonalKits) {
if(Config.ForbiddenItems.contains(stack.getType())) {
e.setCancelled(true);
}
} else {
FightPlayer fp = Fight.getFightPlayer(player);
if(fp == null)
return;
if(!fp.getKit().contains(stack)) {
e.setCancelled(true);
}
}
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler
public void onExplosion(EntityExplodeEvent e) { public void onDropping(PlayerDropItemEvent e){
e.blockList().removeIf(block -> { if(Fight.fighting(e.getPlayer()))
if(block.getType() == Material.TNT) { e.setCancelled(true);
return false;
} else {
block.setType(Material.AIR);
return true;
}
});
} }
@EventHandler @EventHandler
@ -208,36 +161,4 @@ public class Permanent implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void onBlockDispense(BlockDispenseEvent e) {
Block block = e.getBlock();
if(!Config.ArenaRegion.inRegion(block))
return;
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
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);
}
} }

Datei anzeigen

@ -37,7 +37,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -109,15 +108,6 @@ public class PersonalKitCreator implements Listener {
backup.close(); backup.close();
} }
@EventHandler
public void onOpenEvent(InventoryOpenEvent e){
InventoryBackup backup = openKitCreators.get(e.getPlayer());
if(backup == null)
return;
backup.close();
}
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent e) { public void onInventoryClose(InventoryCloseEvent e) {
InventoryBackup backup = openKitCreators.get(e.getPlayer()); InventoryBackup backup = openKitCreators.get(e.getPlayer());

Datei anzeigen

@ -28,25 +28,17 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction; import org.bukkit.block.PistonMoveReaction;
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.BlockPistonEvent;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
import java.util.Set;
import java.util.function.Consumer;
public class PistonListener implements Listener { public class PistonListener implements Listener {
private final Consumer<BlockPistonEvent> leftAreaHandler; public PistonListener() {
public PistonListener(Set<ArenaMode> condition, Consumer<BlockPistonEvent> leftAreaHandler) {
this.leftAreaHandler = leftAreaHandler;
if(!condition.contains(Config.mode))
return;
//Wenn Entern aktiv ist, sollen Raketen etc. entern können //Wenn Entern aktiv ist, sollen Raketen etc. entern können
new StateDependentListener(!Config.AllowMissiles, FightState.All, this); if(!ArenaMode.Check.contains(Config.mode)) {
new StateDependentListener(Config.AllowMissiles, FightState.Setup, this); new StateDependentListener(!Config.AllowMissiles, FightState.All, this);
new StateDependentListener(Config.AllowMissiles, FightState.Setup, this);
}
} }
@EventHandler @EventHandler
@ -58,7 +50,7 @@ public class PistonListener implements Listener {
for(Block block : e.getBlocks()){ for(Block block : e.getBlocks()){
Block target = block.getRelative(face); Block target = block.getRelative(face);
if(!Config.BlueExtendRegion.inRegion(target) && !Config.RedExtendRegion.inRegion(target) && block.getPistonMoveReaction() != PistonMoveReaction.BREAK) { if(!Config.BlueExtendRegion.inRegion(target) && !Config.RedExtendRegion.inRegion(target) && block.getPistonMoveReaction() != PistonMoveReaction.BREAK) {
leftAreaHandler.accept(e); e.setCancelled(true);
return; return;
} }
} }
@ -71,7 +63,7 @@ public class PistonListener implements Listener {
for(Block block : e.getBlocks()){ for(Block block : e.getBlocks()){
if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)) { if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)) {
leftAreaHandler.accept(e); e.setCancelled(true);
return; return;
} }
} }

Datei anzeigen

@ -23,9 +23,6 @@ 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;
@ -34,10 +31,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
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 de.steamwar.fightsystem.utils.BountifulWrapper; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -145,11 +139,6 @@ 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()))
@ -159,13 +148,19 @@ public class Recording implements Listener {
} }
@EventHandler @EventHandler
public void onPlayerDeath(TeamDeathEvent e) { public void onPlayerDeath(PlayerDeathEvent e) {
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity()); if(isNotSent(e.getEntity()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
} }
@EventHandler @EventHandler
public void onPlayerLeave(TeamLeaveEvent e) { public void onPlayerQuit(PlayerQuitEvent e){
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity()); if(isNotSent(e.getPlayer()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@ -286,20 +281,19 @@ public class Recording implements Listener {
if(!fp.isLiving()) if(!fp.isLiving())
continue; continue;
fp.ifPlayer(player -> { Player player = fp.getPlayer();
BountifulWrapper.impl.recordHandItems(player); BountifulWrapper.impl.recordHandItems(player);
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD"); GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST"); GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS"); GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET"); GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
});
} }
} }
private void despawnTeam(FightTeam team){ private void despawnTeam(FightTeam team){
for(FightPlayer player : team.getPlayers()){ for(FightPlayer player : team.getPlayers()){
if(player.isLiving()) if(player.isLiving())
GlobalRecorder.getInstance().entityDespawns(player.getEntity()); GlobalRecorder.getInstance().entityDespawns(player.getPlayer());
} }
} }

Datei anzeigen

@ -25,11 +25,15 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
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.utils.FlatteningWrapper;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Material; import org.bukkit.Material;
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.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class RunningWorldInteraction implements Listener { public class RunningWorldInteraction implements Listener {
@ -37,6 +41,35 @@ public class RunningWorldInteraction implements Listener {
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this); new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
} }
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if(!Fight.fighting(event.getPlayer()))
return;
Inventory inventory = event.getPlayer().getInventory();
ItemStack stack = FlatteningWrapper.impl.onBreak(event.getBlock());
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
ItemStack itemStack = inventory.getItem(i);
if (itemStack != null && itemStack.isSimilar(stack) && itemStack.getAmount() != itemStack.getMaxStackSize()) {
itemStack.setAmount(itemStack.getAmount() + 1);
inventory.setItem(i, itemStack);
event.getPlayer().updateInventory();
return;
}
}
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
ItemStack itemStack = inventory.getItem(i);
if (itemStack == null || itemStack.getType().equals(Material.AIR)) {
inventory.setItem(i, stack);
event.getPlayer().updateInventory();
return;
}
}
}
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent e) { public void onBlockPlace(BlockPlaceEvent e) {
FightPlayer fp = Fight.getFightPlayer(e.getPlayer()); FightPlayer fp = Fight.getFightPlayer(e.getPlayer());

Datei anzeigen

@ -22,122 +22,109 @@ 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.states.StateDependentTask; import de.steamwar.fightsystem.utils.Region;
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.player.PlayerJoinEvent; import org.bukkit.event.block.BlockBreakEvent;
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 final FightTeam team; private static final Set<Player> realSpectator = new HashSet<>();
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 playerJoin(PlayerJoinEvent e) { public void teamAreas(PlayerMoveEvent event) {
Player player = e.getPlayer(); Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) != team && !Config.isReferee(player)) if(Config.isReferee(player))
spectatorBorder.addPlayer(player); return;
}
@EventHandler FightTeam team = Fight.getPlayerTeam(player);
public void teamJoin(TeamSpawnEvent e) { Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
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) {
Player player = e.getPlayer(); realSpectator.remove(e.getPlayer());
spectatorBorder.removePlayer(player);
bordingBorder.removePlayer(player);
realSpectator.remove(player);
} }
private void realSpectatorCheck() { @EventHandler
for(FightPlayer fightPlayer : team.getPlayers()) { public void blockPlace(BlockPlaceEvent event) {
if(fightPlayer.isLiving()) Player player = event.getPlayer();
continue; Block block = event.getBlock();
if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block))
return;
fightPlayer.ifPlayer(player -> { event.setCancelled(true);
boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation()); FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
if(inRegion && !realSpectator.contains(player)) { }
realSpectator.add(player);
//Later to prevent race condition with Fight.setSpecatator() during respawn @EventHandler
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { public void blockBreak(BlockBreakEvent event) {
if(!player.isOnline()) Block block = event.getBlock();
return; if(Config.BluePasteRegion.getMinY() <= block.getY())
Fight.pseudoSpectator(player, false); return;
}, 2);
}else if(!inRegion && realSpectator.contains(player)) { event.setCancelled(true);
Fight.pseudoSpectator(player, true); FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
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);
}
} }

Datei anzeigen

@ -27,7 +27,6 @@ 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.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
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;
@ -44,7 +43,7 @@ public class TestJoin implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) { if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) {
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player); FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);
player.kickPlayer(""); player.kickPlayer("");
return; return;

Datei anzeigen

@ -71,27 +71,19 @@ 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 && !spawn.getExtendRegion().inRegion(event.getLocation())) { if(spawn != null && event.blockList().isEmpty() && Fight.getOpposite(spawn).getExtendRegion().inRegion(event.getLocation())) {
Block b = event.getLocation().getBlock(); checkBlock(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));
}
}
}
} }
event.blockList().forEach(this::checkNeighbours); for(Block b : event.blockList()){
} //b cannot be water or air due to current explosion
private void checkNeighbours(Block b) { checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.UP)); checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.EAST)); checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.WEST)); checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.NORTH)); checkBlock(b.getRelative(BlockFace.SOUTH));
checkBlock(b.getRelative(BlockFace.SOUTH)); }
checkBlock(b.getRelative(BlockFace.DOWN));
} }
private void checkBlock(Block b) { private void checkBlock(Block b) {
@ -106,6 +98,10 @@ public class WaterRemover implements Listener {
if(b.getY() < MIN_Y) if(b.getY() < MIN_Y)
return; return;
checkNeighbours(b); checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
} }
} }

Datei anzeigen

@ -22,17 +22,19 @@ 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();

Datei anzeigen

@ -50,7 +50,6 @@ public class FileSource extends PacketSource {
public FileSource(File fightFile) throws IOException { public FileSource(File fightFile) throws IOException {
super(new GZIPInputStream(new FileInputStream(fightFile))); super(new GZIPInputStream(new FileInputStream(fightFile)));
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -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

Datei anzeigen

@ -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);
} }

Datei anzeigen

@ -31,7 +31,6 @@ public class LiveSource extends PacketSource {
protected LiveSource(Socket socket) throws IOException { protected LiveSource(Socket socket) throws IOException {
super(socket.getInputStream()); super(socket.getInputStream());
this.socket = socket; this.socket = socket;
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -56,7 +56,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scoreboard.NameTagVisibility;
import java.io.EOFException; import java.io.EOFException;
import java.io.FilterInputStream; import java.io.FilterInputStream;
@ -67,11 +66,16 @@ import java.util.stream.Collectors;
public class PacketProcessor implements Listener { public class PacketProcessor implements Listener {
private static final org.bukkit.scoreboard.Team team = FightScoreboard.getBukkitTeam("Replay"); /*private static final String SCOREBOARD_TEAMNAME = "Replay";
private static final Team team;
static { static {
BountifulWrapper.impl.setNametagVisibility(team); if(FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME) == null)
team = FightScoreboard.getBukkit().registerNewTeam(SCOREBOARD_TEAMNAME);
else
team = FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME);
team.setNameTagVisibility(NameTagVisibility.NEVER); team.setNameTagVisibility(NameTagVisibility.NEVER);
} }*/
private static PacketProcessor currentProcessor = null; private static PacketProcessor currentProcessor = null;
@ -88,8 +92,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().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet()); 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 int obfuscateWith = BlockIds.impl.materialToId(Config.ObfuscateWith); private final int obfuscateWith = BlockIds.impl.materialToId(Material.getMaterial(Config.ObfuscateWith.toUpperCase()));
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<>();
@ -121,8 +125,7 @@ public class PacketProcessor implements Listener {
packetDecoder[0x0a] = this::bow; packetDecoder[0x0a] = this::bow;
packetDecoder[0x0b] = this::damage; packetDecoder[0x0b] = this::damage;
packetDecoder[0x0c] = this::fireTick; packetDecoder[0x0c] = this::fireTick;
packetDecoder[0x20] = this::oldArenaInfo; packetDecoder[0x20] = this::arenaInfo;
packetDecoder[0x21] = this::arenaInfo;
packetDecoder[0x30] = this::byteWorldHeightBlock; packetDecoder[0x30] = this::byteWorldHeightBlock;
packetDecoder[0x31] = this::particle; packetDecoder[0x31] = this::particle;
packetDecoder[0x32] = this::sound; packetDecoder[0x32] = this::sound;
@ -165,11 +168,6 @@ 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());
@ -240,8 +238,7 @@ public class PacketProcessor implements Listener {
execSync(() -> { execSync(() -> {
SteamwarUser user = SteamwarUser.get(userId); SteamwarUser user = SteamwarUser.get(userId);
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn)); entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
team.addEntry(user.getUserName());
}); });
} }
@ -262,10 +259,8 @@ 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);
}
}); });
} }
@ -274,10 +269,8 @@ 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();
}
}); });
} }
@ -298,7 +291,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(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn))); execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
} }
private void entityVelocity() throws IOException { private void entityVelocity() throws IOException {
@ -353,13 +346,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(() -> addREntity(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn))); execSync(() -> entities.put(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(() -> addREntity(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn))); execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
} }
private void send(ChatMessageType type) throws IOException { private void send(ChatMessageType type) throws IOException {
@ -377,20 +370,13 @@ public class PacketProcessor implements Listener {
Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix)); Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix));
} }
private void oldArenaInfo() throws IOException { private void arenaInfo() throws IOException {
rotateZ = source.readBoolean() != Config.blueNegZ(); rotateZ = source.readBoolean() != Config.blueNegZ();
arenaMinY = Byte.toUnsignedInt(source.readByte()); arenaMinY = Byte.toUnsignedInt(source.readByte());
arenaMinX = source.readInt(); arenaMinX = source.readInt();
arenaMinZ = source.readInt(); arenaMinZ = source.readInt();
} }
private void arenaInfo() throws IOException {
rotateZ = source.readBoolean() != Config.blueNegZ();
arenaMinX = source.readInt();
arenaMinY = source.readInt();
arenaMinZ = source.readInt();
}
private void shortBlock() throws IOException { private void shortBlock() throws IOException {
int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX(); int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX();
int y = Byte.toUnsignedInt(source.readByte()); int y = Byte.toUnsignedInt(source.readByte());
@ -446,10 +432,7 @@ 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(() -> { execSync(() -> BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
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 {
@ -590,7 +573,6 @@ 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();
@ -633,7 +615,7 @@ public class PacketProcessor implements Listener {
} }
private void tick(){ private void tick(){
execSync(entityServer::tick); entityServer.tick();
if(!source.async() && !skipToSubtitle) if(!source.async() && !skipToSubtitle)
tickFinished = true; tickFinished = true;

Datei anzeigen

@ -30,6 +30,7 @@ public abstract class PacketSource extends DataInputStream {
protected PacketSource(InputStream inputStream){ protected PacketSource(InputStream inputStream){
super(inputStream); super(inputStream);
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -29,14 +29,13 @@ import de.steamwar.fightsystem.utils.BlockIdWrapper;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.sql.NodeData; import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -69,7 +68,7 @@ public interface Recorder {
if(FightState.AntiSpectate.contains(FightState.getFightState())){ if(FightState.AntiSpectate.contains(FightState.getFightState())){
for(FightPlayer player : team.getPlayers()){ for(FightPlayer player : team.getPlayers()){
if(player.isLiving()){ if(player.isLiving()){
playerJoins(player.getEntity(), player.getUser()); playerJoins(player.getPlayer());
} }
} }
} }
@ -99,8 +98,7 @@ public interface Recorder {
* PlayerDamagePacket (0x0b) + int EntityId * PlayerDamagePacket (0x0b) + int EntityId
* SetOnFire (0x0c) + int EntityId + boolean perma * SetOnFire (0x0c) + int EntityId + boolean perma
* *
* DEPRECATED ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ * ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ
* ArenaInfo (0x21) + bool blueNegZ + int arenaMinX + int arenaMinY + int arenaMinZ
* *
* DEPRECATED BlockPacket (0x30) + pos int, byte, int + int BlockState * DEPRECATED BlockPacket (0x30) + pos int, byte, int + int BlockState
* ParticlePacket (0x31) + double x, y, z + string particleType * ParticlePacket (0x31) + double x, y, z + string particleType
@ -149,7 +147,9 @@ public interface Recorder {
* 0x08: Message following * 0x08: Message following
* */ * */
default void playerJoins(LivingEntity p, SteamwarUser user){ default void playerJoins(Player p){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
write(0x00, p.getEntityId(), user.getId()); write(0x00, p.getEntityId(), user.getId());
entityMoves(p); entityMoves(p);
} }
@ -213,7 +213,8 @@ public interface Recorder {
} }
default void arenaInfo(){ default void arenaInfo(){
write(0x21, Config.blueNegZ(), Config.ArenaRegion.getMinX(), Config.BluePasteRegion.getMinY(), Config.ArenaRegion.getMinZ()); write(0x20, Config.blueNegZ(), (byte)Config.BluePasteRegion.getMinY(),
Config.ArenaRegion.getMinX(), Config.ArenaRegion.getMinZ());
} }
default void blockChange(Block block){ default void blockChange(Block block){
@ -275,7 +276,7 @@ public interface Recorder {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{ try{
copy(NodeData.get(SchematicNode.getSchematicNode(schemId)).schemData(), buffer); copy(new SchematicData(SchematicNode.getSchematicNode(schemId)).schemData(), buffer);
}catch (EOFException e) { }catch (EOFException e) {
Bukkit.getLogger().log(Level.INFO, "EOFException ignored"); Bukkit.getLogger().log(Level.INFO, "EOFException ignored");
} catch (IOException e) { } catch (IOException e) {

Datei anzeigen

@ -19,8 +19,6 @@
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 {
@ -50,9 +48,12 @@ 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;

Datei anzeigen

@ -19,28 +19,16 @@
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); Object getPose(boolean sneaking);
void untrackEntity(Player player, int entity);
} }

Datei anzeigen

@ -52,12 +52,12 @@ public class BungeeFightInfo {
Fight.getRedTeam().getColoredName(), Fight.getRedTeam().getColoredName(),
FightState.getFightState().name(), FightState.getFightState().name(),
StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0, StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0,
Fight.getBlueTeam().getLeader() != null ? Fight.getBlueTeam().getLeader().getUser().getId() : 0, Fight.getBlueTeam().getLeader() != null ? SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId() : 0,
Fight.getRedTeam().getLeader() != null ? Fight.getRedTeam().getLeader().getUser().getId() : 0, Fight.getRedTeam().getLeader() != null ? SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId() : 0,
Fight.getBlueTeam().getSchematic(), Fight.getBlueTeam().getSchematic(),
Fight.getRedTeam().getSchematic(), Fight.getRedTeam().getSchematic(),
Fight.getBlueTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()), Fight.getBlueTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
Fight.getRedTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList()) Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList())
)); ));
} }

Datei anzeigen

@ -23,6 +23,8 @@ import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -30,7 +32,9 @@ public interface CraftbukkitWrapper {
CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
void resetChunk(World world, World backup, int x, int z); void resetChunk(World world, World backup, int x, int z);
void sendResourcePack(Player player, String pack, String sha1);
float headRotation(Entity e); float headRotation(Entity e);
boolean hasItems(ItemStack stack);
Stream<?> entityIterator(); Stream<?> entityIterator();
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.EnternCountdown;
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;
@ -51,7 +53,8 @@ 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(null); if(Config.EnterStages.size() > fp.getKit().getEnterStage() && fp.getKit().getEnterStage() >= 0)
fp.setEnternCountdown(new EnternCountdown(fp));
} }
} }

Datei anzeigen

@ -35,7 +35,6 @@ 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;
@ -47,7 +46,6 @@ 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() {
@ -80,7 +78,6 @@ public class FightStatistics {
FightTeam winner = FightSystem.getLastWinner(); FightTeam winner = FightSystem.getLastWinner();
String windescription = FightSystem.getLastWinreason(); String windescription = FightSystem.getLastWinreason();
String gameMode = Config.SchematicType.toDB(); String gameMode = Config.SchematicType.toDB();
Instant endTime = Instant.now();
int blueLeader = getLeader(Fight.getBlueTeam()); int blueLeader = getLeader(Fight.getBlueTeam());
int redLeader = getLeader(Fight.getRedTeam()); int redLeader = getLeader(Fight.getRedTeam());
@ -96,12 +93,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 (NullPointerException e) { } catch (SecurityException e) {
blueSchem = null; blueSchem = null;
} }
try { try {
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId(); redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
} catch (NullPointerException e) { } catch (SecurityException e) {
redSchem = null; redSchem = null;
} }
@ -134,7 +131,7 @@ public class FightStatistics {
} }
if (!Bukkit.getOnlinePlayers().isEmpty() && !unranked) { if (!Bukkit.getOnlinePlayers().isEmpty() && !unranked) {
NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode, (int)(endTime.getEpochSecond() - starttime.toInstant().getEpochSecond()))); NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode));
} }
unranked = false; unranked = false;
@ -142,13 +139,14 @@ public class FightStatistics {
private int getLeader(FightTeam team) { private int getLeader(FightTeam team) {
if (team.getLeader() != null) if (team.getLeader() != null)
return team.getLeader().getUser().getId(); return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
else if (team.getDesignatedLeader() != null) else if (team.getDesignatedLeader() != null)
return SteamwarUser.get(team.getDesignatedLeader()).getId(); return SteamwarUser.get(team.getDesignatedLeader()).getId();
return 0; return 0;
} }
private void savePlayerStats(FightPlayer fp, int fightId) { private void savePlayerStats(FightPlayer fp, int fightId) {
de.steamwar.sql.FightPlayer.create(fightId, fp.getUser().getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving()); SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
} }
} }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen