2021-03-24 11:21:17 +01:00
|
|
|
/*
|
|
|
|
This file is a part of the SteamWar software.
|
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
Copyright (C) 2021 SteamWar.de-Serverteam
|
2021-03-24 11:21:17 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2021-08-31 10:42:42 +02:00
|
|
|
*/
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
package de.steamwar.fightsystem.utils;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2022-03-29 20:47:33 +02:00
|
|
|
import de.steamwar.fightsystem.Config;
|
2021-08-31 10:42:42 +02:00
|
|
|
import de.steamwar.fightsystem.fight.FightWorld;
|
2021-03-24 11:21:17 +01:00
|
|
|
import net.minecraft.server.v1_9_R2.Chunk;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
2021-04-09 14:45:09 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
|
|
|
|
import org.bukkit.entity.Entity;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2022-03-29 20:47:33 +02:00
|
|
|
import java.util.stream.Stream;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2022-04-09 16:14:03 +02:00
|
|
|
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
2021-08-31 10:42:42 +02:00
|
|
|
@Override
|
|
|
|
public void resetChunk(World world, World backup, int x, int z) {
|
2021-03-24 11:21:17 +01:00
|
|
|
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());
|
2021-08-31 10:42:42 +02:00
|
|
|
if (!FightWorld.isPaper()) {
|
2021-04-12 16:37:09 +02:00
|
|
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
|
|
|
}
|
2021-03-24 11:21:17 +01:00
|
|
|
chunk.tileEntities.clear();
|
|
|
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
|
|
|
}
|
2021-04-09 14:45:09 +02:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
@Override
|
|
|
|
public float headRotation(Entity e) {
|
2021-04-09 14:45:09 +02:00
|
|
|
return ((CraftEntity)e).getHandle().getHeadRotation();
|
|
|
|
}
|
2021-08-31 10:42:42 +02:00
|
|
|
|
2022-03-29 20:47:33 +02:00
|
|
|
@Override
|
2022-04-09 16:14:03 +02:00
|
|
|
public Stream<?> entityIterator() {
|
2022-03-29 20:47:33 +02:00
|
|
|
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
|
|
|
}
|
2021-03-24 11:21:17 +01:00
|
|
|
}
|