Sweet Berry bushes now grant XP when harvested and no longer activate tools

This commit is contained in:
nossr50 2021-03-25 13:42:20 -07:00
parent 2c5e11138b
commit e40ab38bbd
4 changed files with 63 additions and 2 deletions

View File

@ -1,4 +1,6 @@
Version 2.1.182 Version 2.1.182
Players now receive XP from harvesting Sweet Berry bushes (double XP for harvesting fully grown berries)
Sweet Berry Bush will no longer ready tools for Super Abilities
You can now use '.all' (for example: mcmmo.perks.xp.customboost.all) to give an XP perk to all skills You can now use '.all' (for example: mcmmo.perks.xp.customboost.all) to give an XP perk to all skills
Removed hardcore and vampirism commands, these commands are dangerous, just modify the config file if you want to use hardcore / vampirism Removed hardcore and vampirism commands, these commands are dangerous, just modify the config file if you want to use hardcore / vampirism
Fixed several errors in de locale (Thanks TheBusyBiscuit & w1tcherrr) Fixed several errors in de locale (Thanks TheBusyBiscuit & w1tcherrr)

View File

@ -841,10 +841,13 @@ public class PlayerListener implements Listener {
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) { if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
Bukkit.getPluginManager().callEvent(fakeSwing); Bukkit.getPluginManager().callEvent(fakeSwing);
event.setCancelled(true); event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) { if (herbalismManager.processShroomThumb(blockState)
&& EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true); blockState.update(true);
} }
} }
} else {
herbalismManager.processBerryBushHarvesting(blockState);
} }
break; break;

View File

@ -40,6 +40,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -62,6 +63,10 @@ public class HerbalismManager extends SkillManager {
} }
public boolean canUseShroomThumb(BlockState blockState) { public boolean canUseShroomThumb(BlockState blockState) {
if(!BlockUtils.canMakeShroomy(blockState)) {
return false;
}
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB)) if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
return false; return false;
@ -69,7 +74,57 @@ public class HerbalismManager extends SkillManager {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
Material itemType = inventory.getItemInMainHand().getType(); Material itemType = inventory.getItemInMainHand().getType();
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB); return (itemType == Material.BROWN_MUSHROOM
|| itemType == Material.RED_MUSHROOM)
&& inventory.contains(Material.BROWN_MUSHROOM, 1)
&& inventory.contains(Material.RED_MUSHROOM, 1)
&& Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
}
public void processBerryBushHarvesting(@NotNull BlockState blockState) {
/* Check if the player is harvesting a berry bush */
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Processing sweet berry bush rewards");
}
//Check the age
if(blockState.getBlockData() instanceof Ageable) {
int rewardByAge = 0;
Ageable ageable = (Ageable) blockState.getBlockData();
if(ageable.getAge() == 2) {
rewardByAge = 1; //Normal XP
} else if(ageable.getAge() == 3) {
rewardByAge = 2; //Double XP
} else {
return; //Not old enough, back out of processing
}
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Bush Reward Multiplier: " + rewardByAge);
}
int xpReward = ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, blockState) * rewardByAge;
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Bush XP: " + xpReward);
}
//Check for double drops
if(checkDoubleDrop(blockState)) {
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Double Drops succeeded for Berry Bush");
}
//Add metadata to mark this block for double or triple drops
markForBonusDrops(blockState);
}
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
}
}
} }
public boolean canUseHylianLuck() { public boolean canUseHylianLuck() {

View File

@ -1265,6 +1265,7 @@ public class MaterialMapStore {
toolBlackList.add("stonecutter"); toolBlackList.add("stonecutter");
toolBlackList.add("lodestone"); toolBlackList.add("lodestone");
toolBlackList.add("respawn_anchor"); toolBlackList.add("respawn_anchor");
toolBlackList.add("sweet_berry_bush");
} }
public boolean isIntendedToolPickaxe(Material material) { public boolean isIntendedToolPickaxe(Material material) {