Skip to content

Commit

Permalink
Add right clicks at entity event
Browse files Browse the repository at this point in the history
Because Spigot is stupid
  • Loading branch information
mcmonkey4eva committed Jan 16, 2015
1 parent 27637eb commit 66042c9
Showing 1 changed file with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,74 @@ else if (determination.startsWith("CANCELLED"))
event.setCancelled(true);
}

// <--[event]
// @Events
// player right clicks at entity (with <item>)
// player right clicks at entity in <notable cuboid>
// player right clicks at entity in notable cuboid
// player right clicks at <entity> (with <item>)
// player right clicks at <entity> in <notable cuboid>
// player right clicks at <entity> in notable cuboid

// @Triggers when a player right clicks at an entity (Similar to right clicks entity, but for armor stands).
// @Context
// <context.entity> returns the dEntity the player is clicking on.
// <context.item> returns the dItem the player is clicking with.
// <context.cuboids> returns a dList of cuboids that contain the interacted entity.
// <context.location> returns a dLocation of the clicked entity.
//
// @Determine
// "CANCELLED" to stop the click from happening.
//
// -->
@EventHandler
public void playerInteractStand(PlayerInteractAtEntityEvent event) {

Map<String, dObject> context = new HashMap<String, dObject>();
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<String> events = new ArrayList<String>();
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<dCuboid> 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<String> 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 <item>)
Expand All @@ -3495,7 +3563,8 @@ else if (determination.startsWith("CANCELLED"))
// @Context
// <context.entity> returns the dEntity the player is clicking on.
// <context.item> returns the dItem the player is clicking with.
// <context.cuboids> returns a dList of cuboids that contain the interacted entity
// <context.cuboids> returns a dList of cuboids that contain the interacted entity.
// <context.location> returns a dLocation of the clicked entity.
//
// @Determine
// "CANCELLED" to stop the click from happening.
Expand Down

0 comments on commit 66042c9

Please sign in to comment.