Refactoring

This commit is contained in:
filoghost 2021-08-18 16:16:20 +02:00
parent 4f03b2e4e3
commit 903c94657b
75 changed files with 2661 additions and 1513 deletions

View File

@ -1,44 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.common.nms;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractNMSPacketList implements NMSPacketList {
// Lazily instantiate a list only when adding more than one element
private @Nullable NMSPacket singlePacket;
private @Nullable List<NMSPacket> multiplePackets;
protected final void add(NMSPacket packet) {
if (multiplePackets != null) {
multiplePackets.add(packet);
} else if (singlePacket != null) {
multiplePackets = new ArrayList<>();
multiplePackets.add(singlePacket);
multiplePackets.add(packet);
singlePacket = null;
} else {
singlePacket = packet;
}
}
@Override
public final void sendTo(Player player) {
if (multiplePackets != null) {
for (NMSPacket packet : multiplePackets) {
packet.sendTo(player);
}
} else if (singlePacket != null) {
singlePacket.sendTo(player);
}
}
}

View File

@ -8,7 +8,7 @@ package me.filoghost.holographicdisplays.common.nms;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface IndividualCustomName {
public interface IndividualText {
String get(Player player);

View File

@ -5,13 +5,18 @@
*/
package me.filoghost.holographicdisplays.common.nms;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import org.bukkit.entity.Player;
public interface NMSManager {
EntityID newEntityID();
TextNMSPacketEntity newTextPacketEntity();
NMSPacketList createPacketList();
ItemNMSPacketEntity newItemPacketEntity();
ClickableNMSPacketEntity newClickablePacketEntity();
void injectPacketListener(Player player, PacketListener packetListener);

View File

@ -6,33 +6,38 @@
package me.filoghost.holographicdisplays.common.nms;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
public interface NMSPacketList {
import java.util.ArrayList;
import java.util.List;
void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ);
public class NMSPacketList {
void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName);
// Lazily instantiate a list only when adding more than one element
private @Nullable NMSPacket singlePacket;
private @Nullable List<NMSPacket> multiplePackets;
void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName);
public void add(NMSPacket packet) {
if (multiplePackets != null) {
multiplePackets.add(packet);
} else if (singlePacket != null) {
multiplePackets = new ArrayList<>();
multiplePackets.add(singlePacket);
multiplePackets.add(packet);
singlePacket = null;
} else {
singlePacket = packet;
}
}
void addArmorStandNameChangePackets(EntityID entityID, String customName);
void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName);
void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack);
void addItemStackChangePackets(EntityID entityID, ItemStack itemStack);
void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ);
void addEntityDestroyPackets(EntityID... entityIDs);
void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ);
void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID);
void sendTo(Player player);
public void sendTo(Player player) {
if (multiplePackets != null) {
for (NMSPacket packet : multiplePackets) {
packet.sendTo(player);
}
} else if (singlePacket != null) {
singlePacket.sendTo(player);
}
}
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.common.nms.entity;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
public interface ClickableNMSPacketEntity extends NMSPacketEntity {
EntityID getID();
void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ);
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.common.nms.entity;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import org.bukkit.inventory.ItemStack;
public interface ItemNMSPacketEntity extends NMSPacketEntity {
void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack);
void addChangePackets(NMSPacketList packetList, ItemStack itemStack);
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.common.nms.entity;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
public interface NMSPacketEntity {
void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ);
void addDestroyPackets(NMSPacketList packetList);
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.common.nms.entity;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
public interface TextNMSPacketEntity extends NMSPacketEntity {
void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ);
void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text);
void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText);
void addChangePackets(NMSPacketList packetList, String text);
void addChangePackets(NMSPacketList packetList, IndividualText individualText);
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_10_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_10_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.NetworkManager;
import net.minecraft.server.v1_10_R1.PlayerConnection;
@ -65,14 +67,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_10_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_10_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_11_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_11_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_11_R1.PlayerConnection;
@ -65,14 +67,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_11_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_11_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_12_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_12_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_12_R1.Entity;
import net.minecraft.server.v1_12_R1.NetworkManager;
import net.minecraft.server.v1_12_R1.PlayerConnection;
@ -65,14 +67,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_12_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_12_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_13_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_13_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_13_R2.Entity;
import net.minecraft.server.v1_13_R2.NetworkManager;
import net.minecraft.server.v1_13_R2.PlayerConnection;
@ -65,14 +67,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_13_R2;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_13_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_14_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(EntityLivingSpawnNMSPacket.builder(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_14_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(EntityLivingSpawnNMSPacket.builder(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.NetworkManager;
import net.minecraft.server.v1_14_R1.PlayerConnection;
@ -50,14 +52,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,101 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_14_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityLivingSpawnNMSPacket.builder(
entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_14_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(EntityLivingSpawnNMSPacket.builder(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(EntityLivingSpawnNMSPacket.builder(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityLivingSpawnNMSPacket.builder(
armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_15_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(slimeID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_15_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.NetworkManager;
import net.minecraft.server.v1_15_R1.PlayerConnection;
@ -50,14 +52,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,104 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_15_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_15_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(slimeID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_16_R1.Entity;
import net.minecraft.server.v1_16_R1.NetworkManager;
import net.minecraft.server.v1_16_R1.PlayerConnection;
@ -50,14 +52,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,104 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R1;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(slimeID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_16_R2.Entity;
import net.minecraft.server.v1_16_R2.NetworkManager;
import net.minecraft.server.v1_16_R2.PlayerConnection;
@ -50,14 +52,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,104 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R2;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(slimeID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_16_R3.Entity;
import net.minecraft.server.v1_16_R3.NetworkManager;
import net.minecraft.server.v1_16_R3.PlayerConnection;
@ -50,14 +52,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,104 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R3;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_16_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_17_R1;
import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntList;
import java.lang.reflect.Field;
class PacketHelper {
private static final boolean USE_ENTITY_LIST_DESTROY_PACKET = useEntityListDestroyPacket();
static void addDestroyPackets(NMSPacketList packetList, EntityID... entityIDs) {
if (USE_ENTITY_LIST_DESTROY_PACKET) {
packetList.add(new EntityListDestroyNMSPacket(entityIDs));
} else {
for (EntityID entityID : entityIDs) {
packetList.add(new EntityDestroyNMSPacket(entityID));
}
}
}
private static boolean useEntityListDestroyPacket() {
try {
for (Field field : PacketPlayOutEntityDestroy.class.getDeclaredFields()) {
if (field.getType() == IntList.class) {
return true;
}
}
return false;
} catch (Throwable t) {
Log.warning("Could not detect PacketPlayOutEntityDestroy details, error can be ignored if on Minecraft 1.17.1+", t);
return true; // Assume newer Minecraft version
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_17_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(slimeID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
PacketHelper.addDestroyPackets(packetList, slimeID, vehicleID);
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_17_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
PacketHelper.addDestroyPackets(packetList, itemID, vehicleID);
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.network.NetworkManager;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.entity.Entity;
@ -49,14 +51,23 @@ public class VersionNMSManager implements NMSManager {
}
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,131 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_17_R1;
import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntList;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Field;
class VersionNMSPacketList extends AbstractNMSPacketList {
private static final boolean USE_ENTITY_LIST_DESTROY_PACKET = useEntityListDestroyPacket();
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
if (USE_ENTITY_LIST_DESTROY_PACKET) {
add(new EntityListDestroyNMSPacket(entityIDs));
} else {
for (EntityID entityID : entityIDs) {
add(new EntityDestroyNMSPacket(entityID));
}
}
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
private static boolean useEntityListDestroyPacket() {
try {
for (Field field : PacketPlayOutEntityDestroy.class.getDeclaredFields()) {
if (field.getType() == IntList.class) {
return true;
}
}
return false;
} catch (Throwable t) {
Log.warning("Could not detect PacketPlayOutEntityDestroy details, error can be ignored if on Minecraft 1.17.1+", t);
return true; // Assume newer Minecraft version
}
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_17_R1;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
PacketHelper.addDestroyPackets(packetList, armorStandID);
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_8_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_8_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.NetworkManager;
import net.minecraft.server.v1_8_R3.PlayerConnection;
@ -62,14 +64,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_8_R3;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_8_R3;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_9_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity {
private final EntityID slimeID;
private final EntityID vehicleID;
public VersionClickableNMSPacketEntity(EntityID slimeID, EntityID vehicleID) {
this.slimeID = slimeID;
this.vehicleID = vehicleID;
}
@Override
public EntityID getID() {
return slimeID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, slimeID));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(slimeID, vehicleID));
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_9_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import org.bukkit.inventory.ItemStack;
public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity {
private final EntityID itemID;
private final EntityID vehicleID;
public VersionItemNMSPacketEntity(EntityID itemID, EntityID vehicleID) {
this.itemID = itemID;
this.vehicleID = vehicleID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) {
packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(vehicleID)
.setArmorStandMarker()
.build()
);
packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
packetList.add(new EntityMountNMSPacket(vehicleID, itemID));
}
@Override
public void addChangePackets(NMSPacketList packetList, ItemStack itemStack) {
packetList.add(EntityMetadataNMSPacket.builder(itemID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(itemID, vehicleID));
}
}

View File

@ -15,8 +15,10 @@ import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSErrors;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import net.minecraft.server.v1_9_R2.Entity;
import net.minecraft.server.v1_9_R2.NetworkManager;
import net.minecraft.server.v1_9_R2.PlayerConnection;
@ -65,14 +67,23 @@ public class VersionNMSManager implements NMSManager {
field.setStatic(value);
}
@Override
public EntityID newEntityID() {
private EntityID newEntityID() {
return new EntityID(entityIDGenerator);
}
@Override
public NMSPacketList createPacketList() {
return new VersionNMSPacketList();
public TextNMSPacketEntity newTextPacketEntity() {
return new VersionTextNMSPacketEntity(newEntityID());
}
@Override
public ItemNMSPacketEntity newItemPacketEntity() {
return new VersionItemNMSPacketEntity(newEntityID(), newEntityID());
}
@Override
public ClickableNMSPacketEntity newClickablePacketEntity() {
return new VersionClickableNMSPacketEntity(newEntityID(), newEntityID());
}
@Override

View File

@ -1,103 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_9_R2;
import me.filoghost.holographicdisplays.common.nms.AbstractNMSPacketList;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualCustomName;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import org.bukkit.inventory.ItemStack;
class VersionNMSPacketList extends AbstractNMSPacketList {
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addArmorStandSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, String customName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandSpawnPackets(
EntityID entityID, double positionX, double positionY, double positionZ, IndividualCustomName individualCustomName) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setArmorStandMarker()
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, String customName) {
add(EntityMetadataNMSPacket.builder(entityID)
.setCustomName(customName)
.build()
);
}
@Override
public void addArmorStandNameChangePackets(EntityID entityID, IndividualCustomName individualCustomName) {
add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(entityID)
.setCustomName(individualCustomName.get(player))
.build()
));
}
@Override
public void addItemSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ, ItemStack itemStack) {
add(new EntitySpawnNMSPacket(entityID, EntityTypeID.ITEM, positionX, positionY, positionZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addItemStackChangePackets(EntityID entityID, ItemStack itemStack) {
add(EntityMetadataNMSPacket.builder(entityID)
.setItemStack(itemStack)
.build()
);
}
@Override
public void addSlimeSpawnPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(EntityLivingSpawnNMSPacket.builder(entityID, EntityTypeID.SLIME, positionX, positionY, positionZ)
.setInvisible()
.setSlimeSmall() // Required for a correct client-side collision box
.build()
);
}
@Override
public void addEntityDestroyPackets(EntityID... entityIDs) {
add(new EntityDestroyNMSPacket(entityIDs));
}
@Override
public void addTeleportPackets(EntityID entityID, double positionX, double positionY, double positionZ) {
add(new EntityTeleportNMSPacket(entityID, positionX, positionY, positionZ));
}
@Override
public void addMountPackets(EntityID vehicleEntityID, EntityID passengerEntityID) {
add(new EntityMountNMSPacket(vehicleEntityID, passengerEntityID));
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.nms.v1_9_R2;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket;
import me.filoghost.holographicdisplays.common.nms.IndividualText;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
class VersionTextNMSPacketEntity implements TextNMSPacketEntity {
private final EntityID armorStandID;
VersionTextNMSPacketEntity(EntityID armorStandID) {
this.armorStandID = armorStandID;
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.build()
);
}
@Override
public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(text)
.build()
);
}
@Override
public void addSpawnPackets(
NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) {
packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY, positionZ));
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setArmorStandMarker()
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addChangePackets(NMSPacketList packetList, String text) {
packetList.add(EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(text)
.build()
);
}
@Override
public void addChangePackets(NMSPacketList packetList, IndividualText individualText) {
packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID)
.setCustomName(individualText.get(player))
.build()
));
}
@Override
public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) {
packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY, positionZ));
}
@Override
public void addDestroyPackets(NMSPacketList packetList) {
packetList.add(new EntityDestroyNMSPacket(armorStandID));
}
}

View File

@ -5,28 +5,26 @@
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseClickableLine;
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
import org.jetbrains.annotations.MustBeInvokedByOverriders;
public abstract class ClickableLineTracker<T extends BaseClickableLine> extends PositionBasedLineTracker<T> {
private static final double SLIME_HEIGHT = 0.5;
private static final double CLICKABLE_ENTITY_HEIGHT = 0.5;
private final ClickableNMSPacketEntity clickableEntity;
private final LineClickListener lineClickListener;
private final EntityID vehicleEntityID;
private final EntityID slimeEntityID;
private boolean spawnSlimeEntities;
private boolean spawnSlimeEntitiesChanged;
private boolean spawnClickableEntity;
private boolean spawnClickableEntityChanged;
public ClickableLineTracker(T line, NMSManager nmsManager, LineClickListener lineClickListener) {
super(line, nmsManager);
this.vehicleEntityID = nmsManager.newEntityID();
this.slimeEntityID = nmsManager.newEntityID();
super(line);
this.clickableEntity = nmsManager.newClickablePacketEntity();
this.lineClickListener = lineClickListener;
}
@ -34,7 +32,7 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> extends
@Override
public void onRemoval() {
super.onRemoval();
lineClickListener.unregisterLine(slimeEntityID);
lineClickListener.unregisterLine(clickableEntity.getID());
}
@MustBeInvokedByOverriders
@ -42,14 +40,14 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> extends
protected void detectChanges() {
super.detectChanges();
boolean spawnSlimeEntities = line.getClickListener() != null;
if (this.spawnSlimeEntities != spawnSlimeEntities) {
this.spawnSlimeEntities = spawnSlimeEntities;
this.spawnSlimeEntitiesChanged = true;
if (spawnSlimeEntities) {
lineClickListener.registerLine(slimeEntityID, line);
boolean spawnClickableEntity = line.getClickListener() != null;
if (this.spawnClickableEntity != spawnClickableEntity) {
this.spawnClickableEntity = spawnClickableEntity;
this.spawnClickableEntityChanged = true;
if (spawnClickableEntity) {
lineClickListener.registerLine(clickableEntity.getID(), line);
} else {
lineClickListener.unregisterLine(slimeEntityID);
lineClickListener.unregisterLine(clickableEntity.getID());
}
}
}
@ -58,22 +56,22 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> extends
@Override
protected void clearDetectedChanges() {
super.clearDetectedChanges();
this.spawnSlimeEntitiesChanged = false;
this.spawnClickableEntityChanged = false;
}
@MustBeInvokedByOverriders
@Override
protected void addSpawnPackets(NMSPacketList packetList) {
if (spawnSlimeEntities) {
addSlimeSpawnPackets(packetList);
if (spawnClickableEntity) {
clickableEntity.addSpawnPackets(packetList, positionX, getClickablePositionY(), positionZ);
}
}
@MustBeInvokedByOverriders
@Override
protected void addDestroyPackets(NMSPacketList packetList) {
if (spawnSlimeEntities) {
addSlimeDestroyPackets(packetList);
if (spawnClickableEntity) {
clickableEntity.addDestroyPackets(packetList);
}
}
@ -82,11 +80,11 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> extends
protected void addChangesPackets(NMSPacketList packetList) {
super.addChangesPackets(packetList);
if (spawnSlimeEntitiesChanged) {
if (spawnSlimeEntities) {
addSlimeSpawnPackets(packetList);
if (spawnClickableEntityChanged) {
if (spawnClickableEntity) {
clickableEntity.addSpawnPackets(packetList, positionX, getClickablePositionY(), positionZ);
} else {
addSlimeDestroyPackets(packetList);
clickableEntity.addDestroyPackets(packetList);
}
}
}
@ -94,23 +92,13 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> extends
@MustBeInvokedByOverriders
@Override
protected void addPositionChangePackets(NMSPacketList packetList) {
if (spawnSlimeEntities) {
packetList.addTeleportPackets(vehicleEntityID, positionX, getSlimePositionY(), positionZ);
if (spawnClickableEntity) {
clickableEntity.addTeleportPackets(packetList, positionX, getClickablePositionY(), positionZ);
}
}
private void addSlimeSpawnPackets(NMSPacketList packetList) {
packetList.addArmorStandSpawnPackets(vehicleEntityID, positionX, getSlimePositionY(), positionZ);
packetList.addSlimeSpawnPackets(slimeEntityID, positionX, getSlimePositionY(), positionZ);
packetList.addMountPackets(vehicleEntityID, slimeEntityID);
}
private void addSlimeDestroyPackets(NMSPacketList packetList) {
packetList.addEntityDestroyPackets(slimeEntityID, vehicleEntityID);
}
private double getSlimePositionY() {
return positionY + ((line.getHeight() - SLIME_HEIGHT) / 2);
private double getClickablePositionY() {
return positionY + ((line.getHeight() - CLICKABLE_ENTITY_HEIGHT) / 2);
}
}

View File

@ -5,9 +5,9 @@
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseItemLine;
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
import org.bukkit.entity.Player;
@ -19,19 +19,17 @@ import java.util.Objects;
public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
private final EntityID vehicleEntityID;
private final EntityID itemEntityID;
private final ItemNMSPacketEntity itemEntity;
private ItemStack itemStack;
private boolean itemStackChanged;
private boolean spawnItemEntities;
private boolean spawnItemEntitiesChanged;
private boolean spawnItemEntity;
private boolean spawnItemEntityChanged;
public ItemLineTracker(BaseItemLine line, NMSManager nmsManager, LineClickListener lineClickListener) {
super(line, nmsManager, lineClickListener);
this.vehicleEntityID = nmsManager.newEntityID();
this.itemEntityID = nmsManager.newEntityID();
this.itemEntity = nmsManager.newItemPacketEntity();
}
@MustBeInvokedByOverriders
@ -39,7 +37,7 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void update(Collection<? extends Player> onlinePlayers) {
super.update(onlinePlayers);
if (spawnItemEntities && hasTrackedPlayers()) {
if (spawnItemEntity && hasTrackedPlayers()) {
for (Player trackedPlayer : getTrackedPlayers()) {
if (CollisionHelper.isInPickupRange(trackedPlayer, positionX, positionY, positionZ)) {
line.onPickup(trackedPlayer);
@ -64,10 +62,10 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
this.itemStackChanged = true;
}
boolean spawnItemEntities = itemStack != null;
if (this.spawnItemEntities != spawnItemEntities) {
this.spawnItemEntities = spawnItemEntities;
this.spawnItemEntitiesChanged = true;
boolean spawnItemEntity = itemStack != null;
if (this.spawnItemEntity != spawnItemEntity) {
this.spawnItemEntity = spawnItemEntity;
this.spawnItemEntityChanged = true;
}
}
@ -76,7 +74,7 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void clearDetectedChanges() {
super.clearDetectedChanges();
this.itemStackChanged = false;
this.spawnItemEntitiesChanged = false;
this.spawnItemEntityChanged = false;
}
@MustBeInvokedByOverriders
@ -84,8 +82,8 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void addSpawnPackets(NMSPacketList packetList) {
super.addSpawnPackets(packetList);
if (spawnItemEntities) {
addItemSpawnPackets(packetList);
if (spawnItemEntity) {
itemEntity.addSpawnPackets(packetList, positionX, getItemPositionY(), positionZ, itemStack);
}
}
@ -94,8 +92,8 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void addDestroyPackets(NMSPacketList packetList) {
super.addDestroyPackets(packetList);
if (spawnItemEntities) {
addItemDestroyPackets(packetList);
if (spawnItemEntity) {
itemEntity.addDestroyPackets(packetList);
}
}
@ -104,15 +102,15 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void addChangesPackets(NMSPacketList packetList) {
super.addChangesPackets(packetList);
if (spawnItemEntitiesChanged) {
if (spawnItemEntities) {
addItemSpawnPackets(packetList);
if (spawnItemEntityChanged) {
if (spawnItemEntity) {
itemEntity.addSpawnPackets(packetList, positionX, getItemPositionY(), positionZ, itemStack);
} else {
addItemDestroyPackets(packetList);
itemEntity.addDestroyPackets(packetList);
}
} else if (itemStackChanged) {
// Only send item changes if full spawn/destroy packets were not sent
packetList.addItemStackChangePackets(itemEntityID, itemStack);
itemEntity.addChangePackets(packetList, itemStack);
}
}
@ -121,21 +119,11 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
protected void addPositionChangePackets(NMSPacketList packetList) {
super.addPositionChangePackets(packetList);
if (spawnItemEntities) {
packetList.addTeleportPackets(vehicleEntityID, positionX, getItemPositionY(), positionZ);
if (spawnItemEntity) {
itemEntity.addTeleportPackets(packetList, positionX, getItemPositionY(), positionZ);
}
}
private void addItemSpawnPackets(NMSPacketList packetList) {
packetList.addArmorStandSpawnPackets(vehicleEntityID, positionX, getItemPositionY(), positionZ);
packetList.addItemSpawnPackets(itemEntityID, positionX, getItemPositionY(), positionZ, itemStack);
packetList.addMountPackets(vehicleEntityID, itemEntityID);
}
private void addItemDestroyPackets(NMSPacketList packetList) {
packetList.addEntityDestroyPackets(itemEntityID, vehicleEntityID);
}
private double getItemPositionY() {
return positionY;
}

View File

@ -5,7 +5,6 @@
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramLine;
import org.bukkit.entity.Player;
@ -19,17 +18,15 @@ public abstract class LineTracker<T extends BaseHologramLine> {
protected final T line;
private final Set<Player> trackedPlayers;
private final NMSManager nmsManager;
/**
* Flag to indicate that the line has changed in some way and there could be the need to send update packets.
*/
private boolean lineChanged;
LineTracker(T line, NMSManager nmsManager) {
LineTracker(T line) {
this.line = line;
this.trackedPlayers = new HashSet<>();
this.nmsManager = nmsManager;
}
final boolean shouldBeRemoved() {
@ -63,7 +60,7 @@ public abstract class LineTracker<T extends BaseHologramLine> {
// Then, send the changes (if any) to already tracked players
if (sendChangesPackets) {
if (hasTrackedPlayers()) {
NMSPacketList packetList = nmsManager.createPacketList();
NMSPacketList packetList = new NMSPacketList();
addChangesPackets(packetList);
broadcastPackets(packetList);
}
@ -94,7 +91,7 @@ public abstract class LineTracker<T extends BaseHologramLine> {
if (shouldTrackPlayer(player)) {
if (trackedPlayers.add(player)) {
if (spawnPacketList == null) {
spawnPacketList = nmsManager.createPacketList();
spawnPacketList = new NMSPacketList();
addSpawnPackets(spawnPacketList);
}
spawnPacketList.sendTo(player);
@ -102,7 +99,7 @@ public abstract class LineTracker<T extends BaseHologramLine> {
} else {
if (trackedPlayers.remove(player)) {
if (destroyPacketList == null) {
destroyPacketList = nmsManager.createPacketList();
destroyPacketList = new NMSPacketList();
addDestroyPackets(destroyPacketList);
}
destroyPacketList.sendTo(player);
@ -134,7 +131,7 @@ public abstract class LineTracker<T extends BaseHologramLine> {
return;
}
NMSPacketList destroyPacketList = nmsManager.createPacketList();
NMSPacketList destroyPacketList = new NMSPacketList();
addDestroyPackets(destroyPacketList);
broadcastPackets(destroyPacketList);
trackedPlayers.clear();

View File

@ -5,7 +5,6 @@
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramLine;
import org.bukkit.Location;
@ -21,8 +20,8 @@ abstract class PositionBasedLineTracker<T extends BaseHologramLine> extends Line
protected double positionZ;
private boolean positionChanged;
PositionBasedLineTracker(T line, NMSManager nmsManager) {
super(line, nmsManager);
PositionBasedLineTracker(T line) {
super(line);
}
@MustBeInvokedByOverriders

View File

@ -5,9 +5,9 @@
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextLine;
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
@ -17,7 +17,7 @@ import java.util.Objects;
public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
private final EntityID armorStandEntityID;
private final TextNMSPacketEntity textEntity;
private final DisplayText displayText;
private boolean displayTextChanged;
@ -29,7 +29,7 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
LineClickListener lineClickListener,
PlaceholderTracker placeholderTracker) {
super(line, nmsManager, lineClickListener);
this.armorStandEntityID = nmsManager.newEntityID();
this.textEntity = nmsManager.newTextPacketEntity();
this.displayText = new DisplayText(placeholderTracker);
}
@ -77,14 +77,14 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
super.addSpawnPackets(packetList);
if (!allowPlaceholders) {
packetList.addArmorStandSpawnPackets(
armorStandEntityID, positionX, getArmorStandPositionY(), positionZ, displayText.getWithoutReplacements());
textEntity.addSpawnPackets(
packetList, positionX, getTextPositionY(), positionZ, displayText.getWithoutReplacements());
} else if (displayText.containsIndividualPlaceholders()) {
packetList.addArmorStandSpawnPackets(
armorStandEntityID, positionX, getArmorStandPositionY(), positionZ, displayText::getWithIndividualReplacements);
textEntity.addSpawnPackets(
packetList, positionX, getTextPositionY(), positionZ, displayText::getWithIndividualReplacements);
} else {
packetList.addArmorStandSpawnPackets(
armorStandEntityID, positionX, getArmorStandPositionY(), positionZ, displayText.getWithGlobalReplacements());
textEntity.addSpawnPackets(
packetList, positionX, getTextPositionY(), positionZ, displayText.getWithGlobalReplacements());
}
}
@ -92,7 +92,7 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
@Override
protected void addDestroyPackets(NMSPacketList packetList) {
super.addDestroyPackets(packetList);
packetList.addEntityDestroyPackets(armorStandEntityID);
textEntity.addDestroyPackets(packetList);
}
@Override
@ -101,11 +101,11 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
if (displayTextChanged) {
if (!allowPlaceholders) {
packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText.getWithoutReplacements());
textEntity.addChangePackets(packetList, displayText.getWithoutReplacements());
} else if (displayText.containsIndividualPlaceholders()) {
packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText::getWithIndividualReplacements);
textEntity.addChangePackets(packetList, displayText::getWithIndividualReplacements);
} else {
packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText.getWithGlobalReplacements());
textEntity.addChangePackets(packetList, displayText.getWithGlobalReplacements());
}
}
}
@ -114,10 +114,10 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
@Override
protected void addPositionChangePackets(NMSPacketList packetList) {
super.addPositionChangePackets(packetList);
packetList.addTeleportPackets(armorStandEntityID, positionX, getArmorStandPositionY(), positionZ);
textEntity.addTeleportPackets(packetList, positionX, getTextPositionY(), positionZ);
}
private double getArmorStandPositionY() {
private double getTextPositionY() {
return positionY - 0.29;
}

View File

@ -5,35 +5,28 @@
*/
package me.filoghost.holographicdisplays.plugin.test;
import me.filoghost.holographicdisplays.common.nms.EntityID;
import me.filoghost.holographicdisplays.common.nms.FallbackEntityIDGenerator;
import me.filoghost.holographicdisplays.common.nms.NMSManager;
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
import me.filoghost.holographicdisplays.common.nms.PacketListener;
import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.common.nms.entity.TextNMSPacketEntity;
import org.bukkit.entity.Player;
import java.util.function.Supplier;
import static org.mockito.Mockito.*;
public class TestNMSManager implements NMSManager {
private final Supplier<Integer> entityIDGenerator;
private final NMSPacketList packetList;
public TestNMSManager() {
this.entityIDGenerator = new FallbackEntityIDGenerator();
this.packetList = mock(NMSPacketList.class);
@Override
public TextNMSPacketEntity newTextPacketEntity() {
return null;
}
@Override
public EntityID newEntityID() {
return new EntityID(entityIDGenerator);
public ItemNMSPacketEntity newItemPacketEntity() {
return null;
}
@Override
public NMSPacketList createPacketList() {
return packetList;
public ClickableNMSPacketEntity newClickablePacketEntity() {
return null;
}
@Override