@ -1613,6 +1613,18 @@ public class PlayerListener
book . setItemMeta ( bookdata ) ;
book . setItemMeta ( bookdata ) ;
p . getInventory ( ) . addItem ( book ) ;
p . getInventory ( ) . addItem ( book ) ;
}
}
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".join.halloween_vote_signs" ) ) {
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".join.halloween_vote_signs" , Boolean . valueOf ( true ) ) ;
this . plugin . saveAccountsConfig ( ) ;
ItemStack sign = new ItemStack ( Material . SIGN , 2 ) ;
ItemMeta meta = sign . getItemMeta ( ) ;
meta . setDisplayName ( ChatColor . BLUE + p . getName ( ) ) ;
sign . setItemMeta ( meta ) ;
p . getInventory ( ) . addItem ( sign ) ;
p . sendMessage ( "You have received 2 vote signs. Go vote at the Pumpkin Patch for the best pumpkin! (Note that voting for yourself does not count. Please vote the best of the others' pumpkins.)" ) ;
} else {
p . sendMessage ( "You do not have enough room in your inventory to receive Pumpkin vote signs. Clear some of your inventory and then rejoin." ) ;
}
}
}
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".halloween.chest1" ) ) {
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".halloween.chest1" ) ) {
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest1" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest1" , Boolean . valueOf ( false ) ) ;
@ -1625,10 +1637,16 @@ public class PlayerListener
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest8" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest8" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest9" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest9" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest10" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.chest10" , Boolean . valueOf ( false ) ) ;
this . plugin . saveAccountsConfig ( ) ;
}
}
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".jobs.ultimate" ) ) {
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".jobs.ultimate" ) ) {
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".jobs.ultimate" , String . valueOf ( "None" ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".jobs.ultimate" , String . valueOf ( "None" ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".jobs.ultimatesealed" , Boolean . valueOf ( false ) ) ;
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".jobs.ultimatesealed" , Boolean . valueOf ( false ) ) ;
this . plugin . saveAccountsConfig ( ) ;
}
if ( ! this . plugin . getAccountsConfig ( ) . contains ( p . getName ( ) + ".halloween.wand" ) ) {
this . plugin . getAccountsConfig ( ) . set ( p . getName ( ) + ".halloween.wand" , Long . valueOf ( Bukkit . getWorld ( "world" ) . getFullTime ( ) ) ) ;
this . plugin . saveAccountsConfig ( ) ;
}
}
}
}
//Check if this player has unallocated stat points.
//Check if this player has unallocated stat points.
@ -1729,34 +1747,115 @@ public class PlayerListener
@EventHandler
@EventHandler
public void onPlayerInteract ( PlayerInteractEntityEvent ev ) {
public void onPlayerInteract ( PlayerInteractEntityEvent ev ) {
Entity theAnimal = ev . getRightClicked ( ) ;
Entity theAnimal = ev . getRightClicked ( ) ;
if ( theAnimal . getType ( ) = = EntityType . WOLF ) {
if ( ev . getPlayer ( ) . getItemInHand ( ) . getType ( ) = = Material . getMaterial ( 127 ) ) {
Wolf dog = ( Wolf ) theAnimal ;
if ( this . plugin . getAccountsConfig ( ) . getLong ( ev . getPlayer ( ) . getName ( ) + ".halloween.wand" ) < Bukkit . getWorld ( "world" ) . getFullTime ( ) )
DyeColor dogcolor = dog . getCollarColor ( ) ;
if ( theAnimal . getType ( ) ! = EntityType . PLAYER ) {
Player p = ev . getPlayer ( ) ;
if ( theAnimal instanceof LivingEntity ) {
if ( dog . getOwner ( ) = = null ) {
LivingEntity l = ( LivingEntity ) theAnimal ;
return ;
if ( l . getCustomName ( ) = = null ) {
}
//This is not a boss. Convert it to something else.
if ( p ! = dog . getOwner ( ) ) {
Location oldloc = theAnimal . getLocation ( ) ;
return ;
EntityType newtype = null ;
}
theAnimal . remove ( ) ;
if ( ! dog . isAngry ( ) ) {
EntityType types [ ] = { EntityType . ZOMBIE ,
//Switch state of wolf.
EntityType . BAT ,
//dog.setSitting(!dog.isSitting());
EntityType . CHICKEN ,
return ;
EntityType . COW ,
}
EntityType . CREEPER ,
ev . setCancelled ( true ) ;
EntityType . ENDERMAN ,
double oldhealth = dog . getHealth ( ) ;
EntityType . GIANT ,
dog . setSitting ( true ) ;
EntityType . HORSE ,
dog . remove ( ) ;
EntityType . IRON_GOLEM ,
Location wolfloc = dog . getLocation ( ) ;
EntityType . MINECART ,
World world = Bukkit . getWorld ( "world" ) ;
EntityType . MUSHROOM_COW ,
Entity newAnimal = world . spawnEntity ( wolfloc , EntityType . WOLF ) ;
EntityType . OCELOT ,
Wolf newdog = ( Wolf ) newAnimal ;
EntityType . PIG ,
newdog . setOwner ( p ) ;
EntityType . PIG_ZOMBIE ,
newdog . setHealth ( oldhealth ) ;
EntityType . SHEEP ,
newdog . setSitting ( true ) ;
EntityType . SILVERFISH ,
newdog . setCollarColor ( dogcolor ) ;
EntityType . SKELETON ,
p . sendMessage ( ChatColor . GREEN + "This dog is now happy!" ) ;
EntityType . SNOWMAN ,
EntityType . SPIDER ,
EntityType . SQUID ,
EntityType . VILLAGER ,
EntityType . WITCH ,
EntityType . WOLF } ;
World world = Bukkit . getWorld ( "world" ) ;
Entity newAnimal = world . spawnEntity ( oldloc , types [ ( int ) ( Math . random ( ) * types . length ) ] ) ;
if ( newAnimal instanceof LivingEntity ) {
LivingEntity l2 = ( LivingEntity ) newAnimal ;
l2 . setCustomName ( ChatColor . DARK_AQUA + "Polymorphed Creature" ) ;
}
this . plugin . getAccountsConfig ( ) . set ( ev . getPlayer ( ) . getName ( ) + ".halloween.wand" , Long . valueOf ( Bukkit . getWorld ( "world" ) . getFullTime ( ) + 1200 ) ) ;
} else {
if ( ! l . getCustomName ( ) . contains ( ChatColor . DARK_PURPLE + "" ) ) {
//This is not a boss. Convert it to something else.
Location oldloc = theAnimal . getLocation ( ) ;
EntityType newtype = null ;
theAnimal . remove ( ) ;
EntityType types [ ] = { EntityType . ZOMBIE ,
EntityType . BAT ,
EntityType . CHICKEN ,
EntityType . COW ,
EntityType . CREEPER ,
EntityType . ENDERMAN ,
EntityType . GIANT ,
EntityType . HORSE ,
EntityType . IRON_GOLEM ,
EntityType . MUSHROOM_COW ,
EntityType . OCELOT ,
EntityType . PIG ,
EntityType . PIG_ZOMBIE ,
EntityType . SHEEP ,
EntityType . SILVERFISH ,
EntityType . SKELETON ,
EntityType . SPIDER ,
EntityType . SQUID ,
EntityType . VILLAGER ,
EntityType . WITCH ,
EntityType . WOLF } ;
World world = Bukkit . getWorld ( "world" ) ;
Entity newAnimal = world . spawnEntity ( oldloc , types [ ( int ) ( Math . random ( ) * types . length ) ] ) ;
if ( newAnimal instanceof LivingEntity ) {
LivingEntity l2 = ( LivingEntity ) newAnimal ;
l2 . setCustomName ( ChatColor . DARK_AQUA + "Polymorphed Creature" ) ;
}
this . plugin . getAccountsConfig ( ) . set ( ev . getPlayer ( ) . getName ( ) + ".halloween.wand" , Long . valueOf ( Bukkit . getWorld ( "world" ) . getFullTime ( ) + 1200 ) ) ;
}
}
}
}
} else {
//Make sure we're not polymporphin, otherwise do other things in here.
if ( theAnimal . getType ( ) = = EntityType . WOLF ) {
Wolf dog = ( Wolf ) theAnimal ;
DyeColor dogcolor = dog . getCollarColor ( ) ;
Player p = ev . getPlayer ( ) ;
if ( dog . getOwner ( ) = = null ) {
return ;
}
if ( p ! = dog . getOwner ( ) ) {
return ;
}
if ( ! dog . isAngry ( ) ) {
//Switch state of wolf.
//dog.setSitting(!dog.isSitting());
return ;
}
ev . setCancelled ( true ) ;
double oldhealth = dog . getHealth ( ) ;
dog . setSitting ( true ) ;
dog . remove ( ) ;
Location wolfloc = dog . getLocation ( ) ;
World world = Bukkit . getWorld ( "world" ) ;
Entity newAnimal = world . spawnEntity ( wolfloc , EntityType . WOLF ) ;
Wolf newdog = ( Wolf ) newAnimal ;
newdog . setOwner ( p ) ;
newdog . setHealth ( oldhealth ) ;
newdog . setSitting ( true ) ;
newdog . setCollarColor ( dogcolor ) ;
p . sendMessage ( ChatColor . GREEN + "This dog is now happy!" ) ;
}
}
}
}
}
@ -1806,7 +1905,7 @@ public class PlayerListener
if ( entity instanceof Monster ) {
if ( entity instanceof Monster ) {
LivingEntity test = ( LivingEntity ) entity ;
LivingEntity test = ( LivingEntity ) entity ;
boolean block = false ;
boolean block = false ;
if ( test . getCustomName ( ) ! = null & & test . getCustomName ( ) . contains ( ChatColor . DARK_PURPLE + "" ) ) {
if ( test . getCustomName ( ) ! = null & & ( test . getCustomName ( ) . contains ( ChatColor . DARK_PURPLE + "" ) | | test . getCustomName ( ) . contains ( ChatColor . DARK_AQUA + "Polymorphed Creature" ) ) ) {
for ( int i = - 2 ; i < 3 ; i + + ) {
for ( int i = - 2 ; i < 3 ; i + + ) {
for ( int j = - 2 ; j < 3 ; j + + ) {
for ( int j = - 2 ; j < 3 ; j + + ) {
for ( int k = - 2 ; k < 3 ; k + + ) {
for ( int k = - 2 ; k < 3 ; k + + ) {
@ -2045,23 +2144,29 @@ public class PlayerListener
}
}
}
}
}
}
if ( Bukkit . getWorld ( "world" ) . getHighestBlockYAt ( entity . getLocation ( ) ) > = 96 ) {
if ( ! this . plugin . harrowing_night ) {
//This is a tall world.
if ( Bukkit . getWorld ( "world" ) . getHighestBlockYAt ( entity . getLocation ( ) ) > = 96 ) {
if ( entity . getLocation ( ) . getBlockY ( ) > 104 ) {
//This is a tall world.
despawnchancer * = ( Math . random ( ) * 3 . 0d ) + 1 ;
if ( entity . getLocation ( ) . getBlockY ( ) > 104 ) {
despawnchancer * = ( Math . random ( ) * 3 . 0d ) + 1 ;
} else {
for ( int i = 104 - entity . getLocation ( ) . getBlockY ( ) ; i > 0 ; i - - ) {
despawnchancer / = 1 . 0175d ;
}
}
} else {
} else {
for ( int i = 104 - entity . getLocation ( ) . getBlockY ( ) ; i > 0 ; i - - ) {
//This is a short world.
despawnchancer / = 1 . 0175d ;
if ( entity . getLocation ( ) . getBlockY ( ) > 52 ) {
despawnchancer * = ( Math . random ( ) * 3 . 0d ) + 1 ;
} else {
for ( int i = 52 - entity . getLocation ( ) . getBlockY ( ) ; i > 0 ; i - - ) {
despawnchancer / = 1 . 025d ;
}
}
}
}
}
} else {
} else {
//This is a short world.
for ( int i = 52 ; i > 0 ; i - - ) {
if ( entity . getLocation ( ) . getBlockY ( ) > 52 ) {
despawnchancer / = 1 . 025d ;
despawnchancer * = ( Math . random ( ) * 3 . 0d ) + 1 ;
} else {
for ( int i = 52 - entity . getLocation ( ) . getBlockY ( ) ; i > 0 ; i - - ) {
despawnchancer / = 1 . 025d ;
}
}
}
}
}
//if (e.getSpawnReason()!=SpawnReason.NATURAL) { //If it's a natural spawn, we gotta do it. Ignore our checking stuff.
//if (e.getSpawnReason()!=SpawnReason.NATURAL) { //If it's a natural spawn, we gotta do it. Ignore our checking stuff.
@ -5538,24 +5643,8 @@ public ItemStack getGoodie() {
if ( this . plugin . getAccountsConfig ( ) . getBoolean ( "halloween-enabled" ) ) {
if ( this . plugin . getAccountsConfig ( ) . getBoolean ( "halloween-enabled" ) ) {
e . setDroppedExp ( e . getDroppedExp ( ) * 2 ) ;
e . setDroppedExp ( e . getDroppedExp ( ) * 2 ) ;
}
}
Player p = null ;
if ( f . getKiller ( ) ! = null & & f . getKiller ( ) . getType ( ) = = EntityType . PLAYER ) {
for ( int i = 0 ; i < this . plugin . hitmoblist . size ( ) ; i + + ) {
Player p = f . getKiller ( ) ;
for ( int j = 0 ; j < this . plugin . hitmoblist . get ( i ) . id . size ( ) ; j + + ) {
if ( this . plugin . hitmoblist . get ( i ) . id . contains ( e . getEntity ( ) . getUniqueId ( ) ) ) {
//This is the player that killed. Also identify them.
p = this . plugin . hitmoblist . get ( i ) . p ;
//Bukkit.getPlayer("sigonasr2").sendMessage("Found: "+e.getEntity().getUniqueId().toString());
//this.plugin.gainMoneyExp(this.plugin.hitmoblist.get(i).p,"Support",0.025,3);
this . plugin . hitmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . hitmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) ) ;
if ( e . getDroppedExp ( ) ! = 0 ) {
p . playSound ( p . getLocation ( ) , Sound . ORB_PICKUP , 0 . 9f , 1f ) ;
}
break ;
}
}
}
if ( p ! = null ) {
for ( int x = - 10 ; x < 10 ; x + + ) {
for ( int x = - 10 ; x < 10 ; x + + ) {
for ( int y = - 3 ; y < 3 ; y + + ) {
for ( int y = - 3 ; y < 3 ; y + + ) {
for ( int z = - 10 ; z < 10 ; z + + ) {
for ( int z = - 10 ; z < 10 ; z + + ) {
@ -5586,7 +5675,7 @@ public ItemStack getGoodie() {
if ( this . plugin . supportmoblist . get ( i ) . id . contains ( e . getEntity ( ) . getUniqueId ( ) ) ) {
if ( this . plugin . supportmoblist . get ( i ) . id . contains ( e . getEntity ( ) . getUniqueId ( ) ) ) {
//Award the support player.
//Award the support player.
//Bukkit.getPlayer("sigonasr2").sendMessage("Found: "+e.getEntity().getUniqueId().toString());
//Bukkit.getPlayer("sigonasr2").sendMessage("Found: "+e.getEntity().getUniqueId().toString());
this . plugin . gainMoneyExp ( this . plugin . supportmoblist . get ( i ) . p , "Support" , 0 . 05 , 6 ) ;
this . plugin . gainMoneyExp ( this . plugin . supportmoblist . get ( i ) . p , "Support" , 0 . 025 , 3 ) ;
this . plugin . supportmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . supportmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . supportmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) / 2 ) ;
this . plugin . supportmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) / 2 ) ;
if ( e . getDroppedExp ( ) / 2 ! = 0 ) {
if ( e . getDroppedExp ( ) / 2 ! = 0 ) {
@ -5678,53 +5767,6 @@ public ItemStack getGoodie() {
}
}
}
}
}
}
} else {
//We're going to see if a player killed it themselves then.
Player pp = null ;
for ( int i = 0 ; i < this . plugin . hitmoblist . size ( ) ; i + + ) {
for ( int j = 0 ; j < this . plugin . hitmoblist . get ( i ) . id . size ( ) ; j + + ) {
if ( this . plugin . hitmoblist . get ( i ) . id . contains ( e . getEntity ( ) . getUniqueId ( ) ) ) {
//This is the player that killed. Also identify them.
pp = this . plugin . hitmoblist . get ( i ) . p ;
//Bukkit.getPlayer("sigonasr2").sendMessage("Found: "+e.getEntity().getUniqueId().toString());
//this.plugin.gainMoneyExp(this.plugin.hitmoblist.get(i).p,"Support",0.025,3);
this . plugin . hitmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . hitmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) ) ;
if ( e . getDroppedExp ( ) ! = 0 ) {
pp . playSound ( p . getLocation ( ) , Sound . ORB_PICKUP , 0 . 9f , 1f ) ;
}
break ;
}
}
}
//Check other players and give them assist experience.
for ( int i = 0 ; i < this . plugin . hitmoblist . size ( ) ; i + + ) {
for ( int j = 0 ; j < this . plugin . hitmoblist . get ( i ) . id . size ( ) ; j + + ) {
if ( this . plugin . hitmoblist . get ( i ) . id . contains ( e . getEntity ( ) . getUniqueId ( ) ) & & this . plugin . hitmoblist . get ( i ) . p ! = pp ) {
//This is the player that killed. Also identify them.
Player tempp = this . plugin . hitmoblist . get ( i ) . p ;
if ( this . plugin . PlayerinJob ( tempp , "Support" ) ) {
//Bukkit.getPlayer("sigonasr2").sendMessage("Found: "+e.getEntity().getUniqueId().toString());
//this.plugin.gainMoneyExp(this.plugin.hitmoblist.get(i).p,"Support",0.025,3);
this . plugin . hitmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . hitmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) / 4 ) ;
if ( e . getDroppedExp ( ) / 4 ! = 0 ) {
tempp . playSound ( p . getLocation ( ) , Sound . ORB_PICKUP , 0 . 4f , 0 . 6f ) ;
}
} else {
this . plugin . hitmoblist . get ( i ) . id . remove ( e . getEntity ( ) . getUniqueId ( ) ) ;
this . plugin . hitmoblist . get ( i ) . p . giveExp ( e . getDroppedExp ( ) / 2 ) ;
if ( e . getDroppedExp ( ) / 2 ! = 0 ) {
tempp . playSound ( p . getLocation ( ) , Sound . ORB_PICKUP , 0 . 4f , 0 . 6f ) ;
}
}
break ;
}
}
}
}
}
e . setDroppedExp ( 0 ) ;
e . setDroppedExp ( 0 ) ;
/ *
/ *
@ -6024,70 +6066,72 @@ public ItemStack getGoodie() {
}
}
}
}
}
}
for ( int m = 0 ; m < p . getInventory ( ) . getContents ( ) . length ; m + + ) {
if ( this . plugin . getConfig ( ) . getBoolean ( "halloween-enabled" ) ) {
if ( p . getInventory ( ) . getContents ( ) [ m ] ! = null & & p . getInventory ( ) . getContents ( ) [ m ] . getType ( ) = = Material . PUMPKIN_PIE ) {
for ( int m = 0 ; m < p . getInventory ( ) . getContents ( ) . length ; m + + ) {
//First see if it's a magical pumpkin pie.
if ( p . getInventory ( ) . getContents ( ) [ m ] ! = null & & p . getInventory ( ) . getContents ( ) [ m ] . getType ( ) = = Material . PUMPKIN_PIE ) {
if ( p . getInventory ( ) . getContents ( ) [ m ] . getItemMeta ( ) . getLore ( ) ! = null ) {
//First see if it's a magical pumpkin pie.
//It has lore! See if we can get the number of pumpkin pies from it.
if ( p . getInventory ( ) . getContents ( ) [ m ] . getItemMeta ( ) . getLore ( ) ! = null ) {
int pies = 0 ;
//It has lore! See if we can get the number of pumpkin pies from it.
List < String > data = p . getInventory ( ) . getContents ( ) [ m ] . getItemMeta ( ) . getLore ( ) ;
int pies = 0 ;
//newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory");
List < String > data = p . getInventory ( ) . getContents ( ) [ m ] . getItemMeta ( ) . getLore ( ) ;
ItemStack magic_pie = null ;
//newlore.add("Requires "+((int)(Math.random()*1000)+100)+" Pumpkin Pie in inventory");
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
ItemStack magic_pie = null ;
if ( data . get ( i ) . contains ( "Requires " ) & & data . get ( i ) . contains ( " Pumpkin Pie in inventory" ) ) {
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
pies = Integer . valueOf ( ( data . get ( i ) . replace ( "Requires " , "" ) ) . replace ( " Pumpkin Pie in inventory" , "" ) ) ;
if ( data . get ( i ) . contains ( "Requires " ) & & data . get ( i ) . contains ( " Pumpkin Pie in inventory" ) ) {
Bukkit . getLogger ( ) . info ( "Found the magic pie. Amount required is " + pies ) ;
pies = Integer . valueOf ( ( data . get ( i ) . replace ( "Requires " , "" ) ) . replace ( " Pumpkin Pie in inventory" , "" ) ) ;
magic_pie = p . getInventory ( ) . getContents ( ) [ m ] . clone ( ) ;
Bukkit . getLogger ( ) . info ( "Found the magic pie. Amount required is " + pies ) ;
break ;
magic_pie = p . getInventory ( ) . getContents ( ) [ m ] . clone ( ) ;
}
break ;
}
}
//Now count all pumpkin pies in inventory. If they are greater than the amount in the inventory (and are not special pies), remove them.
int piecount = 0 ;
ItemStack ideal_pie = null ;
for ( int i = 0 ; i < p . getInventory ( ) . getContents ( ) . length ; i + + ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] ! = null & & p . getInventory ( ) . getContents ( ) [ i ] . getType ( ) = = Material . PUMPKIN_PIE & & p . getInventory ( ) . getContents ( ) [ i ] . getItemMeta ( ) . getLore ( ) = = null ) {
piecount + = p . getInventory ( ) . getContents ( ) [ i ] . getAmount ( ) ;
ideal_pie = p . getInventory ( ) . getContents ( ) [ i ] . clone ( ) ;
}
}
}
//Now count all pumpkin pies in inventory. If they are greater than the amount in the inventory (and are not special pies), remove them.
Bukkit . getLogger ( ) . info ( "We have " + piecount + " pies." ) ;
int piecount = 0 ;
if ( ideal_pie ! = null & & magic_pie ! = null & & piecount > = pies ) {
ItemStack ideal_pie = null ;
p . getInventory ( ) . remove ( magic_pie ) ;
//Check to see if there are any pies we need to keep for later.
List < ItemStack > items = new ArrayList < ItemStack > ( ) ;
for ( int i = 0 ; i < p . getInventory ( ) . getContents ( ) . length ; i + + ) {
for ( int i = 0 ; i < p . getInventory ( ) . getContents ( ) . length ; i + + ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] ! = null ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] ! = null & & p . getInventory ( ) . getContents ( ) [ i ] . getType ( ) = = Material . PUMPKIN_PIE & & p . getInventory ( ) . getContents ( ) [ i ] . getItemMeta ( ) . getLore ( ) = = null ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] . getType ( ) = = Material . PUMPKIN_PIE & &
piecount + = p . getInventory ( ) . getContents ( ) [ i ] . getAmount ( ) ;
p . getInventory ( ) . getContents ( ) [ i ] . hasItemMeta ( ) & &
ideal_pie = p . getInventory ( ) . getContents ( ) [ i ] . clone ( ) ;
p . getInventory ( ) . getContents ( ) [ i ] . getItemMeta ( ) . getLore ( ) ! = null ) {
//This is a special pie. Must keep.
items . add ( p . getInventory ( ) . getContents ( ) [ i ] ) ;
}
}
}
}
}
for ( int i = 0 ; i < pies ; i + + ) {
Bukkit . getLogger ( ) . info ( "We have " + piecount + " pies." ) ;
p . getInventory ( ) . remove ( Material . PUMPKIN_PIE ) ;
if ( ideal_pie ! = null & & magic_pie ! = null & & piecount > = pies ) {
//Remove the pies. Remove the magic pie.
p . getInventory ( ) . remove ( magic_pie ) ;
}
//Check to see if there are any pies we need to keep for later.
List < ItemStack > items = new ArrayList < ItemStack > ( ) ;
int amountleft = piecount - pies ;
for ( int i = 0 ; i < p . getInventory ( ) . getContents ( ) . length ; i + + ) {
while ( amountleft > 0 ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] ! = null ) {
if ( amountleft > = 64 ) {
if ( p . getInventory ( ) . getContents ( ) [ i ] . getType ( ) = = Material . PUMPKIN_PIE & &
p . getInventory ( ) . addItem ( new ItemStack ( Material . PUMPKIN_PIE , 64 ) ) ;
p . getInventory ( ) . getContents ( ) [ i ] . hasItemMeta ( ) & &
amountleft - = 64 ;
p . getInventory ( ) . getContents ( ) [ i ] . getItemMeta ( ) . getLore ( ) ! = null ) {
} else {
//This is a special pie. Must keep.
p . getInventory ( ) . addItem ( new ItemStack ( Material . PUMPKIN_PIE , 1 ) ) ;
items . add ( p . getInventory ( ) . getContents ( ) [ i ] ) ;
amountleft - - ;
}
}
}
}
for ( int i = 0 ; i < pies ; i + + ) {
p . getInventory ( ) . remove ( Material . PUMPKIN_PIE ) ;
//Remove the pies. Remove the magic pie.
}
int amountleft = piecount - pies ;
while ( amountleft > 0 ) {
if ( amountleft > = 64 ) {
p . getInventory ( ) . addItem ( new ItemStack ( Material . PUMPKIN_PIE , 64 ) ) ;
amountleft - = 64 ;
} else {
p . getInventory ( ) . addItem ( new ItemStack ( Material . PUMPKIN_PIE , 1 ) ) ;
amountleft - - ;
}
}
for ( int i = 0 ; i < items . size ( ) ; i + + ) {
p . getInventory ( ) . addItem ( items . get ( i ) ) ;
}
//Give a legendary armor/weapon here.
//Bukkit.getLogger().info("LEGENDARY!");
giveLegendaryItem ( p ) ;
p . addPotionEffect ( new PotionEffect ( PotionEffectType . SATURATION , 1728000 , 0 ) ) ;
p . updateInventory ( ) ;
}
}
for ( int i = 0 ; i < items . size ( ) ; i + + ) {
p . getInventory ( ) . addItem ( items . get ( i ) ) ;
}
//Give a legendary armor/weapon here.
//Bukkit.getLogger().info("LEGENDARY!");
giveLegendaryItem ( p ) ;
p . addPotionEffect ( new PotionEffect ( PotionEffectType . SATURATION , 1728000 , 0 ) ) ;
p . updateInventory ( ) ;
}
}
}
}
}
}
@ -8085,7 +8129,7 @@ public ItemStack getGoodie() {
i . setDurability ( ( short ) 0 ) ;
i . setDurability ( ( short ) 0 ) ;
p . getInventory ( ) . addItem ( i ) ;
p . getInventory ( ) . addItem ( i ) ;
}
}
if ( i . hasItemMeta ( ) & & i . getItemMeta ( ) . get Lore( ) ! = null ) {
if ( i . hasItemMeta ( ) & & i . getItemMeta ( ) . has Lore( ) ) {
boolean is_halloween = false ;
boolean is_halloween = false ;
List < String > finallore = new ArrayList < String > ( ) ;
List < String > finallore = new ArrayList < String > ( ) ;
for ( int j = 0 ; j < i . getItemMeta ( ) . getLore ( ) . size ( ) ; j + + ) {
for ( int j = 0 ; j < i . getItemMeta ( ) . getLore ( ) . size ( ) ; j + + ) {
@ -8106,6 +8150,11 @@ public ItemStack getGoodie() {
meta . setLore ( finallore ) ;
meta . setLore ( finallore ) ;
//p.sendMessage("Meta is set.");
//p.sendMessage("Meta is set.");
i . setItemMeta ( meta ) ;
i . setItemMeta ( meta ) ;
if ( this . plugin . inventoryFull ( p ) ) {
//Drop it on the ground since our inventory is full.
p . sendMessage ( ChatColor . LIGHT_PURPLE + "Dropped " + i . getItemMeta ( ) . getDisplayName ( ) + ChatColor . LIGHT_PURPLE + " on the ground since there is no room in your inventory." ) ;
p . getWorld ( ) . dropItemNaturally ( p . getLocation ( ) , i ) ;
}
p . updateInventory ( ) ;
p . updateInventory ( ) ;
}
}
}
}
@ -10856,6 +10905,11 @@ public void onEntityExpode(ExplosionPrimeEvent e) {
boolean largechest = false ;
boolean largechest = false ;
boolean smallchest = false ;
boolean smallchest = false ;
int identifier = - 1 ;
int identifier = - 1 ;
if ( p . getItemInHand ( ) ! = null & & ( p . getItemInHand ( ) . getType ( ) = = Material . getMaterial ( 127 ) ) ) {
p . updateInventory ( ) ;
e . setCancelled ( true ) ;
return ;
}
if ( p . getItemInHand ( ) ! = null & & ( p . getItemInHand ( ) . getType ( ) = = Material . CHEST | | p . getItemInHand ( ) . getType ( ) = = Material . TRAPPED_CHEST ) ) {
if ( p . getItemInHand ( ) ! = null & & ( p . getItemInHand ( ) . getType ( ) = = Material . CHEST | | p . getItemInHand ( ) . getType ( ) = = Material . TRAPPED_CHEST ) ) {
if ( p . getItemInHand ( ) . getItemMeta ( ) . getLore ( ) ! = null ) {
if ( p . getItemInHand ( ) . getItemMeta ( ) . getLore ( ) ! = null ) {
//Check to see if the Lore contains anything.
//Check to see if the Lore contains anything.