mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Fixing Mining Double Drops (update configs)
This commit is contained in:
parent
8d477a5cf5
commit
53534e0f1d
@ -7,6 +7,13 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- 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
|
Version 2.1.29
|
||||||
Fixed a bug where double drops and triple drops were not activating
|
Fixed a bug where double drops and triple drops were not activating
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -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.29</version>
|
<version>2.1.30-SNAPSHOT</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>
|
||||||
|
@ -35,6 +35,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Tag;
|
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.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;
|
||||||
@ -54,42 +55,66 @@ 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());
|
||||||
|
|
||||||
if(!event.getBlock().getDrops().contains(is))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(is.getAmount() <= 0)
|
if(is.getAmount() <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(event.getBlock().getState().getMetadata(mcMMO.doubleDropKey).size() > 0)
|
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType())
|
||||||
{
|
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType())
|
||||||
//Extra Protection
|
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType()))
|
||||||
if(event.getBlock().getState() instanceof Container)
|
continue;
|
||||||
return;
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@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> metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops);
|
||||||
|
|
||||||
|
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
|
||||||
|
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
|
||||||
|
|
||||||
|
if(potentialDrops.contains(is))
|
||||||
|
{
|
||||||
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)
|
event.getBlock().removeMetadata(mcMMO.doubleDrops, plugin);
|
||||||
{
|
} else {
|
||||||
//Extra Protection
|
if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) {
|
||||||
if(event.getBlock().getState() instanceof Container)
|
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops);
|
||||||
return;
|
|
||||||
event.getBlock().getState().removeMetadata(mcMMO.tripleDropKey, plugin);
|
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
|
||||||
|
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) 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().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.getBlock().removeMetadata(mcMMO.tripleDrops, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@ -110,6 +110,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
||||||
public final static String bowForceKey = "mcMMO: Bow Force";
|
public final static String bowForceKey = "mcMMO: Bow Force";
|
||||||
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
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 customDamageKey = "mcMMO: Custom Damage";
|
||||||
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";
|
||||||
|
@ -67,7 +67,7 @@ public class Herbalism {
|
|||||||
dropAmount++;
|
dropAmount++;
|
||||||
|
|
||||||
if(herbalismManager.checkDoubleDrop(target.getState()))
|
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})
|
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.spawnBonusDrops(relativeBlock.getState(), triple);
|
BlockUtils.markDropsAsBonus(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.spawnBonusDrops(relativeUpBlock.getState(), triple);
|
BlockUtils.markDropsAsBonus(relativeUpBlock.getState(), triple);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.spawnBonusDrops(blockState, greenTerra);
|
BlockUtils.markDropsAsBonus(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.spawnBonusDrops(blockState, greenTerra);
|
BlockUtils.markDropsAsBonus(blockState, greenTerra);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.greenThumbPlant(player, material)) {
|
if (Permissions.greenThumbPlant(player, material)) {
|
||||||
|
@ -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.spawnBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
|
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ 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;
|
||||||
|
|
||||||
@ -27,15 +26,12 @@ 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 spawnBonusDrops(BlockState blockState, boolean triple)
|
public static void markDropsAsBonus(BlockState blockState, boolean triple)
|
||||||
{
|
|
||||||
for(ItemStack spawnItem : blockState.getBlock().getDrops())
|
|
||||||
{
|
{
|
||||||
if(triple)
|
if(triple)
|
||||||
blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
|
blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue);
|
||||||
|
else
|
||||||
blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
|
blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -461,20 +461,29 @@ Double_Drops:
|
|||||||
Diorite: true
|
Diorite: true
|
||||||
Granite: true
|
Granite: true
|
||||||
Coal_Ore: true
|
Coal_Ore: true
|
||||||
|
Coal: true
|
||||||
Diamond_Ore: true
|
Diamond_Ore: true
|
||||||
|
Diamond: true
|
||||||
Emerald_Ore: true
|
Emerald_Ore: true
|
||||||
|
Emerald: true
|
||||||
End_Stone: true
|
End_Stone: true
|
||||||
Glowstone: true
|
Glowstone: true
|
||||||
|
Glowstone_Dust: true
|
||||||
Gold_Ore: true
|
Gold_Ore: true
|
||||||
Iron_Ore: true
|
Iron_Ore: true
|
||||||
|
Iron_Ingot: true
|
||||||
Lapis_Ore: true
|
Lapis_Ore: true
|
||||||
|
Lapis_Lazuli: true
|
||||||
Mossy_Cobblestone: true
|
Mossy_Cobblestone: true
|
||||||
Netherrack: true
|
Netherrack: true
|
||||||
Obsidian: true
|
Obsidian: true
|
||||||
Nether_Quartz_Ore: true
|
Nether_Quartz_Ore: true
|
||||||
|
Nether_Quartz: true
|
||||||
Redstone_Ore: true
|
Redstone_Ore: true
|
||||||
|
Redstone: true
|
||||||
Sandstone: true
|
Sandstone: true
|
||||||
Stone: true
|
Stone: true
|
||||||
|
Cobblestone: true
|
||||||
Woodcutting:
|
Woodcutting:
|
||||||
Acacia_Log: true
|
Acacia_Log: true
|
||||||
Birch_Log: true
|
Birch_Log: true
|
||||||
|
Loading…
Reference in New Issue
Block a user