mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Cleanup & Silk Touch changes.
This commit is contained in:
parent
6da43b15c8
commit
a622707608
@ -7,6 +7,9 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
|
Version 1.3.08
|
||||||
|
! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed.
|
||||||
|
|
||||||
Version 1.3.07
|
Version 1.3.07
|
||||||
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
|
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
|
||||||
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
||||||
|
@ -23,11 +23,9 @@ import com.gmail.nossr50.util.Users;
|
|||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
|
|
||||||
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.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -43,6 +41,8 @@ import org.getspout.spoutapi.sound.SoundEffect;
|
|||||||
|
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
private static Config configInstance = Config.getInstance();
|
||||||
|
private static Permissions permInstance = Permissions.getInstance();
|
||||||
|
|
||||||
public BlockListener(final mcMMO plugin) {
|
public BlockListener(final mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -119,7 +119,7 @@ public class BlockListener implements Listener {
|
|||||||
mcMMO.placeStore.setTrue(block);
|
mcMMO.placeStore.setTrue(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == Config.getInstance().getRepairAnvilId() && Config.getInstance().getRepairAnvilMessagesEnabled()) {
|
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||||
Repair.placedAnvilCheck(player, id);
|
Repair.placedAnvilCheck(player, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,77 +134,72 @@ public class BlockListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Material mat = block.getType();
|
ItemStack inHand = player.getItemInHand();
|
||||||
ItemStack inhand = player.getItemInHand();
|
|
||||||
|
|
||||||
if (event instanceof FakeBlockBreakEvent) {
|
if (event instanceof FakeBlockBreakEvent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* HERBALISM */
|
||||||
* HERBALISM
|
if (BlockChecks.canBeGreenTerra(block)) {
|
||||||
*/
|
/* Green Terra */
|
||||||
|
if (PP.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||||
/* Green Terra */
|
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||||
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || BlockChecks.canBeGreenTerra(block))) {
|
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Triple drops */
|
|
||||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canBeGreenTerra(block)) {
|
|
||||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Permissions.getInstance().herbalism(player) && BlockChecks.canBeGreenTerra(block)) {
|
|
||||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MINING
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (Permissions.getInstance().mining(player) && BlockChecks.canBeSuperBroken(block)) {
|
|
||||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
|
|
||||||
Mining.miningBlockCheck(player, block);
|
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
|
||||||
Mining.miningBlockCheck(player, block);
|
/* Triple drops */
|
||||||
|
if (PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||||
|
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permInstance.herbalism(player)) {
|
||||||
|
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* MINING */
|
||||||
* WOOD CUTTING
|
else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) {
|
||||||
*/
|
if (configInstance.getMiningRequiresTool()) {
|
||||||
|
if (ItemChecks.isPickaxe(inHand)) {
|
||||||
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
|
Mining.miningBlockCheck(player, block);
|
||||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
|
||||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
|
||||||
}
|
|
||||||
else if (!Config.getInstance().getWoodcuttingRequiresTool()) {
|
|
||||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
|
||||||
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
|
|
||||||
WoodCutting.treeFeller(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WoodCutting.treeFeller(event);
|
Mining.miningBlockCheck(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* WOOD CUTTING */
|
||||||
* EXCAVATION
|
else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) {
|
||||||
*/
|
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||||
|
if (ItemChecks.isAxe(inHand)) {
|
||||||
if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.getInstance().excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
}
|
||||||
Excavation.excavationProcCheck(block, player);
|
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
else {
|
||||||
|
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||||
|
if (ItemChecks.isCustomTool(inHand)) {
|
||||||
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
|
WoodCutting.treeFeller(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WoodCutting.treeFeller(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EXCAVATION */
|
||||||
|
else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||||
|
if (configInstance.getExcavationRequiresTool()) {
|
||||||
|
if (ItemChecks.isShovel(inHand)) {
|
||||||
|
Excavation.excavationProcCheck(block, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
Excavation.excavationProcCheck(block, player);
|
Excavation.excavationProcCheck(block, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,9 +221,9 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
ItemStack inhand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Material mat = block.getType();
|
Material material = block.getType();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABILITY PREPARATION CHECKS
|
* ABILITY PREPARATION CHECKS
|
||||||
@ -237,7 +232,7 @@ public class BlockListener implements Listener {
|
|||||||
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
else if (PP.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||||
@ -246,22 +241,22 @@ public class BlockListener implements Listener {
|
|||||||
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||||
}
|
}
|
||||||
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW))) {
|
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TREE FELLER SOUNDS */
|
/* TREE FELLER SOUNDS */
|
||||||
if (Config.getInstance().spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
if (configInstance.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABILITY TRIGGER CHECKS
|
* ABILITY TRIGGER CHECKS
|
||||||
*/
|
*/
|
||||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) {
|
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (ItemChecks.isCustomTool(inHand)) {
|
||||||
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
Herbalism.greenTerra(player, block);
|
Herbalism.greenTerra(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,64 +265,66 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
if (configInstance.getExcavationRequiresTool()) {
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (ItemChecks.isShovel(inHand)) {
|
||||||
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
|
if (ItemChecks.isCustomTool(inHand)) {
|
||||||
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
|
event.setInstaBreak(true);
|
||||||
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Excavation.gigaDrillBreaker(player, block);
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
Excavation.gigaDrillBreaker(player, block);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
else {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Excavation.gigaDrillBreaker(player, block);
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||||
if (inhand.getType().equals(Material.AIR)) {
|
if (inHand.getType().equals(Material.AIR)) {
|
||||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||||
|
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().spoutEnabled) {
|
if (configInstance.spoutEnabled) {
|
||||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||||
if (!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { //TODO: Why are we checking this?
|
if (configInstance.getMiningRequiresTool()) {
|
||||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
|
if (ItemChecks.isPickaxe(inHand)) {
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (ItemChecks.isCustomTool(inHand)) {
|
||||||
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Mining.SuperBreakerBlockCheck(player, block);
|
Mining.superBreakerBlockCheck(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Mining.SuperBreakerBlockCheck(player, block);
|
Mining.superBreakerBlockCheck(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
}
|
||||||
event.setInstaBreak(true);
|
else {
|
||||||
Mining.SuperBreakerBlockCheck(player, block);
|
event.setInstaBreak(true);
|
||||||
}
|
Mining.superBreakerBlockCheck(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (mat.equals(Material.LEAVES) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||||
event.setInstaBreak(true);
|
if (ItemChecks.isAxe(inHand)) {
|
||||||
WoodCutting.leafBlower(player, block);
|
event.setInstaBreak(true);
|
||||||
|
WoodCutting.leafBlower(player, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (!inHand.getType().equals(Material.SHEARS)) {
|
||||||
else if (!Config.getInstance().getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) {
|
|
||||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
WoodCutting.leafBlower(player, block);
|
WoodCutting.leafBlower(player, block);
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,13 @@ import org.bukkit.CoalType;
|
|||||||
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;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.getspout.spoutapi.sound.SoundEffect;
|
import org.getspout.spoutapi.sound.SoundEffect;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -29,6 +28,74 @@ public class Mining {
|
|||||||
|
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle double drops when using Silk Touch.
|
||||||
|
*
|
||||||
|
* @param block The block to process drops for
|
||||||
|
*/
|
||||||
|
private static void silkTouchDrops(Block block) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
Material type = block.getType();
|
||||||
|
ItemStack item = new ItemStack(type);
|
||||||
|
Config configInstance = Config.getInstance();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case ENDER_STONE:
|
||||||
|
case GOLD_ORE:
|
||||||
|
case IRON_ORE:
|
||||||
|
case MOSSY_COBBLESTONE:
|
||||||
|
case NETHERRACK:
|
||||||
|
case OBSIDIAN:
|
||||||
|
case SANDSTONE:
|
||||||
|
miningDrops(block);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COAL_ORE:
|
||||||
|
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DIAMOND_ORE:
|
||||||
|
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLOWING_REDSTONE_ORE:
|
||||||
|
case REDSTONE_ORE:
|
||||||
|
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLOWSTONE:
|
||||||
|
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LAPIS_ORE:
|
||||||
|
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STONE:
|
||||||
|
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||||
|
Misc.mcDropItem(loc, item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop items from Mining & Blast Mining skills.
|
* Drop items from Mining & Blast Mining skills.
|
||||||
*
|
*
|
||||||
@ -130,7 +197,7 @@ public class Mining {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||||
Misc.mcDropItem(loc, item);
|
Misc.mcDropItem(loc, item);
|
||||||
}
|
}
|
||||||
@ -221,18 +288,21 @@ public class Mining {
|
|||||||
* @param block The block being broken
|
* @param block The block being broken
|
||||||
*/
|
*/
|
||||||
public static void miningBlockCheck(Player player, Block block) {
|
public static void miningBlockCheck(Player player, Block block) {
|
||||||
if (mcMMO.placeStore.isTrue(block) || player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (mcMMO.placeStore.isTrue(block)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
miningXP(player, block);
|
miningXP(player, block);
|
||||||
|
|
||||||
if (BlockChecks.canBeSuperBroken(block)) {
|
final int MAX_BONUS_LEVEL = 1000;
|
||||||
final int MAX_BONUS_LEVEL = 1000;
|
|
||||||
|
|
||||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||||
|
|
||||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
|
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||||
|
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
|
silkTouchDrops(block);
|
||||||
|
}
|
||||||
|
else {
|
||||||
miningDrops(block);
|
miningDrops(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +314,7 @@ public class Mining {
|
|||||||
* @param player The player using the ability
|
* @param player The player using the ability
|
||||||
* @param block The block being affected
|
* @param block The block being affected
|
||||||
*/
|
*/
|
||||||
public static void SuperBreakerBlockCheck(Player player, Block block) {
|
public static void superBreakerBlockCheck(Player player, Block block) {
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
int tier = Misc.getTier(player.getItemInHand());
|
int tier = Misc.getTier(player.getItemInHand());
|
||||||
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
|
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import org.bukkit.CropState;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -158,7 +160,6 @@ public class BlockChecks {
|
|||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case BROWN_MUSHROOM:
|
case BROWN_MUSHROOM:
|
||||||
case CACTUS:
|
case CACTUS:
|
||||||
case CROPS:
|
|
||||||
case MELON_BLOCK:
|
case MELON_BLOCK:
|
||||||
case NETHER_WARTS:
|
case NETHER_WARTS:
|
||||||
case PUMPKIN:
|
case PUMPKIN:
|
||||||
@ -170,6 +171,14 @@ public class BlockChecks {
|
|||||||
case YELLOW_FLOWER:
|
case YELLOW_FLOWER:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case CROPS:
|
||||||
|
if (block.getData() == CropState.RIPE.getData()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||||
return true;
|
return true;
|
||||||
@ -263,4 +272,13 @@ public class BlockChecks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLog (Block block){
|
||||||
|
if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user