1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-12-27 07:48:48 +00:00

fix: 修复悬浮物初始化错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2017-05-09 21:02:55 +08:00
parent dec12d75cb
commit b3995f3b2f
4 changed files with 8 additions and 6 deletions

View File

@ -78,7 +78,7 @@
<groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId>
<type>jar</type>
<version>1.8</version>
<version>1.7</version>
</dependency>
<dependency>
<groupId>io.github.Cnly.WowSuchCleaner</groupId>

View File

@ -31,15 +31,16 @@ public abstract class DisplayItem {
List<Class<? extends DisplayItem>> fakeItems = Arrays.asList(FakeItem_19_111.class, FakeItem_18.class, FakeItem_17.class);
Log.i("启用虚拟悬浮物 尝试启动中...");
FakeItem.register(plugin);
fakeItems.forEach(c -> {
for (Class<? extends DisplayItem> c : fakeItems) {
try {
c.getConstructor(Location.class, ItemStack.class).newInstance(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), new ItemStack(Material.STONE)).spawn();
displayItemClass = c;
Log.i("虚拟悬浮物功能测试正常(%s)...", c.getSimpleName());
break;
} catch (Throwable e) {
Log.d(e);
}
});
}
if (displayItemClass == null) {
displayItemClass = NormalItem.class;
Log.w("+=========================================");

View File

@ -30,7 +30,7 @@ public class FakeItem_18 extends FakeItem {
@Override
protected PacketContainer setMetadataPacket(PacketContainer fakePacket) {
fakePacket.getIntegers().write(0, eid);
final WrappedWatchableObject itemMeta = new WrappedWatchableObject(10, itemStack);
final WrappedWatchableObject itemMeta = new WrappedWatchableObject(5, itemStack);
final List<WrappedWatchableObject> entityMetaList = new ArrayList<>(1);
entityMetaList.add(itemMeta);
fakePacket.getWatchableCollectionModifier().write(0, entityMetaList);

View File

@ -1,5 +1,7 @@
package org.maxgamer.QuickShop.Shop.Item;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
@ -8,7 +10,6 @@ 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;
import com.google.common.base.Optional;
/**
* Minecraft 虚拟悬浮物品工具类
@ -28,7 +29,7 @@ public class FakeItem_19_111 extends FakeItem {
fakePacket.getIntegers().write(0, eid);
final WrappedDataWatcher wr = new WrappedDataWatcher();
final Serializer serializer = WrappedDataWatcher.Registry.getItemStackSerializer(true);
final WrappedDataWatcherObject object = new WrappedDataWatcher.WrappedDataWatcherObject(6, serializer);
final WrappedDataWatcherObject object = new WrappedDataWatcherObject(6, serializer);
wr.setObject(object, Optional.of(itemStack));
fakePacket.getWatchableCollectionModifier().write(0, wr.getWatchableObjects());
return fakePacket;