SteamWar/FightSystem
Archiviert
13
1

Added paper-compatibility

Dieser Commit ist enthalten in:
Zeanon 2021-04-12 16:37:09 +02:00
Ursprung 63d8da1f94
Commit 5b2947daea
9 geänderte Dateien mit 33 neuen und 38 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.entity.Player;
public class FightWorld_10 { public class FightWorld_10 {
private FightWorld_10(){} private FightWorld_10(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@ -40,7 +40,9 @@ public class FightWorld_10 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!isPaper) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear(); chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
for(Player p : Bukkit.getOnlinePlayers()){ for(Player p : Bukkit.getOnlinePlayers()){

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.entity.Player;
public class FightWorld_12 { public class FightWorld_12 {
private FightWorld_12(){} private FightWorld_12(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@ -40,7 +40,9 @@ public class FightWorld_12 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!isPaper) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear(); chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
for(Player p : Bukkit.getOnlinePlayers()){ for(Player p : Bukkit.getOnlinePlayers()){

Datei anzeigen

@ -32,14 +32,16 @@ import org.bukkit.entity.Player;
public class FightWorld_14 { public class FightWorld_14 {
private FightWorld_14(){} private FightWorld_14(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().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.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!isPaper) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear(); chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
chunk.heightMap.clear(); chunk.heightMap.clear();

Datei anzeigen

@ -32,14 +32,16 @@ import org.bukkit.entity.Player;
public class FightWorld_15 { public class FightWorld_15 {
private FightWorld_15(){} private FightWorld_15(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().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.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!isPaper) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear(); chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
chunk.heightMap.clear(); chunk.heightMap.clear();

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.entity.Player;
public class FightWorld_8 { public class FightWorld_8 {
private FightWorld_8(){} private FightWorld_8(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.entity.Player;
public class FightWorld_9 { public class FightWorld_9 {
private FightWorld_9(){} private FightWorld_9(){}
static void resetChunk(World world, World backup, int x, int z){ static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle(); net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
@ -40,7 +40,9 @@ public class FightWorld_9 {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!isPaper) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear(); chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
for(Player p : Bukkit.getOnlinePlayers()){ for(Player p : Bukkit.getOnlinePlayers()){

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentCountdown;
@ -30,12 +29,8 @@ public class EventSpectateCountdown extends Countdown {
public EventSpectateCountdown() { public EventSpectateCountdown() {
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false); super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
if(FightWorld.isPaper()){
new StateDependentCountdown(ArenaMode.Fight, FightState.Spectate, this);
}else{
new StateDependentCountdown(ArenaMode.Event, FightState.Spectate, this); new StateDependentCountdown(ArenaMode.Event, FightState.Spectate, this);
} }
}
@Override @Override
public String countdownCounting() { public String countdownCounting() {

Datei anzeigen

@ -30,10 +30,8 @@ public class SpectateOverCountdown extends Countdown {
public SpectateOverCountdown() { public SpectateOverCountdown() {
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false); super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
if(!FightWorld.isPaper()){
new StateDependentCountdown(ArenaMode.Restartable, FightState.Spectate, this); new StateDependentCountdown(ArenaMode.Restartable, FightState.Spectate, this);
} }
}
@Override @Override
public String countdownCounting() { public String countdownCounting() {

Datei anzeigen

@ -35,21 +35,13 @@ public class FightWorld extends StateDependent {
private static final boolean paper; private static final boolean paper;
static{ static{
boolean ispaper; paper = Bukkit.getVersion().contains("git-Paper");
try {
Class.forName("com.destroystokyo.paper.PaperConfig");
ispaper = true;
} catch (ClassNotFoundException e) {
ispaper = false;
}
paper = ispaper;
} }
private final World world = Bukkit.getWorlds().get(0); private final World world = Bukkit.getWorlds().get(0);
public FightWorld() { public FightWorld() {
super(ArenaMode.Restartable, FightState.Schem); super(ArenaMode.Restartable, FightState.Schem);
if(!isPaper())
register(); register();
} }
@ -72,17 +64,17 @@ public class FightWorld extends StateDependent {
World backup = new WorldCreator(world.getName() + "/backup").createWorld(); World backup = new WorldCreator(world.getName() + "/backup").createWorld();
assert backup != null; assert backup != null;
Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z)); Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z, FightWorld.isPaper()));
Bukkit.unloadWorld(backup, false); Bukkit.unloadWorld(backup, false);
} }
private void resetChunk(World backup, int x, int z){ private void resetChunk(World backup, int x, int z, boolean isPaper){
VersionedRunnable.call( VersionedRunnable.call(
new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z), 8), new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z, isPaper), 8),
new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z), 9), new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z, isPaper), 9),
new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z), 10), new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z, isPaper), 10),
new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z), 12), new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z, isPaper), 12),
new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z), 14), new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z, isPaper), 14),
new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z), 15)); new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z, isPaper), 15));
} }
} }