mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
packets: update project references from packets:api to packets:packets-api
This commit is contained in:
25
libraries/packets/packets-api/build.gradle.kts
Normal file
25
libraries/packets/packets-api/build.gradle.kts
Normal file
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id("java-library")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
|
||||
compileOnly("de.oliver.FancyAnalytics:logger:0.0.6")
|
||||
}
|
||||
|
||||
tasks {
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release = 21
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package de.oliver.fancysitula.api;
|
||||
|
||||
import de.oliver.fancyanalytics.logger.ExtendedFancyLogger;
|
||||
|
||||
public interface IFancySitula {
|
||||
ExtendedFancyLogger LOGGER = new ExtendedFancyLogger("FancySitula");
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
import de.oliver.fancysitula.api.utils.entityData.FS_BlockDisplayData;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_BlockDisplay extends FS_Display {
|
||||
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData blockData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_BlockDisplayData.BLOCK, null);
|
||||
|
||||
public FS_BlockDisplay() {
|
||||
super(EntityType.BLOCK_DISPLAY);
|
||||
}
|
||||
|
||||
public org.bukkit.block.BlockState getBlock() {
|
||||
return (org.bukkit.block.BlockState) this.blockData.getValue();
|
||||
}
|
||||
|
||||
public void setBlock(org.bukkit.block.BlockState block) {
|
||||
this.blockData.setValue(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FS_ClientboundSetEntityDataPacket.EntityData> getEntityData() {
|
||||
List<FS_ClientboundSetEntityDataPacket.EntityData> entityData = super.getEntityData();
|
||||
entityData.add(this.blockData);
|
||||
return entityData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
import de.oliver.fancysitula.api.utils.entityData.FS_DisplayData;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_Display extends FS_Entity {
|
||||
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData transformationInterpolationStartDeltaTicksData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.TRANSFORMATION_INTERPOLATION_START_DELTA_TICKS, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData transformationInterpolationDurationData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.TRANSFORMATION_INTERPOLATION_DURATION, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData posRotInterpolationDurationData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.POS_ROT_INTERPOLATION_DURATION, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData translationData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.TRANSLATION, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData scaleData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.SCALE, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData leftRotationData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.LEFT_ROTATION, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData rightRotationData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.RIGHT_ROTATION, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData billboardRenderConstraintsData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.BILLBOARD_RENDER_CONSTRAINTS, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData brightnessOverrideData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.BRIGHTNESS_OVERRIDE, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData viewRangeData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.VIEW_RANGE, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData shadowRadiusData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.SHADOW_RADIUS, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData shadowStrengthData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.SHADOW_STRENGTH, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData widthData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.WIDTH, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData heightData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.HEIGHT, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData glowColorOverrideData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_DisplayData.GLOW_COLOR_OVERRIDE, null);
|
||||
|
||||
public FS_Display(EntityType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public int getTransformationInterpolationStartDeltaTicks() {
|
||||
return (int) this.transformationInterpolationStartDeltaTicksData.getValue();
|
||||
}
|
||||
|
||||
public void setTransformationInterpolationStartDeltaTicks(int transformationInterpolationStartDeltaTicks) {
|
||||
this.transformationInterpolationStartDeltaTicksData.setValue(transformationInterpolationStartDeltaTicks);
|
||||
}
|
||||
|
||||
public int getTransformationInterpolationDuration() {
|
||||
return (int) this.transformationInterpolationDurationData.getValue();
|
||||
}
|
||||
|
||||
public void setTransformationInterpolationDuration(int transformationInterpolationDuration) {
|
||||
this.transformationInterpolationDurationData.setValue(transformationInterpolationDuration);
|
||||
}
|
||||
|
||||
public int getPosRotInterpolationDuration() {
|
||||
return (int) this.posRotInterpolationDurationData.getValue();
|
||||
}
|
||||
|
||||
public void setPosRotInterpolationDuration(int posRotInterpolationDuration) {
|
||||
this.posRotInterpolationDurationData.setValue(posRotInterpolationDuration);
|
||||
}
|
||||
|
||||
public org.joml.Vector3f getTranslation() {
|
||||
return (org.joml.Vector3f) this.translationData.getValue();
|
||||
}
|
||||
|
||||
public void setTranslation(org.joml.Vector3f translation) {
|
||||
this.translationData.setValue(translation);
|
||||
}
|
||||
|
||||
public org.joml.Vector3f getScale() {
|
||||
return (org.joml.Vector3f) this.scaleData.getValue();
|
||||
}
|
||||
|
||||
public void setScale(org.joml.Vector3f scale) {
|
||||
this.scaleData.setValue(scale);
|
||||
}
|
||||
|
||||
public org.joml.Quaternionf getLeftRotation() {
|
||||
return (org.joml.Quaternionf) this.leftRotationData.getValue();
|
||||
}
|
||||
|
||||
public void setLeftRotation(org.joml.Quaternionf leftRotation) {
|
||||
this.leftRotationData.setValue(leftRotation);
|
||||
}
|
||||
|
||||
public org.joml.Quaternionf getRightRotation() {
|
||||
return (org.joml.Quaternionf) this.rightRotationData.getValue();
|
||||
}
|
||||
|
||||
public void setRightRotation(org.joml.Quaternionf rightRotation) {
|
||||
this.rightRotationData.setValue(rightRotation);
|
||||
}
|
||||
|
||||
public byte getBillboardRenderConstraints() {
|
||||
return (byte) this.billboardRenderConstraintsData.getValue();
|
||||
}
|
||||
|
||||
public void setBillboardRenderConstraints(byte billboardRenderConstraints) {
|
||||
this.billboardRenderConstraintsData.setValue(billboardRenderConstraints);
|
||||
}
|
||||
|
||||
public Billboard getBillboard() {
|
||||
return Billboard.getById(getBillboardRenderConstraints());
|
||||
}
|
||||
|
||||
public void setBillboard(Billboard billboard) {
|
||||
this.billboardRenderConstraintsData.setValue(billboard.getId());
|
||||
}
|
||||
|
||||
public int getBrightnessOverride() {
|
||||
return (int) this.brightnessOverrideData.getValue();
|
||||
}
|
||||
|
||||
public void setBrightnessOverride(int brightnessOverride) {
|
||||
this.brightnessOverrideData.setValue(brightnessOverride);
|
||||
}
|
||||
|
||||
public float getViewRange() {
|
||||
return (float) this.viewRangeData.getValue();
|
||||
}
|
||||
|
||||
public void setViewRange(float viewRange) {
|
||||
this.viewRangeData.setValue(viewRange);
|
||||
}
|
||||
|
||||
public float getShadowRadius() {
|
||||
return (float) this.shadowRadiusData.getValue();
|
||||
}
|
||||
|
||||
public void setShadowRadius(float shadowRadius) {
|
||||
this.shadowRadiusData.setValue(shadowRadius);
|
||||
}
|
||||
|
||||
public float getShadowStrength() {
|
||||
return (float) this.shadowStrengthData.getValue();
|
||||
}
|
||||
|
||||
public void setShadowStrength(float shadowStrength) {
|
||||
this.shadowStrengthData.setValue(shadowStrength);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return (int) this.widthData.getValue();
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.widthData.setValue(width);
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return (int) this.heightData.getValue();
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.heightData.setValue(height);
|
||||
}
|
||||
|
||||
public int getGlowColorOverride() {
|
||||
return (int) this.glowColorOverrideData.getValue();
|
||||
}
|
||||
|
||||
public void setGlowColorOverride(int glowColorOverride) {
|
||||
this.glowColorOverrideData.setValue(glowColorOverride);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FS_ClientboundSetEntityDataPacket.EntityData> getEntityData() {
|
||||
List<FS_ClientboundSetEntityDataPacket.EntityData> entityData = super.getEntityData();
|
||||
|
||||
entityData.add(this.transformationInterpolationStartDeltaTicksData);
|
||||
entityData.add(this.transformationInterpolationDurationData);
|
||||
entityData.add(this.posRotInterpolationDurationData);
|
||||
entityData.add(this.translationData);
|
||||
entityData.add(this.scaleData);
|
||||
entityData.add(this.leftRotationData);
|
||||
entityData.add(this.rightRotationData);
|
||||
entityData.add(this.billboardRenderConstraintsData);
|
||||
entityData.add(this.brightnessOverrideData);
|
||||
entityData.add(this.viewRangeData);
|
||||
entityData.add(this.shadowRadiusData);
|
||||
entityData.add(this.shadowStrengthData);
|
||||
entityData.add(this.widthData);
|
||||
entityData.add(this.heightData);
|
||||
entityData.add(this.glowColorOverrideData);
|
||||
return entityData;
|
||||
}
|
||||
|
||||
public enum Billboard {
|
||||
FIXED((byte) 0, "fixed"),
|
||||
VERTICAL((byte) 1, "vertical"),
|
||||
HORIZONTAL((byte) 2, "horizontal"),
|
||||
CENTER((byte) 3, "center"),
|
||||
;
|
||||
|
||||
private final byte id;
|
||||
private final String name;
|
||||
|
||||
Billboard(byte id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Billboard getById(byte id) {
|
||||
for (Billboard value : values()) {
|
||||
if (value.getId() == id) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
import de.oliver.fancysitula.api.utils.entityData.FS_EntityData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FS_Entity {
|
||||
|
||||
private static int entityCount = Integer.MAX_VALUE / 2;
|
||||
|
||||
protected int id = entityCount++;
|
||||
protected UUID uuid = UUID.randomUUID();
|
||||
protected EntityType type;
|
||||
|
||||
protected double x = 0;
|
||||
protected double y = 0;
|
||||
protected double z = 0;
|
||||
|
||||
protected float yaw = 0;
|
||||
protected float pitch = 0;
|
||||
protected float headYaw = 0;
|
||||
|
||||
protected int velocityX = 0;
|
||||
protected int velocityY = 0;
|
||||
protected int velocityZ = 0;
|
||||
|
||||
protected int data = 0;
|
||||
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData sharedFlagsData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.SHARED_FLAGS, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData airSupplyData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.AIR_SUPPLY, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData customNameData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.CUSTOM_NAME, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData customNameVisibleData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.CUSTOM_NAME_VISIBLE, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData silentData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.SILENT, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData noGravityData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.NO_GRAVITY, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData ticksFrozenData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_EntityData.TICKS_FROZEN, null);
|
||||
|
||||
public FS_Entity(EntityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// Entity data
|
||||
|
||||
public byte getSharedFlags() {
|
||||
return (byte) sharedFlagsData.getValue();
|
||||
}
|
||||
|
||||
public void setSharedFlags(byte sharedFlags) {
|
||||
this.sharedFlagsData.setValue(sharedFlags);
|
||||
}
|
||||
|
||||
public byte getAirSupply() {
|
||||
return (byte) airSupplyData.getValue();
|
||||
}
|
||||
|
||||
public void setAirSupply(byte airSupply) {
|
||||
this.airSupplyData.setValue(airSupply);
|
||||
}
|
||||
|
||||
public Optional<Component> getCustomName() {
|
||||
return (Optional<Component>) customNameData.getValue();
|
||||
}
|
||||
|
||||
public void setCustomName(Optional<Component> customName) {
|
||||
this.customNameData.setValue(customName);
|
||||
}
|
||||
|
||||
public boolean getCustomNameVisible() {
|
||||
return (boolean) customNameVisibleData.getValue();
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean customNameVisible) {
|
||||
this.customNameVisibleData.setValue(customNameVisible);
|
||||
}
|
||||
|
||||
public boolean getSilent() {
|
||||
return (boolean) silentData.getValue();
|
||||
}
|
||||
|
||||
public void setSilent(boolean silent) {
|
||||
this.silentData.setValue(silent);
|
||||
}
|
||||
|
||||
public boolean getNoGravity() {
|
||||
return (boolean) noGravityData.getValue();
|
||||
}
|
||||
|
||||
public void setNoGravity(boolean noGravity) {
|
||||
this.noGravityData.setValue(noGravity);
|
||||
}
|
||||
|
||||
public int getTicksFrozen() {
|
||||
return (int) ticksFrozenData.getValue();
|
||||
}
|
||||
|
||||
public void setTicksFrozen(int ticksFrozen) {
|
||||
this.ticksFrozenData.setValue(ticksFrozen);
|
||||
}
|
||||
|
||||
public List<FS_ClientboundSetEntityDataPacket.EntityData> getEntityData() {
|
||||
List<FS_ClientboundSetEntityDataPacket.EntityData> entityData = new ArrayList<>();
|
||||
|
||||
entityData.add(this.sharedFlagsData);
|
||||
entityData.add(this.airSupplyData);
|
||||
entityData.add(this.customNameData);
|
||||
entityData.add(this.customNameVisibleData);
|
||||
entityData.add(this.silentData);
|
||||
entityData.add(this.noGravityData);
|
||||
entityData.add(this.ticksFrozenData);
|
||||
return entityData;
|
||||
}
|
||||
|
||||
// Getter and Setter for all fields
|
||||
|
||||
public void setLocation(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
setLocation(location.getX(), location.getY(), location.getZ());
|
||||
setRotation(location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public void setVelocity(int velocityX, int velocityY, int velocityZ) {
|
||||
this.velocityX = velocityX;
|
||||
this.velocityY = velocityY;
|
||||
this.velocityZ = velocityZ;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(EntityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getHeadYaw() {
|
||||
return headYaw;
|
||||
}
|
||||
|
||||
public void setHeadYaw(float headYaw) {
|
||||
this.headYaw = headYaw;
|
||||
}
|
||||
|
||||
public int getVelocityX() {
|
||||
return velocityX;
|
||||
}
|
||||
|
||||
public void setVelocityX(int velocityX) {
|
||||
this.velocityX = velocityX;
|
||||
}
|
||||
|
||||
public int getVelocityY() {
|
||||
return velocityY;
|
||||
}
|
||||
|
||||
public void setVelocityY(int velocityY) {
|
||||
this.velocityY = velocityY;
|
||||
}
|
||||
|
||||
public int getVelocityZ() {
|
||||
return velocityZ;
|
||||
}
|
||||
|
||||
public void setVelocityZ(int velocityZ) {
|
||||
this.velocityZ = velocityZ;
|
||||
}
|
||||
|
||||
public int getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(int data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
import de.oliver.fancysitula.api.utils.entityData.FS_ItemDisplayData;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_ItemDisplay extends FS_Display {
|
||||
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData itemData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_ItemDisplayData.ITEM, null);
|
||||
|
||||
public FS_ItemDisplay() {
|
||||
super(EntityType.ITEM_DISPLAY);
|
||||
}
|
||||
|
||||
public org.bukkit.inventory.ItemStack getItem() {
|
||||
return (org.bukkit.inventory.ItemStack) this.itemData.getValue();
|
||||
}
|
||||
|
||||
public void setItem(org.bukkit.inventory.ItemStack item) {
|
||||
this.itemData.setValue(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FS_ClientboundSetEntityDataPacket.EntityData> getEntityData() {
|
||||
List<FS_ClientboundSetEntityDataPacket.EntityData> entityData = super.getEntityData();
|
||||
entityData.add(this.itemData);
|
||||
return entityData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.utils.FS_EquipmentSlot;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FS_Player extends FS_Entity {
|
||||
|
||||
protected Map<FS_EquipmentSlot, ItemStack> equipment;
|
||||
|
||||
public FS_Player() {
|
||||
super(EntityType.PLAYER);
|
||||
|
||||
this.equipment = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public Map<FS_EquipmentSlot, ItemStack> getEquipment() {
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public void setEquipment(Map<FS_EquipmentSlot, ItemStack> equipment) {
|
||||
this.equipment = equipment;
|
||||
}
|
||||
|
||||
public void setEquipment(FS_EquipmentSlot slot, ItemStack item) {
|
||||
this.equipment.put(slot, item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a real player
|
||||
*/
|
||||
public class FS_RealPlayer {
|
||||
|
||||
@NotNull
|
||||
private final Player bukkitPlayer;
|
||||
|
||||
/**
|
||||
* Creates a new FS_RealPlayer instance
|
||||
* Must have a real bukkit player instance
|
||||
* Used for sending packets to the player
|
||||
*
|
||||
* @param bukkitPlayer the bukkit player instance
|
||||
*/
|
||||
public FS_RealPlayer(@NotNull Player bukkitPlayer) {
|
||||
this.bukkitPlayer = bukkitPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet to the player
|
||||
* Must have a real bukkit player instance
|
||||
*
|
||||
* @param packet the packet to send
|
||||
*/
|
||||
public void sendPacket(FS_ClientboundPacket packet) {
|
||||
packet.send(this);
|
||||
}
|
||||
|
||||
public @NotNull Player getBukkitPlayer() {
|
||||
return bukkitPlayer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package de.oliver.fancysitula.api.entities;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
import de.oliver.fancysitula.api.utils.entityData.FS_TextDisplayData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_TextDisplay extends FS_Display {
|
||||
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData textData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_TextDisplayData.TEXT, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData lineWidthData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_TextDisplayData.LINE_WIDTH, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData backgroundData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_TextDisplayData.BACKGROUND, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData textOpacityData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_TextDisplayData.TEXT_OPACITY, null);
|
||||
protected FS_ClientboundSetEntityDataPacket.EntityData styleFlagsData = new FS_ClientboundSetEntityDataPacket.EntityData(FS_TextDisplayData.STYLE_FLAGS, null);
|
||||
|
||||
public FS_TextDisplay() {
|
||||
super(EntityType.TEXT_DISPLAY);
|
||||
}
|
||||
|
||||
public Component getText() {
|
||||
return (Component) this.textData.getValue();
|
||||
}
|
||||
|
||||
public void setText(Component text) {
|
||||
this.textData.setValue(text);
|
||||
}
|
||||
|
||||
public int getLineWidth() {
|
||||
return (int) this.lineWidthData.getValue();
|
||||
}
|
||||
|
||||
public void setLineWidth(int lineWidth) {
|
||||
this.lineWidthData.setValue(lineWidth);
|
||||
}
|
||||
|
||||
public int getBackground() {
|
||||
return (int) this.backgroundData.getValue();
|
||||
}
|
||||
|
||||
public void setBackground(int background) {
|
||||
this.backgroundData.setValue(background);
|
||||
}
|
||||
|
||||
public byte getTextOpacity() {
|
||||
return (byte) this.textOpacityData.getValue();
|
||||
}
|
||||
|
||||
public void setTextOpacity(byte textOpacity) {
|
||||
this.textOpacityData.setValue(textOpacity);
|
||||
}
|
||||
|
||||
public byte getStyleFlags() {
|
||||
return (byte) this.styleFlagsData.getValue();
|
||||
}
|
||||
|
||||
public void setStyleFlags(byte styleFlags) {
|
||||
this.styleFlagsData.setValue(styleFlags);
|
||||
}
|
||||
|
||||
public void setStyleFlag(byte flag, boolean value) {
|
||||
byte styleFlags = getStyleFlags();
|
||||
if (value) {
|
||||
this.styleFlagsData.setValue((byte) (styleFlags | flag));
|
||||
} else {
|
||||
this.styleFlagsData.setValue((byte) (styleFlags & ~flag));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasStyleFlag(byte flag) {
|
||||
return (getStyleFlags() & flag) == flag;
|
||||
}
|
||||
|
||||
public void setShadow(boolean shadow) {
|
||||
setStyleFlag((byte) 1, shadow);
|
||||
}
|
||||
|
||||
public boolean hasShadow() {
|
||||
return hasStyleFlag((byte) 1);
|
||||
}
|
||||
|
||||
public boolean isSeeThrough() {
|
||||
return hasStyleFlag((byte) 2);
|
||||
}
|
||||
|
||||
public void setSeeThrough(boolean seeThrough) {
|
||||
setStyleFlag((byte) 2, seeThrough);
|
||||
}
|
||||
|
||||
public void setUseDefaultBackground(boolean defaultBackground) {
|
||||
setStyleFlag((byte) 4, defaultBackground);
|
||||
}
|
||||
|
||||
public boolean isUsingDefaultBackground() {
|
||||
return hasStyleFlag((byte) 4);
|
||||
}
|
||||
|
||||
public boolean isAlignLeft() {
|
||||
return hasStyleFlag((byte) 8);
|
||||
}
|
||||
|
||||
public void setAlignLeft(boolean alignLeft) {
|
||||
setStyleFlag((byte) 8, alignLeft);
|
||||
}
|
||||
|
||||
public void setAlignRight(boolean alignRight) {
|
||||
setStyleFlag((byte) 16, alignRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FS_ClientboundSetEntityDataPacket.EntityData> getEntityData() {
|
||||
List<FS_ClientboundSetEntityDataPacket.EntityData> entityData = super.getEntityData();
|
||||
|
||||
entityData.add(this.textData);
|
||||
entityData.add(this.lineWidthData);
|
||||
entityData.add(this.backgroundData);
|
||||
entityData.add(this.textOpacityData);
|
||||
entityData.add(this.styleFlagsData);
|
||||
return entityData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Used to add an entity to the client's world.
|
||||
*/
|
||||
public abstract class FS_ClientboundAddEntityPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected UUID entityUUID;
|
||||
protected EntityType entityType;
|
||||
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
|
||||
protected float yaw;
|
||||
protected float pitch;
|
||||
protected float headYaw;
|
||||
|
||||
protected int velocityX;
|
||||
protected int velocityY;
|
||||
protected int velocityZ;
|
||||
|
||||
protected int data;
|
||||
|
||||
/**
|
||||
* @param pitch in degrees (0 - 360)
|
||||
* @param headYaw in degrees (0 - 360)
|
||||
*/
|
||||
public FS_ClientboundAddEntityPacket(
|
||||
int entityId,
|
||||
UUID entityUUID,
|
||||
EntityType entityType,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
float yaw,
|
||||
float pitch,
|
||||
float headYaw,
|
||||
int velocityX,
|
||||
int velocityY,
|
||||
int velocityZ,
|
||||
int data) {
|
||||
this.entityId = entityId;
|
||||
this.entityUUID = entityUUID;
|
||||
this.entityType = entityType;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.headYaw = headYaw;
|
||||
this.velocityX = velocityX;
|
||||
this.velocityY = velocityY;
|
||||
this.velocityZ = velocityZ;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public UUID getEntityUUID() {
|
||||
return entityUUID;
|
||||
}
|
||||
|
||||
public void setEntityUUID(UUID entityUUID) {
|
||||
this.entityUUID = entityUUID;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getHeadYaw() {
|
||||
return headYaw;
|
||||
}
|
||||
|
||||
public void setHeadYaw(float headYaw) {
|
||||
this.headYaw = headYaw;
|
||||
}
|
||||
|
||||
public int getVelocityX() {
|
||||
return velocityX;
|
||||
}
|
||||
|
||||
public void setVelocityX(int velocityX) {
|
||||
this.velocityX = velocityX;
|
||||
}
|
||||
|
||||
public int getVelocityY() {
|
||||
return velocityY;
|
||||
}
|
||||
|
||||
public void setVelocityY(int velocityY) {
|
||||
this.velocityY = velocityY;
|
||||
}
|
||||
|
||||
public int getVelocityZ() {
|
||||
return velocityZ;
|
||||
}
|
||||
|
||||
public void setVelocityZ(int velocityZ) {
|
||||
this.velocityZ = velocityZ;
|
||||
}
|
||||
|
||||
public int getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(int data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import de.oliver.fancysitula.api.teams.FS_CollisionRule;
|
||||
import de.oliver.fancysitula.api.teams.FS_NameTagVisibility;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FS_ClientboundCreateOrUpdateTeamPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected Method method;
|
||||
protected String teamName;
|
||||
|
||||
protected CreateTeam createTeam;
|
||||
protected RemoveTeam removeTeam;
|
||||
protected UpdateTeam updateTeam;
|
||||
protected AddEntity addEntity;
|
||||
protected RemoveEntity removeEntity;
|
||||
|
||||
public FS_ClientboundCreateOrUpdateTeamPacket(String teamName, CreateTeam createTeam) {
|
||||
this.method = Method.CREATE_TEAM;
|
||||
this.teamName = teamName;
|
||||
this.createTeam = createTeam;
|
||||
}
|
||||
|
||||
public FS_ClientboundCreateOrUpdateTeamPacket(String teamName, RemoveTeam removeTeam) {
|
||||
this.method = Method.REMOVE_TEAM;
|
||||
this.teamName = teamName;
|
||||
this.removeTeam = removeTeam;
|
||||
}
|
||||
|
||||
public FS_ClientboundCreateOrUpdateTeamPacket(String teamName, UpdateTeam updateTeam) {
|
||||
this.method = Method.UPDATE_TEAM;
|
||||
this.teamName = teamName;
|
||||
this.updateTeam = updateTeam;
|
||||
}
|
||||
|
||||
public FS_ClientboundCreateOrUpdateTeamPacket(String teamName, AddEntity addEntity) {
|
||||
this.method = Method.ADD_ENTITY;
|
||||
this.teamName = teamName;
|
||||
this.addEntity = addEntity;
|
||||
}
|
||||
|
||||
public FS_ClientboundCreateOrUpdateTeamPacket(String teamName, RemoveEntity removeEntity) {
|
||||
this.method = Method.REMOVE_ENTITY;
|
||||
this.teamName = teamName;
|
||||
this.removeEntity = removeEntity;
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public CreateTeam getCreateTeam() {
|
||||
return createTeam;
|
||||
}
|
||||
|
||||
public void setCreateTeam(CreateTeam createTeam) {
|
||||
this.createTeam = createTeam;
|
||||
}
|
||||
|
||||
public UpdateTeam getUpdateTeam() {
|
||||
return updateTeam;
|
||||
}
|
||||
|
||||
public void setUpdateTeam(UpdateTeam updateTeam) {
|
||||
this.updateTeam = updateTeam;
|
||||
}
|
||||
|
||||
public AddEntity getAddEntity() {
|
||||
return addEntity;
|
||||
}
|
||||
|
||||
public void setAddEntity(AddEntity addEntity) {
|
||||
this.addEntity = addEntity;
|
||||
}
|
||||
|
||||
public RemoveEntity getRemoveEntity() {
|
||||
return removeEntity;
|
||||
}
|
||||
|
||||
public void setRemoveEntity(RemoveEntity removeEntity) {
|
||||
this.removeEntity = removeEntity;
|
||||
}
|
||||
|
||||
public enum Method {
|
||||
CREATE_TEAM,
|
||||
REMOVE_TEAM,
|
||||
UPDATE_TEAM,
|
||||
ADD_ENTITY,
|
||||
REMOVE_ENTITY;
|
||||
}
|
||||
|
||||
public static class CreateTeam {
|
||||
private Component displayName;
|
||||
private boolean allowFriendlyFire;
|
||||
private boolean canSeeFriendlyInvisibles;
|
||||
private FS_NameTagVisibility nameTagVisibility;
|
||||
private FS_CollisionRule collisionRule;
|
||||
private FS_Color color;
|
||||
private Component prefix;
|
||||
private Component suffix;
|
||||
private List<String> entities;
|
||||
|
||||
public CreateTeam(Component displayName, boolean allowFriendlyFire, boolean canSeeFriendlyInvisibles, FS_NameTagVisibility nameTagVisibility, FS_CollisionRule collisionRule, FS_Color color, Component prefix, Component suffix, List<String> entities) {
|
||||
this.displayName = displayName;
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
this.collisionRule = collisionRule;
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(Component displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public boolean isAllowFriendlyFire() {
|
||||
return allowFriendlyFire;
|
||||
}
|
||||
|
||||
public void setAllowFriendlyFire(boolean allowFriendlyFire) {
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
}
|
||||
|
||||
public boolean isCanSeeFriendlyInvisibles() {
|
||||
return canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public void setCanSeeFriendlyInvisibles(boolean canSeeFriendlyInvisibles) {
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public FS_NameTagVisibility getNameTagVisibility() {
|
||||
return nameTagVisibility;
|
||||
}
|
||||
|
||||
public void setNameTagVisibility(FS_NameTagVisibility nameTagVisibility) {
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
}
|
||||
|
||||
public FS_CollisionRule getCollisionRule() {
|
||||
return collisionRule;
|
||||
}
|
||||
|
||||
public void setCollisionRule(FS_CollisionRule collisionRule) {
|
||||
this.collisionRule = collisionRule;
|
||||
}
|
||||
|
||||
public FS_Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(FS_Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Component getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(Component prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public Component getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(Component suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public List<String> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void setEntities(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveTeam {
|
||||
|
||||
}
|
||||
|
||||
public static class UpdateTeam {
|
||||
private Component displayName;
|
||||
private boolean allowFriendlyFire;
|
||||
private boolean canSeeFriendlyInvisibles;
|
||||
private FS_NameTagVisibility nameTagVisibility;
|
||||
private FS_CollisionRule collisionRule;
|
||||
private FS_Color color;
|
||||
private Component prefix;
|
||||
private Component suffix;
|
||||
|
||||
public UpdateTeam(Component displayName, boolean allowFriendlyFire, boolean canSeeFriendlyInvisibles, FS_NameTagVisibility nameTagVisibility, FS_CollisionRule collisionRule, FS_Color color, Component prefix, Component suffix) {
|
||||
this.displayName = displayName;
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
this.collisionRule = collisionRule;
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(Component displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public boolean isAllowFriendlyFire() {
|
||||
return allowFriendlyFire;
|
||||
}
|
||||
|
||||
public void setAllowFriendlyFire(boolean allowFriendlyFire) {
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
}
|
||||
|
||||
public boolean isCanSeeFriendlyInvisibles() {
|
||||
return canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public void setCanSeeFriendlyInvisibles(boolean canSeeFriendlyInvisibles) {
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public FS_NameTagVisibility getNameTagVisibility() {
|
||||
return nameTagVisibility;
|
||||
}
|
||||
|
||||
public void setNameTagVisibility(FS_NameTagVisibility nameTagVisibility) {
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
}
|
||||
|
||||
public FS_CollisionRule getCollisionRule() {
|
||||
return collisionRule;
|
||||
}
|
||||
|
||||
public void setCollisionRule(FS_CollisionRule collisionRule) {
|
||||
this.collisionRule = collisionRule;
|
||||
}
|
||||
|
||||
public FS_Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(FS_Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Component getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(Component prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public Component getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(Component suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AddEntity {
|
||||
private List<String> entities;
|
||||
|
||||
public AddEntity(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public List<String> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void setEntities(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveEntity {
|
||||
private List<String> entities;
|
||||
|
||||
public RemoveEntity(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public List<String> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void setEntities(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import de.oliver.fancysitula.api.IFancySitula;
|
||||
import de.oliver.fancysitula.api.entities.FS_RealPlayer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public abstract class FS_ClientboundPacket {
|
||||
|
||||
/**
|
||||
* Creates the packet object.
|
||||
* For internal use only.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public abstract Object createPacket();
|
||||
|
||||
/**
|
||||
* Sends the packet to the player.
|
||||
* For internal use only.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
protected abstract void sendPacketTo(FS_RealPlayer player);
|
||||
|
||||
/**
|
||||
* Sends the packet to the player.
|
||||
*/
|
||||
public final void send(FS_RealPlayer player) {
|
||||
IFancySitula.LOGGER.debug("Sending packet '" + this.getClass().getSimpleName() + "' to " + player.getBukkitPlayer().getName());
|
||||
|
||||
sendPacketTo(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Used to remove players from the client's player list.
|
||||
*/
|
||||
public abstract class FS_ClientboundPlayerInfoRemovePacket extends FS_ClientboundPacket {
|
||||
|
||||
protected List<UUID> uuids;
|
||||
|
||||
public FS_ClientboundPlayerInfoRemovePacket(List<UUID> uuids) {
|
||||
this.uuids = uuids;
|
||||
}
|
||||
|
||||
public List<UUID> getUuids() {
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void setUuids(List<UUID> uuids) {
|
||||
this.uuids = uuids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import de.oliver.fancysitula.api.utils.FS_GameProfile;
|
||||
import de.oliver.fancysitula.api.utils.FS_GameType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Used to update the player list of the client.
|
||||
*/
|
||||
public abstract class FS_ClientboundPlayerInfoUpdatePacket extends FS_ClientboundPacket {
|
||||
|
||||
protected EnumSet<Action> actions;
|
||||
protected List<Entry> entries;
|
||||
|
||||
public FS_ClientboundPlayerInfoUpdatePacket(EnumSet<Action> actions, List<Entry> entries) {
|
||||
this.actions = actions;
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public EnumSet<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(EnumSet<Action> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public List<Entry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void setEntries(List<Entry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
ADD_PLAYER,
|
||||
INITIALIZE_CHAT,
|
||||
UPDATE_GAME_MODE,
|
||||
UPDATE_LISTED,
|
||||
UPDATE_LATENCY,
|
||||
UPDATE_DISPLAY_NAME,
|
||||
}
|
||||
|
||||
public record Entry(UUID uuid,
|
||||
FS_GameProfile profile,
|
||||
boolean listed,
|
||||
int latency,
|
||||
FS_GameType gameMode,
|
||||
@Nullable Component displayName) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used to remove entities from the client's world.
|
||||
*/
|
||||
public abstract class FS_ClientboundRemoveEntitiesPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected List<Integer> entityIds;
|
||||
|
||||
/**
|
||||
* @param entityIds IDs of the entities to remove
|
||||
*/
|
||||
public FS_ClientboundRemoveEntitiesPacket(List<Integer> entityIds) {
|
||||
this.entityIds = entityIds;
|
||||
}
|
||||
|
||||
public List<Integer> getEntityIds() {
|
||||
return entityIds;
|
||||
}
|
||||
|
||||
public void setEntityIds(List<Integer> entityIds) {
|
||||
this.entityIds = entityIds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
public abstract class FS_ClientboundRotateHeadPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected float headYaw;
|
||||
|
||||
public FS_ClientboundRotateHeadPacket(int entityId, float headYaw) {
|
||||
this.entityId = entityId;
|
||||
this.headYaw = headYaw;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public float getHeadYaw() {
|
||||
return headYaw;
|
||||
}
|
||||
|
||||
public void setHeadYaw(float headYaw) {
|
||||
this.headYaw = headYaw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FS_ClientboundSetEntityDataPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected List<EntityData> entityData;
|
||||
|
||||
public FS_ClientboundSetEntityDataPacket(int entityId, List<EntityData> entityData) {
|
||||
this.entityId = entityId;
|
||||
this.entityData = entityData;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public List<EntityData> getEntityData() {
|
||||
return entityData;
|
||||
}
|
||||
|
||||
public void setEntityData(List<EntityData> entityData) {
|
||||
this.entityData = entityData;
|
||||
}
|
||||
|
||||
public static class EntityData {
|
||||
private EntityDataAccessor accessor;
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* @param accessor can be found in {@link de.oliver.fancysitula.api.utils.entityData}
|
||||
* @param value must be the correct type for the accessor (see accessor javadoc)
|
||||
*/
|
||||
public EntityData(EntityDataAccessor accessor, Object value) {
|
||||
this.accessor = accessor;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public EntityDataAccessor getAccessor() {
|
||||
return accessor;
|
||||
}
|
||||
|
||||
public void setAccessor(EntityDataAccessor accessor) {
|
||||
this.accessor = accessor;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityClassName the class name of the entity (e.g. "net.minecraft.world.entity.Display$TextDisplay")
|
||||
* @param accessorFieldName the field name of the accessor (typically starts with "DATA_" and ends with "_ID")
|
||||
*/
|
||||
public record EntityDataAccessor(String entityClassName, String accessorFieldName) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import de.oliver.fancysitula.api.utils.FS_EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class FS_ClientboundSetEquipmentPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected Map<FS_EquipmentSlot, ItemStack> equipment;
|
||||
|
||||
public FS_ClientboundSetEquipmentPacket(int entityId, Map<FS_EquipmentSlot, ItemStack> equipment) {
|
||||
this.entityId = entityId;
|
||||
this.equipment = equipment;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public Map<FS_EquipmentSlot, ItemStack> getEquipment() {
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public void setEquipment(Map<FS_EquipmentSlot, ItemStack> equipment) {
|
||||
this.equipment = equipment;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FS_ClientboundSetPassengersPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected List<Integer> passengers;
|
||||
|
||||
public FS_ClientboundSetPassengersPacket(int entityId, List<Integer> passengers) {
|
||||
this.entityId = entityId;
|
||||
this.passengers = passengers;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public List<Integer> getPassengers() {
|
||||
return passengers;
|
||||
}
|
||||
|
||||
public void setPassengers(List<Integer> passengers) {
|
||||
this.passengers = passengers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
public abstract class FS_ClientboundTeleportEntityPacket extends FS_ClientboundPacket {
|
||||
|
||||
protected int entityId;
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
protected float yaw;
|
||||
protected float pitch;
|
||||
protected boolean onGround;
|
||||
|
||||
public FS_ClientboundTeleportEntityPacket(int entityId, double x, double y, double z, float yaw, float pitch, boolean onGround) {
|
||||
this.entityId = entityId;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.onGround = onGround;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public boolean isOnGround() {
|
||||
return onGround;
|
||||
}
|
||||
|
||||
public void setOnGround(boolean onGround) {
|
||||
this.onGround = onGround;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.packets;
|
||||
|
||||
public enum FS_Color {
|
||||
BLACK(0),
|
||||
DARK_BLUE(1),
|
||||
DARK_GREEN(2),
|
||||
DARK_AQUA(3),
|
||||
DARK_RED(4),
|
||||
DARK_PURPLE(5),
|
||||
GOLD(6),
|
||||
GRAY(7),
|
||||
DARK_GRAY(8),
|
||||
BLUE(9),
|
||||
GREEN(10),
|
||||
AQUA(11),
|
||||
RED(12),
|
||||
LIGHT_PURPLE(13),
|
||||
YELLOW(14),
|
||||
WHITE(15);
|
||||
|
||||
|
||||
private final int id;
|
||||
|
||||
FS_Color(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package de.oliver.fancysitula.api.teams;
|
||||
|
||||
public enum FS_CollisionRule {
|
||||
ALWAYS("always"),
|
||||
NEVER("never"),
|
||||
PUSH_OTHER_TEAMS("pushOtherTeams"),
|
||||
PUSH_OWN_TEAM("pushOwnTeam");
|
||||
|
||||
private final String name;
|
||||
|
||||
FS_CollisionRule(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package de.oliver.fancysitula.api.teams;
|
||||
|
||||
public enum FS_NameTagVisibility {
|
||||
ALWAYS("always"),
|
||||
NEVER("never"),
|
||||
HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
|
||||
HIDE_FOR_OWN_TEAM("hideForOwnTeam");
|
||||
|
||||
private final String name;
|
||||
|
||||
FS_NameTagVisibility(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package de.oliver.fancysitula.api.teams;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_Color;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_Team {
|
||||
|
||||
private String teamName;
|
||||
private Component displayName;
|
||||
private boolean allowFriendlyFire;
|
||||
private boolean canSeeFriendlyInvisibles;
|
||||
private FS_NameTagVisibility nameTagVisibility;
|
||||
private FS_CollisionRule collisionRule;
|
||||
private FS_Color color;
|
||||
private Component prefix;
|
||||
private Component suffix;
|
||||
private List<String> entities;
|
||||
|
||||
public FS_Team(String teamName, Component displayName, boolean allowFriendlyFire, boolean canSeeFriendlyInvisibles, FS_NameTagVisibility nameTagVisibility, FS_CollisionRule collisionRule, FS_Color color, Component prefix, Component suffix, List<String> entities) {
|
||||
this.teamName = teamName;
|
||||
this.displayName = displayName;
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
this.collisionRule = collisionRule;
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(Component displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public boolean isAllowFriendlyFire() {
|
||||
return allowFriendlyFire;
|
||||
}
|
||||
|
||||
public void setAllowFriendlyFire(boolean allowFriendlyFire) {
|
||||
this.allowFriendlyFire = allowFriendlyFire;
|
||||
}
|
||||
|
||||
public boolean isCanSeeFriendlyInvisibles() {
|
||||
return canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public void setCanSeeFriendlyInvisibles(boolean canSeeFriendlyInvisibles) {
|
||||
this.canSeeFriendlyInvisibles = canSeeFriendlyInvisibles;
|
||||
}
|
||||
|
||||
public FS_NameTagVisibility getNameTagVisibility() {
|
||||
return nameTagVisibility;
|
||||
}
|
||||
|
||||
public void setNameTagVisibility(FS_NameTagVisibility nameTagVisibility) {
|
||||
this.nameTagVisibility = nameTagVisibility;
|
||||
}
|
||||
|
||||
public FS_CollisionRule getCollisionRule() {
|
||||
return collisionRule;
|
||||
}
|
||||
|
||||
public void setCollisionRule(FS_CollisionRule collisionRule) {
|
||||
this.collisionRule = collisionRule;
|
||||
}
|
||||
|
||||
public FS_Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(FS_Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Component getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(Component prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public Component getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(Component suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public List<String> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void setEntities(List<String> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package de.oliver.fancysitula.api.utils;
|
||||
|
||||
public class AngelConverter {
|
||||
|
||||
public static byte degreesToVanillaByte(float degrees) {
|
||||
return (byte) Math.floor(degrees * 256.0F / 360.0F);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.oliver.fancysitula.api.utils;
|
||||
|
||||
public enum FS_EquipmentSlot {
|
||||
MAINHAND,
|
||||
OFFHAND,
|
||||
FEET,
|
||||
LEGS,
|
||||
CHEST,
|
||||
HEAD,
|
||||
BODY,
|
||||
SADDLE, // Added in 1.21.5
|
||||
;
|
||||
|
||||
public static FS_EquipmentSlot fromBukkit(org.bukkit.inventory.EquipmentSlot equipmentSlot) {
|
||||
return switch (equipmentSlot) {
|
||||
case HAND -> MAINHAND;
|
||||
case OFF_HAND -> OFFHAND;
|
||||
case FEET -> FEET;
|
||||
case LEGS -> LEGS;
|
||||
case CHEST -> CHEST;
|
||||
case HEAD -> HEAD;
|
||||
case BODY -> BODY;
|
||||
case SADDLE -> SADDLE;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package de.oliver.fancysitula.api.utils;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FS_GameProfile {
|
||||
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
private Map<String, Property> properties;
|
||||
|
||||
public FS_GameProfile(UUID uuid, String name, Map<String, Property> properties) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public FS_GameProfile(UUID uuid, String name) {
|
||||
this(uuid, name, new HashMap<>());
|
||||
}
|
||||
|
||||
public static FS_GameProfile fromBukkit(PlayerProfile gameProfile) {
|
||||
FS_GameProfile fsGameProfile = new FS_GameProfile(gameProfile.getId(), gameProfile.getName());
|
||||
|
||||
for (ProfileProperty property : gameProfile.getProperties()) {
|
||||
fsGameProfile.getProperties().put(property.getName(), new FS_GameProfile.Property(property.getName(), property.getValue(), property.getSignature()));
|
||||
}
|
||||
|
||||
return fsGameProfile;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, Property> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Property> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public record Property(String name, String value, String signature) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.oliver.fancysitula.api.utils;
|
||||
|
||||
public enum FS_GameType {
|
||||
SURVIVAL(0, "survival"),
|
||||
CREATIVE(1, "creative"),
|
||||
ADVENTURE(2, "adventure"),
|
||||
SPECTATOR(3, "spectator");
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
FS_GameType(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package de.oliver.fancysitula.api.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum ServerVersion {
|
||||
|
||||
v1_21_5("1.21.5", 770),
|
||||
v1_21_4("1.21.4", 769),
|
||||
v1_21_3("1.21.3", 768),
|
||||
v1_21_1("1.21.1", 767),
|
||||
v1_21("1.21", 767),
|
||||
v1_20_6("1.20.6", 766),
|
||||
v1_20_5("1.20.5", 766),
|
||||
;
|
||||
|
||||
private final String version;
|
||||
private final int protocolVersion;
|
||||
|
||||
ServerVersion(String version, int protocolVersion) {
|
||||
this.version = version;
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public static ServerVersion getByProtocolVersion(int protocolVersion) {
|
||||
for (ServerVersion version : values()) {
|
||||
if (version.getProtocolVersion() == protocolVersion) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ServerVersion getByVersion(String version) {
|
||||
for (ServerVersion serverVersion : values()) {
|
||||
if (serverVersion.getVersion().equals(version)) {
|
||||
return serverVersion;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> getSupportedVersions() {
|
||||
return Arrays.stream(values())
|
||||
.map(ServerVersion::getVersion)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static boolean isVersionSupported(String version) {
|
||||
return getByVersion(version) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current server version of the server the plugin is running on
|
||||
*/
|
||||
public static ServerVersion getCurrentVersion() {
|
||||
return getByVersion(Bukkit.getMinecraftVersion());
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public int getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package de.oliver.fancysitula.api.utils.entityData;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
|
||||
public class FS_BlockDisplayData {
|
||||
|
||||
/**
|
||||
* Use {@link org.bukkit.block.Block} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor BLOCK = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$BlockDisplay", "DATA_BLOCK_STATE_ID");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.oliver.fancysitula.api.utils.entityData;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
|
||||
public class FS_DisplayData {
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TRANSFORMATION_INTERPOLATION_START_DELTA_TICKS = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_TRANSFORMATION_INTERPOLATION_START_DELTA_TICKS_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TRANSFORMATION_INTERPOLATION_DURATION = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_TRANSFORMATION_INTERPOLATION_DURATION_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor POS_ROT_INTERPOLATION_DURATION = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_POS_ROT_INTERPOLATION_DURATION_ID");
|
||||
|
||||
/**
|
||||
* Use {@link org.joml.Vector3f} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TRANSLATION = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_TRANSLATION_ID");
|
||||
|
||||
/**
|
||||
* Use {@link org.joml.Vector3f} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor SCALE = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_SCALE_ID");
|
||||
|
||||
/**
|
||||
* Use {@link org.joml.Quaternionf} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor LEFT_ROTATION = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_LEFT_ROTATION_ID");
|
||||
|
||||
/**
|
||||
* Use {@link org.joml.Quaternionf} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor RIGHT_ROTATION = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_RIGHT_ROTATION_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Byte} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor BILLBOARD_RENDER_CONSTRAINTS = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_BILLBOARD_RENDER_CONSTRAINTS_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor BRIGHTNESS_OVERRIDE = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_BRIGHTNESS_OVERRIDE_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Float} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor VIEW_RANGE = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_VIEW_RANGE_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Float} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor SHADOW_RADIUS = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_SHADOW_RADIUS_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Float} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor SHADOW_STRENGTH = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_SHADOW_STRENGTH_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Float} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor WIDTH = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_WIDTH_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Float} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor HEIGHT = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_HEIGHT_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor GLOW_COLOR_OVERRIDE = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display", "DATA_GLOW_COLOR_OVERRIDE_ID");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.oliver.fancysitula.api.utils.entityData;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
|
||||
public class FS_EntityData {
|
||||
|
||||
/**
|
||||
* Use {@link Byte} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor SHARED_FLAGS = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_SHARED_FLAGS_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor AIR_SUPPLY = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_AIR_SUPPLY_ID");
|
||||
|
||||
/**
|
||||
* Use {@link java.util.Optional<net.kyori.adventure.text.Component>} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor CUSTOM_NAME = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_CUSTOM_NAME");
|
||||
|
||||
/**
|
||||
* Use {@link Boolean} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor CUSTOM_NAME_VISIBLE = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_CUSTOM_NAME_VISIBLE");
|
||||
|
||||
/**
|
||||
* Use {@link Boolean} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor SILENT = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_SILENT");
|
||||
|
||||
/**
|
||||
* Use {@link Boolean} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor NO_GRAVITY = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_NO_GRAVITY");
|
||||
|
||||
// TODO: Add DATA_POSE
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TICKS_FROZEN = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Entity", "DATA_TICKS_FROZEN");
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package de.oliver.fancysitula.api.utils.entityData;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
|
||||
public class FS_ItemDisplayData {
|
||||
|
||||
/**
|
||||
* Use {@link org.bukkit.inventory.ItemStack} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor ITEM = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$ItemDisplay", "DATA_ITEM_STACK_ID");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.oliver.fancysitula.api.utils.entityData;
|
||||
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
|
||||
|
||||
public class FS_TextDisplayData {
|
||||
|
||||
/**
|
||||
* Use {@link net.kyori.adventure.text.Component} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TEXT = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$TextDisplay", "DATA_TEXT_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor LINE_WIDTH = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$TextDisplay", "DATA_LINE_WIDTH_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Integer} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor BACKGROUND = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$TextDisplay", "DATA_BACKGROUND_COLOR_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Byte} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor TEXT_OPACITY = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$TextDisplay", "DATA_TEXT_OPACITY_ID");
|
||||
|
||||
/**
|
||||
* Use {@link Byte} as value
|
||||
*/
|
||||
public static final FS_ClientboundSetEntityDataPacket.EntityDataAccessor STYLE_FLAGS = new FS_ClientboundSetEntityDataPacket.EntityDataAccessor("net.minecraft.world.entity.Display$TextDisplay", "DATA_STYLE_FLAGS_ID");
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package de.oliver.fancysitula.api.utils.reflections;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ReflectionUtils {
|
||||
|
||||
private static Unsafe getUnsafe() throws Exception {
|
||||
Field field = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
field.setAccessible(true);
|
||||
return (Unsafe) field.get(null);
|
||||
}
|
||||
|
||||
public static <T> T createUnsafeInstance(Class<T> clazz) throws Exception {
|
||||
Unsafe unsafe = getUnsafe();
|
||||
return (T) unsafe.allocateInstance(clazz);
|
||||
}
|
||||
|
||||
public static <T> T createInstance(Class<T> clazz) throws Exception {
|
||||
Constructor<T> constructor = clazz.getDeclaredConstructor();
|
||||
constructor.setAccessible(true);
|
||||
return constructor.newInstance();
|
||||
}
|
||||
|
||||
public static Object getField(Object object, String fieldName) throws Exception {
|
||||
Field field = object.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return field.get(object);
|
||||
}
|
||||
|
||||
public static void setField(Object object, String fieldName, Object value) throws Exception {
|
||||
Field field = object.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(object, value);
|
||||
}
|
||||
|
||||
public static void setFinalField(Object target, String fieldName, Object value) throws Exception {
|
||||
Field field = target.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
|
||||
// Use Unsafe to modify the final field
|
||||
Unsafe unsafe = getUnsafe();
|
||||
long offset = unsafe.objectFieldOffset(field);
|
||||
if (field.getType() == int.class) {
|
||||
unsafe.putInt(target, offset, (int) value);
|
||||
} else if (field.getType() == long.class) {
|
||||
unsafe.putLong(target, offset, (long) value);
|
||||
} else if (field.getType() == double.class) {
|
||||
unsafe.putDouble(target, offset, (double) value);
|
||||
} else if (field.getType() == float.class) {
|
||||
unsafe.putFloat(target, offset, (float) value);
|
||||
} else if (field.getType() == boolean.class) {
|
||||
unsafe.putBoolean(target, offset, (boolean) value);
|
||||
} else if (field.getType() == byte.class) {
|
||||
unsafe.putByte(target, offset, (byte) value);
|
||||
} else if (field.getType() == short.class) {
|
||||
unsafe.putShort(target, offset, (short) value);
|
||||
} else if (field.getType() == char.class) {
|
||||
unsafe.putChar(target, offset, (char) value);
|
||||
} else {
|
||||
unsafe.putObject(target, offset, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T getStaticField(Class<?> clazz, String fieldName) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return (T) field.get(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user