use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerMendsItemScriptEvent method onPlayerItemMend.
@EventHandler
public void onPlayerItemMend(PlayerItemMendEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
item = new ItemTag(event.getItem());
location = new LocationTag(event.getPlayer().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerTakesFromLecternScriptEvent method onPlayerTakesFromLectern.
@EventHandler
public void onPlayerTakesFromLectern(PlayerTakeLecternBookEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
item = new ItemTag(event.getBook());
location = new LocationTag(event.getLectern().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerFishesScriptEvent method matches.
@Override
public boolean matches(ScriptPath path) {
String fish = path.eventArgLowerAt(2);
if (!fish.isEmpty() && !fish.equals("in") && !fish.equals("while")) {
if (entity == null) {
return false;
}
if (!tryEntity(entity, fish)) {
if (item == null) {
return false;
}
if (!tryItem(item, fish)) {
return false;
}
}
}
String[] data = path.eventArgsLower;
for (int index = 2; index < data.length; index++) {
if (data[index].equals("while") && !data[index + 1].equalsIgnoreCase(state.asString())) {
return false;
}
}
if (!runInCheck(path, hook.getLocation())) {
return false;
}
if (path.switches.containsKey("with")) {
if (!EntityTag.isPlayer(event.getPlayer())) {
return false;
}
ItemStack held = event.getPlayer().getEquipment().getItemInMainHand();
if (held.getType() != Material.FISHING_ROD) {
held = event.getPlayer().getEquipment().getItemInOffHand();
}
if (!runWithCheck(path, new ItemTag(held))) {
return false;
}
}
return super.matches(path);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerFishesScriptEvent method onPlayerFishes.
@EventHandler
public void onPlayerFishes(PlayerFishEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
Entity hookEntity = NMSHandler.getEntityHelper().getFishHook(event);
EntityTag.rememberEntity(hookEntity);
hook = new EntityTag(hookEntity);
state = new ElementTag(event.getState().toString());
item = null;
entity = null;
Entity caughtEntity = event.getCaught();
if (caughtEntity != null) {
EntityTag.rememberEntity(caughtEntity);
entity = new EntityTag(caughtEntity);
if (caughtEntity instanceof Item) {
item = new ItemTag(((Item) caughtEntity).getItemStack());
}
}
this.event = event;
fire(event);
EntityTag.forgetEntity(hookEntity);
EntityTag.forgetEntity(caughtEntity);
}
use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.
the class LootGenerateScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
String determination = determinationObj.toString();
String determinationLower = CoreUtilities.toLowerCase(determination);
if (determinationLower.startsWith("loot:")) {
ListTag list = ListTag.valueOf(determination.substring("loot:".length()), getTagContext(path));
ArrayList<ItemStack> newLoot = new ArrayList<>(list.size());
for (ItemTag item : list.filter(ItemTag.class, getTagContext(path))) {
newLoot.add(item.getItemStack());
}
event.setLoot(newLoot);
return true;
}
}
return super.applyDetermination(path, determinationObj);
}
Aggregations