mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Changed Super Breaker & Giga Drill Breaker to be an enchantment-based
boost, rather than an instabreak.
This commit is contained in:
parent
ca5bf0bd09
commit
e8319aee81
@ -79,6 +79,7 @@ Version 1.4.00-dev
|
|||||||
! Changed BeastLore: Now also displays offline player names
|
! Changed BeastLore: Now also displays offline player names
|
||||||
! Changed backup task to include ALL config files
|
! Changed backup task to include ALL config files
|
||||||
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
|
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
|
||||||
|
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak.
|
||||||
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
|
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
|
||||||
- Removed unused "healthbar" files from the resources
|
- Removed unused "healthbar" files from the resources
|
||||||
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
|
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
|
||||||
|
@ -175,11 +175,19 @@ public class BlockListener implements Listener {
|
|||||||
if (ItemChecks.isPickaxe(heldItem)) {
|
if (ItemChecks.isPickaxe(heldItem)) {
|
||||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||||
miningManager.miningBlockCheck(block);
|
miningManager.miningBlockCheck(block);
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||||
|
miningManager.miningBlockCheck(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||||
miningManager.miningBlockCheck(block);
|
miningManager.miningBlockCheck(block);
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||||
|
miningManager.miningBlockCheck(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,10 +213,18 @@ public class BlockListener implements Listener {
|
|||||||
if (Excavation.requiresTool) {
|
if (Excavation.requiresTool) {
|
||||||
if (ItemChecks.isShovel(heldItem)) {
|
if (ItemChecks.isShovel(heldItem)) {
|
||||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
|
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
|
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,18 +349,6 @@ public class BlockListener implements Listener {
|
|||||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||||
Herbalism.greenTerra(player, block);
|
Herbalism.greenTerra(player, block);
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
|
||||||
if (Excavation.requiresTool) {
|
|
||||||
if (ItemChecks.isShovel(heldItem)) {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
else if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||||
if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||||
if (heldItem.getType() == Material.AIR) {
|
if (heldItem.getType() == Material.AIR) {
|
||||||
@ -360,20 +364,6 @@ public class BlockListener implements Listener {
|
|||||||
Unarmed.blockCracker(player, block);
|
Unarmed.blockCracker(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
|
||||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
|
||||||
|
|
||||||
if (Mining.requiresTool) {
|
|
||||||
if (ItemChecks.isPickaxe(heldItem)) {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
miningManager.superBreakerBlockCheck(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
miningManager.superBreakerBlockCheck(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {
|
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {
|
||||||
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -37,6 +38,7 @@ import com.gmail.nossr50.skills.repair.Repair;
|
|||||||
import com.gmail.nossr50.skills.repair.Salvage;
|
import com.gmail.nossr50.skills.repair.Salvage;
|
||||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
|
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
@ -81,6 +83,21 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerDropItem events that involve modifying the event.
|
||||||
|
*
|
||||||
|
* @param event The event to modify
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
PlayerProfile playerProfile = Users.getPlayer(player).getProfile();
|
||||||
|
|
||||||
|
if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerFish events.
|
* Monitor PlayerFish events.
|
||||||
*
|
*
|
||||||
|
@ -5,16 +5,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.TreasuresConfig;
|
import com.gmail.nossr50.config.TreasuresConfig;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|
||||||
import com.gmail.nossr50.mods.ModChecks;
|
import com.gmail.nossr50.mods.ModChecks;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
@ -128,19 +125,8 @@ public class Excavation {
|
|||||||
* @param mcMMOPlayer The player using the ability
|
* @param mcMMOPlayer The player using the ability
|
||||||
* @param block The block to check
|
* @param block The block to check
|
||||||
*/
|
*/
|
||||||
public static void gigaDrillBreaker(McMMOPlayer mcMMOplayer, Block block) {
|
public static void gigaDrillBreaker(McMMOPlayer mcMMOPlayer, Block block) {
|
||||||
Player player = mcMMOplayer.getPlayer();
|
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||||
|
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||||
SkillTools.abilityDurabilityLoss(player.getItemInHand(), Misc.toolDurabilityLoss);
|
|
||||||
|
|
||||||
if (!mcMMO.placeStore.isTrue(block) && Misc.blockBreakSimulate(block, player, true)) {
|
|
||||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
|
||||||
|
|
||||||
Excavation.excavationProcCheck(block, mcMMOplayer);
|
|
||||||
Excavation.excavationProcCheck(block, mcMMOplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
@ -122,26 +121,4 @@ public class MiningManager extends SkillManager{
|
|||||||
eventHandler.processDrops();
|
eventHandler.processDrops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the Super Breaker ability.
|
|
||||||
*
|
|
||||||
* @param block The block being affected
|
|
||||||
*/
|
|
||||||
public void superBreakerBlockCheck(Block block) {
|
|
||||||
if (mcMMO.placeStore.isTrue(block) || !Misc.blockBreakSimulate(block, mcMMOPlayer.getPlayer(), true)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SuperBreakerEventHandler eventHandler = new SuperBreakerEventHandler(this, block);
|
|
||||||
|
|
||||||
if (!eventHandler.tierCheck()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eventHandler.callFakeArmswing();
|
|
||||||
eventHandler.processDurabilityLoss();
|
|
||||||
eventHandler.processDropsAndXP();
|
|
||||||
eventHandler.playSound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|
||||||
import com.gmail.nossr50.mods.ModChecks;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
|
|
||||||
public class SuperBreakerEventHandler {
|
|
||||||
private MiningManager manager;
|
|
||||||
private Block block;
|
|
||||||
private Material blockType;
|
|
||||||
private boolean customBlock;
|
|
||||||
private ItemStack heldItem;
|
|
||||||
private int tier;
|
|
||||||
private int durabilityLoss;
|
|
||||||
private FakePlayerAnimationEvent armswing;
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
protected SuperBreakerEventHandler (MiningManager manager, Block block) {
|
|
||||||
this.manager = manager;
|
|
||||||
this.block = block;
|
|
||||||
this.blockType = block.getType();
|
|
||||||
this.customBlock = ModChecks.isCustomMiningBlock(block);
|
|
||||||
this.player = manager.getMcMMOPlayer().getPlayer();
|
|
||||||
this.heldItem = player.getItemInHand();
|
|
||||||
this.tier = Misc.getTier(heldItem);
|
|
||||||
this.armswing = new FakePlayerAnimationEvent(player);
|
|
||||||
|
|
||||||
calculateDurabilityLoss();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void callFakeArmswing() {
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processDurabilityLoss() {
|
|
||||||
SkillTools.abilityDurabilityLoss(heldItem, durabilityLoss);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processDropsAndXP() {
|
|
||||||
manager.miningBlockCheck(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void playSound() {
|
|
||||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for the proper tier of item for use with Super Breaker.
|
|
||||||
*
|
|
||||||
* @return True if the item is the required tier or higher, false otherwise
|
|
||||||
*/
|
|
||||||
protected boolean tierCheck() {
|
|
||||||
if (customBlock) {
|
|
||||||
if (tier < ModChecks.getCustomBlock(block).getTier()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (blockType) {
|
|
||||||
case OBSIDIAN:
|
|
||||||
if (tier < Mining.DIAMOND_TOOL_TIER) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* FALL THROUGH */
|
|
||||||
|
|
||||||
case DIAMOND_ORE:
|
|
||||||
case GLOWING_REDSTONE_ORE:
|
|
||||||
case GOLD_ORE:
|
|
||||||
case LAPIS_ORE:
|
|
||||||
case REDSTONE_ORE:
|
|
||||||
case EMERALD_ORE:
|
|
||||||
if (tier < Mining.IRON_TOOL_TIER) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* FALL THROUGH */
|
|
||||||
|
|
||||||
case IRON_ORE:
|
|
||||||
if (tier < Mining.STONE_TOOL_TIER) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* FALL THROUGH */
|
|
||||||
|
|
||||||
case COAL_ORE:
|
|
||||||
case ENDER_STONE:
|
|
||||||
case GLOWSTONE:
|
|
||||||
case MOSSY_COBBLESTONE:
|
|
||||||
case NETHERRACK:
|
|
||||||
case SANDSTONE:
|
|
||||||
case STONE:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateDurabilityLoss() {
|
|
||||||
this.durabilityLoss = Misc.toolDurabilityLoss;
|
|
||||||
|
|
||||||
if (blockType == Material.OBSIDIAN) {
|
|
||||||
durabilityLoss = durabilityLoss * 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,16 @@
|
|||||||
package com.gmail.nossr50.skills.utilities;
|
package com.gmail.nossr50.skills.utilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
@ -203,6 +209,9 @@ public class SkillTools {
|
|||||||
if (ability == AbilityType.BERSERK) {
|
if (ability == AbilityType.BERSERK) {
|
||||||
player.setCanPickupItems(true);
|
player.setCanPickupItems(true);
|
||||||
}
|
}
|
||||||
|
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||||
|
handleAbilitySpeedDecrease(player);
|
||||||
|
}
|
||||||
|
|
||||||
profile.setAbilityMode(ability, false);
|
profile.setAbilityMode(ability, false);
|
||||||
profile.setAbilityInformed(ability, false);
|
profile.setAbilityInformed(ability, false);
|
||||||
@ -427,9 +436,13 @@ public class SkillTools {
|
|||||||
|
|
||||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||||
profile.setAbilityMode(ability, true);
|
profile.setAbilityMode(ability, true);
|
||||||
|
|
||||||
if (ability == AbilityType.BERSERK) {
|
if (ability == AbilityType.BERSERK) {
|
||||||
player.setCanPickupItems(false);
|
player.setCanPickupItems(false);
|
||||||
}
|
}
|
||||||
|
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||||
|
handleAbilitySpeedIncrease(player.getItemInHand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,4 +525,55 @@ public class SkillTools {
|
|||||||
|
|
||||||
return skillLevel;
|
return skillLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleAbilitySpeedIncrease(ItemStack heldItem) {
|
||||||
|
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||||
|
ItemMeta itemMeta = heldItem.getItemMeta();
|
||||||
|
List<String> itemLore = new ArrayList<String>();
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
itemLore = itemMeta.getLore();
|
||||||
|
}
|
||||||
|
|
||||||
|
itemLore.add("mcMMO Ability Tool");
|
||||||
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
|
||||||
|
|
||||||
|
itemMeta.setLore(itemLore);
|
||||||
|
heldItem.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleAbilitySpeedDecrease(Player player) {
|
||||||
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
|
|
||||||
|
for (ItemStack item : playerInventory.getContents()) {
|
||||||
|
if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||||
|
List<String> itemLore = itemMeta.getLore();
|
||||||
|
|
||||||
|
for (Iterator<String> loreIterator = itemLore.iterator(); loreIterator.hasNext();) {
|
||||||
|
String lore = loreIterator.next();
|
||||||
|
|
||||||
|
if (lore.equalsIgnoreCase("mcMMO Ability Tool")) {
|
||||||
|
loreIterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (efficiencyLevel == 5) {
|
||||||
|
item.removeEnchantment(Enchantment.DIG_SPEED);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta.setLore(itemLore);
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user