Cleanup on Fishing.java, implemented some Enum values elsewhere.

This commit is contained in:
GJ 2012-03-13 03:00:49 -04:00
parent 71e09423fe
commit 2c417d28c5
4 changed files with 319 additions and 338 deletions

View File

@ -18,6 +18,7 @@ import com.gmail.nossr50.spout.SpoutStuff;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.CropState;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -126,7 +127,7 @@ public class mcBlockListener implements Listener {
*/ */
//Green Terra //Green Terra
if (PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && ((mat.equals(Material.CROPS) && block.getData() == (byte) 0x7) || Herbalism.canBeGreenTerra(mat))) { if (PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM); Skills.abilityCheck(player, SkillType.HERBALISM);
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.runnables; package com.gmail.nossr50.runnables;
import org.bukkit.CropState;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -22,20 +23,20 @@ public class GreenThumbTimer implements Runnable {
//This replants the wheat at a certain stage in development based on Herbalism Skill //This replants the wheat at a certain stage in development based on Herbalism Skill
if (!PP.getGreenTerraMode()) { if (!PP.getGreenTerraMode()) {
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) { if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
block.setData((byte) 0x4); block.setData(CropState.MEDIUM.getData());
} }
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 400) { else if (PP.getSkillLevel(SkillType.HERBALISM) >= 400) {
block.setData((byte) 0x3); block.setData(CropState.SMALL.getData());
} }
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 200) { else if (PP.getSkillLevel(SkillType.HERBALISM) >= 200) {
block.setData((byte) 0x2); block.setData(CropState.VERY_SMALL.getData());
} }
else { else {
block.setData((byte) 0x1); block.setData(CropState.GERMINATED.getData());
} }
} }
else { else {
block.setData((byte) 0x4); block.setData(CropState.MEDIUM.getData());
} }
} }
} }

View File

@ -1,11 +1,17 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Wool; import org.bukkit.material.Wool;
@ -22,209 +28,145 @@ import com.gmail.nossr50.locale.mcLocale;
public class Fishing { public class Fishing {
//Return the fishing tier for the player /**
public static int getFishingLootTier(PlayerProfile PP) * Get the player's current fishing loot tier.
{ *
int lvl = PP.getSkillLevel(SkillType.FISHING); * @param PP The profile of the player
* @return the player's current fishing rank
*/
public static int getFishingLootTier(PlayerProfile PP) {
int level = PP.getSkillLevel(SkillType.FISHING);
int fishingTier;
if(lvl >= LoadProperties.fishingTier1 && lvl < LoadProperties.fishingTier2) if (level >= LoadProperties.fishingTier5) {
return 1; fishingTier = 5;
else if (lvl >= LoadProperties.fishingTier2 && lvl < LoadProperties.fishingTier3) }
return 2; else if (level >= LoadProperties.fishingTier4) {
else if (lvl >= LoadProperties.fishingTier3 && lvl < LoadProperties.fishingTier4) fishingTier = 4;
return 3; }
else if (lvl >= LoadProperties.fishingTier4 && lvl < LoadProperties.fishingTier5) else if (level >= LoadProperties.fishingTier3) {
return 4; fishingTier = 3;
else }
return 5; else if (level >= LoadProperties.fishingTier2) {
fishingTier = 2;
}
else {
fishingTier = 1;
} }
public static void getFishingResults(Player player, PlayerFishEvent event) return fishingTier;
{ }
switch(getFishingLootTier(Users.getProfile(player)))
{ /**
* Get item results from Fishing.
*
* @param player The player that was fishing
* @param event The event to modify
*/
private static void getFishingResults(Player player, PlayerFishEvent event) {
PlayerProfile PP = Users.getProfile(player);
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
Item theCatch = (Item) event.getCaught();
switch (getFishingLootTier(PP)) {
case 1: case 1:
getFishingResultsTier1(player, event); rewards = LoadTreasures.fishingRewardsTier1;
break; break;
case 2: case 2:
getFishingResultsTier2(player, event); rewards = LoadTreasures.fishingRewardsTier2;
break; break;
case 3: case 3:
getFishingResultsTier3(player, event); rewards = LoadTreasures.fishingRewardsTier3;
break; break;
case 4: case 4:
getFishingResultsTier4(player, event); rewards = LoadTreasures.fishingRewardsTier4;
break; break;
case 5: case 5:
getFishingResultsTier5(player, event); rewards = LoadTreasures.fishingRewardsTier5;
break;
default:
break; break;
} }
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH, 1));
Users.getProfile(player).addXP(SkillType.FISHING, LoadProperties.mfishing, player); if (LoadProperties.fishingDrops) {
FishingTreasure treasure = rewards.get((int) (Math.random() * rewards.size()));
if (Math.random() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else {
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
}
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change durability to random value
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish
PP.addXP(SkillType.FISHING, LoadProperties.mfishing, player);
Skills.XpCheckSkill(SkillType.FISHING, player); Skills.XpCheckSkill(SkillType.FISHING, player);
} }
private static void getFishingResultsTier1(Player player, PlayerFishEvent event) /**
{ * Process results from Fishing.
Item theCatch = (Item)event.getCaught(); *
if(LoadProperties.fishingDrops) * @param event The event to modify
{ */
List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier1; public static void processResults(PlayerFishEvent event) {
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
//Change durability to random value
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change the damage value
}
private static void getFishingResultsTier2(Player player, PlayerFishEvent event)
{
Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops)
{
List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier2;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
//Change durability to random value
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change the damage value
}
private static void getFishingResultsTier3(Player player, PlayerFishEvent event)
{
Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops)
{
List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier3;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
//Change durability to random value
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change the damage value
}
private static void getFishingResultsTier4(Player player, PlayerFishEvent event)
{
Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops)
{
List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier4;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
//Change durability to random value
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change the damage value
}
private static void getFishingResultsTier5(Player player, PlayerFishEvent event)
{
Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops)
{
List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier5;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
theCatch.setItemStack(treasure.getDrop());
}
}
else
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
//Change durability to random value
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change the damage value
}
public static void processResults(PlayerFishEvent event)
{
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
Fishing.getFishingResults(player, event); getFishingResults(player, event);
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(theCatch.getItemStack().getType() != Material.RAW_FISH) if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
{ final int ENCHANTMENT_CHANCE = 10;
//Inform the player they retrieved a treasure...
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
//Keep track of whether or not the treasure is enchanted
boolean enchanted = false; boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack(); ItemStack fishingResults = theCatch.getItemStack();
if(Repair.isArmor(fishingResults) || Repair.isTools(fishingResults))
{ player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
//Fishing up items will have a 10% chance to enter them into random enchantment lottery if (Repair.isArmor(fishingResults) || Repair.isTools(fishingResults)) {
if(Math.random() * 100 < 10)
{ if (Math.random() * 100 <= ENCHANTMENT_CHANCE) {
for(Enchantment x : Enchantment.values()) for (Enchantment enchantment : Enchantment.values()) {
{ if (enchantment.canEnchantItem(fishingResults)) {
if(x.canEnchantItem(fishingResults))
{ //TODO: Clean this up. It's ugly & unreadable.
//Prevent impossible enchantment combinations //Prevent impossible enchantment combinations
if((fishingResults.containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL) || fishingResults.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS) || if ((fishingResults.containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL) || fishingResults.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS) ||
fishingResults.containsEnchantment(Enchantment.PROTECTION_FIRE) || fishingResults.containsEnchantment(Enchantment.PROTECTION_PROJECTILE)) && fishingResults.containsEnchantment(Enchantment.PROTECTION_FIRE) || fishingResults.containsEnchantment(Enchantment.PROTECTION_PROJECTILE)) &&
(x.equals(Enchantment.PROTECTION_EXPLOSIONS) || x.equals(Enchantment.PROTECTION_PROJECTILE) || x.equals(Enchantment.PROTECTION_FIRE) || x.equals(Enchantment.PROTECTION_ENVIRONMENTAL))){ (enchantment.equals(Enchantment.PROTECTION_EXPLOSIONS) || enchantment.equals(Enchantment.PROTECTION_PROJECTILE) || enchantment.equals(Enchantment.PROTECTION_FIRE) || enchantment.equals(Enchantment.PROTECTION_ENVIRONMENTAL))){
return; return;
} }
//More impossible enchantment combinations //More impossible enchantment combinations
else if((fishingResults.containsEnchantment(Enchantment.DAMAGE_ALL) || fishingResults.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) || fishingResults.containsEnchantment(Enchantment.DAMAGE_UNDEAD)) && else if ((fishingResults.containsEnchantment(Enchantment.DAMAGE_ALL) || fishingResults.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) || fishingResults.containsEnchantment(Enchantment.DAMAGE_UNDEAD)) &&
(x.equals(Enchantment.DAMAGE_ALL) || x.equals(Enchantment.DAMAGE_ARTHROPODS) || x.equals(Enchantment.DAMAGE_UNDEAD))){ (enchantment.equals(Enchantment.DAMAGE_ALL) || enchantment.equals(Enchantment.DAMAGE_ARTHROPODS) || enchantment.equals(Enchantment.DAMAGE_UNDEAD))){
return; return;
} }
//Even more impossible enchantment combinations //Even more impossible enchantment combinations
else if((fishingResults.containsEnchantment(Enchantment.SILK_TOUCH) || fishingResults.containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS)) && else if ((fishingResults.containsEnchantment(Enchantment.SILK_TOUCH) || fishingResults.containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS)) &&
(x.equals(Enchantment.SILK_TOUCH) || x.equals(Enchantment.LOOT_BONUS_BLOCKS))){ (enchantment.equals(Enchantment.SILK_TOUCH) || enchantment.equals(Enchantment.LOOT_BONUS_BLOCKS))){
return; return;
} }
else{ else {
//Actual chance to have an enchantment is related to your fishing skill //Actual chance to have an enchantment is related to your fishing skill
if(Math.random() * 15 < Fishing.getFishingLootTier(PP)) if (Math.random() * 15 < Fishing.getFishingLootTier(PP)) {
{
enchanted = true; enchanted = true;
int randomEnchantLevel = (int)(Math.random() * x.getMaxLevel()) + 1; int randomEnchantLevel = (int)(Math.random() * enchantment.getMaxLevel()) + 1;
if(randomEnchantLevel == 0) if (randomEnchantLevel == 0) {
randomEnchantLevel = 1; randomEnchantLevel = 1;
}
fishingResults.addEnchantment(x, randomEnchantLevel); fishingResults.addEnchantment(enchantment, randomEnchantLevel);
} }
} }
} }
@ -232,134 +174,170 @@ public class Fishing {
} }
} }
//Inform the player of magical properties if (enchanted) {
if(enchanted)
{
player.sendMessage(mcLocale.getString("Fishing.MagicFound")); player.sendMessage(mcLocale.getString("Fishing.MagicFound"));
} }
} }
} }
public static void shakeMob(PlayerFishEvent event)
{ /**
* Shake a mob, have them drop an item.
*
* @param event The event to modify
*/
public static void shakeMob(PlayerFishEvent event) {
final int DROP_NUMBER = (int) (Math.random() * 101);
LivingEntity le = (LivingEntity) event.getCaught(); LivingEntity le = (LivingEntity) event.getCaught();
EntityType type = le.getType(); EntityType type = le.getType();
Location loc = le.getLocation(); Location loc = le.getLocation();
switch(type) switch (type) {
{
case BLAZE: case BLAZE:
m.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD, 1)); m.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD, 1));
break; break;
case CAVE_SPIDER: case CAVE_SPIDER:
if(Math.random() * 10 < 5) if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1)); m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.STRING, 1)); m.mcDropItem(loc, new ItemStack(Material.STRING, 1));
}
break; break;
case CHICKEN: case CHICKEN:
if(Math.random() * 10 <= 7) if (DROP_NUMBER > 66) {
{
if(Math.random() * 10 < 5)
m.mcDropItem(loc, new ItemStack(Material.FEATHER, 1)); m.mcDropItem(loc, new ItemStack(Material.FEATHER, 1));
else }
else if (DROP_NUMBER > 33) {
m.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN, 1)); m.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN, 1));
} }
else else {
m.mcDropItem(loc, new ItemStack(Material.EGG, 1)); m.mcDropItem(loc, new ItemStack(Material.EGG, 1));
}
break; break;
case COW: case COW:
if(Math.random() * 100 >= 99) if (DROP_NUMBER > 99) {
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1));
else if(Math.random() * 10 < 5) }
else if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1)); m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1)); m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1));
}
break; break;
case CREEPER: case CREEPER:
m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1)); m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1));
break; break;
case ENDERMAN: case ENDERMAN:
m.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL, 1)); m.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL, 1));
break; break;
case GHAST: case GHAST:
if(Math.random() * 10 < 5) if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1)); m.mcDropItem(loc, new ItemStack(Material.SULPHUR, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR, 1)); m.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR, 1));
}
break; break;
case MAGMA_CUBE: case MAGMA_CUBE:
m.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM, 1)); m.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM, 1));
break; break;
case MUSHROOM_COW: case MUSHROOM_COW:
if(Math.random() * 100 >= 99) if (DROP_NUMBER > 99) {
{ m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1));
if(Math.random() * 10 < 5)
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET, 1)); //rare chance to drop milk
else
m.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP, 1)); //rare chance to drop soup
} }
else if(Math.random() * 10 <= 7) else if (DROP_NUMBER > 98) {
{ m.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP, 1));
if(Math.random() * 10 < 5) }
else if (DROP_NUMBER > 66) {
m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1)); m.mcDropItem(loc, new ItemStack(Material.LEATHER, 1));
else }
else if (DROP_NUMBER > 33) {
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1)); m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF, 1));
} }
else else {
m.mcDropItem(loc, 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 }
break; break;
case PIG: case PIG:
m.mcDropItem(loc, new ItemStack(Material.PORK, 1)); m.mcDropItem(loc, new ItemStack(Material.PORK, 1));
break; break;
case PIG_ZOMBIE: case PIG_ZOMBIE:
if(Math.random() * 10 < 5) if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1)); m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET, 1)); m.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET, 1));
}
break; break;
case SHEEP: case SHEEP:
Sheep sheep = (Sheep)le; Sheep sheep = (Sheep) le;
if(!sheep.isSheared())
{ if (!sheep.isSheared()) {
Wool wool = new Wool(); Wool wool = new Wool();
wool.setColor(sheep.getColor()); wool.setColor(sheep.getColor());
ItemStack theWool = wool.toItemStack(); ItemStack theWool = wool.toItemStack();
theWool.setAmount((int)(Math.random() * 6)); theWool.setAmount((int)(Math.random() * 6));
m.mcDropItem(loc, theWool); m.mcDropItem(loc, theWool);
sheep.setSheared(true); sheep.setSheared(true);
} }
break; break;
case SKELETON: case SKELETON:
if(Math.random() * 10 < 5) if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.BONE, 1)); m.mcDropItem(loc, new ItemStack(Material.BONE, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.ARROW, 3)); m.mcDropItem(loc, new ItemStack(Material.ARROW, 3));
}
break; break;
case SLIME: case SLIME:
m.mcDropItem(loc, new ItemStack(Material.SLIME_BALL, 1)); m.mcDropItem(loc, new ItemStack(Material.SLIME_BALL, 1));
break; break;
case SNOWMAN: case SNOWMAN:
if(Math.random() * 100 >= 99) if (DROP_NUMBER > 99) {
m.mcDropItem(loc, new ItemStack(Material.PUMPKIN, 1)); //rare chance to drop pumpkin m.mcDropItem(loc, new ItemStack(Material.PUMPKIN, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.SNOW_BALL, 5)); m.mcDropItem(loc, new ItemStack(Material.SNOW_BALL, 5));
}
break; break;
case SPIDER: case SPIDER:
if(Math.random() * 10 < 5) if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1)); m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE, 1));
else }
else {
m.mcDropItem(loc, new ItemStack(Material.STRING, 1)); m.mcDropItem(loc, new ItemStack(Material.STRING, 1));
}
break; break;
case SQUID: case SQUID:
m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (byte)0, (byte)0)); m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (byte) 0x0, DyeColor.BLACK.getData()));
break; break;
case ZOMBIE: case ZOMBIE:
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1)); m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH, 1));
break; break;
default: default:
return; break;
} }
Combat.dealDamage(le, 1); Combat.dealDamage(le, 1);

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.CropState;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -143,7 +144,7 @@ public class Herbalism {
break; break;
case CROPS: case CROPS:
if (data == (byte) 0x7) { if (data == CropState.RIPE.getData()) {
mat = Material.WHEAT; mat = Material.WHEAT;
xp = LoadProperties.mwheat; xp = LoadProperties.mwheat;
greenThumbWheat(block, player, event, plugin); greenThumbWheat(block, player, event, plugin);