SteamWar/FightSystem
Archiviert
13
1

Reenable Items #373

Zusammengeführt
Lixfel hat 8 Commits von items nach master 2023-05-09 16:43:14 +02:00 zusammengeführt
31 geänderte Dateien mit 159 neuen und 437 gelöschten Zeilen
Nur Änderungen aus Commit cb4cb1d6fe werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -25,14 +25,8 @@ import net.minecraft.server.v1_10_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper10 implements CraftbukkitWrapper { public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
@ -52,24 +46,11 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -25,14 +25,8 @@ import net.minecraft.server.v1_12_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper12 implements CraftbukkitWrapper { public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
@ -52,24 +46,11 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -19,32 +19,41 @@
package de.steamwar.fightsystem.utils; 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.World;
import org.bukkit.block.Block; 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 { 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 @Override
public int blockToId(Block block) { 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 @Override
public void setBlock(World world, int x, int y, int z, int blockState) { 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)); Object blockData = getByCombinedId.invoke(null, blockState);
WorldServer cworld = ((CraftWorld)world).getHandle(); Object nworld = getWorldHandle.invoke(world);
BlockPosition pos = new BlockPosition(x, y, z); Object pos = newBlockPosition.invoke(x, y, z);
cworld.removeTileEntity(pos);
cworld.setTypeAndData(pos, blockData, 1042);
cworld.getChunkProvider().flagDirty(pos);
}
@Override removeTileEntity.invoke(nworld, pos);
public Object getPose(boolean sneaking) { getTypeAndData.invoke(nworld, pos, blockData, 1042);
return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING; flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
} }
} }

Datei anzeigen

@ -25,14 +25,8 @@ import net.minecraft.server.v1_14_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper14 implements CraftbukkitWrapper { public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
@ -53,24 +47,11 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
chunk.heightMap.putAll(backupChunk.heightMap); chunk.heightMap.putAll(backupChunk.heightMap);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -25,14 +25,8 @@ import net.minecraft.server.v1_15_R1.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper15 implements CraftbukkitWrapper { public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
@ -53,24 +47,11 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
chunk.heightMap.putAll(backupChunk.heightMap); chunk.heightMap.putAll(backupChunk.heightMap);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -19,53 +19,47 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.chunk.Chunk; 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.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.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.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
public class CraftbukkitWrapper18 implements CraftbukkitWrapper { public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
@Override private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle");
public void resetChunk(World world, World backup, int x, int z) { private static final Reflection.MethodInvoker getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle(); private static final Reflection.MethodInvoker getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
Chunk chunk = w.d(x, z); private ChunkSection[] getChunkSections(World world, int x, int z) {
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z); return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
} }
@Override @Override
public void sendResourcePack(Player player, String pack, String sha1) { public void resetChunk(World world, World backup, int x, int z) {
((CraftPlayer)player).getHandle().a(pack, sha1, true, null); 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 @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().ce(); return getEntity(e).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();
} }
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 @Override
public Stream<?> entityIterator() { 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);
} }
} }

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -19,53 +19,12 @@
package de.steamwar.fightsystem.utils; 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.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet; public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 {
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);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().cg(); return getEntity(e).ck();
}
@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);
} }
} }

Datei anzeigen

@ -37,9 +37,4 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false); 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));
}
} }

Datei anzeigen

