Fixed ItemStack deprecation issues.

This commit is contained in:
gmcferrin
2012-12-25 01:01:10 -05:00
parent 5e965aec2c
commit 9af66a8e69
10 changed files with 120 additions and 67 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.mcMMO;
@ -51,7 +52,10 @@ public class Excavation {
int xp;
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0);
item.setData(new MaterialData(block.getTypeId(), block.getData()));
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
xp = ModChecks.getCustomBlock(block).getXpGain();
}
else {

View File

@ -17,6 +17,7 @@ import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Wool;
import com.gmail.nossr50.config.AdvancedConfig;
@ -284,8 +285,7 @@ public class Fishing {
case CREEPER:
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM,
1, (short) 4));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
} else {
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
}
@ -321,17 +321,14 @@ public class Fishing {
if (DROP_NUMBER > 95) {
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
} else if (DROP_NUMBER > 90) {
Misc.dropItem(location, new ItemStack(
Material.MUSHROOM_SOUP));
Misc.dropItem(location, new ItemStack(Material.MUSHROOM_SOUP));
} else if (DROP_NUMBER > 60) {
Misc.dropItem(location, new ItemStack(Material.LEATHER));
} else if (DROP_NUMBER > 30) {
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
} else {
Misc.dropItem(location,
new ItemStack(Material.RED_MUSHROOM));
Misc.randomDropItems(location, new ItemStack(
Material.RED_MUSHROOM), 50, 2);
Misc.dropItem(location, new ItemStack(Material.RED_MUSHROOM));
Misc.randomDropItems(location, new ItemStack(Material.RED_MUSHROOM), 50, 2);
}
break;
@ -341,8 +338,7 @@ public class Fishing {
case PIG_ZOMBIE:
if (DROP_NUMBER > 50) {
Misc.dropItem(location,
new ItemStack(Material.ROTTEN_FLESH));
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
} else {
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
}
@ -366,25 +362,21 @@ public class Fishing {
case SKELETON:
if (((Skeleton) le).getSkeletonType() == SkeletonType.WITHER) {
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(
Material.SKULL_ITEM, 1, (short) 1));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1));
} else if (DROP_NUMBER > 50) {
Misc.dropItem(location, new ItemStack(Material.BONE));
} else {
Misc.dropItem(location, new ItemStack(Material.COAL));
Misc.randomDropItems(location, new ItemStack(
Material.COAL), 50, 2);
Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2);
}
} else {
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(
Material.SKULL_ITEM));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM));
} else if (DROP_NUMBER > 50) {
Misc.dropItem(location, new ItemStack(Material.BONE));
} else {
Misc.dropItem(location, new ItemStack(Material.ARROW));
Misc.randomDropItems(location, new ItemStack(
Material.ARROW), 50, 2);
Misc.randomDropItems(location, new ItemStack(Material.ARROW), 50, 2);
}
}
break;
@ -398,8 +390,7 @@ public class Fishing {
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
} else {
Misc.dropItem(location, new ItemStack(Material.SNOW_BALL));
Misc.randomDropItems(location, new ItemStack(
Material.SNOW_BALL), 50, 4);
Misc.randomDropItems(location, new ItemStack(Material.SNOW_BALL), 50, 4);
}
break;
@ -412,38 +403,33 @@ public class Fishing {
break;
case SQUID:
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1,
(short) 0));
ItemStack item = new ItemStack(Material.INK_SACK, 1, (short) 0);
item.setData(new MaterialData(Material.INK_SACK, (byte) 0x0));
Misc.dropItem(location, item);
break;
case WITCH:
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
if (DROP_NUMBER > 95) {
if (DROP_NUMBER_2 > 66) {
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8197));
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8197));
} else if (DROP_NUMBER_2 > 33) {
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8195));
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8195));
} else {
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8194));
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8194));
}
} else {
if (DROP_NUMBER_2 > 88) {
Misc.dropItem(location, new ItemStack(
Material.GLASS_BOTTLE));
Misc.dropItem(location, new ItemStack(Material.GLASS_BOTTLE));
} else if (DROP_NUMBER_2 > 75) {
Misc.dropItem(location, new ItemStack(
Material.GLOWSTONE_DUST));
Misc.dropItem(location, new ItemStack(Material.GLOWSTONE_DUST));
} else if (DROP_NUMBER_2 > 63) {
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
} else if (DROP_NUMBER_2 > 50) {
Misc.dropItem(location,
new ItemStack(Material.REDSTONE));
Misc.dropItem(location, new ItemStack(Material.REDSTONE));
} else if (DROP_NUMBER_2 > 38) {
Misc.dropItem(location, new ItemStack(
Material.SPIDER_EYE));
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
} else if (DROP_NUMBER_2 > 25) {
Misc.dropItem(location, new ItemStack(Material.STICK));
} else if (DROP_NUMBER_2 > 13) {
@ -456,11 +442,9 @@ public class Fishing {
case ZOMBIE:
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM,
1, (short) 2));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2));
} else {
Misc.dropItem(location,
new ItemStack(Material.ROTTEN_FLESH));
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
}
break;

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@ -240,7 +241,10 @@ public class Herbalism {
break;
default:
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0);
item.setData(new MaterialData(block.getTypeId(), block.getData()));
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
customPlant = true;
xp = ModChecks.getCustomBlock(block).getXpGain();
}

View File

@ -9,6 +9,7 @@ import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.mcMMO;
@ -96,7 +97,10 @@ public class Mining {
default:
if (ModChecks.isCustomMiningBlock(block)) {
Misc.dropItem(location, new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()));
ItemStack dropItem = new ItemStack(block.getTypeId(), 1, (short) 0);
dropItem.setData(new MaterialData(block.getTypeId(), block.getData()));
Misc.dropItem(location, dropItem);
}
break;
}
@ -117,7 +121,9 @@ public class Mining {
switch (type) {
case COAL_ORE:
if (configInstance.getCoalDoubleDropsEnabled()) {
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
item = new ItemStack(Material.COAL, 1, (short) 0);
item.setData(new MaterialData(Material.COAL, CoalType.COAL.getData()));
Misc.dropItem(location, item);
}
break;
@ -166,7 +172,9 @@ public class Mining {
case LAPIS_ORE:
if (configInstance.getLapisDoubleDropsEnabled()) {
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
item = new ItemStack(Material.INK_SACK, 1, (short) 0);
item.setData(new MaterialData(Material.INK_SACK, (byte) 0x4));
Misc.dropItems(location, item, 4);
Misc.randomDropItems(location, item, 50, 4);
}

View File

@ -10,6 +10,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Tree;
import org.getspout.spoutapi.sound.SoundEffect;
@ -97,11 +98,15 @@ public class WoodCutting {
//Prepare ItemStacks
ItemStack item = null;
ItemStack oak = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.GENERIC.getData());
ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData());
ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData());
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData());
ItemStack oak = new ItemStack(Material.LOG, 1, (short) 0);
ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0);
ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0);
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0);
oak.setData(new MaterialData(Material.LOG, TreeSpecies.GENERIC.getData()));
spruce.setData(new MaterialData(Material.LOG, TreeSpecies.REDWOOD.getData()));
birch.setData(new MaterialData(Material.LOG, TreeSpecies.BIRCH.getData()));
jungle.setData(new MaterialData(Material.LOG, TreeSpecies.JUNGLE.getData()));
for (Block x : toBeFelled) {
if (Misc.blockBreakSimulate(x, player, true)) {
if (Config.getInstance().getBlockModsEnabled()) {
@ -204,7 +209,9 @@ public class WoodCutting {
else if (x.getType() == Material.LEAVES) {
final int SAPLING_DROP_CHANCE = 10;
item = new ItemStack(Material.SAPLING, 1, (short) 0, (byte) (x.getData() & 3)); //Drop the right type of sapling
item = new ItemStack(Material.SAPLING, 1, (short) 0);
item.setData(new MaterialData(Material.SAPLING, (byte) (x.getData() & 3))); //Drop the right type of sapling
Misc.randomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
//Remove the block
@ -373,7 +380,9 @@ public class WoodCutting {
}
}
else {
item = new ItemStack(mat, 1, (short) 0, type);
item = new ItemStack(mat, 1, (short) 0);
item.setData(new MaterialData(mat, type));
location = block.getLocation();
TreeSpecies species = TreeSpecies.getByData(type);