mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-21 01:48:54 +00:00
feat: 调整虚拟悬浮物
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
36dd2ac988
commit
ec2498fc48
@ -46,23 +46,20 @@ public abstract class FakeItem extends DisplayItem {
|
||||
this.eid = getFakeEntityId();
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public static boolean isRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
public static void register(final Plugin plugin) {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
if (registered) { return; }
|
||||
final PluginManager pm = Bukkit.getPluginManager();
|
||||
final Plugin p = pm.getPlugin("ProtocolLib");
|
||||
if (p != null) {
|
||||
if (!p.isEnabled()) {
|
||||
pm.enablePlugin(p);
|
||||
}
|
||||
if (!p.isEnabled()) {
|
||||
throw new IllegalStateException("前置插件ProtocolLib启动失败 请检查版本.");
|
||||
}
|
||||
if (!p.isEnabled()) { throw new IllegalStateException("前置插件ProtocolLib启动失败 请检查版本."); }
|
||||
} else {
|
||||
throw new IllegalStateException("服务器未找到前置插件ProtocolLib.");
|
||||
}
|
||||
@ -154,12 +151,8 @@ public abstract class FakeItem extends DisplayItem {
|
||||
}
|
||||
|
||||
private void create() {
|
||||
if (!registered) {
|
||||
throw new IllegalStateException("You have to call the register method first.");
|
||||
}
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
if (!registered) { throw new IllegalStateException("You have to call the register method first."); }
|
||||
if (created) { return; }
|
||||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getSpawnPacket());
|
||||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getVelocityPacket());
|
||||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getMetadataPacket());
|
||||
@ -175,9 +168,7 @@ public abstract class FakeItem extends DisplayItem {
|
||||
}
|
||||
|
||||
private void destory() {
|
||||
if (!created) {
|
||||
return;
|
||||
}
|
||||
if (!created) { return; }
|
||||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDestoryPacket());
|
||||
|
||||
final String chunkId = getChunkIdentifyString(location.getChunk());
|
||||
@ -204,8 +195,15 @@ public abstract class FakeItem extends DisplayItem {
|
||||
return fakePacket;
|
||||
}
|
||||
|
||||
protected abstract PacketContainer getMetadataPacket();
|
||||
protected PacketContainer getMetadataPacket() {
|
||||
return setMetadataPacket(ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA));
|
||||
}
|
||||
|
||||
protected abstract PacketContainer getSpawnPacket();
|
||||
protected abstract PacketContainer setMetadataPacket(PacketContainer fakePacket);
|
||||
|
||||
protected PacketContainer getSpawnPacket() {
|
||||
return setSpawnPacket(ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY));
|
||||
}
|
||||
|
||||
protected abstract PacketContainer setSpawnPacket(PacketContainer fakePacket);
|
||||
}
|
||||
|
@ -6,9 +6,8 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
|
||||
/**
|
||||
@ -29,8 +28,7 @@ public class FakeItem_17_18 extends FakeItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketContainer getMetadataPacket() {
|
||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
|
||||
protected PacketContainer setMetadataPacket(PacketContainer fakePacket) {
|
||||
fakePacket.getIntegers().write(0, eid);
|
||||
final WrappedWatchableObject itemMeta = new WrappedWatchableObject(10, itemStack);
|
||||
final List<WrappedWatchableObject> entityMetaList = new ArrayList<>(1);
|
||||
@ -40,14 +38,12 @@ public class FakeItem_17_18 extends FakeItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketContainer getSpawnPacket() {
|
||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
|
||||
fakePacket.getIntegers().write(0, eid);
|
||||
fakePacket.getIntegers().write(1, getNormalizedDistance(location.getX()));
|
||||
fakePacket.getIntegers().write(2, getNormalizedDistance(location.getY()));
|
||||
fakePacket.getIntegers().write(3, getNormalizedDistance(location.getZ()));
|
||||
fakePacket.getIntegers().write(9, 2);
|
||||
protected PacketContainer setSpawnPacket(PacketContainer fakePacket) {
|
||||
StructureModifier<Integer> is = fakePacket.getIntegers();
|
||||
is.write(0, eid);
|
||||
is.write(1, getNormalizedDistance(location.getX()));
|
||||
is.write(2, getNormalizedDistance(location.getY()));
|
||||
is.write(3, getNormalizedDistance(location.getZ()));
|
||||
return fakePacket;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ package org.maxgamer.QuickShop.Shop.Item;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||
@ -25,8 +24,7 @@ public class FakeItem_19_111 extends FakeItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketContainer getMetadataPacket() {
|
||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
|
||||
protected PacketContainer setMetadataPacket(PacketContainer fakePacket) {
|
||||
fakePacket.getIntegers().write(0, eid);
|
||||
final WrappedDataWatcher wr = new WrappedDataWatcher();
|
||||
final Serializer serializer = WrappedDataWatcher.Registry.getItemStackSerializer(true);
|
||||
@ -37,14 +35,13 @@ public class FakeItem_19_111 extends FakeItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketContainer getSpawnPacket() {
|
||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
|
||||
fakePacket.getIntegers().write(0, eid);
|
||||
fakePacket.getModifier().write(1, uuid);
|
||||
fakePacket.getDoubles().write(0, location.getX());
|
||||
fakePacket.getDoubles().write(1, location.getY());
|
||||
fakePacket.getDoubles().write(2, location.getZ());
|
||||
fakePacket.getIntegers().write(6, 2);
|
||||
protected PacketContainer setSpawnPacket(PacketContainer fakePacket) {
|
||||
StructureModifier<Object> mdf = fakePacket.getModifier();
|
||||
mdf.write(0, eid);
|
||||
mdf.write(1, uuid);
|
||||
mdf.write(2, location.getX());
|
||||
mdf.write(3, location.getY());
|
||||
mdf.write(4, location.getZ());
|
||||
return fakePacket;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user