2021-03-24 11:32:41 +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:32:41 +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:32:41 +01:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
package de.steamwar.fightsystem.utils;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
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_12_R1.Chunk;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
2021-04-09 14:45:09 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
|
|
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
2021-08-31 10:42:42 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
2021-04-09 14:45:09 +02:00
|
|
|
import org.bukkit.entity.Entity;
|
2021-03-24 11:21:17 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2021-08-31 10:42:42 +02:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
2021-03-24 11:21:17 +01:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
|
|
|
@Override
|
|
|
|
public void resetChunk(World world, World backup, int x, int z) {
|
2021-03-24 11:21:17 +01:00
|
|
|
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());
|
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 void sendResourcePack(Player player, String pack, String sha1) {
|
2021-04-09 14:45:09 +02:00
|
|
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasItems(ItemStack stack) {
|
|
|
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
|
|
|
keys.remove("Enchantments");
|
|
|
|
keys.remove("Damage");
|
|
|
|
return !keys.isEmpty();
|
|
|
|
}
|
2021-03-24 11:21:17 +01:00
|
|
|
}
|