mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-25 16:45:28 +02:00

committed by
GitHub

parent
02c732bdf2
commit
971e5da0ad
@@ -32,95 +32,47 @@ public final class CommandRegistrationManager {
|
||||
private static final String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
private static void registerSkillCommands() {
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
if (skill == PrimarySkillType.MACES)
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
if (primarySkillType == PrimarySkillType.MACES
|
||||
&& !mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 21, 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String commandName = skill.toString().toLowerCase(Locale.ENGLISH);
|
||||
String localizedName = mcMMO.p.getSkillTools().getLocalizedSkillName(skill).toLowerCase(Locale.ENGLISH);
|
||||
final String commandName = primarySkillType.toString().toLowerCase(Locale.ENGLISH);
|
||||
final String localizedName = mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType).toLowerCase(Locale.ENGLISH);
|
||||
|
||||
PluginCommand command;
|
||||
final PluginCommand command = mcMMO.p.getCommand(commandName);
|
||||
if (command == null) {
|
||||
mcMMO.p.getLogger().severe("Command not found: " + commandName);
|
||||
continue;
|
||||
}
|
||||
|
||||
command = mcMMO.p.getCommand(commandName);
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName)));
|
||||
command.setPermission("mcmmo.commands." + commandName);
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", commandName));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", commandName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||
|
||||
switch (skill) {
|
||||
case ACROBATICS:
|
||||
command.setExecutor(new AcrobaticsCommand());
|
||||
break;
|
||||
|
||||
case ALCHEMY:
|
||||
command.setExecutor(new AlchemyCommand());
|
||||
break;
|
||||
|
||||
case ARCHERY:
|
||||
command.setExecutor(new ArcheryCommand());
|
||||
break;
|
||||
|
||||
case AXES:
|
||||
command.setExecutor(new AxesCommand());
|
||||
break;
|
||||
case CROSSBOWS:
|
||||
command.setExecutor(new CrossbowsCommand());
|
||||
break;
|
||||
|
||||
case EXCAVATION:
|
||||
command.setExecutor(new ExcavationCommand());
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
command.setExecutor(new FishingCommand());
|
||||
break;
|
||||
|
||||
case HERBALISM:
|
||||
command.setExecutor(new HerbalismCommand());
|
||||
break;
|
||||
|
||||
case MACES:
|
||||
// command.setExecutor(new MacesCommand());
|
||||
break;
|
||||
|
||||
case MINING:
|
||||
command.setExecutor(new MiningCommand());
|
||||
break;
|
||||
|
||||
case REPAIR:
|
||||
command.setExecutor(new RepairCommand());
|
||||
break;
|
||||
|
||||
case SALVAGE:
|
||||
command.setExecutor(new SalvageCommand());
|
||||
break;
|
||||
|
||||
case SMELTING:
|
||||
command.setExecutor(new SmeltingCommand());
|
||||
break;
|
||||
|
||||
case SWORDS:
|
||||
command.setExecutor(new SwordsCommand());
|
||||
break;
|
||||
|
||||
case TAMING:
|
||||
command.setExecutor(new TamingCommand());
|
||||
break;
|
||||
case TRIDENTS:
|
||||
command.setExecutor(new TridentsCommand());
|
||||
break;
|
||||
|
||||
case UNARMED:
|
||||
command.setExecutor(new UnarmedCommand());
|
||||
break;
|
||||
|
||||
case WOODCUTTING:
|
||||
command.setExecutor(new WoodcuttingCommand());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + skill);
|
||||
switch (primarySkillType) {
|
||||
case ACROBATICS -> command.setExecutor(new AcrobaticsCommand());
|
||||
case ALCHEMY -> command.setExecutor(new AlchemyCommand());
|
||||
case ARCHERY -> command.setExecutor(new ArcheryCommand());
|
||||
case AXES -> command.setExecutor(new AxesCommand());
|
||||
case CROSSBOWS -> command.setExecutor(new CrossbowsCommand());
|
||||
case EXCAVATION -> command.setExecutor(new ExcavationCommand());
|
||||
case FISHING -> command.setExecutor(new FishingCommand());
|
||||
case HERBALISM -> command.setExecutor(new HerbalismCommand());
|
||||
case MACES -> command.setExecutor(new MacesCommand());
|
||||
case MINING -> command.setExecutor(new MiningCommand());
|
||||
case REPAIR -> command.setExecutor(new RepairCommand());
|
||||
case SALVAGE -> command.setExecutor(new SalvageCommand());
|
||||
case SMELTING -> command.setExecutor(new SmeltingCommand());
|
||||
case SWORDS -> command.setExecutor(new SwordsCommand());
|
||||
case TAMING -> command.setExecutor(new TamingCommand());
|
||||
case TRIDENTS -> command.setExecutor(new TridentsCommand());
|
||||
case UNARMED -> command.setExecutor(new UnarmedCommand());
|
||||
case WOODCUTTING -> command.setExecutor(new WoodcuttingCommand());
|
||||
default -> throw new IllegalStateException("Unexpected value: " + primarySkillType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,7 +215,7 @@ public final class CommandRegistrationManager {
|
||||
command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrank", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McrankCommand());
|
||||
command.setExecutor(new McRankCommand());
|
||||
}
|
||||
|
||||
private static void registerMcstatsCommand() {
|
||||
@@ -281,7 +233,7 @@ public final class CommandRegistrationManager {
|
||||
command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||
command.setExecutor(new MctopCommand());
|
||||
command.setExecutor(new McTopCommand());
|
||||
}
|
||||
|
||||
private static void registerMcpurgeCommand() {
|
||||
|
@@ -216,13 +216,14 @@ public final class CommandUtils {
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill));
|
||||
}
|
||||
|
||||
private static void printGroupedSkillData(Player inspectTarget, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
||||
private static void printGroupedSkillData(Player inspectTarget, CommandSender display,
|
||||
String header, List<PrimarySkillType> skillGroup) {
|
||||
if (UserManager.getPlayer(inspectTarget) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(inspectTarget).getProfile();
|
||||
final PlayerProfile profile = UserManager.getPlayer(inspectTarget).getProfile();
|
||||
|
||||
List<String> displayData = new ArrayList<>();
|
||||
final List<String> displayData = new ArrayList<>();
|
||||
displayData.add(header);
|
||||
|
||||
for (PrimarySkillType primarySkillType : skillGroup) {
|
||||
|
@@ -28,15 +28,10 @@ public class PlatformBuilder {
|
||||
}
|
||||
|
||||
public @Nullable Platform build() {
|
||||
switch(serverSoftwareType) {
|
||||
|
||||
case PAPER:
|
||||
case SPIGOT:
|
||||
case CRAFT_BUKKIT:
|
||||
return createBukkitPlatform();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (serverSoftwareType) {
|
||||
case PAPER, SPIGOT, CRAFT_BUKKIT -> createBukkitPlatform();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private BukkitPlatform createBukkitPlatform() {
|
||||
|
@@ -85,14 +85,11 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
public String getServerSoftwareStr() {
|
||||
switch(getServerSoftware()) {
|
||||
case PAPER:
|
||||
return "Paper";
|
||||
case SPIGOT:
|
||||
return "Spigot";
|
||||
default:
|
||||
return "CraftBukkit";
|
||||
}
|
||||
return switch (getServerSoftware()) {
|
||||
case PAPER -> "Paper";
|
||||
case SPIGOT -> "Spigot";
|
||||
default -> "CraftBukkit";
|
||||
};
|
||||
}
|
||||
|
||||
public @Nullable CompatibilityManager getCompatibilityManager() {
|
||||
|
@@ -94,4 +94,17 @@ public interface Probability {
|
||||
double probabilityValue = getValue() * probabilityMultiplier;
|
||||
return isSuccessfulRoll(probabilityValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify and then Simulate an outcome on a probability and return true or false for the result of that outcome.
|
||||
*
|
||||
* @param probabilityMultiplier probability will be multiplied by this before success is checked
|
||||
* @param finalProbabilityMultiplier probability will be multiplied by this after the first multiplier,
|
||||
* should be between 0 and 1
|
||||
* @return true if the probability succeeded, false if it failed
|
||||
*/
|
||||
default boolean evaluate(double probabilityMultiplier, double finalProbabilityMultiplier) {
|
||||
double probabilityValue = getValue() * probabilityMultiplier;
|
||||
return isSuccessfulRoll(probabilityValue * finalProbabilityMultiplier);
|
||||
}
|
||||
}
|
||||
|
@@ -188,6 +188,45 @@ public class ProbabilityUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is one of several Skill RNG evaluation methods.
|
||||
* This one specifically allows for a probability multiplier to be passed in.
|
||||
* This probability multiplier is applied after any lucky modifiers, affecting the final result.
|
||||
* <p>
|
||||
* This helper method is for specific {@link SubSkillType},
|
||||
* which help mcMMO understand where the RNG values used in our calculations come from this {@link SubSkillType}
|
||||
* <p>
|
||||
* 1) Determine where the RNG values come from for the passed {@link SubSkillType}
|
||||
* NOTE: In the config file, there are values which are static and which are more dynamic,
|
||||
* this is currently a bit hardcoded and will need to be updated manually
|
||||
* <p>
|
||||
* 2) Determine whether to use Lucky multiplier and influence the outcome
|
||||
* <p>
|
||||
* 3)
|
||||
* Creates a {@link Probability} and pipes it to {@link ProbabilityUtil} which processes the result and returns it
|
||||
* <p>
|
||||
* This also calls a {@link SubSkillEvent} which can be cancelled, if it is cancelled this will return false
|
||||
* The outcome of the probability can also be modified by this event that is called
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @param mmoPlayer target player
|
||||
* can be null (null players are given odds equivalent to a player with no levels or luck)
|
||||
* @return true if the Skill RNG succeeds, false if it fails
|
||||
*/
|
||||
public static boolean isSkillRNGSuccessful(@NotNull SubSkillType subSkillType, @Nullable McMMOPlayer mmoPlayer,
|
||||
double probabilityMultiplier) {
|
||||
final Probability probability = getSkillProbability(subSkillType, mmoPlayer);
|
||||
|
||||
//Luck
|
||||
boolean isLucky = mmoPlayer != null && Permissions.lucky(mmoPlayer.getPlayer(), subSkillType.getParentSkill());
|
||||
|
||||
if (isLucky) {
|
||||
return probability.evaluate(LUCKY_MODIFIER, probabilityMultiplier);
|
||||
} else {
|
||||
return probability.evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Probability} for a specific {@link SubSkillType} for a specific {@link Player}.
|
||||
* This does not take into account perks such as lucky for the player.
|
||||
|
@@ -13,6 +13,7 @@ import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
import com.gmail.nossr50.skills.maces.MacesManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.tridents.TridentsManager;
|
||||
@@ -20,6 +21,7 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
@@ -58,7 +60,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
@@ -72,10 +74,6 @@ public final class CombatUtils {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.SWORDS);
|
||||
}
|
||||
|
||||
if (target.getHealth() - event.getFinalDamage() > 0) {
|
||||
swordsManager.processRupture(target);
|
||||
}
|
||||
|
||||
//Add Stab Damage
|
||||
if (swordsManager.canUseStab()) {
|
||||
boostedDamage += (swordsManager.getStabDamage() * mcMMOPlayer.getAttackStrength());
|
||||
@@ -86,18 +84,27 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (getLimitBreakDamage
|
||||
(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
|
||||
if (target.getHealth() - event.getFinalDamage() > 0) {
|
||||
swordsManager.processRupture(target);
|
||||
}
|
||||
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.SWORDS);
|
||||
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer);
|
||||
}
|
||||
|
||||
private static void printFinalDamageDebug(@NotNull Player player, @NotNull EntityDamageByEntityEvent event, @NotNull McMMOPlayer mcMMOPlayer, @Nullable String @Nullable ... extraInfoLines) {
|
||||
private static void printFinalDamageDebug(@NotNull Player player, @NotNull EntityDamageByEntityEvent event,
|
||||
@NotNull McMMOPlayer mcMMOPlayer,
|
||||
@Nullable String @Nullable ...extraInfoLines) {
|
||||
if (mcMMOPlayer.isDebugMode()) {
|
||||
player.sendMessage("Final Damage value after mcMMO modifiers: "+ event.getFinalDamage());
|
||||
player.sendMessage("Your current attack strength: "+ player.getAttackCooldown());
|
||||
if (extraInfoLines != null) {
|
||||
for(String str : extraInfoLines) {
|
||||
if (str != null)
|
||||
@@ -114,14 +121,14 @@ public final class CombatUtils {
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
|
||||
final TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
|
||||
|
||||
// if (tridentsManager.canActivateAbility()) {
|
||||
// mcMMOPlayer.checkAbilityActivation(PrimarySkillType.TRIDENTS);
|
||||
@@ -132,7 +139,8 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (getLimitBreakDamage(
|
||||
player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
@@ -148,21 +156,21 @@ public final class CombatUtils {
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
|
||||
final TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, SubSkillType.TRIDENTS_IMPALE)) {
|
||||
boostedDamage += (tridentsManager.impaleDamageBonus() * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (tridentsManager.impaleDamageBonus());
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK));
|
||||
}
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
@@ -175,7 +183,7 @@ public final class CombatUtils {
|
||||
@NotNull EntityDamageByEntityEvent event, @NotNull Arrow arrow) {
|
||||
double initialDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
@@ -210,60 +218,73 @@ public final class CombatUtils {
|
||||
delayArrowMetaCleanup(arrow);
|
||||
}
|
||||
|
||||
private static void processMacesCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
|
||||
private static void processMacesCombat(@NotNull LivingEntity target,
|
||||
@NotNull Player player,
|
||||
@NotNull EntityDamageByEntityEvent event) {
|
||||
if (event.getCause() == DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// MacesManager macesManager = mcMMOPlayer.getMacesManager();
|
||||
final MacesManager macesManager = mcMMOPlayer.getMacesManager();
|
||||
|
||||
// Apply Limit Break DMG
|
||||
if (canUseLimitBreak(player, target, SubSkillType.MACES_MACES_LIMIT_BREAK)) {
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.MACES_MACES_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (getLimitBreakDamage(
|
||||
player, target, SubSkillType.MACES_MACES_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.MACES);
|
||||
// Apply Crush DMG
|
||||
boostedDamage += (macesManager.getCrushDamage() * mcMMOPlayer.getAttackStrength());
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
|
||||
// Apply Cripple
|
||||
if (target.getHealth() - event.getFinalDamage() > 0) {
|
||||
macesManager.processCripple(target);
|
||||
}
|
||||
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.MACES);
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer);
|
||||
}
|
||||
|
||||
private static void processAxeCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
|
||||
private static void processAxeCombat(@NotNull LivingEntity target, @NotNull Player player,
|
||||
@NotNull EntityDamageByEntityEvent event) {
|
||||
if (event.getCause() == DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||
final AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||
|
||||
if (axesManager.canActivateAbility()) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.AXES);
|
||||
}
|
||||
|
||||
if (axesManager.canUseAxeMastery()) {
|
||||
boostedDamage+=axesManager.axeMastery();
|
||||
boostedDamage += axesManager.axeMastery() * mcMMOPlayer.getAttackStrength();
|
||||
}
|
||||
|
||||
if (axesManager.canImpact(target)) {
|
||||
axesManager.impactCheck(target);
|
||||
} else if (axesManager.canGreaterImpact(target)) {
|
||||
boostedDamage+=axesManager.greaterImpact(target);
|
||||
boostedDamage += axesManager.greaterImpact(target) * mcMMOPlayer.getAttackStrength();
|
||||
}
|
||||
|
||||
if (axesManager.canUseSkullSplitter(target)) {
|
||||
@@ -291,14 +312,14 @@ public final class CombatUtils {
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
final UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canActivateAbility()) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
|
||||
@@ -317,7 +338,8 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
|
||||
boostedDamage+=(getLimitBreakDamage(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(getLimitBreakDamage(
|
||||
player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
@@ -331,14 +353,14 @@ public final class CombatUtils {
|
||||
double boostedDamage = initialDamage;
|
||||
|
||||
if (master != null && master.isOnline() && master.isValid()) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
final TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
if (tamingManager.canUseFastFoodService()) {
|
||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||
@@ -364,7 +386,7 @@ public final class CombatUtils {
|
||||
@NotNull EntityDamageByEntityEvent event, @NotNull Arrow arrow) {
|
||||
double initialDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Make sure the profiles been loaded
|
||||
if (mcMMOPlayer == null) {
|
||||
@@ -372,7 +394,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||
final ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
@@ -416,7 +438,9 @@ public final class CombatUtils {
|
||||
*
|
||||
* @param event The event to run the combat checks on.
|
||||
*/
|
||||
public static void processCombatAttack(@NotNull EntityDamageByEntityEvent event, @NotNull Entity painSourceRoot, @NotNull LivingEntity target) {
|
||||
public static void processCombatAttack(@NotNull EntityDamageByEntityEvent event,
|
||||
@NotNull Entity painSourceRoot,
|
||||
@NotNull LivingEntity target) {
|
||||
Entity painSource = event.getDamager();
|
||||
EntityType entityType = painSource.getType();
|
||||
|
||||
@@ -435,8 +459,8 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||
|
||||
if (acrobaticsManager.canDodge(target)) {
|
||||
event.setDamage(acrobaticsManager.dodgeCheck(painSourceRoot, event.getDamage()));
|
||||
@@ -447,7 +471,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||
final SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||
|
||||
if (swordsManager.canUseCounterAttack(painSource)) {
|
||||
swordsManager.counterAttackChecks((LivingEntity) painSource, event.getDamage());
|
||||
@@ -456,7 +480,6 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (painSourceRoot instanceof Player player && entityType == EntityType.PLAYER) {
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -811,7 +834,7 @@ public final class CombatUtils {
|
||||
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
|
||||
}
|
||||
|
||||
McMMOPlayer mmoAttacker = UserManager.getPlayer(attacker);
|
||||
final McMMOPlayer mmoAttacker = UserManager.getPlayer(attacker);
|
||||
|
||||
if (mmoAttacker != null) {
|
||||
mmoAttacker.getSwordsManager().processRupture(livingEntity);
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package com.gmail.nossr50.util.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -29,7 +30,26 @@ public final class ParticleEffectUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
livingEntity.getWorld().playEffect(getParticleLocation(livingEntity), Effect.STEP_SOUND, Material.REDSTONE_WIRE);
|
||||
livingEntity.getWorld().playEffect(getParticleLocation(livingEntity),
|
||||
Effect.STEP_SOUND, Material.REDSTONE_WIRE);
|
||||
}
|
||||
|
||||
public static void playCrippleEffect(@NotNull LivingEntity livingEntity) {
|
||||
if (!mcMMO.p.getGeneralConfig().getCrippleEffectEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoundManager.sendCategorizedSound(livingEntity.getLocation(), SoundType.CRIPPLE, SoundCategory.PLAYERS, 0.2F);
|
||||
livingEntity.getWorld().playEffect(getParticleLocation(livingEntity), Effect.ANVIL_BREAK, null, 20);
|
||||
|
||||
if (livingEntity instanceof Player player) {
|
||||
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
boolean useChatNotification = mmoPlayer == null || mmoPlayer.useChatNotifications();
|
||||
if (useChatNotification) {
|
||||
NotificationManager.sendPlayerInformation(
|
||||
player, NotificationType.SUBSKILL_MESSAGE, "Maces.SubSkill.Cripple.Proc");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull Location getParticleLocation(@NotNull LivingEntity livingEntity) {
|
||||
|
@@ -23,8 +23,8 @@ import java.util.*;
|
||||
|
||||
public class SkillTools {
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
//TODO: Figure out which ones we don't need, this was copy pasted from a diff branch
|
||||
// TODO: Java has immutable types now, switch to those
|
||||
// TODO: Figure out which ones we don't need, this was copy pasted from a diff branch
|
||||
public final @NotNull ImmutableList<String> LOCALIZED_SKILL_NAMES;
|
||||
public final @NotNull ImmutableList<String> FORMATTED_SUBSKILL_NAMES;
|
||||
public final @NotNull ImmutableSet<String> EXACT_SUBSKILL_NAMES;
|
||||
@@ -156,14 +156,28 @@ public class SkillTools {
|
||||
* Build categorized skill lists
|
||||
*/
|
||||
|
||||
COMBAT_SKILLS = ImmutableList.of(
|
||||
PrimarySkillType.ARCHERY,
|
||||
PrimarySkillType.AXES,
|
||||
PrimarySkillType.CROSSBOWS,
|
||||
PrimarySkillType.SWORDS,
|
||||
PrimarySkillType.TAMING,
|
||||
PrimarySkillType.TRIDENTS,
|
||||
PrimarySkillType.UNARMED);
|
||||
// We are in a game version with Maces
|
||||
if (mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 21, 0)) {
|
||||
COMBAT_SKILLS = ImmutableList.of(
|
||||
PrimarySkillType.ARCHERY,
|
||||
PrimarySkillType.AXES,
|
||||
PrimarySkillType.CROSSBOWS,
|
||||
PrimarySkillType.MACES,
|
||||
PrimarySkillType.SWORDS,
|
||||
PrimarySkillType.TAMING,
|
||||
PrimarySkillType.TRIDENTS,
|
||||
PrimarySkillType.UNARMED);
|
||||
} else {
|
||||
// No Maces in this version
|
||||
COMBAT_SKILLS = ImmutableList.of(
|
||||
PrimarySkillType.ARCHERY,
|
||||
PrimarySkillType.AXES,
|
||||
PrimarySkillType.CROSSBOWS,
|
||||
PrimarySkillType.SWORDS,
|
||||
PrimarySkillType.TAMING,
|
||||
PrimarySkillType.TRIDENTS,
|
||||
PrimarySkillType.UNARMED);
|
||||
}
|
||||
GATHERING_SKILLS = ImmutableList.of(
|
||||
PrimarySkillType.EXCAVATION,
|
||||
PrimarySkillType.FISHING,
|
||||
|
@@ -9,21 +9,54 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SoundManager {
|
||||
public static Sound CRIPPLE_SOUND;
|
||||
static {
|
||||
try {
|
||||
CRIPPLE_SOUND = Sound.valueOf("ITEM_MACE_SMASH_GROUND");
|
||||
} catch (IllegalArgumentException e) {
|
||||
CRIPPLE_SOUND = Sound.BLOCK_ANVIL_PLACE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a sound to the player
|
||||
* @param soundType the type of sound
|
||||
*/
|
||||
public static void sendSound(Player player, Location location, SoundType soundType) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
||||
player.playSound(location, getSound(soundType),
|
||||
SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) {
|
||||
public static void sendCategorizedSound(Location location, SoundType soundType, SoundCategory soundCategory) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
|
||||
final World world = location.getWorld();
|
||||
if (world != null) {
|
||||
world.playSound(location, getSound(soundType), soundCategory,
|
||||
getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Location location, SoundType soundType, SoundCategory soundCategory,
|
||||
float pitchModifier) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
|
||||
final World world = location.getWorld();
|
||||
if (world != null) {
|
||||
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
|
||||
world.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Player player, Location location,
|
||||
SoundType soundType, SoundCategory soundCategory) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
|
||||
public static void sendCategorizedSound(Player player, Location location,
|
||||
SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
|
||||
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
|
||||
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
@@ -74,6 +107,7 @@ public class SoundManager {
|
||||
case DEFLECT_ARROWS, BLEED -> Sound.ENTITY_ENDER_EYE_DEATH;
|
||||
case GLASS -> Sound.BLOCK_GLASS_BREAK;
|
||||
case ITEM_CONSUMED -> Sound.ITEM_BOTTLE_EMPTY;
|
||||
case CRIPPLE -> CRIPPLE_SOUND;
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ public enum SoundType {
|
||||
BLEED,
|
||||
GLASS,
|
||||
ITEM_CONSUMED,
|
||||
CRIPPLE,
|
||||
TIRED;
|
||||
|
||||
public boolean usesCustomPitch() {
|
||||
|
Reference in New Issue
Block a user