mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 04:55:28 +02:00
Merge master into endgame branch to prepare merge for beta 2.2.000 update
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public final class Acrobatics {
|
||||
public static double dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
|
||||
public static double dodgeDamageModifier = mcMMO.p.getAdvancedConfig().getDodgeDamageModifier();
|
||||
public static int dodgeXpModifier = ExperienceConfig.getInstance().getDodgeXPModifier();
|
||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||
public static boolean dodgeLightningDisabled = mcMMO.p.getGeneralConfig().getDodgeLightningDisabled();
|
||||
|
||||
private Acrobatics() {}
|
||||
|
||||
|
@@ -8,7 +8,9 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.MobDodgeMetaCleanup;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@@ -18,6 +20,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
@@ -62,6 +65,9 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canDodge(Entity damager) {
|
||||
if(getPlayer().isBlocking())
|
||||
return false;
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
|
||||
return false;
|
||||
|
||||
@@ -70,7 +76,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
return skill.shouldProcess(damager);
|
||||
return mcMMO.p.getSkillTools().canCombatSkillsTrigger(skill, damager);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -95,20 +101,21 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if(!(attacker instanceof Player)) {
|
||||
if(attacker instanceof Mob mob) {
|
||||
//Check to see how many dodge XP rewards this mob has handed out
|
||||
if(attacker.hasMetadata(mcMMO.DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
if(mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
//If Dodge XP has been handed out 5 times then consider it being exploited
|
||||
MetadataValue metadataValue = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0);
|
||||
int count = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0).asInt();
|
||||
MetadataValue metadataValue = mob.getMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0);
|
||||
int count = metadataValue.asInt();
|
||||
|
||||
if(count <= 5) {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
|
||||
metaCleanupTask.runTaskTimer(mcMMO.p, 20, 20*60); //one minute
|
||||
}
|
||||
} else {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
package com.gmail.nossr50.skills.alchemy;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -43,16 +40,15 @@ public final class Alchemy {
|
||||
}
|
||||
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getConcoctionsTierLevel(this);
|
||||
return mcMMO.p.getAdvancedConfig().getConcoctionsTierLevel(this);
|
||||
}
|
||||
}*/
|
||||
|
||||
public static final int INGREDIENT_SLOT = 3;
|
||||
|
||||
public static int catalysisUnlockLevel = RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS);
|
||||
public static int catalysisMaxBonusLevel = AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
|
||||
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
|
||||
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
|
||||
public static int catalysisMaxBonusLevel = mcMMO.p.getAdvancedConfig().getCatalysisMaxBonusLevel();
|
||||
public static double catalysisMinSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMinSpeed();
|
||||
public static double catalysisMaxSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMaxSpeed();
|
||||
|
||||
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<>();
|
||||
|
||||
|
@@ -45,11 +45,11 @@ public class AlchemyManager extends SkillManager {
|
||||
public double calculateBrewSpeed(boolean isLucky) {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
if (skillLevel < Alchemy.catalysisUnlockLevel) {
|
||||
if (skillLevel < RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS)) {
|
||||
return Alchemy.catalysisMinSpeed;
|
||||
}
|
||||
|
||||
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
||||
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS)) / (Alchemy.catalysisMaxBonusLevel - RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS))) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
||||
}
|
||||
|
||||
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
|
||||
|
@@ -22,6 +22,7 @@ import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class AlchemyPotionBrewer {
|
||||
@@ -113,8 +114,8 @@ public final class AlchemyPotionBrewer {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AlchemyPotion> inputList = new ArrayList<>();
|
||||
ItemStack[] outputList = new ItemStack[3];
|
||||
List<AlchemyPotion> inputList = new ArrayList<>(Collections.nCopies(3, null));
|
||||
List<ItemStack> outputList = new ArrayList<>(Collections.nCopies(3, null));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
@@ -126,14 +127,14 @@ public final class AlchemyPotionBrewer {
|
||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
|
||||
AlchemyPotion output = input.getChild(ingredient);
|
||||
|
||||
inputList.add(input);
|
||||
inputList.set(i, input);
|
||||
|
||||
if (output != null) {
|
||||
outputList[i] = output.toItemStack(item.getAmount()).clone();
|
||||
outputList.set(i, output.toItemStack(item.getAmount()).clone());
|
||||
}
|
||||
}
|
||||
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel());
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, outputList, ((BrewingStand) brewingStand).getFuelLevel());
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled() || inputList.isEmpty()) {
|
||||
@@ -141,14 +142,16 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(outputList[i] != null) {
|
||||
inventory.setItem(i, outputList[i]);
|
||||
if(outputList.get(i) != null) {
|
||||
inventory.setItem(i, outputList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
removeIngredient(inventory, player);
|
||||
|
||||
for (AlchemyPotion input : inputList) {
|
||||
if (input == null) continue;
|
||||
|
||||
AlchemyPotion output = input.getChild(ingredient);
|
||||
|
||||
if (output != null && player != null) {
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.Material;
|
||||
@@ -19,9 +19,9 @@ import java.util.List;
|
||||
public class Archery {
|
||||
private static final List<TrackedEntity> trackedEntities = new ArrayList<>();
|
||||
|
||||
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
|
||||
public static double skillShotMaxBonusDamage = mcMMO.p.getAdvancedConfig().getSkillShotDamageMax();
|
||||
|
||||
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
||||
public static double dazeBonusDamage = mcMMO.p.getAdvancedConfig().getDazeBonusDamage();
|
||||
|
||||
public static final double DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Archery {
|
||||
TrackedEntity trackedEntity = entityIterator.next();
|
||||
|
||||
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
|
||||
Misc.spawnItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount(), ItemSpawnReason.ARROW_RETRIEVAL_ACTIVATED);
|
||||
Misc.spawnItems(null, livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount(), ItemSpawnReason.ARROW_RETRIEVAL_ACTIVATED);
|
||||
entityIterator.remove();
|
||||
return;
|
||||
}
|
||||
@@ -72,6 +72,6 @@ public class Archery {
|
||||
}
|
||||
|
||||
public static double getDamageBonusPercent(Player player) {
|
||||
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * (AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier()) / 100.0D);
|
||||
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * (mcMMO.p.getAdvancedConfig().getSkillShotRankDamageMultiplier()) / 100.0D);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@@ -53,10 +54,10 @@ public class ArcheryManager extends SkillManager {
|
||||
*/
|
||||
public double distanceXpBonusMultiplier(LivingEntity target, Entity arrow) {
|
||||
//Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
|
||||
if(!arrow.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
if(!arrow.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
return 1;
|
||||
|
||||
Location firedLocation = (Location) arrow.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
||||
Location firedLocation = (Location) arrow.getMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE).get(0).value();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
if(firedLocation == null || firedLocation.getWorld() == null)
|
||||
@@ -75,9 +76,9 @@ public class ArcheryManager extends SkillManager {
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
*/
|
||||
public void retrieveArrows(LivingEntity target, Projectile projectile) {
|
||||
if(projectile.hasMetadata(mcMMO.trackedArrow)) {
|
||||
if(projectile.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
Archery.incrementTrackerValue(target);
|
||||
projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile
|
||||
projectile.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p); //Only 1 entity per projectile
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -9,18 +9,18 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Axes {
|
||||
public static double axeMasteryRankDamageMultiplier = AdvancedConfig.getInstance().getAxeMasteryRankDamageMultiplier();
|
||||
public static double axeMasteryRankDamageMultiplier = mcMMO.p.getAdvancedConfig().getAxeMasteryRankDamageMultiplier();
|
||||
|
||||
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalStrikesPVPModifier();
|
||||
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalStrikesPVEModifier();
|
||||
public static double criticalHitPVPModifier = mcMMO.p.getAdvancedConfig().getCriticalStrikesPVPModifier();
|
||||
public static double criticalHitPVEModifier = mcMMO.p.getAdvancedConfig().getCriticalStrikesPVEModifier();
|
||||
|
||||
public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
|
||||
public static double impactChance = mcMMO.p.getAdvancedConfig().getImpactChance();
|
||||
|
||||
public static double greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
|
||||
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
|
||||
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
|
||||
public static double greaterImpactBonusDamage = mcMMO.p.getAdvancedConfig().getGreaterImpactBonusDamage();
|
||||
public static double greaterImpactChance = mcMMO.p.getAdvancedConfig().getGreaterImpactChance();
|
||||
public static double greaterImpactKnockbackMultiplier = mcMMO.p.getAdvancedConfig().getGreaterImpactModifier();
|
||||
|
||||
public static double skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
|
||||
public static double skullSplitterModifier = mcMMO.p.getAdvancedConfig().getSkullSplitterModifier();
|
||||
|
||||
protected static boolean hasArmor(LivingEntity target) {
|
||||
if(target == null || !target.isValid() || target.getEquipment() == null)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -17,12 +17,9 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AxesManager extends SkillManager {
|
||||
public AxesManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.AXES);
|
||||
@@ -95,8 +92,7 @@ public class AxesManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CriticalHit");
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck");
|
||||
@@ -122,14 +118,14 @@ public class AxesManager extends SkillManager {
|
||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||
if (armor != null && ItemUtils.isArmor(armor)) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) {
|
||||
SkillUtils.handleDurabilityChange(armor, durabilityDamage, 1);
|
||||
SkillUtils.handleArmorDurabilityChange(armor, durabilityDamage, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getImpactDurabilityDamage() {
|
||||
return AdvancedConfig.getInstance().getImpactDurabilityDamageMultiplier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT);
|
||||
return mcMMO.p.getAdvancedConfig().getImpactDurabilityDamageMultiplier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +148,7 @@ public class AxesManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Proc");
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck");
|
||||
@@ -165,11 +160,10 @@ public class AxesManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handle the effects of the Skull Splitter ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void skullSplitterCheck(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
|
||||
public void skullSplitterCheck(@NotNull LivingEntity target, double damage) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,15 @@
|
||||
package com.gmail.nossr50.skills.child;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
public class ChildConfig extends BukkitConfig {
|
||||
public ChildConfig() {
|
||||
super("child.yml");
|
||||
loadKeys();
|
||||
@@ -16,12 +17,12 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml")));
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader("child.yml")));
|
||||
|
||||
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
|
||||
|
||||
for (PrimarySkillType skill : PrimarySkillType.CHILD_SKILLS) {
|
||||
plugin.debug("Finding parents of " + skill.name());
|
||||
for (PrimarySkillType skill : mcMMO.p.getSkillTools().CHILD_SKILLS) {
|
||||
mcMMO.p.debug("Finding parents of " + skill.name());
|
||||
|
||||
EnumSet<PrimarySkillType> parentSkills = EnumSet.noneOf(PrimarySkillType.class);
|
||||
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||
@@ -33,7 +34,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
parentSkills.add(parentSkill);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||
mcMMO.p.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||
useDefaults = true;
|
||||
break;
|
||||
}
|
||||
@@ -52,7 +53,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
// Register them
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||
mcMMO.p.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||
FamilyTree.registerParent(skill, parentSkill);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.skills.child;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
@@ -40,13 +41,13 @@ public class FamilyTree {
|
||||
}
|
||||
|
||||
protected static void enforceChildSkill(PrimarySkillType skill) {
|
||||
if (!skill.isChildSkill()) {
|
||||
if (!SkillTools.isChildSkill(skill)) {
|
||||
throw new IllegalArgumentException(skill.name() + " is not a child skill!");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void enforceNotChildSkill(PrimarySkillType skill) {
|
||||
if (skill.isChildSkill()) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
throw new IllegalArgumentException(skill.name() + " is a child skill!");
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.gmail.nossr50.skills.excavation;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -48,7 +48,7 @@ public class ExcavationManager extends SkillManager {
|
||||
}
|
||||
|
||||
xp += treasure.getXp();
|
||||
Misc.spawnItem(location, treasure.getDrop(), ItemSpawnReason.EXCAVATION_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), location, treasure.getDrop(), ItemSpawnReason.EXCAVATION_TREASURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,6 @@ public class ExcavationManager extends SkillManager {
|
||||
excavationBlockCheck(blockState);
|
||||
excavationBlockCheck(blockState);
|
||||
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.p.getGeneralConfig().getAbilityToolDamage());
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
@@ -43,7 +41,6 @@ import java.util.*;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 100;
|
||||
public static final int OVERFISH_LIMIT = 10;
|
||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||
|
||||
private long fishingRodCastTimestamp = 0L;
|
||||
@@ -104,10 +101,10 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
public void setFishHookReference(FishHook fishHook)
|
||||
{
|
||||
if(fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
|
||||
if(fishHook.getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() > 0)
|
||||
return;
|
||||
|
||||
fishHook.setMetadata(mcMMO.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
|
||||
fishHook.setMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
this.fishHookReference = fishHook;
|
||||
fishHookSpawnTimestamp = System.currentTimeMillis();
|
||||
fishingRodCastTimestamp = System.currentTimeMillis();
|
||||
@@ -146,20 +143,21 @@ public class FishingManager extends SkillManager {
|
||||
else
|
||||
fishCaughtCounter = 1;
|
||||
|
||||
if(fishCaughtCounter + 1 == OVERFISH_LIMIT)
|
||||
if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
|
||||
{
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", 3));
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||
}
|
||||
|
||||
//If the new bounding box does not intersect with the old one, then update our bounding box reference
|
||||
if(!sameTarget)
|
||||
lastFishingBoundingBox = newCastBoundingBox;
|
||||
|
||||
return sameTarget && fishCaughtCounter >= OVERFISH_LIMIT;
|
||||
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
|
||||
}
|
||||
|
||||
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
||||
return BoundingBox.of(centerOfCastVector, 1, 1, 1);
|
||||
int exploitingRange = ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange();
|
||||
return BoundingBox.of(centerOfCastVector, exploitingRange / 2, 1, exploitingRange / 2);
|
||||
}
|
||||
|
||||
public void setFishingTarget() {
|
||||
@@ -199,11 +197,11 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public double getShakeChance() {
|
||||
return AdvancedConfig.getInstance().getShakeChance(getLootTier());
|
||||
return mcMMO.p.getAdvancedConfig().getShakeChance(RankUtils.getRank(mmoPlayer.getPlayer(), SubSkillType.FISHING_SHAKE));
|
||||
}
|
||||
|
||||
protected int getVanillaXPBoostModifier() {
|
||||
return AdvancedConfig.getInstance().getFishingVanillaXPModifier(getLootTier());
|
||||
return mcMMO.p.getAdvancedConfig().getFishingVanillaXPModifier(getLootTier());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,8 +272,8 @@ public class FishingManager extends SkillManager {
|
||||
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus, convertedLureBonus);
|
||||
|
||||
//Ticks for minWait and maxWait never go below this value
|
||||
int bonusCapMin = AdvancedConfig.getInstance().getFishingReductionMinWaitCap();
|
||||
int bonusCapMax = AdvancedConfig.getInstance().getFishingReductionMaxWaitCap();
|
||||
int bonusCapMin = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitCap();
|
||||
int bonusCapMax = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitCap();
|
||||
|
||||
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, bonusCapMin);
|
||||
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, bonusCapMax);
|
||||
@@ -338,7 +336,7 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public int getMasterAnglerTickMaxWaitReduction(int masterAnglerRank, boolean boatBonus, int emulatedLureBonus) {
|
||||
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMaxWaitTicks() * masterAnglerRank;
|
||||
int totalBonus = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitTicks() * masterAnglerRank;
|
||||
|
||||
if(boatBonus) {
|
||||
totalBonus += getFishingBoatMaxWaitReduction();
|
||||
@@ -350,7 +348,7 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public int getMasterAnglerTickMinWaitReduction(int masterAnglerRank, boolean boatBonus) {
|
||||
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMinWaitTicks() * masterAnglerRank;
|
||||
int totalBonus = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitTicks() * masterAnglerRank;
|
||||
|
||||
if(boatBonus) {
|
||||
totalBonus += getFishingBoatMinWaitReduction();
|
||||
@@ -360,11 +358,11 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public int getFishingBoatMinWaitReduction() {
|
||||
return AdvancedConfig.getInstance().getFishingBoatReductionMinWaitTicks();
|
||||
return mcMMO.p.getAdvancedConfig().getFishingBoatReductionMinWaitTicks();
|
||||
}
|
||||
|
||||
public int getFishingBoatMaxWaitReduction() {
|
||||
return AdvancedConfig.getInstance().getFishingBoatReductionMaxWaitTicks();
|
||||
return mcMMO.p.getAdvancedConfig().getFishingBoatReductionMaxWaitTicks();
|
||||
}
|
||||
|
||||
public boolean isMagicHunterEnabled() {
|
||||
@@ -387,7 +385,7 @@ public class FishingManager extends SkillManager {
|
||||
FishingTreasure treasure = null;
|
||||
boolean fishingSucceeds = false;
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
|
||||
if (mcMMO.p.getGeneralConfig().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
|
||||
treasure = getFishingTreasure();
|
||||
this.fishingCatch = null;
|
||||
}
|
||||
@@ -448,8 +446,8 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
if(fishingSucceeds) {
|
||||
if (Config.getInstance().getFishingExtraFish()) {
|
||||
Misc.spawnItem(player.getEyeLocation(), fishingCatch.getItemStack(), ItemSpawnReason.FISHING_EXTRA_FISH);
|
||||
if (mcMMO.p.getGeneralConfig().getFishingExtraFish()) {
|
||||
Misc.spawnItem(getPlayer(), player.getEyeLocation(), fishingCatch.getItemStack(), ItemSpawnReason.FISHING_EXTRA_FISH);
|
||||
}
|
||||
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
@@ -556,7 +554,7 @@ public class FishingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
Misc.spawnItem(target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
|
||||
CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times.
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
|
||||
}
|
||||
@@ -580,7 +578,7 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck.
|
||||
diceRoll *= (1.0 - luck * Config.getInstance().getFishingLureModifier() / 100);
|
||||
diceRoll *= (1.0 - luck * mcMMO.p.getGeneralConfig().getFishingLureModifier() / 100);
|
||||
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
|
@@ -8,8 +8,8 @@ public class Herbalism {
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState
|
||||
* The {@link BlockState} to check ability activation for
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
@@ -22,16 +22,16 @@ public class Herbalism {
|
||||
blockState.setType(Material.MOSSY_STONE_BRICKS);
|
||||
return true;
|
||||
|
||||
case DIRT :
|
||||
case GRASS_PATH :
|
||||
case DIRT:
|
||||
case DIRT_PATH:
|
||||
blockState.setType(Material.GRASS_BLOCK);
|
||||
return true;
|
||||
|
||||
case COBBLESTONE :
|
||||
case COBBLESTONE:
|
||||
blockState.setType(Material.MOSSY_COBBLESTONE);
|
||||
return true;
|
||||
|
||||
default :
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -39,19 +39,19 @@ public class Herbalism {
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState
|
||||
* The {@link BlockState} to check ability activation for
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case DIRT :
|
||||
case DIRT:
|
||||
case GRASS_BLOCK:
|
||||
case GRASS_PATH :
|
||||
case DIRT_PATH:
|
||||
blockState.setType(Material.MYCELIUM);
|
||||
return true;
|
||||
|
||||
default :
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.BlockSnapshot;
|
||||
@@ -37,6 +36,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -59,6 +60,10 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canUseShroomThumb(BlockState blockState) {
|
||||
if(!BlockUtils.canMakeShroomy(blockState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
|
||||
return false;
|
||||
|
||||
@@ -66,9 +71,75 @@ public class HerbalismManager extends SkillManager {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
Material itemType = inventory.getItemInMainHand().getType();
|
||||
|
||||
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
return (itemType == Material.BROWN_MUSHROOM
|
||||
|| itemType == Material.RED_MUSHROOM)
|
||||
&& inventory.contains(Material.BROWN_MUSHROOM, 1)
|
||||
&& inventory.contains(Material.RED_MUSHROOM, 1)
|
||||
&& Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
}
|
||||
|
||||
public void processBerryBushHarvesting(@NotNull BlockState blockState) {
|
||||
/* Check if the player is harvesting a berry bush */
|
||||
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Processing sweet berry bush rewards");
|
||||
}
|
||||
//Check the age
|
||||
if(blockState.getBlockData() instanceof Ageable ageable) {
|
||||
int rewardByAge = 0;
|
||||
|
||||
if(ageable.getAge() == 2) {
|
||||
rewardByAge = 1; //Normal XP
|
||||
} else if(ageable.getAge() == 3) {
|
||||
rewardByAge = 2; //Double XP
|
||||
} else {
|
||||
return; //Not old enough, back out of processing
|
||||
}
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Bush Reward Multiplier: " + rewardByAge);
|
||||
}
|
||||
|
||||
int xpReward = ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, blockState) * rewardByAge;
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Bush XP: " + xpReward);
|
||||
}
|
||||
|
||||
CheckBushAge checkBushAge = new CheckBushAge(blockState.getBlock(), mmoPlayer, xpReward);
|
||||
checkBushAge.runTaskLater(mcMMO.p, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CheckBushAge extends BukkitRunnable {
|
||||
|
||||
@NotNull Block block;
|
||||
@NotNull McMMOPlayer mmoPlayer;
|
||||
int xpReward;
|
||||
|
||||
public CheckBushAge(@NotNull Block block, @NotNull McMMOPlayer mmoPlayer, int xpReward) {
|
||||
this.block = block;
|
||||
this.mmoPlayer = mmoPlayer;
|
||||
this.xpReward = xpReward;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
|
||||
if(blockState.getBlockData() instanceof Ageable ageable) {
|
||||
|
||||
if(ageable.getAge() <= 1) {
|
||||
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean canUseHylianLuck() {
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
|
||||
return false;
|
||||
@@ -132,18 +203,21 @@ public class HerbalismManager extends SkillManager {
|
||||
public void processHerbalismBlockBreakEvent(BlockBreakEvent blockBreakEvent) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (Config.getInstance().getHerbalismPreventAFK() && player.isInsideVehicle()) {
|
||||
Block block = blockBreakEvent.getBlock();
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getHerbalismPreventAFK() && player.isInsideVehicle()) {
|
||||
if(block.hasMetadata(MetadataConstants.METADATA_KEY_REPLANT)) {
|
||||
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the plant was recently replanted
|
||||
if(blockBreakEvent.getBlock().getBlockData() instanceof Ageable) {
|
||||
Ageable ageableCrop = (Ageable) blockBreakEvent.getBlock().getBlockData();
|
||||
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).size() >= 1) {
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).get(0).asBoolean()) {
|
||||
if(block.getBlockData() instanceof Ageable ageableCrop) {
|
||||
if(block.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).size() >= 1) {
|
||||
if(block.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).get(0).asBoolean()) {
|
||||
if(isAgeableMature(ageableCrop)) {
|
||||
blockBreakEvent.getBlock().removeMetadata(mcMMO.REPLANT_META_KEY, mcMMO.p);
|
||||
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
} else {
|
||||
//Crop is recently replanted to back out of destroying it
|
||||
blockBreakEvent.setCancelled(true);
|
||||
@@ -174,28 +248,21 @@ public class HerbalismManager extends SkillManager {
|
||||
* @param brokenPlants plant blocks to process
|
||||
*/
|
||||
private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, HashSet<Block> brokenPlants) {
|
||||
if(blockBreakEvent.isCancelled())
|
||||
return;
|
||||
|
||||
BlockState originalBreak = blockBreakEvent.getBlock().getState();
|
||||
boolean greenThumbActivated = false;
|
||||
|
||||
//TODO: The design of Green Terra needs to change, this is a mess
|
||||
if(Permissions.greenThumbPlant(getPlayer(), originalBreak.getType())) {
|
||||
if(Config.getInstance().isGreenThumbReplantableCrop(originalBreak.getType())) {
|
||||
if(mcMMO.p.getGeneralConfig().isGreenThumbReplantableCrop(originalBreak.getType())) {
|
||||
if(!getPlayer().isSneaking()) {
|
||||
greenThumbActivated = processGreenThumbPlants(originalBreak, blockBreakEvent, isGreenTerraActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//When replanting a immature crop we cancel the block break event and back out
|
||||
if(greenThumbActivated) {
|
||||
if(originalBreak.getBlock().getBlockData() instanceof Ageable) {
|
||||
Ageable ageableCrop = (Ageable) originalBreak.getBlock().getBlockData();
|
||||
if(!isAgeableMature(ageableCrop)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark blocks for double drops
|
||||
* Be aware of the hacky interactions we are doing with Chorus Plants
|
||||
@@ -244,7 +311,7 @@ public class HerbalismManager extends SkillManager {
|
||||
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mmoPlayer, delayedChorusBlocks);
|
||||
|
||||
//Large delay because the tree takes a while to break
|
||||
delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 20); //Calculate Chorus XP + Bonus Drops 1 tick later
|
||||
delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 0); //Calculate Chorus XP + Bonus Drops 1 tick later
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +345,7 @@ public class HerbalismManager extends SkillManager {
|
||||
*/
|
||||
|
||||
//Not all things that are natural should give double drops, make sure its fully mature as well
|
||||
if(plantData instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) plantData;
|
||||
if(plantData instanceof Ageable ageable) {
|
||||
|
||||
if(isAgeableMature(ageable) || isBizarreAgeable(plantData)) {
|
||||
if(checkDoubleDrop(brokenPlantState)) {
|
||||
@@ -317,6 +383,7 @@ public class HerbalismManager extends SkillManager {
|
||||
//Catcus and Sugar Canes cannot be trusted
|
||||
switch(blockData.getMaterial()) {
|
||||
case CACTUS:
|
||||
case KELP:
|
||||
case SUGAR_CANE:
|
||||
return true;
|
||||
default:
|
||||
@@ -373,8 +440,7 @@ public class HerbalismManager extends SkillManager {
|
||||
*/
|
||||
|
||||
//Calculate XP
|
||||
if(plantData instanceof Ageable) {
|
||||
Ageable plantAgeable = (Ageable) plantData;
|
||||
if(plantData instanceof Ageable plantAgeable) {
|
||||
|
||||
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
|
||||
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenBlockNewState.getType());
|
||||
@@ -417,8 +483,8 @@ public class HerbalismManager extends SkillManager {
|
||||
BlockState brokenBlockNewState = blockSnapshot.getBlockRef().getState();
|
||||
|
||||
//Remove metadata from the snapshot of blocks
|
||||
if(brokenBlockNewState.hasMetadata(mcMMO.BONUS_DROPS_METAKEY)) {
|
||||
brokenBlockNewState.removeMetadata(mcMMO.BONUS_DROPS_METAKEY, mcMMO.p);
|
||||
if(brokenBlockNewState.hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS)) {
|
||||
brokenBlockNewState.removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, mcMMO.p);
|
||||
}
|
||||
|
||||
//If the block is not AIR that means it wasn't broken
|
||||
@@ -453,21 +519,18 @@ public class HerbalismManager extends SkillManager {
|
||||
* @param blockBreakEvent target event
|
||||
* @return a set of plant-blocks that were broken as a result of this event
|
||||
*/
|
||||
private HashSet<Block> getBrokenHerbalismBlocks(BlockBreakEvent blockBreakEvent) {
|
||||
private HashSet<Block> getBrokenHerbalismBlocks(@NotNull BlockBreakEvent blockBreakEvent) {
|
||||
//Get an updated capture of this block
|
||||
BlockState originalBlockBlockState = blockBreakEvent.getBlock().getState();
|
||||
Material originalBlockMaterial = originalBlockBlockState.getType();
|
||||
BlockState originBlockState = blockBreakEvent.getBlock().getState();
|
||||
Material originBlockMaterial = originBlockState.getType();
|
||||
HashSet<Block> blocksBroken = new HashSet<>(); //Blocks broken
|
||||
|
||||
//Check if this block is a one block plant or not
|
||||
boolean oneBlockPlant = isOneBlockPlant(originalBlockMaterial);
|
||||
//Add the initial block
|
||||
blocksBroken.add(originBlockState.getBlock());
|
||||
|
||||
if(oneBlockPlant) {
|
||||
//If the block is a one-block plant return only that
|
||||
blocksBroken.add(originalBlockBlockState.getBlock());
|
||||
} else {
|
||||
if(!isOneBlockPlant(originBlockMaterial)) {
|
||||
//If the block is a multi-block structure, capture a set of all blocks broken and return that
|
||||
blocksBroken = getBrokenBlocksMultiBlockPlants(originalBlockBlockState, blockBreakEvent);
|
||||
blocksBroken = getBrokenBlocksMultiBlockPlants(originBlockState);
|
||||
}
|
||||
|
||||
//Return all broken plant-blocks
|
||||
@@ -503,17 +566,16 @@ public class HerbalismManager extends SkillManager {
|
||||
* The method to grab these blocks is a bit hacky and does not hook into the API
|
||||
* Basically we expect the blocks to be broken if this event is not cancelled and we determine which block are broken on our end rather than any event state captures
|
||||
*
|
||||
* @param blockBreakEvent target event
|
||||
* @return a set of plant-blocks broken from this event
|
||||
*/
|
||||
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState originalBlockBroken, BlockBreakEvent blockBreakEvent) {
|
||||
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState brokenBlock) {
|
||||
//Track the broken blocks
|
||||
HashSet<Block> brokenBlocks;
|
||||
|
||||
if (isChorusBranch(originalBlockBroken.getType())) {
|
||||
brokenBlocks = getBrokenChorusBlocks(originalBlockBroken);
|
||||
if (isChorusBranch(brokenBlock.getType())) {
|
||||
brokenBlocks = getBrokenChorusBlocks(brokenBlock);
|
||||
} else {
|
||||
brokenBlocks = getBlocksBrokenAbove(originalBlockBroken);
|
||||
brokenBlocks = getBlocksBrokenAboveOrBelow(brokenBlock, false, mcMMO.getMaterialMapStore().isMultiBlockHangingPlant(brokenBlock.getType()));
|
||||
}
|
||||
|
||||
return brokenBlocks;
|
||||
@@ -533,29 +595,34 @@ public class HerbalismManager extends SkillManager {
|
||||
* The vertical search returns early if it runs into anything that is not a multi-block plant
|
||||
* Multi-block plants are hard-coded and kept in {@link MaterialMapStore}
|
||||
*
|
||||
* @param breakPointBlockState The point of the "break"
|
||||
* @param originBlock The point of the "break"
|
||||
* @param inclusive Whether to include the origin block
|
||||
* @param below Whether to search down instead of up.
|
||||
* @return A set of blocks above the target block which can be assumed to be broken
|
||||
*/
|
||||
private HashSet<Block> getBlocksBrokenAbove(BlockState breakPointBlockState) {
|
||||
private HashSet<Block> getBlocksBrokenAboveOrBelow(BlockState originBlock, boolean inclusive, boolean below) {
|
||||
HashSet<Block> brokenBlocks = new HashSet<>();
|
||||
Block block = breakPointBlockState.getBlock();
|
||||
Block block = originBlock.getBlock();
|
||||
|
||||
//Add the initial block to the set
|
||||
brokenBlocks.add(block);
|
||||
if(inclusive)
|
||||
brokenBlocks.add(block);
|
||||
|
||||
//Limit our search
|
||||
int maxHeight = 255;
|
||||
int maxHeight = 512;
|
||||
|
||||
final BlockFace relativeFace = below ? BlockFace.DOWN : BlockFace.UP;
|
||||
|
||||
// Search vertically for multi-block plants, exit early if any non-multi block plants
|
||||
for (int y = 1; y < maxHeight; y++) {
|
||||
for (int y = 0; y < maxHeight; y++) {
|
||||
//TODO: Should this grab state? It would be more expensive..
|
||||
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
|
||||
Block relativeBlock = block.getRelative(relativeFace, y);
|
||||
|
||||
//Abandon our search if the block isn't multi
|
||||
if(!mcMMO.getMaterialMapStore().isMultiBlockPlant(relativeUpBlock.getType()))
|
||||
if (isOneBlockPlant(relativeBlock.getType()))
|
||||
break;
|
||||
|
||||
brokenBlocks.add(relativeUpBlock);
|
||||
brokenBlocks.add(relativeBlock);
|
||||
}
|
||||
|
||||
return brokenBlocks;
|
||||
@@ -568,7 +635,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* @return true if the block is not contained in the collection of multi-block plants
|
||||
*/
|
||||
private boolean isOneBlockPlant(Material material) {
|
||||
return !mcMMO.getMaterialMapStore().isMultiBlockPlant(material);
|
||||
return !mcMMO.getMaterialMapStore().isMultiBlockPlant(material) && !mcMMO.getMaterialMapStore().isMultiBlockHangingPlant(material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -627,7 +694,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
blockState.setType(Material.AIR);
|
||||
Misc.spawnItem(location, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), location, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck");
|
||||
return true;
|
||||
}
|
||||
@@ -676,7 +743,7 @@ public class HerbalismManager extends SkillManager {
|
||||
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
|
||||
//Mark the plant as recently replanted to avoid accidental breakage
|
||||
new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
|
||||
blockBreakEvent.getBlock().setMetadata(mcMMO.REPLANT_META_KEY, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -693,12 +760,10 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
|
||||
if (!(blockData instanceof Ageable)) {
|
||||
if (!(blockData instanceof Ageable ageable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ageable ageable = (Ageable) blockData;
|
||||
|
||||
//If the ageable is NOT mature and the player is NOT using a hoe, abort
|
||||
|
||||
Player player = getPlayer();
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
|
||||
public class BlastMining {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@@ -33,7 +32,7 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getBlastMiningRankLevel(this);
|
||||
return mcMMO.p.getAdvancedConfig().getBlastMiningRankLevel(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +41,13 @@ public class BlastMining {
|
||||
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
||||
|
||||
public static double getBlastRadiusModifier(int rank) {
|
||||
return AdvancedConfig.getInstance().getBlastRadiusModifier(rank);
|
||||
return mcMMO.p.getAdvancedConfig().getBlastRadiusModifier(rank);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static double getBlastDamageDecrease(int rank) {
|
||||
return AdvancedConfig.getInstance().getBlastDamageDecrease(rank);
|
||||
return mcMMO.p.getAdvancedConfig().getBlastDamageDecrease(rank);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,12 +91,12 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
|
||||
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
if (!tnt.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!(player != null && player.equals(defender))) {
|
||||
return false;
|
||||
@@ -114,7 +113,7 @@ public class BlastMining {
|
||||
return false;
|
||||
}
|
||||
|
||||
event.setDamage(DamageModifier.BASE, miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
|
||||
if (event.getFinalDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
@@ -33,6 +31,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MiningManager extends SkillManager {
|
||||
|
||||
public static final String BUDDING_AMETHYST = "budding_amethyst";
|
||||
|
||||
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.MINING);
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class MiningManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
|
||||
return canUseBlastMining() && player.isSneaking()
|
||||
&& (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == Config.getInstance().getDetonatorItem())
|
||||
&& (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == mcMMO.p.getGeneralConfig().getDetonatorItem())
|
||||
&& Permissions.remoteDetonation(player);
|
||||
}
|
||||
|
||||
@@ -87,16 +88,16 @@ public class MiningManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mmoPlayer.getAbilityMode(skill.getAbility())) {
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||
if (mmoPlayer.getAbilityMode(mcMMO.p.getSkillTools().getSuperAbility(skill))) {
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.p.getGeneralConfig().getAbilityToolDamage());
|
||||
}
|
||||
|
||||
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType()) || !canDoubleDrop())
|
||||
if(!mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType()) || !canDoubleDrop())
|
||||
return;
|
||||
|
||||
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
|
||||
|
||||
if(silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled())
|
||||
if(silkTouch && !mcMMO.p.getAdvancedConfig().getDoubleDropSilkTouchEnabled())
|
||||
return;
|
||||
|
||||
//Mining mastery allows for a chance of triple drops
|
||||
@@ -147,13 +148,16 @@ public class MiningManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom");
|
||||
//player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
|
||||
tnt.setMetadata(mcMMO.tntMetadataKey, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setFuseTicks(0);
|
||||
if (mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 16, 4)) {
|
||||
tnt.setSource(player);
|
||||
}
|
||||
targetBlock.setType(Material.AIR);
|
||||
|
||||
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
|
||||
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,32 +167,11 @@ public class MiningManager extends SkillManager {
|
||||
* @param event The {@link EntityExplodeEvent}
|
||||
*/
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
|
||||
//Strip out only stuff that gives mining XP
|
||||
if (yield == 0)
|
||||
return;
|
||||
|
||||
//Strip out only stuff that gives mining XP
|
||||
List<BlockState> ores = new ArrayList<>();
|
||||
|
||||
List<BlockState> notOres = new ArrayList<>();
|
||||
@@ -209,28 +192,33 @@ public class MiningManager extends SkillManager {
|
||||
int xp = 0;
|
||||
|
||||
float oreBonus = (float) (getOreBonus() / 100);
|
||||
//TODO: Pretty sure something is fucked with debrisReduction stuff
|
||||
float debrisReduction = (float) (getDebrisReduction() / 100);
|
||||
int dropMultiplier = getDropMultiplier();
|
||||
float debrisYield = yield - debrisReduction;
|
||||
|
||||
//Drop "debris" based on skill modifiers
|
||||
for(BlockState blockState : notOres) {
|
||||
if(isDropIllegal(blockState.getType()))
|
||||
continue;
|
||||
|
||||
if(RandomUtils.nextFloat() < debrisYield) {
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockState blockState : ores) {
|
||||
if(isDropIllegal(blockState.getType()))
|
||||
continue;
|
||||
|
||||
if (RandomUtils.nextFloat() < (yield + oreBonus)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
// Bukkit.broadcastMessage("Bonus Drop on Ore: "+blockState.getType().toString());
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP); // Initial block that would have been dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,6 +232,17 @@ public class MiningManager extends SkillManager {
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if it would be illegal (in vanilla) to obtain the block
|
||||
* Certain things should never drop ( such as budding_amethyst )
|
||||
*
|
||||
* @param material target material
|
||||
* @return true if it's not legal to obtain the block through normal gameplay
|
||||
*/
|
||||
public boolean isDropIllegal(@NotNull Material material) {
|
||||
return material.getKey().getKey().equalsIgnoreCase(BUDDING_AMETHYST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the blast radius of the explosion.
|
||||
*
|
||||
@@ -277,11 +276,11 @@ public class MiningManager extends SkillManager {
|
||||
}
|
||||
|
||||
public static double getOreBonus(int rank) {
|
||||
return AdvancedConfig.getInstance().getOreBonus(rank);
|
||||
return mcMMO.p.getAdvancedConfig().getOreBonus(rank);
|
||||
}
|
||||
|
||||
public static double getDebrisReduction(int rank) {
|
||||
return AdvancedConfig.getInstance().getDebrisReduction(rank);
|
||||
return mcMMO.p.getAdvancedConfig().getDebrisReduction(rank);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +293,7 @@ public class MiningManager extends SkillManager {
|
||||
}
|
||||
|
||||
public static int getDropMultiplier(int rank) {
|
||||
return AdvancedConfig.getInstance().getDropMultiplier(rank);
|
||||
return mcMMO.p.getAdvancedConfig().getDropMultiplier(rank);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class ArcaneForging {
|
||||
|
||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
|
||||
public static boolean arcaneForgingDowngrades = mcMMO.p.getAdvancedConfig().getArcaneForgingDowngradeEnabled();
|
||||
public static boolean arcaneForgingEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneForgingEnchantLossEnabled();
|
||||
}
|
||||
|
@@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class Repair {
|
||||
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY);
|
||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||
public static int repairMasteryMaxBonusLevel = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY);
|
||||
public static double repairMasteryMaxBonus = mcMMO.p.getAdvancedConfig().getRepairMasteryMaxBonus();
|
||||
|
||||
public static Material anvilMaterial = Config.getInstance().getRepairAnvilMaterial();
|
||||
public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getRepairAnvilMaterial();
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
@@ -27,8 +25,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RepairManager extends SkillManager {
|
||||
private boolean placedAnvil;
|
||||
@@ -48,11 +49,11 @@ public class RepairManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getRepairAnvilMessagesEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getRepairAnvilMessagesEnabled()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Repair.Listener.Anvil");
|
||||
}
|
||||
|
||||
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getRepairAnvilPlaceSoundsEnabled()) {
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
|
||||
}
|
||||
|
||||
@@ -127,6 +128,35 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
// toRemove should be refreshed before the event call.
|
||||
toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
|
||||
|
||||
// Check if we allow enchanted materials to be used to repair objects.
|
||||
// (Servers may provide enchanted items that don't follow their intended use)
|
||||
if (!mcMMO.p.getAdvancedConfig().getAllowEnchantedRepairMaterials()) {
|
||||
|
||||
// See if our proposed item is even enchanted in the first place.
|
||||
if (toRemove.getEnchantments().size() > 0) {
|
||||
|
||||
// Lots of array sorting to find a potential non-enchanted candidate item.
|
||||
Optional<ItemStack> possibleMaterial = Arrays.stream(inventory.getContents())
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.getType() == repairMaterial)
|
||||
.filter(p -> p.getEnchantments().isEmpty())
|
||||
.findFirst();
|
||||
|
||||
// Fail out with "you need material" if we don't find a suitable alternative.
|
||||
if (possibleMaterial.isEmpty()) {
|
||||
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
|
||||
|
||||
String materialsNeeded = "";
|
||||
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Skills.NeedMore.Extra", prettyName, materialsNeeded);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update our toRemove item to our suggested possible material.
|
||||
toRemove = possibleMaterial.get().clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Call event
|
||||
if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
|
||||
@@ -150,7 +180,7 @@ public class RepairManager extends SkillManager {
|
||||
* ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE);
|
||||
|
||||
// BWONG BWONG BWONG
|
||||
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getRepairAnvilUseSoundsEnabled()) {
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
|
||||
}
|
||||
@@ -172,7 +202,7 @@ public class RepairManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
long lastUse = getLastAnvilUse();
|
||||
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.p.getGeneralConfig().getRepairConfirmRequired()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,7 +231,7 @@ public class RepairManager extends SkillManager {
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public double getKeepEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChance(getArcaneForgingRank());
|
||||
return mcMMO.p.getAdvancedConfig().getArcaneForgingKeepEnchantsChance(getArcaneForgingRank());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +240,7 @@ public class RepairManager extends SkillManager {
|
||||
* @return The chance of the enchantment being downgraded
|
||||
*/
|
||||
public double getDowngradeEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChance(getArcaneForgingRank());
|
||||
return mcMMO.p.getAdvancedConfig().getArcaneForgingDowngradeChance(getArcaneForgingRank());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public final class Salvage {
|
||||
@@ -12,15 +11,15 @@ public final class Salvage {
|
||||
*/
|
||||
private Salvage() {}
|
||||
|
||||
public static Material anvilMaterial = Config.getInstance().getSalvageAnvilMaterial();
|
||||
public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getSalvageAnvilMaterial();
|
||||
|
||||
/*public static int salvageMaxPercentageLevel = AdvancedConfig.getInstance().getSalvageMaxPercentageLevel();
|
||||
public static double salvageMaxPercentage = AdvancedConfig.getInstance().getSalvageMaxPercentage();
|
||||
/*public static int salvageMaxPercentageLevel = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentageLevel();
|
||||
public static double salvageMaxPercentage = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentage();
|
||||
|
||||
public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_SCRAP_COLLECTOR, 1);*/
|
||||
|
||||
public static boolean arcaneSalvageDowngrades = AdvancedConfig.getInstance().getArcaneSalvageEnchantDowngradeEnabled();
|
||||
public static boolean arcaneSalvageEnchantLoss = AdvancedConfig.getInstance().getArcaneSalvageEnchantLossEnabled();
|
||||
public static boolean arcaneSalvageDowngrades = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantDowngradeEnabled();
|
||||
public static boolean arcaneSalvageEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantLossEnabled();
|
||||
|
||||
static int calculateSalvageableAmount(int currentDurability, short maxDurability, int baseAmount) {
|
||||
double percentDamaged = (maxDurability <= 0) ? 1D : (double) (maxDurability - currentDurability) / maxDurability;
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@@ -51,11 +49,11 @@ public class SalvageManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageAnvilMessagesEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getSalvageAnvilMessagesEnabled()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Listener.Anvil");
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getSalvageAnvilPlaceSoundsEnabled()) {
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
|
||||
}
|
||||
|
||||
@@ -129,14 +127,6 @@ public class SalvageManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
}
|
||||
|
||||
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), lotteryResults);
|
||||
|
||||
//Call event
|
||||
@@ -144,6 +134,15 @@ public class SalvageManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// We only send a confirmation message after processing the event (fixes #4694)
|
||||
if (lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else if (salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
}
|
||||
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
||||
Location anvilLoc = location.clone();
|
||||
@@ -160,13 +159,13 @@ public class SalvageManager extends SkillManager {
|
||||
anvilLoc.add(0, .1, 0);
|
||||
|
||||
if (enchantBook != null) {
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed, ItemSpawnReason.SALVAGE_ENCHANTMENT_BOOK);
|
||||
Misc.spawnItemTowardsLocation(getPlayer(), anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed, ItemSpawnReason.SALVAGE_ENCHANTMENT_BOOK);
|
||||
}
|
||||
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed, ItemSpawnReason.SALVAGE_MATERIALS);
|
||||
Misc.spawnItemTowardsLocation(getPlayer(), anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed, ItemSpawnReason.SALVAGE_MATERIALS);
|
||||
|
||||
// BWONG BWONG BWONG - CLUNK!
|
||||
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getSalvageAnvilUseSoundsEnabled()) {
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
|
||||
}
|
||||
|
||||
@@ -218,11 +217,11 @@ public class SalvageManager extends SkillManager {
|
||||
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
|
||||
return 100.0D;
|
||||
|
||||
return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
|
||||
return mcMMO.p.getAdvancedConfig().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
|
||||
}
|
||||
|
||||
public double getExtractPartialEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneSalvageExtractPartialEnchantsChance(getArcaneSalvageRank());
|
||||
return mcMMO.p.getAdvancedConfig().getArcaneSalvageExtractPartialEnchantsChance(getArcaneSalvageRank());
|
||||
}
|
||||
|
||||
private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) {
|
||||
@@ -291,7 +290,7 @@ public class SalvageManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
long lastUse = getLastAnvilUse();
|
||||
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getSalvageConfirmRequired()) {
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.p.getGeneralConfig().getSalvageConfirmRequired()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -2,12 +2,13 @@ package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Smelting {
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType());
|
||||
public static int getSmeltXP(@NotNull ItemStack smelting) {
|
||||
return ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
@@ -22,97 +22,32 @@ public class SmeltingManager extends SkillManager {
|
||||
super(mcMMOPlayer, PrimarySkillType.SMELTING);
|
||||
}
|
||||
|
||||
/*public boolean canUseFluxMining(BlockState blockState) {
|
||||
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel
|
||||
&& BlockUtils.affectedByFluxMining(blockState)
|
||||
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_FLUX_MINING)
|
||||
&& !mcMMO.getPlaceStore().isTrue(blockState);
|
||||
}*/
|
||||
|
||||
public boolean isSecondSmeltSuccessful() {
|
||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT)
|
||||
&& SkillUtils.isSkillRNGSuccessful(SubSkillType.SMELTING_SECOND_SMELT, getPlayer());
|
||||
}
|
||||
|
||||
/*
|
||||
Process the Flux Mining ability.
|
||||
|
||||
@param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
/*public boolean processFluxMining(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.SMELTING_FLUX_MINING, true)) {
|
||||
ItemStack item = null;
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case IRON_ORE:
|
||||
item = new ItemStack(Material.IRON_INGOT);
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
item = new ItemStack(Material.GOLD_INGOT);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to distribute Mining XP here, because the block break event gets cancelled
|
||||
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE, XPGainSource.PASSIVE);
|
||||
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), item, isSecondSmeltSuccessful() ? 2 : 1);
|
||||
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
|
||||
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
||||
}
|
||||
|
||||
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Increases burn time for furnace fuel.
|
||||
*
|
||||
* @param burnTime The initial burn time from the {@link FurnaceBurnEvent}
|
||||
*/
|
||||
public int fuelEfficiency(int burnTime) {
|
||||
return burnTime * getFuelEfficiencyMultiplier();
|
||||
return Math.min(Short.MAX_VALUE, Math.max(1, burnTime * getFuelEfficiencyMultiplier()));
|
||||
}
|
||||
|
||||
public int getFuelEfficiencyMultiplier()
|
||||
{
|
||||
switch(RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY))
|
||||
{
|
||||
case 1:
|
||||
return 2;
|
||||
case 2:
|
||||
return 3;
|
||||
case 3:
|
||||
return 4;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return switch (RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
|
||||
case 1 -> 2;
|
||||
case 2 -> 3;
|
||||
case 3 -> 4;
|
||||
default -> 1;
|
||||
};
|
||||
}
|
||||
|
||||
public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull Furnace furnace) {
|
||||
applyXpGain(Smelting.getResourceXp(furnaceSmeltEvent.getSource()), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
applyXpGain(Smelting.getSmeltXP(furnaceSmeltEvent.getSource()), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
|
||||
processDoubleSmelt(furnaceSmeltEvent, furnace);
|
||||
}
|
||||
@@ -124,7 +59,7 @@ public class SmeltingManager extends SkillManager {
|
||||
*/
|
||||
|
||||
//Process double smelt
|
||||
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
|
||||
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
|
||||
&& canDoubleSmeltItemStack(furnace) //Effectively two less than max stack size
|
||||
&& isSecondSmeltSuccessful()) {
|
||||
|
||||
@@ -139,7 +74,7 @@ public class SmeltingManager extends SkillManager {
|
||||
ItemStack furnaceResult = furnaceInventory.getResult();
|
||||
|
||||
if(furnaceResult == null)
|
||||
return false;
|
||||
return true; //This actually means there is nothing yet in the resulting item slot, which means it should always be okay to double smelt
|
||||
|
||||
int resultAmount = furnaceResult.getAmount(); //Amount before double smelt
|
||||
int itemLimit = furnaceResult.getMaxStackSize();
|
||||
|
@@ -1,11 +1,9 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Swords {
|
||||
public static int bleedMaxTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();
|
||||
public static double counterAttackModifier = mcMMO.p.getAdvancedConfig().getCounterModifier();
|
||||
|
||||
public static double counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier();
|
||||
|
||||
public static double serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier();
|
||||
public static double serratedStrikesModifier = mcMMO.p.getAdvancedConfig().getSerratedStrikesModifier();
|
||||
}
|
||||
|
@@ -1,28 +1,29 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.meta.RuptureTaskMeta;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.RuptureTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SwordsManager extends SkillManager {
|
||||
public SwordsManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.SWORDS);
|
||||
@@ -59,32 +60,54 @@ public class SwordsManager extends SkillManager {
|
||||
*
|
||||
* @param target The defending entity
|
||||
*/
|
||||
public void ruptureCheck(@NotNull LivingEntity target) throws IllegalStateException {
|
||||
if(BleedTimerTask.isBleedOperationAllowed()) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.SWORDS_RUPTURE, getPlayer())) {
|
||||
public void processRupture(@NotNull LivingEntity target) {
|
||||
if(!canUseRupture())
|
||||
return;
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if(target.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
//Don't start or add to a bleed if they are blocking
|
||||
if(defender.isBlocking())
|
||||
return;
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Rupture task ongoing for target " + target.toString());
|
||||
mmoPlayer.getPlayer().sendMessage(ruptureTaskMeta.getRuptureTimerTask().toString());
|
||||
}
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
if(!BleedTimerTask.isBleeding(defender))
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started");
|
||||
}
|
||||
}
|
||||
ruptureTaskMeta.getRuptureTimerTask().refreshRupture();
|
||||
return; //Don't apply bleed
|
||||
}
|
||||
|
||||
BleedTimerTask.add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand()));
|
||||
if (RandomChanceUtil.rollDice(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
|
||||
|
||||
if (mmoPlayer.useChatNotifications()) {
|
||||
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
//Don't start or add to a bleed if they are blocking
|
||||
if(defender.isBlocking())
|
||||
return;
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started");
|
||||
}
|
||||
}
|
||||
|
||||
RuptureTask ruptureTask = new RuptureTask(mmoPlayer, target,
|
||||
mcMMO.p.getAdvancedConfig().getRuptureTickDamage(target instanceof Player, getRuptureRank()),
|
||||
mcMMO.p.getAdvancedConfig().getRuptureExplosionDamage(target instanceof Player, getRuptureRank()));
|
||||
|
||||
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
|
||||
|
||||
ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
|
||||
|
||||
// if (mmoPlayer.useChatNotifications()) {
|
||||
// NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private int getRuptureRank() {
|
||||
return RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);
|
||||
}
|
||||
|
||||
public double getStabDamage()
|
||||
{
|
||||
int rank = RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_STAB);
|
||||
@@ -111,16 +134,6 @@ public class SwordsManager extends SkillManager {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getRuptureBleedTicks()
|
||||
{
|
||||
int bleedTicks = 2 * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);
|
||||
|
||||
if(bleedTicks > Swords.bleedMaxTicks)
|
||||
bleedTicks = Swords.bleedMaxTicks;
|
||||
|
||||
return bleedTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Counter Attack ability
|
||||
*
|
||||
@@ -128,7 +141,7 @@ public class SwordsManager extends SkillManager {
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void counterAttackChecks(@NotNull LivingEntity attacker, double damage) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
|
||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
|
||||
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier, getPlayer());
|
||||
|
||||
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered");
|
||||
@@ -141,11 +154,10 @@ public class SwordsManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handle the effects of the Serrated Strikes ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void serratedStrikes(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, modifiers, skill);
|
||||
public void serratedStrikes(@NotNull LivingEntity target, double damage) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,20 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class Taming {
|
||||
public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance();
|
||||
public static double fastFoodServiceActivationChance = mcMMO.p.getAdvancedConfig().getFastFoodChance();
|
||||
|
||||
public static int goreBleedTicks = 2; //Equivalent to rank 1 in Rupture
|
||||
public static double goreModifier = AdvancedConfig.getInstance().getGoreModifier();
|
||||
public static double goreModifier = mcMMO.p.getAdvancedConfig().getGoreModifier();
|
||||
|
||||
public static double sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus();
|
||||
public static double sharpenedClawsBonusDamage = mcMMO.p.getAdvancedConfig().getSharpenedClawsBonus();
|
||||
|
||||
public static double shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier();
|
||||
public static double shockProofModifier = mcMMO.p.getAdvancedConfig().getShockProofModifier();
|
||||
|
||||
public static double thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
|
||||
public static double thickFurModifier = mcMMO.p.getAdvancedConfig().getThickFurModifier();
|
||||
|
||||
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
|
||||
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
@@ -12,11 +10,10 @@ import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
@@ -27,6 +24,7 @@ import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -62,9 +60,9 @@ public class TamingManager extends SkillManager {
|
||||
if(summoningItems == null) {
|
||||
summoningItems = new HashMap<>();
|
||||
|
||||
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry()), CallOfTheWildType.CAT);
|
||||
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry()), CallOfTheWildType.WOLF);
|
||||
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry()), CallOfTheWildType.HORSE);
|
||||
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry()), CallOfTheWildType.CAT);
|
||||
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry()), CallOfTheWildType.WOLF);
|
||||
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry()), CallOfTheWildType.HORSE);
|
||||
}
|
||||
|
||||
//TODO: Temporary static cache, will be changed in 2.2
|
||||
@@ -73,11 +71,11 @@ public class TamingManager extends SkillManager {
|
||||
cotwSummonDataProperties = new HashMap<>();
|
||||
|
||||
for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
|
||||
Material itemSummonMaterial = Config.getInstance().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int itemAmountRequired = Config.getInstance().getTamingCOTWCost(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int entitiesSummonedPerCOTW = Config.getInstance().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int summonLifespanSeconds = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int perPlayerMaxAmount = Config.getInstance().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
Material itemSummonMaterial = mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int itemAmountRequired = mcMMO.p.getGeneralConfig().getTamingCOTWCost(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int entitiesSummonedPerCOTW = mcMMO.p.getGeneralConfig().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int summonLifespanSeconds = mcMMO.p.getGeneralConfig().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int perPlayerMaxAmount = mcMMO.p.getGeneralConfig().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
|
||||
TamingSummon tamingSummon = new TamingSummon(callOfTheWildType, itemSummonMaterial, itemAmountRequired, entitiesSummonedPerCOTW, summonLifespanSeconds, perPlayerMaxAmount);
|
||||
cotwSummonDataProperties.put(callOfTheWildType, tamingSummon);
|
||||
@@ -165,21 +163,7 @@ public class TamingManager extends SkillManager {
|
||||
* @param damage The initial damage
|
||||
*/
|
||||
public double gore(@NotNull LivingEntity target, double damage) {
|
||||
if(BleedTimerTask.isBleedOperationAllowed()) {
|
||||
if (!SkillUtils.isSkillRNGSuccessful(SubSkillType.TAMING_GORE, getPlayer())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BleedTimerTask.add(target, getPlayer(), Taming.goreBleedTicks, 1, 2);
|
||||
|
||||
if (target instanceof Player) {
|
||||
NotificationManager.sendPlayerInformation((Player)target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
|
||||
}
|
||||
|
||||
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore");
|
||||
|
||||
damage = (damage * Taming.goreModifier) - damage;
|
||||
}
|
||||
damage = (damage * Taming.goreModifier) - damage;
|
||||
|
||||
return damage;
|
||||
}
|
||||
@@ -247,19 +231,23 @@ public class TamingManager extends SkillManager {
|
||||
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
|
||||
|
||||
if (beast instanceof Horse) {
|
||||
Horse horse = (Horse) beast;
|
||||
double jumpStrength = horse.getAttribute(Attribute.HORSE_JUMP_STRENGTH).getValue();
|
||||
// Taken from https://minecraft.gamepedia.com/Horse#Jump_strength
|
||||
jumpStrength = -0.1817584952 * Math.pow(jumpStrength, 3) + 3.689713992 * Math.pow(jumpStrength, 2) + 2.128599134 * jumpStrength - 0.343930367;
|
||||
message = message.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseSpeed", horse.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getValue() * 43))
|
||||
.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseJumpStrength", jumpStrength));
|
||||
// Bred mules & donkeys can actually have horse-like stats, but llamas cannot.
|
||||
if (beast instanceof AbstractHorse horseLikeCreature && !(beast instanceof Llama)) {
|
||||
AttributeInstance jumpAttribute = horseLikeCreature.getAttribute(Attribute.HORSE_JUMP_STRENGTH);
|
||||
|
||||
if(jumpAttribute != null) {
|
||||
double jumpStrength = jumpAttribute.getValue();
|
||||
// Taken from https://minecraft.gamepedia.com/Horse#Jump_strength
|
||||
jumpStrength = -0.1817584952 * Math.pow(jumpStrength, 3) + 3.689713992 * Math.pow(jumpStrength, 2) + 2.128599134 * jumpStrength - 0.343930367;
|
||||
message = message.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseSpeed", horseLikeCreature.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getValue() * 43))
|
||||
.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseJumpStrength", jumpStrength));
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
public void processEnvironmentallyAware(Wolf wolf, double damage) {
|
||||
public void processEnvironmentallyAware(@NotNull Wolf wolf, double damage) {
|
||||
if (damage > wolf.getHealth()) {
|
||||
return;
|
||||
}
|
||||
@@ -280,8 +268,7 @@ public class TamingManager extends SkillManager {
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D));
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage");
|
||||
@@ -290,9 +277,8 @@ public class TamingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void attackTarget(LivingEntity target) {
|
||||
if(target instanceof Tameable)
|
||||
if(target instanceof Tameable tameable)
|
||||
{
|
||||
Tameable tameable = (Tameable) target;
|
||||
if(tameable.getOwner() == getPlayer())
|
||||
{
|
||||
return;
|
||||
@@ -460,7 +446,7 @@ public class TamingManager extends SkillManager {
|
||||
callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth());
|
||||
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
|
||||
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
|
||||
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
|
||||
horse.setJumpStrength(Math.max(mcMMO.p.getAdvancedConfig().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, mcMMO.p.getAdvancedConfig().getMaxHorseJumpStrength())));
|
||||
horse.setAdult();
|
||||
|
||||
//TODO: setSpeed, once available
|
||||
@@ -478,7 +464,7 @@ public class TamingManager extends SkillManager {
|
||||
|
||||
private void applyMetaDataToCOTWEntity(LivingEntity summonedEntity) {
|
||||
//This helps identify the entity as being summoned by COTW
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity);
|
||||
mcMMO.getMetadataService().getMobMetadataService().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -19,7 +18,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
|
||||
this.callOfTheWildType = callOfTheWildType;
|
||||
this.livingEntity = livingEntity;
|
||||
|
||||
int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
int tamingCOTWLength = mcMMO.p.getGeneralConfig().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
|
||||
|
||||
if (tamingCOTWLength > 0) {
|
||||
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Unarmed {
|
||||
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
|
||||
public static boolean blockCrackerSmoothBrick = mcMMO.p.getGeneralConfig().getUnarmedBlockCrackerSmoothbrickToCracked();
|
||||
public static double berserkDamageModifier = 1.5;
|
||||
|
||||
public static void handleItemPickup(Player player, EntityPickupItemEvent event) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@@ -10,10 +9,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
@@ -110,10 +106,10 @@ public class UnarmedManager extends SkillManager {
|
||||
if(UserManager.getPlayer(defender) == null)
|
||||
return;
|
||||
|
||||
Item item = Misc.spawnItem(defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||
Item item = Misc.spawnItem(getPlayer(), defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||
|
||||
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
|
||||
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
|
||||
item.setMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
}
|
||||
|
||||
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
@@ -166,8 +162,8 @@ public class UnarmedManager extends SkillManager {
|
||||
double finalBonus = bonus + 0.5 + (rank / 2);
|
||||
|
||||
|
||||
if(AdvancedConfig.getInstance().isSteelArmDamageCustom()) {
|
||||
return AdvancedConfig.getInstance().getSteelArmOverride(RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE), finalBonus);
|
||||
if(mcMMO.p.getAdvancedConfig().isSteelArmDamageCustom()) {
|
||||
return mcMMO.p.getAdvancedConfig().getSteelArmOverride(RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE), finalBonus);
|
||||
} else {
|
||||
return finalBonus;
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
@@ -14,8 +12,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -53,7 +53,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
|
||||
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.WOODCUTTING);
|
||||
treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
|
||||
treeFellerThreshold = mcMMO.p.getGeneralConfig().getTreeFellerThreshold();
|
||||
}
|
||||
|
||||
public boolean canUseLeafBlower(ItemStack heldItem) {
|
||||
@@ -67,12 +67,18 @@ public class WoodcuttingManager extends SkillManager {
|
||||
&& ItemUtils.isAxe(heldItem);
|
||||
}
|
||||
|
||||
private boolean checkHarvestLumberActivation() {
|
||||
return SkillUtils.isSkillRNGSuccessful(SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer());
|
||||
private boolean checkHarvestLumberActivation(Material material) {
|
||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& SkillUtils.isSkillRNGSuccessful(SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer())
|
||||
&& mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, material);
|
||||
}
|
||||
|
||||
private boolean checkCleanCutsActivation() {
|
||||
return SkillUtils.isSkillRNGSuccessful(SubSkillType.WOODCUTTING_CLEAN_CUTS, getPlayer());
|
||||
private boolean checkCleanCutsActivation(Material material) {
|
||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& SkillUtils.isSkillRNGSuccessful(SubSkillType.WOODCUTTING_CLEAN_CUTS, getPlayer())
|
||||
&& mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +111,9 @@ public class WoodcuttingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void processWoodcuttingBlockXP(@NotNull BlockState blockState) {
|
||||
if(mcMMO.getPlaceStore().isTrue(blockState))
|
||||
return;
|
||||
|
||||
int xp = getExperienceFromLog(blockState);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
@@ -122,14 +131,6 @@ public class WoodcuttingManager extends SkillManager {
|
||||
|
||||
processTree(blockState, treeFellerBlocks);
|
||||
|
||||
// If the player is trying to break too many blocks
|
||||
if (treeFellerReachedThreshold) {
|
||||
treeFellerReachedThreshold = false;
|
||||
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Threshold");
|
||||
return;
|
||||
}
|
||||
|
||||
// If the tool can't sustain the durability loss
|
||||
if (!handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand(), player)) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Splinter");
|
||||
@@ -235,7 +236,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
if (BlockUtils.hasWoodcuttingXP(blockState)) {
|
||||
durabilityLoss += Config.getInstance().getAbilityToolDamage();
|
||||
durabilityLoss += mcMMO.p.getGeneralConfig().getAbilityToolDamage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,13 +297,14 @@ public class WoodcuttingManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
int xp = 0;
|
||||
int processedLogCount = 0;
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
int beforeXP = xp;
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (!EventUtils.simulateBlockBreak(block, player, true)) {
|
||||
break; // TODO: Shouldn't we use continue instead?
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -314,7 +316,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
xp += processTreeFellerXPGains(blockState, processedLogCount);
|
||||
|
||||
//Drop displaced block
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
|
||||
//Bonus Drops / Harvest lumber checks
|
||||
processBonusDropCheck(blockState);
|
||||
@@ -322,10 +324,10 @@ public class WoodcuttingManager extends SkillManager {
|
||||
//Drop displaced non-woodcutting XP blocks
|
||||
|
||||
if(RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
|
||||
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||
if(AdvancedConfig.getInstance().isKnockOnWoodXPOrbEnabled()) {
|
||||
if(mcMMO.p.getAdvancedConfig().isKnockOnWoodXPOrbEnabled()) {
|
||||
//TODO: Test the results of this RNG, should be 10%
|
||||
if(SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.WOODCUTTING, player, 10)) {
|
||||
int randOrbCount = Math.max(1, Misc.getRandom().nextInt(100));
|
||||
@@ -335,7 +337,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
}
|
||||
|
||||
} else {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +369,9 @@ public class WoodcuttingManager extends SkillManager {
|
||||
* @return Amount of experience
|
||||
*/
|
||||
private static int processTreeFellerXPGains(BlockState blockState, int woodCount) {
|
||||
if(mcMMO.getPlaceStore().isTrue(blockState))
|
||||
return 0;
|
||||
|
||||
int rawXP = ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockState.getType());
|
||||
|
||||
if(rawXP <= 0)
|
||||
@@ -400,7 +405,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
*
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
protected static void spawnHarvestLumberBonusDrops(@NotNull BlockState blockState) {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops(), ItemSpawnReason.BONUS_DROPS);
|
||||
protected void spawnHarvestLumberBonusDrops(@NotNull BlockState blockState) {
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), blockState.getBlock().getDrops(getPlayer().getInventory().getItemInMainHand()), ItemSpawnReason.BONUS_DROPS);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user