2022-01-14 18:58:00 +01:00
|
|
|
/*
|
|
|
|
This file is a part of the SteamWar software.
|
|
|
|
|
|
|
|
Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package de.steamwar.fightsystem.utils;
|
|
|
|
|
2022-02-02 23:58:45 +01:00
|
|
|
import net.minecraft.world.level.chunk.Chunk;
|
2022-01-14 18:58:00 +01:00
|
|
|
import org.bukkit.World;
|
2022-03-29 16:45:10 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
|
|
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
|
|
|
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
|
|
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
2022-01-14 18:58:00 +01:00
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resetChunk(World world, World backup, int x, int z) {
|
2022-02-02 23:58:45 +01:00
|
|
|
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
|
|
|
|
Chunk chunk = w.d(x, z);
|
|
|
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
2022-01-14 18:58:00 +01:00
|
|
|
|
2022-02-02 23:58:45 +01:00
|
|
|
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
2022-01-14 18:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void sendResourcePack(Player player, String pack, String sha1) {
|
2022-02-02 23:58:45 +01:00
|
|
|
((CraftPlayer)player).getHandle().a(pack, sha1, true, null);
|
2022-01-14 18:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float headRotation(Entity e) {
|
2022-02-02 23:58:45 +01:00
|
|
|
return ((CraftEntity)e).getHandle().ce();
|
2022-01-14 18:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasItems(ItemStack stack) {
|
2022-03-29 16:45:10 +02:00
|
|
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).t().d());
|
2022-01-14 18:58:00 +01:00
|
|
|
keys.remove("Enchantments");
|
|
|
|
keys.remove("Damage");
|
|
|
|
return !keys.isEmpty();
|
|
|
|
}
|
|
|
|
}
|