Search in sources :

Example 6 with MCItemStack

use of com.laytonsmith.abstraction.MCItemStack in project CommandHelper by EngineHub.

the class BukkitMCWorld method spawnParticle.

@Override
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
    try {
        Particle type = Particle.valueOf(pa.name());
        Location loc = ((BukkitMCLocation) l).asLocation();
        if (data != null && type.getDataType().equals(ItemStack.class) && data instanceof MCItemStack) {
            w.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity, ((MCItemStack) data).getHandle());
        } else {
            w.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity);
        }
    } catch (NoClassDefFoundError ex) {
    // probably prior to 1.9
    }
}
Also used : Particle(org.bukkit.Particle) MCItemStack(com.laytonsmith.abstraction.MCItemStack) Location(org.bukkit.Location) MCLocation(com.laytonsmith.abstraction.MCLocation)

Example 7 with MCItemStack

use of com.laytonsmith.abstraction.MCItemStack in project CommandHelper by EngineHub.

the class BukkitMCInventory method addItem.

@Override
public Map<Integer, MCItemStack> addItem(MCItemStack stack) {
    Map<Integer, ItemStack> h = i.addItem(stack == null ? null : ((BukkitMCItemStack) stack).is);
    Map<Integer, MCItemStack> m = new HashMap<>();
    for (Map.Entry<Integer, ItemStack> entry : h.entrySet()) {
        Integer key = entry.getKey();
        ItemStack value = entry.getValue();
        m.put(key, new BukkitMCItemStack(value));
    }
    return m;
}
Also used : MCItemStack(com.laytonsmith.abstraction.MCItemStack) HashMap(java.util.HashMap) MCItemStack(com.laytonsmith.abstraction.MCItemStack) ItemStack(org.bukkit.inventory.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with MCItemStack

use of com.laytonsmith.abstraction.MCItemStack in project CommandHelper by EngineHub.

the class BukkitMCItemFactory method asMetaFor.

@Override
public MCItemMeta asMetaFor(MCItemMeta meta, MCItemStack stack) {
    ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta();
    ItemStack bstack = ((BukkitMCItemStack) stack).asItemStack();
    return BukkitConvertor.BukkitGetCorrectMeta(f.asMetaFor(bmeta, bstack));
}
Also used : MCItemStack(com.laytonsmith.abstraction.MCItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) MCItemMeta(com.laytonsmith.abstraction.MCItemMeta)

Example 9 with MCItemStack

use of com.laytonsmith.abstraction.MCItemStack in project CommandHelper by EngineHub.

the class BukkitMCPlayer method spawnParticle.

@Override
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
    try {
        Particle type = Particle.valueOf(pa.name());
        Location loc = ((BukkitMCLocation) l).asLocation();
        if (data != null && type.getDataType().equals(ItemStack.class) && data instanceof MCItemStack) {
            p.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity, ((MCItemStack) data).getHandle());
        } else {
            p.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity);
        }
    } catch (NoClassDefFoundError ex) {
    // probably prior to 1.9
    }
}
Also used : MCParticle(com.laytonsmith.abstraction.enums.MCParticle) Particle(org.bukkit.Particle) BukkitMCItemStack(com.laytonsmith.abstraction.bukkit.BukkitMCItemStack) MCItemStack(com.laytonsmith.abstraction.MCItemStack) BukkitMCLocation(com.laytonsmith.abstraction.bukkit.BukkitMCLocation) Location(org.bukkit.Location) MCLocation(com.laytonsmith.abstraction.MCLocation) BukkitMCLocation(com.laytonsmith.abstraction.bukkit.BukkitMCLocation)

Example 10 with MCItemStack

use of com.laytonsmith.abstraction.MCItemStack in project CommandHelper by EngineHub.

the class BukkitMCItemFactory method isApplicable.

@Override
public boolean isApplicable(MCItemMeta meta, MCItemStack stack) {
    ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta();
    ItemStack bstack = ((BukkitMCItemStack) stack).asItemStack();
    return f.isApplicable(bmeta, bstack);
}
Also used : MCItemStack(com.laytonsmith.abstraction.MCItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) MCItemMeta(com.laytonsmith.abstraction.MCItemMeta)

Aggregations

MCItemStack (com.laytonsmith.abstraction.MCItemStack)11 MCItemMeta (com.laytonsmith.abstraction.MCItemMeta)4 CArray (com.laytonsmith.core.constructs.CArray)4 CString (com.laytonsmith.core.constructs.CString)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 MCLocation (com.laytonsmith.abstraction.MCLocation)3 CNull (com.laytonsmith.core.constructs.CNull)3 Construct (com.laytonsmith.core.constructs.Construct)3 CREFormatException (com.laytonsmith.core.exceptions.CRE.CREFormatException)3 Location (org.bukkit.Location)3 ItemStack (org.bukkit.inventory.ItemStack)3 MCEnchantment (com.laytonsmith.abstraction.MCEnchantment)2 MCFurnaceRecipe (com.laytonsmith.abstraction.MCFurnaceRecipe)2 MCShapedRecipe (com.laytonsmith.abstraction.MCShapedRecipe)2 MCShapelessRecipe (com.laytonsmith.abstraction.MCShapelessRecipe)2 BukkitMCLocation (com.laytonsmith.abstraction.bukkit.BukkitMCLocation)2 CRECastException (com.laytonsmith.core.exceptions.CRE.CRECastException)2 CRENotFoundException (com.laytonsmith.core.exceptions.CRE.CRENotFoundException)2 CRERangeException (com.laytonsmith.core.exceptions.CRE.CRERangeException)2