diff --git a/Changelog.txt b/Changelog.txt index 82235738a..a9d59d5e2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,23 @@ Key: ! Change - Removal +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 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 + 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 + 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..d7f067afe 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.27 + 2.1.30 mcMMO https://github.com/mcMMO-Dev/mcMMO 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/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 9cf7452d1..956af224c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -62,34 +62,66 @@ public class BlockListener implements Listener { { 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); + event.getBlock().getState().removeMetadata(mcMMO.doubleDrops, plugin); } - - else if(event.getBlock().getState().getMetadata(mcMMO.tripleDropKey).size() > 0) + else if(event.getBlock().getState().getMetadata(mcMMO.tripleDrops).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); + event.getBlock().getState().removeMetadata(mcMMO.tripleDrops, plugin); } } } + /*@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) + { + 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); + } + } + } + }*/ + /** * Monitor BlockPistonExtend events. * 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/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 365fb124d..7d8664e4b 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -110,12 +110,12 @@ 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"; 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/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/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index dd9e0cdf2..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.markBlocksForBonusDrops(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.markBlocksForBonusDrops(relativeBlock.getState(), triple); + BlockUtils.markDropsAsBonus(relativeBlock.getState(), triple); } } } @@ -142,7 +142,7 @@ public class Herbalism { amount += 1; if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState())) - BlockUtils.markBlocksForBonusDrops(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 accd2ab56..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.markBlocksForBonusDrops(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.markBlocksForBonusDrops(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 c9d54579c..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.markBlocksForBonusDrops(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 129e5c1aa..66cef68f3 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -26,12 +26,12 @@ 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 markDropsAsBonus(BlockState blockState, boolean triple) { if(triple) - blockState.setMetadata(mcMMO.tripleDropKey, mcMMO.metadataValue); + blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue); else - blockState.setMetadata(mcMMO.doubleDropKey, mcMMO.metadataValue); + blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue); } /** 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..f1a58e6b4 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -240,7 +240,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 +327,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 +339,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 +356,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) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4c616b22d..fd7507450 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -426,17 +426,22 @@ Skills: # # Settings for Double Drops ### -Double_Drops: +Bonus_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 @@ -461,26 +466,41 @@ 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_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 #