Skip to content

Commit

Permalink
closes/opens inv event, smarter location handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 21, 2021
1 parent c1e8a20 commit f6f3e76
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Expand Up @@ -2,6 +2,7 @@

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
Expand Down Expand Up @@ -60,7 +61,11 @@ public boolean matches(ScriptPath path) {
if (!tryInventory(inventory, path.eventArgLowerAt(2))) {
return false;
}
if (!runInCheck(path, inventory.getLocation())) {
LocationTag loc = inventory.getLocation();
if (loc == null) {
loc = player.getLocation();
}
if (!runInCheck(path, loc)) {
return false;
}
return super.matches(path);
Expand Down
Expand Up @@ -6,6 +6,7 @@
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryOpenEvent;
Expand Down Expand Up @@ -57,7 +58,11 @@ public boolean matches(ScriptPath path) {
if (!tryInventory(inventory, path.eventArgLowerAt(2))) {
return false;
}
if (!runInCheck(path, inventory.getLocation())) {
Location loc = inventory.getLocation();
if (loc == null) {
loc = event.getPlayer().getLocation();
}
if (!runInCheck(path, loc)) {
return false;
}
return super.matches(path);
Expand Down
Expand Up @@ -90,7 +90,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
String determinationLower = CoreUtilities.toLowerCase(determination);
if (determinationLower.startsWith("loot:")) {
ListTag list = ListTag.valueOf(determinationLower.substring("loot:".length()), getTagContext(path));
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());
Expand Down

0 comments on commit f6f3e76

Please sign in to comment.