From 5d71169690e962546734aee46a683641d1700d5c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 24 Mar 2021 11:21:17 +0100 Subject: [PATCH] Fix multiversioning Signed-off-by: Lixfel --- .../fightsystem/fight/FightWorld_10.java | 47 ++++++++++++++++++ .../fightsystem/fight/FightWorld_12.java | 28 +++++++++++ .../fightsystem/fight/FightWorld_14.java | 48 +++++++++++++++++++ .../fightsystem/fight/FightWorld_15.java | 48 +++++++++++++++++++ .../fightsystem/fight/FightWorld_8.java | 47 ++++++++++++++++++ .../fightsystem/fight/FightWorld_9.java | 47 ++++++++++++++++++ .../fightsystem/commands/Commands.java | 4 +- .../fightsystem/fight/FightWorld.java | 42 ++++++++++------ 8 files changed, 294 insertions(+), 17 deletions(-) create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java create mode 100644 FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java create mode 100644 FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java new file mode 100644 index 0000000..3b81471 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java @@ -0,0 +1,47 @@ +/* + 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.core.events.ChunkListener; +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.entity.Player; + +class FightWorld_10 { + private FightWorld_10(){} + + static void resetChunk(World world, World backup, int x, int z){ + net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle(); + Chunk chunk = w.getChunkAt(x, z); + Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); + + System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); + System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); + w.tileEntityListTick.removeAll(chunk.tileEntities.values()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java new file mode 100644 index 0000000..8df8227 --- /dev/null +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java @@ -0,0 +1,28 @@ +package de.steamwar.fightsystem.fight; + +import de.steamwar.core.events.ChunkListener; +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.entity.Player; + +class FightWorld_12 { + private FightWorld_12(){} + + static void resetChunk(World world, World backup, int x, int z){ + net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle(); + Chunk chunk = w.getChunkAt(x, z); + Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); + + System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); + System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); + w.tileEntityListTick.removeAll(chunk.tileEntities.values()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java new file mode 100644 index 0000000..0cff188 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java @@ -0,0 +1,48 @@ +/* + 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.core.events.ChunkListener; +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.entity.Player; + +class FightWorld_14 { + private FightWorld_14(){} + + static 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()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + chunk.heightMap.clear(); + chunk.heightMap.putAll(backupChunk.heightMap); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java new file mode 100644 index 0000000..cac3956 --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java @@ -0,0 +1,48 @@ +/* + 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.core.events.ChunkListener; +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.entity.Player; + +class FightWorld_15 { + private FightWorld_15(){} + + static 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()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + chunk.heightMap.clear(); + chunk.heightMap.putAll(backupChunk.heightMap); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java new file mode 100644 index 0000000..e341167 --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java @@ -0,0 +1,47 @@ +/* + 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.core.events.ChunkListener; +import net.minecraft.server.v1_8_R3.Chunk; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Player; + +class FightWorld_8 { + private FightWorld_8(){} + + static 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); + Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); + + System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); + System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); + w.h.removeAll(chunk.tileEntities.values()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java new file mode 100644 index 0000000..06bdcc5 --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java @@ -0,0 +1,47 @@ +/* + 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.core.events.ChunkListener; +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.entity.Player; + +class FightWorld_9 { + private FightWorld_9(){} + + static void resetChunk(World world, World backup, int x, int z){ + net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle(); + Chunk chunk = w.getChunkAt(x, z); + Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); + + System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); + System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); + w.tileEntityListTick.removeAll(chunk.tileEntities.values()); + w.tileEntityList.removeAll(chunk.tileEntities.values()); + chunk.tileEntities.clear(); + chunk.tileEntities.putAll(backupChunk.tileEntities); + for(Player p : Bukkit.getOnlinePlayers()){ + ChunkListener.sendChunk(p, x, z); + } + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java index 973440a..26bed7c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java @@ -92,7 +92,7 @@ public class Commands { if(fightTeam == null || checkGetLeader(p) == null) return; - fightTeam.skip(); + fightTeam.setReady(!fightTeam.isReady()); } static void toggleSkip(Player p){ @@ -100,7 +100,7 @@ public class Commands { if(fightTeam == null || checkGetLeader(p) == null) return; - fightTeam.setReady(!fightTeam.isReady()); + fightTeam.skip(); } static void acceptInvitation(Player p){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java index 0ae81ef..8b99fdc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -1,16 +1,32 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package de.steamwar.fightsystem.fight; -import de.steamwar.core.events.ChunkListener; +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 net.minecraft.server.v1_15_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.entity.Player; public class FightWorld extends StateDependent { @@ -35,16 +51,12 @@ public class FightWorld extends StateDependent { } private void resetChunk(World backup, int x, int z){ - Chunk chunk = ((CraftWorld) world).getHandle().getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - chunk.heightMap.clear(); - chunk.heightMap.putAll(backupChunk.heightMap); - for(Player p : Bukkit.getOnlinePlayers()){ - ChunkListener.sendChunk(p, x, z); - } + VersionedRunnable.call( + new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z), 8), + new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z), 9), + new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z), 10), + new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z), 12), + new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z), 14), + new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z), 15)); } }