New McMMOItemSpawnEvent

- Changed all of mcMMO to use one drop method to facilitate new event
- Added a missing bit of copyright notice to last event
This commit is contained in:
NuclearW
2012-01-29 02:51:59 -05:00
parent a61efae527
commit 01bbd9bcac
10 changed files with 213 additions and 100 deletions

View File

@ -269,7 +269,7 @@ public class Excavation
for(ItemStack x : is)
{
if(x != null)
loc.getWorld().dropItemNaturally(loc, x);
m.mcDropItem(loc, x);
}
//Handle XP related tasks

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
@ -11,6 +11,7 @@ import org.bukkit.material.Wool;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@ -61,7 +62,7 @@ public class Fishing {
getFishingResultsTier5(player, event);
break;
}
player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.RAW_FISH, 1));
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH, 1));
Users.getProfile(player).addXP(SkillType.FISHING, LoadProperties.mfishing, player);
Skills.XpCheckSkill(SkillType.FISHING, player);
}
@ -673,7 +674,7 @@ public class Fishing {
return;
Combat.dealDamage(le, 1, event.getPlayer());
World world = le.getWorld();
Location loc = le.getLocation();
/* Neutral Mobs */
if(le instanceof Sheep)
@ -685,26 +686,26 @@ public class Fishing {
wool.setColor(sheep.getColor());
ItemStack theWool = wool.toItemStack();
theWool.setAmount((int)(Math.random() * 6));
world.dropItemNaturally(le.getLocation(), theWool);
m.mcDropItem(loc, theWool);
sheep.setSheared(true);
}
}
else if(le instanceof Pig)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.PORK, 1));
m.mcDropItem(loc, new ItemStack(Material.PORK, 1));
}
else if(le instanceof Cow)
{
if(Math.random() * 100 < 99){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk
}
else if(Math.random() * 10 < 5){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.LEATHER, 1));
m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1));
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.RAW_BEEF, 1));
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1));
}
}
@ -712,14 +713,14 @@ public class Fishing {
{
if(Math.random() * 10 <= 7){
if(Math.random() * 10 < 5){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.FEATHER, 1));
m.mcDropItem(loc, new ItemStack(Material.FEATHER, 1));
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.RAW_CHICKEN, 1));
m.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN, 1));
}
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.EGG, 1));
m.mcDropItem(loc, new ItemStack(Material.EGG, 1));
}
}
@ -727,37 +728,37 @@ public class Fishing {
{
if(Math.random() * 100 < 99){
if(Math.random() * 10 < 5){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.MUSHROOM_SOUP, 1)); //rare chance to drop soup
m.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP, 1)); //rare chance to drop soup
}
}
else if(Math.random() * 10 <= 7){
if(Math.random() * 10 < 5){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.LEATHER, 1));
m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1));
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.RAW_BEEF, 1));
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1));
}
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.RED_MUSHROOM, 3));
m.mcDropItem(loc, new ItemStack(Material.RED_MUSHROOM, 3));
//need some way to remove MushroomCow & replace with regular cow when sheared
}
}
else if(le instanceof Squid)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.getMaterial(351), 1, (byte)0, (byte)0));
m.mcDropItem(loc, new ItemStack(Material.getMaterial(351), 1, (byte)0, (byte)0));
}
else if(le instanceof Snowman){
if(Math.random() * 100 < 99){
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.PUMPKIN, 1)); //rare chance to drop pumpkin
m.mcDropItem(loc, new ItemStack(Material.PUMPKIN, 1)); //rare chance to drop pumpkin
}
else{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SNOW_BALL, 5));
m.mcDropItem(loc, new ItemStack(Material.SNOW_BALL, 5));
}
}
@ -765,71 +766,71 @@ public class Fishing {
else if(le instanceof Skeleton)
{
if(Math.random() * 10 < 5)
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.BONE, 1));
m.mcDropItem(loc, new ItemStack(Material.BONE, 1));
else
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.ARROW, 3));
m.mcDropItem(loc, new ItemStack(Material.ARROW, 3));
}
else if(le instanceof Spider)
{
if(Math.random() * 10 < 5)
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SPIDER_EYE, 1));
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1));
else
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.STRING, 1));
m.mcDropItem(loc, new ItemStack(Material.STRING, 1));
}
else if(le instanceof Creeper)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SULPHUR, 1));
m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1));
}
else if(le instanceof Enderman)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.ENDER_PEARL, 1));
m.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL, 1));
}
else if(le instanceof PigZombie)
{
if(Math.random() * 10 < 5)
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.ROTTEN_FLESH, 1));
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1));
else
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.GOLD_NUGGET, 1));
m.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET, 1));
}
else if(le instanceof Blaze)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.BLAZE_ROD, 1));
m.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD, 1));
}
else if(le instanceof CaveSpider)
{
if(Math.random() * 10 < 5)
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SPIDER_EYE, 1));
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1));
else
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.STRING, 1));
m.mcDropItem(loc, new ItemStack(Material.STRING, 1));
}
else if(le instanceof Ghast)
{
if(Math.random() * 10 < 5)
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SULPHUR, 1));
m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1));
else
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.GHAST_TEAR, 1));
m.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR, 1));
}
else if(le instanceof MagmaCube)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.MAGMA_CREAM, 1));
m.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM, 1));
}
else if(le instanceof Slime)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.SLIME_BALL, 1));
m.mcDropItem(loc, new ItemStack(Material.SLIME_BALL, 1));
}
else if(le instanceof Zombie)
{
world.dropItemNaturally(le.getLocation(), new ItemStack(Material.ROTTEN_FLESH, 1));
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1));
}
}
}

