Added container transaction support for item frames (...)

Fixed ClassCastException when targeting an armor stand with #container
This commit is contained in:
Intelli 2022-02-17 20:56:20 -07:00
parent e462e68806
commit fb79071ee7
23 changed files with 423 additions and 359 deletions

View file

@ -10,6 +10,7 @@ import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -118,6 +119,11 @@ public class BukkitAdapter implements BukkitInterface {
return Material.ITEM_FRAME;
}
@Override
public Material getFrameType(EntityType type) {
return type == EntityType.ITEM_FRAME ? Material.ITEM_FRAME : null;
}
@Override
public Class<?> getFrameClass(Material material) {
return ItemFrame.class;

View file

@ -9,6 +9,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -20,6 +21,8 @@ public interface BukkitInterface {
public Material getFrameType(Entity entity);
public Material getFrameType(EntityType type);
public Class<?> getFrameClass(Material material);
public String parseLegacyName(String name);

View file

@ -15,6 +15,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.PointedDripstone;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.GlowItemFrame;
import org.bukkit.entity.Goat;
import org.bukkit.entity.ItemFrame;
@ -199,6 +200,18 @@ public class Bukkit_v1_17 extends Bukkit_v1_16 implements BukkitInterface {
return (entity instanceof GlowItemFrame) ? Material.GLOW_ITEM_FRAME : Material.ITEM_FRAME;
}
@Override
public Material getFrameType(EntityType type) {
switch (type) {
case ITEM_FRAME:
return Material.ITEM_FRAME;
case GLOW_ITEM_FRAME:
return Material.GLOW_ITEM_FRAME;
default:
return null;
}
}
@Override
public Class<?> getFrameClass(Material material) {
return (material == Material.GLOW_ITEM_FRAME) ? GlowItemFrame.class : ItemFrame.class;