Fixed a bug with herbalism double drops

This commit is contained in:
nossr50 2019-08-05 10:39:33 -04:00
parent 7c17126ffb
commit 11409c07c0
2 changed files with 22 additions and 4 deletions

View File

@ -1,5 +1,7 @@
Version 2.1.100
Corrected some mistakes made in the updated Russian locale (thanks myfbone!)
Updated Russian locale (thanks myfbone!)
Fixed a bug where plants could double drop when the skill was not yet unlocked
Fixed a bug where plants ALWAYS double dropped
mcnotify command now checks that it's being executed by a player
Fixed some concurrency concerns around BleedTasks
Fixed an NPE that may occur with random chances on a player without loaded data

View File

@ -19,6 +19,7 @@ import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
@ -164,7 +165,7 @@ public class HerbalismManager extends SkillManager {
* Mark blocks for double drops
* Be aware of the hacky interactions we are doing with Chorus Plants
*/
checkDoubleDropsOnBrokenPlants(brokenPlants);
checkDoubleDropsOnBrokenPlants(blockBreakEvent.getPlayer(), brokenPlants);
//It would take an expensive algorithm to predict which parts of a Chorus Tree will break as a result of root break
//So this hacky method is used instead
@ -212,7 +213,20 @@ public class HerbalismManager extends SkillManager {
}
}
public void checkDoubleDropsOnBrokenPlants(Collection<Block> brokenPlants) {
/**
* Check for double drops on a collection of broken blocks
* If a double drop has occurred, it will be marked here for bonus drops
* @param player player who broke the blocks
* @param brokenPlants the collection of broken plants
*/
public void checkDoubleDropsOnBrokenPlants(Player player, Collection<Block> brokenPlants) {
//Only proceed if skill unlocked and permission enabled
if (!RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS)
|| !Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS)) {
return;
}
for(Block brokenPlant : brokenPlants) {
BlockState brokenPlantState = brokenPlant.getState();
BlockData plantData = brokenPlantState.getBlockData();
@ -233,7 +247,9 @@ public class HerbalismManager extends SkillManager {
Ageable ageable = (Ageable) plantData;
if(isAgeableMature(ageable) || isBizarreAgeable(plantData)) {
markForBonusDrops(brokenPlantState);
if(checkDoubleDrop(brokenPlantState)) {
markForBonusDrops(brokenPlantState);
}
}
} else if(checkDoubleDrop(brokenPlantState)) {
//Add metadata to mark this block for double or triple drops