changed ItemStack in property from PE to Bukkit
This commit is contained in:
parent
2dd75b4cda
commit
ade20ac869
4 changed files with 10 additions and 11 deletions
|
@ -1,10 +1,8 @@
|
||||||
package lol.pyr.znpcsplus.commands.property;
|
package lol.pyr.znpcsplus.commands.property;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
|
||||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
|
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
|
||||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
|
||||||
import lol.pyr.director.adventure.command.CommandContext;
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.adventure.command.CommandHandler;
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
@ -18,6 +16,7 @@ import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -43,12 +42,12 @@ public class PropertySetCommand implements CommandHandler {
|
||||||
Object value;
|
Object value;
|
||||||
String valueName;
|
String valueName;
|
||||||
if (type == ItemStack.class) {
|
if (type == ItemStack.class) {
|
||||||
org.bukkit.inventory.ItemStack bukkitStack = context.ensureSenderIsPlayer().getInventory().getItemInHand();
|
ItemStack bukkitStack = context.ensureSenderIsPlayer().getInventory().getItemInHand();
|
||||||
if (bukkitStack.getAmount() == 0) {
|
if (bukkitStack.getAmount() == 0) {
|
||||||
value = null;
|
value = null;
|
||||||
valueName = "EMPTY";
|
valueName = "EMPTY";
|
||||||
} else {
|
} else {
|
||||||
value = SpigotConversionUtil.fromBukkitItemStack(bukkitStack);
|
value = bukkitStack;
|
||||||
valueName = bukkitStack.toString();
|
valueName = bukkitStack.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package lol.pyr.znpcsplus.entity;
|
package lol.pyr.znpcsplus.entity;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import lol.pyr.znpcsplus.api.entity.EntityProperty;
|
import lol.pyr.znpcsplus.api.entity.EntityProperty;
|
||||||
import lol.pyr.znpcsplus.api.entity.EntityPropertyRegistry;
|
import lol.pyr.znpcsplus.api.entity.EntityPropertyRegistry;
|
||||||
import lol.pyr.znpcsplus.api.skin.SkinDescriptor;
|
import lol.pyr.znpcsplus.api.skin.SkinDescriptor;
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package lol.pyr.znpcsplus.entity.serializers;
|
package lol.pyr.znpcsplus.entity.serializers;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
|
||||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
|
||||||
import lol.pyr.znpcsplus.entity.PropertySerializer;
|
import lol.pyr.znpcsplus.entity.PropertySerializer;
|
||||||
import lol.pyr.znpcsplus.util.ItemSerializationUtil;
|
import lol.pyr.znpcsplus.util.ItemSerializationUtil;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ItemStackPropertySerializer implements PropertySerializer<ItemStack> {
|
public class ItemStackPropertySerializer implements PropertySerializer<ItemStack> {
|
||||||
@Override
|
@Override
|
||||||
public String serialize(ItemStack property) {
|
public String serialize(ItemStack property) {
|
||||||
return ItemSerializationUtil.itemToB64(SpigotConversionUtil.toBukkitItemStack(property));
|
return ItemSerializationUtil.itemToB64(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack deserialize(String property) {
|
public ItemStack deserialize(String property) {
|
||||||
return SpigotConversionUtil.fromBukkitItemStack(ItemSerializationUtil.itemFromB64(property));
|
return ItemSerializationUtil.itemFromB64(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,8 @@ import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.github.retrooper.packetevents.protocol.player.*;
|
import com.github.retrooper.packetevents.protocol.player.*;
|
||||||
import com.github.retrooper.packetevents.util.Vector3d;
|
import com.github.retrooper.packetevents.util.Vector3d;
|
||||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
|
@ -279,7 +280,7 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
|
|
||||||
for (Map.Entry<String, EquipmentSlot> entry : equipmentSlotMap.entrySet()) {
|
for (Map.Entry<String, EquipmentSlot> entry : equipmentSlotMap.entrySet()) {
|
||||||
if (!properties.hasProperty(propertyRegistry.getByName(entry.getKey()))) continue;
|
if (!properties.hasProperty(propertyRegistry.getByName(entry.getKey()))) continue;
|
||||||
equipements.add(new Equipment(entry.getValue(), properties.getProperty(propertyRegistry.getByName(entry.getKey(), ItemStack.class))));
|
equipements.add(new Equipment(entry.getValue(), SpigotConversionUtil.fromBukkitItemStack(properties.getProperty(propertyRegistry.getByName(entry.getKey(), ItemStack.class)))));
|
||||||
}
|
}
|
||||||
return equipements;
|
return equipements;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue