mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
fix: make mount packet sending sync to prevent problems with the backpack staying on the player
This commit is contained in:
@@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.nms;
|
||||
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import me.lojosho.hibiscuscommons.packets.BundledRidingData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -104,5 +105,9 @@ public interface NMSPackets {
|
||||
|
||||
void sendInvisibleEntity(int entityId, EntityType type, Location location, UUID uuid, List<Player> sendTo);
|
||||
|
||||
default void sendBundledRidingPacket(BundledRidingData packet, List<Player> sendTo) {
|
||||
|
||||
}
|
||||
|
||||
Object createMountPacket(int entityId, int[] passengerIds);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.lojosho.hibiscuscommons.packets;
|
||||
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BundledRidingData {
|
||||
|
||||
private final LinkedHashMap<Integer, List<Integer>> QUEUED_PACKETS = new LinkedHashMap<>();
|
||||
|
||||
public BundledRidingData() {
|
||||
|
||||
}
|
||||
|
||||
public void add(int owner, int passenger) {
|
||||
add(owner, List.of(passenger));
|
||||
}
|
||||
|
||||
public void add(int owner, List<Integer> passengers) {
|
||||
QUEUED_PACKETS.put(owner, passengers);
|
||||
}
|
||||
|
||||
public Map<Integer, List<Integer>> getQueued() {
|
||||
return QUEUED_PACKETS;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be sent all at once to the players specified.
|
||||
*/
|
||||
public void send(List<Player> sendTo) {
|
||||
NMSHandlers.getHandler().getPacketHandler().sendBundledRidingPacket(this, sendTo);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user