Added INVENTORY_OPEN as a player event

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-30 22:05:36 +00:00
parent 301b48abea
commit 63181e1c59
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
/**
* Represents a player related inventory event
*/
public class PlayerInventoryEvent extends PlayerEvent {
protected Inventory inventory;
public PlayerInventoryEvent(final Type type, final Player player, final Inventory inventory) {
super(type, player);
this.inventory = inventory;
}
/**
* Gets the Inventory involved in this event
*
* @return Inventory
*/
public Inventory getInventory() {
return inventory;
}
}

View File

@ -89,4 +89,12 @@ public class PlayerListener implements Listener {
*/ */
public void onPlayerAnimation(PlayerAnimationEvent event) { public void onPlayerAnimation(PlayerAnimationEvent event) {
} }
/**
* Called when a player opens an inventory
*
* @param event Relevant event details
*/
public void onInventoryOpen(PlayerInventoryEvent event) {
}
} }

View File

@ -24,6 +24,7 @@ import org.bukkit.event.vehicle.*;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.WorldListener; import org.bukkit.event.world.WorldListener;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.*; import org.bukkit.plugin.*;
/** /**
@ -167,6 +168,11 @@ public final class JavaPluginLoader implements PluginLoader {
((PlayerListener)listener).onPlayerAnimation( (PlayerAnimationEvent)event ); ((PlayerListener)listener).onPlayerAnimation( (PlayerAnimationEvent)event );
} }
}; };
case INVENTORY_OPEN:
return new EventExecutor() { public void execute( Listener listener, Event event ) {
((PlayerListener)listener).onInventoryOpen( (PlayerInventoryEvent)event );
}
};
// Block Events // Block Events
case BLOCK_PHYSICS: case BLOCK_PHYSICS: