2.1.29 - Double Drop Fix

This commit is contained in:
nossr50 2019-03-29 11:27:49 -07:00
parent 39b22d0ee8
commit 74908cdcf5
8 changed files with 27 additions and 20 deletions

View File

@ -7,6 +7,9 @@ Key:
! Change ! Change
- Removal - Removal
Version 2.1.29
Fixed a bug where double drops and triple drops were not activating
Version 2.1.28 Version 2.1.28
Fixed a bug where Archery could not gain XP Fixed a bug where Archery could not gain XP

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.28</version> <version>2.1.29</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -29,10 +29,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.GameMode; import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.*; import org.bukkit.block.*;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
@ -55,9 +52,13 @@ public class BlockListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) /* @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDropItemEvent(BlockDropItemEvent event) public void onBlockDropItemEvent(BlockDropItemEvent event)
{ {
Bukkit.broadcastMessage("Debug: Drop Item Event");
for(Item item : event.getItems()) for(Item item : event.getItems())
{ {
ItemStack is = new ItemStack(item.getItemStack()); ItemStack is = new ItemStack(item.getItemStack());
@ -88,7 +89,7 @@ public class BlockListener implements Listener {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
} }
} }
} }*/
/** /**
* Monitor BlockPistonExtend events. * Monitor BlockPistonExtend events.

View File

@ -114,8 +114,6 @@ public class mcMMO extends JavaPlugin {
public final static String disarmedItemKey = "mcMMO: Disarmed Item"; public final static String disarmedItemKey = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data"; public final static String playerDataKey = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb"; 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 databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal"; public final static String bredMetadataKey = "mcMMO: Bred Animal";

View File

@ -67,7 +67,7 @@ public class Herbalism {
dropAmount++; dropAmount++;
if(herbalismManager.checkDoubleDrop(target.getState())) 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}) for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST})
@ -110,7 +110,7 @@ public class Herbalism {
dropAmount++; dropAmount++;
if(herbalismManager.checkDoubleDrop(relativeBlock.getState())) if(herbalismManager.checkDoubleDrop(relativeBlock.getState()))
BlockUtils.markBlocksForBonusDrops(relativeBlock.getState(), triple); BlockUtils.spawnBonusDrops(relativeBlock.getState(), triple);
} }
} }
} }
@ -142,7 +142,7 @@ public class Herbalism {
amount += 1; amount += 1;
if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState())) if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
BlockUtils.markBlocksForBonusDrops(relativeUpBlock.getState(), triple); BlockUtils.spawnBonusDrops(relativeUpBlock.getState(), triple);
} }

View File

@ -147,7 +147,7 @@ public class HerbalismManager extends SkillManager {
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) {
if(checkDoubleDrop(blockState)) if(checkDoubleDrop(blockState))
BlockUtils.markBlocksForBonusDrops(blockState, greenTerra); BlockUtils.spawnBonusDrops(blockState, greenTerra);
} }
} }
else { else {
@ -165,7 +165,7 @@ public class HerbalismManager extends SkillManager {
} else { } else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */ /* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */
if(checkDoubleDrop(blockState)) if(checkDoubleDrop(blockState))
BlockUtils.markBlocksForBonusDrops(blockState, greenTerra); BlockUtils.spawnBonusDrops(blockState, greenTerra);
} }
if (Permissions.greenThumbPlant(player, material)) { if (Permissions.greenThumbPlant(player, material)) {

View File

@ -91,7 +91,7 @@ public class MiningManager extends SkillManager {
//TODO: Make this readable //TODO: Make this readable
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) { if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
BlockUtils.markBlocksForBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility())); BlockUtils.spawnBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
} }
} }

View File

@ -9,11 +9,13 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable; import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet; import java.util.HashSet;
@ -26,12 +28,15 @@ public final class BlockUtils {
* @param blockState target blockstate * @param blockState target blockstate
* @param triple marks the block to give triple drops * @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) for(ItemStack spawnItem : blockState.getBlock().getDrops())
blockState.setMetadata(mcMMO.tripleDropKey, mcMMO.metadataValue); {
else if(triple)
blockState.setMetadata(mcMMO.doubleDropKey, mcMMO.metadataValue); blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
}
} }
/** /**