View File

@ -82,12 +82,12 @@ public class Herbalism
Location loc = block.getLocation();
ItemStack is = new ItemStack(mat, 1, (byte)0, (byte)0);
PP.addXP(SkillType.HERBALISM, LoadProperties.mwheat, player);
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
//DROP SOME SEEDS
mat = Material.SEEDS;
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
herbalismProcCheck(block, player, event, plugin);
herbalismProcCheck(block, player, event, plugin);
@ -166,18 +166,18 @@ public class Herbalism
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
}
}
//GREEN THUMB
if(Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM))
{
event.setCancelled(true);
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
//DROP SOME SEEDS
mat = Material.SEEDS;
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
block.setData((byte) 0x1); //Change it to first stage
@ -233,7 +233,7 @@ public class Herbalism
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
m.mcDropItem(target.getLocation(), is);
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mcactus, player);
}
@ -272,7 +272,7 @@ public class Herbalism
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
m.mcDropItem(target.getLocation(), is);
}
PP.addXP(SkillType.HERBALISM, LoadProperties.msugar, player);
}
@ -290,7 +290,7 @@ public class Herbalism
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mpumpkin, player);
@ -303,7 +303,7 @@ public class Herbalism
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mmelon, player);
}
@ -316,7 +316,7 @@ public class Herbalism
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mmushroom, player);
@ -327,7 +327,7 @@ public class Herbalism
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null){
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM)){
loc.getWorld().dropItemNaturally(loc, is);
m.mcDropItem(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mflower, player);

View File

@ -84,50 +84,50 @@ public class Mining
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56
&& block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
if(block.getTypeId() == 89)
{
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
if(block.getTypeId() == 73 || block.getTypeId() == 74)
{
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5){
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
}
if(block.getTypeId() == 21)
{
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
}
if(block.getTypeId() == 56)
{
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
if(block.getTypeId() == 1)
{
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
if(block.getTypeId() == 16)
{
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
}
public static void blockProcCheck(Block block, Player player)
@ -291,7 +291,7 @@ public class Mining
}
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -305,7 +305,7 @@ public class Mining
}
mat = Material.getMaterial(87);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -319,7 +319,7 @@ public class Mining
}
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -333,7 +333,7 @@ public class Mining
}
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -346,7 +346,7 @@ public class Mining
blockProcCheck(block, player);
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -362,7 +362,7 @@ public class Mining
}
mat = Material.getMaterial(49);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -376,7 +376,7 @@ public class Mining
}
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -389,7 +389,7 @@ public class Mining
blockProcCheck(block, player);
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
@ -404,12 +404,12 @@ public class Mining
}
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
{
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
}
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
@ -423,10 +423,10 @@ public class Mining
}
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}

View File

@ -84,7 +84,7 @@ public class Unarmed {
ItemStack item = defender.getItemInHand();
if(item != null)
{
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
ItemStack itemx = null;
defender.setItemInHand(itemx);
}
@ -99,7 +99,7 @@ public class Unarmed {
ItemStack item = defender.getItemInHand();
if(item != null)
{
loc.getWorld().dropItemNaturally(loc, item);
m.mcDropItem(loc, item);
ItemStack itemx = null;
defender.setItemInHand(itemx);
}

View File

@ -48,7 +48,7 @@ public class WoodCutting
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING))
{
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
block.getWorld().dropItemNaturally(block.getLocation(), item);
m.mcDropItem(block.getLocation(), item);
}
}
}