Skip to content

Commit

Permalink
Merge pull request #3 from Orphey98/holo-attach
Browse files Browse the repository at this point in the history
Added attach() function to TextHologram object
  • Loading branch information
max1mde authored Dec 12, 2024
2 parents c6c4c21 + 0f7c9d4 commit 39b5666
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public void spawn(TextHologram textHologram, Location location) {
this.hologramsMap.put(textHologram.getId(), textHologram);
}

public void attach(TextHologram textHologram, int entityID) {
textHologram.attach(textHologram, entityID);
}

public void register(TextHologram textHologram) {
this.hologramsMap.put(textHologram.getId(), textHologram);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetPassengers;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
import com.maximde.hologramapi.HologramAPI;
import com.maximde.hologramapi.utils.MiniMessage;
Expand Down Expand Up @@ -129,6 +130,14 @@ public void spawn(Location location) {
update();
}

public void attach(TextHologram textHologram, int entityID) {
int[] hologramToArray = { textHologram.getEntityID() };
WrapperPlayServerSetPassengers attachPacket = new WrapperPlayServerSetPassengers(entityID, hologramToArray);
HologramAPI.getInstance().getServer().getScheduler().runTask(HologramAPI.getInstance(), () -> {
sendPacket(attachPacket);
});
}

public TextHologram update() {
HologramAPI.getInstance().getServer().getScheduler().runTask(HologramAPI.getInstance(), () -> {
updateAffectedPlayers();
Expand Down

0 comments on commit 39b5666

Please sign in to comment.