Many methods in ServerManager now static
This commit is contained in:
1 parent
794ad6b042
commit
87223f8df1
4 files changed
+32
-32
No files matched your search
@@ -73,7 +73,7 @@ public final class PacketEvents implements Listener {
|
||||
try {
|
||||
MinecraftReflection.init();
|
||||
|
||||
serverManager.entityCache = GuavaUtils.makeMap();
|
||||
ServerManager.entityCache = GuavaUtils.makeMap();
|
||||
} catch (Exception ex) {
|
||||
throw new PacketEventsLoadFailureException(ex);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import java.util.Map;
|
||||
|
||||
public final class ServerManager {
|
||||
//Initialized in PacketEvents#load
|
||||
public Map<Integer, Entity> entityCache;
|
||||
public static Map<Integer, Entity> entityCache;
|
||||
private static final ServerVersion version;
|
||||
|
||||
static {
|
||||
@@ -63,7 +63,7 @@ public final class ServerManager {
|
||||
*
|
||||
* @return Get Recent TPS
|
||||
*/
|
||||
public double[] getRecentTPS() {
|
||||
public static double[] getRecentTPS() {
|
||||
return MinecraftReflection.recentTPS();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class ServerManager {
|
||||
*
|
||||
* @return Get Current TPS
|
||||
*/
|
||||
public double getTPS() {
|
||||
public static double getTPS() {
|
||||
return getRecentTPS()[0];
|
||||
}
|
||||
|
||||
@@ -81,15 +81,15 @@ public final class ServerManager {
|
||||
*
|
||||
* @return Get Operating System
|
||||
*/
|
||||
public SystemOS getOS() {
|
||||
public static SystemOS getOS() {
|
||||
return SystemOS.getOS();
|
||||
}
|
||||
|
||||
public boolean isBungeeCordEnabled() {
|
||||
public static boolean isBungeeCordEnabled() {
|
||||
return SpigotConfig.bungee;
|
||||
}
|
||||
|
||||
public BoundingBox getEntityBoundingBox(Entity entity) {
|
||||
public static BoundingBox getEntityBoundingBox(Entity entity) {
|
||||
Object nmsEntity = MinecraftReflection.getNMSEntity(entity);
|
||||
Object aabb = MinecraftReflection.getNMSAxisAlignedBoundingBox(nmsEntity);
|
||||
ReflectionObject wrappedBoundingBox = new ReflectionObject(aabb);
|
||||
@@ -102,30 +102,30 @@ public final class ServerManager {
|
||||
return new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public void receivePacket(ChannelAbstract channel, ByteBufAbstract byteBuf) {
|
||||
public static void receivePacket(ChannelAbstract channel, ByteBufAbstract byteBuf) {
|
||||
//TODO Test with Via present
|
||||
ChannelHandlerContextAbstract ctx = channel.pipeline().context(PacketEvents.get().decoderName);
|
||||
ChannelInboundHandlerUtil.handlerChannelRead(ctx.handler().rawChannelHandler(),
|
||||
ctx.rawChannelHandlerContext(), byteBuf.rawByteBuf());
|
||||
}
|
||||
|
||||
public void receivePacket(Player player, ByteBufAbstract byteBuf) {
|
||||
public static void receivePacket(Player player, ByteBufAbstract byteBuf) {
|
||||
ChannelAbstract channel = ChannelAbstract.generate(PacketEvents.get().getPlayerManager().getChannel(player));
|
||||
receivePacket(channel, byteBuf);
|
||||
}
|
||||
|
||||
public void receivePacket(Player player, PacketWrapper<?> wrapper) {
|
||||
public static void receivePacket(Player player, PacketWrapper<?> wrapper) {
|
||||
wrapper.createPacket();
|
||||
ChannelAbstract channel = ChannelAbstract.generate(PacketEvents.get().getPlayerManager().getChannel(player));
|
||||
receivePacket(channel, wrapper.byteBuf);
|
||||
}
|
||||
|
||||
public void receivePacket(ChannelAbstract channel, PacketWrapper<?> wrapper) {
|
||||
public static void receivePacket(ChannelAbstract channel, PacketWrapper<?> wrapper) {
|
||||
wrapper.createPacket();
|
||||
receivePacket(channel, wrapper.byteBuf);
|
||||
}
|
||||
|
||||
private Entity getEntityByIDWithWorldUnsafe(World world, int id) {
|
||||
private static Entity getEntityByIDWithWorldUnsafe(World world, int id) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public final class ServerManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Entity getEntityByIDUnsafe(World origin, int id) {
|
||||
private static Entity getEntityByIDUnsafe(World origin, int id) {
|
||||
Entity e = getEntityByIDWithWorldUnsafe(origin, id);
|
||||
if (e != null) {
|
||||
return e;
|
||||
@@ -172,7 +172,7 @@ public final class ServerManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntityByID(@Nullable World world, int entityID) {
|
||||
public static Entity getEntityByID(@Nullable World world, int entityID) {
|
||||
Entity e = entityCache.get(entityID);
|
||||
if (e != null) {
|
||||
return e;
|
||||
@@ -211,11 +211,11 @@ public final class ServerManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntityByID(int entityID) {
|
||||
public static Entity getEntityByID(int entityID) {
|
||||
return getEntityByID(null, entityID);
|
||||
}
|
||||
|
||||
public List<Entity> getEntityList(World world) {
|
||||
public static List<Entity> getEntityList(World world) {
|
||||
if (MinecraftReflection.V_1_17_OR_HIGHER) {
|
||||
Object worldServer = MinecraftReflection.convertBukkitWorldToWorldServer(world);
|
||||
ReflectionObject wrappedWorldServer = new ReflectionObject(worldServer);
|
||||
@@ -242,7 +242,7 @@ public final class ServerManager {
|
||||
}
|
||||
|
||||
|
||||
public boolean isGeyserAvailable() {
|
||||
public static boolean isGeyserAvailable() {
|
||||
return MinecraftReflection.GEYSER_CLASS != null;
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ public class PacketWrapper<T extends PacketWrapper> {
|
||||
writeLong(uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
public BlockPosition readBlockPos() {
|
||||
public BlockPosition readBlockPosition() {
|
||||
long val = readLong();
|
||||
int x = (int) (val >> 38);
|
||||
|
||||
@@ -372,7 +372,7 @@ public class PacketWrapper<T extends PacketWrapper> {
|
||||
return new BlockPosition(x, y, z);
|
||||
}
|
||||
|
||||
public void writeBlockPos(BlockPosition pos) {
|
||||
public void writeBlockPosition(BlockPosition pos) {
|
||||
// 1.14 method for this is storing X Z Y
|
||||
if (serverVersion.isNewerThanOrEquals(ServerVersion.v_1_14)) {
|
||||
long val = ((long) (pos.getX() & 0x3FFFFFF) << 38) | ((long) (pos.getZ() & 0x3FFFFFF) << 12) | (pos.getY() & 0xFFF);
|
||||
|
||||
+13
-13
@@ -6,9 +6,9 @@ import io.github.retrooper.packetevents.utils.BlockPosition;
|
||||
import io.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServerBlockAction> {
|
||||
BlockPosition blockPos;
|
||||
int actionID, actionParam;
|
||||
int block;
|
||||
private BlockPosition blockPos;
|
||||
private int actionID, actionParam;
|
||||
private int blockID;
|
||||
|
||||
public WrapperPlayServerBlockAction(PacketSendEvent event) {
|
||||
super(event);
|
||||
@@ -19,23 +19,23 @@ public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServe
|
||||
this.blockPos = blockPos;
|
||||
this.actionID = actionID;
|
||||
this.actionParam = actionParam;
|
||||
this.block = block;
|
||||
this.blockID = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData() {
|
||||
this.blockPos = readBlockPos();
|
||||
this.blockPos = readBlockPosition();
|
||||
this.actionID = readUnsignedByte();
|
||||
this.actionParam = readUnsignedByte();
|
||||
this.block = readInt();
|
||||
this.blockID = readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData() {
|
||||
writeBlockPos(blockPos);
|
||||
writeBlockPosition(blockPos);
|
||||
writeByte(actionID);
|
||||
writeByte(actionParam);
|
||||
writeVarInt(block);
|
||||
writeVarInt(blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +43,7 @@ public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServe
|
||||
this.blockPos = wrapper.getBlockPos();
|
||||
this.actionID = wrapper.getActionID();
|
||||
this.actionParam = wrapper.getActionParam();
|
||||
this.block = wrapper.getBlock();
|
||||
this.blockID = wrapper.getBlockID();
|
||||
}
|
||||
|
||||
public BlockPosition getBlockPos() {
|
||||
@@ -70,11 +70,11 @@ public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServe
|
||||
this.actionParam = actionParam;
|
||||
}
|
||||
|
||||
public int getBlock() {
|
||||
return block;
|
||||
public int getBlockID() {
|
||||
return blockID;
|
||||
}
|
||||
|
||||
public void setBlock(int block) {
|
||||
this.block = block;
|
||||
public void setBlockID(int blockID) {
|
||||
this.blockID = blockID;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user