@ -9685,12 +9685,15 @@ implements Listener
}
if ( event . getInventory ( ) . getType ( ) = = InventoryType . CRAFTING /*|| event.getInventory().getType()==InventoryType.CHEST*/ /*Buggy for some reason. We can't open chests in chests.*/ ) {
if ( event . getCurrentItem ( ) ! = null ) {
if ( ( event . getCurrentItem ( ) . getType ( ) = = Material . CHEST | | event . getCurrentItem ( ) . getType ( ) = = Material . TRAPPED_CHEST | | event . getCurrentItem ( ) . getType ( ) = = Material . ENDER_CHEST ) & & event . getClick ( ) = = ClickType . RIGHT ) {
if ( ( event . getCurrentItem ( ) . getType ( ) = = Material . CHEST | | event . getCurrentItem ( ) . getType ( ) = = Material . TRAPPED_CHEST | | event . getCurrentItem ( ) . getType ( ) = = Material . ENDER_CHEST ) & & event . getClick ( ) = = ClickType . RIGHT & & event . getCurrentItem ( ) . hasItemMeta ( ) ) {
if ( isItemCube ( event . getCurrentItem ( ) ) ) {
//Only cancel the event and view the Item Cube if it actually is one.
viewItemCube ( p , event . getCurrentItem ( ) ) ;
event . setCancelled ( true ) ;
return ;
}
}
}
} else
if ( event . getInventory ( ) . getType ( ) = = InventoryType . CHEST & & event . getInventory ( ) . getName ( ) . contains ( "Item Cube" ) ) {
//If we click a chest, make sure it's not the same ID chest.
@ -11832,27 +11835,29 @@ implements Listener
}
}
public void viewItemCube ( Player p , ItemStack item_cube ) {
//This function will figure out what type of Item Cube this item is and then display the correct inventory on-screen, also setting up the identifier.
//Note that this function does not check if the item *is* an item cube. It assumes it is.
Cube cube_type = null ;
int identifier = - 1 ;
if ( item_cube . getItemMeta ( ) . getLore ( ) ! = null ) {
public boolean isItemCube ( ItemStack item_cube ) {
if ( item_cube . hasItemMeta ( ) & & item_cube . getItemMeta ( ) . getLore ( ) ! = null ) {
//Check to see if the Lore contains anything.
for ( int i = 0 ; i < item_cube . getItemMeta ( ) . getLore ( ) . size ( ) ; i + + ) {
if ( item_cube . getItemMeta ( ) . getLore ( ) . get ( i ) . equalsIgnoreCase ( ChatColor . AQUA + "Contains 9 item slots." ) ) {
cube_type = Cube . SMALL ;
return true ;
}
if ( item_cube . getItemMeta ( ) . getLore ( ) . get ( i ) . equalsIgnoreCase ( ChatColor . AQUA + "Contains 54 item slots." ) ) {
cube_type = Cube . LARGE ;
return true ;
}
if ( item_cube . getItemMeta ( ) . getLore ( ) . get ( i ) . equalsIgnoreCase ( ChatColor . AQUA + "Contains 27 item slots." ) ) {
cube_type = Cube . ENDER ;
return true ;
}
}
if ( item_cube . getItemMeta ( ) . getLore ( ) . get ( i ) . contains ( "ID#" ) ) {
identifier = Integer . valueOf ( item_cube . getItemMeta ( ) . getLore ( ) . get ( i ) . replace ( "ID#" , "" ) ) ;
}
return false ;
}
public void viewItemCube ( Player p , ItemStack item_cube ) {
//This function will figure out what type of Item Cube this item is and then display the correct inventory on-screen, also setting up the identifier.
Cube cube_type = null ;
int identifier = - 1 ;
if ( isItemCube ( item_cube ) ) {
if ( identifier = = - 1 ) {
//This doesn't have an identifier yet. Create a new one.
identifier = this . plugin . getConfig ( ) . getInt ( "item-cube-numb" ) ;
@ -12024,10 +12029,9 @@ implements Listener
f . set ( "item-" + i , new ItemStack ( Material . AIR ) ) ;
}
f . set ( "item-0" , insert_item ) ;
insert_item . setType ( Material . AIR ) ;
f . set ( "created" , Boolean . valueOf ( true ) ) ;
return insert_item ;
} else {
//return insert_item;
}
//We need to see if we have the inventory opened already...If so we have to add it to THAT one.
Inventory thisinven = Bukkit . createInventory ( p , slots , heading + "Item Cube #" + identifier ) ;
boolean changeinven = false ;
@ -12086,7 +12090,6 @@ implements Listener
return new ItemStack ( insert_item ) ;
}
}
}
public ItemStack insertIntoItemCube ( Player p , ItemStack item_cube , ItemStack insert_item ) {
//This function will attmempt to insert an item into an item cube. It actually returns whatever cannot fit into the