From bddca30668be5c262e992a6c60a555dd30a536b2 Mon Sep 17 00:00:00 2001 From: Tslat Date: Sat, 5 Mar 2016 20:39:16 +1000 Subject: [PATCH 1/5] Fix infinite GreenThumb & ShroomThumb usage bug --- .../nossr50/skills/herbalism/HerbalismManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 6131c5ae4..21c2d1e40 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -50,13 +50,21 @@ public class HerbalismManager extends SkillManager { public boolean canGreenThumbBlock(BlockState blockState) { Player player = getPlayer(); + ItemStack item = player.getInventory().getItemInMainHand(); + + if (item.getAmount() <= 0) + return false; - return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); + return item.getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); } public boolean canUseShroomThumb(BlockState blockState) { Player player = getPlayer(); - Material itemType = player.getItemInHand().getType(); + ItemStack item = player.getInventory().getItemInMainHand(); + Material itemType = item.getType(); + + if (item.getAmount() <= 0) + return false; return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB); } From 5f960fd80ab38ffb5a511aeae5ce97abfa2c6713 Mon Sep 17 00:00:00 2001 From: Tslat Date: Sun, 6 Mar 2016 14:36:21 +1000 Subject: [PATCH 2/5] Update ability blacklist to include 1.8 fence[gate] types --- src/main/java/com/gmail/nossr50/util/BlockUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 6662f37b1..b485f49bb 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -47,6 +47,11 @@ public final class BlockUtils { case ENCHANTMENT_TABLE: case ENDER_CHEST: case FENCE_GATE: + case ACACIA_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case JUNGLE_FENCE_GATE: case FURNACE: case IRON_DOOR_BLOCK: case JUKEBOX: @@ -70,10 +75,12 @@ public final class BlockUtils { case BIRCH_DOOR: case JUNGLE_DOOR: case DARK_OAK_DOOR: + case FENCE: case ACACIA_FENCE: case DARK_OAK_FENCE: case BIRCH_FENCE: case JUNGLE_FENCE: + case SPRUCE_FENCE: case ARMOR_STAND: return false; From 272e99d41f1dc3588b5053468fadd08380ac8839 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sun, 6 Mar 2016 16:48:22 -0500 Subject: [PATCH 3/5] Master volume config option --- src/main/java/com/gmail/nossr50/config/Config.java | 2 ++ src/main/java/com/gmail/nossr50/util/Misc.java | 13 +++++++------ src/main/resources/config.yml | 7 +++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index ed342a143..6a0cf3d96 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -533,4 +533,6 @@ public class Config extends AutoUpdateConfigLoader { /* PVP & PVE Settings */ public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); } public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); } + + public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); } } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index d6e3f17fc..9d0f503d4 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.util.player.UserManager; @@ -30,14 +31,14 @@ public final class Misc { // Sound Pitches & Volumes from CB public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values - public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values - public static final float FIZZ_VOLUME = 0.5F; - public static final float POP_VOLUME = 0.2F; - public static final float BAT_VOLUME = 1.0F; + public static final float ANVIL_USE_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); // Not in CB directly, I went off the place sound values + public static final float FIZZ_VOLUME = 0.5F * Config.getInstance().getMasterVolume(); + public static final float POP_VOLUME = 0.2F * Config.getInstance().getMasterVolume(); + public static final float BAT_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); public static final float BAT_PITCH = 0.6F; - public static final float GHAST_VOLUME = 1.0F; + public static final float GHAST_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up - public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always + public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always public static final Set modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 713eb4575..5f4ade1d9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -502,3 +502,10 @@ Particles: # this will happen by default for every 100 levels. LevelUp_Enabled: true LevelUp_Tier: 100 +# +# Settings for sounds +### +Sounds: + # This setting controls the master volume. 1.0 is Max, 0 would be off + MasterVolume: 1.0 + From 52f1e33052255369852b331fffde30f0dc495f59 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Mon, 7 Mar 2016 18:41:49 -0500 Subject: [PATCH 4/5] I think this fixes the auto update config function when a config file has two similar keys. --- .../com/gmail/nossr50/config/AutoUpdateConfigLoader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java index 424bf3faf..394964a4f 100644 --- a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java @@ -88,8 +88,11 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { // Dump to the new one for (String key : comments.keySet()) { - if (output.contains(key)) { - output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key)); + if (output.contains(" " + key)) { + output = output.substring(0, output.indexOf(" " + key)) + comments.get(key) + output.substring(output.indexOf(" " + key)); + } + if (output.contains("\n" + key)) { + output = output.substring(0, output.indexOf("\n" + key)) + comments.get(key) + output.substring(output.indexOf("\n" + key)); } } } From 9bc97c6dd35276e543ebe27b3669db85676883a2 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Tue, 8 Mar 2016 08:09:48 -0500 Subject: [PATCH 5/5] I think this fixes the auto update config function when a config file has two similar keys. (reverted from commit 52f1e33052255369852b331fffde30f0dc495f59) --- .../com/gmail/nossr50/config/AutoUpdateConfigLoader.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java index 394964a4f..424bf3faf 100644 --- a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java @@ -88,11 +88,8 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { // Dump to the new one for (String key : comments.keySet()) { - if (output.contains(" " + key)) { - output = output.substring(0, output.indexOf(" " + key)) + comments.get(key) + output.substring(output.indexOf(" " + key)); - } - if (output.contains("\n" + key)) { - output = output.substring(0, output.indexOf("\n" + key)) + comments.get(key) + output.substring(output.indexOf("\n" + key)); + if (output.contains(key)) { + output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key)); } } }