mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Added hidden.yml option for using potion-based buffs instead of
enchantment-based buffs.
This commit is contained in:
parent
6f96a5026b
commit
f6b38ab32a
@ -85,7 +85,7 @@ Version 1.4.00-dev
|
|||||||
! Changed BeastLore: Now also displays offline player names
|
! Changed BeastLore: Now also displays offline player names
|
||||||
! Changed backup task to include ALL config files
|
! 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
|
! 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.
|
! 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 Party "master/apprentice" system. Replaced with the new party XP share feature.
|
||||||
- Removed unused "healthbar" files from the resources
|
- Removed unused "healthbar" files from the resources
|
||||||
|
@ -10,6 +10,7 @@ public class HiddenConfig {
|
|||||||
private static YamlConfiguration config;
|
private static YamlConfiguration config;
|
||||||
private static boolean chunkletsEnabled;
|
private static boolean chunkletsEnabled;
|
||||||
private static int conversionRate;
|
private static int conversionRate;
|
||||||
|
private static boolean useEnchantmentBuffs;
|
||||||
|
|
||||||
public HiddenConfig(String fileName) {
|
public HiddenConfig(String fileName) {
|
||||||
HiddenConfig.fileName = fileName;
|
HiddenConfig.fileName = fileName;
|
||||||
@ -29,6 +30,7 @@ public class HiddenConfig {
|
|||||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||||
|
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,4 +41,8 @@ public class HiddenConfig {
|
|||||||
public int getConversionRate() {
|
public int getConversionRate() {
|
||||||
return conversionRate;
|
return conversionRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean useEnchantmentBuffs() {
|
||||||
|
return useEnchantmentBuffs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
@ -266,8 +267,15 @@ public class BlockListener implements Listener {
|
|||||||
if (BlockChecks.canActivateAbilities(block)) {
|
if (BlockChecks.canActivateAbilities(block)) {
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||||
SkillTools.removeAbilityBuff(heldItem);
|
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")) {
|
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && player.hasPermission("mcmmo.ability.herbalism.greenterra")) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.utilities;
|
package com.gmail.nossr50.skills.utilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,12 +12,15 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
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.SpoutManager;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@ -525,33 +529,67 @@ public class SkillTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleAbilitySpeedIncrease(Player player) {
|
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 ) {
|
if (heldItem == null || heldItem.getType() == Material.AIR ) {
|
||||||
return;
|
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);
|
if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) {
|
||||||
ItemMeta itemMeta = heldItem.getItemMeta();
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
List<String> itemLore = new ArrayList<String>();
|
if (effect.getType() == PotionEffectType.FAST_DIGGING) {
|
||||||
|
duration = effect.getDuration();
|
||||||
|
amplifier = effect.getAmplifier();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||||
itemLore = itemMeta.getLore();
|
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) {
|
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++) {
|
for (int i = 0; i < playerInventory.getContents().length; i++) {
|
||||||
ItemStack item = playerInventory.getItem(i);
|
ItemStack item = playerInventory.getItem(i);
|
||||||
playerInventory.setItem(i, removeAbilityBuff(item));
|
playerInventory.setItem(i, removeAbilityBuff(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.removePotionEffect(PotionEffectType.FAST_DIGGING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,4 +6,6 @@ Options:
|
|||||||
# true to use Chunklets metadata store system, false to disable
|
# true to use Chunklets metadata store system, false to disable
|
||||||
Chunklets: true
|
Chunklets: true
|
||||||
# Square root of the number of chunks to convert per tick.
|
# 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
|
Loading…
Reference in New Issue
Block a user