diff --git a/FightSystem_10/pom.xml b/FightSystem_10/pom.xml
index 66633c1..3e87409 100644
--- a/FightSystem_10/pom.xml
+++ b/FightSystem_10/pom.xml
@@ -17,28 +17,10 @@
FightSystem_10
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
- FightSystem_9
- 1.0
-
-
- steamwar
- FightSystem_API
+ FightSystem_Core
1.0
diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java
deleted file mode 100644
index 5a805c9..0000000
--- a/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerSwapHandItemsEvent;
-
-public class DenyWorldInteraction_10 implements Listener {
-
- @EventHandler
- public void onSwapItems(PlayerSwapHandItemsEvent event) {
- event.setCancelled(true);
- }
-}
diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java
deleted file mode 100644
index d02d944..0000000
--- a/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class PersonalKitCreator_10 {
-
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
- }
-}
diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java
similarity index 69%
rename from FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java
rename to FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java
index 849b070..3e20fe9 100644
--- a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java
+++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,24 +15,29 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
+import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_10_R1.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_10 {
- private FightWorld_10(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@@ -40,7 +45,7 @@ public class FightWorld_10 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
- if (!isPaper) {
+ if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@@ -50,11 +55,21 @@ public class FightWorld_10 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_12/pom.xml b/FightSystem_12/pom.xml
index 0c0bcba..e5c8537 100644
--- a/FightSystem_12/pom.xml
+++ b/FightSystem_12/pom.xml
@@ -17,28 +17,15 @@
FightSystem_12
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
- FightSystem_10
+ FightSystem_8
1.0
steamwar
- FightSystem_API
+ FightSystem_Core
1.0
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java
deleted file mode 100644
index 0f3b5c6..0000000
--- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.fight;
-
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import org.bukkit.ChatColor;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.scoreboard.Team;
-
-import java.util.Collections;
-import java.util.Set;
-
-class FightTeam_12 {
- private FightTeam_12(){}
-
- @SuppressWarnings("deprecation")
- private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
-
- @SuppressWarnings("deprecation")
- private static final BaseBlock CONCRETE = new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE);
- @SuppressWarnings("deprecation")
- private static final BaseBlock CONCRETE_POWDER = new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE);
-
- private static final Set CONCRETE_SET = Collections.singleton(CONCRETE);
- private static final Set CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER);
-
- static void setTeamColor(Team team, ChatColor color){
- team.setColor(color);
- team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
- }
-
- static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
- FightTeam_8.replaceTeamColor(clipboard, c);
-
- Vector minimum = clipboard.getRegion().getMinimumPoint();
- BaseBlock concrete = new BaseBlock(CONCRETE.getId(), c.getWoolData());
- BaseBlock concretePowder = new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData());
-
- for(int x = 0; x < clipboard.getDimensions().getX(); x++){
- for(int y = 0; y < clipboard.getDimensions().getY(); y++){
- for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
- Vector pos = minimum.add(x, y, z);
- BaseBlock block = clipboard.getBlock(pos);
- if(block.equals(CONCRETE)){
- clipboard.setBlock(pos, concrete);
- }else if(block.equals(CONCRETE_POWDER)){
- clipboard.setBlock(pos, concretePowder);
- }
- }
- }
- }
- }
-}
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java b/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java
deleted file mode 100644
index a76bdc8..0000000
--- a/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class PersonalKitCreator_12 {
-
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
- }
-}
\ No newline at end of file
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java
similarity index 69%
rename from FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java
rename to FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java
index be3596e..1c03c20 100644
--- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java
+++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,24 +15,29 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
+import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_12_R1.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_12 {
- private FightWorld_12(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@@ -40,7 +45,7 @@ public class FightWorld_12 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
- if (!isPaper) {
+ if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@@ -50,11 +55,21 @@ public class FightWorld_12 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java
new file mode 100644
index 0000000..f554505
--- /dev/null
+++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java
@@ -0,0 +1,124 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.events.PacketAdapter;
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.events.PacketEvent;
+import com.comphenix.protocol.reflect.StructureModifier;
+import com.comphenix.protocol.wrappers.nbt.NbtBase;
+import com.comphenix.protocol.wrappers.nbt.NbtCompound;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+
+import static de.steamwar.fightsystem.utils.TechHider.bypass;
+
+public class TechHider12 extends PacketAdapter {
+
+ private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds();
+ private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith();
+
+ public TechHider12() {
+ super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
+ }
+
+ @Override
+ public void onPacketSending(PacketEvent e) {
+ PacketContainer packet = e.getPacket();
+ StructureModifier ints = packet.getIntegers();
+
+ int chunkX = ints.read(0);
+ int chunkZ = ints.read(1);
+ Player p = e.getPlayer();
+ if(bypass(p, chunkX, chunkZ))
+ return;
+
+ packet = packet.shallowClone();
+ e.setPacket(packet);
+ StructureModifier>> list = packet.getListNbtModifier();
+ List> nmsTags = list.read(0);
+ boolean changed = false;
+ for(int i = nmsTags.size() - 1; i >= 0; i--){
+ NbtCompound nbt = (NbtCompound)nmsTags.get(i);
+ if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
+ nmsTags.remove(i);
+ changed = true;
+ }
+ }
+ if(changed)
+ list.write(0, nmsTags);
+
+ changed = false;
+ StructureModifier byteArray = packet.getByteArrays();
+ byte [] data = byteArray.read(0);
+ ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
+ int i = 0;
+
+ while(i < data.length){
+ byte bitsPerBlock = data[i++];
+ buffer.writeByte(bitsPerBlock);
+
+ if(bitsPerBlock != 13){
+ int paletteLength = TechHider.readVarInt(data, i);
+ int paletteLengthLength = TechHider.readVarIntLength(data, i);
+ buffer.writeBytes(data, i, paletteLengthLength);
+ i += paletteLengthLength;
+
+ for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
+ int entry = TechHider.readVarInt(data, i);
+ i += TechHider.readVarIntLength(data, i);
+
+ if(hiddenBlockIds.contains(entry)){
+ entry = obfuscateWith;
+ changed = true;
+ }
+ buffer.writeBytes(TechHider.writeVarInt(entry));
+ }
+ }else{
+ buffer.writeByte(data[++i]); //Empty palette
+ Bukkit.getLogger().log(Level.SEVERE, "Full chunk occured");
+ }
+
+ int dataArrayLength = TechHider.readVarInt(data, i);
+ int dataArrayLengthLength = TechHider.readVarIntLength(data, i);
+ buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
+ i += dataArrayLengthLength;
+ i += dataArrayLength * 8;
+
+ buffer.writeBytes(data, i, 4096);
+ i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
+ }
+
+ if(changed){
+ data = new byte[buffer.readableBytes()];
+ buffer.readBytes(data);
+ byteArray.write(0, data);
+ }
+ }
+}
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java
deleted file mode 100644
index 4286cd5..0000000
--- a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.utils;
-
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.events.PacketAdapter;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.events.PacketEvent;
-import com.comphenix.protocol.reflect.StructureModifier;
-import com.comphenix.protocol.wrappers.nbt.NbtBase;
-import com.comphenix.protocol.wrappers.nbt.NbtCompound;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.IFightSystem;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.UnpooledByteBufAllocator;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-
-import static de.steamwar.fightsystem.utils.ITechHider.bypass;
-
-class TechHider_12 {
- private TechHider_12(){}
-
- static PacketAdapter chunkHider(Set hiddenBlockIds, int obfuscateWith){
- return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
- @Override
- public void onPacketSending(PacketEvent e) {
- PacketContainer packet = e.getPacket();
- StructureModifier ints = packet.getIntegers();
-
- int chunkX = ints.read(0);
- int chunkZ = ints.read(1);
- Player p = e.getPlayer();
- if(bypass(p, chunkX, chunkZ))
- return;
-
- packet = packet.shallowClone();
- e.setPacket(packet);
- StructureModifier>> list = packet.getListNbtModifier();
- List> nmsTags = list.read(0);
- boolean changed = false;
- for(int i = nmsTags.size() - 1; i >= 0; i--){
- NbtCompound nbt = (NbtCompound)nmsTags.get(i);
- if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
- nmsTags.remove(i);
- changed = true;
- }
- }
- if(changed)
- list.write(0, nmsTags);
-
- changed = false;
- StructureModifier byteArray = packet.getByteArrays();
- byte [] data = byteArray.read(0);
- ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
- int i = 0;
-
- while(i < data.length){
- byte bitsPerBlock = data[i++];
- buffer.writeByte(bitsPerBlock);
-
- if(bitsPerBlock != 13){
- int paletteLength = ITechHider.readVarInt(data, i);
- int paletteLengthLength = ITechHider.readVarIntLength(data, i);
- buffer.writeBytes(data, i, paletteLengthLength);
- i += paletteLengthLength;
-
- for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
- int entry = ITechHider.readVarInt(data, i);
- i += ITechHider.readVarIntLength(data, i);
-
- if(hiddenBlockIds.contains(entry)){
- entry = obfuscateWith;
- changed = true;
- }
- buffer.writeBytes(ITechHider.writeVarInt(entry));
- }
- }else{
- buffer.writeByte(data[++i]); //Empty palette
- Bukkit.getLogger().log(Level.SEVERE, "Full chunk 1.12 occured");
- }
-
- int dataArrayLength = ITechHider.readVarInt(data, i);
- int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
- buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
- i += dataArrayLengthLength;
- i += dataArrayLength * 8;
-
- buffer.writeBytes(data, i, 4096);
- i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
- }
-
- if(changed){
- data = new byte[buffer.readableBytes()];
- buffer.readBytes(data);
- byteArray.write(0, data);
- }
- }
- };
- }
-}
diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java
new file mode 100644
index 0000000..deef5e6
--- /dev/null
+++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java
@@ -0,0 +1,44 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.Sound;
+import org.bukkit.SoundCategory;
+import org.bukkit.entity.Arrow;
+import org.bukkit.scoreboard.Team;
+
+public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
+ @Override
+ public void setTeamColor(Team team, ChatColor color) {
+ team.setColor(color);
+ }
+
+ @Override
+ public boolean isInBlock(Arrow e) {
+ return e.isInBlock();
+ }
+
+ @Override
+ public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
+ location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
+ }
+}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java
similarity index 65%
rename from FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java
rename to FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java
index 3255431..7dd977b 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java
+++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,16 +15,18 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.utils;
-import org.bukkit.DyeColor;
+import com.sk89q.worldedit.blocks.BaseBlock;
+import org.bukkit.Material;
-class ColorConverter_8 {
- private ColorConverter_8(){}
+@SuppressWarnings("deprecation")
+public class WorldeditWrapper12 extends WorldeditWrapper8 {
- static DyeColor getSilver(){
- return DyeColor.SILVER;
+ static {
+ colorBlocks.add(new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE));
+ colorBlocks.add(new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE));
}
}
diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml
index 3d7c934..ad025b7 100644
--- a/FightSystem_14/pom.xml
+++ b/FightSystem_14/pom.xml
@@ -17,19 +17,6 @@
FightSystem_14
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
@@ -47,12 +34,7 @@
steamwar
- FightSystem_API
- 1.0
-
-
- steamwar
- FightSystem_12
+ FightSystem_Core
1.0
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java
deleted file mode 100644
index d648d9b..0000000
--- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.fight;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.session.ClipboardHolder;
-import com.sk89q.worldedit.world.World;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.utils.Region;
-import de.steamwar.sql.NoClipboardException;
-import de.steamwar.sql.Schematic;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.scoreboard.Team;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Objects;
-
-public class FightTeam_14 {
- private FightTeam_14(){}
-
- private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
- private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
- private static final BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
- private static final BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
- private static final BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
- private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
- private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
-
- static void setTeamColor(Team team, ChatColor color){
- team.setColor(color);
- team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
- }
-
- static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
- BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
- BaseBlock wool = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
- BaseBlock clay = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
- BaseBlock glass = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
- BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
- BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
- BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
- BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
-
- for(int x = 0; x < clipboard.getDimensions().getX(); x++){
- for(int y = 0; y < clipboard.getDimensions().getY(); y++){
- for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
- BlockVector3 pos = minimum.add(x, y, z);
- BaseBlock block = clipboard.getFullBlock(pos);
- if(block.equals(WOOL)){
- clipboard.setBlock(pos, wool);
- }else if(block.equals(CLAY)){
- clipboard.setBlock(pos, clay);
- }else if(block.equals(GLASS)){
- clipboard.setBlock(pos, glass);
- }else if(block.equals(GLASS_PANE)){
- clipboard.setBlock(pos, glassPane);
- }else if(block.equals(CARPET)){
- clipboard.setBlock(pos, carpet);
- }else if(block.equals(CONCRETE)){
- clipboard.setBlock(pos, concrete);
- }else if(block.equals(CONCRETE_POWDER)){
- clipboard.setBlock(pos, concretePowder);
- }
- }
- }
- }
- }
-
- static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) throws NoClipboardException {
- BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
-
- World w = new BukkitWorld(Bukkit.getWorlds().get(0));
- BlockVector3 dimensions = clipboard.getDimensions();
- BlockVector3 v;
- BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
- AffineTransform aT = new AffineTransform();
- if(rotate){
- aT = aT.rotateY(180);
- v = paste.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
- }else{
- v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
- }
-
- if(Config.WaterDepth != 0){
- BlockVector3 it = clipboard.getMinimumPoint();
- int depth = 0;
- while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
- depth++;
- it = it.add(0, 1, 0);
- }
- v = v.add(0, Config.WaterDepth - depth, 0);
- }
-
- EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
- ClipboardHolder ch = new ClipboardHolder(clipboard);
- ch.setTransform(aT);
- Operations.completeBlindly(ch.createPaste(e).to(v).build());
- e.flushSession();
- }
-
- public static boolean checkPistonMoving(Block block){
- return block.getType() == Material.MOVING_PISTON;
- }
-
- public static void saveSchem(Schematic schem, Region region, int minY) {
- World w = new BukkitWorld(Bukkit.getWorlds().get(0));
- BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
- CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
- BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
- EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
-
- ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
- forwardExtentCopy.setCopyingEntities(false);
-
- try{
- Operations.complete(forwardExtentCopy);
- }catch(WorldEditException e){
- throw new IllegalStateException(e);
- }
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try {
- ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
- writer.write(clipboard);
- writer.close();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- schem.saveFromBytes(outputStream.toByteArray(), true);
- }
-}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java
deleted file mode 100644
index 74b3b44..0000000
--- a/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-public class PersonalKitCreator_14 {
- private PersonalKitCreator_14(){}
-
- public static boolean hasAttributeModifier(ItemStack stack){
- return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
- }
-
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
- }
-}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java
deleted file mode 100644
index 3b03787..0000000
--- a/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.block.data.BlockData;
-import org.bukkit.block.data.Waterlogged;
-
-class WaterRemover_14 {
- private WaterRemover_14(){}
-
- static boolean isWater(Block block){
- if(block.getType() == Material.WATER)
- return true;
-
- BlockData data = block.getBlockData();
- if(!(data instanceof Waterlogged))
- return false;
-
- return ((Waterlogged) data).isWaterlogged();
- }
-
- static boolean removeWater(Block block){
- if(block.getType() == Material.WATER){
- block.setType(Material.AIR);
- return true;
- }
-
- BlockData data = block.getBlockData();
- if(!(data instanceof Waterlogged))
- return false;
-
- Waterlogged waterlogged = (Waterlogged) data;
- if(waterlogged.isWaterlogged()){
- block.setType(Material.AIR);
- return true;
- }
-
- return false;
- }
-}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java
new file mode 100644
index 0000000..78101c3
--- /dev/null
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java
@@ -0,0 +1,79 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import de.steamwar.fightsystem.Config;
+import net.minecraft.server.v1_14_R1.*;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
+
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+public class BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper {
+ @Override
+ public int blockToId(Block block) {
+ return net.minecraft.server.v1_14_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_14_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 Set getHiddenBlockIds() {
+ Set hiddenBlockIds = new HashSet<>();
+ for(String tag : Config.HiddenBlocks){
+ for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
+ hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data));
+ }
+ }
+
+ if(Config.HiddenBlocks.contains("water")){
+ Fluid water = FluidTypes.WATER.a(false);
+ for(IBlockData data : net.minecraft.server.v1_14_R1.Block.REGISTRY_ID){
+ if(data.p() == water){
+ hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data));
+ }
+ }
+ }
+
+ return hiddenBlockIds;
+ }
+
+ @Override
+ public int getObfuscateWith() {
+ return net.minecraft.server.v1_14_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
+ }
+
+ @Override
+ public Object getPose(boolean sneaking) {
+ return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING;
+ }
+}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java
similarity index 69%
rename from FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java
rename to FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java
index f2b9412..14c5989 100644
--- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,31 +15,36 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
+import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_14_R1.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_14 {
- private FightWorld_14(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
- if (!isPaper) {
+ if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@@ -51,11 +56,21 @@ public class FightWorld_14 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java
new file mode 100644
index 0000000..dc3ed90
--- /dev/null
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java
@@ -0,0 +1,111 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import org.bukkit.DyeColor;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.block.data.Waterlogged;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.BlockDataMeta;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.Objects;
+
+public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper {
+ @Override
+ public DyeColor getSilver() {
+ return DyeColor.LIGHT_GRAY;
+ }
+
+ @Override
+ public boolean isWater(Block block) {
+ if(block.getType() == Material.WATER)
+ return true;
+
+ BlockData data = block.getBlockData();
+ if(!(data instanceof Waterlogged))
+ return false;
+
+ return ((Waterlogged) data).isWaterlogged();
+ }
+
+ @Override
+ public boolean removeWater(Block block) {
+ if(block.getType() == Material.WATER){
+ block.setType(Material.AIR);
+ return true;
+ }
+
+ BlockData data = block.getBlockData();
+ if(!(data instanceof Waterlogged))
+ return false;
+
+ Waterlogged waterlogged = (Waterlogged) data;
+ if(waterlogged.isWaterlogged()){
+ block.setType(Material.AIR);
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean containsBlockMeta(ItemMeta meta) {
+ return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData();
+ }
+
+ @Override
+ public boolean hasAttributeModifier(ItemStack stack) {
+ return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
+ }
+
+ @Override
+ public Material onBreak(Material type) {
+ switch(type){
+ case REDSTONE_WIRE:
+ return Material.REDSTONE;
+ case PISTON_HEAD:
+ return Material.PISTON;
+ case ICE:
+ return Material.AIR;
+ default:
+ return type;
+ }
+ }
+
+ @Override
+ public boolean doRecord(BlockPhysicsEvent e) {
+ return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
+ }
+
+ @Override
+ public void forceLoadChunk(World world, int cX, int cZ) {
+ world.setChunkForceLoaded(cX, cZ, true);
+ }
+
+ @Override
+ public boolean checkPistonMoving(Block block) {
+ return block.getType() == Material.MOVING_PISTON;
+ }
+}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java
similarity index 78%
rename from FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java
rename to FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java
index 0195bdc..77fde1d 100644
--- a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,16 +15,15 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.countdown;
+package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
-class Countdown_14 {
- private Countdown_14(){}
-
- static Sound getSound(SWSound sound){
+public class SWSound14 implements SWSound.ISWSound {
+ @Override
+ public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
@@ -32,6 +31,8 @@ class Countdown_14 {
return Sound.BLOCK_NOTE_BLOCK_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_BLOCK_PLING;
+ case ENTITY_GENERIC_EXPLODE:
+ return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java
new file mode 100644
index 0000000..78100f1
--- /dev/null
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java
@@ -0,0 +1,199 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.events.PacketAdapter;
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.events.PacketEvent;
+import com.comphenix.protocol.reflect.StructureModifier;
+import com.comphenix.protocol.wrappers.nbt.NbtBase;
+import com.comphenix.protocol.wrappers.nbt.NbtCompound;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.bukkit.entity.Player;
+
+import java.nio.ByteBuffer;
+import java.nio.LongBuffer;
+import java.util.List;
+import java.util.Set;
+
+import static de.steamwar.fightsystem.utils.TechHider.bypass;
+
+public class TechHider14 extends PacketAdapter {
+
+ private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds();
+ private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith();
+
+ public TechHider14(){
+ super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
+ }
+
+ @Override
+ public void onPacketSending(PacketEvent e) {
+ PacketContainer packet = e.getPacket();
+ StructureModifier ints = packet.getIntegers();
+
+ int chunkX = ints.read(0);
+ int chunkZ = ints.read(1);
+ Player p = e.getPlayer();
+ if(bypass(p, chunkX, chunkZ))
+ return;
+
+ packet = packet.shallowClone();
+ e.setPacket(packet);
+ StructureModifier>> list = packet.getListNbtModifier();
+ List> nmsTags = list.read(0);
+ boolean changed = false;
+ for(int i = nmsTags.size() - 1; i >= 0; i--){
+ NbtBase> nbtBase = nmsTags.get(i);
+ assert nbtBase instanceof NbtCompound;
+ NbtCompound nbt = (NbtCompound) nbtBase;
+ if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
+ nmsTags.remove(i);
+ changed = true;
+ }
+ }
+ if(changed){
+ list.write(0, nmsTags);
+ }
+
+ changed = false;
+ StructureModifier byteArray = packet.getByteArrays();
+ int primaryBitMask = ints.read(2);
+ byte[] data = byteArray.read(0);
+ ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
+ int i = 0;
+
+ //int chunkY = 0;
+ while(primaryBitMask != 0){
+ while((primaryBitMask & 1) == 0){
+ primaryBitMask >>= 1;
+ //chunkY++;
+ }
+
+ buffer.writeBytes(data, i, 2); // Block count
+ i += 2;
+ byte bitsPerBlock = data[i++];
+ buffer.writeByte(bitsPerBlock);
+
+ if(bitsPerBlock < 9){
+ int paletteLength = TechHider.readVarInt(data, i);
+ int paletteLengthLength = TechHider.readVarIntLength(data, i);
+ buffer.writeBytes(data, i, paletteLengthLength);
+ i += paletteLengthLength;
+ for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
+ int blockId = TechHider.readVarInt(data, i);
+ int actPaletteLength = TechHider.readVarIntLength(data, i);
+
+ if(hiddenBlockIds.contains(blockId)){
+ buffer.writeBytes(TechHider.writeVarInt(obfuscateWith));
+ changed = true;
+ }else{
+ buffer.writeBytes(data, i, actPaletteLength);
+ }
+ i += actPaletteLength;
+ }
+
+ //We modify only the chunk palette for performance reasons
+ int dataArrayLength = TechHider.readVarInt(data, i);
+ int dataArrayLengthLength = TechHider.readVarIntLength(data, i);
+ buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
+ i += dataArrayLengthLength;
+ i += dataArrayLength * 8;
+ }else{
+ //Full Chunk/no palette, so the chunk has to be crawled through
+ int dataArrayLength = TechHider.readVarInt(data, i);
+ int dataArrayLengthLength = TechHider.readVarIntLength(data, i);
+ buffer.writeBytes(data, i, dataArrayLengthLength);
+ i += dataArrayLengthLength;
+
+ ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8);
+ VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer());
+
+ for(int pos = 0; pos < 4096; pos++){
+ if(hiddenBlockIds.contains(values.get(pos))){
+ changed = true;
+ values.set(pos, obfuscateWith);
+ }
+ }
+
+ for(long l : values.backing)
+ buffer.writeLong(l);
+
+ i += dataArrayLength * 8;
+ }
+
+ primaryBitMask >>= 1;
+ //chunkY++;
+ }
+ buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why
+
+ if(changed){
+ data = new byte[buffer.readableBytes()];
+ buffer.readBytes(data);
+ byteArray.write(0, data);
+ }
+ }
+
+ private static final class VariableValueArray {
+ private final long[] backing;
+ private final int bitsPerValue;
+ private final long valueMask;
+
+ public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
+ this.bitsPerValue = bitsPerEntry;
+ this.backing = new long[dataArrayLength];
+ buffer.get(backing);
+ this.valueMask = (1L << this.bitsPerValue) - 1;
+ }
+
+ public int get(int index) {
+ index *= bitsPerValue;
+ int i0 = index >> 6;
+ int i1 = index & 0x3f;
+
+ long value = backing[i0] >>> i1;
+
+ // The value is divided over two long values
+ if (i1 + bitsPerValue > 64) {
+ value |= backing[++i0] << 64 - i1;
+ }
+
+ return (int) (value & valueMask);
+ }
+
+ public void set(int index, int value) {
+ index *= bitsPerValue;
+ int i0 = index >> 6;
+ int i1 = index & 0x3f;
+
+ backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
+ int i2 = i1 + bitsPerValue;
+ // The value is divided over two long values
+ if (i2 > 64) {
+ i0++;
+ backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1;
+ }
+ }
+ }
+}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java
deleted file mode 100644
index 39546ec..0000000
--- a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.utils;
-
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.events.PacketAdapter;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.events.PacketEvent;
-import com.comphenix.protocol.reflect.StructureModifier;
-import com.comphenix.protocol.wrappers.nbt.NbtBase;
-import com.comphenix.protocol.wrappers.nbt.NbtCompound;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.IFightSystem;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.UnpooledByteBufAllocator;
-import net.minecraft.server.v1_14_R1.*;
-import org.bukkit.entity.Player;
-
-import java.nio.ByteBuffer;
-import java.nio.LongBuffer;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static de.steamwar.fightsystem.utils.ITechHider.bypass;
-
-public class TechHider_14 {
- private TechHider_14(){}
-
- static Set getHiddenBlockIds() {
- Set hiddenBlockIds = new HashSet<>();
- for(String tag : Config.HiddenBlocks){
- for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
- hiddenBlockIds.add(Block.getCombinedId(data));
- }
- }
-
- if(Config.HiddenBlocks.contains("water")){
- Fluid water = FluidTypes.WATER.a(false);
- for(IBlockData data : Block.REGISTRY_ID){
- if(data.p() == water){
- hiddenBlockIds.add(Block.getCombinedId(data));
- }
- }
- }
-
- return hiddenBlockIds;
- }
-
- static int getObfuscateWith() {
- return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
- }
-
- static PacketAdapter chunkHider(Set hiddenBlockIds, int obfuscateWith){
- /*
- * Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
- * */
- return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
- @Override
- public void onPacketSending(PacketEvent e) {
- PacketContainer packet = e.getPacket();
- StructureModifier ints = packet.getIntegers();
-
- int chunkX = ints.read(0);
- int chunkZ = ints.read(1);
- Player p = e.getPlayer();
- if(bypass(p, chunkX, chunkZ))
- return;
-
- packet = packet.shallowClone();
- e.setPacket(packet);
- StructureModifier>> list = packet.getListNbtModifier();
- List> nmsTags = list.read(0);
- boolean changed = false;
- for(int i = nmsTags.size() - 1; i >= 0; i--){
- NbtBase> nbtBase = nmsTags.get(i);
- assert nbtBase instanceof NbtCompound;
- NbtCompound nbt = (NbtCompound) nbtBase;
- if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
- nmsTags.remove(i);
- changed = true;
- }
- }
- if(changed){
- list.write(0, nmsTags);
- }
-
- changed = false;
- StructureModifier byteArray = packet.getByteArrays();
- int primaryBitMask = ints.read(2);
- byte[] data = byteArray.read(0);
- ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
- int i = 0;
-
- int chunkY = 0;
- while(primaryBitMask != 0){
- while((primaryBitMask & 1) == 0){
- primaryBitMask >>= 1;
- chunkY++;
- }
-
- buffer.writeBytes(data, i, 2); // Block count
- i += 2;
- byte bitsPerBlock = data[i++];
- buffer.writeByte(bitsPerBlock);
-
- if(bitsPerBlock < 9){
- int paletteLength = ITechHider.readVarInt(data, i);
- int paletteLengthLength = ITechHider.readVarIntLength(data, i);
- buffer.writeBytes(data, i, paletteLengthLength);
- i += paletteLengthLength;
- for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
- int blockId = ITechHider.readVarInt(data, i);
- int actPaletteLength = ITechHider.readVarIntLength(data, i);
-
- if(hiddenBlockIds.contains(blockId)){
- buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith));
- changed = true;
- }else{
- buffer.writeBytes(data, i, actPaletteLength);
- }
- i += actPaletteLength;
- }
-
- //We modify only the chunk palette for performance reasons
- int dataArrayLength = ITechHider.readVarInt(data, i);
- int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
- buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
- i += dataArrayLengthLength;
- i += dataArrayLength * 8;
- }else{
- //Full Chunk/no palette, so the chunk has to be crawled through
- int dataArrayLength = ITechHider.readVarInt(data, i);
- int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
- buffer.writeBytes(data, i, dataArrayLengthLength);
- i += dataArrayLengthLength;
-
- ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8);
- VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer());
-
- for(int pos = 0; pos < 4096; pos++){
- if(hiddenBlockIds.contains(values.get(pos))){
- changed = true;
- values.set(pos, obfuscateWith);
- }
- }
-
- for(long l : values.backing)
- buffer.writeLong(l);
-
- i += dataArrayLength * 8;
- }
-
- primaryBitMask >>= 1;
- chunkY++;
- }
- buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why
-
- if(changed){
- data = new byte[buffer.readableBytes()];
- buffer.readBytes(data);
- byteArray.write(0, data);
- }
- }
- };
- }
-
- private static final class VariableValueArray {
- private final long[] backing;
- private final int bitsPerValue;
- private final long valueMask;
-
- public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
- this.bitsPerValue = bitsPerEntry;
- this.backing = new long[dataArrayLength];
- buffer.get(backing);
- this.valueMask = (1L << this.bitsPerValue) - 1;
- }
-
- public int get(int index) {
- index *= bitsPerValue;
- int i0 = index >> 6;
- int i1 = index & 0x3f;
-
- long value = backing[i0] >>> i1;
-
- // The value is divided over two long values
- if (i1 + bitsPerValue > 64) {
- value |= backing[++i0] << 64 - i1;
- }
-
- return (int) (value & valueMask);
- }
-
- public void set(int index, int value) {
- index *= bitsPerValue;
- int i0 = index >> 6;
- int i1 = index & 0x3f;
-
- backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
- int i2 = i1 + bitsPerValue;
- // The value is divided over two long values
- if (i2 > 64) {
- i0++;
- backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1;
- }
- }
- }
-}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java
new file mode 100644
index 0000000..a91d4eb
--- /dev/null
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java
@@ -0,0 +1,148 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.sk89q.jnbt.NBTInputStream;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
+import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
+import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
+import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
+import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
+import com.sk89q.worldedit.function.operation.Operations;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+import com.sk89q.worldedit.regions.CuboidRegion;
+import com.sk89q.worldedit.session.ClipboardHolder;
+import com.sk89q.worldedit.world.World;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockTypes;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.sql.Schematic;
+import org.bukkit.Bukkit;
+import org.bukkit.DyeColor;
+import org.bukkit.Location;
+import org.bukkit.util.Vector;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.zip.GZIPInputStream;
+
+public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
+
+ private static final Map colorBlocks = new HashMap<>();
+
+ static {
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder");
+ colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet");
+ }
+
+ @Override
+ public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
+ BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
+ Map replaceMap = new HashMap<>();
+ colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock()));
+
+ for(int x = 0; x < clipboard.getDimensions().getX(); x++){
+ for(int y = 0; y < clipboard.getDimensions().getY(); y++){
+ for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
+ BlockVector3 pos = minimum.add(x, y, z);
+ BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
+ if(replacement != null)
+ clipboard.setBlock(pos, replacement);
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getWaterDepth(Clipboard clipboard) {
+ BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1);
+ int depth = 0;
+ while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
+ depth++;
+ it = it.add(0, 1, 0);
+ }
+ return depth;
+ }
+
+ @Override
+ public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) {
+ EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
+ ClipboardHolder ch = new ClipboardHolder(clipboard);
+ ch.setTransform(aT);
+ Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
+ aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
+ ).toBlockPoint()).build());
+ e.flushSession();
+ }
+
+ @Override
+ public Vector getDimensions(Clipboard clipboard) {
+ BlockVector3 dims = clipboard.getDimensions();
+ return new Vector(dims.getX(), dims.getY(), dims.getZ());
+ }
+
+ @Override
+ public Clipboard loadChar(String charName) throws IOException {
+ return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read();
+ }
+
+ @Override
+ public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
+ World w = new BukkitWorld(Bukkit.getWorlds().get(0));
+ BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
+ CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
+ BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
+
+ ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
+ WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
+ );
+ forwardExtentCopy.setCopyingEntities(false);
+ Operations.complete(forwardExtentCopy);
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ try {
+ ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
+ writer.write(clipboard);
+ writer.close();
+ } catch (IOException e) {
+ throw new SecurityException(e);
+ }
+
+ schem.saveFromBytes(outputStream.toByteArray(), true);
+ }
+}
diff --git a/FightSystem_15/pom.xml b/FightSystem_15/pom.xml
index 8858c54..7aa938d 100644
--- a/FightSystem_15/pom.xml
+++ b/FightSystem_15/pom.xml
@@ -17,19 +17,6 @@
FightSystem_15
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
@@ -47,12 +34,7 @@
steamwar
- FightSystem_API
- 1.0
-
-
- steamwar
- FightSystem_14
+ FightSystem_Core
1.0
diff --git a/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java b/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java
deleted file mode 100644
index eec0197..0000000
--- a/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class PersonalKitCreator_15 {
-
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
- }
-}
diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java
new file mode 100644
index 0000000..c88034f
--- /dev/null
+++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java
@@ -0,0 +1,79 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import de.steamwar.fightsystem.Config;
+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.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+public class BlockIdWrapper15 implements BlockIdWrapper.IBlockIdWrapper {
+ @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 Set getHiddenBlockIds() {
+ Set hiddenBlockIds = new HashSet<>();
+ for(String tag : Config.HiddenBlocks){
+ for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
+ hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data));
+ }
+ }
+
+ if(Config.HiddenBlocks.contains("water")){
+ Fluid water = FluidTypes.WATER.a(false);
+ for(IBlockData data : net.minecraft.server.v1_15_R1.Block.REGISTRY_ID){
+ if(data.getFluid() == water){
+ hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data));
+ }
+ }
+ }
+
+ return hiddenBlockIds;
+ }
+
+ @Override
+ public int getObfuscateWith() {
+ return net.minecraft.server.v1_15_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
+ }
+
+ @Override
+ public Object getPose(boolean sneaking) {
+ return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING;
+ }
+}
diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java
similarity index 69%
rename from FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java
rename to FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java
index b4c53b8..8d55c47 100644
--- a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java
+++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,31 +15,36 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
+import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_15_R1.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_15 {
- private FightWorld_15(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
- if (!isPaper) {
+ if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@@ -51,11 +56,21 @@ public class FightWorld_15 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java
deleted file mode 100644
index e5d5e03..0000000
--- a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.utils;
-
-import de.steamwar.fightsystem.Config;
-import net.minecraft.server.v1_15_R1.*;
-
-import java.util.HashSet;
-import java.util.Set;
-
-class TechHider_15 {
- private TechHider_15(){}
-
- static Set getHiddenBlockIds() {
- Set hiddenBlockIds = new HashSet<>();
- for(String tag : Config.HiddenBlocks){
- for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
- hiddenBlockIds.add(Block.getCombinedId(data));
- }
- }
-
- if(Config.HiddenBlocks.contains("water")){
- Fluid water = FluidTypes.WATER.a(false);
- for(IBlockData data : Block.REGISTRY_ID){
- if(data.getFluid() == water){
- hiddenBlockIds.add(Block.getCombinedId(data));
- }
- }
- }
-
- return hiddenBlockIds;
- }
-
- static int getObfuscateWith() {
- return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
- }
-}
diff --git a/FightSystem_8/pom.xml b/FightSystem_8/pom.xml
index 2fabd6f..3ec6b70 100644
--- a/FightSystem_8/pom.xml
+++ b/FightSystem_8/pom.xml
@@ -17,19 +17,6 @@
FightSystem_8
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
@@ -40,7 +27,7 @@
steamwar
- FightSystem_API
+ FightSystem_Core
1.0
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java
deleted file mode 100644
index 2894747..0000000
--- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.fight;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.session.ClipboardHolder;
-import com.sk89q.worldedit.world.World;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.utils.Region;
-import de.steamwar.sql.NoClipboardException;
-import de.steamwar.sql.Schematic;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.scoreboard.Team;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-public class FightTeam_8 {
- private FightTeam_8(){}
-
- @SuppressWarnings("deprecation")
- private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
-
- @SuppressWarnings("deprecation")
- private static final BaseBlock WOOL = new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE);
- @SuppressWarnings("deprecation")
- private static final BaseBlock GLASS = new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE);
- @SuppressWarnings("deprecation")
- private static final BaseBlock CLAY = new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE);
- @SuppressWarnings("deprecation")
- private static final BaseBlock GLASS_PANE = new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE);
- @SuppressWarnings("deprecation")
- private static final BaseBlock CARPET = new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE);
-
- static void setTeamColor(Team team, ChatColor color){
- team.setPrefix("§" + color.getChar());
- }
-
- static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
- Vector minimum = clipboard.getRegion().getMinimumPoint();
- BaseBlock wool = new BaseBlock(WOOL.getId(), c.getWoolData());
- BaseBlock clay = new BaseBlock(CLAY.getId(), c.getWoolData());
- BaseBlock glass = new BaseBlock(GLASS.getId(), c.getWoolData());
- BaseBlock glassPane = new BaseBlock(GLASS_PANE.getId(), c.getWoolData());
- BaseBlock carpet = new BaseBlock(CARPET.getId(), c.getWoolData());
-
- for(int x = 0; x < clipboard.getDimensions().getX(); x++){
- for(int y = 0; y < clipboard.getDimensions().getY(); y++){
- for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
- Vector pos = minimum.add(x, y, z);
- BaseBlock block = clipboard.getBlock(pos);
- if(block.equals(WOOL)){
- clipboard.setBlock(pos, wool);
- }else if(block.equals(CLAY)){
- clipboard.setBlock(pos, clay);
- }else if(block.equals(GLASS)){
- clipboard.setBlock(pos, glass);
- }else if(block.equals(GLASS_PANE)){
- clipboard.setBlock(pos, glassPane);
- }else if(block.equals(CARPET)){
- clipboard.setBlock(pos, carpet);
- }
- }
- }
- }
- }
-
- static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) throws NoClipboardException {
- World w = new BukkitWorld(Bukkit.getWorlds().get(0));
- Vector dimensions = clipboard.getDimensions();
- Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
- Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
- AffineTransform aT = new AffineTransform();
- if(rotate){
- aT = aT.rotateY(180);
- v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
- }else{
- v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
- }
-
- if(Config.WaterDepth != 0){
- Vector it = clipboard.getMinimumPoint();
- int depth = 0;
- while(!clipboard.getBlock(it).isAir()){
- depth++;
- it = it.setY(it.getY()+1);
- }
- v = v.add(0, Config.WaterDepth - depth, 0);
- }
-
- EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
- ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
- ch.setTransform(aT);
- Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
- e.flushQueue();
- }
-
- public static boolean checkPistonMoving(Block block){
- return block.getType() == Material.PISTON_MOVING_PIECE;
- }
-
- public static void saveSchem(Schematic schem, Region region, int minY) {
- World w = new BukkitWorld(Bukkit.getWorlds().get(0));
- Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
- CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
- BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
- EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
-
- ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
- try{
- Operations.complete(forwardExtentCopy);
- }catch(WorldEditException e){
- throw new IllegalStateException(e);
- }
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try {
- ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
- writer.write(clipboard, w.getWorldData());
- writer.close();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- schem.saveFromBytes(outputStream.toByteArray(), false);
- }
-}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java b/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java
deleted file mode 100644
index 4f7bab9..0000000
--- a/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-
-public class WaterRemover_8 {
- private WaterRemover_8(){}
-
- static boolean isWater(Block block){
- Material type = block.getType();
- return type == Material.WATER || type == Material.STATIONARY_WATER;
- }
-
- static boolean removeWater(Block block){
- if(isWater(block)){
- block.setType(Material.AIR);
- return true;
- }
- return false;
- }
-}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java
similarity index 63%
rename from FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java
rename to FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java
index ccf7943..723e2f0 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,20 +15,31 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
import java.util.HashSet;
import java.util.Set;
-class TechHider_8 {
- private TechHider_8(){}
+public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
+ @Override
+ public int blockToId(Block block) {
+ return block.getTypeId() << 4 + block.getData();
+ }
- static Set getHiddenBlockIds() {
+ @Override
+ public void setBlock(World world, int x, int y, int z, int blockState) {
+ world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
+ }
+
+ @Override
+ public Set getHiddenBlockIds() {
Set hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
@@ -36,7 +47,13 @@ class TechHider_8 {
return hiddenBlockIds;
}
- static int getObfuscateWith() {
+ @Override
+ public int getObfuscateWith() {
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
}
+
+ @Override
+ public Object getPose(boolean sneaking) {
+ return null;
+ }
}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java
new file mode 100644
index 0000000..50ff9ea
--- /dev/null
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java
@@ -0,0 +1,89 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.protocol.wrappers.EnumWrappers;
+import de.steamwar.fightsystem.listener.Recording;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import net.md_5.bungee.api.chat.BaseComponent;
+import net.minecraft.server.v1_8_R3.ChatComponentText;
+import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
+import org.bukkit.Effect;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.scoreboard.Team;
+
+public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
+ @Override
+ public boolean bowInHand(EnumWrappers.Hand hand, Player p) {
+ return p.getInventory().getItemInHand().getType() == Material.BOW;
+ }
+
+ @Override
+ public void toActionbar(Player player, BaseComponent... components) {
+ PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ @Override
+ public void toChat(Player player, BaseComponent... components) {
+ PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)0);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ @Override
+ public void setAttackSpeed(Player player) {
+ // nothing to do
+ }
+
+ @Override
+ public void setNametagVisibility(Team team) {
+ //nothing to do
+ }
+
+ @Override
+ public Listener newDenyArrowPickupListener() {
+ return new Listener() {};
+ }
+
+ @Override
+ public Listener newDenyHandSwapListener() {
+ return new Listener() {};
+ }
+
+ @Override
+ public void recordHandItems(Player player) {
+ GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInHand()), "MAINHAND");
+ }
+
+ @Override
+ public Listener newHandSwapRecorder() {
+ return new Listener() {};
+ }
+
+ @Override
+ public void spawnParticle(World world, String particleName, double x, double y, double z) {
+ world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1);
+ }
+}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java
similarity index 68%
rename from FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java
rename to FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java
index 9d25c29..3eb750e 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,9 +15,9 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import net.minecraft.server.v1_8_R3.Chunk;
@@ -26,15 +26,20 @@ import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_8 {
- private FightWorld_8(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
+ ((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true;
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
@@ -47,11 +52,21 @@ public class FightWorld_8 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java
new file mode 100644
index 0000000..5782625
--- /dev/null
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java
@@ -0,0 +1,89 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import org.bukkit.DyeColor;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
+ @Override
+ public DyeColor getSilver() {
+ return DyeColor.SILVER;
+ }
+
+ @Override
+ public boolean isWater(Block block) {
+ Material type = block.getType();
+ return type == Material.WATER || type == Material.STATIONARY_WATER;
+ }
+
+ @Override
+ public boolean removeWater(Block block) {
+ if(isWater(block)){
+ block.setType(Material.AIR);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean containsBlockMeta(ItemMeta meta) {
+ return false;
+ }
+
+ @Override
+ public boolean hasAttributeModifier(ItemStack stack) {
+ return false;
+ }
+
+ @Override
+ public Material onBreak(Material type) {
+ switch(type){
+ case REDSTONE_WIRE:
+ return Material.REDSTONE;
+ case PISTON_EXTENSION:
+ return Material.PISTON_BASE;
+ case ICE:
+ return Material.AIR;
+ default:
+ return type;
+ }
+ }
+
+ @Override
+ public boolean doRecord(BlockPhysicsEvent e) {
+ return e.getChangedType() != e.getBlock().getType();
+ }
+
+ @Override
+ public void forceLoadChunk(World world, int cX, int cZ) {
+ // not possible in 1.8
+ }
+
+ @Override
+ public boolean checkPistonMoving(Block block) {
+ return block.getType() == Material.PISTON_MOVING_PIECE;
+ }
+}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java
similarity index 79%
rename from FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java
rename to FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java
index 4224ecd..d4a6e21 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,16 +15,15 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.countdown;
+package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
-class Countdown_8 {
- private Countdown_8(){}
-
- static Sound getSound(SWSound sound){
+public class SWSound8 implements SWSound.ISWSound {
+ @Override
+ public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.WITHER_DEATH;
@@ -32,6 +31,8 @@ class Countdown_8 {
return Sound.NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.NOTE_PLING;
+ case ENTITY_GENERIC_EXPLODE:
+ return Sound.EXPLODE;
default:
return null;
}
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java
similarity index 60%
rename from FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java
rename to FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java
index af749e0..3a8e4f6 100644
--- a/FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,16 +15,23 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.utils;
-import org.bukkit.DyeColor;
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.events.PacketAdapter;
+import com.comphenix.protocol.events.PacketEvent;
+import de.steamwar.fightsystem.FightSystem;
-class ColorConverter_14 {
- private ColorConverter_14(){}
+public class TechHider8 extends PacketAdapter {
- static DyeColor getSilver(){
- return DyeColor.LIGHT_GRAY;
+ public TechHider8() {
+ super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
+ }
+
+ @Override
+ public void onPacketSending(PacketEvent e) {
+ // no implementation availible
}
}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java
new file mode 100644
index 0000000..dfe0228
--- /dev/null
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java
@@ -0,0 +1,43 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.Sound;
+import org.bukkit.entity.Arrow;
+import org.bukkit.scoreboard.Team;
+
+public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
+ @Override
+ public void setTeamColor(Team team, ChatColor color) {
+ team.setPrefix("§" + color.getChar());
+ }
+
+ @Override
+ public boolean isInBlock(Arrow e) {
+ return false;
+ }
+
+ @Override
+ public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
+ location.getWorld().playSound(location, sound, volume, pitch);
+ }
+}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java
new file mode 100644
index 0000000..2264f2b
--- /dev/null
+++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java
@@ -0,0 +1,146 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.sk89q.jnbt.NBTInputStream;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.blocks.BaseBlock;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
+import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
+import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
+import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
+import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
+import com.sk89q.worldedit.function.operation.Operations;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+import com.sk89q.worldedit.regions.CuboidRegion;
+import com.sk89q.worldedit.session.ClipboardHolder;
+import com.sk89q.worldedit.world.World;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.sql.Schematic;
+import org.bukkit.Bukkit;
+import org.bukkit.DyeColor;
+import org.bukkit.Location;
+import org.bukkit.Material;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.zip.GZIPInputStream;
+
+@SuppressWarnings("deprecation")
+public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
+
+ protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
+ protected static final Set colorBlocks = new HashSet<>();
+
+ static {
+ colorBlocks.add(new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE));
+ colorBlocks.add(new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE));
+ colorBlocks.add(new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE));
+ colorBlocks.add(new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE));
+ colorBlocks.add(new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE));
+ }
+
+ @Override
+ public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
+ Vector minimum = clipboard.getRegion().getMinimumPoint();
+ Map replaceMap = new HashMap<>();
+ colorBlocks.forEach(base -> replaceMap.put(base, new BaseBlock(base.getId(), c.getWoolData())));
+
+ for(int x = 0; x < clipboard.getDimensions().getX(); x++){
+ for(int y = 0; y < clipboard.getDimensions().getY(); y++){
+ for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
+ Vector pos = minimum.add(x, y, z);
+ BaseBlock replacement = replaceMap.get(clipboard.getBlock(pos));
+ if(replacement != null)
+ clipboard.setBlock(pos, replacement);
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getWaterDepth(Clipboard clipboard) {
+ Vector it = clipboard.getMinimumPoint().add(0, 0, 1);
+ int depth = 0;
+ while(!clipboard.getBlock(it).isAir()) {
+ depth++;
+ it = it.add(0, 1, 0);
+ }
+ return depth;
+ }
+
+ @Override
+ public void pasteClipboard(Clipboard clipboard, Location position, org.bukkit.util.Vector offset, AffineTransform aT) {
+ World w = new BukkitWorld(position.getWorld());
+ EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
+ ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
+ ch.setTransform(aT);
+ Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add(
+ aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()))
+ ).toBlockPoint()).build());
+ e.flushQueue();
+ }
+
+ @Override
+ public org.bukkit.util.Vector getDimensions(Clipboard clipboard) {
+ Vector dims = clipboard.getDimensions();
+ return new org.bukkit.util.Vector(dims.getBlockX(), dims.getBlockY(), dims.getBlockZ());
+ }
+
+ @Override
+ public Clipboard loadChar(String charName) throws IOException {
+ return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData());
+ }
+
+ @Override
+ public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
+ World w = new BukkitWorld(Bukkit.getWorlds().get(0));
+ Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
+ CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
+ BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
+
+ ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
+ WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
+ );
+ Operations.complete(forwardExtentCopy);
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ try {
+ ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
+ writer.write(clipboard, w.getWorldData());
+ writer.close();
+ } catch (IOException e) {
+ throw new SecurityException(e);
+ }
+
+ schem.saveFromBytes(outputStream.toByteArray(), false);
+ }
+}
diff --git a/FightSystem_9/pom.xml b/FightSystem_9/pom.xml
index 769e6c2..8cf317c 100644
--- a/FightSystem_9/pom.xml
+++ b/FightSystem_9/pom.xml
@@ -17,28 +17,10 @@
FightSystem_9
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
- FightSystem_8
- 1.0
-
-
- steamwar
- FightSystem_API
+ FightSystem_Core
1.0
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java
deleted file mode 100644
index f90fa8a..0000000
--- a/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import net.md_5.bungee.api.ChatMessageType;
-import net.md_5.bungee.api.chat.BaseComponent;
-import org.bukkit.attribute.Attribute;
-import org.bukkit.attribute.AttributeInstance;
-import org.bukkit.entity.Player;
-
-class BasicListener_9 {
- private BasicListener_9(){}
-
- static void toActionbar(Player player, BaseComponent... components){
- player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
- }
-
- static void toChat(Player player, BaseComponent... components){
- player.spigot().sendMessage(ChatMessageType.CHAT, components);
- }
-
- static void setAttackSpeed(Player player){
- AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
- attribute.setBaseValue(16);
- }
-}
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java
deleted file mode 100644
index 956e46a..0000000
--- a/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class PersonalKitCreator_9 {
-
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
- }
-}
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java
deleted file mode 100644
index 19a547a..0000000
--- a/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerPickupArrowEvent;
-
-class PickupArrowListener_9 implements Listener {
-
- @EventHandler
- public void onArrowPickup(PlayerPickupArrowEvent e){
- e.setCancelled(true);
- }
-}
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java
new file mode 100644
index 0000000..12312f9
--- /dev/null
+++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java
@@ -0,0 +1,113 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.protocol.wrappers.EnumWrappers;
+import de.steamwar.fightsystem.listener.Recording;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import net.md_5.bungee.api.ChatMessageType;
+import net.md_5.bungee.api.chat.BaseComponent;
+import org.bukkit.Material;
+import org.bukkit.Particle;
+import org.bukkit.World;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.attribute.AttributeInstance;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+import org.bukkit.event.player.PlayerSwapHandItemsEvent;
+import org.bukkit.scoreboard.Team;
+
+public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
+ @Override
+ public boolean bowInHand(EnumWrappers.Hand hand, Player p) {
+ return (hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) ||
+ (hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW);
+ }
+
+ @Override
+ public void toActionbar(Player player, BaseComponent... components) {
+ player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
+ }
+
+ @Override
+ public void toChat(Player player, BaseComponent... components) {
+ player.spigot().sendMessage(ChatMessageType.CHAT, components);
+ }
+
+ @Override
+ public void setAttackSpeed(Player player) {
+ AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
+ attribute.setBaseValue(16);
+ }
+
+ @Override
+ public void setNametagVisibility(Team team) {
+ team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
+ }
+
+ @Override
+ public Listener newDenyArrowPickupListener() {
+ return new Listener() {
+ @EventHandler
+ public void onArrowPickup(PlayerPickupArrowEvent e){
+ e.setCancelled(true);
+ }
+ };
+ }
+
+ @Override
+ public Listener newDenyHandSwapListener() {
+ return new Listener() {
+ @EventHandler
+ public void onSwapItems(PlayerSwapHandItemsEvent event) {
+ event.setCancelled(true);
+ }
+ };
+ }
+
+ @Override
+ public void recordHandItems(Player player) {
+ GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
+ GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
+ }
+
+ @Override
+ public Listener newHandSwapRecorder() {
+ return new Listener() {
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onItemSwap(PlayerSwapHandItemsEvent e){
+ if(Recording.isNotSent(e.getPlayer()))
+ return;
+
+ Player player = e.getPlayer();
+ GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND");
+ GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND");
+ }
+ };
+ }
+
+ @Override
+ public void spawnParticle(World world, String particleName, double x, double y, double z) {
+ world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
+ }
+}
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java
similarity index 69%
rename from FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java
rename to FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java
index f35afb4..bb13e18 100644
--- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java
+++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,24 +15,29 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
+import de.steamwar.fightsystem.fight.FightWorld;
import net.minecraft.server.v1_9_R2.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
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.CraftPlayer;
+import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
-public class FightWorld_9 {
- private FightWorld_9(){}
+import java.util.HashSet;
+import java.util.Set;
- static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
+public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper {
+ @Override
+ public void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@@ -40,7 +45,7 @@ public class FightWorld_9 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
- if (!isPaper) {
+ if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@@ -50,11 +55,21 @@ public class FightWorld_9 {
}
}
- public static void sendResourcePack(Player player, String pack, String sha1){
+ @Override
+ public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
- public static float headRotation(Entity e){
+ @Override
+ public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
+
+ @Override
+ public boolean hasItems(ItemStack stack) {
+ Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
+ keys.remove("Enchantments");
+ keys.remove("Damage");
+ return !keys.isEmpty();
+ }
}
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java
similarity index 78%
rename from FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java
rename to FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java
index 71e345a..3589c09 100644
--- a/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java
+++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,16 +15,15 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.countdown;
+package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
-class Countdown_9 {
- private Countdown_9(){}
-
- static Sound getSound(SWSound sound){
+public class SWSound9 implements SWSound.ISWSound {
+ @Override
+ public Sound getSound(SWSound sound){
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
@@ -32,6 +31,8 @@ class Countdown_9 {
return Sound.BLOCK_NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_PLING;
+ case ENTITY_GENERIC_EXPLODE:
+ return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java
deleted file mode 100644
index 5725381..0000000
--- a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem;
-
-import de.steamwar.sql.EventFight;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-public class IFightSystem {
- private IFightSystem(){}
-
- private static Plugin plugin;
- private static EventFight eventFight;
- private static Player eventLeiter;
-
- public static void init(Plugin plugin){
- IFightSystem.plugin = plugin;
- }
- static void setEventFight(EventFight ef){
- eventFight = ef;
- }
- static void setEventLeiter(Player el){
- eventLeiter = el;
- }
-
- public static Plugin getPlugin(){
- return plugin;
- }
- public static EventFight getEventFight(){
- return eventFight;
- }
- public static Player getEventLeiter(){
- return eventLeiter;
- }
-}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java b/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java
deleted file mode 100644
index dc15ff5..0000000
--- a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.fight;
-
-import org.bukkit.entity.Player;
-
-public class IFight {
- private IFight(){}
-
- private static IFightTeam redTeam;
- private static IFightTeam blueTeam;
-
- static void init(IFightTeam redTeam, IFightTeam blueTeam){
- IFight.redTeam = redTeam;
- IFight.blueTeam = blueTeam;
- }
-
- public static IFightTeam getPlayerTeam(Player player) {
- if(redTeam.isPlayerInTeam(player))
- return redTeam;
- if(blueTeam.isPlayerInTeam(player))
- return blueTeam;
- return null;
- }
-}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java b/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java
deleted file mode 100644
index 919fa23..0000000
--- a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.fight;
-
-import org.bukkit.entity.Player;
-
-public interface IFightTeam {
-
- boolean isBlue();
- boolean isPlayerInTeam(Player player);
- boolean canPlayerEntern(Player player);
-}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java
deleted file mode 100644
index ade4044..0000000
--- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.utils;
-
-import com.google.common.primitives.Bytes;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.IFightSystem;
-import de.steamwar.fightsystem.fight.IFight;
-import de.steamwar.fightsystem.fight.IFightTeam;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ITechHider {
- private ITechHider (){}
-
- static boolean bypass(Player p, int chunkX, int chunkZ){
- if(p == IFightSystem.getEventLeiter())
- return true;
-
- IFightTeam ft = IFight.getPlayerTeam(p);
- if(ft == null){
- return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
- }else if(ft.isBlue()){
- return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
- }else{
- return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
- }
- }
-
- public static int posToChunk(int c){
- int chunk = c / 16;
- if(c<0)
- chunk--;
- return chunk;
- }
-
- static int readVarInt(byte[] array, int startPos) {
- int numRead = 0;
- int result = 0;
- byte read;
- do {
- read = array[startPos + numRead];
- int value = (read & 0b01111111);
- result |= (value << (7 * numRead));
-
- numRead++;
- if (numRead > 5) {
- break;
- }
- } while ((read & 0b10000000) != 0);
-
- return result;
- }
-
- static int readVarIntLength(byte[] array, int startPos) {
- int numRead = 0;
- byte read;
- do {
- read = array[startPos + numRead];
- numRead++;
- if (numRead > 5) {
- break;
- }
- } while ((read & 0b10000000) != 0);
-
- return numRead;
- }
-
- static byte[] writeVarInt(int value) {
- List buffer = new ArrayList<>(5);
- do {
- byte temp = (byte)(value & 0b01111111);
- // Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
- value >>>= 7;
- if (value != 0) {
- temp |= 0b10000000;
- }
- buffer.add(temp);
- } while (value != 0);
- return Bytes.toArray(buffer);
- }
-}
diff --git a/FightSystem_API/pom.xml b/FightSystem_Core/pom.xml
similarity index 60%
rename from FightSystem_API/pom.xml
rename to FightSystem_Core/pom.xml
index a2faacd..a9f81ed 100644
--- a/FightSystem_API/pom.xml
+++ b/FightSystem_Core/pom.xml
@@ -14,29 +14,23 @@
${project.basedir}/..
- FightSystem_API
+ FightSystem_Core
1.0
-
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
-
-
steamwar
Spigot
- 1.12
+ 1.15
system
- ${main.basedir}/lib/Spigot-1.12.jar
+ ${main.basedir}/lib/Spigot-1.15.jar
+
+
+ steamwar
+ WorldEdit
+ 1.0
+ system
+ ${main.basedir}/lib/WorldEdit-1.12.jar
\ No newline at end of file
diff --git a/FightSystem_Main/src/config.yml b/FightSystem_Core/src/config.yml
similarity index 100%
rename from FightSystem_Main/src/config.yml
rename to FightSystem_Core/src/config.yml
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java
similarity index 82%
rename from FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java
index 70edcef..bcfb258 100644
--- a/FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem;
@@ -29,7 +29,8 @@ public enum ArenaMode {
EVENT,
TEST,
CHECK,
- PREPARE;
+ PREPARE,
+ REPLAY;
public static final Set All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
@@ -39,14 +40,16 @@ public enum ArenaMode {
public static final Set Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
public static final Set Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
public static final Set Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
+ public static final Set Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY));
+ public static final Set AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
+ public static final Set Replayable = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
public static final Set AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
public static final Set AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
public static final Set AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
- public static final Set VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT)));
- public static final Set RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
- public static final Set Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
- public static final Set Fight = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, EVENT));
+ public static final Set VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT, REPLAY)));
+ public static final Set RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT, REPLAY));
+ public static final Set Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, REPLAY));
public static final Set SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
- public static final Set NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
+ public static final Set NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java
similarity index 93%
rename from FightSystem_API/src/de/steamwar/fightsystem/Config.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/Config.java
index 9156fba..72f436b 100644
--- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem;
@@ -67,7 +67,7 @@ public class Config {
public static final Location TeamRedSpawn;
public static final Location SpecSpawn;
- private static final int BlueToRedX;
+ public static final int BlueToRedX;
private static final int BlueToRedY;
public static final int BlueToRedZ;
@@ -124,7 +124,7 @@ public class Config {
public static final int EventTeamRedID;
public static final boolean BothTeamsPublic;
public static final int MaximumTeamMembers;
- public static final boolean SpectateSystem;
+ public static final boolean LiveReplay;
//check parameter
public static final int CheckSchemID;
@@ -132,19 +132,21 @@ public class Config {
public static final ArenaMode mode;
- //live recorder parameter
+ //replay system parameter
public static final String spectateIP = "127.0.0.1";
public static final int spectatePort = 2222;
+ public static final int ReplayID;
static{
- if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
- IFightSystem.getPlugin().saveDefaultConfig();
+ String configFile = System.getProperty("config", "config.yml");
+ if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
+ FightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
Bukkit.shutdown();
}
- FileConfiguration config = YamlConfiguration.loadConfiguration(new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")));
+ FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
- File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
+ File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if(!worldConfigFile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
Bukkit.shutdown();
@@ -178,7 +180,7 @@ public class Config {
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
- SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
+ SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.SchematicType")));
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
boolean rotate = config.getBoolean("Schematic.Rotate");
PasteAligned = config.getBoolean("Schematic.PasteAligned");
@@ -331,7 +333,7 @@ public class Config {
EventTeamRedID = team2.getTeamId();
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
- IFightSystem.setEventFight(eventFight);
+ FightSystem.setEventFight(eventFight);
Event event = Event.get(eventFight.getEventID());
if(BothTeamsPublic) {
@@ -341,7 +343,7 @@ public class Config {
OnlyPublicSchematics = event.publicSchemsOnly();
MaximumTeamMembers = event.getMaximumTeamMembers();
}
- SpectateSystem = event.spectateSystem();
+ LiveReplay = event.spectateSystem();
}else{
//No event
TeamRedColor = config.getString("Output.TeamRedPrefix");
@@ -353,7 +355,7 @@ public class Config {
EventTeamRedID = 0;
BothTeamsPublic = true;
MaximumTeamMembers = Integer.MAX_VALUE;
- SpectateSystem = false;
+ LiveReplay = false;
}
String blueLeader = System.getProperty("blueLeader", null);
@@ -370,6 +372,7 @@ public class Config {
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
+ ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
if(Ranked){
mode = ArenaMode.RANKED;
@@ -381,6 +384,8 @@ public class Config {
mode = ArenaMode.EVENT;
}else if(EventKampfID == -1){
mode = ArenaMode.TEST;
+ }else if(ReplayID != 0){
+ mode = ArenaMode.REPLAY;
}else{
mode = ArenaMode.NORMAL;
}
@@ -389,7 +394,10 @@ public class Config {
public static boolean test(){
return ArenaMode.Test.contains(mode);
}
- public static boolean recording(){
- return mode == ArenaMode.EVENT;
+ public static boolean replayserver(){
+ return ReplayID == -1;
+ }
+ public static boolean blueNegZ(){
+ return BlueToRedZ > 0;
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
similarity index 76%
rename from FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
index be6b5b5..58a1296 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java
@@ -20,7 +20,6 @@
package de.steamwar.fightsystem;
import de.steamwar.core.CommandRemover;
-import de.steamwar.core.Core;
import de.steamwar.fightsystem.commands.*;
import de.steamwar.fightsystem.countdown.*;
import de.steamwar.fightsystem.event.HellsBells;
@@ -29,8 +28,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
-import de.steamwar.fightsystem.record.RecordSystem;
-import de.steamwar.fightsystem.record.Recorder;
+import de.steamwar.fightsystem.record.*;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.EnterHandler;
@@ -49,18 +47,16 @@ public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§eArena§8» ";
private static FightSystem plugin;
+ private static EventFight eventFight;
+ private static Player eventLeiter;
@Override
public void onLoad() {
plugin = this;
- IFightSystem.init(this);
}
@Override
public void onEnable() {
- Fight.init();
- RecordSystem.init();
-
new EntityDamage();
new WaterRemover();
new Permanent();
@@ -75,7 +71,7 @@ public class FightSystem extends JavaPlugin {
new DenyWorldInteraction();
new EventJoin();
new Recording();
- // new ResourcePack();
+ //new ResourcePack();
new Check();
new Shutdown();
new SetupQuit();
@@ -86,8 +82,7 @@ public class FightSystem extends JavaPlugin {
new PersonalKitCreator();
new FightScoreboard();
new ArrowStopper();
- if(Core.getVersion() > 8)
- new ArrowPickup();
+ new ArrowPickup();
new EnterHandler();
new TechHider();
@@ -108,7 +103,6 @@ public class FightSystem extends JavaPlugin {
new RankedPlayerLeftWincondition();
new WinconditionPercentTimeout();
- //noinspection InstantiationOfUtilityClass
new HellsBells();
new NoPlayersOnlineCountdown();
@@ -128,12 +122,16 @@ public class FightSystem extends JavaPlugin {
new AkCommand();
new LeaderCommand();
new LockschemCommand();
+ new ReplayCommand();
new StateCommand();
new SkipCommand();
new WinCommand();
- new OneShotStateDependent(ArenaMode.All, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
- new OneShotStateDependent(ArenaMode.All, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
+ new LiveRecorder();
+ new FileRecorder();
+
+ new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightSystem.broadcast("§aDer Kampf beginnt!"));
+ new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightSystem.broadcast("§aArena freigegeben!"));
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
try {
@@ -148,17 +146,16 @@ public class FightSystem extends JavaPlugin {
}else if(Config.mode == ArenaMode.CHECK){
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
}else if(Config.mode == ArenaMode.PREPARE) {
- if(Config.BlueRotate){
- Fight.getRedTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
- }else{
- Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
- }
+ Fight.getUnrotated().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
+ }else if(Config.mode == ArenaMode.REPLAY) {
+ FightWorld.forceLoad();
+ FileSource.startReplay();
}
}
@Override
public void onDisable() {
- Recorder.closeAll();
+ GlobalRecorder.getInstance().close();
}
public static void setPreLeaderState() {
@@ -185,38 +182,44 @@ public class FightSystem extends JavaPlugin {
}
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
+ if(!PacketProcessor.isReplaying()){
+ if(winFightTeam != null) {
+ FightSystem.broadcast("§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
+ } else {
+ FightSystem.broadcast("§aKein Team hat gewonnen!");
+ }
+ }
+
FightState.setFightState(FightState.SPECTATE);
- if(winFightTeam != null) {
- Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
- } else {
- Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
- }
+ if(!Config.test() && !PacketProcessor.isReplaying()){
+ if(Config.mode == ArenaMode.EVENT) {
+ if (winFightTeam == null)
+ getEventFight().setErgebnis(0);
+ else if (winFightTeam.isBlue())
+ getEventFight().setErgebnis(1);
+ else
+ getEventFight().setErgebnis(2);
+ }
- if(Config.mode == ArenaMode.EVENT) {
- if (winFightTeam == null)
- getEventFight().setErgebnis(0);
- else if (winFightTeam.isBlue())
- getEventFight().setErgebnis(1);
- else
- getEventFight().setErgebnis(2);
- }
-
- if(!Config.test()){
FightStatistics.saveStats(winFightTeam, windescription);
}
}
public static void setEventLeiter(Player el){
- IFightSystem.setEventLeiter(el);
+ eventLeiter = el;
}
public static Player getEventLeiter(){
- return IFightSystem.getEventLeiter();
+ return eventLeiter;
}
public static EventFight getEventFight(){
- return IFightSystem.getEventFight();
+ return eventFight;
+ }
+
+ public static void setEventFight(EventFight ef){
+ eventFight = ef;
}
public static FightSystem getPlugin() {
@@ -225,11 +228,16 @@ public class FightSystem extends JavaPlugin {
public static void shutdown(String reason){
if(reason != null)
- Bukkit.broadcastMessage(reason);
+ FightSystem.broadcast(reason);
//Staggered kick to prevent lobby overloading
kickNext();
}
+ public static void broadcast(String message) {
+ Bukkit.broadcastMessage(PREFIX + message);
+ GlobalRecorder.getInstance().systemChat(PREFIX + message);
+ }
+
private static void kickNext(){
if(Bukkit.getOnlinePlayers().isEmpty()){
Bukkit.shutdown();
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java
new file mode 100644
index 0000000..d44a1e6
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java
@@ -0,0 +1,41 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem;
+
+import de.steamwar.core.Core;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class VersionDependent {
+ private VersionDependent() {}
+
+ public static T getVersionImpl(String className){
+ for(int version = Core.getVersion(); version >= 8; version--) {
+ try {
+ return (T) Class.forName(className + version).getDeclaredConstructor().newInstance();
+ } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ throw new SecurityException("Could not load version dependent class", e);
+ } catch (ClassNotFoundException e) {
+ // try next version
+ }
+ }
+ throw new SecurityException("Unable to find version dependent implementation for " + className);
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AcceptCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AcceptCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/AcceptCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/AcceptCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/CommandInjector.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/CommandInjector.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/DeclineCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/DeclineCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/DeclineCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/DeclineCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/GamemodeCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/InviteCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/InviteCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/KitCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java
similarity index 94%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/KitCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java
index 585262b..000711d 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/KitCommand.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java
@@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class KitCommand implements CommandExecutor {
public KitCommand() {
- new StateDependentCommand(ArenaMode.All, FightState.Setup, "kit", this);
+ new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaderCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaderCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaveCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java
similarity index 94%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaveCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java
index 7e3327e..902f779 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaveCommand.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java
@@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class LeaveCommand implements CommandExecutor {
public LeaveCommand() {
- new StateDependentCommand(ArenaMode.All, FightState.Setup, "leave", this);
+ new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java
similarity index 96%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java
index 6070d12..27dbb97 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java
@@ -37,7 +37,7 @@ import org.bukkit.entity.Player;
public class LockschemCommand implements CommandExecutor {
public LockschemCommand() {
- new StateDependentCommand(ArenaMode.All, FightState.All, "lockschem", this);
+ new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/ReadyCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/ReadyCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/RemoveCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/RemoveCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java
new file mode 100644
index 0000000..170705b
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java
@@ -0,0 +1,70 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.commands;
+
+import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.record.FileRecorder;
+import de.steamwar.fightsystem.record.FileSource;
+import de.steamwar.fightsystem.states.FightState;
+import de.steamwar.fightsystem.states.StateDependentCommand;
+import de.steamwar.sql.SteamwarUser;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.io.IOException;
+
+public class ReplayCommand implements CommandExecutor {
+
+ public ReplayCommand() {
+ new StateDependentCommand(ArenaMode.Replayable, FightState.All, "replay", this);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if(!(sender instanceof Player)) {
+ return false;
+ }
+ Player player = (Player) sender;
+
+ if(!Config.test()){
+ SteamwarUser user = SteamwarUser.get(player.getUniqueId());
+ if(!user.getUserGroup().isTeamGroup()){
+ sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar.");
+ return false;
+ }
+ }
+
+ if(!FileRecorder.getFile().exists()){
+ sender.sendMessage(FightSystem.PREFIX + "§cKein Replay vorhanden.");
+ return false;
+ }
+
+ try {
+ new FileSource(FileRecorder.getFile());
+ } catch (IOException e) {
+ sender.sendMessage(FightSystem.PREFIX + "§cDas Replay konnte nicht gestartet werden.");
+ }
+ return false;
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/SkipCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/SkipCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/StateCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/StateCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java
similarity index 81%
rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java
index 90aafa6..d2a18ea 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java
@@ -5,7 +5,6 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
-import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -35,13 +34,13 @@ public class WinCommand implements CommandExecutor {
}
if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
+ FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee");
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
+ FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee");
}else if(args[0].equalsIgnoreCase("tie")){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
+ FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(null, "Referee");
}
return false;
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java
similarity index 82%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java
index 35ef83b..565bd04 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java
@@ -19,11 +19,11 @@
package de.steamwar.fightsystem.countdown;
-import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.listener.BasicListener;
-import de.steamwar.fightsystem.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import de.steamwar.fightsystem.utils.SWSound;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@@ -39,7 +39,7 @@ public abstract class Countdown {
private static final List currentCountdowns = new ArrayList<>();
private final int totalTime;
- private final Sound sound;
+ protected final Sound sound;
private final boolean level;
protected int time;
@@ -48,31 +48,13 @@ public abstract class Countdown {
public abstract String countdownCounting();
public abstract void countdownFinished();
- public Countdown(int time, SWSound sound, boolean level) {
+ protected Countdown(int time, SWSound sound, boolean level) {
this.totalTime = time;
this.time = time;
- this.sound = getSound(sound);
+ this.sound = sound != null ? sound.getSound() : null;
this.level = level;
}
- public static Sound getSound(SWSound sound){
- if(sound == null)
- return null;
-
- switch (Core.getVersion()){
- case 8:
- return Countdown_8.getSound(sound);
- case 9:
- case 10:
- case 12:
- return Countdown_9.getSound(sound);
- case 14:
- case 15:
- default:
- return Countdown_14.getSound(sound);
- }
- }
-
public void enable() {
time = totalTime;
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
@@ -104,11 +86,11 @@ public abstract class Countdown {
countdown.show();
}
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
+ FightSystem.broadcast("§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
}
private void broadcast(String message){
- RecordSystem.actionBar(message);
+ GlobalRecorder.getInstance().actionBar(message);
BaseComponent[] msg = TextComponent.fromLegacyText(message);
for(Player p : Bukkit.getOnlinePlayers())
BasicListener.toActionbar(p, msg);
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
similarity index 89%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
index f08a8fe..ec78cc6 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
@@ -23,6 +23,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.listener.BasicListener;
+import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.utils.TechHider;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@@ -59,19 +60,19 @@ public class EnternCountdown extends Countdown {
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
- player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
+ player.playSound(player.getLocation(), sound, 100.0F, 1.0F);
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting()));
break;
case 1:
- player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
+ player.playSound(player.getLocation(), sound, 100.0F, 1.0F);
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting()));
chunkPos = TechHider.prepareChunkReload(player, false);
break;
case 0:
- player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 2.0F);
+ player.playSound(player.getLocation(), sound, 100.0F, 2.0F);
disable();
countdownFinished();
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java
similarity index 97%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java
index abaa890..a26a14d 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java
@@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
+import de.steamwar.fightsystem.utils.SWSound;
public class EventSpectateCountdown extends Countdown {
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java
index fc8ed95..5ab54d7 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java
@@ -34,8 +34,8 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener {
public NoPlayersOnlineCountdown() {
super(Config.NoPlayerOnlineDuration, null, false);
- new StateDependentListener(ArenaMode.All, FightState.PreLeaderSetup, this);
- new StateDependentCountdown(ArenaMode.All, FightState.PreLeaderSetup, this){
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
+ new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this){
@Override
public void enable() {
if(Bukkit.getOnlinePlayers().isEmpty())
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java
index 4506ace..9a5dac4 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java
@@ -24,12 +24,13 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
+import de.steamwar.fightsystem.utils.SWSound;
public class PreRunningCountdown extends Countdown {
public PreRunningCountdown() {
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
- new StateDependentCountdown(ArenaMode.All, FightState.PreRunning, this);
+ new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java
index e0084a4..f9c007a 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java
@@ -24,12 +24,13 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
+import de.steamwar.fightsystem.utils.SWSound;
public class PreSchemCountdown extends Countdown {
public PreSchemCountdown() {
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
- new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
+ new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java
similarity index 96%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java
index 5946085..92ac120 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java
@@ -22,9 +22,9 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
+import de.steamwar.fightsystem.utils.SWSound;
public class SpectateOverCountdown extends Countdown {
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java
similarity index 92%
rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java
index 96a6cab..30659cb 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java
@@ -19,9 +19,9 @@
package de.steamwar.fightsystem.countdown;
-import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.Config;
-import org.bukkit.Bukkit;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.utils.SWSound;
public class TimeOverCountdown extends Countdown {
@@ -39,7 +39,7 @@ public class TimeOverCountdown extends Countdown {
@Override
public void countdownFinished() {
- Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
+ FightSystem.broadcast("§aZeit abgelaufen!");
timeOver.run();
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java
similarity index 96%
rename from FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java
index 1d3d87f..a19a3ae 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.event;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
-import de.steamwar.fightsystem.countdown.SWSound;
+import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.winconditions.Winconditions;
@@ -63,10 +63,10 @@ public class HellsBells {
public void startCountdown() {
if (current == State.PRE) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + (startMessages.get(random.nextInt(startMessages.size()))));
+ FightSystem.broadcast(startMessages.get(random.nextInt(startMessages.size())));
current = current.getNext();
} else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + (stateSwapMessages.get(random.nextInt(stateSwapMessages.size()))));
+ FightSystem.broadcast(stateSwapMessages.get(random.nextInt(stateSwapMessages.size())));
currentDrops = 0;
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java
similarity index 73%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java
index dd56cf4..c00c9ba 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java
@@ -28,10 +28,11 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.sql.Schematic;
-import org.bukkit.*;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Sound;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
@@ -45,10 +46,6 @@ public class Fight {
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 blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
- public static void init(){
- IFight.init(redTeam, blueTeam);
- }
-
public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
@@ -90,8 +87,12 @@ public class Fight {
return blueTeam;
}
+ public static FightTeam getUnrotated() {
+ return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
+ }
+
public static void playSound(Sound sound, float volume, float pitch) {
- RecordSystem.soundAtPlayer(sound.name(), volume, pitch);
+ GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
//volume: max. 100, pitch: max. 2
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
}
@@ -121,16 +122,7 @@ public class Fight {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!player.isOnline())
return;
- PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
- gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
- List playerInfoActions = new ArrayList<>();
- playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(player.getDisplayName())));
- gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
- try {
- ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
- } catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
- }
+ pseudoSpectator(player, true);
}, 2);
}else if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
@@ -142,6 +134,19 @@ public class Fight {
}
}
+ public static void pseudoSpectator(Player player, boolean enable) {
+ PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
+ gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
+ List playerInfoActions = new ArrayList<>();
+ playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, enable ? EnumWrappers.NativeGameMode.CREATIVE : EnumWrappers.NativeGameMode.SPECTATOR, WrappedChatComponent.fromText(player.getDisplayName())));
+ gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
+ try {
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
+ } catch (InvocationTargetException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
+ }
+ }
+
public static int getMaxRank(){
/* MaxRank of 0 is Pubonly*/
if(Config.OnlyPublicSchematics){
@@ -157,22 +162,6 @@ public class Fight {
return 1000;
}
- if(Config.RanksEnabled)
- return Math.min(schemRank(redTeam.getLeader()), schemRank(blueTeam.getLeader()));
- else if(Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() ||
- Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty())
- return 0;
- else
- return 1;
- }
-
- private static int schemRank(FightPlayer fightPlayer){
- int rank = 1;
- List schematics = Schematic.getSchemsOfType(fightPlayer.getPlayer().getUniqueId(), Config.SchematicType);
- for(Schematic schem : schematics){
- if(schem.getRank() > rank)
- rank = schem.getRank();
- }
- return rank;
+ return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java
similarity index 54%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java
index 172a8b7..159317d 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java
@@ -21,28 +21,21 @@ package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import de.steamwar.core.VersionedRunnable;
+import com.sk89q.worldedit.math.transform.AffineTransform;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.IFightSystem;
-import de.steamwar.fightsystem.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.fightsystem.utils.Region;
-import de.steamwar.sql.NoClipboardException;
+import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.Schematic;
-import org.bukkit.Bukkit;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.block.Block;
-import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.*;
-import org.bukkit.event.inventory.InventoryMoveItemEvent;
+import org.bukkit.util.Vector;
import java.io.IOException;
import java.util.List;
@@ -66,7 +59,7 @@ public class FightSchematic extends StateDependent {
register();
}
- public boolean hasSchematic(){
+ public boolean hasSchematic() {
return clipboard != null;
}
@@ -79,11 +72,16 @@ public class FightSchematic extends StateDependent {
try {
clipboard = schem.load();
} catch (IOException e) {
- team.broadcast(FightSystem.PREFIX + "§cKonnte die Schematic nicht laden!");
- Bukkit.getLogger().log(Level.SEVERE, "Couldn't load Schematic " + schem.getSchemName(), e);
+ team.broadcast(FightSystem.PREFIX + "§cSchematic konnte nicht geladen werden!");
+ Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName());
}
}
+ public void setSchematic(int schemId, Clipboard clipboard) {
+ this.schematic = schemId;
+ this.clipboard = clipboard;
+ }
+
public void reset(){
schematic = 0;
clipboard = null;
@@ -109,47 +107,39 @@ public class FightSchematic extends StateDependent {
}
if(team.isBlue())
- RecordSystem.blueSchem(schematic);
+ GlobalRecorder.getInstance().blueSchem(schematic);
else
- RecordSystem.redSchem(schematic);
+ GlobalRecorder.getInstance().redSchem(schematic);
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
}
+ private void replaceTeamColor(Clipboard clipboard) {
+ try {
+ WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK);
+ } catch (WorldEditException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not recolor schematic", e);
+ }
+ }
+
private void paste(){
FreezeWorld freezer = new FreezeWorld();
- DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK;
- try {
- VersionedRunnable.call(new VersionedRunnable(() -> {
- try {
- FightTeam_8.replaceTeamColor(clipboard, c);
- FightTeam_8.pasteSchematic(clipboard, region, rotate);
- } catch (NoClipboardException | WorldEditException ex) {
- throw new SecurityException("Error pasting schematic", ex);
- }
- }, 8), new VersionedRunnable(() -> {
- try {
- FightTeam_12.replaceTeamColor(clipboard, c);
- FightTeam_8.pasteSchematic(clipboard, region, rotate);
- } catch (NoClipboardException | WorldEditException ex) {
- throw new SecurityException("Error pasting schematic", ex);
- }
- }, 12), new VersionedRunnable(() -> {
- try {
- FightTeam_14.replaceTeamColor(clipboard, c);
- FightTeam_14.pasteSchematic(clipboard, region, rotate);
- } catch (NoClipboardException | WorldEditException ex) {
- throw new SecurityException("Error pasting schematic", ex);
- }
- }, 14));
- } catch (SecurityException securityException) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
- Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState);
- throw securityException;
- }
+ replaceTeamColor(clipboard);
- Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> HandlerList.unregisterAll(freezer), 3);
+ Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
+ WorldeditWrapper.impl.pasteClipboard(
+ clipboard,
+ new Location(Bukkit.getWorlds().get(0), region.centerX(), region.getMinY(), region.centerZ()),
+ new Vector(
+ -(Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX() : dims.getBlockX())/2.0,
+ Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
+ -(Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ() : dims.getBlockZ())/2.0
+ ).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
+ new AffineTransform().rotateY(rotate ? 180 : 0)
+ );
+
+ Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
}
@@ -169,6 +159,41 @@ public class FightSchematic extends StateDependent {
HandlerList.unregisterAll(freezer);
}
+ public void pasteTeamName(){
+ char[] chars = team.getName().toCharArray();
+ Clipboard[] characters = new Clipboard[chars.length];
+
+ int length = 0;
+ int[] offsets = new int[chars.length];
+
+ for(int i = 0; i < chars.length; i++){
+ Clipboard character;
+ try {
+ character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
+ try {
+ character = WorldeditWrapper.impl.loadChar("");
+ }catch (IOException ex) {
+ throw new SecurityException("Could not load text", ex);
+ }
+ }
+
+ replaceTeamColor(character);
+
+ characters[i] = character;
+ offsets[i] = length;
+ length += WorldeditWrapper.impl.getDimensions(character).getBlockX() + 1; // 1 is the distance between characters
+ }
+
+ length -= 1;
+ AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
+ Location base = new Location(Bukkit.getWorlds().get(0), region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
+ 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);
+ }
+ }
+
private void replaceSync(Material target, Material replacement){
World world = Bukkit.getWorlds().get(0);
@@ -178,45 +203,4 @@ public class FightSchematic extends StateDependent {
block.setType(replacement);
});
}
-
- private static class FreezeWorld implements Listener {
- private FreezeWorld(){
- Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
- }
-
- @EventHandler
- public void onBlockPhysicsEvent(BlockPhysicsEvent e){
- e.setCancelled(true);
- }
-
- @EventHandler
- public void onPistonExtend(BlockPistonExtendEvent e){
- e.setCancelled(true);
- }
-
- @EventHandler
- public void onPistonRetract(BlockPistonRetractEvent e){
- e.setCancelled(true);
- }
-
- @EventHandler
- public void onBlockGrow(BlockGrowEvent e){
- e.setCancelled(true);
- }
-
- @EventHandler
- public void onRedstoneEvent(BlockRedstoneEvent e){
- e.setNewCurrent(e.getOldCurrent());
- }
-
- @EventHandler
- public void onBlockDispense(BlockDispenseEvent e){
- e.setCancelled(true);
- }
-
- @EventHandler
- public void onInventoryMoveEvent(InventoryMoveItemEvent e){
- e.setCancelled(true);
- }
- }
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
similarity index 87%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
index f2a477f..be1f4b5 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
@@ -19,21 +19,18 @@
package de.steamwar.fightsystem.fight;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.comms.packets.TablistNamePacket;
-import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
-import de.steamwar.fightsystem.listener.BasicListener;
-import de.steamwar.fightsystem.listener.PersonalKitCreator;
-import de.steamwar.fightsystem.record.RecordSystem;
-import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.listener.FightScoreboard;
+import de.steamwar.fightsystem.listener.PersonalKitCreator;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
-import de.steamwar.fightsystem.utils.ItemBuilder;
-import de.steamwar.fightsystem.utils.Region;
-import de.steamwar.fightsystem.utils.TechHider;
+import de.steamwar.fightsystem.utils.*;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
@@ -47,16 +44,18 @@ import org.bukkit.scoreboard.Team;
import java.util.*;
-public class FightTeam implements IFightTeam{
+public class FightTeam {
private UUID designatedLeader;
private FightPlayer leader;
+ private int schemRank;
+
private final Map players = new HashMap<>();
private final Set invited = new HashSet<>();
- private final String name;
- private final String prefix;
- private final ChatColor color;
+ private String name;
+ private String prefix;
+ private ChatColor color;
private final FightSchematic schematic;
private final Team team;
private final boolean blue;
@@ -72,28 +71,34 @@ public class FightTeam implements IFightTeam{
this.spawn = spawn;
this.schemRegion = schemRegion;
this.extendRegion = extendRegion;
- this.name = name;
- this.prefix = prefix;
+ this.schemRank = 0;
this.ready = false;
this.skip = false;
this.blue = blue;
this.designatedLeader = designatedLeader;
- this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
+ setPrefixAndName(prefix, name);
this.schematic = new FightSchematic(this, rotate);
new KitLoader();
new SpectateHandler();
- if(FightScoreboard.getScoreboard().getTeam(name) == null)
- team = FightScoreboard.getScoreboard().registerNewTeam(name);
+ if(FightScoreboard.getBukkit().getTeam(name) == null)
+ team = FightScoreboard.getBukkit().registerNewTeam(name);
else
- team = FightScoreboard.getScoreboard().getTeam(name);
+ team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
- setTeamColor(team, color);
+ WorldOfColorWrapper.impl.setTeamColor(team, color);
+ BountifulWrapper.impl.setNametagVisibility(team);
//noinspection deprecation
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
team.setAllowFriendlyFire(false);
}
+ public void setPrefixAndName(String prefix, String name){
+ this.name = name;
+ this.prefix = prefix;
+ this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
+ }
+
public UUID getDesignatedLeader(){
return designatedLeader;
}
@@ -110,6 +115,10 @@ public class FightTeam implements IFightTeam{
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
}
+ public int getSchemRank() {
+ return schemRank;
+ }
+
public void teleportToSpawn(){
players.forEach((player, fp) -> player.teleport(spawn));
}
@@ -126,12 +135,10 @@ public class FightTeam implements IFightTeam{
return true;
}
- @Override
public boolean isPlayerInTeam(Player player) {
return players.containsKey(player);
}
- @Override
public boolean canPlayerEntern(Player player) {
return getFightPlayer(player).canEntern();
}
@@ -166,7 +173,7 @@ public class FightTeam implements IFightTeam{
playerSet.forEach(this::addMember);
- if(isLeaderless()){
+ if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
for(Player player : Bukkit.getOnlinePlayers()){
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
addMember(player);
@@ -191,14 +198,14 @@ public class FightTeam implements IFightTeam{
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
- BasicListener.setAttackSpeed(player);
+ BountifulWrapper.impl.setAttackSpeed(player);
player.teleport(spawn);
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
if(ArenaMode.NotOnBau.contains(Config.mode))
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
- RecordSystem.playerJoins(player);
+ GlobalRecorder.getInstance().playerJoins(player);
TechHider.reloadChunks(player, chunksToReload, false);
if(isLeaderless())
@@ -216,7 +223,7 @@ public class FightTeam implements IFightTeam{
if(fightPlayer.equals(leader))
setLeader(null);
- RecordSystem.entityDespawns(player);
+ GlobalRecorder.getInstance().entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
player.getInventory().clear();
@@ -232,7 +239,6 @@ public class FightTeam implements IFightTeam{
return leader == null;
}
- @Override
public boolean isBlue(){
return blue;
}
@@ -246,7 +252,7 @@ public class FightTeam implements IFightTeam{
this.leader = null;
if(!players.isEmpty()) {
setLeader(players.values().iterator().next());
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
+ FightSystem.broadcast("§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
}
@@ -259,6 +265,12 @@ public class FightTeam implements IFightTeam{
if(ready)
setReady(false);
+ Optional maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare);
+ if(Config.RanksEnabled)
+ schemRank = maxRank.orElse(1);
+ else
+ schemRank = maxRank.isPresent() ? 1 : 0;
+
if(!Config.PersonalKits)
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
@@ -295,23 +307,31 @@ public class FightTeam implements IFightTeam{
public void pasteSchem(Schematic schematic){
setSchem(schematic);
+ testPasteAction();
+ }
+ public void pasteSchem(int schemId, Clipboard clipboard){
+ this.schematic.setSchematic(schemId, clipboard);
+ testPasteAction();
+ }
+
+ private void testPasteAction(){
if(Config.test())
this.schematic.enable();
- else if(Fight.getOpposite(this).hasSchematic()){
+ else if(Fight.getOpposite(this).schematic.hasSchematic()){
FightSystem.setPostSchemState();
}
}
+ public void pasteTeamName(){
+ schematic.pasteTeamName();
+ }
+
public void setSchem(Schematic schematic){
this.schematic.setSchematic(schematic);
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
}
- public boolean hasSchematic(){
- return schematic.hasSchematic();
- }
-
public void setReady(boolean ready) {
Player l = leader.getPlayer();
@@ -385,20 +405,13 @@ public class FightTeam implements IFightTeam{
return currentHearts / maximumHearts;
}
- private void setTeamColor(Team team, ChatColor color){
- VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
- new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
- new VersionedRunnable(() -> FightTeam_12.setTeamColor(team, color), 12),
- new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14));
- }
-
public ChatColor getColor() {
return color;
}
private class KitLoader extends StateDependent {
private KitLoader() {
- super(ArenaMode.All, FightState.Ingame);
+ super(ArenaMode.AntiReplay, FightState.Ingame);
register();
}
@@ -423,7 +436,7 @@ public class FightTeam implements IFightTeam{
private class SpectateHandler extends StateDependent {
private SpectateHandler() {
- super(ArenaMode.All, FightState.Spectate);
+ super(ArenaMode.AntiReplay, FightState.Spectate);
register();
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java
similarity index 63%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java
index 342f1a4..b3cacb5 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java
@@ -19,11 +19,12 @@
package de.steamwar.fightsystem.fight;
-import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
+import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@@ -32,14 +33,13 @@ import org.bukkit.entity.EntityType;
public class FightWorld extends StateDependent {
- private static final boolean paper;
+ private static final World world = Bukkit.getWorlds().get(0);
+ private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
- static{
- paper = Bukkit.getVersion().contains("git-Paper");
+ public static boolean isPaper(){
+ return paper;
}
- private final World world = Bukkit.getWorlds().get(0);
-
public FightWorld() {
super(ArenaMode.Restartable, FightState.Schem);
register();
@@ -50,12 +50,20 @@ public class FightWorld extends StateDependent {
//unused
}
- public static boolean isPaper(){
- return paper;
- }
-
@Override
public void disable() {
+ resetWorld();
+ }
+
+ public static void forceLoad(){
+ Config.ArenaRegion.forEachChunk((cX, cZ) -> {
+ world.loadChunk(cX, cZ);
+ FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ);
+ });
+ world.setKeepSpawnInMemory(true);
+ }
+
+ public static void resetWorld(){
for(Entity entity : world.getEntities()){
if(entity.getType() != EntityType.PLAYER){
entity.remove();
@@ -64,17 +72,7 @@ public class FightWorld extends StateDependent {
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
assert backup != null;
- Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z, FightWorld.isPaper()));
+ Config.ArenaRegion.forEachChunk((x, z) -> CraftbukkitWrapper.impl.resetChunk(world, backup, x, z));
Bukkit.unloadWorld(backup, false);
}
-
- private void resetChunk(World backup, int x, int z, boolean isPaper){
- VersionedRunnable.call(
- new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z, isPaper), 8),
- new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z, isPaper), 9),
- new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z, isPaper), 10),
- new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z, isPaper), 12),
- new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z, isPaper), 14),
- new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z, isPaper), 15));
- }
-}
+}
\ No newline at end of file
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java
new file mode 100644
index 0000000..b94fc72
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java
@@ -0,0 +1,91 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.fight;
+
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.*;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+
+public class FreezeWorld implements Listener {
+
+ private final Listener denyHandSwap = BountifulWrapper.impl.newDenyHandSwapListener();
+
+ public FreezeWorld(){
+ Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
+ Bukkit.getPluginManager().registerEvents(denyHandSwap, FightSystem.getPlugin());
+ }
+
+ public void disable(){
+ HandlerList.unregisterAll(this);
+ HandlerList.unregisterAll(denyHandSwap);
+ }
+
+ @EventHandler
+ public void onBlockPhysicsEvent(BlockPhysicsEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onPistonExtend(BlockPistonExtendEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onPistonRetract(BlockPistonRetractEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onBlockGrow(BlockGrowEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onRedstoneEvent(BlockRedstoneEvent e){
+ e.setNewCurrent(e.getOldCurrent());
+ }
+
+ @EventHandler
+ public void onBlockDispense(BlockDispenseEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onInventoryMoveEvent(InventoryMoveItemEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onBlockExplosion(BlockExplodeEvent e){
+ e.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void handlePlayerInteract(PlayerInteractEvent event) {
+ event.setCancelled(true);
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java
similarity index 92%
rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java
index e37b47f..84df9b5 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java
@@ -19,13 +19,13 @@
package de.steamwar.fightsystem.fight;
-import de.steamwar.core.Core;
-import de.steamwar.core.VersionedCallable;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.Commands;
import de.steamwar.fightsystem.commands.GUI;
-import de.steamwar.fightsystem.listener.*;
+import de.steamwar.fightsystem.listener.PersonalKitCreator;
+import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.PersonalKit;
@@ -38,7 +38,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.BlockDataMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
@@ -188,21 +187,16 @@ public class Kit {
return true;
//Check for attribute modifiers
- if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){
+ if(FlatteningWrapper.impl.hasAttributeModifier(stack)){
return true;
}
if(stack.hasItemMeta()){
ItemMeta meta = stack.getItemMeta();
- if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
+ if(FlatteningWrapper.impl.containsBlockMeta(meta))
return true; //Blocks always upwards slabs etc.
- if(VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8),
- new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9),
- new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10),
- new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12),
- new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14),
- new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15)))
+ if(CraftbukkitWrapper.impl.hasItems(stack))
return true; //Blocks prefilled inventories
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java
similarity index 85%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java
index b8d4693..6839a3f 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java
@@ -19,16 +19,14 @@
package de.steamwar.fightsystem.listener;
-import de.steamwar.core.Core;
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() {
- if(Core.getVersion() > 8){
- new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9());
- }
+ new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java
similarity index 93%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java
index 35d8af1..1e286e9 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,13 +15,14 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
+import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -90,7 +91,11 @@ public class ArrowStopper {
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
boolean otherSide = teamFrom == overMid;
return otherSide ||
- entity.isInBlock() ||
+ WorldOfColorWrapper.impl.isInBlock(entity) ||
entity.getVelocity().equals(NULL_VECTOR);
}
+
+ public interface IArrowStopper {
+ boolean isInBlock(Arrow e);
+ }
}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java
similarity index 69%
rename from FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java
index 5cd86f6..f63dc1c 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java
@@ -19,17 +19,19 @@
package de.steamwar.fightsystem.listener;
+import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
-class BasicListener_8 {
- private BasicListener_8(){}
+public class BasicListener {
+ private BasicListener(){}
- static void toActionbar(Player player, BaseComponent... components){
- player.spigot().sendMessage(components);
+ public static boolean notFighting(Player p){
+ return Fight.getFightPlayer(p) == null;
}
- static void toChat(Player player, BaseComponent... components){
- player.spigot().sendMessage(components);
+ public static void toActionbar(Player player, BaseComponent... components){
+ BountifulWrapper.impl.toActionbar(player, components);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java
similarity index 92%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java
index 8e89799..21fdd77 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java
@@ -24,9 +24,10 @@ 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.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@@ -64,9 +65,9 @@ public class Chat implements Listener {
}
private void broadcastChat(String message) {
- RecordSystem.chat(message);
+ GlobalRecorder.getInstance().chat(message);
BaseComponent[] msg = TextComponent.fromLegacyText(message);
for(Player p : Bukkit.getOnlinePlayers())
- BasicListener.toChat(p, msg);
+ BountifulWrapper.impl.toChat(p, msg);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Check.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Check.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java
index 78b5d50..579d303 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java
@@ -19,10 +19,10 @@
package de.steamwar.fightsystem.listener;
-import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -40,11 +40,10 @@ public class DenyWorldInteraction implements Listener {
public DenyWorldInteraction() {
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
- if(Core.getVersion() > 9){
- Listener listener = new DenyWorldInteraction_10();
- new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
- new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
- }
+
+ Listener listener = BountifulWrapper.impl.newDenyHandSwapListener();
+ new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
+ new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
}
@EventHandler
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityDamage.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityDamage.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EventJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java
similarity index 98%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/EventJoin.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java
index 55195dc..dc3cca0 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EventJoin.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java
@@ -42,7 +42,7 @@ public class EventJoin implements Listener {
@EventHandler
public void playerLogin(PlayerLoginEvent event) {
- if(!Config.SpectateSystem)
+ if(!Config.LiveReplay)
return;
Player player = event.getPlayer();
@@ -89,7 +89,7 @@ public class EventJoin implements Listener {
FightSystem.setEventLeiter(player);
return;
}
- if(Config.SpectateSystem)
+ if(Config.LiveReplay)
player.kickPlayer("§cDu bist kein Kampfteilnehmer");
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/FightScoreboard.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/FightScoreboard.java
similarity index 85%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/FightScoreboard.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/FightScoreboard.java
index f0ceb64..c747520 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/FightScoreboard.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/FightScoreboard.java
@@ -24,7 +24,8 @@ import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
-import de.steamwar.fightsystem.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
+import de.steamwar.fightsystem.record.PacketProcessor;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
@@ -43,20 +44,27 @@ import java.util.*;
public class FightScoreboard implements Listener, ScoreboardCallback {
+ public static Scoreboard getBukkit() {
+ return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
+ }
+
private static final Set fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
+ private static FightScoreboard scoreboard;
+
+ public static FightScoreboard getScoreboard(){
+ return scoreboard;
+ }
private int index = 0;
private String title = "";
private final HashMap scores = new HashMap<>();
- public static Scoreboard getScoreboard() {
- return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
- }
public FightScoreboard(){
- new StateDependentListener(ArenaMode.All, FightState.All, this);
- new StateDependentTask(ArenaMode.All, FightState.All, this::updateScoreboard, 0, 20);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
+ new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::updateScoreboard, 0, 20);
+ scoreboard = this;
}
@EventHandler
@@ -105,7 +113,9 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
}
private void updateScoreboard() {
- scores.clear();
+ if(PacketProcessor.isReplaying())
+ return;
+
if ((index++ / 5) % 2 == 0) {
generalScoreboard();
} else {
@@ -115,14 +125,15 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
}
}
- private void setTitle(String t) {
+ public void setTitle(String t) {
+ scores.clear();
title = t;
- RecordSystem.scoreboardTitle(t);
+ GlobalRecorder.getInstance().scoreboardTitle(t);
}
- private void addScore(String string, int i) {
+ public void addScore(String string, int i) {
scores.put(string, i);
- RecordSystem.scoreboardData(string, i);
+ GlobalRecorder.getInstance().scoreboardData(string, i);
}
@Override
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java
similarity index 97%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java
index 94ff28a..8b3b07f 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java
@@ -35,7 +35,7 @@ import org.bukkit.inventory.meta.ItemMeta;
public class HotbarGUI implements Listener {
public HotbarGUI() {
- new StateDependentListener(ArenaMode.All, FightState.Setup, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
}
@EventHandler
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamage.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java
similarity index 97%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamage.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java
index d525e6c..f83f39a 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamage.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java
@@ -36,7 +36,7 @@ import java.util.Objects;
public class InFightDamage implements Listener {
public InFightDamage() {
- new StateDependentListener(ArenaMode.All, FightState.Running, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
}
@EventHandler
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java
similarity index 92%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java
index 3dd0274..70ae2ba 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java
@@ -24,6 +24,7 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
@@ -40,7 +41,7 @@ import org.bukkit.inventory.ItemStack;
public class InFightInventory implements Listener {
public InFightInventory() {
- new StateDependentListener(ArenaMode.All, FightState.Running, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
}
@EventHandler
@@ -81,17 +82,7 @@ public class InFightInventory implements Listener {
public void onBlockBreak(BlockBreakEvent event) {
Inventory inventory = event.getPlayer().getInventory();
- Material type = event.getBlock().getType();
- switch(type){
- case REDSTONE_WIRE:
- type = Material.REDSTONE;
- break;
- case PISTON_HEAD:
- type = Material.PISTON;
- break;
- case ICE:
- return;
- }
+ Material type = FlatteningWrapper.impl.onBreak(event.getBlock().getType());
ItemStack itemStack;
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java
similarity index 77%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java
index 6bf1074..154ed42 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java
@@ -21,15 +21,13 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.countdown.Countdown;
-import de.steamwar.fightsystem.countdown.SWSound;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
-import de.steamwar.fightsystem.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.Bukkit;
+import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -40,7 +38,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class IngameDeath implements Listener {
public IngameDeath() {
- new StateDependentListener(ArenaMode.All, FightState.Ingame, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Ingame, this);
}
@EventHandler(priority = EventPriority.HIGH)
@@ -53,8 +51,8 @@ public class IngameDeath implements Listener {
if(team == null)
return;
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!");
- Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
+ FightSystem.broadcast("§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!");
+ Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
team.getFightPlayer(player).setOut();
}
@@ -69,9 +67,9 @@ public class IngameDeath implements Listener {
FightPlayer fightPlayer = team.getFightPlayer(player);
if(fightPlayer.isLiving()) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
+ FightSystem.broadcast("§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
team.getFightPlayer(player).setOut();
- RecordSystem.entityDespawns(player);
+ GlobalRecorder.getInstance().entityDespawns(player);
}
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
similarity index 98%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
index d57e883..4463317 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java
@@ -25,6 +25,7 @@ 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.record.REntity;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SteamwarUser;
@@ -81,6 +82,8 @@ public class Permanent implements Listener {
if(ArenaMode.NotOnBau.contains(Config.mode))
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
}
+
+ REntity.playerJoins(player);
}
@EventHandler
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java
similarity index 98%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java
index 5be57c1..adb4195 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java
@@ -23,7 +23,6 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.block.Block;
-import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPistonExtendEvent;
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java
similarity index 72%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java
index a9c68e9..f20057f 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java
@@ -19,18 +19,17 @@
package de.steamwar.fightsystem.listener;
-import de.steamwar.core.VersionedCallable;
-import de.steamwar.core.VersionedRunnable;
+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.fight.FightTeam;
-import de.steamwar.fightsystem.fight.FightTeam_14;
-import de.steamwar.fightsystem.fight.FightTeam_8;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
+import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.World;
@@ -47,8 +46,8 @@ public class PrepareSchem implements Listener {
public void disable() {
super.disable();
World world = Bukkit.getWorlds().get(0);
- Region region = Config.BlueRotate ? Fight.getRedTeam().getExtendRegion() : Fight.getBlueTeam().getExtendRegion();
- int minY = Config.BlueRotate ? Fight.getRedTeam().getSchemRegion().getMinY() : Fight.getBlueTeam().getSchemRegion().getMinY();
+ Region region = Fight.getUnrotated().getExtendRegion();
+ int minY = Fight.getUnrotated().getSchemRegion().getMinY();
Schematic schem;
try{
@@ -60,9 +59,7 @@ public class PrepareSchem implements Listener {
try{
region.forEach((x, y, z) -> {
- if(VersionedCallable.call(
- new VersionedCallable<>(() -> FightTeam_8.checkPistonMoving(world.getBlockAt(x, y, z)), 8),
- new VersionedCallable<>(() -> FightTeam_14.checkPistonMoving(world.getBlockAt(x, y, z)), 14))){
+ if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z))){
FightSystem.shutdown(FightSystem.PREFIX + "§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen.");
throw new IllegalStateException();
}
@@ -72,12 +69,10 @@ public class PrepareSchem implements Listener {
}
try{
- VersionedRunnable.call(
- new VersionedRunnable(() -> FightTeam_8.saveSchem(schem, region, minY), 8),
- new VersionedRunnable(() -> FightTeam_14.saveSchem(schem, region, minY), 14));
- }catch(IllegalStateException e){
+ WorldeditWrapper.impl.saveSchem(schem, region, minY);
+ }catch(WorldEditException e){
FightSystem.shutdown(FightSystem.PREFIX + "§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen.");
- return;
+ throw new SecurityException("Could not save schem", e);
}
schem.setSchemType(Config.SchematicType.checkType());
@@ -92,11 +87,7 @@ public class PrepareSchem implements Listener {
FightTeam team = Fight.getPlayerTeam(player);
if (team == null) {
- if(Config.BlueRotate){
- Fight.getRedTeam().addMember(player);
- }else{
- Fight.getBlueTeam().addMember(player);
- }
+ Fight.getUnrotated().addMember(player);
}
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP) {
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/RankedJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/RankedJoin.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
similarity index 66%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
index 9a414ba..94d8182 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java
@@ -25,16 +25,23 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
-import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.ArenaMode;
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.record.RecordSystem;
+import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.*;
+import de.steamwar.fightsystem.states.StateDependentTask;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
+import de.steamwar.fightsystem.utils.SWSound;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
@@ -46,7 +53,6 @@ import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
-import org.bukkit.event.server.BroadcastMessageEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Random;
@@ -55,6 +61,7 @@ public class Recording implements Listener {
private static final int AIR = 0;
private static final Random random = new Random();
+ private static final World world = Bukkit.getWorlds().get(0);
private static final PacketAdapter BOW_PACKET_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_PLACE) {
@Override
public void onPacketReceiving(PacketEvent event) {
@@ -62,27 +69,37 @@ public class Recording implements Listener {
EnumWrappers.Hand hand = packet.getHands().read(0);
Player p = event.getPlayer();
- if(!((hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) ||
- (hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW)))
+ if(!BountifulWrapper.impl.bowInHand(hand, p))
return;
- RecordSystem.bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
+ GlobalRecorder.getInstance().bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
}
};
-
private static final PacketAdapter BOW_PACKET_DEDRAW_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_DIG) {
@Override
public void onPacketReceiving(PacketEvent e) {
PacketContainer packetDig = e.getPacket();
if(packetDig.getPlayerDigTypes().read(0) == EnumWrappers.PlayerDigType.RELEASE_USE_ITEM) {
- RecordSystem.bowSpan(e.getPlayer(), false, false);
+ GlobalRecorder.getInstance().bowSpan(e.getPlayer(), false, false);
}
}
};
+ public static ItemStack disarmNull(ItemStack stack){
+ if(stack == null)
+ return new ItemStack(Material.AIR);
+ return stack;
+ }
+
+ public static boolean isNotSent(Player p){
+ FightPlayer fp = Fight.getFightPlayer(p);
+ return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
+ }
+
public Recording() {
- new StateDependentListener(Config.recording(), FightState.All, this);
- new StateDependent(Config.recording(), FightState.Ingame){
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.All, BountifulWrapper.impl.newHandSwapRecorder());
+ new StateDependent(ArenaMode.AntiReplay, FightState.Ingame){
@Override
public void enable() {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
@@ -98,7 +115,7 @@ public class Recording implements Listener {
despawnTNT();
}
}.register();
- new StateDependent(Config.recording(), FightState.Ingame) {
+ new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) {
@Override
public void enable() {
ProtocolLibrary.getProtocolManager().addPacketListener(BOW_PACKET_PROCESSOR);
@@ -111,6 +128,17 @@ public class Recording implements Listener {
ProtocolLibrary.getProtocolManager().removePacketListener(BOW_PACKET_DEDRAW_PROCESSOR);
}
}.register();
+ new StateDependentTask(ArenaMode.AntiReplay, FightState.All, () -> {
+ GlobalRecorder.getInstance().tick();
+
+ if(FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
+ return;
+
+ for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
+ GlobalRecorder.getInstance().entityMoves(tnt);
+ GlobalRecorder.getInstance().entitySpeed(tnt);
+ }
+ }, 1, 1);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -118,7 +146,7 @@ public class Recording implements Listener {
if(isNotSent(e.getPlayer()))
return;
- RecordSystem.entityMoves(e.getPlayer());
+ GlobalRecorder.getInstance().entityMoves(e.getPlayer());
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@@ -126,12 +154,13 @@ public class Recording implements Listener {
if(isNotSent(e.getEntity()))
return;
- RecordSystem.entityDespawns(e.getEntity());
+ GlobalRecorder.getInstance().entityDespawns(e.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onBroadcast(BroadcastMessageEvent e){
- RecordSystem.systemChat(e.getMessage());
+ public void onBlockPhysics(BlockPhysicsEvent e){
+ if(FlatteningWrapper.impl.doRecord(e))
+ GlobalRecorder.getInstance().blockChange(e.getBlock());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -139,7 +168,7 @@ public class Recording implements Listener {
if(isNotSent(e.getPlayer()))
return;
- RecordSystem.playerSneak(e.getPlayer(), e.isSneaking());
+ GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -148,7 +177,7 @@ public class Recording implements Listener {
return;
if(e.getAnimationType() == PlayerAnimationType.ARM_SWING)
- RecordSystem.entityAnimation(e.getPlayer(), AIR);
+ GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -160,10 +189,10 @@ public class Recording implements Listener {
if(isNotSent(p))
return;
- RecordSystem.damageAnimation(p);
+ GlobalRecorder.getInstance().damageAnimation(p);
if(e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || e.getCause() == EntityDamageEvent.DamageCause.FIRE)
- RecordSystem.setOnFire(p, false);
+ GlobalRecorder.getInstance().setOnFire(p, false);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -175,22 +204,15 @@ public class Recording implements Listener {
if(isNotSent(p))
return;
- RecordSystem.setOnFire(p, false);
+ GlobalRecorder.getInstance().setOnFire(p, false);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTNTSpawn(EntitySpawnEvent e){
- //TODO: Falling block
if(e.getEntityType() != EntityType.PRIMED_TNT)
return;
- RecordSystem.tntSpawn(e.getEntity());
- }
-
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onBlockPhysics(BlockPhysicsEvent e){
- if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR)
- RecordSystem.blockChange(e.getBlock());
+ GlobalRecorder.getInstance().tntSpawn(e.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -199,9 +221,9 @@ public class Recording implements Listener {
return;
Location loc = e.getLocation();
- RecordSystem.entityDespawns(e.getEntity());
- RecordSystem.particle(loc.getX(), loc.getY(), loc.getZ(), Particle.EXPLOSION_HUGE.name());
- RecordSystem.sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
+ GlobalRecorder.getInstance().entityDespawns(e.getEntity());
+ GlobalRecorder.getInstance().particle(loc.getX(), loc.getY(), loc.getZ(), "EXPLOSION_HUGE");
+ GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), SWSound.ENTITY_GENERIC_EXPLODE, EnumWrappers.SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -209,25 +231,15 @@ public class Recording implements Listener {
if(isNotSent(e.getPlayer()))
return;
- RecordSystem.item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
- }
-
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onItemSwap(PlayerSwapHandItemsEvent e){
- if(isNotSent(e.getPlayer()))
- return;
-
- Player player = e.getPlayer();
- RecordSystem.item(player, disarmNull(e.getMainHandItem()), "MAINHAND");
- RecordSystem.item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
+ GlobalRecorder.getInstance().item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onProjectileSpawn(ProjectileLaunchEvent e){
if(e.getEntityType() == EntityType.FIREBALL)
- RecordSystem.fireballSpawn(e.getEntity());
+ GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
else if(e.getEntityType() == EntityType.ARROW)
- RecordSystem.arrowSpawn(e.getEntity());
+ GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -241,17 +253,17 @@ public class Recording implements Listener {
switch(e.getSlot()){
case 103:
- RecordSystem.item(player, disarmNull(e.getCurrentItem()), "HEAD");
+ GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "HEAD");
break;
case 102:
- RecordSystem.item(player, disarmNull(e.getCurrentItem()), "CHEST");
+ GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "CHEST");
break;
case 101:
- RecordSystem.item(player, disarmNull(e.getCurrentItem()), "LEGS");
+ GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "LEGS");
break;
case 100:
default:
- RecordSystem.item(player, disarmNull(e.getCurrentItem()), "FEET");
+ GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "FEET");
}
}
@@ -264,35 +276,23 @@ public class Recording implements Listener {
continue;
Player player = fp.getPlayer();
- RecordSystem.item(player, disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
- RecordSystem.item(player, disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
- RecordSystem.item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
- RecordSystem.item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
- RecordSystem.item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
- RecordSystem.item(player, disarmNull(player.getInventory().getBoots()), "FEET");
+ BountifulWrapper.impl.recordHandItems(player);
+ 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().getLeggings()), "LEGS");
+ GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
}
}
- private ItemStack disarmNull(ItemStack stack){
- if(stack == null)
- return new ItemStack(Material.AIR);
- return stack;
- }
-
private void despawnTeam(FightTeam team){
for(FightPlayer player : team.getPlayers()){
if(player.isLiving())
- RecordSystem.entityDespawns(player.getPlayer());
+ GlobalRecorder.getInstance().entityDespawns(player.getPlayer());
}
}
private void despawnTNT(){
for(TNTPrimed tnt : Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class))
- RecordSystem.entityDespawns(tnt);
- }
-
- private boolean isNotSent(Player p){
- FightPlayer fp = Fight.getFightPlayer(p);
- return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
+ GlobalRecorder.getInstance().entityDespawns(tnt);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java
similarity index 60%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java
index 019ff5e..dfe27c8 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java
@@ -1,11 +1,10 @@
package de.steamwar.fightsystem.listener;
-import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.fight.*;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -21,7 +20,7 @@ public class ResourcePack implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
- sendResourcePack(player, "https://steamwar.de/antixray.zip", "3e94f5abeb07cc95067b27705615ec14666abe7b");
+ CraftbukkitWrapper.impl.sendResourcePack(player, "https://steamwar.de/antixray.zip", "3e94f5abeb07cc95067b27705615ec14666abe7b");
}
@EventHandler
@@ -34,14 +33,4 @@ public class ResourcePack implements Listener {
player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erst einmal wieder Ressourcenpakete von SteamWar aktivieren.");
player.kickPlayer(null);
}
-
- private void sendResourcePack(Player player, String pack, String sha1){
- VersionedRunnable.call(
- new VersionedRunnable(() -> FightWorld_8.sendResourcePack(player, pack, sha1), 8),
- new VersionedRunnable(() -> FightWorld_9.sendResourcePack(player, pack, sha1), 9),
- new VersionedRunnable(() -> FightWorld_10.sendResourcePack(player, pack, sha1), 10),
- new VersionedRunnable(() -> FightWorld_12.sendResourcePack(player, pack, sha1), 12),
- new VersionedRunnable(() -> FightWorld_14.sendResourcePack(player, pack, sha1), 14),
- new VersionedRunnable(() -> FightWorld_15.sendResourcePack(player, pack, sha1), 15));
- }
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java
similarity index 95%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java
index 3b083e7..87d4b7e 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java
@@ -32,7 +32,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class SetupQuit implements Listener {
public SetupQuit(){
- new StateDependentListener(ArenaMode.All, FightState.Setup, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
}
@EventHandler
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java
similarity index 92%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java
index be3e243..e088314 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java
@@ -20,6 +20,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.Bukkit;
@@ -36,7 +37,10 @@ public class Shutdown implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
- //Shutdown server if nobody online and its not an event server
+ if(Config.replayserver())
+ return;
+
+ //Shutdown server if nobody online
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
Bukkit.shutdown();
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
similarity index 53%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
index db88f9f..6a06a8e 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java
@@ -26,15 +26,18 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
-import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import java.util.HashSet;
+import java.util.Set;
import java.util.logging.Level;
public class TeamArea implements Listener {
@@ -42,6 +45,8 @@ public class TeamArea implements Listener {
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
+ private static final Set realSpectator = new HashSet<>();
+
public TeamArea() {
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
}
@@ -52,37 +57,48 @@ public class TeamArea implements Listener {
if(player == FightSystem.getEventLeiter())
return;
- Location to = event.getTo();
- assert to != null;
-
FightTeam team = Fight.getPlayerTeam(player);
+ checkInTeamRegion(event, Fight.getBlueTeam(), player, team);
+ checkInTeamRegion(event, Fight.getRedTeam(), player, team);
+ }
- if(Config.BlueExtendRegion.playerInRegion(to)){
- if(team == null)
- reset(event, DENY_TEAM);
- else if(team == Fight.getRedTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
- reset(event, DENY_ENTERN);
- else
- return; // Is allowed in area
- checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
- }else if(Config.RedExtendRegion.playerInRegion(to)){
- if(team == null)
- reset(event, DENY_TEAM);
- else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
- reset(event, DENY_ENTERN);
- else
- return; // Is allowed in area
- checkInInnerArea(event.getPlayer(), to, Fight.getRedTeam());
- }else{
- if(team != null && player.getGameMode() != GameMode.SPECTATOR && !team.canPlayerEntern(player) && !team.getExtendRegion().in2dRegion(to))
- reset(event, DENY_ENTERN);
+ @EventHandler
+ public void playerQuit(PlayerQuitEvent e) {
+ realSpectator.remove(e.getPlayer());
+ }
+
+ 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.playerInRegion(event.getTo());
+ if(team == playerTeam) {
+ if(spectator) {
+ realSpectator(inRegion, player);
+ } else if (!playerTeam.canPlayerEntern(player) && !inRegion) {
+ reset(event, DENY_ENTERN); // Leaving prior to entern
+ }
+ return; // Always allowed in own region
+ }
+
+ if(inRegion) {
+ reset(event, DENY_TEAM); // 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() + " ist in einen Teambereich eingedrungen.");
+ }
}
}
- private void checkInInnerArea(Player player, Location to, FightTeam team){
- if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
- player.kickPlayer(null);
- Bukkit.getLogger().log(Level.INFO, player.getName() + " ist in einen Teambereich eingedrungen.");
+ 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);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java
similarity index 80%
rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java
index 40ae32e..ae8059e 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java
@@ -19,11 +19,11 @@
package de.steamwar.fightsystem.listener;
-import de.steamwar.core.VersionedCallable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
@@ -35,7 +35,7 @@ public class WaterRemover implements Listener {
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
public WaterRemover() {
- new StateDependentListener(ArenaMode.All, FightState.Running, this);
+ new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
}
@EventHandler
@@ -55,9 +55,7 @@ public class WaterRemover implements Listener {
private void checkBlock(Block b) {
//checks for water and removes it, if present
- if(!VersionedCallable.call(
- new VersionedCallable<>(() -> WaterRemover_8.removeWater(b), 8),
- new VersionedCallable<>(() -> WaterRemover_14.removeWater(b), 14)))
+ if(!FlatteningWrapper.impl.removeWater(b))
return;
if(b.getY() < MIN_Y)
@@ -69,10 +67,4 @@ public class WaterRemover implements Listener {
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
}
-
- public static boolean isWater(Block block){
- return VersionedCallable.call(
- new VersionedCallable<>(() -> WaterRemover_8.isWater(block), 8),
- new VersionedCallable<>(() -> WaterRemover_14.isWater(block), 14));
- }
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java
new file mode 100644
index 0000000..f462a83
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java
@@ -0,0 +1,78 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.states.FightState;
+import de.steamwar.fightsystem.states.StateDependent;
+import org.bukkit.Bukkit;
+
+import java.io.*;
+import java.util.zip.GZIPOutputStream;
+
+public class FileRecorder extends StateDependent implements Recorder {
+
+ private static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "recording.recording");
+ private DataOutputStream outputStream;
+
+ public static File getFile() {
+ return file;
+ }
+
+ public FileRecorder(){
+ super(ArenaMode.AntiReplay, FightState.Recording);
+ register();
+ }
+
+ @Override
+ public DataOutputStream getStream() {
+ return outputStream;
+ }
+
+ @Override
+ public void enable() {
+ try{
+ outputStream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file), 4096)){
+ @Override
+ public synchronized void flush() {
+ //Don't flush explicitly (performance)
+ }
+
+ @Override
+ public void close() throws IOException {
+ try{
+ super.flush();
+ }catch(IOException e){
+ //do nothing
+ }
+ super.close();
+ }
+ });
+ }catch(IOException e){
+ throw new SecurityException("Could not open file", e);
+ }
+ Recorder.super.enable();
+ }
+
+ @Override
+ public void disable() {
+ Recorder.super.disable();
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java
new file mode 100644
index 0000000..c283504
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java
@@ -0,0 +1,65 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import de.steamwar.fightsystem.Config;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.zip.GZIPInputStream;
+
+public class FileSource extends PacketSource {
+
+ public static void startReplay() {
+ if(Config.replayserver())
+ return;
+
+ InputStream input = de.steamwar.sql.Fight.getReplay(Config.ReplayID);
+ try {
+ Files.copy(
+ input,
+ FileRecorder.getFile().toPath(),
+ StandardCopyOption.REPLACE_EXISTING);
+ input.close();
+ new FileSource(FileRecorder.getFile());
+ } catch (IOException e) {
+ throw new SecurityException("Could not start replay", e);
+ }
+ }
+
+ public FileSource(File fightFile) throws IOException {
+ super(new GZIPInputStream(new FileInputStream(fightFile)));
+ }
+
+ @Override
+ boolean isClosed() {
+ try{
+ return available() == 0;
+ }catch (IOException e){
+ return true;
+ }
+ }
+
+ @Override
+ boolean async() {
+ return false;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/GlobalRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/GlobalRecorder.java
new file mode 100644
index 0000000..b0e9824
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/GlobalRecorder.java
@@ -0,0 +1,95 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import org.bukkit.Bukkit;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+public class GlobalRecorder extends OutputStream implements Recorder {
+
+ private static final GlobalRecorder recorder = new GlobalRecorder();
+
+ public static GlobalRecorder getInstance(){
+ return recorder;
+ }
+
+ private final List recorders = new ArrayList<>();
+ private final DataOutputStream outputStream = new DataOutputStream(this);
+
+ public void add(Recorder recorder){
+ recorders.add(recorder);
+ }
+
+ public void remove(Recorder recorder){
+ recorders.remove(recorder);
+ }
+
+ public boolean recording(){
+ return !recorders.isEmpty();
+ }
+
+ @Override
+ public DataOutputStream getStream() {
+ return outputStream;
+ }
+
+ @Override
+ public void write(int i) {
+ foreach(stream -> stream.write(i));
+ }
+
+ @Override
+ public void write(byte[] bytes, int i, int i1) {
+ foreach(stream -> stream.write(bytes, i, i1));
+ }
+
+ @Override
+ public void flush() {
+ foreach(OutputStream::flush);
+ }
+
+ @Override
+ public void close() {
+ foreach(OutputStream::close);
+ }
+
+ private void foreach(IOThrower thrower) {
+ for(int i = 0; i < recorders.size(); i++) {
+ Recorder stream = recorders.get(i);
+ try{
+ thrower.run(stream.getStream());
+ }catch (IOException e){
+ Bukkit.getLogger().log(Level.SEVERE, "Could not operate on OutputStream", e);
+ stream.disable();
+ i--; // Recorder was removed from recorders
+ }
+ }
+ }
+
+ interface IOThrower{
+ void run(OutputStream stream) throws IOException;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java
new file mode 100644
index 0000000..8b6c735
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java
@@ -0,0 +1,70 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.states.FightState;
+import de.steamwar.fightsystem.states.StateDependent;
+import org.bukkit.Bukkit;
+
+import java.io.*;
+import java.net.Socket;
+import java.util.logging.Level;
+
+public class LiveRecorder extends StateDependent implements Recorder {
+
+ private DataOutputStream outputStream;
+ private Socket socket;
+
+ public LiveRecorder(){
+ super(Config.LiveReplay, FightState.All);
+ register();
+ }
+
+ @Override
+ public void enable() {
+ try {
+ socket = new Socket(Config.spectateIP, Config.spectatePort);
+ 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.setTcpNoDelay(true); // Don't wait on ack
+ outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), 1024));
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.WARNING, "Could not init connection to spectate server", e);
+ disable();
+ }
+ Recorder.super.enable();
+ }
+
+ @Override
+ public void disable() {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.WARNING, "IOException on socket close", e);
+ }
+ Recorder.super.disable();
+ }
+
+ @Override
+ public DataOutputStream getStream() {
+ return outputStream;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveServer.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveServer.java
new file mode 100644
index 0000000..b58f0fa
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveServer.java
@@ -0,0 +1,62 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import org.bukkit.Bukkit;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.logging.Level;
+
+public class LiveServer {
+
+ private final ServerSocket socket;
+
+ public LiveServer() throws IOException {
+ socket = new ServerSocket(Config.spectatePort);
+ Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::acceptConnections);
+ }
+
+ public void close(){
+ try {
+ socket.close();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not close socket", e);
+ }
+ }
+
+ private void acceptConnections(){
+ try {
+ while(!socket.isClosed()){
+ Socket s = socket.accept();
+ if(PacketProcessor.isReplaying()){
+ s.close();
+ }else{
+ new LiveSource(s);
+ }
+ }
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.INFO, "Stopping accepting connections", e);
+ }
+ }
+}
diff --git a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveSource.java
similarity index 54%
rename from FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/record/LiveSource.java
index 6d1a1e3..3a1fad5 100644
--- a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveSource.java
@@ -19,13 +19,37 @@
package de.steamwar.fightsystem.record;
-import org.bukkit.block.Block;
-import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
+import org.bukkit.Bukkit;
-class RecordSystem_15 {
- private RecordSystem_15(){}
+import java.io.IOException;
+import java.net.Socket;
+import java.util.logging.Level;
- static int blockToId(Block block){
- return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
+public class LiveSource extends PacketSource {
+ private final Socket socket;
+
+ protected LiveSource(Socket socket) throws IOException {
+ super(socket.getInputStream());
+ this.socket = socket;
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ try {
+ socket.close();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "IOException on close", e);
+ }
+ }
+
+ @Override
+ boolean isClosed() {
+ return socket.isClosed();
+ }
+
+ @Override
+ boolean async() {
+ return true;
}
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java
new file mode 100644
index 0000000..c8d0845
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java
@@ -0,0 +1,445 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import de.steamwar.core.Core;
+import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.FightSystem;
+import de.steamwar.fightsystem.countdown.EventSpectateCountdown;
+import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.fight.FightTeam;
+import de.steamwar.fightsystem.fight.FreezeWorld;
+import de.steamwar.fightsystem.listener.BasicListener;
+import de.steamwar.fightsystem.listener.FightScoreboard;
+import de.steamwar.fightsystem.utils.BlockIdWrapper;
+import de.steamwar.fightsystem.utils.BountifulWrapper;
+import de.steamwar.fightsystem.utils.TechHider;
+import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
+import de.steamwar.sql.Schematic;
+import de.steamwar.sql.Team;
+import net.md_5.bungee.api.ChatMessageType;
+import net.md_5.bungee.api.chat.BaseComponent;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Sound;
+import org.bukkit.World;
+import org.bukkit.entity.EntityType;
+import org.bukkit.scheduler.BukkitTask;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.logging.Level;
+
+public class PacketProcessor {
+
+ static boolean replaying = false;
+
+ public static boolean isReplaying(){
+ return replaying;
+ }
+
+ private static final World world = Bukkit.getWorlds().get(0);
+
+ private final PacketParser[] packetDecoder = new PacketParser[256];
+
+ private final PacketSource source;
+ private final BukkitTask task;
+ private final LinkedList syncList = new LinkedList<>();
+ private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds();
+ private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith();
+ private final FreezeWorld freezer = new FreezeWorld();
+
+ private boolean rotateZ = false;
+ private int arenaMinX = Config.ArenaRegion.getMinX();
+ private int arenaMinY = Config.BluePasteRegion.getMinY();
+ private int arenaMinZ = Config.ArenaRegion.getMinZ();
+
+ private boolean tickFinished = false;
+
+ public PacketProcessor(PacketSource source){
+ this.source = source;
+ replaying = true;
+
+ packetDecoder[0x00] = this::playerJoins;
+ packetDecoder[0x01] = this::entityMoves;
+ packetDecoder[0x02] = this::entityDespawns;
+ packetDecoder[0x03] = this::entitySneak;
+ packetDecoder[0x04] = this::entityAnimation;
+ packetDecoder[0x05] = this::tntSpawn;
+ packetDecoder[0x06] = this::entityVelocity;
+ packetDecoder[0x07] = this::playerItem;
+ packetDecoder[0x08] = this::arrowSpawn;
+ packetDecoder[0x09] = this::fireballSpawn;
+ packetDecoder[0x0a] = this::bow;
+ packetDecoder[0x0b] = this::damage;
+ packetDecoder[0x0c] = this::fireTick;
+ packetDecoder[0x20] = this::arenaInfo;
+ packetDecoder[0x30] = this::block;
+ packetDecoder[0x31] = this::particle;
+ packetDecoder[0x32] = this::sound;
+ packetDecoder[0x33] = this::shortBlock;
+ packetDecoder[0x34] = this::soundAtPlayer;
+ packetDecoder[0x35] = this::shortRelativeBlock;
+ packetDecoder[0xa0] = () -> send(ChatMessageType.CHAT);
+ packetDecoder[0xa1] = () -> send(ChatMessageType.ACTION_BAR);
+ packetDecoder[0xa2] = () -> send(ChatMessageType.SYSTEM);
+ packetDecoder[0xb0] = () -> pasteSchem(Fight.getBlueTeam());
+ packetDecoder[0xb1] = () -> pasteSchem(Fight.getRedTeam());
+ packetDecoder[0xb2] = this::teams;
+ packetDecoder[0xb3] = () -> pasteEmbeddedSchem(Fight.getBlueTeam());
+ packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam());
+ packetDecoder[0xc0] = this::scoreboardTitle;
+ packetDecoder[0xc1] = this::scoreboardData;
+ packetDecoder[0xef] = source::readUTF;
+ packetDecoder[0xff] = this::tick;
+
+ if(source.async()) {
+ Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process);
+ task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1);
+ }else
+ task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::process, 1, 1);
+ }
+
+ private void runSync() {
+ synchronized (syncList) {
+ for(Runnable runnable : syncList) {
+ try{
+ runnable.run();
+ }catch (Exception e) {
+ Bukkit.getLogger().log(Level.WARNING, "Failed to execute packet", e);
+ }
+ }
+ syncList.clear();
+ }
+ }
+
+ private void execSync(Runnable runnable){
+ if (!source.async()) {
+ runnable.run();
+ return;
+ }
+
+ synchronized (syncList) {
+ syncList.add(runnable);
+ }
+ }
+
+ private void playerJoins() throws IOException {
+ int entityId = source.readInt();
+ int userId = source.readInt();
+
+ execSync(() -> new REntity(entityId, userId));
+ }
+
+ private void entityMoves() throws IOException {
+ int entityId = source.readInt();
+ double locX = source.readDouble() - arenaMinX + Config.ArenaRegion.getMinX();
+ double locY = source.readDouble() - arenaMinY + Config.BluePasteRegion.getMinY();
+ double z = source.readDouble() - arenaMinZ;
+ if(rotateZ)
+ z = Config.ArenaRegion.getSizeZ() - z;
+ double locZ = z + Config.ArenaRegion.getMinZ();
+ float pitch = source.readFloat();
+ float yaw = source.readFloat() + (rotateZ ? 360 : 0);
+ byte headYaw = (byte)((source.readByte() + (rotateZ ? 128 : 0)) % 256);
+
+ execSync(() -> REntity.getEntity(entityId).move(locX, locY, locZ, pitch, yaw, headYaw));
+ }
+
+ private void entityDespawns() throws IOException {
+ int entityId = source.readInt();
+
+ execSync(() -> REntity.getEntity(entityId).die());
+ }
+
+ private void entitySneak() throws IOException {
+ int entityId = source.readInt();
+ boolean sneaking = source.readBoolean();
+
+ execSync(() -> REntity.getEntity(entityId).sneak(sneaking));
+ }
+
+ private void entityAnimation() throws IOException {
+ int entityId = source.readInt();
+ byte animation = source.readByte();
+
+ execSync(() -> REntity.getEntity(entityId).animation(animation));
+ }
+
+ private void tntSpawn() throws IOException {
+ int entityId = source.readInt();
+
+ execSync(() -> new REntity(entityId, EntityType.PRIMED_TNT));
+ }
+
+ private void entityVelocity() throws IOException {
+ int entityId = source.readInt();
+
+ double dX = source.readDouble();
+ double dY = source.readDouble();
+ double dZ = rotateZ ? -source.readDouble() : source.readDouble();
+
+ execSync(() -> {
+ REntity entity = REntity.getEntity(entityId);
+ if(entity != null)
+ entity.setVelocity(dX, dY, dZ);
+ });
+ }
+
+ private void playerItem() throws IOException {
+ int entityId = source.readInt();
+ String item = source.readUTF();
+ boolean enchanted = source.readBoolean();
+ String slot = source.readUTF();
+
+ execSync(() -> REntity.getEntity(entityId).setItem(item, enchanted, slot));
+ }
+
+ private void arrowSpawn() throws IOException {
+ int entityId = source.readInt();
+
+ execSync(() -> new REntity(entityId, EntityType.ARROW));
+ }
+
+ private void fireballSpawn() throws IOException {
+ int entityId = source.readInt();
+
+ execSync(() -> new REntity(entityId, EntityType.FIREBALL));
+ }
+
+ private void send(ChatMessageType type) throws IOException {
+ String message = source.readUTF();
+
+ BaseComponent[] text = TextComponent.fromLegacyText(message);
+ Bukkit.getOnlinePlayers().forEach(p -> {
+ switch(type){
+ case CHAT:
+ BountifulWrapper.impl.toChat(p, text);
+ break;
+ case SYSTEM:
+ p.spigot().sendMessage(text);
+ break;
+ case ACTION_BAR:
+ BasicListener.toActionbar(p, text);
+ break;
+ }
+ });
+ }
+
+ private void arenaInfo() throws IOException {
+ rotateZ = source.readBoolean() != Config.blueNegZ();
+ arenaMinY = Byte.toUnsignedInt(source.readByte());
+ arenaMinX = source.readInt();
+ arenaMinZ = source.readInt();
+ }
+
+ private void shortBlock() throws IOException {
+ int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX();
+ int y = Byte.toUnsignedInt(source.readByte());
+ int z = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinZ();
+ int blockState = source.readShort();
+
+ setBlock(x, y, z, blockState);
+ }
+
+ private void shortRelativeBlock() throws IOException {
+ int x = Byte.toUnsignedInt(source.readByte());
+ int y = Byte.toUnsignedInt(source.readByte());
+ int z = Byte.toUnsignedInt(source.readByte());
+ int blockState = source.readShort();
+
+ if(rotateZ)
+ z = Config.ArenaRegion.getSizeZ() - z;
+
+ setBlock(x + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), z + Config.ArenaRegion.getMinZ(), blockState);
+ }
+
+ private void block() throws IOException {
+ int x = source.readInt() - arenaMinX;
+ int y = Byte.toUnsignedInt(source.readByte()) - arenaMinY;
+ int z = source.readInt() - arenaMinZ;
+ int blockState = source.readInt();
+
+ if(rotateZ)
+ z = Config.ArenaRegion.getSizeZ() - z;
+
+ setBlock(x + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), z + Config.ArenaRegion.getMinZ(), blockState);
+ }
+
+ private void setBlock(int x, int y, int z, int blockState){
+ if(!Config.ArenaRegion.in2dRegion(x, z))
+ return; //Outside of the arena
+
+ execSync(() -> BlockIdWrapper.impl.setBlock(world, x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
+ }
+
+ private void particle() throws IOException {
+ double x = source.readDouble();
+ double y = source.readDouble();
+ double z = source.readDouble();
+ String particleName = source.readUTF();
+
+ execSync(() -> BountifulWrapper.impl.spawnParticle(world, particleName, x, y, z));
+ }
+
+ private void sound() throws IOException {
+ int x = source.readInt();
+ int y = source.readInt();
+ int z = source.readInt();
+
+ String soundName = source.readUTF();
+ String soundCategory = source.readUTF();
+
+ float volume = source.readFloat();
+ float pitch = source.readFloat();
+
+ Sound sound = Sound.valueOf(soundName);
+
+ execSync(() -> WorldOfColorWrapper.impl.playSound(new Location(world, x, y, z), sound, soundCategory, volume, pitch));
+ }
+
+ private void soundAtPlayer() throws IOException {
+ String soundName = source.readUTF();
+
+ float volume = source.readFloat();
+ float pitch = source.readFloat();
+
+ Sound sound = Sound.valueOf(soundName);
+
+ execSync(() -> Fight.playSound(sound, volume, pitch));
+ }
+
+ private void pasteSchem(FightTeam team) throws IOException {
+ int schemId = source.readInt();
+
+ execSync(() -> team.pasteSchem(Schematic.getSchemFromDB(schemId)));
+ }
+
+ private void pasteEmbeddedSchem(FightTeam team) throws IOException {
+ int schemId = source.readInt();
+ Clipboard clipboard = Schematic.clipboardFromStream(source, Core.getVersion() > 12);
+
+ execSync(() -> team.pasteSchem(schemId, clipboard));
+ }
+
+ private void teams() throws IOException {
+ int blueId = source.readInt();
+ int redId = source.readInt();
+
+ execSync(() -> {
+ pasteForTeam(blueId, Fight.getBlueTeam());
+ pasteForTeam(redId, Fight.getRedTeam());
+ });
+ }
+
+ private void pasteForTeam(int teamId, FightTeam fightTeam){
+ Team team = Team.get(teamId);
+ fightTeam.setPrefixAndName("§" + team.getTeamColor(), team.getTeamKuerzel());
+ fightTeam.pasteTeamName();
+ }
+
+ private void scoreboardTitle() throws IOException {
+ String title = source.readUTF();
+
+ FightScoreboard.getScoreboard().setTitle(title);
+ }
+
+ private void scoreboardData() throws IOException {
+ String key = source.readUTF();
+ int value = source.readInt();
+
+ FightScoreboard.getScoreboard().addScore(key, value);
+ }
+
+ private void endReplay(){
+ REntity.dieAll();
+ freezer.disable();
+ if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) {
+ FightSystem.setSpectateState(null, "Replay ends");
+ }else{
+ Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet");
+ new EventSpectateCountdown().enable();
+ }
+ replaying = false;
+ }
+
+ private void bow() throws IOException {
+ int entityId = source.readInt();
+ boolean drawn = source.readBoolean();
+ boolean offHand = source.readBoolean();
+
+ execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, offHand));
+ }
+
+ private void damage() throws IOException {
+ int entityId = source.readInt();
+
+ execSync(() -> REntity.getEntity(entityId).damage());
+ }
+
+ private void fireTick() throws IOException {
+ int entityId = source.readInt();
+ boolean perma = source.readBoolean();
+
+ execSync(() -> REntity.getEntity(entityId).setOnFire(perma));
+ }
+
+ private void tick(){
+ execSync(REntity::tickFire);
+ if(!source.async())
+ tickFinished = true;
+ }
+
+ private void process(){
+ tickFinished = false;
+ try{
+ while(!source.isClosed() && !tickFinished){
+ int packetType = Byte.toUnsignedInt(source.readByte());
+ PacketParser parser = packetDecoder[packetType];
+ if(parser != null){
+ parser.process();
+ }else{
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown packet " + packetType + " recieved, closing.");
+ source.close();
+ }
+ }
+ } catch (EOFException e) {
+ Bukkit.getLogger().log(Level.INFO, "The FightServer is offline");
+ source.close();
+ } catch(IOException e) {
+ Bukkit.getLogger().log(Level.WARNING, "Could not recieve packet", e);
+ source.close();
+ }
+
+ if(source.isClosed()){
+ Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::endReplay);
+ task.cancel();
+ }
+ }
+
+ private interface PacketParser{
+ void process() throws IOException;
+ }
+}
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketSource.java
similarity index 58%
rename from FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/record/PacketSource.java
index 207a3fd..855959f 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketSource.java
@@ -19,13 +19,29 @@
package de.steamwar.fightsystem.record;
-import org.bukkit.block.Block;
+import org.bukkit.Bukkit;
-class RecordSystem_8 {
- private RecordSystem_8(){}
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.Level;
- @SuppressWarnings("deprecation")
- static int blockToId(Block block){
- return block.getTypeId() << 4 + block.getData();
+public abstract class PacketSource extends DataInputStream {
+
+ protected PacketSource(InputStream inputStream){
+ super(inputStream);
+ new PacketProcessor(this);
}
+
+ @Override
+ public void close(){
+ try {
+ super.close();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "IOException on disable", e);
+ }
+ }
+
+ abstract boolean isClosed();
+ abstract boolean async();
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java
new file mode 100644
index 0000000..880b41d
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java
@@ -0,0 +1,373 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.reflect.StructureModifier;
+import com.comphenix.protocol.wrappers.*;
+import com.mojang.authlib.GameProfile;
+import de.steamwar.core.Core;
+import de.steamwar.fightsystem.listener.FightScoreboard;
+import de.steamwar.fightsystem.utils.BlockIdWrapper;
+import de.steamwar.sql.SteamwarUser;
+import net.royawesome.jlibnoise.MathHelper;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.scoreboard.NameTagVisibility;
+import org.bukkit.scoreboard.Team;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+import java.util.logging.Level;
+
+public class REntity {
+
+ private static final Map entities = new HashMap<>();
+
+ public static REntity getEntity(int internalId){
+ return entities.get(internalId);
+ }
+
+ public static void tickFire() {
+ entities.forEach((integer, entity) -> {
+ if(entity.fireTick > 0) {
+ entity.fireTick--;
+ if(entity.fireTick == 0) {
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(entity.getDataWatcherPacket(0, (byte)0));
+ }
+ }
+ });
+ }
+
+ public static void playerJoins(Player player) {
+ try{
+ for(REntity entity : entities.values()){
+ if(entity.entityType == EntityType.PLAYER){
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getPlayerInfoPacket());
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getNamedSpawnPacket());
+ for (Map.Entry entry : entity.itemSlots.entrySet()) {
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getEquipmentPacket(entry.getKey(), entry.getValue()));
+ }
+ }else{
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getSpawnEntityPacket());
+ }
+ //ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getTeleportPacket()); Sollte nicht nötig sein?
+ if(entity.fireTick != 0) {
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(0, (byte) 1));
+ }
+ if(entity.sneaks) {
+ if(Core.getVersion() > 12){
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(true)));
+ }else{
+ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(0, (byte) 2));
+ }
+ }
+ }
+ }catch(InvocationTargetException e){
+ Bukkit.getLogger().log(Level.SEVERE, "Could not sync player", e);
+ }
+ }
+
+ public static void dieAll(){
+ entities.forEach((id, entity) -> entity.broadcastDeath());
+ entities.clear();
+ }
+
+ private static final String SCOREBOARD_TEAMNAME = "Replay";
+ private static final Team team;
+
+ static {
+ if(FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME) == null)
+ team = FightScoreboard.getBukkit().registerNewTeam(SCOREBOARD_TEAMNAME);
+ else
+ team = FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME);
+ team.setNameTagVisibility(NameTagVisibility.NEVER);
+ }
+
+ private static int entityCount = Integer.MAX_VALUE;
+ private static final Random random = new Random();
+
+ private final int internalId;
+ private final int entityId;
+ private final UUID uuid;
+ private final EntityType entityType;
+ private final PlayerInfoData playerInfoData;
+ private final Map itemSlots = new HashMap<>();
+
+ private double locX;
+ private double locY;
+ private double locZ;
+ private byte yaw;
+ private byte pitch;
+ private byte headYaw;
+ private int fireTick;
+ private boolean sneaks;
+
+ public REntity(int internalId, int userId){
+ this.internalId = internalId;
+ this.entityType = EntityType.PLAYER;
+ this.entityId = entityCount--;
+
+ SteamwarUser user = SteamwarUser.get(userId);
+ this.uuid = user.getUUID();
+ this.playerInfoData = new PlayerInfoData(WrappedGameProfile.fromHandle(new GameProfile(uuid, user.getUserName())), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(user.getUserName()));
+ entities.put(internalId, this);
+
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getPlayerInfoPacket());
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getNamedSpawnPacket());
+ team.addEntry(user.getUserName());
+ }
+
+ public REntity(int internalId, EntityType entityType){
+ this.internalId = internalId;
+ this.entityType = entityType;
+ this.entityId = entityCount--;
+ this.playerInfoData = null;
+ this.uuid = new UUID(random.nextLong() & -61441L | 16384L, random.nextLong() & 4611686018427387903L | -9223372036854775808L);
+ entities.put(internalId, this);
+
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getSpawnEntityPacket());
+ }
+
+ public void move(double locX, double locY, double locZ, float pitch, float yaw, byte headYaw){
+ this.locX = locX;
+ this.locY = locY;
+ this.locZ = locZ;
+ this.yaw = (byte)((int)(yaw * 256.0F / 360.0F));
+ this.pitch = (byte)((int)(pitch * 256.0F / 360.0F));
+ this.headYaw = headYaw;
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getTeleportPacket());
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHeadRotationPacket());
+ }
+
+ public void animation(byte animation) {
+ PacketContainer animationPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ANIMATION);
+ StructureModifier ints = animationPacket.getIntegers();
+ ints.write(0, entityId);
+ ints.write(1, (int) animation);
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(animationPacket);
+ }
+
+ public void setVelocity(double dX, double dY, double dZ) {
+ PacketContainer velocityPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_VELOCITY);
+ StructureModifier ints = velocityPacket.getIntegers();
+ ints.write(0, entityId);
+ ints.write(1, calcVelocity(dX));
+ ints.write(2, calcVelocity(dY));
+ ints.write(3, calcVelocity(dZ));
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(velocityPacket);
+ }
+
+ public void damage() {
+ PacketContainer statusPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_STATUS);
+ statusPacket.getIntegers().write(0, entityId);
+ statusPacket.getBytes().write(0, (byte) 2);
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(statusPacket);
+ }
+
+ public void sneak(boolean sneaking) {
+ sneaks = sneaking;
+
+ if(Core.getVersion() > 12){
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(sneaking)));
+ }else{
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, sneaking ? (byte) 2 : (byte) 0));
+ }
+ }
+
+ public void setOnFire(boolean perma) {
+ if(!perma) {
+ fireTick = 21;
+ } else {
+ fireTick = -1;
+ }
+
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, (byte) 1));
+ }
+
+ public void setBowDrawn(boolean drawn, boolean offHand) {
+ if(Core.getVersion() > 8){
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(Core.getVersion() > 12 ? 7 : 6, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
+ }else{
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, (byte)0x10));
+ }
+ }
+
+ public void setItem(String item, boolean enchanted, String slot) {
+ ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1);
+ if(enchanted)
+ stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
+ itemSlots.put(slot, stack);
+
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getEquipmentPacket(slot, stack));
+ }
+
+ public void die(){
+ broadcastDeath();
+ entities.remove(internalId);
+ }
+
+ private void broadcastDeath(){
+ if(entityType == EntityType.PLAYER){
+ PacketContainer infoPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
+ infoPacket.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
+ infoPacket.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(infoPacket);
+ team.removeEntry(playerInfoData.getProfile().getName());
+ }
+
+ PacketContainer destroyPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_DESTROY);
+ destroyPacket.getIntegerArrays().write(0, new int[]{entityId});
+ ProtocolLibrary.getProtocolManager().broadcastServerPacket(destroyPacket);
+ }
+
+ private int calcVelocity(double value) {
+ return (int)(Math.max(-3.9, Math.min(value, 3.9)) * 8000);
+ }
+
+ private void fillPositioningPacket(PacketContainer packet, StructureModifier ints){
+ ints.write(0, entityId);
+ if(Core.getVersion() > 8){
+ StructureModifier doubles = packet.getDoubles();
+ doubles.write(0, locX);
+ doubles.write(1, locY);
+ doubles.write(2, locZ);
+ }else{
+ ints.write(1, MathHelper.floor(locX * 32));
+ ints.write(2, MathHelper.floor(locY * 32));
+ ints.write(3, MathHelper.floor(locZ * 32));
+ }
+ }
+
+ private void fillByteRotation(PacketContainer packet){
+ StructureModifier bytes = packet.getBytes();
+ bytes.write(0, yaw);
+ bytes.write(1, pitch);
+ }
+
+ private PacketContainer getDataWatcherPacket(int index, Object value) {
+ PacketContainer metadataPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
+ metadataPacket.getIntegers().write(0, entityId);
+ WrappedWatchableObject watchable = new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(index, WrappedDataWatcher.Registry.get(value.getClass())), value);
+ watchable.setDirtyState(true);
+ metadataPacket.getWatchableCollectionModifier().write(0, Collections.singletonList(watchable));
+ return metadataPacket;
+ }
+
+ private PacketContainer getTeleportPacket(){
+ PacketContainer teleportPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_TELEPORT);
+ fillPositioningPacket(teleportPacket, teleportPacket.getIntegers());
+ fillByteRotation(teleportPacket);
+ return teleportPacket;
+ }
+
+ private PacketContainer getHeadRotationPacket(){
+ PacketContainer headRotation = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
+ headRotation.getIntegers().write(0, entityId);
+ headRotation.getBytes().write(0, headYaw);
+ return headRotation;
+ }
+
+ private PacketContainer getSpawnEntityPacket(){
+ PacketContainer spawnPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
+ StructureModifier ints = spawnPacket.getIntegers();
+ fillPositioningPacket(spawnPacket, ints);
+ spawnPacket.getUUIDs().write(0, uuid);
+ if(Core.getVersion() > 8){
+ spawnPacket.getUUIDs().write(0, uuid);
+ ints.write(1, 0); // dX
+ ints.write(2, 0); // dY
+ ints.write(3, 0); // dZ
+ }
+ ints.write(4, (int)pitch);
+ ints.write(5, (int)yaw);
+ if(Core.getVersion() > 12){
+ spawnPacket.getEntityTypeModifier().write(0, entityType);
+ }else{
+ switch(entityType){
+ case PRIMED_TNT:
+ ints.write(6, 50);
+ break;
+ case ARROW:
+ ints.write(6, 60);
+ break;
+ case FIREBALL:
+ ints.write(6, 63);
+ break;
+ }
+ }
+ return spawnPacket;
+ }
+
+ private PacketContainer getEquipmentPacket(String slot, ItemStack stack){
+ PacketContainer equipmentPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
+ StructureModifier ints = equipmentPacket.getIntegers();
+ ints.write(0, entityId);
+ if(Core.getVersion() == 8){
+ switch(slot){
+ case "MAINHAND":
+ case "OFFHAND":
+ ints.write(1, 0);
+ break;
+ case "HEAD":
+ ints.write(1, 4);
+ break;
+ case "CHEST":
+ ints.write(1, 3);
+ break;
+ case "LEGS":
+ ints.write(1, 2);
+ break;
+ case "FEET":
+ default:
+ ints.write(1, 1);
+ }
+ }else{
+ equipmentPacket.getItemSlots().write(0, EnumWrappers.ItemSlot.valueOf(slot));
+ }
+ equipmentPacket.getItemModifier().write(0, stack);
+ return equipmentPacket;
+ }
+
+ private PacketContainer getPlayerInfoPacket(){
+ PacketContainer infoPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
+ infoPacket.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
+ infoPacket.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
+ return infoPacket;
+ }
+
+ private PacketContainer getNamedSpawnPacket(){
+ PacketContainer namedSpawnPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
+ StructureModifier ints = namedSpawnPacket.getIntegers();
+ fillPositioningPacket(namedSpawnPacket, ints);
+ namedSpawnPacket.getUUIDs().write(0, uuid);
+ fillByteRotation(namedSpawnPacket);
+ if(Core.getVersion() < 13){
+ namedSpawnPacket.getDataWatcherModifier().write(0, new WrappedDataWatcher());
+ }
+ return namedSpawnPacket;
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java
new file mode 100644
index 0000000..c98e21d
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java
@@ -0,0 +1,317 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.fightsystem.record;
+
+import de.steamwar.fightsystem.ArenaMode;
+import de.steamwar.fightsystem.Config;
+import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.fight.FightPlayer;
+import de.steamwar.fightsystem.fight.FightTeam;
+import de.steamwar.fightsystem.states.FightState;
+import de.steamwar.fightsystem.utils.BlockIdWrapper;
+import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
+import de.steamwar.fightsystem.utils.SWSound;
+import de.steamwar.sql.Schematic;
+import de.steamwar.sql.SteamwarUser;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.util.Vector;
+
+import java.io.*;
+import java.util.logging.Level;
+
+public interface Recorder {
+ DataOutputStream getStream();
+
+ default void enable() {
+ GlobalRecorder.getInstance().add(this);
+
+ if(ArenaMode.Event.contains(Config.mode)){
+ teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
+ }
+
+ arenaInfo();
+ enableTeam(Fight.getBlueTeam());
+ enableTeam(Fight.getRedTeam());
+ }
+
+ default void enableTeam(FightTeam team){
+ if(FightState.Schem.contains(FightState.getFightState())){
+ if(team.isBlue())
+ blueSchem(team.getSchematic());
+ else
+ redSchem(team.getSchematic());
+ }
+
+ if(FightState.AntiSpectate.contains(FightState.getFightState())){
+ for(FightPlayer player : team.getPlayers()){
+ if(player.isLiving()){
+ playerJoins(player.getPlayer());
+ }
+ }
+ }
+ }
+
+ default void disable() {
+ GlobalRecorder.getInstance().remove(this);
+ try {
+ getStream().close();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not close OutputStream", e);
+ }
+ }
+
+ /*
+ * PlayerJoinPacket (0x00) + int EntityId + int SWUserId
+ * EntityMovePacket (0x01) + int EntityId + double x, y, z + float pitch, yaw + byte headyaw
+ * EntityDespawnsPacket (0x02) + int EntityId
+ * PlayerSneakPacket (0x03) + int EntityId + boolean sneaks
+ * EntityAnimationPacket (0x04) + int EntityId + byte animation
+ * TNTSpawnPacket (0x05) + int EntityId
+ * EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
+ * PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
+ * ArrowSpawnPacket (0x08) + int EntityId
+ * FireballSpawnPacket (0x09) + int EntityId
+ * BowSpanPacket (0x0A) + int EntityId + boolean start + hand
+ * PlayerDamagePacket (0x0B) + int EntityId
+ * SetOnFire (0x0C) + int EntityId + boolean perma
+ *
+ * ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ
+ *
+ * BlockPacket (0x30) + pos int, byte, int + int BlockState
+ * ParticlePacket (0x31) + double x, y, z + string particleType
+ * SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
+ * ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
+ * SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
+ * ShortBlockPacket (0x35) + pos relative to ArenaMinX,BluePasteY,ArenaMinZ byte, byte, byte + short BlockState
+ *
+ *
+ * ChatPacket (0xA0) + String message
+ * ActionBarPacket (0xA1) + String message
+ * SystemPacket (0xA2) + String message
+ *
+ * BlueSchemPacket (0xB0) + int blueSchemId
+ * RedSchemPacket (0xB1) + int redSchemId
+ * TeamIDPacket (0xB2) + int blueTeamId, redTeamId
+ * BlueEmbeddedSchemPacket (0xB3) + int blueSchemId + gzipt NBT blob
+ * RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob
+ *
+ * ScoreboardTitlePacket (0xC0) + String scoreboardTitle
+ * ScoreboardDataPacket (0xC1) + String key + int value
+ *
+ * CommentPacket (0xfe) + String comment
+ * TickPacket (0xff)
+ * */
+
+ default void playerJoins(Player p){
+ SteamwarUser user = SteamwarUser.get(p.getUniqueId());
+
+ write(0x00, p.getEntityId(), user.getId());
+ entityMoves(p);
+ }
+
+ default void entityMoves(Entity e){
+ Location location = e.getLocation();
+ write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (byte) (CraftbukkitWrapper.impl.headRotation(e) * 256 / 360));
+ }
+
+ default void entityDespawns(Entity e){
+ write(0x02, e.getEntityId());
+ }
+
+ default void playerSneak(Player p, boolean sneaks){
+ write(0x03, p.getEntityId(), sneaks);
+ }
+
+ default void entityAnimation(Entity e, int animation){
+ write(0x04, e.getEntityId(), (byte)animation);
+ }
+
+ default void tntSpawn(Entity e){
+ write(0x05, e.getEntityId());
+ entityMoves(e);
+ entitySpeed(e);
+ }
+
+ default void entitySpeed(Entity e){
+ Vector velocity = e.getVelocity();
+ write(0x06, e.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ());
+ }
+
+ default void item(Player p, ItemStack item, String slot){
+ write(0x07, p.getEntityId(), "minecraft:" + item.getType().name().toLowerCase(), !item.getEnchantments().isEmpty(), slot);
+ }
+
+ default void arrowSpawn(Entity e){
+ write(0x08, e.getEntityId());
+ entityMoves(e);
+ entitySpeed(e);
+ if(e.getFireTicks() > 0)
+ setOnFire(e, true);
+ }
+
+ default void fireballSpawn(Entity e){
+ write(0x09, e.getEntityId());
+ entityMoves(e);
+ entitySpeed(e);
+ }
+
+ default void bowSpan(Entity e, boolean start, boolean offHand) {
+ write(0x0a, e.getEntityId(), start, offHand);
+ }
+
+ default void damageAnimation(Player p) {
+ write(0x0b, p.getEntityId());
+ }
+
+ default void setOnFire(Entity e, boolean perma) {
+ write(0x0c, e.getEntityId(), perma);
+ }
+
+ default void arenaInfo(){
+ write(0x20, Config.blueNegZ(), (byte)Config.BluePasteRegion.getMinY(),
+ Config.ArenaRegion.getMinX(), Config.ArenaRegion.getMinZ());
+ }
+
+ default void blockChange(Block block){
+ int blockState = BlockIdWrapper.impl.blockToId(block);
+
+ int shortX = block.getX() - Config.ArenaRegion.getMinX();
+ int shortY = block.getY() - Config.BluePasteRegion.getMinY();
+ int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
+ if((short)blockState == blockState && shortX >= 0 && shortX < 256 && shortY >= 0 && shortZ >= 0 && shortZ < 256){
+ //Short block packet
+ write(0x35, (byte)shortX, (byte)shortY, (byte)shortZ, (short)blockState);
+ }else{
+ //Block packet
+ write(0x30, block.getX(), (byte)block.getY(), block.getZ(), blockState);
+ }
+ }
+
+ default void particle(double x, double y, double z, String particleType){
+ write(0x31, x, y, z, particleType);
+ }
+
+ default void sound(int x, int y, int z, SWSound soundType, String soundCategory, float volume, float pitch){
+ write(0x32, x, y, z, soundType.getSound().name(), soundCategory, volume, pitch);
+ }
+
+ default void soundAtPlayer(String soundType, float volume, float pitch){
+ write(0x34, soundType, volume, pitch);
+ }
+
+ default void chat(String s) {
+ write(0xa0, s);
+ }
+
+ default void actionBar(String s) {
+ write(0xa1, s);
+ }
+
+ default void systemChat(String s) {
+ write(0xa2, s);
+ }
+
+ default void teamIds(int blueTeamId, int redTeamId) {
+ write(0xb2, blueTeamId, redTeamId);
+ }
+
+ default void blueSchem(int schemId) {
+ schem(0xb3, 0xb0, schemId);
+ }
+
+ default void redSchem(int schemId) {
+ schem(0xb4, 0xb1, schemId);
+ }
+
+ default void schem(int embedId, int noEmbedId, int schemId){
+ if(schemId == 0) {
+ write(noEmbedId, schemId);
+ return;
+ }
+
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ try{
+ copy(Schematic.getSchemFromDB(schemId).schemData(), buffer);
+ }catch (EOFException e) {
+ Bukkit.getLogger().log(Level.INFO, "EOFException ignored");
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not embed schematic", e);
+ disable();
+ return;
+ }
+
+ write(embedId, schemId, buffer.toByteArray());
+ }
+
+ default void scoreboardTitle(String title){
+ write(0xc0, title);
+ }
+
+ default void scoreboardData(String key, int value){
+ write(0xc1, key, value);
+ }
+
+ default void tick(){
+ write(0xff);
+ }
+
+ default void write(int id, Object... objects){
+ DataOutputStream stream = getStream();
+ try {
+ stream.writeByte(id);
+ for(Object o : objects){
+ if(o instanceof Boolean)
+ stream.writeBoolean((Boolean)o);
+ else if(o instanceof Byte)
+ stream.writeByte((Byte)o);
+ else if(o instanceof Short)
+ stream.writeShort((Short)o);
+ else if(o instanceof Integer)
+ stream.writeInt((Integer)o);
+ else if(o instanceof Float)
+ stream.writeFloat((Float)o);
+ else if(o instanceof Double)
+ stream.writeDouble((Double)o);
+ else if(o instanceof String)
+ stream.writeUTF((String)o);
+ else if(o instanceof byte[])
+ stream.write((byte[])o);
+ else
+ throw new SecurityException("Undefined write for: " + o.getClass().getName());
+ }
+ stream.flush();
+ } catch (IOException e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
+ disable();
+ }
+ }
+
+ static void copy(InputStream var0, OutputStream var1) throws IOException {
+ int var5;
+ for(byte[] var4 = new byte[8192]; (var5 = var0.read(var4)) > 0;) {
+ var1.write(var4, 0, var5);
+ }
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java
similarity index 93%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java
index 52c1490..84deb25 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java
@@ -42,7 +42,9 @@ public enum FightState {
public static final Set Ingame = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING));
public static final Set TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
public static final Set Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
+ public static final Set Recording = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE)));
public static final Set AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
+ public static final Set AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
private static final Map stateDependentFeatures = new HashMap<>();
private static FightState fightState = PRE_LEADER_SETUP;
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/IStateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/IStateDependent.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/IStateDependent.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/IStateDependent.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCountdown.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCountdown.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java
new file mode 100644
index 0000000..d293875
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java
@@ -0,0 +1,42 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import de.steamwar.fightsystem.VersionDependent;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+
+import java.util.Set;
+
+public class BlockIdWrapper {
+ private BlockIdWrapper() {}
+
+ public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(BlockIdWrapper.class.getName());
+
+ public interface IBlockIdWrapper {
+ int blockToId(Block block);
+ void setBlock(World world, int x, int y, int z, int blockState);
+
+ Set getHiddenBlockIds();
+ int getObfuscateWith();
+
+ Object getPose(boolean sneaking);
+ }
+}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java
new file mode 100644
index 0000000..261c83f
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java
@@ -0,0 +1,53 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.protocol.wrappers.EnumWrappers;
+import de.steamwar.fightsystem.VersionDependent;
+import net.md_5.bungee.api.chat.BaseComponent;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.scoreboard.Team;
+
+public class BountifulWrapper {
+ private BountifulWrapper() {}
+
+ public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(BountifulWrapper.class.getName());
+
+ public interface IBountifulWrapper {
+ boolean bowInHand(EnumWrappers.Hand hand, Player p);
+
+ void toActionbar(Player player, BaseComponent... components);
+ void toChat(Player player, BaseComponent... components);
+
+ void setAttackSpeed(Player player);
+
+ void setNametagVisibility(Team team);
+
+ Listener newDenyArrowPickupListener();
+ Listener newDenyHandSwapListener();
+
+ void recordHandItems(Player player);
+ Listener newHandSwapRecorder();
+
+ void spawnParticle(World world, String particleName, double x, double y, double z);
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java
similarity index 86%
rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java
index faa10ac..32f4451 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java
@@ -19,7 +19,6 @@
package de.steamwar.fightsystem.utils;
-import de.steamwar.core.VersionedRunnable;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@@ -47,10 +46,7 @@ public class ColorConverter {
chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
chat2dye.put(ChatColor.DARK_RED, DyeColor.RED);
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
- //Rosa 9pink, Braun 3brown
-
- VersionedRunnable.call(new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver()), 8),
- new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()), 14));
+ chat2dye.put(ChatColor.GRAY, FlatteningWrapper.impl.getSilver());
}
public static DyeColor chat2dye(ChatColor color){
diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java
similarity index 53%
rename from FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java
index aa34f31..a39b895 100644
--- a/FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,22 +15,25 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.listener;
+package de.steamwar.fightsystem.utils;
-import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
+import de.steamwar.fightsystem.VersionDependent;
+import org.bukkit.World;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import java.util.HashSet;
-import java.util.Set;
+public class CraftbukkitWrapper {
+ private CraftbukkitWrapper() {}
-public class PersonalKitCreator_8 {
+ public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(CraftbukkitWrapper.class.getName());
- public static boolean hasItems(ItemStack stack){
- Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
- keys.remove("Enchantments");
- keys.remove("Damage");
- return !keys.isEmpty();
+ public interface ICraftbukkitWrapper {
+ void resetChunk(World world, World backup, int x, int z);
+ void sendResourcePack(Player player, String pack, String sha1);
+ float headRotation(Entity e);
+ boolean hasItems(ItemStack stack);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java
similarity index 86%
rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java
index 4e7928f..9c9eacf 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java
@@ -19,23 +19,27 @@
package de.steamwar.fightsystem.utils;
+import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
+import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.sql.Elo;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
+import java.nio.file.Files;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.logging.Level;
import static de.steamwar.sql.Fight.create;
+import static de.steamwar.sql.Fight.setReplay;
public class FightStatistics {
private FightStatistics(){}
@@ -92,6 +96,12 @@ public class FightStatistics {
savePlayerStats(fp, fightId);
for (FightPlayer fp : Fight.getRedTeam().getPlayers())
savePlayerStats(fp, fightId);
+
+ setReplay(fightId, Files.readAllBytes(FileRecorder.getFile().toPath()));
+
+ if(ArenaMode.Event.contains(Config.mode)){
+ FightSystem.getEventFight().setFight(fightId);
+ }
}catch(Exception e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
}
@@ -105,8 +115,8 @@ public class FightStatistics {
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
Elo.setElo(blueLeader, gameMode, newBlueElo);
Elo.setElo(redLeader, gameMode, newRedElo);
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + SteamwarUser.get(blueLeader).getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + SteamwarUser.get(redLeader).getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
+ FightSystem.broadcast("§7ELO von " + Fight.getBlueTeam().getPrefix() + SteamwarUser.get(blueLeader).getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
+ FightSystem.broadcast("§7ELO von " + Fight.getRedTeam().getPrefix() + SteamwarUser.get(redLeader).getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
}
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java
new file mode 100644
index 0000000..a3b09e2
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java
@@ -0,0 +1,53 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import de.steamwar.fightsystem.VersionDependent;
+import org.bukkit.DyeColor;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class FlatteningWrapper {
+ private FlatteningWrapper() {}
+
+ public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FlatteningWrapper.class.getName());
+
+ public interface IFlatteningWrapper {
+ DyeColor getSilver();
+
+ boolean isWater(Block block);
+ boolean removeWater(Block block);
+
+ boolean containsBlockMeta(ItemMeta meta);
+ boolean hasAttributeModifier(ItemStack stack);
+
+ Material onBreak(Material type);
+
+ boolean doRecord(BlockPhysicsEvent e);
+
+ void forceLoadChunk(World world, int cX, int cZ);
+
+ boolean checkPistonMoving(Block block);
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ItemBuilder.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/ItemBuilder.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
similarity index 88%
rename from FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
index a4f9953..ac6d9a3 100644
--- a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.utils;
@@ -71,6 +71,14 @@ public class Region {
return maxZ;
}
+ public int getSizeX() {
+ return maxX - minX;
+ }
+
+ public int getSizeZ() {
+ return maxZ - minZ;
+ }
+
public double posToChunk(int pos){
return pos / 16.0;
}
@@ -116,12 +124,12 @@ public class Region {
return (maxX - minX) * (maxY - minY) * (maxZ - minZ);
}
- public int centerX() {
- return (maxX - minX) / 2 + minX;
+ public double centerX() {
+ return (maxX - minX) / 2.0 + minX;
}
- public int centerZ() {
- return (maxZ - minZ) / 2 + minZ;
+ public double centerZ() {
+ return (maxZ - minZ) / 2.0 + minZ;
}
public boolean in2dRegion(Location location){
@@ -137,7 +145,11 @@ public class Region {
}
public boolean in2dRegion(Block block){
- return minX <= block.getX() && block.getX() < maxX && minZ <= block.getZ() && block.getZ() <= maxZ;
+ return in2dRegion(block.getX(), block.getZ());
+ }
+
+ public boolean in2dRegion(int x, int z) {
+ return minX <= x && x < maxX && minZ <= z && z <= maxZ;
}
public boolean inRegion(Block block){
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java
similarity index 62%
rename from FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java
index 46cd3f8..9d6ece4 100644
--- a/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,12 +15,26 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.countdown;
+package de.steamwar.fightsystem.utils;
+
+import de.steamwar.fightsystem.VersionDependent;
+import org.bukkit.Sound;
public enum SWSound {
ENTITY_WITHER_DEATH,
BLOCK_NOTE_PLING,
- BLOCK_NOTE_BASS
+ BLOCK_NOTE_BASS,
+ ENTITY_GENERIC_EXPLODE;
+
+ private static final ISWSound impl = VersionDependent.getVersionImpl(SWSound.class.getName());
+
+ public Sound getSound() {
+ return impl.getSound(this);
+ }
+
+ public interface ISWSound {
+ Sound getSound(SWSound sound);
+ }
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java
similarity index 73%
rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java
index 3a3308e..f0b0f5c 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java
@@ -30,13 +30,15 @@ import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
import com.comphenix.protocol.wrappers.WrappedBlockData;
+import com.google.common.primitives.Bytes;
import de.steamwar.core.Core;
-import de.steamwar.core.VersionedCallable;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.IFightSystem;
+import de.steamwar.fightsystem.VersionDependent;
+import de.steamwar.fightsystem.fight.Fight;
+import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import org.bukkit.Bukkit;
@@ -46,11 +48,9 @@ import org.bukkit.entity.Player;
import java.util.*;
-import static de.steamwar.fightsystem.utils.ITechHider.bypass;
-
public class TechHider extends StateDependent {
- private static final boolean enabled = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
+ public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
private final Map packetCache = new HashMap<>();
@@ -59,28 +59,17 @@ public class TechHider extends StateDependent {
private final int threadMultiplier;
public TechHider(){
- super(enabled, FightState.Schem);
-
- Set hiddenBlockIds = VersionedCallable.call(
- new VersionedCallable<>(TechHider_8::getHiddenBlockIds, 8),
- new VersionedCallable<>(TechHider_14::getHiddenBlockIds, 14),
- new VersionedCallable<>(TechHider_15::getHiddenBlockIds, 15));
- int obfuscateWith = VersionedCallable.call(
- new VersionedCallable<>(TechHider_8::getObfuscateWith, 8),
- new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
- new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
+ super(ENABLED, FightState.Schem);
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase());
- chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
- new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
- new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
+ chunkHider = VersionDependent.getVersionImpl(TechHider.class.getName());
if(Config.mode == ArenaMode.EVENT)
threadMultiplier = 4;
else
threadMultiplier = 1;
- Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
+ Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1);
if(Core.getVersion() > 8){
protocolManager.addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
@@ -88,7 +77,7 @@ public class TechHider extends StateDependent {
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
- if(p.getGameMode() == GameMode.SPECTATOR)
+ if(p == null || p.getGameMode() == GameMode.SPECTATOR)
e.setCancelled(true);
}
});
@@ -110,15 +99,13 @@ public class TechHider extends StateDependent {
protocolManager.addPacketListener(blockHider);
protocolManager.addPacketListener(multiBlockHider);
protocolManager.addPacketListener(blockActionHider);
+ protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4);
if(Core.getVersion() > 8) {
protocolManager.addPacketListener(updateBlockEntity);
}
if(Core.getVersion() > 12) {
protocolManager.addPacketListener(blockBreakHider);
}
- if(chunkHider != null) {
- protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4);
- }
}
@Override
@@ -126,18 +113,16 @@ public class TechHider extends StateDependent {
protocolManager.removePacketListener(blockHider);
protocolManager.removePacketListener(multiBlockHider);
protocolManager.removePacketListener(blockActionHider);
+ protocolManager.getAsynchronousManager().unregisterAsyncHandler(chunkHider);
if(Core.getVersion() > 8) {
protocolManager.removePacketListener(updateBlockEntity);
}
if(Core.getVersion() > 12) {
protocolManager.removePacketListener(blockBreakHider);
}
- if(chunkHider != null) {
- protocolManager.getAsynchronousManager().unregisterAsyncHandler(chunkHider);
- }
}
- private final PacketAdapter multiBlockHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
+ private final PacketAdapter multiBlockHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
@@ -174,14 +159,14 @@ public class TechHider extends StateDependent {
}
};
- private final PacketAdapter blockHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
+ private final PacketAdapter blockHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer();
- if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
+ if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return;
PacketContainer cached = packetCache.get(packet);
@@ -202,28 +187,28 @@ public class TechHider extends StateDependent {
}
};
- private final PacketAdapter blockActionHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
+ private final PacketAdapter blockActionHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer();
- if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
+ if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return;
e.setCancelled(true);
}
};
- private final PacketAdapter blockBreakHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) {
+ private final PacketAdapter blockBreakHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer();
- if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
+ if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return;
@@ -252,7 +237,7 @@ public class TechHider extends StateDependent {
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = event.getPlayer();
- if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
+ if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return;
// 9 == Set sign text
@@ -264,7 +249,7 @@ public class TechHider extends StateDependent {
};
public static List prepareChunkReload(Player p, boolean hide){
- if(!enabled)
+ if(!ENABLED)
return Collections.emptyList();
List chunksToReload = new ArrayList<>();
Config.ArenaRegion.forEachChunk((x, z) -> {
@@ -275,7 +260,7 @@ public class TechHider extends StateDependent {
}
public static void reloadChunks(Player p, List chunksToReload, boolean hide){
- if(!enabled)
+ if(!ENABLED)
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(ChunkPos chunk : chunksToReload){
@@ -285,6 +270,73 @@ public class TechHider extends StateDependent {
}, 40);
}
+ static boolean bypass(Player p, int chunkX, int chunkZ){
+ if(p == FightSystem.getEventLeiter())
+ return true;
+
+ FightTeam ft = Fight.getPlayerTeam(p);
+ if(ft == null){
+ return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
+ }else if(ft.isBlue()){
+ return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
+ }else{
+ return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
+ }
+ }
+
+ private static int posToChunk(int c){
+ int chunk = c / 16;
+ if(c<0)
+ chunk--;
+ return chunk;
+ }
+
+ static int readVarInt(byte[] array, int startPos) {
+ int numRead = 0;
+ int result = 0;
+ byte read;
+ do {
+ read = array[startPos + numRead];
+ int value = (read & 0b01111111);
+ result |= (value << (7 * numRead));
+
+ numRead++;
+ if (numRead > 5) {
+ break;
+ }
+ } while ((read & 0b10000000) != 0);
+
+ return result;
+ }
+
+ static int readVarIntLength(byte[] array, int startPos) {
+ int numRead = 0;
+ byte read;
+ do {
+ read = array[startPos + numRead];
+ numRead++;
+ if (numRead > 5) {
+ break;
+ }
+ } while ((read & 0b10000000) != 0);
+
+ return numRead;
+ }
+
+ static byte[] writeVarInt(int value) {
+ List buffer = new ArrayList<>(5);
+ do {
+ byte temp = (byte)(value & 0b01111111);
+ // Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
+ value >>>= 7;
+ if (value != 0) {
+ temp |= 0b10000000;
+ }
+ buffer.add(temp);
+ } while (value != 0);
+ return Bytes.toArray(buffer);
+ }
+
public static class ChunkPos{
final int x;
final int z;
diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java
similarity index 54%
rename from FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java
index 51c04ce..6d17a26 100644
--- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java
@@ -1,7 +1,7 @@
-/*
+/*
This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,18 +15,26 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
-package de.steamwar.fightsystem.fight;
+package de.steamwar.fightsystem.utils;
+import de.steamwar.fightsystem.VersionDependent;
import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.Sound;
+import org.bukkit.entity.Arrow;
import org.bukkit.scoreboard.Team;
-class FightTeam_9 {
- private FightTeam_9(){}
+public class WorldOfColorWrapper {
+ private WorldOfColorWrapper() {}
- static void setTeamColor(Team team, ChatColor color){
- FightTeam_8.setTeamColor(team, color);
- team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
+ public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(WorldOfColorWrapper.class.getName());
+
+ public interface IWorldOfColorWrapper {
+ void setTeamColor(Team team, ChatColor color);
+ boolean isInBlock(Arrow e);
+
+ void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);
}
}
diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java
new file mode 100644
index 0000000..d96df0a
--- /dev/null
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java
@@ -0,0 +1,46 @@
+/*
+ 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 .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+import de.steamwar.fightsystem.VersionDependent;
+import de.steamwar.sql.Schematic;
+import org.bukkit.DyeColor;
+import org.bukkit.Location;
+import org.bukkit.util.Vector;
+
+import java.io.IOException;
+
+public class WorldeditWrapper {
+ private WorldeditWrapper() {}
+
+ public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(WorldeditWrapper.class.getName());
+
+ public interface IWorldeditWrapper {
+ void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;
+ int getWaterDepth(Clipboard clipboard);
+ void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
+ Vector getDimensions(Clipboard clipboard);
+ Clipboard loadChar(String charName) throws IOException;
+ void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException;
+ }
+}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java
similarity index 88%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java
index 1366fbf..fc8e9c9 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
-import org.bukkit.Bukkit;
public class EventTeamOffWincondition extends Wincondition{
@@ -35,7 +34,7 @@ public class EventTeamOffWincondition extends Wincondition{
@Override
public void enable() {
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cBeide Teams sind offline!");
+ FightSystem.broadcast("§cBeide Teams sind offline!");
win(null);
}else{
teamOff(Fight.getBlueTeam());
@@ -52,7 +51,7 @@ public class EventTeamOffWincondition extends Wincondition{
private void teamOff(FightTeam team){
if(team.allPlayersOut()){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDas Team " + team.getColoredName() + " §cist offline!");
+ FightSystem.broadcast("§cDas Team " + team.getColoredName() + " §cist offline!");
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java
index 34c5fc2..56f849f 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -46,7 +45,7 @@ public class RankedPlayerLeftWincondition extends Wincondition implements Listen
return;
if(team.isPlayerLeader(player)) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + team.getColoredName() + " §chat den Kampf verlassen!");
+ FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + " §chat den Kampf verlassen!");
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
similarity index 93%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
index 263c2b6..572d1ee 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java
@@ -24,7 +24,6 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -54,7 +53,7 @@ public class WinconditionAllDead extends Wincondition implements Listener {
return;
if(team.allPlayersOut()) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + team.getColoredName() + message);
+ FightSystem.broadcast("§cDer letzte Spieler aus " + team.getColoredName() + message);
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
similarity index 93%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
index b1e406b..9a1bd7d 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java
@@ -24,7 +24,6 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -54,7 +53,7 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
return;
if(team.isPlayerLeader(player)) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + team.getColoredName() + message);
+ FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + message);
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java
similarity index 78%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java
index 73608ea..3e71579 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
-import org.bukkit.Bukkit;
public class WinconditionHeartRatioTimeout extends Wincondition {
@@ -41,13 +40,13 @@ public class WinconditionHeartRatioTimeout extends Wincondition {
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
if(blueHeartRatio > redHeartRatio) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
win(Fight.getBlueTeam());
}else if(blueHeartRatio < redHeartRatio){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
win(Fight.getRedTeam());
}else{
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und beide Teams hatten die gleiche Anzahl an verbleibenden Leben!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und beide Teams hatten die gleiche Anzahl an verbleibenden Leben!");
win(null);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java
similarity index 79%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java
index c8f343b..be67855 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
-import org.bukkit.Bukkit;
public class WinconditionPercentTimeout extends Wincondition {
@@ -41,13 +40,13 @@ public class WinconditionPercentTimeout extends Wincondition {
double redPercent = Wincondition.percentWincondition.getPercent(Fight.getRedTeam());
if(bluePercent > redPercent) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chat weniger Schaden erlitten!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chat weniger Schaden erlitten!");
win(Fight.getRedTeam());
}else if(bluePercent < redPercent){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chat weniger Schaden erlitten!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chat weniger Schaden erlitten!");
win(Fight.getBlueTeam());
}else{
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden erlitten!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden erlitten!");
win(null);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java
similarity index 90%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java
index 84959d4..e3e5ff3 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java
@@ -27,7 +27,6 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentListener;
-import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -57,13 +56,13 @@ public class WinconditionPoints extends PercentWincondition implements Listener
int bluePoints = teamMap.get(Fight.getBlueTeam()).getPoints();
if(bluePoints < redPoints) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDas Team " + Fight.getRedTeam().getColoredName() + " §chat mehr Punkte!");
+ FightSystem.broadcast("§cDas Team " + Fight.getRedTeam().getColoredName() + " §chat mehr Punkte!");
win(Fight.getRedTeam());
}else if(bluePoints > redPoints){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDas Team " + Fight.getBlueTeam().getColoredName() + " §chat mehr Punkte!");
+ FightSystem.broadcast("§cDas Team " + Fight.getBlueTeam().getColoredName() + " §chat mehr Punkte!");
win(Fight.getBlueTeam());
}else{
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cBeide Teams haben gleich viele Punkte!");
+ FightSystem.broadcast("§cBeide Teams haben gleich viele Punkte!");
win(null);
}
}
@@ -86,7 +85,7 @@ public class WinconditionPoints extends PercentWincondition implements Listener
TeamPoints enemy = teamMap.get(Fight.getOpposite(team));
if(team.isPlayerLeader(player)) {
enemy.points += 500;
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + team.getColoredName() + message);
+ FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + message);
timeOver();
}else if(team.getPlayers().size() <= 5)
enemy.points += 300;
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java
similarity index 95%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java
index 54c3447..4fda590 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java
@@ -77,7 +77,7 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
});
if(pumpkins == 0) {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDas Team " + team.getColoredName() + " §cist Tech K.O.!");
+ FightSystem.broadcast("§cDas Team " + team.getColoredName() + " §cist Tech K.O.!");
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java
similarity index 100%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java
similarity index 95%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java
index 7dea0d1..3a61db5 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
-import de.steamwar.fightsystem.countdown.SWSound;
+import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -52,7 +52,7 @@ public class WinconditionTimeTechKO extends Wincondition {
public WinconditionTimeTechKO(){
super("TechKO");
- if(Config.BlueToRedZ > 0) {
+ if(Config.blueNegZ()) {
smallerZteam = Fight.getBlueTeam();
biggerZteam = Fight.getRedTeam();
}else{
@@ -121,7 +121,7 @@ public class WinconditionTimeTechKO extends Wincondition {
@Override
public void countdownFinished() {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cTeam " + team.getColoredName() + " §chat zu lange nicht geschossen!");
+ FightSystem.broadcast("§cTeam " + team.getColoredName() + " §chat zu lange nicht geschossen!");
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java
similarity index 93%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java
index a14fd79..e6d8a3f 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java
@@ -24,7 +24,6 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
-import org.bukkit.Bukkit;
public class WinconditionTimeout extends Wincondition {
@@ -36,7 +35,7 @@ public class WinconditionTimeout extends Wincondition {
}
protected void timeOver() {
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDie Zeit ist abgelaufen!");
+ FightSystem.broadcast("§cDie Zeit ist abgelaufen!");
win(null);
}
}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java
similarity index 91%
rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java
index d548f8c..f6f2c5b 100644
--- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java
@@ -23,9 +23,9 @@ 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.WaterRemover;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
+import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.Bukkit;
import org.bukkit.World;
@@ -69,12 +69,12 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
private void check() {
water = 0;
team.getExtendRegion().forEach((x, y, z) -> {
- if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
+ if (FlatteningWrapper.impl.isWater(WORLD.getBlockAt(x, y, z)))
water++;
});
if(water == 0){
- Bukkit.broadcastMessage(FightSystem.PREFIX + "§cTeam " + team.getColoredName() + " §cwurde Tech K.O. gesetzt!");
+ FightSystem.broadcast("§cTeam " + team.getColoredName() + " §cwurde Tech K.O. gesetzt!");
win(Fight.getOpposite(team));
}
}
diff --git a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java
similarity index 95%
rename from FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java
rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java
index 3c68222..3fef015 100644
--- a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java
+++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java
@@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
- Copyright (C) 2020 SteamWar.de-Serverteam
+ Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-*/
+ */
package de.steamwar.fightsystem.winconditions;
@@ -23,14 +23,18 @@ public enum Winconditions {
TIMEOUT,
HEART_RATIO_TIMEOUT,
PERCENT_TIMEOUT,
+
ALL_DEAD,
CAPTAIN_DEAD,
+
PERCENT_SYSTEM,
RELATIVE_WHITELIST_PERCENT,
RELATIVE_PERCENT,
POINTS,
+
TIME_TECH_KO,
WATER_TECH_KO,
PUMPKIN_TECH_KO,
+
HELLS_BELLS
}
diff --git a/FightSystem_Main/src/plugin.yml b/FightSystem_Core/src/plugin.yml
similarity index 94%
rename from FightSystem_Main/src/plugin.yml
rename to FightSystem_Core/src/plugin.yml
index eae2084..88fbbec 100644
--- a/FightSystem_Main/src/plugin.yml
+++ b/FightSystem_Core/src/plugin.yml
@@ -18,6 +18,7 @@ commands:
remove:
leader:
lockschem:
+ replay:
state:
skip:
win:
\ No newline at end of file
diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml
index 3083862..2cd94da 100644
--- a/FightSystem_Main/pom.xml
+++ b/FightSystem_Main/pom.xml
@@ -1,4 +1,23 @@
+
+
@@ -18,16 +37,6 @@
1.0
- src
-
-
- src
-
- **/*.java
- **/*.kt
-
-
-
org.apache.maven.plugins
@@ -47,20 +56,6 @@
-
- steamwar
- Spigot
- 1.15
- system
- ${main.basedir}/lib/Spigot-1.15.jar
-
-
- steamwar
- WorldEdit
- 1.0
- system
- ${main.basedir}/lib/WorldEdit-1.12.jar
-
steamwar
FightSystem_8
@@ -99,7 +94,7 @@
steamwar
- FightSystem_API
+ FightSystem_Core
1.0
compile
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java
deleted file mode 100644
index c572101..0000000
--- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.listener;
-
-import de.steamwar.core.VersionedRunnable;
-import de.steamwar.fightsystem.fight.Fight;
-import net.md_5.bungee.api.chat.BaseComponent;
-import org.bukkit.entity.Player;
-
-public class BasicListener {
- private BasicListener(){}
-
- public static boolean notFighting(Player p){
- return Fight.getFightPlayer(p) == null;
- }
-
- public static void toActionbar(Player player, BaseComponent... components){
- VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toActionbar(player, components), 8),
- new VersionedRunnable(() -> BasicListener_9.toActionbar(player, components), 9));
- }
-
- public static void toChat(Player player, BaseComponent... components){
- VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toChat(player, components), 8),
- new VersionedRunnable(() -> BasicListener_9.toChat(player, components), 9));
- }
-
- public static void setAttackSpeed(Player player){
- VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_9.setAttackSpeed(player), 9));
- }
-}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/FileRecorder.java
deleted file mode 100644
index 42aabd1..0000000
--- a/FightSystem_Main/src/de/steamwar/fightsystem/record/FileRecorder.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.record;
-
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-
-import java.io.*;
-import java.util.logging.Level;
-import java.util.zip.GZIPOutputStream;
-
-public class FileRecorder extends Recorder {
-
- private final DataOutputStream outputStream;
-
- public FileRecorder(){
- super();
- World world = Bukkit.getWorlds().get(0);
- File file = new File(world.getWorldFolder(), world.getName() + ".recording");
- try{
- file.createNewFile();
- outputStream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file), 4096)));
- }catch(IOException e){
- throw new SecurityException("Could not open file", e);
- }
- }
-
- @Override
- protected void writeBoolean(boolean b) {
- try {
- outputStream.writeBoolean(b);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeByte(int b) {
- try {
- outputStream.writeByte(b);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeShort(short s) {
- try {
- outputStream.writeShort(s);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeInt(int i) {
- try {
- outputStream.writeInt(i);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeLong(long l) {
- try {
- outputStream.writeLong(l);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeFloat(float f) {
- try {
- outputStream.writeFloat(f);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeDouble(double d) {
- try {
- outputStream.writeDouble(d);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void writeString(String s) {
- try {
- outputStream.writeUTF(s);
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
- close();
- }
- }
-
- @Override
- protected void doFlush() {
-
- }
-
- @Override
- protected void closeRecorder() {
- try {
- outputStream.close();
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not close OutputStream", e);
- }
- }
-}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java
deleted file mode 100644
index 52e31ba..0000000
--- a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.record;
-
-import de.steamwar.core.VersionedCallable;
-import de.steamwar.fightsystem.ArenaMode;
-import de.steamwar.fightsystem.Config;
-import de.steamwar.fightsystem.FightSystem;
-import de.steamwar.fightsystem.fight.*;
-import de.steamwar.fightsystem.states.FightState;
-import de.steamwar.sql.SteamwarUser;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.util.Vector;
-
-public class RecordSystem {
- private RecordSystem(){}
-
- private static final World WORLD = Bukkit.getWorlds().get(0);
-
- public static void init(){
- if(!Config.recording())
- return;
-
- Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), RecordSystem::checkWorldState, 1, 1);
- if (Config.SpectateSystem)
- new SpectateConnection();
- new FileRecorder();
- if(Config.mode == ArenaMode.EVENT)
- teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
- }
-
- /*
- * PlayerJoinPacket (0x00) + int EntityId + int SWUserId
- * EntityMovePacket (0x01) + int EntityId + double x, y, z + float pitch, yaw + byte headyaw
- * EntityDespawnsPacket (0x02) + int EntityId
- * PlayerSneakPacket (0x03) + int EntityId + boolean sneaks
- * EntityAnimationPacket (0x04) + int EntityId + byte animation
- * TNTSpawnPacket (0x05) + int EntityId
- * EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
- * PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
- * ArrowSpawnPacket (0x08) + int EntityId
- * FireballSpawnPacket (0x09) + int EntityId
- * BowSpanPacket (0x0A) + int EntityId + boolean start + hand
- * PlayerDamagePacket (0x0B) + int EntityId
- * SetOnFire (0x0C) + int EntityId + boolean perma
- *
- *
- * BlockPacket (0x30) + pos int, byte, int + int BlockState
- * ParticlePacket (0x31) + double x, y, z + string particleType
- * SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
- * ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
- * SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
- *
- *
- * ChatPacket (0xA0) + String message
- * ActionBarPacket (0xA1) + String message
- * SystemPacket (0xA2) + String message
- * BlueSchemPacket (0xB0) + int blueSchemId
- * RedSchemPacket (0xB1) + int redSchemId
- * TeamIDPacket (0xB2) + int blueTeamId, redTeamId
- * ScoreboardTitlePacket (0xC0) + String scoreboardTitle
- * ScoreboardDataPacket (0xC1) + String key + int value
- *
- * CommentPacket (0xfe) + String comment
- * TickPacket (0xff)
- * */
-
- public static synchronized void playerJoins(Player p){
- SteamwarUser user = SteamwarUser.get(p.getUniqueId());
-
- Recorder.rByte(0x00);
- Recorder.rInt(p.getEntityId());
- Recorder.rInt(user.getId());
- entityMoves(p);
- }
-
- public static synchronized void entityMoves(Entity e){
- Location location = e.getLocation();
-
- Recorder.rByte(0x01);
- Recorder.rInt(e.getEntityId());
- Recorder.rDouble(location.getX());
- Recorder.rDouble(location.getY());
- Recorder.rDouble(location.getZ());
- Recorder.rFloat(location.getPitch());
- Recorder.rFloat(location.getYaw());
- Recorder.rByte((int)(VersionedCallable.call(
- new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8),
- new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9),
- new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10),
- new VersionedCallable<>(() -> FightWorld_12.headRotation(e), 12),
- new VersionedCallable<>(() -> FightWorld_14.headRotation(e), 14),
- new VersionedCallable<>(() -> FightWorld_15.headRotation(e), 15)
- ) * 256 / 360));
- Recorder.flush();
- }
-
- public static synchronized void entityDespawns(Entity e){
- Recorder.rByte(0x02);
- Recorder.rInt(e.getEntityId());
- Recorder.flush();
- }
-
- public static synchronized void playerSneak(Player p, boolean sneaks){
- Recorder.rByte(0x03);
- Recorder.rInt(p.getEntityId());
- Recorder.rBoolean(sneaks);
- Recorder.flush();
- }
-
- public static synchronized void entityAnimation(Entity e, int animation){
- Recorder.rByte(0x04);
- Recorder.rInt(e.getEntityId());
- Recorder.rByte(animation);
- Recorder.flush();
- }
-
- public static synchronized void tntSpawn(Entity e){
- Recorder.rByte(0x05);
- spawnEntity(e);
- }
-
- public static synchronized void entitySpeed(Entity e){
- Vector velocity = e.getVelocity();
- Recorder.rByte(0x06);
- Recorder.rInt(e.getEntityId());
- Recorder.rDouble(velocity.getX());
- Recorder.rDouble(velocity.getY());
- Recorder.rDouble(velocity.getZ());
- Recorder.flush();
- }
-
- public static synchronized void item(Player p, ItemStack item, String slot){
- Recorder.rByte(0x07);
- Recorder.rInt(p.getEntityId());
- Recorder.rString(item.getType().getKey().toString());
- Recorder.rBoolean(!item.getEnchantments().isEmpty());
- Recorder.rString(slot);
- Recorder.flush();
- }
-
- public static synchronized void arrowSpawn(Entity e){
- Recorder.rByte(0x08);
- spawnEntity(e);
- if(e.getFireTicks() > 0)
- setOnFire(e, true);
- }
-
- public static synchronized void fireballSpawn(Entity e){
- Recorder.rByte(0x09);
- spawnEntity(e);
- }
-
- public static synchronized void bowSpan(Entity e, boolean start, boolean offHand) {
- Recorder.rByte(0x0A);
- Recorder.rInt(e.getEntityId());
- Recorder.rBoolean(start);
- Recorder.rBoolean(offHand);
- Recorder.flush();
- }
-
- public static synchronized void damageAnimation(Player p) {
- Recorder.rByte(0x0B);
- Recorder.rInt(p.getEntityId());
- Recorder.flush();
- }
-
- public static synchronized void setOnFire(Entity e, boolean perma) {
- Recorder.rByte(0x0C);
- Recorder.rInt(e.getEntityId());
- Recorder.rBoolean(perma);
- Recorder.flush();
- }
-
- public static synchronized void blockChange(Block block){
- int blockState = blockToId(block);
-
- int shortX = block.getX() - Config.ArenaRegion.getMinX();
- int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
- if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
- //Short block packet
- Recorder.rByte(0x33);
- Recorder.rByte(shortX);
- Recorder.rByte(block.getY());
- Recorder.rByte(shortZ);
- Recorder.rShort((short)blockState);
- }else{
- //Block packet
- Recorder.rByte(0x30);
- Recorder.rInt(block.getX());
- Recorder.rByte(block.getY());
- Recorder.rInt(block.getZ());
- Recorder.rInt(blockState);
- }
- Recorder.flush();
- }
-
- public static synchronized void particle(double x, double y, double z, String particleType){
- Recorder.rByte(0x31);
- Recorder.rDouble(x);
- Recorder.rDouble(y);
- Recorder.rDouble(z);
- Recorder.rString(particleType);
- Recorder.flush();
- }
-
- public static synchronized void sound(int x, int y, int z, String soundType, String soundCategory, float volume, float pitch){
- Recorder.rByte(0x32);
- Recorder.rInt(x);
- Recorder.rInt(y);
- Recorder.rInt(z);
- Recorder.rString(soundType);
- Recorder.rString(soundCategory);
- Recorder.rFloat(volume);
- Recorder.rFloat(pitch);
- Recorder.flush();
- }
-
- public static synchronized void soundAtPlayer(String soundType, float volume, float pitch){
- Recorder.rByte(0x34);
- Recorder.rString(soundType);
- Recorder.rFloat(volume);
- Recorder.rFloat(pitch);
- Recorder.flush();
- }
-
- public static synchronized void chat(String s) {
- Recorder.rByte(0xA0);
- Recorder.rString(s);
- Recorder.flush();
- }
-
- public static synchronized void actionBar(String s) {
- Recorder.rByte(0xA1);
- Recorder.rString(s);
- Recorder.flush();
- }
-
- public static synchronized void systemChat(String s) {
- Recorder.rByte(0xA2);
- Recorder.rString(s);
- Recorder.flush();
- }
-
- public static synchronized void blueSchem(int schemId) {
- Recorder.rByte(0xB0);
- Recorder.rInt(schemId);
- Recorder.flush();
- }
-
- public static synchronized void redSchem(int schemId) {
- Recorder.rByte(0xB1);
- Recorder.rInt(schemId);
- Recorder.flush();
- }
-
- public static synchronized void teamIds(int blueTeamId, int redTeamId) {
- Recorder.rByte(0xB2);
- Recorder.rInt(blueTeamId);
- Recorder.rInt(redTeamId);
- Recorder.flush();
- }
-
- public static synchronized void scoreboardTitle(String title){
- Recorder.rByte(0xC0);
- Recorder.rString(title);
- Recorder.flush();
- }
-
- public static synchronized void scoreboardData(String key, int value){
- Recorder.rByte(0xC1);
- Recorder.rString(key);
- Recorder.rInt(value);
- Recorder.flush();
- }
-
- public static synchronized void tick(){
- Recorder.rByte(0xff);
- Recorder.flush();
- }
-
- private static void checkWorldState(){
- tick();
-
- if(FightState.getFightState() == FightState.SPECTATE)
- return;
-
- for(TNTPrimed tnt : WORLD.getEntitiesByClass(TNTPrimed.class)){
- entityMoves(tnt);
- entitySpeed(tnt);
- }
- }
-
- private static void spawnEntity(Entity e){
- Recorder.rInt(e.getEntityId());
- entityMoves(e);
- entitySpeed(e);
- }
-
- private static int blockToId(Block block){
- return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8),
- new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15));
- }
-}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java
deleted file mode 100644
index a332331..0000000
--- a/FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.record;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class Recorder {
-
- private static final List recorders = new ArrayList<>();
-
- public static void rBoolean(boolean b){
- recorders.forEach((recorder) -> recorder.writeBoolean(b));
- }
-
- public static void rByte(int b){
- recorders.forEach((recorder) -> recorder.writeByte(b));
- }
-
- public static void rShort(short s){
- recorders.forEach((recorder) -> recorder.writeShort(s));
- }
-
- public static void rInt(int i){
- recorders.forEach((recorder) -> recorder.writeInt(i));
- }
-
- public static void rLong(long l){
- recorders.forEach((recorder) -> recorder.writeLong(l));
- }
-
- public static void rFloat(float f){
- recorders.forEach((recorder) -> recorder.writeFloat(f));
- }
-
- public static void rDouble(double d){
- recorders.forEach((recorder) -> recorder.writeDouble(d));
- }
-
- public static void rString(String s){
- recorders.forEach((recorder) -> recorder.writeString(s));
- }
-
- public static void flush(){
- recorders.forEach(Recorder::doFlush);
- }
-
- public static void closeAll(){
- while(!recorders.isEmpty())
- recorders.get(0).close();
- }
-
- protected Recorder(){
- recorders.add(this);
- }
-
- protected void close(){
- closeRecorder();
- recorders.remove(this);
- }
-
- protected abstract void writeBoolean(boolean b);
- protected abstract void writeByte(int b);
- protected abstract void writeShort(short s);
- protected abstract void writeInt(int i);
- protected abstract void writeLong(long l);
- protected abstract void writeFloat(float f);
- protected abstract void writeDouble(double d);
- protected abstract void writeString(String s);
- protected abstract void doFlush();
-
- protected abstract void closeRecorder();
-}
diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java
deleted file mode 100644
index 9951321..0000000
--- a/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.fightsystem.record;
-
-import de.steamwar.fightsystem.Config;
-import org.bukkit.Bukkit;
-
-import java.io.*;
-import java.net.Socket;
-import java.util.logging.Level;
-
-public class SpectateConnection extends Recorder{
-
- private Socket socket;
- private DataOutputStream outputStream;
-
- SpectateConnection(){
- super();
- try {
- this.socket = new Socket(Config.spectateIP, Config.spectatePort);
- socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
- socket.setSoLinger(true, 1); // Wait a maximum of 1ms on close
- socket.setTcpNoDelay(true); // Don't wait always on ack
- this.outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.WARNING, "Could not init connection to spectate server", e);
- close();
- }
- }
-
- @Override
- protected void writeBoolean(boolean b) {
- try{
- outputStream.writeBoolean(b);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeByte(int b) {
- try{
- outputStream.writeByte(b);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeShort(short s) {
- try{
- outputStream.writeShort(s);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeInt(int i) {
- try{
- outputStream.writeInt(i);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeLong(long l) {
- try{
- outputStream.writeLong(l);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeFloat(float f) {
- try{
- outputStream.writeFloat(f);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeDouble(double d) {
- try{
- outputStream.writeDouble(d);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void writeString(String s) {
- try{
- outputStream.writeUTF(s);
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
- }
- }
-
- @Override
- protected void doFlush() {
- try{
- outputStream.flush();
- } catch (IOException e) {
- close();
- Bukkit.getLogger().log(Level.SEVERE, "Could not flush", e);
- }
- }
-
- @Override
- protected void closeRecorder() {
- try {
- socket.close();
- outputStream.close();
- } catch (IOException e) {
- Bukkit.getLogger().log(Level.WARNING, "IOException on socket close", e);
- }
- }
-}
diff --git a/pom.xml b/pom.xml
index 455d1b6..da93e94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,17 +26,37 @@
1.8
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+ false
+
+
+
+ src
+
+
+ src
+
+ **/*.java
+ **/*.kt
+
+
+
- FightSystem_API
FightSystem_8
FightSystem_9
FightSystem_10
FightSystem_12
FightSystem_14
FightSystem_15
+ FightSystem_Core
FightSystem_Main
diff --git a/steamwarci.yml b/steamwarci.yml
new file mode 100644
index 0000000..a48cedd
--- /dev/null
+++ b/steamwarci.yml
@@ -0,0 +1,6 @@
+build:
+ - "ln -s /home/gitea/lib"
+ - "mvn package -B"
+
+artifacts:
+ "/binarys/fightsystem.jar": "FightSystem_Main/target/fightsystem.jar"