mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2025-02-05 12:01:21 +01:00
Move teleport method in FakeEntity, create PacketQueue, split each packet in a dedicated method
This commit is contained in:
parent
7fc4459d12
commit
91a96d2f33
@ -1,12 +1,17 @@
|
|||||||
package de.epiceric.shopchest.nms;
|
package de.epiceric.shopchest.nms;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
/**
|
||||||
import org.bukkit.entity.Player;
|
* Represent an ArmorStand that only exists clientside
|
||||||
|
*/
|
||||||
public interface FakeArmorStand extends FakeEntity {
|
public interface FakeArmorStand extends FakeEntity {
|
||||||
|
|
||||||
void sendData(String name, Iterable<Player> receivers);
|
/**
|
||||||
|
* Register a 'metadata' packet in the {@link PacketQueue}
|
||||||
void setLocation(Location location, Iterable<Player> receivers);
|
* <br>
|
||||||
|
* It sets the invisibility, the custom name, make it visible and the marker flag
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
*/
|
||||||
|
void metadata(PacketQueue packetQueue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,44 @@
|
|||||||
package de.epiceric.shopchest.nms;
|
package de.epiceric.shopchest.nms;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent an entity that only exists clientside
|
||||||
|
*/
|
||||||
public interface FakeEntity {
|
public interface FakeEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get entity id
|
||||||
|
*
|
||||||
|
* @return The entity id
|
||||||
|
*/
|
||||||
int getEntityId();
|
int getEntityId();
|
||||||
|
|
||||||
void spawn(UUID uuid, Location location, Iterable<Player> receivers);
|
/**
|
||||||
|
* Register a 'create' packet in the {@link PacketQueue}
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
* @param uuid The {@link UUID} of the entity
|
||||||
|
* @param location The {@link Location} to spawn the entity
|
||||||
|
*/
|
||||||
|
void create(PacketQueue packetQueue, UUID uuid, Location location);
|
||||||
|
|
||||||
void remove(Iterable<Player> receivers);
|
/**
|
||||||
|
* Register a 'remove' packet in the {@link PacketQueue}
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
*/
|
||||||
|
void remove(PacketQueue packetQueue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a 'teleport' packet in the {@link PacketQueue}
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
* @param position The position to teleport the entity
|
||||||
|
*/
|
||||||
|
void teleport(PacketQueue packetQueue, Vector position);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,27 @@
|
|||||||
package de.epiceric.shopchest.nms;
|
package de.epiceric.shopchest.nms;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface FakeItem extends FakeEntity{
|
/**
|
||||||
|
* Represent an Item entity that only exists clientside
|
||||||
|
*/
|
||||||
|
public interface FakeItem extends FakeEntity {
|
||||||
|
|
||||||
void sendData(ItemStack item, Iterable<Player> receivers);
|
/**
|
||||||
|
* Register a 'metadata' packet in the {@link PacketQueue}
|
||||||
|
* <br>
|
||||||
|
* It sets the type of item
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
* @param item The {@link ItemStack} type
|
||||||
|
*/
|
||||||
|
void metadata(PacketQueue packetQueue, ItemStack item);
|
||||||
|
|
||||||
void resetVelocity(Iterable<Player> receivers);
|
/**
|
||||||
|
* Register a zero 'velocity' packet in the {@link PacketQueue} to stop the item from moving
|
||||||
|
*
|
||||||
|
* @param packetQueue The {@link PacketQueue} to store the packet
|
||||||
|
*/
|
||||||
|
void cancelVelocity(PacketQueue packetQueue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package de.epiceric.shopchest.nms;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A queue of packet that can be sent
|
||||||
|
*/
|
||||||
|
public interface PacketQueue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send all packets to players
|
||||||
|
*
|
||||||
|
* @param receivers The {@link Player}s that receives the packets
|
||||||
|
*/
|
||||||
|
void send(Iterable<Player> receivers);
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,32 @@
|
|||||||
package de.epiceric.shopchest.nms;
|
package de.epiceric.shopchest.nms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The platform that create all nms objects
|
||||||
|
*/
|
||||||
public interface Platform {
|
public interface Platform {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link FakeArmorStand} object
|
||||||
|
*
|
||||||
|
* @return a new {@link FakeArmorStand}
|
||||||
|
*/
|
||||||
FakeArmorStand createFakeArmorStand();
|
FakeArmorStand createFakeArmorStand();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link FakeItem} object
|
||||||
|
*
|
||||||
|
* @return a new {@link FakeItem}
|
||||||
|
*/
|
||||||
FakeItem createFakeItem();
|
FakeItem createFakeItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link PacketQueue} object
|
||||||
|
*
|
||||||
|
* @return a new {@link PacketQueue}
|
||||||
|
*/
|
||||||
|
PacketQueue createPacketQueue();
|
||||||
|
|
||||||
|
|
||||||
TextComponentHelper getTextComponentHelper();
|
TextComponentHelper getTextComponentHelper();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user