Added hidden.yml option for using potion-based buffs instead of

enchantment-based buffs.
This commit is contained in:
GJ 2013-02-16 14:36:46 -05:00
parent 6f96a5026b
commit f6b38ab32a
5 changed files with 76 additions and 22 deletions

View File

@ -85,7 +85,7 @@ Version 1.4.00-dev
! Changed BeastLore: Now also displays offline player names
! Changed backup task to include ALL config files
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak.
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff.
! Changed locales to fall back on English when translated strings cannot be found.
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
- Removed unused "healthbar" files from the resources

View File

@ -10,6 +10,7 @@ public class HiddenConfig {
private static YamlConfiguration config;
private static boolean chunkletsEnabled;
private static int conversionRate;
private static boolean useEnchantmentBuffs;
public HiddenConfig(String fileName) {
HiddenConfig.fileName = fileName;
@ -29,6 +30,7 @@ public class HiddenConfig {
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
}
}
@ -39,4 +41,8 @@ public class HiddenConfig {
public int getConversionRate() {
return conversionRate;
}
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
}

View File

@ -22,6 +22,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
@ -266,8 +267,15 @@ public class BlockListener implements Listener {
if (BlockChecks.canActivateAbilities(block)) {
ItemStack heldItem = player.getItemInHand();
if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
SkillTools.removeAbilityBuff(heldItem);
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
SkillTools.removeAbilityBuff(heldItem);
}
}
else {
if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.canBeSuperBroken(block)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.canBeGigaDrillBroken(block))) {
SkillTools.handleAbilitySpeedDecrease(player);
}
}
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && player.hasPermission("mcmmo.ability.herbalism.greenterra")) {

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills.utilities;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.Material;
@ -11,12 +12,15 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
@ -525,33 +529,67 @@ public class SkillTools {
}
public static void handleAbilitySpeedIncrease(Player player) {
ItemStack heldItem = player.getItemInHand();
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getItemInHand();
if (heldItem == null || heldItem.getType() == Material.AIR ) {
return;
if (heldItem == null || heldItem.getType() == Material.AIR ) {
return;
}
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
ItemMeta itemMeta = heldItem.getItemMeta();
List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore = itemMeta.getLore();
}
itemLore.add("mcMMO Ability Tool");
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
itemMeta.setLore(itemLore);
heldItem.setItemMeta(itemMeta);
}
else {
int duration = 0;
int amplifier = 0;
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
ItemMeta itemMeta = heldItem.getItemMeta();
List<String> itemLore = new ArrayList<String>();
if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) {
for (PotionEffect effect : player.getActivePotionEffects()) {
if (effect.getType() == PotionEffectType.FAST_DIGGING) {
duration = effect.getDuration();
amplifier = effect.getAmplifier();
break;
}
}
}
if (itemMeta.hasLore()) {
itemLore = itemMeta.getLore();
PlayerProfile profile = Users.getPlayer(player).getProfile();
int ticks = 0;
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
}
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
}
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
player.addPotionEffect(abilityBuff, true);
}
itemLore.add("mcMMO Ability Tool");
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
itemMeta.setLore(itemLore);
heldItem.setItemMeta(itemMeta);
}
public static void handleAbilitySpeedDecrease(Player player) {
PlayerInventory playerInventory = player.getInventory();
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
PlayerInventory playerInventory = player.getInventory();
for (int i = 0; i < playerInventory.getContents().length; i++) {
ItemStack item = playerInventory.getItem(i);
playerInventory.setItem(i, removeAbilityBuff(item));
for (int i = 0; i < playerInventory.getContents().length; i++) {
ItemStack item = playerInventory.getItem(i);
playerInventory.setItem(i, removeAbilityBuff(item));
}
}
else {
player.removePotionEffect(PotionEffectType.FAST_DIGGING);
}
}

View File

@ -6,4 +6,6 @@ Options:
# true to use Chunklets metadata store system, false to disable
Chunklets: true
# Square root of the number of chunks to convert per tick.
ConversionRate: 1
ConversionRate: 1
# true to use enchantment buffs for Super Breaker & Giga Drill Breaker, false to use potion buffs
EnchantmentBuffs: true