mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-03-30 08:16:25 +02:00

General Added Crossbows Skill, this skill is a WIP and feedback on discord is appreciated. Added Tridents Skill, this skill is a WIP and feedback on discord is appreciated. Added the "endgame" triple drop subskill 'Mother Lode' to Mining Added the "endgame" triple drop subskill 'Clean Cuts' to Woodcutting Added the "endgame" triple drop subskill 'Verdant Bounty' to Herbalism Added /mmopower command which simply shows your power level (aliases /mmopowerlevel /powerlevel) Config Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console. Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs. child.yml config is gone now, feel free to delete it. Tweaks Tree Feller now drops 90% less non-wood block rewards (leaves/etc) on average from Knock on Wood. Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk. Updated advanced.yml with entries for the new skills Permission nodes Added 'mcmmo.commands.mmopower' permission node for the new /mmopower command Added 'mcmmo.commands.crossbows' permission node Added 'mcmmo.ability.crossbows.crossbowslimitbreak' permission node Added 'mcmmo.ability.crossbows.trickshot' permission node Added 'mcmmo.ability.herbalism.verdantbounty' permission node Added 'mcmmo.ability.mining.motherlode' permission node Added 'mcmmo.ability.woodcutting.cleancuts' permission node Locale Added locale entries for motherlode, cleancuts, and verdant bounty. Codebase Major rewrite for how random chance was handled in the code. Many skills with RNG elements now send out a SubSkillEvent (which can be used to modify probability or cancel the results), some skills without RNG still send out this event when activated, this event is cancellable so it can be used to make a skill fail. A lot of new unit tests were added to help keep mcMMO stable as part of this update, of course, more could always be added. NOTES: One feature of this update is to provide an endgame benefits to some skills that you can grind for a long time, ideally for a long while. I will likely expand upon this idea in future updates. A few skills have these endgame-oriented subskills, these new subskills provide a small benefit at first that grows and scales up to level 10,000 (or 1,000 for Standard mode which no one uses) and does not have ranks (other than the initial rank to unlock it). These endgame sub skills unlock at level 1000 for users with default mcMMO settings, or 100 for those using the optional Standard scaling. You can tweak the benefits of these skills in advanced.yml, the default settings are meant to be a good starting point. Crossbows and Tridents are WIP skills, I would like feedback on discord about them. More info on the new Triple Drop skills (Mother Lode, Clean Cuts, Verdant Bounty): Currently these start at about 5% chance and can reach a maximum 50% chance if a player acquired 10,000 skill, you can adjust this in advanced.yml These skills respect double drop settings from config.yml just like the corresponding Double Drop skills do, if a double drop is disabled for an item, then it's disabled for triple drops too. I added a new Power Level Command, for now this just shows you your current power level. If I ever add features based on power level, this command will likely display output related to those features. Regarding Maces, I will likely add that as a WIP skill when the next Minecraft update drops.
191 lines
6.9 KiB
Java
191 lines
6.9 KiB
Java
package com.gmail.nossr50.skills.unarmed;
|
|
|
|
import com.gmail.nossr50.api.ItemSpawnReason;
|
|
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.*;
|
|
import com.gmail.nossr50.util.player.NotificationManager;
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.block.BlockState;
|
|
import org.bukkit.entity.Item;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class UnarmedManager extends SkillManager {
|
|
|
|
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
|
|
super(mcMMOPlayer, PrimarySkillType.UNARMED);
|
|
}
|
|
|
|
public boolean canActivateAbility() {
|
|
return mmoPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer());
|
|
}
|
|
|
|
public boolean canUseSteelArm() {
|
|
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE))
|
|
return false;
|
|
|
|
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
|
}
|
|
|
|
public boolean canUseBerserk() {
|
|
return mmoPlayer.getAbilityMode(SuperAbilityType.BERSERK);
|
|
}
|
|
|
|
public boolean canDisarm(LivingEntity target) {
|
|
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM))
|
|
return false;
|
|
|
|
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM);
|
|
}
|
|
|
|
public boolean canDeflect() {
|
|
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT))
|
|
return false;
|
|
|
|
Player player = getPlayer();
|
|
|
|
return ItemUtils.isUnarmed(player.getInventory().getItemInMainHand()) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT);
|
|
}
|
|
|
|
public boolean canUseBlockCracker() {
|
|
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER))
|
|
return false;
|
|
|
|
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER);
|
|
}
|
|
|
|
public boolean blockCrackerCheck(@NotNull BlockState blockState) {
|
|
if (!ProbabilityUtil.isNonRNGSkillActivationSuccessful(SubSkillType.UNARMED_BLOCK_CRACKER, getPlayer())) {
|
|
return false;
|
|
}
|
|
|
|
switch (blockState.getType()) {
|
|
case STONE_BRICKS:
|
|
if (!Unarmed.blockCrackerSmoothBrick) {
|
|
return false;
|
|
}
|
|
|
|
blockState.getBlock().setType(Material.CRACKED_STONE_BRICKS);
|
|
return true;
|
|
case INFESTED_STONE_BRICKS:
|
|
if (!Unarmed.blockCrackerSmoothBrick) {
|
|
return false;
|
|
}
|
|
|
|
blockState.getBlock().setType(Material.INFESTED_CRACKED_STONE_BRICKS);
|
|
return true;
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check for disarm.
|
|
*
|
|
* @param defender The defending player
|
|
*/
|
|
public void disarmCheck(@NotNull Player defender) {
|
|
if (ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.UNARMED_DISARM, getPlayer()) && !hasIronGrip(defender)) {
|
|
if (EventUtils.callDisarmEvent(defender).isCancelled()) {
|
|
return;
|
|
}
|
|
|
|
if(UserManager.getPlayer(defender) == null)
|
|
return;
|
|
|
|
Item item = Misc.spawnItem(getPlayer(), defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
|
|
|
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));
|
|
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Skills.Disarmed");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check for arrow deflection.
|
|
*/
|
|
public boolean deflectCheck() {
|
|
if (ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.UNARMED_ARROW_DEFLECT, getPlayer())) {
|
|
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.ArrowDeflect");
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Handle the effects of the Berserk ability
|
|
*
|
|
* @param damage The amount of damage initially dealt by the event
|
|
*/
|
|
public double berserkDamage(double damage) {
|
|
damage = ((damage * Unarmed.berserkDamageModifier) * mmoPlayer.getAttackStrength()) - damage;
|
|
|
|
return damage;
|
|
}
|
|
|
|
/**
|
|
* Handle the effects of the Iron Arm ability
|
|
*/
|
|
public double calculateSteelArmStyleDamage() {
|
|
if (ProbabilityUtil.isNonRNGSkillActivationSuccessful(SubSkillType.UNARMED_STEEL_ARM_STYLE, getPlayer())) {
|
|
return getSteelArmStyleDamage();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public double getSteelArmStyleDamage() {
|
|
double rank = RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
|
|
|
double bonus = 0;
|
|
|
|
if(rank >= 18)
|
|
bonus = 1 + rank - 18;
|
|
|
|
double finalBonus = bonus + 0.5 + (rank / 2);
|
|
|
|
|
|
if(mcMMO.p.getAdvancedConfig().isSteelArmDamageCustom()) {
|
|
return mcMMO.p.getAdvancedConfig().getSteelArmOverride(RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE), finalBonus);
|
|
} else {
|
|
return finalBonus;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check Iron Grip ability success
|
|
*
|
|
* @param defender The defending player
|
|
* @return true if the defender was not disarmed, false otherwise
|
|
*/
|
|
private boolean hasIronGrip(@NotNull Player defender) {
|
|
if (!Misc.isNPCEntityExcludingVillagers(defender)
|
|
&& Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP)
|
|
&& ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.UNARMED_IRON_GRIP, defender)) {
|
|
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender");
|
|
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker");
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|