Multiversion simplification & 1.19.3 compatibility
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
239c0bf5f6
Commit
f29bf025e6
@ -25,14 +25,8 @@ import net.minecraft.server.v1_10_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
||||
@ -52,24 +46,11 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
|
@ -25,14 +25,8 @@ import net.minecraft.server.v1_12_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
||||
@ -52,24 +46,11 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
|
@ -19,32 +19,41 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||
|
||||
private static final Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
|
||||
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
|
||||
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
|
||||
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
|
||||
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||
|
||||
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
||||
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||
return (int) getCombinedId.invoke(null, getNMS.invoke(block));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
||||
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
|
||||
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
||||
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
||||
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
||||
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
||||
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
||||
@Override
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.fromId(blockState));
|
||||
WorldServer cworld = ((CraftWorld)world).getHandle();
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
cworld.removeTileEntity(pos);
|
||||
cworld.setTypeAndData(pos, blockData, 1042);
|
||||
cworld.getChunkProvider().flagDirty(pos);
|
||||
}
|
||||
Object blockData = getByCombinedId.invoke(null, blockState);
|
||||
Object nworld = getWorldHandle.invoke(world);
|
||||
Object pos = newBlockPosition.invoke(x, y, z);
|
||||
|
||||
@Override
|
||||
public Object getPose(boolean sneaking) {
|
||||
return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING;
|
||||
removeTileEntity.invoke(nworld, pos);
|
||||
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
||||
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,8 @@ import net.minecraft.server.v1_14_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
||||
@ -53,24 +47,11 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
||||
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockIdWrapper15 implements BlockIdWrapper {
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.fromId(blockState));
|
||||
WorldServer cworld = ((CraftWorld)world).getHandle();
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
cworld.removeTileEntity(pos);
|
||||
cworld.setTypeAndData(pos, blockData, 1042);
|
||||
cworld.getChunkProvider().flagDirty(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPose(boolean sneaking) {
|
||||
return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING;
|
||||
}
|
||||
}
|
@ -25,14 +25,8 @@ import net.minecraft.server.v1_15_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
||||
@ -53,24 +47,11 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
||||
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.EntityPose;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockIdWrapper18 implements BlockIdWrapper {
|
||||
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
return net.minecraft.world.level.block.Block.i(((CraftBlock)block).getNMS());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
IBlockData blockData = Objects.requireNonNull(net.minecraft.world.level.block.Block.a(blockState));
|
||||
WorldServer cworld = ((CraftWorld)world).getHandle();
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
cworld.m(pos);
|
||||
cworld.a(pos, blockData, 1042);
|
||||
cworld.k().a(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPose(boolean sneaking) {
|
||||
return sneaking ? EntityPose.f : EntityPose.a;
|
||||
}
|
||||
}
|
@ -19,53 +19,47 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.ChunkSection;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import org.bukkit.World;
|
||||
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;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
||||
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.d(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
||||
private static final Reflection.MethodInvoker getWorld = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", net.minecraft.world.level.World.class);
|
||||
private static final Reflection.MethodInvoker getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
|
||||
private static final Reflection.MethodInvoker getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
|
||||
private ChunkSection[] getChunkSections(World world, int x, int z) {
|
||||
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().a(pack, sha1, true, null);
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
ChunkSection[] sections = getChunkSections(world, x, z);
|
||||
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getEntity = Reflection.getTypedMethod(Reflection.getClass("{obc}.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
|
||||
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
|
||||
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().ce();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).t().d());
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
return getEntity(e).ce();
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
|
||||
private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().H().a().spliterator(), false);
|
||||
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.EntityPose;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockIdWrapper19 implements BlockIdWrapper {
|
||||
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
return net.minecraft.world.level.block.Block.i(((CraftBlock)block).getNMS());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
IBlockData blockData = Objects.requireNonNull(net.minecraft.world.level.block.Block.a(blockState));
|
||||
WorldServer cworld = ((CraftWorld)world).getHandle();
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
cworld.m(pos);
|
||||
cworld.a(pos, blockData, 1042);
|
||||
cworld.k().a(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPose(boolean sneaking) {
|
||||
return sneaking ? EntityPose.f : EntityPose.a;
|
||||
}
|
||||
}
|
@ -19,53 +19,12 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class CraftbukkitWrapper19 implements CraftbukkitWrapper {
|
||||
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.d(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().a(pack, sha1, true, null);
|
||||
}
|
||||
public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 {
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().cg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).u().d());
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().F().a().spliterator(), false);
|
||||
return getEntity(e).ck();
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,4 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
|
||||
|
||||
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPose(boolean sneaking) {
|
||||
return Byte.valueOf((byte)(sneaking ? 2 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -24,14 +24,8 @@ import net.minecraft.server.v1_8_R3.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
|
||||
@ -49,24 +43,11 @@ public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
|
@ -25,14 +25,8 @@ import net.minecraft.server.v1_9_R2.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
||||
@ -52,24 +46,11 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(Player player, String pack, String sha1) {
|
||||
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
|
@ -19,10 +19,8 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
@ -34,9 +32,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Fight {
|
||||
private Fight(){}
|
||||
@ -146,22 +142,8 @@ public class Fight {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Class<?> playerInfoActionClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction");
|
||||
private static final Reflection.FieldAccessor<?> playerInfoAction = Reflection.getField(ProtocolWrapper.playerInfoPacket, playerInfoActionClass, 0);
|
||||
private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1];
|
||||
private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(ProtocolWrapper.playerInfoPacket, List.class, 0);
|
||||
public static final Object creative = ProtocolWrapper.enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 1 : 2];
|
||||
private static final Object spectator = ProtocolWrapper.enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 3 : 4];
|
||||
|
||||
public static void pseudoSpectator(Player player, boolean enable) {
|
||||
TinyProtocol.instance.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator));
|
||||
}
|
||||
|
||||
public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
|
||||
Object packet = Reflection.newInstance(ProtocolWrapper.playerInfoPacket);
|
||||
playerInfoAction.set(packet, action);
|
||||
playerInfoData.set(packet, Collections.singletonList(ProtocolWrapper.impl.playerInfoDataConstructor(packet, profile, mode)));
|
||||
return packet;
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
|
||||
}
|
||||
|
||||
public static int getMaxRank(){
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.commands.Commands;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -211,7 +211,7 @@ public class Kit {
|
||||
if(FlatteningWrapper.impl.containsBlockMeta(meta))
|
||||
return true; //Blocks always upwards slabs etc.
|
||||
|
||||
if(CraftbukkitWrapper.impl.hasItems(stack))
|
||||
if(hasItems(stack))
|
||||
return true; //Blocks prefilled inventories
|
||||
}
|
||||
|
||||
@ -220,6 +220,18 @@ public class Kit {
|
||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||
}
|
||||
|
||||
private static final Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
|
||||
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
|
||||
private static final Class<?> nbtTagCompound = Reflection.getClass("{nms.nbt}.NBTTagCompound");
|
||||
private static final Reflection.MethodInvoker getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound);
|
||||
private static final Reflection.MethodInvoker getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class);
|
||||
public static boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>((Set<String>) getKeys.invoke(getTag.invoke(asNMSCopy.invoke(null, stack))));
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isEnchantmentInKit(ItemStack stack){
|
||||
for(ItemStack is : inventory){
|
||||
if(similar(stack, is))
|
||||
|
@ -29,6 +29,4 @@ public interface BlockIdWrapper {
|
||||
|
||||
int blockToId(Block block);
|
||||
void setBlock(World world, int x, int y, int z, int blockState);
|
||||
|
||||
Object getPose(boolean sneaking);
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ import de.steamwar.core.VersionDependent;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -32,9 +30,7 @@ public interface CraftbukkitWrapper {
|
||||
CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
void resetChunk(World world, World backup, int x, int z);
|
||||
void sendResourcePack(Player player, String pack, String sha1);
|
||||
float headRotation(Entity e);
|
||||
boolean hasItems(ItemStack stack);
|
||||
|
||||
Stream<?> entityIterator();
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren