mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-30 12:44:45 +02:00
Skills refactoring
This commit is contained in:
@ -0,0 +1,308 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlastMining {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Handler for what blocks drop from the explosion.
|
||||
*
|
||||
* @param ores List of ore blocks destroyed by the explosion
|
||||
* @param debris List of non-ore blocks destroyed by the explosion
|
||||
* @param yield Percentage of blocks to drop
|
||||
* @param oreBonus Percentage bonus for ore drops
|
||||
* @param debrisReduction Percentage reduction for non-ore drops
|
||||
* @param extraDrops Number of times to drop each block
|
||||
* @return A list of blocks dropped from the explosion
|
||||
*/
|
||||
private static List<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, int extraDrops) {
|
||||
Iterator<Block> oresIterator = ores.iterator();
|
||||
List<Block> blocksDropped = new ArrayList<Block>();
|
||||
|
||||
while (oresIterator.hasNext()) {
|
||||
Block temp = oresIterator.next();
|
||||
|
||||
if (random.nextFloat() < (yield + oreBonus)) {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
|
||||
if (!temp.hasMetadata("mcmmoPlacedBlock")) {
|
||||
for (int i = 1 ; i < extraDrops ; i++) {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (yield - debrisReduction > 0) {
|
||||
Iterator<Block> debrisIterator = debris.iterator();
|
||||
|
||||
while (debrisIterator.hasNext()) {
|
||||
Block temp = debrisIterator.next();
|
||||
|
||||
if (random.nextFloat() < (yield - debrisReduction))
|
||||
Mining.miningDrops(temp);
|
||||
}
|
||||
}
|
||||
|
||||
return blocksDropped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for explosion drops and XP gain.
|
||||
*
|
||||
* @param player Player triggering the explosion
|
||||
* @param event Event whose explosion is being processed
|
||||
*/
|
||||
public static void dropProcessing(Player player, EntityExplodeEvent event) {
|
||||
final int RANK_1_LEVEL = 125;
|
||||
final int RANK_2_LEVEL = 250;
|
||||
final int RANK_3_LEVEL = 375;
|
||||
final int RANK_4_LEVEL = 500;
|
||||
final int RANK_5_LEVEL = 625;
|
||||
final int RANK_6_LEVEL = 750;
|
||||
final int RANK_7_LEVEL = 875;
|
||||
final int RANK_8_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
float yield = event.getYield();
|
||||
List<Block> blocks = event.blockList();
|
||||
Iterator<Block> iterator = blocks.iterator();
|
||||
|
||||
List<Block> ores = new ArrayList<Block>();
|
||||
List<Block> debris = new ArrayList<Block>();
|
||||
List<Block> xp = new ArrayList<Block>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Block temp = iterator.next();
|
||||
|
||||
if (BlockChecks.isOre(temp.getType())) {
|
||||
ores.add(temp);
|
||||
}
|
||||
else {
|
||||
debris.add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
//Normal explosion
|
||||
if (skillLevel < RANK_1_LEVEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setYield(0);
|
||||
|
||||
//Triple Drops, No debris, +70% ores
|
||||
if (skillLevel >= RANK_8_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .70f, .30f, 3);
|
||||
}
|
||||
|
||||
//Triple Drops, No debris, +65% ores
|
||||
else if (skillLevel >= RANK_7_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .65f, .30f, 3);
|
||||
}
|
||||
|
||||
//Double Drops, No Debris, +60% ores
|
||||
else if (skillLevel >= RANK_6_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .60f, .30f, 2);
|
||||
}
|
||||
|
||||
//Double Drops, No Debris, +55% ores
|
||||
else if (skillLevel >= RANK_5_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .55f, .30f, 2);
|
||||
}
|
||||
|
||||
//No debris, +50% ores
|
||||
else if (skillLevel >= RANK_4_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .50f, .30f, 1);
|
||||
}
|
||||
|
||||
//No debris, +45% ores
|
||||
else if (skillLevel >= RANK_3_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .45f, .30f, 1);
|
||||
}
|
||||
|
||||
//+40% ores, -20% debris
|
||||
else if (skillLevel >= RANK_2_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .40f, .20f, 1);
|
||||
}
|
||||
|
||||
//+35% ores, -10% debris
|
||||
else if (skillLevel >= RANK_1_LEVEL) {
|
||||
xp = explosionYields(ores, debris, yield, .35f, .10f, 1);
|
||||
}
|
||||
|
||||
for (Block block : xp) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
Mining.miningXP(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the blast radius of the explosion.
|
||||
*
|
||||
* @param player Player triggering the explosion
|
||||
* @param event Event whose explosion radius is being changed
|
||||
*/
|
||||
public static void biggerBombs(Player player, ExplosionPrimeEvent event) {
|
||||
final int RANK_1_LEVEL = 250;
|
||||
final int RANK_2_LEVEL = 500;
|
||||
final int RANK_3_LEVEL = 750;
|
||||
final int RANK_4_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
float radius = event.getRadius();
|
||||
|
||||
if (skillLevel < RANK_1_LEVEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= RANK_1_LEVEL) {
|
||||
radius++;
|
||||
}
|
||||
|
||||
if (skillLevel >= RANK_2_LEVEL) {
|
||||
radius++;
|
||||
}
|
||||
|
||||
if (skillLevel >= RANK_3_LEVEL) {
|
||||
radius++;
|
||||
}
|
||||
|
||||
if (skillLevel >= RANK_4_LEVEL) {
|
||||
radius++;
|
||||
}
|
||||
|
||||
event.setRadius(radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases damage dealt by the explosion.
|
||||
*
|
||||
* @param player Player triggering the explosion
|
||||
* @param event Event whose explosion damage is being reduced
|
||||
*/
|
||||
public static void demolitionsExpertise(Player player, EntityDamageEvent event) {
|
||||
final int RANK_1_LEVEL = 500;
|
||||
final int RANK_2_LEVEL = 750;
|
||||
final int RANK_3_LEVEL = 1000;
|
||||
|
||||
int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (skill < RANK_1_LEVEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skill >= RANK_3_LEVEL) {
|
||||
damage = 0;
|
||||
}
|
||||
else if (skill >= RANK_2_LEVEL) {
|
||||
damage = damage / 2;
|
||||
}
|
||||
else if (skill >= RANK_1_LEVEL) {
|
||||
damage = damage/4;
|
||||
}
|
||||
|
||||
event.setDamage(damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detonate TNT for Blast Mining
|
||||
*
|
||||
* @param event The PlayerInteractEvent
|
||||
* @param player Player detonating the TNT
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125)
|
||||
return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (block == null || block.getType() != Material.TNT) {
|
||||
final byte SNOW = 78;
|
||||
final byte AIR = 0;
|
||||
final int BLOCKS_AWAY = 100;
|
||||
|
||||
HashSet<Byte> transparent = new HashSet<Byte>();
|
||||
|
||||
transparent.add(SNOW);
|
||||
transparent.add(AIR);
|
||||
|
||||
block = player.getTargetBlock(transparent, BLOCKS_AWAY);
|
||||
|
||||
if (block.getType() != Material.TNT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (block.getType() == Material.TNT) {
|
||||
event.setCancelled(true); // This is the only way I know to avoid the original TNT to be triggered (in case the player is close to it)
|
||||
}
|
||||
|
||||
if (!Misc.blockBreakSimulate(block, player, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double MAX_DISTANCE_AWAY = 10.0;
|
||||
final int TIME_CONVERSION_FACTOR = 1000;
|
||||
|
||||
AbilityType ability = AbilityType.BLAST_MINING;
|
||||
|
||||
/* Check Cooldown */
|
||||
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send message to nearby players */
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
|
||||
/* Create the TNT entity */
|
||||
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
|
||||
plugin.tntTracker.put(tnt.getEntityId(), player);
|
||||
tnt.setFuseTicks(0);
|
||||
|
||||
/* Disable the original one */
|
||||
block.setType(Material.AIR);
|
||||
|
||||
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
|
||||
PP.setAbilityInformed(ability, false);
|
||||
}
|
||||
}
|
127
src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java
Normal file
127
src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java
Normal file
@ -0,0 +1,127 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
public class Excavation {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Check to see if treasures were found.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @param player The player who broke the block
|
||||
*/
|
||||
public static void excavationProcCheck(Block block, Player player) {
|
||||
Material type = block.getType();
|
||||
Location loc = block.getLocation();
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
|
||||
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
int xp = Config.getInstance().getExcavationBaseXP();
|
||||
|
||||
if (Permissions.getInstance().excavationTreasures(player)) {
|
||||
switch (type) {
|
||||
case DIRT:
|
||||
treasures = LoadTreasures.getInstance().excavationFromDirt;
|
||||
break;
|
||||
|
||||
case GRASS:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGrass;
|
||||
break;
|
||||
|
||||
case SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSand;
|
||||
break;
|
||||
|
||||
case GRAVEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGravel;
|
||||
break;
|
||||
|
||||
case CLAY:
|
||||
treasures = LoadTreasures.getInstance().excavationFromClay;
|
||||
break;
|
||||
|
||||
case MYCEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromMycel;
|
||||
break;
|
||||
|
||||
case SOUL_SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSoulSand;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()) {
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Drop items
|
||||
for (ItemStack x : is) {
|
||||
if (x != null) {
|
||||
Misc.mcDropItem(loc, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Handle XP related tasks
|
||||
PP.addXP(SkillType.EXCAVATION, xp);
|
||||
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle triple drops from Giga Drill Breaker.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block to check
|
||||
*/
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
338
src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java
Normal file
338
src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java
Normal file
@ -0,0 +1,338 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
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.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Fishing {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Get the player's current fishing loot tier.
|
||||
*
|
||||
* @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 (level >= Config.getInstance().getFishingTierLevelsTier5()) {
|
||||
fishingTier = 5;
|
||||
}
|
||||
else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
|
||||
fishingTier = 4;
|
||||
}
|
||||
else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
|
||||
fishingTier = 3;
|
||||
}
|
||||
else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
|
||||
fishingTier = 2;
|
||||
}
|
||||
else {
|
||||
fishingTier = 1;
|
||||
}
|
||||
|
||||
return fishingTier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier3;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier4;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier5;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
}
|
||||
}
|
||||
else {
|
||||
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
||||
}
|
||||
|
||||
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
Skills.XpCheckSkill(SkillType.FISHING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process results from Fishing.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void processResults(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
getFishingResults(player, event);
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
|
||||
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
||||
final int ENCHANTMENT_CHANCE = 10;
|
||||
boolean enchanted = false;
|
||||
ItemStack fishingResults = theCatch.getItemStack();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
||||
|
||||
for (Enchantment oldEnchant : resultEnchantments.keySet()) {
|
||||
if (oldEnchant.conflictsWith(newEnchant)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Actual chance to have an enchantment is related to your fishing skill */
|
||||
if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
|
||||
enchanted = true;
|
||||
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
||||
|
||||
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
||||
randomEnchantLevel = newEnchant.getStartLevel();
|
||||
}
|
||||
|
||||
fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enchanted) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shake a mob, have them drop an item.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void shakeMob(PlayerFishEvent event) {
|
||||
final int DROP_NUMBER = random.nextInt(100);
|
||||
|
||||
LivingEntity le = (LivingEntity) event.getCaught();
|
||||
EntityType type = le.getType();
|
||||
Location loc = le.getLocation();
|
||||
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD));
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
if (DROP_NUMBER > 66) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.FEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.EGG));
|
||||
}
|
||||
break;
|
||||
|
||||
case COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL));
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR));
|
||||
}
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM));
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 98) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
|
||||
}
|
||||
else if (DROP_NUMBER > 66) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.PORK));
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET));
|
||||
}
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) le;
|
||||
|
||||
if (!sheep.isSheared()) {
|
||||
Wool wool = new Wool();
|
||||
wool.setColor(sheep.getColor());
|
||||
|
||||
ItemStack theWool = wool.toItemStack();
|
||||
theWool.setAmount(1 + random.nextInt(6));
|
||||
|
||||
Misc.mcDropItem(loc, theWool);
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.BONE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.ARROW), 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SLIME_BALL));
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.PUMPKIN));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Combat.dealDamage(le, 1);
|
||||
}
|
||||
}
|
329
src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java
Normal file
329
src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java
Normal file
@ -0,0 +1,329 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Herbalism {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Activate the Green Terra ability.
|
||||
*
|
||||
* @param player The player activating the ability
|
||||
* @param block The block to be changed by Green Terra
|
||||
*/
|
||||
public static void greenTerra(Player player, Block block) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||
|
||||
if (!hasSeeds) {
|
||||
player.sendMessage("You need more seeds to spread Green Terra"); //TODO: Needs more locale.
|
||||
}
|
||||
else if (hasSeeds && !block.getType().equals(Material.WHEAT)) {
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
player.updateInventory();
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
public static void greenTerraConvert(Player player, Block block) {
|
||||
Material type = block.getType();
|
||||
|
||||
if (Misc.blockBreakSimulate(block, player, false)) {
|
||||
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) {
|
||||
block.setData((byte) 0x1); //Set type of the brick to mossy
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type.equals(Material.DIRT)) {
|
||||
block.setType(Material.GRASS);
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type.equals(Material.COBBLESTONE)) {
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for extra Herbalism drops.
|
||||
*
|
||||
* @param block The block to check for extra drops
|
||||
* @param player The player getting extra drops
|
||||
* @param event The event to use for Green Thumb
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
|
||||
final PlayerProfile PP = Users.getProfile(player);
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int id = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
Byte data = block.getData();
|
||||
Location loc = block.getLocation();
|
||||
Material mat = null;
|
||||
int xp = 0;
|
||||
int catciDrops = 0;
|
||||
int caneDrops = 0;
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
case RED_MUSHROOM:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPMushrooms();
|
||||
}
|
||||
break;
|
||||
|
||||
case CACTUS:
|
||||
for (int y = 0; y <= 2; y++) {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
catciDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPCactus();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CROPS:
|
||||
if (data == CropState.RIPE.getData()) {
|
||||
mat = Material.WHEAT;
|
||||
xp = Config.getInstance().getHerbalismXPWheat();
|
||||
|
||||
if (Permissions.getInstance().greenThumbWheat(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.MELON;
|
||||
xp = Config.getInstance().getHerbalismXPMelon();
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (data == (byte) 0x3) {
|
||||
mat = Material.NETHER_STALK;
|
||||
xp = Config.getInstance().getHerbalismXPNetherWart();
|
||||
}
|
||||
break;
|
||||
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPPumpkin();
|
||||
}
|
||||
break;
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPFlowers();
|
||||
}
|
||||
break;
|
||||
|
||||
case SUGAR_CANE_BLOCK:
|
||||
for (int y = 0; y <= 2; y++) {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
caneDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPSugarCane();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = type;
|
||||
xp = Config.getInstance().getHerbalismXPVines();
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = type;
|
||||
xp = Config.getInstance().getHerbalismXPLilyPads();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mat == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalismDoubleDrops(player)) {
|
||||
ItemStack is = new ItemStack(mat);
|
||||
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
if (configInstance.getBrownMushroomsDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case CACTUS:
|
||||
if (configInstance.getCactiDoubleDropsEnabled()) {
|
||||
Misc.mcDropItems(loc, is, catciDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case CROPS:
|
||||
if (configInstance.getWheatDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (configInstance.getMelonsDoubleDropsEnabled()) {
|
||||
Misc.mcDropItems(loc, is, 3);
|
||||
Misc.mcRandomDropItems(loc, is, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (configInstance.getNetherWartsDoubleDropsEnabled()) {
|
||||
Misc.mcDropItems(loc, is, 2);
|
||||
Misc.mcRandomDropItems(loc, is, 50, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case PUMPKIN:
|
||||
if (configInstance.getPumpkinsDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case RED_MUSHROOM:
|
||||
if (configInstance.getRedMushroomsDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case SUGAR_CANE_BLOCK:
|
||||
if (configInstance.getSugarCaneDoubleDropsEnabled()) {
|
||||
Misc.mcDropItems(loc, is, caneDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (configInstance.getVinesDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (configInstance.getWaterLiliesDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case YELLOW_FLOWER:
|
||||
if (configInstance.getYellowFlowersDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.HERBALISM, xp);
|
||||
Skills.XpCheckSkill(SkillType.HERBALISM, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Green Thumb ability to crops.
|
||||
*
|
||||
* @param block The block to apply the ability to
|
||||
* @param player The player using the ability
|
||||
* @param event The event triggering the ability
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
|
||||
final int MAX_BONUS_LEVEL = 1500;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||
Location loc = block.getLocation();
|
||||
|
||||
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.WHEAT));
|
||||
Misc.mcRandomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
|
||||
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Green Thumb ability to blocks.
|
||||
*
|
||||
* @param is The item in the player's hand
|
||||
* @param player The player activating the ability
|
||||
* @param block The block being used in the ability
|
||||
*/
|
||||
public static void greenThumbBlocks(ItemStack is, Player player, Block block) {
|
||||
final int MAX_BONUS_LEVEL = 1500;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int seeds = is.getAmount();
|
||||
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcPlayerListener.GreenThumbFail"));
|
||||
}
|
||||
}
|
||||
}
|
289
src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
Normal file
289
src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
Normal file
@ -0,0 +1,289 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
public class Mining {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Drop items from Mining & Blast Mining skills.
|
||||
*
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
public static void miningDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
if (configInstance.getEndStoneDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.REDSTONE);
|
||||
Misc.mcDropItems(loc, item, 4);
|
||||
Misc.mcRandomDropItem(loc, item, 50);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
Misc.mcDropItems(loc, item, 2);
|
||||
Misc.mcRandomDropItems(loc, item, 50, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
if (configInstance.getGoldDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
if (configInstance.getIronDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
|
||||
Misc.mcDropItems(loc, item, 4);
|
||||
Misc.mcRandomDropItems(loc, item, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
if (configInstance.getMossyCobblestoneDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
if (configInstance.getNetherrackDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
if (configInstance.getObsidianDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
if (configInstance.getSandstoneDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COBBLESTONE);
|
||||
Misc.mcDropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Award XP for Mining blocks.
|
||||
*
|
||||
* @param player The player to award XP to
|
||||
* @param block The block to award XP for
|
||||
*/
|
||||
public static void miningXP(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Material type = block.getType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
xp += Config.getInstance().getMiningXPCoalOre();
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
xp += Config.getInstance().getMiningXPDiamondOre();
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
xp += Config.getInstance().getMiningXPEndStone();
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
xp += Config.getInstance().getMiningXPRedstoneOre();
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
xp += Config.getInstance().getMiningXPGlowstone();
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
xp += Config.getInstance().getMiningXPGoldOre();
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
xp += Config.getInstance().getMiningXPIronOre();
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
xp += Config.getInstance().getMiningXPLapisOre();
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
xp += Config.getInstance().getMiningXPMossyStone();
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
xp += Config.getInstance().getMiningXPNetherrack();
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
xp += Config.getInstance().getMiningXPObsidian();
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
xp += Config.getInstance().getMiningXPSandstone();
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
xp += Config.getInstance().getMiningXPStone();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.MINING, xp);
|
||||
Skills.XpCheckSkill(SkillType.MINING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Mining block drops.
|
||||
*
|
||||
* @param player The player mining the block
|
||||
* @param block The block being broken
|
||||
*/
|
||||
public static void miningBlockCheck(Player player, Block block) {
|
||||
if (block.hasMetadata("mcmmoPlacedBlock") || player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
return;
|
||||
}
|
||||
|
||||
miningXP(player, block);
|
||||
|
||||
if (BlockChecks.canBeSuperBroken(block.getType())) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||
miningDrops(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Super Breaker ability.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block being affected
|
||||
*/
|
||||
public static void SuperBreakerBlockCheck(Player player, Block block) {
|
||||
Material type = block.getType();
|
||||
int tier = Misc.getTier(player.getItemInHand());
|
||||
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
|
||||
switch (type) {
|
||||
case OBSIDIAN:
|
||||
if (tier < 4) {
|
||||
return;
|
||||
}
|
||||
durabilityLoss = durabilityLoss * 5; //Obsidian needs to do more damage than normal
|
||||
/* FALL THROUGH */
|
||||
|
||||
case DIAMOND_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GOLD_ORE:
|
||||
case LAPIS_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (tier < 3) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case IRON_ORE:
|
||||
if (tier < 2) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case COAL_ORE:
|
||||
case ENDER_STONE:
|
||||
case GLOWSTONE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
|
||||
|
||||
miningBlockCheck(player, block);
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,388 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Tree;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
public class WoodCutting {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Handle the Tree Feller ability.
|
||||
*
|
||||
* @param event Event to modify
|
||||
*/
|
||||
public static void treeFeller(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block firstBlock = event.getBlock();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ArrayList<Block> toBeFelled = new ArrayList<Block>();
|
||||
|
||||
/* NOTE: Tree Feller will cut upwards like how you actually fell trees */
|
||||
processTreeFelling(firstBlock, toBeFelled);
|
||||
removeBlocks(toBeFelled, player, PP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles removing & dropping the blocks from Tree Feller.
|
||||
*
|
||||
* @param toBeFelled List of Blocks to be removed from the tree
|
||||
* @param player The player using the ability
|
||||
* @param PP The PlayerProfile of the player
|
||||
*/
|
||||
private static void removeBlocks(ArrayList<Block> toBeFelled, Player player, PlayerProfile PP) {
|
||||
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
|
||||
return;
|
||||
}
|
||||
|
||||
int durabilityLoss = durabilityLossCalulate(toBeFelled);
|
||||
int xp = 0;
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
/* Damage the tool */
|
||||
inHand.setDurability((short) (inHand.getDurability() + durabilityLoss));
|
||||
|
||||
/* This is to prevent using wood axes everytime you tree fell */
|
||||
if ((inHand.getDurability() + durabilityLoss >= inHand.getType().getMaxDurability()) || inHand.getType().equals(Material.AIR)) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
||||
|
||||
int health = player.getHealth();
|
||||
|
||||
if (health >= 2) {
|
||||
Combat.dealDamage(player, random.nextInt(health - 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//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());
|
||||
|
||||
for (Block x : toBeFelled) {
|
||||
if (Misc.blockBreakSimulate(x, player, true)) {
|
||||
if (x.getType() == Material.LOG) {
|
||||
Tree tree = (Tree) x.getState().getData();
|
||||
TreeSpecies species = tree.getSpecies();
|
||||
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
item = oak;
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
item = spruce;
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
item = birch;
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
item = jungle;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!x.hasMetadata("mcmmoPlacedBlock")) {
|
||||
WoodCutting.woodCuttingProcCheck(player, x);
|
||||
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
xp += Config.getInstance().getWoodcuttingXPBirch();
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle() / 4; //Nerf XP from Jungle Trees when using Tree Feller
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the block */
|
||||
x.setData((byte) 0x0);
|
||||
x.setType(Material.AIR);
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
/* Drop the block */
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
if (configInstance.getOakDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(x.getLocation(), item);
|
||||
}
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
if (configInstance.getSpruceDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(x.getLocation(), item);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
if (configInstance.getBirchDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(x.getLocation(), item);
|
||||
}
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
if (configInstance.getJungleDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(x.getLocation(), item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
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
|
||||
Misc.mcRandomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
|
||||
|
||||
//Remove the block
|
||||
x.setData((byte) 0);
|
||||
x.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().woodcutting(player)) {
|
||||
PP.addXP(SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the calculations from Tree Feller.
|
||||
*
|
||||
* @param currentBlock The current block to be removed
|
||||
* @param toBeFelled The list of blocks left to be removed
|
||||
*/
|
||||
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
|
||||
Material type = currentBlock.getType();
|
||||
|
||||
if(toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) {
|
||||
toBeFelled.add(currentBlock);
|
||||
}
|
||||
|
||||
Block xPositive = currentBlock.getRelative(1, 0, 0);
|
||||
Block xNegative = currentBlock.getRelative(-1, 0, 0);
|
||||
Block zPositive = currentBlock.getRelative(0, 0, 1);
|
||||
Block zNegative = currentBlock.getRelative(0, 0, -1);
|
||||
Block yPositive = currentBlock.getRelative(0, 1, 0);
|
||||
|
||||
if (!currentBlock.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!isTooAggressive(currentBlock, xPositive) && BlockChecks.treeFellerCompatible(xPositive.getType()) && !toBeFelled.contains(xPositive)) {
|
||||
processTreeFelling(xPositive, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, xNegative) && BlockChecks.treeFellerCompatible(xNegative.getType()) && !toBeFelled.contains(xNegative)) {
|
||||
processTreeFelling(xNegative, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, zPositive) && BlockChecks.treeFellerCompatible(zPositive.getType()) && !toBeFelled.contains(zPositive)) {
|
||||
processTreeFelling(zPositive, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, zNegative) && BlockChecks.treeFellerCompatible(zNegative.getType()) && !toBeFelled.contains(zNegative)) {
|
||||
processTreeFelling(zNegative, toBeFelled);
|
||||
}
|
||||
}
|
||||
|
||||
if (BlockChecks.treeFellerCompatible(yPositive.getType())) {
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") && !toBeFelled.contains(yPositive)) {
|
||||
processTreeFelling(yPositive, toBeFelled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Tree Feller is being too aggressive.
|
||||
*
|
||||
* @param currentBlock The current block being felled
|
||||
* @param newBlock The next block to be felled
|
||||
* @return true if Tree Feller is too aggressive, false otherwise
|
||||
*/
|
||||
private static boolean isTooAggressive(Block currentBlock, Block newBlock) {
|
||||
Material currentType = currentBlock.getType();
|
||||
Material newType = currentBlock.getType();
|
||||
|
||||
if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR)) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for double drops.
|
||||
*
|
||||
* @param player Player breaking the block
|
||||
* @param block The block being broken
|
||||
*/
|
||||
private static void woodCuttingProcCheck(Player player, Block block) {
|
||||
final int MAX_SKILL_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING);
|
||||
byte type = block.getData();
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
Tree tree = (Tree) block.getState().getData();
|
||||
TreeSpecies species = tree.getSpecies();
|
||||
|
||||
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
|
||||
Location location = block.getLocation();
|
||||
|
||||
/* Drop the block */
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
if (configInstance.getOakDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
if (configInstance.getSpruceDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
if (configInstance.getBirchDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
if (configInstance.getJungleDoubleDropsEnabled()) {
|
||||
Misc.mcDropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check XP gain for woodcutting.
|
||||
*
|
||||
* @param player The player breaking the block
|
||||
* @param block The block being broken
|
||||
*/
|
||||
public static void woodcuttingBlockCheck(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int xp = 0;
|
||||
TreeSpecies species = TreeSpecies.getByData(block.getData());
|
||||
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
xp += Config.getInstance().getWoodcuttingXPBirch();
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addXP(SkillType.WOODCUTTING, xp);
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Leaf Blower ability.
|
||||
*
|
||||
* @param player Player using the ability
|
||||
* @param block Block being broken
|
||||
*/
|
||||
public static void leafBlower(Player player, Block block) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
}
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled) {
|
||||
int durabilityLoss = 0;
|
||||
for (Block x : toBeFelled) {
|
||||
if (x.getType().equals(Material.LOG)) {
|
||||
durabilityLoss++;
|
||||
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
|
||||
}
|
||||
}
|
||||
|
||||
return durabilityLoss;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user