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
|
|
|
|
|
|
|
import net.minecraft.server.v1_8_R3.Chunk;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
2021-04-09 14:45:09 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
|
|
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
2021-08-31 10:42:42 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_8_R3.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 CraftbukkitWrapper8 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_8_R3.World w = ((CraftWorld) world).getHandle();
|
|
|
|
Chunk chunk = w.getChunkAt(x, z);
|
2021-09-03 17:32:49 +02:00
|
|
|
((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true;
|
2021-03-24 11:21:17 +01:00
|
|
|
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.tileEntityList.removeAll(chunk.tileEntities.values());
|
|
|
|
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
|
|
|
}
|