From e2b8d940d3164485cd1a8d5f65526500dc8ca4d7 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 28 Mar 2019 04:22:26 -0700 Subject: [PATCH 1/8] 2.1.28 --- Changelog.txt | 3 + pom.xml | 2 +- .../nossr50/util/skills/CombatUtils.java | 66 ++++++++++--------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 82235738a..7a55120e9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.28 + Fixed a bug where Archery could not gain XP + Version 2.1.27 Fixed an exploit that allowed players to duplicate torches, and rails diff --git a/pom.xml b/pom.xml index 8e40134d4..bd73668a6 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.27 + 2.1.28 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index ae6910fee..c13a6cdee 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -22,6 +22,7 @@ import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableMap; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.*; @@ -240,7 +241,37 @@ public final class CombatUtils { * @param event The event to run the combat checks on. */ public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { - EntityType entityType = attacker.getType(); + Entity damager = event.getDamager(); + EntityType entityType = damager.getType(); + + if (target instanceof Player) { + if (Misc.isNPCEntity(target)) { + return; + } + + Player player = (Player) target; + if (!UserManager.hasPlayerDataKey(player)) { + return; + } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); + + if (acrobaticsManager.canDodge(target)) { + event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage())); + } + + if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { + if (!PrimarySkillType.SWORDS.shouldProcess(target)) { + return; + } + + SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); + + if (swordsManager.canUseCounterAttack(damager)) { + swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + } + } + } if (attacker instanceof Player && entityType == EntityType.PLAYER) { Player player = (Player) attacker; @@ -297,7 +328,7 @@ public final class CombatUtils { } else if (entityType == EntityType.WOLF) { - Wolf wolf = (Wolf) attacker; + Wolf wolf = (Wolf) damager; AnimalTamer tamer = wolf.getOwner(); if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) { @@ -309,7 +340,7 @@ public final class CombatUtils { } } else if (entityType == EntityType.ARROW) { - Arrow arrow = (Arrow) attacker; + Arrow arrow = (Arrow) damager; ProjectileSource projectileSource = arrow.getShooter(); if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { @@ -326,35 +357,6 @@ public final class CombatUtils { } } } - - if (target instanceof Player) { - if (Misc.isNPCEntity(target)) { - return; - } - - Player player = (Player) target; - if (!UserManager.hasPlayerDataKey(player)) { - return; - } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); - - if (acrobaticsManager.canDodge(target)) { - event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage())); - } - - if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { - if (!PrimarySkillType.SWORDS.shouldProcess(target)) { - return; - } - - SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - - if (swordsManager.canUseCounterAttack(attacker)) { - swordsManager.counterAttackChecks((LivingEntity) attacker, event.getDamage()); - } - } - } } public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) { From 74e62ab08cac9b3022c16625cee323d862d6fce6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 28 Mar 2019 16:01:21 +0100 Subject: [PATCH 2/8] Update locale_it.properties --- src/main/resources/locale/locale_it.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/locale/locale_it.properties b/src/main/resources/locale/locale_it.properties index bbc2d063e..2c4fb0908 100644 --- a/src/main/resources/locale/locale_it.properties +++ b/src/main/resources/locale/locale_it.properties @@ -119,6 +119,7 @@ Fishing.SubSkill.MasterAngler.Description=Migliora le possibilit\u00E0 di riceve Fishing.SubSkill.IceFishing.Name=Pesca sul Ghiaccio Fishing.SubSkill.IceFishing.Description=Ti permette di pescare nei biomi ghiacciati Fishing.Chance.Raining=[[BLUE]] Bonus Pioggia +Fishing.LowResources=[[GRAY]]Non sembrano esserci pi\u00F9 pesci in questa zona... Fishing.Listener=Pesca: Fishing.Ability.TH.MagicFound=[[GRAY]]Senti un tocco di magia in questa cattura... Fishing.Ability.TH.Boom=[[GRAY]]TEMPO DI BOOM!!! From 74908cdcf5e5e52194f34fca566effd8c3a48f13 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 11:27:49 -0700 Subject: [PATCH 3/8] 2.1.29 - Double Drop Fix --- Changelog.txt | 3 +++ pom.xml | 2 +- .../gmail/nossr50/listeners/BlockListener.java | 13 +++++++------ src/main/java/com/gmail/nossr50/mcMMO.java | 2 -- .../gmail/nossr50/skills/herbalism/Herbalism.java | 6 +++--- .../skills/herbalism/HerbalismManager.java | 4 ++-- .../nossr50/skills/mining/MiningManager.java | 2 +- .../java/com/gmail/nossr50/util/BlockUtils.java | 15 ++++++++++----- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 7a55120e9..c0898f16a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.29 + Fixed a bug where double drops and triple drops were not activating + Version 2.1.28 Fixed a bug where Archery could not gain XP diff --git a/pom.xml b/pom.xml index bd73668a6..c34c8e55c 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.28 + 2.1.29 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 9cf7452d1..a1aa57a67 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -29,10 +29,7 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Tag; +import org.bukkit.*; import org.bukkit.block.*; import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; @@ -55,9 +52,13 @@ public class BlockListener implements Listener { this.plugin = plugin; } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) +/* @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDropItemEvent(BlockDropItemEvent event) { + + Bukkit.broadcastMessage("Debug: Drop Item Event"); + + for(Item item : event.getItems()) { ItemStack is = new ItemStack(item.getItemStack()); @@ -88,7 +89,7 @@ public class BlockListener implements Listener { event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); } } - } + }*/ /** * Monitor BlockPistonExtend events. diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 365fb124d..aceebcded 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -114,8 +114,6 @@ public class mcMMO extends JavaPlugin { public final static String disarmedItemKey = "mcMMO: Disarmed Item"; public final static String playerDataKey = "mcMMO: Player Data"; public final static String greenThumbDataKey = "mcMMO: Green Thumb"; - public final static String doubleDropKey = "mcMMO: Double Drop"; - public final static String tripleDropKey = "mcMMO: Triple Drop"; public final static String databaseCommandKey = "mcMMO: Processing Database Command"; public final static String bredMetadataKey = "mcMMO: Bred Animal"; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index dd9e0cdf2..eb7b01c5b 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -67,7 +67,7 @@ public class Herbalism { dropAmount++; if(herbalismManager.checkDoubleDrop(target.getState())) - BlockUtils.markBlocksForBonusDrops(target.getState(), triple); + BlockUtils.spawnBonusDrops(target.getState(), triple); } for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST}) @@ -110,7 +110,7 @@ public class Herbalism { dropAmount++; if(herbalismManager.checkDoubleDrop(relativeBlock.getState())) - BlockUtils.markBlocksForBonusDrops(relativeBlock.getState(), triple); + BlockUtils.spawnBonusDrops(relativeBlock.getState(), triple); } } } @@ -142,7 +142,7 @@ public class Herbalism { amount += 1; if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState())) - BlockUtils.markBlocksForBonusDrops(relativeUpBlock.getState(), triple); + BlockUtils.spawnBonusDrops(relativeUpBlock.getState(), triple); } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index accd2ab56..f7501bc86 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -147,7 +147,7 @@ public class HerbalismManager extends SkillManager { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) { if(checkDoubleDrop(blockState)) - BlockUtils.markBlocksForBonusDrops(blockState, greenTerra); + BlockUtils.spawnBonusDrops(blockState, greenTerra); } } else { @@ -165,7 +165,7 @@ public class HerbalismManager extends SkillManager { } else { /* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */ if(checkDoubleDrop(blockState)) - BlockUtils.markBlocksForBonusDrops(blockState, greenTerra); + BlockUtils.spawnBonusDrops(blockState, greenTerra); } if (Permissions.greenThumbPlant(player, material)) { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index c9d54579c..a5dd723d9 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -91,7 +91,7 @@ public class MiningManager extends SkillManager { //TODO: Make this readable if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) { - BlockUtils.markBlocksForBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility())); + BlockUtils.spawnBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility())); } } diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 129e5c1aa..2730ce501 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -9,11 +9,13 @@ import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceUtil; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import java.util.HashSet; @@ -26,12 +28,15 @@ public final class BlockUtils { * @param blockState target blockstate * @param triple marks the block to give triple drops */ - public static void markBlocksForBonusDrops(BlockState blockState, boolean triple) + public static void spawnBonusDrops(BlockState blockState, boolean triple) { - if(triple) - blockState.setMetadata(mcMMO.tripleDropKey, mcMMO.metadataValue); - else - blockState.setMetadata(mcMMO.doubleDropKey, mcMMO.metadataValue); + for(ItemStack spawnItem : blockState.getBlock().getDrops()) + { + if(triple) + blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem); + + blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem); + } } /** From 8d477a5cf52e7befd1e58298702b4a9dfc6cabe4 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 11:33:40 -0700 Subject: [PATCH 4/8] unused imports --- .../java/com/gmail/nossr50/listeners/BlockListener.java | 6 ++++-- .../java/com/gmail/nossr50/listeners/EntityListener.java | 2 -- .../com/gmail/nossr50/runnables/skills/BleedTimerTask.java | 2 -- src/main/java/com/gmail/nossr50/util/BlockUtils.java | 1 - .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index a1aa57a67..96ff2dffb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -29,10 +29,12 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import org.bukkit.*; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Tag; import org.bukkit.block.*; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index fb17667e3..748b4f9c7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -25,8 +25,6 @@ import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 60c1bda4d..2290c241b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -9,8 +9,6 @@ import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 2730ce501..e3fe60458 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceUtil; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.block.data.Ageable; diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index c13a6cdee..f1a58e6b4 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -22,7 +22,6 @@ import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableMap; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.*; From 53534e0f1d13436218f55b6eb7c2f755f3936600 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 17:44:54 -0700 Subject: [PATCH 5/8] Fixing Mining Double Drops (update configs) --- Changelog.txt | 7 ++ pom.xml | 2 +- .../nossr50/listeners/BlockListener.java | 67 +++++++++++++------ src/main/java/com/gmail/nossr50/mcMMO.java | 2 + .../nossr50/skills/herbalism/Herbalism.java | 6 +- .../skills/herbalism/HerbalismManager.java | 4 +- .../nossr50/skills/mining/MiningManager.java | 2 +- .../com/gmail/nossr50/util/BlockUtils.java | 14 ++-- src/main/resources/config.yml | 9 +++ 9 files changed, 76 insertions(+), 37 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c0898f16a..9bf530fd0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,13 @@ Key: ! Change - Removal +Version 2.1.30 + Fixed yet another bug involving double drops + DoubleDrop config tables now must contain all things that can possibly be doubled, such as the Ore block, the ore itself, etc. + Added the following items to the DoubleDrop tables for Mining: Coal, Diamond, Emerald, Glowstone_Dust, Iron_Ingot, Lapis_Lazuli, Nether_Quartz, Redstone, Cobblestone + + NOTE: I'm gonna have to blame Bukkit on this one, several API methods I used are actually unfinished and kind of janky. So I hacked something together to make them work. + Version 2.1.29 Fixed a bug where double drops and triple drops were not activating diff --git a/pom.xml b/pom.xml index c34c8e55c..3e5ffbdc4 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.29 + 2.1.30-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 96ff2dffb..6d2f95d91 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,6 +35,7 @@ import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.*; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -54,41 +55,65 @@ public class BlockListener implements Listener { this.plugin = plugin; } -/* @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDropItemEvent(BlockDropItemEvent event) { - - Bukkit.broadcastMessage("Debug: Drop Item Event"); - - for(Item item : event.getItems()) { ItemStack is = new ItemStack(item.getItemStack()); - if(!event.getBlock().getDrops().contains(is)) - continue; - if(is.getAmount() <= 0) continue; - if(event.getBlock().getState().getMetadata(mcMMO.doubleDropKey).size() > 0) - { - //Extra Protection - if(event.getBlock().getState() instanceof Container) - return; + if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType()) + && !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType()) + && !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType())) + continue; - event.getBlock().getState().removeMetadata(mcMMO.doubleDropKey, plugin); + if(event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0) + event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + else if(event.getBlock().getState().getMetadata(mcMMO.tripleDrops).size() > 0) + { + event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); } + } + } - else if(event.getBlock().getState().getMetadata(mcMMO.tripleDropKey).size() > 0) + /*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockDropItemEvent(BlockDropItemEvent event) + { + for(Item item : event.getItems()) + { + ItemStack is = new ItemStack(item.getItemStack()); + + if(event.getBlock().getMetadata(mcMMO.doubleDrops).size() > 0) { - //Extra Protection - if(event.getBlock().getState() instanceof Container) - return; - event.getBlock().getState().removeMetadata(mcMMO.tripleDropKey, plugin); - event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); - event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + List metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops); + + BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0); + Collection potentialDrops = (Collection) bonusDrops.value(); + + if(potentialDrops.contains(is)) + { + event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + } + + event.getBlock().removeMetadata(mcMMO.doubleDrops, plugin); + } else { + if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) { + List metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops); + + BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0); + Collection potentialDrops = (Collection) bonusDrops.value(); + + if (potentialDrops.contains(is)) { + event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + } + + event.getBlock().removeMetadata(mcMMO.tripleDrops, plugin); + } } } }*/ diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index aceebcded..7d8664e4b 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -110,6 +110,8 @@ public class mcMMO extends JavaPlugin { public final static String infiniteArrowKey = "mcMMO: Infinite Arrow"; public final static String bowForceKey = "mcMMO: Bow Force"; public final static String arrowDistanceKey = "mcMMO: Arrow Distance"; + public final static String doubleDrops = "mcMMO: Double Drops"; + public final static String tripleDrops = "mcMMO: Triple Drops"; //public final static String customDamageKey = "mcMMO: Custom Damage"; public final static String disarmedItemKey = "mcMMO: Disarmed Item"; public final static String playerDataKey = "mcMMO: Player Data"; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index eb7b01c5b..a51cab404 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -67,7 +67,7 @@ public class Herbalism { dropAmount++; if(herbalismManager.checkDoubleDrop(target.getState())) - BlockUtils.spawnBonusDrops(target.getState(), triple); + BlockUtils.markDropsAsBonus(target.getState(), triple); } for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST}) @@ -110,7 +110,7 @@ public class Herbalism { dropAmount++; if(herbalismManager.checkDoubleDrop(relativeBlock.getState())) - BlockUtils.spawnBonusDrops(relativeBlock.getState(), triple); + BlockUtils.markDropsAsBonus(relativeBlock.getState(), triple); } } } @@ -142,7 +142,7 @@ public class Herbalism { amount += 1; if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState())) - BlockUtils.spawnBonusDrops(relativeUpBlock.getState(), triple); + BlockUtils.markDropsAsBonus(relativeUpBlock.getState(), triple); } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index f7501bc86..afb280e98 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -147,7 +147,7 @@ public class HerbalismManager extends SkillManager { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) { if(checkDoubleDrop(blockState)) - BlockUtils.spawnBonusDrops(blockState, greenTerra); + BlockUtils.markDropsAsBonus(blockState, greenTerra); } } else { @@ -165,7 +165,7 @@ public class HerbalismManager extends SkillManager { } else { /* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */ if(checkDoubleDrop(blockState)) - BlockUtils.spawnBonusDrops(blockState, greenTerra); + BlockUtils.markDropsAsBonus(blockState, greenTerra); } if (Permissions.greenThumbPlant(player, material)) { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index a5dd723d9..fa3ceaaa1 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -91,7 +91,7 @@ public class MiningManager extends SkillManager { //TODO: Make this readable if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) { - BlockUtils.spawnBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility())); + BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility())); } } diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index e3fe60458..66cef68f3 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -14,7 +14,6 @@ import org.bukkit.block.BlockState; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; import java.util.HashSet; @@ -27,15 +26,12 @@ public final class BlockUtils { * @param blockState target blockstate * @param triple marks the block to give triple drops */ - public static void spawnBonusDrops(BlockState blockState, boolean triple) + public static void markDropsAsBonus(BlockState blockState, boolean triple) { - for(ItemStack spawnItem : blockState.getBlock().getDrops()) - { - if(triple) - blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem); - - blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem); - } + if(triple) + blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue); + else + blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue); } /** diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4c616b22d..7858b9ec5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -461,20 +461,29 @@ Double_Drops: Diorite: true Granite: true Coal_Ore: true + Coal: true Diamond_Ore: true + Diamond: true Emerald_Ore: true + Emerald: true End_Stone: true Glowstone: true + Glowstone_Dust: true Gold_Ore: true Iron_Ore: true + Iron_Ingot: true Lapis_Ore: true + Lapis_Lazuli: true Mossy_Cobblestone: true Netherrack: true Obsidian: true Nether_Quartz_Ore: true + Nether_Quartz: true Redstone_Ore: true + Redstone: true Sandstone: true Stone: true + Cobblestone: true Woodcutting: Acacia_Log: true Birch_Log: true From 28c7fdd4e280d62c3f10a555046f6754322085d9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 17:57:48 -0700 Subject: [PATCH 6/8] Add missing Herbalism entries to config --- Changelog.txt | 3 ++- src/main/java/com/gmail/nossr50/listeners/BlockListener.java | 4 ++++ src/main/resources/config.yml | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 9bf530fd0..78e96c278 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,9 +8,10 @@ Key: - Removal Version 2.1.30 - Fixed yet another bug involving double drops + Fixed double drops behaving oddly DoubleDrop config tables now must contain all things that can possibly be doubled, such as the Ore block, the ore itself, etc. Added the following items to the DoubleDrop tables for Mining: Coal, Diamond, Emerald, Glowstone_Dust, Iron_Ingot, Lapis_Lazuli, Nether_Quartz, Redstone, Cobblestone + Added the following items to the DoubleDrop tables for Herbalism: Beetroot, Carrot, Cocoa_Beans, Melon_Slice, Potatoe NOTE: I'm gonna have to blame Bukkit on this one, several API methods I used are actually unfinished and kind of janky. So I hacked something together to make them work. diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 6d2f95d91..956af224c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -71,11 +71,15 @@ public class BlockListener implements Listener { continue; if(event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0) + { event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + event.getBlock().getState().removeMetadata(mcMMO.doubleDrops, plugin); + } else if(event.getBlock().getState().getMetadata(mcMMO.tripleDrops).size() > 0) { event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); + event.getBlock().getState().removeMetadata(mcMMO.tripleDrops, plugin); } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7858b9ec5..d8985d5d8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -429,14 +429,19 @@ Skills: Double_Drops: Herbalism: Beetroots: true + Beetroot: true Brown_Mushroom: true Cactus: true Carrots: true + Carrot: true Cocoa: true + Cocoa_Beans: true Wheat: true Melon: true + Melon_Slice: true Nether_Wart: true Potatoes: true + Potatoe: true Pumpkin: true Red_Mushroom: true Sugar_Cane: true From b7d33f022738c9ed25c66eb80c894a4f248cec93 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 18:11:32 -0700 Subject: [PATCH 7/8] Adding missing Double Drop entries for Woodcutting --- Changelog.txt | 7 +++++-- src/main/java/com/gmail/nossr50/config/Config.java | 8 ++++---- src/main/resources/config.yml | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 78e96c278..a9d59d5e2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,10 +9,13 @@ Key: Version 2.1.30 Fixed double drops behaving oddly + Double_Drop config table has been renamed to Bonus_Drops, this is to jankily auto-update everyones config DoubleDrop config tables now must contain all things that can possibly be doubled, such as the Ore block, the ore itself, etc. - Added the following items to the DoubleDrop tables for Mining: Coal, Diamond, Emerald, Glowstone_Dust, Iron_Ingot, Lapis_Lazuli, Nether_Quartz, Redstone, Cobblestone - Added the following items to the DoubleDrop tables for Herbalism: Beetroot, Carrot, Cocoa_Beans, Melon_Slice, Potatoe + Added the following items to the Bonus_Drops tables for Mining: Coal, Diamond, Emerald, Glowstone_Dust, Iron_Ingot, Lapis_Lazuli, Nether_Quartz, Redstone, Cobblestone + Added the following items to the Bonus_Drops tables for Herbalism: Beetroot, Carrot, Cocoa_Beans, Melon_Slice, Potatoe + Added the following items to the Bonus_Drops tables for Woodcutting: Birch_Wood, Spruce_Wood, Jungle_Wood, Dark_Oak_Wood, Oak_Wood, Acacia_Wood + NOTE: You don't need to update your configs for this one unless you had custom entries in the Double_Drop tables, the renaming of the key will auto-insert default values and give everyone correct defaults NOTE: I'm gonna have to blame Bukkit on this one, several API methods I used are actually unfinished and kind of janky. So I hacked something together to make them work. Version 2.1.29 diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index ddbd86cd8..73deca695 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -463,18 +463,18 @@ public class Config extends AutoUpdateConfigLoader { /* * SKILL SETTINGS */ - public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); } + public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) { return config.getBoolean("Bonus_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); } public boolean getDoubleDropsDisabled(PrimarySkillType skill) { String skillName = StringUtils.getCapitalized(skill.toString()); - ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName); + ConfigurationSection section = config.getConfigurationSection("Bonus_Drops." + skillName); if (section == null) return false; Set keys = section.getKeys(false); boolean disabled = true; for (String key : keys) { - if (config.getBoolean("Double_Drops." + skillName + "." + key)) { + if (config.getBoolean("Bonus_Drops." + skillName + "." + key)) { disabled = false; break; } @@ -540,7 +540,7 @@ public class Config extends AutoUpdateConfigLoader { public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); } /* Woodcutting */ - public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); } + public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Bonus_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); } public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); } public int getWoodcuttingGate() { return config.getInt("Skills.Woodcutting.Ability_Activation_Level_Gate", 10); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d8985d5d8..fd7507450 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -426,7 +426,7 @@ Skills: # # Settings for Double Drops ### -Double_Drops: +Bonus_Drops: Herbalism: Beetroots: true Beetroot: true @@ -490,11 +490,17 @@ Double_Drops: Stone: true Cobblestone: true Woodcutting: + Acacia_Wood: true Acacia_Log: true + Birch_Wood: true Birch_Log: true + Dark_Oak_Wood: true Dark_Oak_Log: true + Oak_Wood: true Oak_Log: true + Jungle_Wood: true Jungle_Log: true + Spruce_Wood: true Spruce_Log: true # From 69e5d3e1b5624e14faed3591e21f9901c8ae98ce Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Mar 2019 18:21:07 -0700 Subject: [PATCH 8/8] 2.1.30 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e5ffbdc4..d7f067afe 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.30-SNAPSHOT + 2.1.30 mcMMO https://github.com/mcMMO-Dev/mcMMO