diff --git a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java index cf32b0381b..41a90172da 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java @@ -3482,6 +3482,74 @@ else if (determination.startsWith("CANCELLED")) event.setCancelled(true); } + // <--[event] + // @Events + // player right clicks at entity (with ) + // player right clicks at entity in + // player right clicks at entity in notable cuboid + // player right clicks at (with ) + // player right clicks at in + // player right clicks at in notable cuboid + + // @Triggers when a player right clicks at an entity (Similar to right clicks entity, but for armor stands). + // @Context + // returns the dEntity the player is clicking on. + // returns the dItem the player is clicking with. + // returns a dList of cuboids that contain the interacted entity. + // returns a dLocation of the clicked entity. + // + // @Determine + // "CANCELLED" to stop the click from happening. + // + // --> + @EventHandler + public void playerInteractStand(PlayerInteractAtEntityEvent event) { + + Map context = new HashMap(); + context.put("location", new dLocation(event.getPlayer().getWorld(), + event.getClickedPosition().getX(), + event.getClickedPosition().getY(), + event.getClickedPosition().getZ())); + dEntity entity = new dEntity(event.getRightClicked()); + context.put("entity", entity); + dItem item = new dItem(event.getPlayer().getItemInHand()); + context.put("item", item); + dNPC npc = null; + if (entity.isNPC()) npc = entity.getDenizenNPC(); + List events = new ArrayList(); + events.add("player right clicks at entity"); + events.add("player right clicks at " + entity.identifyType()); + events.add("player right clicks at entity with " + + item.identifySimple()); + events.add("player right clicks at " + entity.identifyType() + " with " + + item.identifySimple()); + events.add("player right clicks at entity with " + + item.identifyMaterial()); + events.add("player right clicks at " + entity.identifyType() + " with " + + item.identifyMaterial()); + // Look for cuboids that contain the block's location + List cuboids = dCuboid.getNotableCuboidsContaining(event.getRightClicked().getLocation()); + if (cuboids.size() > 0) { + events.add("player right clicks at entity in notable cuboid"); + events.add("player right clicks at " + entity.identifyType() + " in notable cuboid"); + } + dList cuboid_context = new dList(); + for (dCuboid cuboid : cuboids) { + events.add("player right clicks entity in " + cuboid.identifySimple()); + events.add("player right clicks " + entity.identifyType() + " in " + cuboid.identifySimple()); + cuboid_context.add(cuboid.identifySimple()); + } + // Add in cuboids context, with either the cuboids or an empty list + context.put("cuboids", cuboid_context); + List determinations = OldEventManager.doEvents(events, + new BukkitScriptEntryData(new dPlayer(event.getPlayer()), npc), context, true); + for (String determination: determinations) { + if (determination.equalsIgnoreCase("CANCELLED")) { + event.setCancelled(true); + } + } + } + // <--[event] // @Events // player right clicks entity (with ) @@ -3495,7 +3563,8 @@ else if (determination.startsWith("CANCELLED")) // @Context // returns the dEntity the player is clicking on. // returns the dItem the player is clicking with. - // returns a dList of cuboids that contain the interacted entity + // returns a dList of cuboids that contain the interacted entity. + // returns a dLocation of the clicked entity. // // @Determine // "CANCELLED" to stop the click from happening.