use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemRecipeFormedScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj.canBeType(ItemTag.class)) {
ItemTag result = determinationObj.asType(ItemTag.class, getTagContext(path));
event.getInventory().setResult(result.getItemStack());
return true;
} else {
return super.applyDetermination(path, determinationObj);
}
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityDeathScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
String lower = CoreUtilities.toLowerCase(determination);
if (lower.startsWith("drops ")) {
// legacy drops determination format
lower = lower.substring(6);
determination = determination.substring(6);
}
if (lower.startsWith("no_drops")) {
event.getDrops().clear();
if (lower.endsWith("_or_xp")) {
event.setDroppedExp(0);
}
return true;
} else if (lower.equals("no_xp")) {
event.setDroppedExp(0);
return true;
} else if (lower.equals("keep_inv") && event instanceof PlayerDeathEvent) {
((PlayerDeathEvent) event).setKeepInventory(true);
return true;
} else if (lower.equals("keep_level") && event instanceof PlayerDeathEvent) {
((PlayerDeathEvent) event).setKeepLevel(true);
return true;
} else if (lower.equals("no_message") && event instanceof PlayerDeathEvent) {
((PlayerDeathEvent) event).setDeathMessage(null);
return true;
} else if (determinationObj instanceof ElementTag && ((ElementTag) determinationObj).isInt()) {
event.setDroppedExp(((ElementTag) determinationObj).asInt());
return true;
} else if (Argument.valueOf(lower).matchesArgumentList(ItemTag.class)) {
List<ItemStack> drops = event.getDrops();
drops.clear();
for (ItemTag item : ListTag.getListFor(determinationObj, getTagContext(path)).filter(ItemTag.class, getTagContext(path), true)) {
if (item != null) {
drops.add(item.getItemStack());
}
}
return true;
} else if (event instanceof PlayerDeathEvent) {
((PlayerDeathEvent) event).setDeathMessage(determination);
return true;
} else {
return super.applyDetermination(path, determinationObj);
}
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityDropsItemScriptEvent method onPlayerDropsItem.
@EventHandler
public void onPlayerDropsItem(PlayerDropItemEvent event) {
dropper = new EntityTag(event.getPlayer());
location = dropper.getLocation();
itemEntity = new EntityTag(event.getItemDrop());
EntityTag.rememberEntity(itemEntity.getBukkitEntity());
item = new ItemTag(((Item) itemEntity.getBukkitEntity()).getItemStack());
fire(event);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityDropsItemScriptEvent method onEntityDropsItem.
@EventHandler
public void onEntityDropsItem(EntityDropItemEvent event) {
dropper = new EntityTag(event.getEntity());
location = dropper.getLocation();
itemEntity = new EntityTag(event.getItemDrop());
EntityTag.rememberEntity(itemEntity.getBukkitEntity());
item = new ItemTag(((Item) itemEntity.getBukkitEntity()).getItemStack());
fire(event);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerConsumesScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
if (ItemTag.matches(determination)) {
BukkitTagContext context = new BukkitTagContext(EntityTag.getPlayerFrom(event.getPlayer()), null, new ScriptTag(path.container));
ItemTag newitem = ItemTag.valueOf(determination, context);
if (newitem != null) {
event.setItem(newitem.getItemStack());
return true;
} else {
Debug.echoError("Invalid event 'item' check [" + getName() + "] ('determine item ????'): '" + determination + "' for " + path.container.getName());
}
}
return super.applyDetermination(path, determinationObj);
}
Aggregations