diff --git a/Changelog.txt b/Changelog.txt
index 0d809d772f..4b4411717a 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -10,6 +10,7 @@ Version 2.2.000
TODO: Add unit test to determine crossbow or bow skill
TODO: Add unit test for trident xp processing
TODO: Add missing entries to changelog
+ Tree Feller now drops 90% less non-wood blocks (leaves/etc) on average
Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs
Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk
Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console
diff --git a/pom.xml b/pom.xml
index ae782333e7..c354eb0320 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.2.000-BETA-02-SNAPSHOT
+ 2.2.000-BETA-03-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java
index 403f23a970..fc3f19d4c8 100644
--- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java
@@ -34,6 +34,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
//TODO: Seems to not be using the item drop event for bonus drops, may want to change that.. or may not be able to be changed?
public class WoodcuttingManager extends SkillManager {
@@ -89,6 +90,13 @@ private boolean checkCleanCutsActivation(Material material) {
*/
public void processBonusDropCheck(@NotNull BlockState blockState) {
//TODO: Why isn't this using the item drop event? Potentially because of Tree Feller? This should be adjusted either way.
+ if (BlockUtils.isNonWoodPartOfTree(blockState)) {
+ // Leafs should drop less
+ if (ThreadLocalRandom.current().nextInt(100) < 90) {
+ return;
+ }
+ }
+
if(mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, blockState.getType())) {
//Mastery enabled for player
if(Permissions.canUseSubSkill(getPlayer(), SubSkillType.WOODCUTTING_CLEAN_CUTS)) {
diff --git a/src/test/java/com/gmail/nossr50/MMOTestEnvironment.java b/src/test/java/com/gmail/nossr50/MMOTestEnvironment.java
index 7ba7ae97c7..973cf0f282 100644
--- a/src/test/java/com/gmail/nossr50/MMOTestEnvironment.java
+++ b/src/test/java/com/gmail/nossr50/MMOTestEnvironment.java
@@ -30,6 +30,7 @@
import java.util.logging.Logger;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
public abstract class MMOTestEnvironment {
protected MockedStatic mockedMcMMO;
@@ -62,23 +63,24 @@ public abstract class MMOTestEnvironment {
protected String playerName = "testPlayer";
protected ChunkManager chunkManager;
+ protected MaterialMapStore materialMapStore;
protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException {
mockedMcMMO = Mockito.mockStatic(mcMMO.class);
mcMMO.p = Mockito.mock(mcMMO.class);
- Mockito.when(mcMMO.p.getLogger()).thenReturn(logger);
+ when(mcMMO.p.getLogger()).thenReturn(logger);
// place store
chunkManager = Mockito.mock(ChunkManager.class);
- Mockito.when(mcMMO.getPlaceStore()).thenReturn(chunkManager);
+ when(mcMMO.getPlaceStore()).thenReturn(chunkManager);
// shut off mod manager for woodcutting
- Mockito.when(mcMMO.getModManager()).thenReturn(Mockito.mock(ModManager.class));
- Mockito.when(mcMMO.getModManager().isCustomLog(any())).thenReturn(false);
+ when(mcMMO.getModManager()).thenReturn(Mockito.mock(ModManager.class));
+ when(mcMMO.getModManager().isCustomLog(any())).thenReturn(false);
// chat config
mockedChatConfig = Mockito.mockStatic(ChatConfig.class);
- Mockito.when(ChatConfig.getInstance()).thenReturn(Mockito.mock(ChatConfig.class));
+ when(ChatConfig.getInstance()).thenReturn(Mockito.mock(ChatConfig.class));
// general config
mockGeneralConfig();
@@ -94,10 +96,10 @@ protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException {
// wire skill tools
this.skillTools = new SkillTools(mcMMO.p);
- Mockito.when(mcMMO.p.getSkillTools()).thenReturn(skillTools);
+ when(mcMMO.p.getSkillTools()).thenReturn(skillTools);
this.transientEntityTracker = new TransientEntityTracker();
- Mockito.when(mcMMO.getTransientEntityTracker()).thenReturn(transientEntityTracker);
+ when(mcMMO.getTransientEntityTracker()).thenReturn(transientEntityTracker);
mockPermissions();
@@ -105,26 +107,26 @@ protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException {
// wire server
this.server = Mockito.mock(Server.class);
- Mockito.when(mcMMO.p.getServer()).thenReturn(server);
+ when(mcMMO.p.getServer()).thenReturn(server);
// wire plugin manager
this.pluginManager = Mockito.mock(PluginManager.class);
- Mockito.when(server.getPluginManager()).thenReturn(pluginManager);
+ when(server.getPluginManager()).thenReturn(pluginManager);
// wire world
this.world = Mockito.mock(World.class);
// wire Misc
this.mockedMisc = Mockito.mockStatic(Misc.class);
- Mockito.when(Misc.getBlockCenter(any())).thenReturn(new Location(world, 0, 0, 0));
+ when(Misc.getBlockCenter(any())).thenReturn(new Location(world, 0, 0, 0));
// setup player and player related mocks after everything else
this.player = Mockito.mock(Player.class);
- Mockito.when(player.getUniqueId()).thenReturn(playerUUID);
+ when(player.getUniqueId()).thenReturn(playerUUID);
// wire inventory
this.playerInventory = Mockito.mock(PlayerInventory.class);
- Mockito.when(player.getInventory()).thenReturn(playerInventory);
+ when(player.getInventory()).thenReturn(playerInventory);
// PlayerProfile and McMMOPlayer are partially mocked
playerProfile = new PlayerProfile("testPlayer", player.getUniqueId(), 0);
@@ -132,16 +134,19 @@ protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException {
// wire user manager
this.mockedUserManager = Mockito.mockStatic(UserManager.class);
- Mockito.when(UserManager.getPlayer(player)).thenReturn(mmoPlayer);
+ when(UserManager.getPlayer(player)).thenReturn(mmoPlayer);
+
+ this.materialMapStore = new MaterialMapStore();
+ when(mcMMO.getMaterialMapStore()).thenReturn(materialMapStore);
}
private void mockPermissions() {
mockedPermissions = Mockito.mockStatic(Permissions.class);
- Mockito.when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
- Mockito.when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
- Mockito.when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
- Mockito.when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
- Mockito.when(Permissions.lucky(player, PrimarySkillType.WOODCUTTING)).thenReturn(false); // player is not lucky
+ when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
+ when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
+ when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
+ when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
+ when(Permissions.lucky(player, PrimarySkillType.WOODCUTTING)).thenReturn(false); // player is not lucky
}
private void mockRankConfig() {
@@ -150,24 +155,24 @@ private void mockRankConfig() {
private void mockAdvancedConfig() {
this.advancedConfig = Mockito.mock(AdvancedConfig.class);
- Mockito.when(mcMMO.p.getAdvancedConfig()).thenReturn(advancedConfig);
+ when(mcMMO.p.getAdvancedConfig()).thenReturn(advancedConfig);
}
private void mockGeneralConfig() {
generalConfig = Mockito.mock(GeneralConfig.class);
- Mockito.when(generalConfig.getTreeFellerThreshold()).thenReturn(100);
- Mockito.when(generalConfig.getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, Material.OAK_LOG)).thenReturn(true);
- Mockito.when(generalConfig.getLocale()).thenReturn("en_US");
- Mockito.when(mcMMO.p.getGeneralConfig()).thenReturn(generalConfig);
+ when(generalConfig.getTreeFellerThreshold()).thenReturn(100);
+ when(generalConfig.getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, Material.OAK_LOG)).thenReturn(true);
+ when(generalConfig.getLocale()).thenReturn("en_US");
+ when(mcMMO.p.getGeneralConfig()).thenReturn(generalConfig);
}
private void mockExperienceConfig() {
experienceConfig = Mockito.mockStatic(ExperienceConfig.class);
- Mockito.when(ExperienceConfig.getInstance()).thenReturn(Mockito.mock(ExperienceConfig.class));
+ when(ExperienceConfig.getInstance()).thenReturn(Mockito.mock(ExperienceConfig.class));
// Combat
- Mockito.when(ExperienceConfig.getInstance().getCombatXP("Cow")).thenReturn(1D);
+ when(ExperienceConfig.getInstance().getCombatXP("Cow")).thenReturn(1D);
}
protected void cleanupBaseEnvironment() {