mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Added "Shroom Thumb" ability to Herbalism. Closes #724
This commit is contained in:
parent
3bd9a30055
commit
2373ca82ba
@ -39,6 +39,7 @@ Version 1.4.00-dev
|
|||||||
+ Added ability for config files to automatically update with new keys, and prune out old ones
|
+ Added ability for config files to automatically update with new keys, and prune out old ones
|
||||||
+ Added config option to make .new config files instead over writing over old ones when updating
|
+ Added config option to make .new config files instead over writing over old ones when updating
|
||||||
+ Added "Holy Hound" ability to Taming
|
+ Added "Holy Hound" ability to Taming
|
||||||
|
+ Added "Shroom Thumb" ability to Herbalism
|
||||||
= Fixed Green Thumb on wheat not working properly at rank 4
|
= Fixed Green Thumb on wheat not working properly at rank 4
|
||||||
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
||||||
= Fixed Green Terra not also checking Green Thumb permissions
|
= Fixed Green Terra not also checking Green Thumb permissions
|
||||||
|
@ -111,6 +111,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||||
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
|
public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); }
|
||||||
|
public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); }
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||||
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
@ -363,6 +363,12 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SHROOM THUMB CHECK */
|
||||||
|
else if (BlockChecks.canMakeShroomy(blockState)) {
|
||||||
|
if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) {
|
||||||
|
blockState.update(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
@ -27,6 +27,7 @@ import com.gmail.nossr50.skills.utilities.SkillTools;
|
|||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Herbalism {
|
public class Herbalism {
|
||||||
@ -46,6 +47,9 @@ public class Herbalism {
|
|||||||
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
|
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
|
||||||
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
|
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
|
||||||
|
|
||||||
|
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
|
||||||
|
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the farmers diet skill.
|
* Handle the farmers diet skill.
|
||||||
*
|
*
|
||||||
@ -314,4 +318,59 @@ public class Herbalism {
|
|||||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the Shroom Thumb ability.
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
* @param player The {@link Player} using this ability
|
||||||
|
* @return true if the ability was successful, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean processShroomThumb(BlockState blockState, Player player) {
|
||||||
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
|
|
||||||
|
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
|
||||||
|
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||||
|
player.updateInventory();
|
||||||
|
|
||||||
|
if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, shroomThumbMaxChance, shroomThumbMaxLevel)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertShroomThumb(blockState, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
* @param player The {@link Player} using this ability
|
||||||
|
* @return true if the ability was successful, false otherwise
|
||||||
|
*/
|
||||||
|
private static boolean convertShroomThumb(BlockState blockState, Player player) {
|
||||||
|
if (!Permissions.shroomThumb(player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (blockState.getType()){
|
||||||
|
case DIRT:
|
||||||
|
case GRASS:
|
||||||
|
blockState.setType(Material.MYCEL);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
private String doubleDropChanceLucky;
|
private String doubleDropChanceLucky;
|
||||||
private String hylianLuckChance;
|
private String hylianLuckChance;
|
||||||
private String hylianLuckChanceLucky;
|
private String hylianLuckChanceLucky;
|
||||||
|
private String shroomThumbChance;
|
||||||
|
private String shroomThumbChanceLucky;
|
||||||
|
|
||||||
private boolean hasHylianLuck;
|
private boolean hasHylianLuck;
|
||||||
private boolean canGreenTerra;
|
private boolean canGreenTerra;
|
||||||
@ -25,6 +27,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
private boolean canGreenThumbBlocks;
|
private boolean canGreenThumbBlocks;
|
||||||
private boolean canFarmersDiet;
|
private boolean canFarmersDiet;
|
||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
|
private boolean canShroomThumb;
|
||||||
private boolean doubleDropsDisabled;
|
private boolean doubleDropsDisabled;
|
||||||
|
|
||||||
public HerbalismCommand() {
|
public HerbalismCommand() {
|
||||||
@ -57,6 +60,11 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
||||||
hylianLuckChance = hylianLuckStrings[0];
|
hylianLuckChance = hylianLuckStrings[0];
|
||||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||||
|
|
||||||
|
//SHROOM THUMB
|
||||||
|
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
||||||
|
shroomThumbChance = shroomThumbStrings[0];
|
||||||
|
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,11 +76,12 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
canFarmersDiet = Permissions.farmersDiet(player);
|
canFarmersDiet = Permissions.farmersDiet(player);
|
||||||
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
||||||
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
||||||
|
canShroomThumb = Permissions.shroomThumb(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean effectsHeaderPermissions() {
|
protected boolean effectsHeaderPermissions() {
|
||||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,6 +108,10 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShroomThumb) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
|
||||||
|
}
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
||||||
}
|
}
|
||||||
@ -106,7 +119,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean statsHeaderPermissions() {
|
protected boolean statsHeaderPermissions() {
|
||||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,6 +158,16 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShroomThumb) {
|
||||||
|
if (isLucky) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
||||||
|
@ -345,4 +345,21 @@ public final class BlockChecks {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a given block can be made into Mycelium
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block can be made in Mycelium, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean canMakeShroomy(BlockState blockState) {
|
||||||
|
switch (blockState.getType()) {
|
||||||
|
case DIRT:
|
||||||
|
case GRASS:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ public final class Permissions {
|
|||||||
public static boolean greenThumbBlock(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase()); }
|
public static boolean greenThumbBlock(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase()); }
|
||||||
public static boolean greenThumbPlant(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase()); }
|
public static boolean greenThumbPlant(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase()); }
|
||||||
public static boolean hylianLuck(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.hylianluck"); }
|
public static boolean hylianLuck(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.hylianluck"); }
|
||||||
|
public static boolean shroomThumb(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.shroomthumb"); }
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
public static boolean biggerBombs(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs"); }
|
public static boolean biggerBombs(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs"); }
|
||||||
|
@ -156,6 +156,11 @@ Skills:
|
|||||||
# HylianLuck_MaxBonusLevel: On this level, Hylian Luck chance will be HylianLuck_ChanceMax
|
# HylianLuck_MaxBonusLevel: On this level, Hylian Luck chance will be HylianLuck_ChanceMax
|
||||||
HylianLuck_ChanceMax: 10.0
|
HylianLuck_ChanceMax: 10.0
|
||||||
HylianLuck_MaxBonusLevel: 1000
|
HylianLuck_MaxBonusLevel: 1000
|
||||||
|
|
||||||
|
# ShroomThumb_ChanceMax: Maximum chance of ShroomThumb
|
||||||
|
# ShroomThumb_MaxBonusLevel: On this level, ShroomThumb chance will be ShroomThumb_ChanceMax
|
||||||
|
ShroomThumb_ChanceMax: 50.0
|
||||||
|
ShroomThumb_MaxBonusLevel: 1500
|
||||||
#
|
#
|
||||||
# Settings for Mining
|
# Settings for Mining
|
||||||
###
|
###
|
||||||
|
@ -131,6 +131,8 @@ Herbalism.Ability.GTh=[[GREEN]]**GREEN THUMB**
|
|||||||
Herbalism.Ability.HylianLuck=[[RED]]Hylian Luck Chance: [[YELLOW]]{0}
|
Herbalism.Ability.HylianLuck=[[RED]]Hylian Luck Chance: [[YELLOW]]{0}
|
||||||
Herbalism.Ability.Lower=[[GRAY]]**YOU LOWER YOUR HOE**
|
Herbalism.Ability.Lower=[[GRAY]]**YOU LOWER YOUR HOE**
|
||||||
Herbalism.Ability.Ready=[[GREEN]]**YOU READY YOUR HOE**
|
Herbalism.Ability.Ready=[[GREEN]]**YOU READY YOUR HOE**
|
||||||
|
Herbalism.Ability.ShroomThumb.Chance=[[RED]]Shroom Thumb Chance: [[YELLOW]]{0}
|
||||||
|
Herbalism.Ability.ShroomThumb.Fail=[[RED]]**SHROOM THUMB FAIL**
|
||||||
Herbalism.Effect.0=Green Terra (ABILITY)
|
Herbalism.Effect.0=Green Terra (ABILITY)
|
||||||
Herbalism.Effect.1=Spread the Terra, 3x Drops
|
Herbalism.Effect.1=Spread the Terra, 3x Drops
|
||||||
Herbalism.Effect.2=Green Thumb (Wheat)
|
Herbalism.Effect.2=Green Thumb (Wheat)
|
||||||
@ -143,6 +145,8 @@ Herbalism.Effect.8=Double Drops (All Herbs)
|
|||||||
Herbalism.Effect.9=Double the normal loot
|
Herbalism.Effect.9=Double the normal loot
|
||||||
Herbalism.Effect.10=Hylian Luck
|
Herbalism.Effect.10=Hylian Luck
|
||||||
Herbalism.Effect.11=Gives a small chance of finding rare items
|
Herbalism.Effect.11=Gives a small chance of finding rare items
|
||||||
|
Herbalism.Effect.12=Shroom Thumb
|
||||||
|
Herbalism.Effect.13=Spread mycelium to dirt & grass
|
||||||
Herbalism.HylianLuck=[[GREEN]]The luck of Hyrule is with you today!
|
Herbalism.HylianLuck=[[GREEN]]The luck of Hyrule is with you today!
|
||||||
Herbalism.Listener=Herbalism:
|
Herbalism.Listener=Herbalism:
|
||||||
Herbalism.SkillName=HERBALISM
|
Herbalism.SkillName=HERBALISM
|
||||||
|
@ -277,6 +277,7 @@ permissions:
|
|||||||
mcmmo.ability.herbalism.greenterra: true
|
mcmmo.ability.herbalism.greenterra: true
|
||||||
mcmmo.ability.herbalism.greenthumb.all: true
|
mcmmo.ability.herbalism.greenthumb.all: true
|
||||||
mcmmo.ability.herbalism.hylianluck: true
|
mcmmo.ability.herbalism.hylianluck: true
|
||||||
|
mcmmo.ability.herbalism.shroomthumb: true
|
||||||
mcmmo.ability.herbalism.doubledrops:
|
mcmmo.ability.herbalism.doubledrops:
|
||||||
description: Allows double drop chance from Herbalism
|
description: Allows double drop chance from Herbalism
|
||||||
mcmmo.ability.herbalism.farmersdiet:
|
mcmmo.ability.herbalism.farmersdiet:
|
||||||
@ -368,6 +369,8 @@ permissions:
|
|||||||
mcmmo.ability.herbalism.greenthumb.plants.crops: true
|
mcmmo.ability.herbalism.greenthumb.plants.crops: true
|
||||||
mcmmo.ability.herbalism.hylianluck:
|
mcmmo.ability.herbalism.hylianluck:
|
||||||
description: Allows access to the Hylian Luck ability
|
description: Allows access to the Hylian Luck ability
|
||||||
|
mcmmo.ability.herbalism.shroomthumb:
|
||||||
|
description: Allows access to the Shroom Thumb ability
|
||||||
mcmmo.ability.mining.*:
|
mcmmo.ability.mining.*:
|
||||||
default: false
|
default: false
|
||||||
description: Allows access to all Mining abilities
|
description: Allows access to all Mining abilities
|
||||||
|
Loading…
Reference in New Issue
Block a user