@ -24,14 +24,8 @@ import net.minecraft.server.v1_8_R3.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper8 implements CraftbukkitWrapper { public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
@ -49,24 +43,11 @@ public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -25,14 +25,8 @@ import net.minecraft.server.v1_9_R2.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; 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.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.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.Stream;
public class CraftbukkitWrapper9 implements CraftbukkitWrapper { public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
@ -52,24 +46,11 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
chunk.tileEntities.putAll(backupChunk.tileEntities); chunk.tileEntities.putAll(backupChunk.tileEntities);
} }
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
@Override @Override
public float headRotation(Entity e) { public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation(); 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 @Override
public Stream<?> entityIterator() { public Stream<?> entityIterator() {
return ((CraftWorld) Config.world).getHandle().entityList.stream(); return ((CraftWorld) Config.world).getHandle().entityList.stream();

Datei anzeigen

@ -72,6 +72,8 @@ Schematic:
ReplaceObsidianBedrock: false # defaults to false if missing ReplaceObsidianBedrock: false # defaults to false if missing
# If the replacement should happen with block updates # If the replacement should happen with block updates
ReplaceWithBlockupdates: false # defaults to false if missing ReplaceWithBlockupdates: false # defaults to false if missing
# If the schematic perparation arena mode is time limited
UnlimitedPrepare: false # defaults to false if missing
# Maximal amount of blocks allowed in the schematic # Maximal amount of blocks allowed in the schematic
MaxBlocks: 0 # defaults to 0 (ignored) if missing MaxBlocks: 0 # defaults to 0 (ignored) if missing
# Maximal amount of items per dispenser # Maximal amount of items per dispenser

Datei anzeigen

@ -61,6 +61,7 @@ public class Config {
public static final Region BlueExtendRegion; public static final Region BlueExtendRegion;
public static final Region RedExtendRegion; public static final Region RedExtendRegion;
public static final Region ArenaRegion; public static final Region ArenaRegion;
public static final Region PlayerRegion;
public static final Location TeamBlueSpawn; public static final Location TeamBlueSpawn;
public static final Location TeamRedSpawn; public static final Location TeamRedSpawn;
@ -87,6 +88,7 @@ public class Config {
public static final boolean PasteAligned; public static final boolean PasteAligned;
public static final boolean ReplaceObsidianBedrock; public static final boolean ReplaceObsidianBedrock;
public static final boolean ReplaceWithBlockupdates; public static final boolean ReplaceWithBlockupdates;
public static final boolean UnlimitedPrepare;
//team parameter //team parameter
public static final String TeamRedName; public static final String TeamRedName;
@ -184,6 +186,7 @@ public class Config {
PasteAligned = config.getBoolean("Schematic.PasteAligned", false); PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false); ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false);
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false); ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
GameName = config.getString("GameName", "WarGear"); GameName = config.getString("GameName", "WarGear");
TeamChatDetection = config.getString("TeamChatPrefix", "+"); TeamChatDetection = config.getString("TeamChatPrefix", "+");
@ -300,14 +303,13 @@ public class Config {
RedRotate = teamRedRotate; RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate; BlueRotate = teamBlueRotate;
int arenaYSize = blueCornerY - underBorder + schemsizeY + PreperationArea;
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ); BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ); ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){ if(EventKampfID >= 1){

Datei anzeigen

@ -29,6 +29,9 @@ public class PostSchemCountdown extends Countdown {
public PostSchemCountdown() { public PostSchemCountdown() {
super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false); super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
if(Config.mode == ArenaMode.PREPARE && Config.UnlimitedPrepare)
return;
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this); new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
} }

Datei anzeigen

@ -19,10 +19,8 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import de.steamwar.core.Core;
import de.steamwar.core.ProtocolWrapper; import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
@ -34,9 +32,7 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
public class Fight { public class Fight {
private 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) { public static void pseudoSpectator(Player player, boolean enable) {
TinyProtocol.instance.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator)); TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.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;
} }
public static int getMaxRank(){ public static int getMaxRank(){

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.Permanent;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
@ -121,11 +122,7 @@ public class FightTeam {
new KitLoader(); new KitLoader();
new SpectateHandler(); new SpectateHandler();
if(FightScoreboard.getBukkit().getTeam(name) == null) team = FightScoreboard.getBukkitTeam(name);
team = FightScoreboard.getBukkit().registerNewTeam(name);
else
team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
WorldOfColorWrapper.impl.setTeamColor(team, color); WorldOfColorWrapper.impl.setTeamColor(team, color);
BountifulWrapper.impl.setNametagVisibility(team); BountifulWrapper.impl.setNametagVisibility(team);
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
@ -252,6 +249,7 @@ public class FightTeam {
FightPlayer fightPlayer = new FightPlayer(player, this); FightPlayer fightPlayer = new FightPlayer(player, this);
players.put(player, fightPlayer); players.put(player, fightPlayer);
invited.remove(player); invited.remove(player);
Permanent.getSpectatorTeam().removeEntry(player.getName());
team.addEntry(player.getName()); team.addEntry(player.getName());
Fight.setPlayerGamemode(player, GameMode.SURVIVAL); Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
@ -277,6 +275,7 @@ public class FightTeam {
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true); List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
players.remove(player); players.remove(player);
team.removeEntry(player.getName()); team.removeEntry(player.getName());
Permanent.getSpectatorTeam().addEntry(player.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName()); FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName());

Datei anzeigen

@ -19,12 +19,12 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.Commands; import de.steamwar.fightsystem.commands.Commands;
import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
@ -223,7 +223,7 @@ public class Kit {
if(FlatteningWrapper.impl.containsBlockMeta(meta)) if(FlatteningWrapper.impl.containsBlockMeta(meta))
return true; //Blocks always upwards slabs etc. return true; //Blocks always upwards slabs etc.
if(CraftbukkitWrapper.impl.hasItems(stack)) if(hasItems(stack))
return true; //Blocks prefilled inventories return true; //Blocks prefilled inventories
} }
@ -232,6 +232,18 @@ public class Kit {
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty(); 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){ private boolean isEnchantmentInKit(ItemStack stack){
for(ItemStack is : inventory){ for(ItemStack is : inventory){
if(similar(stack, is)) if(similar(stack, is))

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,40 +40,39 @@ public class ArenaBorder implements Listener {
public ArenaBorder() { public ArenaBorder() {
new StateDependentListener(ArenaMode.All, FightState.All, this); new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
} }
@EventHandler @EventHandler
public void arenaBorder(PlayerMoveEvent event){ public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer(); Player player = event.getPlayer();
if(Config.ArenaLeaveable && !Fight.fighting(player)) FightTeam team = Fight.getPlayerTeam(player);
if(Config.ArenaLeaveable && team == null)
return; return;
Location to = event.getTo(); Location to = event.getTo();
assert to != null; assert to != null;
if(!Config.ArenaRegion.in2dRegion(to)){ if(Config.PlayerRegion.inRegion(to))
reset(event);
return; return;
}
FightTeam team = Fight.getPlayerTeam(player); if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) {
if(team == null || player.getGameMode() == GameMode.SPECTATOR){ if(!Config.GroundWalkable && !FightState.infight())
if(to.getY() <= Config.ArenaRegion.getMinY())
reset(event);
return;
}
if(to.getY() <= Config.ArenaRegion.getMinY()) {
if(FightState.infight())
player.damage(2);
else if(!Config.GroundWalkable)
player.teleport(team.getSpawn()); player.teleport(team.getSpawn());
}
}
private void reset(PlayerMoveEvent event){ return;
Player player = event.getPlayer(); }
player.teleport(event.getFrom()); player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR); FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
} }
private void damage() {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam team = Fight.getPlayerTeam(player);
if(team != null && player.getLocation().getY() <= Config.PlayerRegion.getMinY())
player.damage(1);
}
}
} }

Datei anzeigen

@ -19,7 +19,9 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,10 +42,14 @@ public class ClickAnalyzer {
public ClickAnalyzer() { public ClickAnalyzer() {
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
if(Core.getVersion() > 8)
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"), this::onBlockPlace);
} }
public Object onBlockPlace(Player player, Object packet) { public Object onBlockPlace(Player player, Object packet) {
output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch()); synchronized(output) {
output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch());
}
return packet; return packet;
} }

Datei anzeigen

@ -30,14 +30,20 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects; import java.util.Objects;
public class FightScoreboard implements Listener, ScoreboardCallback { public class FightScoreboard implements Listener, ScoreboardCallback {
public static Scoreboard getBukkit() { public static Team getBukkitTeam(String name) {
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
Team team = scoreboard.getTeam(name);
if(team != null)
return team;
return scoreboard.registerNewTeam(name);
} }
private static FightScoreboard scoreboard; private static FightScoreboard scoreboard;

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -48,10 +49,22 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class Permanent implements Listener { public class Permanent implements Listener {
private static final Team spectatorTeam = FightScoreboard.getBukkitTeam("Spectator");
static {
BountifulWrapper.impl.setNametagVisibility(spectatorTeam);
spectatorTeam.setNameTagVisibility(NameTagVisibility.NEVER);
}
public static Team getSpectatorTeam() {
return spectatorTeam;
}
public Permanent() { public Permanent() {
new StateDependentListener(ArenaMode.All, FightState.All, this); new StateDependentListener(ArenaMode.All, FightState.All, this);
} }
@ -84,6 +97,7 @@ public class Permanent implements Listener {
if (!Config.ArenaLeaveable && !Fight.fighting(player)) { if (!Config.ArenaLeaveable && !Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
spectatorTeam.addEntry(player.getName());
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
} }
} }

Datei anzeigen

@ -37,6 +37,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -108,6 +109,15 @@ public class PersonalKitCreator implements Listener {
backup.close(); backup.close();
} }
@EventHandler
public void onOpenEvent(InventoryOpenEvent e){
InventoryBackup backup = openKitCreators.get(e.getPlayer());
if(backup == null)
return;
backup.close();
}
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent e) { public void onInventoryClose(InventoryCloseEvent e) {
InventoryBackup backup = openKitCreators.get(e.getPlayer()); InventoryBackup backup = openKitCreators.get(e.getPlayer());

Datei anzeigen

@ -50,6 +50,7 @@ public class FileSource extends PacketSource {
public FileSource(File fightFile) throws IOException { public FileSource(File fightFile) throws IOException {
super(new GZIPInputStream(new FileInputStream(fightFile))); super(new GZIPInputStream(new FileInputStream(fightFile)));
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -31,6 +31,7 @@ public class LiveSource extends PacketSource {
protected LiveSource(Socket socket) throws IOException { protected LiveSource(Socket socket) throws IOException {
super(socket.getInputStream()); super(socket.getInputStream());
this.socket = socket; this.socket = socket;
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -56,6 +56,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scoreboard.NameTagVisibility;
import java.io.EOFException; import java.io.EOFException;
import java.io.FilterInputStream; import java.io.FilterInputStream;
@ -66,16 +67,11 @@ import java.util.stream.Collectors;
public class PacketProcessor implements Listener { public class PacketProcessor implements Listener {
/*private static final String SCOREBOARD_TEAMNAME = "Replay"; private static final org.bukkit.scoreboard.Team team = FightScoreboard.getBukkitTeam("Replay");
private static final Team team;
static { static {
if(FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME) == null) BountifulWrapper.impl.setNametagVisibility(team);
team = FightScoreboard.getBukkit().registerNewTeam(SCOREBOARD_TEAMNAME);
else
team = FightScoreboard.getBukkit().getTeam(SCOREBOARD_TEAMNAME);
team.setNameTagVisibility(NameTagVisibility.NEVER); team.setNameTagVisibility(NameTagVisibility.NEVER);
}*/ }
private static PacketProcessor currentProcessor = null; private static PacketProcessor currentProcessor = null;
@ -125,7 +121,8 @@ public class PacketProcessor implements Listener {
packetDecoder[0x0a] = this::bow; packetDecoder[0x0a] = this::bow;
packetDecoder[0x0b] = this::damage; packetDecoder[0x0b] = this::damage;
packetDecoder[0x0c] = this::fireTick; packetDecoder[0x0c] = this::fireTick;
packetDecoder[0x20] = this::arenaInfo; packetDecoder[0x20] = this::oldArenaInfo;
packetDecoder[0x21] = this::arenaInfo;
packetDecoder[0x30] = this::byteWorldHeightBlock; packetDecoder[0x30] = this::byteWorldHeightBlock;
packetDecoder[0x31] = this::particle; packetDecoder[0x31] = this::particle;
packetDecoder[0x32] = this::sound; packetDecoder[0x32] = this::sound;
@ -239,6 +236,7 @@ public class PacketProcessor implements Listener {
execSync(() -> { execSync(() -> {
SteamwarUser user = SteamwarUser.get(userId); SteamwarUser user = SteamwarUser.get(userId);
entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn)); entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
team.addEntry(user.getUserName());
}); });
} }
@ -370,13 +368,20 @@ public class PacketProcessor implements Listener {
Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix)); Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix));
} }
private void arenaInfo() throws IOException { private void oldArenaInfo() throws IOException {
rotateZ = source.readBoolean() != Config.blueNegZ(); rotateZ = source.readBoolean() != Config.blueNegZ();
arenaMinY = Byte.toUnsignedInt(source.readByte()); arenaMinY = Byte.toUnsignedInt(source.readByte());
arenaMinX = source.readInt(); arenaMinX = source.readInt();
arenaMinZ = source.readInt(); arenaMinZ = source.readInt();
} }
private void arenaInfo() throws IOException {
rotateZ = source.readBoolean() != Config.blueNegZ();
arenaMinX = source.readInt();
arenaMinY = source.readInt();
arenaMinZ = source.readInt();
}
private void shortBlock() throws IOException { private void shortBlock() throws IOException {
int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX(); int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX();
int y = Byte.toUnsignedInt(source.readByte()); int y = Byte.toUnsignedInt(source.readByte());
@ -615,7 +620,7 @@ public class PacketProcessor implements Listener {
} }
private void tick(){ private void tick(){
entityServer.tick(); execSync(entityServer::tick);
if(!source.async() && !skipToSubtitle) if(!source.async() && !skipToSubtitle)
tickFinished = true; tickFinished = true;

Datei anzeigen

@ -30,7 +30,6 @@ public abstract class PacketSource extends DataInputStream {
protected PacketSource(InputStream inputStream){ protected PacketSource(InputStream inputStream){
super(inputStream); super(inputStream);
new PacketProcessor(this);
} }
@Override @Override

Datei anzeigen

@ -98,7 +98,8 @@ public interface Recorder {
* PlayerDamagePacket (0x0b) + int EntityId * PlayerDamagePacket (0x0b) + int EntityId
* SetOnFire (0x0c) + int EntityId + boolean perma * SetOnFire (0x0c) + int EntityId + boolean perma
* *
* ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ * DEPRECATED ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ
* ArenaInfo (0x21) + bool blueNegZ + int arenaMinX + int arenaMinY + int arenaMinZ
* *
* DEPRECATED BlockPacket (0x30) + pos int, byte, int + int BlockState * DEPRECATED BlockPacket (0x30) + pos int, byte, int + int BlockState
* ParticlePacket (0x31) + double x, y, z + string particleType * ParticlePacket (0x31) + double x, y, z + string particleType
@ -213,8 +214,7 @@ public interface Recorder {
} }
default void arenaInfo(){ default void arenaInfo(){
write(0x20, Config.blueNegZ(), (byte)Config.BluePasteRegion.getMinY(), write(0x21, Config.blueNegZ(), Config.ArenaRegion.getMinX(), Config.BluePasteRegion.getMinY(), Config.ArenaRegion.getMinZ());
Config.ArenaRegion.getMinX(), Config.ArenaRegion.getMinZ());
} }
default void blockChange(Block block){ default void blockChange(Block block){

Datei anzeigen

@ -29,6 +29,4 @@ public interface BlockIdWrapper {
int blockToId(Block block); int blockToId(Block block);
void setBlock(World world, int x, int y, int z, int blockState); void setBlock(World world, int x, int y, int z, int blockState);
Object getPose(boolean sneaking);
} }

Datei anzeigen

@ -23,8 +23,6 @@ import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -32,9 +30,7 @@ public interface CraftbukkitWrapper {
CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
void resetChunk(World world, World backup, int x, int z); void resetChunk(World world, World backup, int x, int z);
void sendResourcePack(Player player, String pack, String sha1);
float headRotation(Entity e); float headRotation(Entity e);
boolean hasItems(ItemStack stack);
Stream<?> entityIterator(); Stream<?> entityIterator();
} }