mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
annotate messaging classes + update more things to use mmoPlayer
This commit is contained in:
parent
a2a41e77ea
commit
8491d0f4e5
@ -3,6 +3,9 @@ Version 2.2.000
|
|||||||
Parts of the API have been migrated to mcMMO-API
|
Parts of the API have been migrated to mcMMO-API
|
||||||
(API) mcMMO makes use of jmal (Java Minecraft Abstraction Library) for some abstraction now
|
(API) mcMMO makes use of jmal (Java Minecraft Abstraction Library) for some abstraction now
|
||||||
|
|
||||||
|
Codebase Stuff
|
||||||
|
Many places that passed type Player now passes type McMMOPlayer instead
|
||||||
|
|
||||||
New Skill - Tridents
|
New Skill - Tridents
|
||||||
New Skill - Crossbows
|
New Skill - Crossbows
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
|
ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
|
||||||
@ -67,7 +67,7 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.EXCAVATION);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.EXCAVATION);
|
||||||
|
@ -107,7 +107,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canFishermansDiet) {
|
if (canFishermansDiet) {
|
||||||
@ -152,7 +152,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.FISHING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.FISHING);
|
||||||
|
@ -77,7 +77,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canBiggerBombs) {
|
if (canBiggerBombs) {
|
||||||
@ -111,7 +111,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.MINING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.MINING);
|
||||||
|
@ -91,7 +91,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canArcaneForge) {
|
if (canArcaneForge) {
|
||||||
@ -122,7 +122,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.REPAIR);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.REPAIR);
|
||||||
|
@ -36,7 +36,7 @@ public class SalvageCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
SalvageManager salvageManager = mmoPlayer.getSalvageManager();
|
SalvageManager salvageManager = mmoPlayer.getSalvageManager();
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class SalvageCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SALVAGE);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SALVAGE);
|
||||||
|
@ -67,7 +67,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Player player = (Player) sender;
|
Player player = mmoPlayer.getPlayer();
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, skill);
|
boolean isLucky = Permissions.lucky(player, skill);
|
||||||
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||||
@ -79,7 +79,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionsCheck(player);
|
permissionsCheck(mmoPlayer);
|
||||||
dataCalculations(mmoPlayer, skillValue);
|
dataCalculations(mmoPlayer, skillValue);
|
||||||
|
|
||||||
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
|
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
|
||||||
@ -209,7 +209,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
public @NotNull List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
return ImmutableList.of("?");
|
return ImmutableList.of("?");
|
||||||
}
|
}
|
||||||
@ -220,11 +220,11 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getAbilityDisplayValues(@NotNull SkillActivationType skillActivationType, @NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkill) {
|
protected @NotNull String[] getAbilityDisplayValues(@NotNull SkillActivationType skillActivationType, @NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkill) {
|
||||||
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, mmoPlayer.getPlayer(), subSkill);
|
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, mmoPlayer.getPlayer(), subSkill);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] calculateLengthDisplayValues(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
protected @NotNull String[] calculateLengthDisplayValues(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
int maxLength = skill.getSuperAbilityType().getMaxLength();
|
int maxLength = skill.getSuperAbilityType().getMaxLength();
|
||||||
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
||||||
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
|
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
|
||||||
@ -248,12 +248,12 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStatMessage(SubSkillType subSkillType, String... vars)
|
protected @NotNull String getStatMessage(SubSkillType subSkillType, String... vars)
|
||||||
{
|
{
|
||||||
return getStatMessage(false, false, subSkillType, vars);
|
return getStatMessage(false, false, subSkillType, vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars)
|
protected @NotNull String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars)
|
||||||
{
|
{
|
||||||
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
|
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
|
||||||
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
|
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
|
||||||
@ -277,13 +277,13 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
|
|
||||||
protected abstract void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue);
|
protected abstract void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue);
|
||||||
|
|
||||||
protected abstract void permissionsCheck(@NotNull Player player);
|
protected abstract void permissionsCheck(@NotNull McMMOPlayer mmoPlayer);
|
||||||
|
|
||||||
//protected abstract List<String> effectsDisplay();
|
//protected abstract List<String> effectsDisplay();
|
||||||
|
|
||||||
protected abstract List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky);
|
protected abstract @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky);
|
||||||
|
|
||||||
protected abstract List<Component> getTextComponents(@NotNull McMMOPlayer player);
|
protected abstract @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player can use a skill
|
* Checks if a player can use a skill
|
||||||
|
@ -61,7 +61,7 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
/*if (canFluxMine) {
|
/*if (canFluxMine) {
|
||||||
@ -88,7 +88,7 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SMELTING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SMELTING);
|
||||||
|
@ -38,15 +38,20 @@ import net.kyori.adventure.identity.Identity;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.permissions.Permissible;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class McMMOPlayer extends PlayerProfile implements Identified {
|
public class McMMOPlayer extends PlayerProfile implements Identified, Permissible {
|
||||||
private final @NotNull Player player;
|
private final @NotNull Player player;
|
||||||
private final @NotNull Identity identity;
|
private final @NotNull Identity identity;
|
||||||
private @Nullable Party playerPartyRef;
|
private @Nullable Party playerPartyRef;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
|
package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface SubSkill extends Skill {
|
public interface SubSkill extends Skill {
|
||||||
/**
|
/**
|
||||||
@ -59,9 +61,9 @@ public interface SubSkill extends Skill {
|
|||||||
/**
|
/**
|
||||||
* Adds detailed stats specific to this skill
|
* Adds detailed stats specific to this skill
|
||||||
* @param componentBuilder target component builder
|
* @param componentBuilder target component builder
|
||||||
* @param player owner of this skill
|
* @param mmoPlayer owner of this skill
|
||||||
*/
|
*/
|
||||||
void addStats(TextComponent.Builder componentBuilder, Player player);
|
void addStats(TextComponent.Builder componentBuilder, @NotNull McMMOPlayer mmoPlayer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this subskill is enabled
|
* Whether or not this subskill is enabled
|
||||||
|
@ -25,6 +25,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class NotificationManager {
|
public class NotificationManager {
|
||||||
/**
|
/**
|
||||||
@ -34,9 +35,11 @@ public class NotificationManager {
|
|||||||
* @param notificationType notifications defined type
|
* @param notificationType notifications defined type
|
||||||
* @param key the locale key for the notifications defined message
|
* @param key the locale key for the notifications defined message
|
||||||
*/
|
*/
|
||||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key)
|
public static void sendPlayerInformation(@NotNull Player player, @NotNull NotificationType notificationType, @NotNull String key)
|
||||||
{
|
{
|
||||||
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer == null || !mmoPlayer.hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
McMMOMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||||
@ -48,40 +51,47 @@ public class NotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean doesPlayerUseNotifications(Player player)
|
public static boolean doesPlayerUseNotifications(@NotNull Player player)
|
||||||
{
|
{
|
||||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer == null)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications();
|
return mmoPlayer.hasSkillChatNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends players notifications from mcMMO
|
* Sends players notifications from mcMMO
|
||||||
* This does this by sending out an event so other plugins can cancel it
|
* This does this by sending out an event so other plugins can cancel it
|
||||||
* This event in particular is provided with a source player, and players near the source player are sent the information
|
* This event in particular is provided with a source player, and players near the source player are sent the information
|
||||||
|
*
|
||||||
* @param targetPlayer the recipient player for this message
|
* @param targetPlayer the recipient player for this message
|
||||||
* @param notificationType type of notification
|
* @param notificationType type of notification
|
||||||
* @param key Locale Key for the string to use with this event
|
* @param key Locale Key for the string to use with this event
|
||||||
* @param values values to be injected into the locale string
|
* @param values values to be injected into the locale string
|
||||||
*/
|
*/
|
||||||
public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key, String... values)
|
public static void sendNearbyPlayersInformation(@NotNull Player targetPlayer, @NotNull NotificationType notificationType, @NotNull String key, String... values)
|
||||||
{
|
{
|
||||||
sendPlayerInformation(targetPlayer, notificationType, key, values);
|
sendPlayerInformation(targetPlayer, notificationType, key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerInformationChatOnly(Player player, String key, String... values)
|
public static void sendPlayerInformationChatOnly(@NotNull Player player, @NotNull String key, String... values)
|
||||||
{
|
{
|
||||||
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer == null || !mmoPlayer.hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
|
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
|
||||||
player.sendMessage(preColoredString);
|
player.sendMessage(preColoredString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerInformationChatOnlyPrefixed(Player player, String key, String... values)
|
public static void sendPlayerInformationChatOnlyPrefixed(@NotNull Player player, @NotNull String key, String... values)
|
||||||
{
|
{
|
||||||
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer == null || !mmoPlayer.hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
|
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
|
||||||
@ -89,7 +99,7 @@ public class NotificationManager {
|
|||||||
player.sendMessage(prefixFormattedMessage);
|
player.sendMessage(prefixFormattedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
|
public static void sendPlayerInformation(@NotNull Player player, @NotNull NotificationType notificationType, @NotNull String key, String... values)
|
||||||
{
|
{
|
||||||
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
|
if(mcMMO.getUserManager().queryPlayer(player) == null || !mcMMO.getUserManager().queryPlayer(player).hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
@ -102,7 +112,7 @@ public class NotificationManager {
|
|||||||
sendNotification(player, customEvent);
|
sendNotification(player, customEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendNotification(Player player, McMMOPlayerNotificationEvent customEvent) {
|
private static void sendNotification(@NotNull Player player, @NotNull McMMOPlayerNotificationEvent customEvent) {
|
||||||
if (customEvent.isCancelled())
|
if (customEvent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -152,7 +162,7 @@ public class NotificationManager {
|
|||||||
sendNotification(mmoPlayer.getPlayer(), customEvent);
|
sendNotification(mmoPlayer.getPlayer(), customEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcastTitle(Server server, String title, String subtitle, int i1, int i2, int i3)
|
public static void broadcastTitle(@NotNull Server server, @NotNull String title, @NotNull String subtitle, int i1, int i2, int i3)
|
||||||
{
|
{
|
||||||
for(Player player : server.getOnlinePlayers())
|
for(Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -160,13 +170,13 @@ public class NotificationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerUnlockNotification(McMMOPlayer mmoPlayer, SubSkillType subSkillType)
|
public static void sendPlayerUnlockNotification(@NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkillType)
|
||||||
{
|
{
|
||||||
if(!mmoPlayer.hasSkillChatNotifications())
|
if(!mmoPlayer.hasSkillChatNotifications())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//CHAT MESSAGE
|
//CHAT MESSAGE
|
||||||
mcMMO.getAudiences().player(mmoPlayer.getPlayer()).sendMessage(Identity.nil(), TextComponentFactory.getSubSkillUnlockedNotificationComponents(mmoPlayer.getPlayer(), subSkillType));
|
mcMMO.getAudiences().player(mmoPlayer.getPlayer()).sendMessage(Identity.nil(), TextComponentFactory.getSubSkillUnlockedNotificationComponents(mmoPlayer, subSkillType));
|
||||||
|
|
||||||
//Unlock Sound Effect
|
//Unlock Sound Effect
|
||||||
SoundManager.sendCategorizedSound(mmoPlayer.getPlayer(), mmoPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
|
SoundManager.sendCategorizedSound(mmoPlayer.getPlayer(), mmoPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
|
||||||
@ -184,7 +194,7 @@ public class NotificationManager {
|
|||||||
* Admins are currently players with either Operator status or Admin Chat permission
|
* Admins are currently players with either Operator status or Admin Chat permission
|
||||||
* @param msg message fetched from locale
|
* @param msg message fetched from locale
|
||||||
*/
|
*/
|
||||||
private static void sendAdminNotification(String msg) {
|
private static void sendAdminNotification(@NotNull String msg) {
|
||||||
//If its not enabled exit
|
//If its not enabled exit
|
||||||
if(!Config.getInstance().adminNotifications())
|
if(!Config.getInstance().adminNotifications())
|
||||||
return;
|
return;
|
||||||
@ -206,7 +216,7 @@ public class NotificationManager {
|
|||||||
* @param commandSender target command sender
|
* @param commandSender target command sender
|
||||||
* @param msg message fetched from locale
|
* @param msg message fetched from locale
|
||||||
*/
|
*/
|
||||||
private static void sendAdminCommandConfirmation(CommandSender commandSender, String msg) {
|
private static void sendAdminCommandConfirmation(@NotNull CommandSender commandSender, @NotNull String msg) {
|
||||||
commandSender.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Self", msg));
|
commandSender.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Self", msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +225,7 @@ public class NotificationManager {
|
|||||||
* @param commandSender the command user
|
* @param commandSender the command user
|
||||||
* @param sensitiveCommandType type of command issued
|
* @param sensitiveCommandType type of command issued
|
||||||
*/
|
*/
|
||||||
public static void processSensitiveCommandNotification(CommandSender commandSender, SensitiveCommandType sensitiveCommandType, String... args) {
|
public static void processSensitiveCommandNotification(@NotNull CommandSender commandSender, @NotNull SensitiveCommandType sensitiveCommandType, String... args) {
|
||||||
/*
|
/*
|
||||||
* Determine the 'identity' of the one who executed the command to pass as a parameters
|
* Determine the 'identity' of the one who executed the command to pass as a parameters
|
||||||
*/
|
*/
|
||||||
@ -247,7 +257,7 @@ public class NotificationManager {
|
|||||||
* @param existingArray the existing array to be copied to the new array at position [0]+1 relative to their original index
|
* @param existingArray the existing array to be copied to the new array at position [0]+1 relative to their original index
|
||||||
* @return the new array combining itemToAdd at the start and existing array elements following while retaining their order
|
* @return the new array combining itemToAdd at the start and existing array elements following while retaining their order
|
||||||
*/
|
*/
|
||||||
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
|
public static @NotNull String[] addItemToFirstPositionOfArray(@NotNull String itemToAdd, @NotNull String... existingArray) {
|
||||||
String[] newArray = new String[existingArray.length + 1];
|
String[] newArray = new String[existingArray.length + 1];
|
||||||
newArray[0] = itemToAdd;
|
newArray[0] = itemToAdd;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.random;
|
package com.gmail.nossr50.util.random;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
@ -327,7 +328,7 @@ public class RandomChanceUtil
|
|||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] calculateAbilityDisplayValuesStatic(Player player, PrimarySkillType primarySkillType, double chance) {
|
public static String[] calculateAbilityDisplayValuesStatic(@NotNull McMMOPlayer mmoPlayer, PrimarySkillType primarySkillType, double chance) {
|
||||||
RandomChanceStatic rcs = new RandomChanceStatic(chance, false);
|
RandomChanceStatic rcs = new RandomChanceStatic(chance, false);
|
||||||
double successChance = getRandomChanceExecutionChance(rcs);
|
double successChance = getRandomChanceExecutionChance(rcs);
|
||||||
|
|
||||||
@ -336,7 +337,7 @@ public class RandomChanceUtil
|
|||||||
|
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, primarySkillType);
|
boolean isLucky = Permissions.lucky(mmoPlayer.getPlayer(), primarySkillType);
|
||||||
|
|
||||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance_lucky, 100.0D) / 100.0D) : null;
|
displayValues[1] = isLucky ? percent.format(Math.min(successChance_lucky, 100.0D) / 100.0D) : null;
|
||||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.config.RankConfig;
|
import com.gmail.nossr50.config.RankConfig;
|
||||||
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
||||||
import com.gmail.nossr50.datatypes.json.McMMOWebLinks;
|
import com.gmail.nossr50.datatypes.json.McMMOWebLinks;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
@ -38,31 +39,31 @@ public class TextComponentFactory {
|
|||||||
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
|
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
|
||||||
* @param localeKey target locale string address
|
* @param localeKey target locale string address
|
||||||
* @param values vars to be passed to the locale loader
|
* @param values vars to be passed to the locale loader
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static TextComponent getNotificationMultipleValues(String localeKey, String... values)
|
public static TextComponent getNotificationMultipleValues(@NotNull String localeKey, String... values)
|
||||||
{
|
{
|
||||||
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
|
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
|
||||||
return Component.text(preColoredString);
|
return Component.text(preColoredString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component getNotificationTextComponentFromLocale(String localeKey)
|
public static Component getNotificationTextComponentFromLocale(@NotNull String localeKey)
|
||||||
{
|
{
|
||||||
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
|
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
|
public static Component getNotificationLevelUpTextComponent(@NotNull PrimarySkillType skill, int levelsGained, int currentLevel)
|
||||||
{
|
{
|
||||||
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+ StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+ StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent getNotificationTextComponent(String text)
|
private static TextComponent getNotificationTextComponent(@NotNull String text)
|
||||||
{
|
{
|
||||||
//textComponent.setColor(getNotificationColor(notificationType));
|
|
||||||
return Component.text(text);
|
return Component.text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted)
|
public static void sendPlayerSubSkillWikiLink(McMMOPlayer mmoPlayer, String subskillformatted)
|
||||||
{
|
{
|
||||||
if(!Config.getInstance().getUrlLinksEnabled())
|
if(!Config.getInstance().getUrlLinksEnabled())
|
||||||
return;
|
return;
|
||||||
@ -78,10 +79,10 @@ public class TextComponentFactory {
|
|||||||
|
|
||||||
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));
|
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));
|
||||||
|
|
||||||
mcMMO.getAudiences().player(player).sendMessage(Identity.nil(), wikiLinkComponent, MessageType.SYSTEM);
|
mcMMO.getAudiences().player(mmoPlayer.getPlayer()).sendMessage(Identity.nil(), wikiLinkComponent, MessageType.SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerUrlHeader(Player player) {
|
public static void sendPlayerUrlHeader(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
TextComponent prefix = Component.text(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
TextComponent prefix = Component.text(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
||||||
/*prefix.setColor(ChatColor.DARK_AQUA);*/
|
/*prefix.setColor(ChatColor.DARK_AQUA);*/
|
||||||
TextComponent suffix = Component.text(" "+LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
|
TextComponent suffix = Component.text(" "+LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
|
||||||
@ -89,7 +90,7 @@ public class TextComponentFactory {
|
|||||||
|
|
||||||
TextComponent emptySpace = Component.space();
|
TextComponent emptySpace = Component.space();
|
||||||
|
|
||||||
mcMMO.getAudiences().player(player).sendMessage(Identity.nil(),TextComponent.ofChildren(
|
mcMMO.getAudiences().player(mmoPlayer.getPlayer()).sendMessage(Identity.nil(),TextComponent.ofChildren(
|
||||||
prefix,
|
prefix,
|
||||||
getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
|
getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
|
||||||
emptySpace,
|
emptySpace,
|
||||||
@ -135,7 +136,7 @@ public class TextComponentFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getWebLinkTextComponent(McMMOWebLinks webLinks)
|
private static Component getWebLinkTextComponent(@NotNull McMMOWebLinks webLinks)
|
||||||
{
|
{
|
||||||
TextComponent.Builder webTextComponent;
|
TextComponent.Builder webTextComponent;
|
||||||
|
|
||||||
@ -181,7 +182,7 @@ public class TextComponentFactory {
|
|||||||
return webTextComponent.build();
|
return webTextComponent.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getUrlHoverEvent(McMMOWebLinks webLinks)
|
private static Component getUrlHoverEvent(@NotNull McMMOWebLinks webLinks)
|
||||||
{
|
{
|
||||||
TextComponent.Builder componentBuilder = Component.text().content(webLinks.getNiceTitle());
|
TextComponent.Builder componentBuilder = Component.text().content(webLinks.getNiceTitle());
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ public class TextComponentFactory {
|
|||||||
return componentBuilder.build();
|
return componentBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addUrlHeaderHover(McMMOWebLinks webLinks, TextComponent.Builder componentBuilder) {
|
private static void addUrlHeaderHover(@NotNull McMMOWebLinks webLinks, @NotNull TextComponent.Builder componentBuilder) {
|
||||||
componentBuilder.append(Component.newline());
|
componentBuilder.append(Component.newline());
|
||||||
componentBuilder.append(Component.text(webLinks.getUrl(), NamedTextColor.GRAY, TextDecoration.ITALIC));
|
componentBuilder.append(Component.text(webLinks.getUrl(), NamedTextColor.GRAY, TextDecoration.ITALIC));
|
||||||
}
|
}
|
||||||
@ -240,17 +241,17 @@ public class TextComponentFactory {
|
|||||||
return ClickEvent.openUrl(url);
|
return ClickEvent.openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getSubSkillTextComponent(Player player, SubSkillType subSkillType)
|
private static Component getSubSkillTextComponent(@NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkillType)
|
||||||
{
|
{
|
||||||
//Get skill name
|
//Get skill name
|
||||||
String skillName = subSkillType.getLocaleName();
|
String skillName = subSkillType.getLocaleName();
|
||||||
|
|
||||||
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(player, subSkillType);
|
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType);
|
||||||
|
|
||||||
TextComponent.Builder textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
|
TextComponent.Builder textComponent = initNewSkillTextComponent(mmoPlayer, skillName, subSkillType, skillUnlocked);
|
||||||
|
|
||||||
//Hover Event
|
//Hover Event
|
||||||
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, subSkillType));
|
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(mmoPlayer, subSkillType));
|
||||||
|
|
||||||
//Insertion
|
//Insertion
|
||||||
textComponent.insertion(skillName);
|
textComponent.insertion(skillName);
|
||||||
@ -258,7 +259,7 @@ public class TextComponentFactory {
|
|||||||
return textComponent.build();
|
return textComponent.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill)
|
private static TextComponent getSubSkillTextComponent(@NotNull McMMOPlayer mmoPlayer, @NotNull AbstractSubSkill abstractSubSkill)
|
||||||
{
|
{
|
||||||
//String key = abstractSubSkill.getConfigKeyName();
|
//String key = abstractSubSkill.getConfigKeyName();
|
||||||
String skillName = abstractSubSkill.getNiceName();
|
String skillName = abstractSubSkill.getNiceName();
|
||||||
@ -266,12 +267,12 @@ public class TextComponentFactory {
|
|||||||
//Setup Text Component
|
//Setup Text Component
|
||||||
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
|
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
|
||||||
|
|
||||||
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(player, subSkillType);
|
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType);
|
||||||
|
|
||||||
TextComponent.Builder textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
|
TextComponent.Builder textComponent = initNewSkillTextComponent(mmoPlayer, skillName, subSkillType, skillUnlocked);
|
||||||
|
|
||||||
//Hover Event
|
//Hover Event
|
||||||
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, abstractSubSkill));
|
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(mmoPlayer, abstractSubSkill));
|
||||||
|
|
||||||
//Insertion
|
//Insertion
|
||||||
textComponent.insertion(skillName);
|
textComponent.insertion(skillName);
|
||||||
@ -279,10 +280,10 @@ public class TextComponentFactory {
|
|||||||
return textComponent.build();
|
return textComponent.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent.Builder initNewSkillTextComponent(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
private static TextComponent.Builder initNewSkillTextComponent(@NotNull McMMOPlayer mmoPlayer, @NotNull String skillName, @NotNull SubSkillType subSkillType, boolean skillUnlocked) {
|
||||||
TextComponent.Builder textComponent;
|
TextComponent.Builder textComponent;
|
||||||
if (skillUnlocked) {
|
if (skillUnlocked) {
|
||||||
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
|
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(mmoPlayer, subSkillType) && subSkillType.getNumRanks() > 1)
|
||||||
textComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName));
|
textComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName));
|
||||||
else
|
else
|
||||||
textComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.SkillName", skillName));
|
textComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.SkillName", skillName));
|
||||||
@ -298,35 +299,29 @@ public class TextComponentFactory {
|
|||||||
return textComponent;
|
return textComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill)
|
private static Component getSubSkillHoverComponent(@NotNull McMMOPlayer mmoPlayer, @NotNull AbstractSubSkill abstractSubSkill)
|
||||||
{
|
{
|
||||||
return getSubSkillHoverEventJSON(abstractSubSkill, player);
|
return getSubSkillHoverEventJSON(abstractSubSkill, mmoPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Component getSubSkillHoverComponent(Player player, SubSkillType subSkillType)
|
private static Component getSubSkillHoverComponent(@NotNull McMMOPlayer mmoPlayer, SubSkillType subSkillType)
|
||||||
{
|
{
|
||||||
return getSubSkillHoverEventJSON(subSkillType, player);
|
return getSubSkillHoverEventJSON(subSkillType, mmoPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for the skill in the new skill system (Deriving from AbstractSubSkill)
|
* Used for the skill in the new skill system (Deriving from AbstractSubSkill)
|
||||||
* @param abstractSubSkill this subskill
|
* @param abstractSubSkill this subskill
|
||||||
* @param player the player who owns this subskill
|
* @param mmoPlayer the player who owns this subskill
|
||||||
* @return the hover basecomponent object for this subskill
|
* @return the hover basecomponent object for this subskill
|
||||||
*/
|
*/
|
||||||
private static Component getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player)
|
private static Component getSubSkillHoverEventJSON(@NotNull AbstractSubSkill abstractSubSkill, @NotNull McMMOPlayer mmoPlayer)
|
||||||
{
|
{
|
||||||
String skillName = abstractSubSkill.getNiceName();
|
String skillName = abstractSubSkill.getNiceName();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hover Event BaseComponent color table
|
* Hover Event BaseComponent color table
|
||||||
*/
|
*/
|
||||||
TextColor ccSubSkillHeader = NamedTextColor.GOLD;
|
|
||||||
TextColor ccRank = NamedTextColor.BLUE;
|
|
||||||
TextColor ccCurRank = NamedTextColor.GREEN;
|
|
||||||
TextColor ccPossessive = NamedTextColor.WHITE;
|
|
||||||
//ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
|
|
||||||
//ChatColor ccDescription = ChatColor.WHITE;
|
|
||||||
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
||||||
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
||||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||||
@ -334,9 +329,9 @@ public class TextComponentFactory {
|
|||||||
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
|
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
|
||||||
|
|
||||||
//SubSkillType Name
|
//SubSkillType Name
|
||||||
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, abstractSubSkill));
|
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(mmoPlayer, skillName, subSkillType, RankUtils.hasUnlockedSubskill(mmoPlayer, abstractSubSkill));
|
||||||
|
|
||||||
if(!RankUtils.hasUnlockedSubskill(player, abstractSubSkill))
|
if(!RankUtils.hasUnlockedSubskill(mmoPlayer, abstractSubSkill))
|
||||||
{
|
{
|
||||||
//Skill is not unlocked yet
|
//Skill is not unlocked yet
|
||||||
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
||||||
@ -344,7 +339,7 @@ public class TextComponentFactory {
|
|||||||
addSubSkillTypeToHoverEventJSON(abstractSubSkill, componentBuilder);
|
addSubSkillTypeToHoverEventJSON(abstractSubSkill, componentBuilder);
|
||||||
|
|
||||||
//RANK
|
//RANK
|
||||||
int curRank = RankUtils.getRank(player, abstractSubSkill);
|
int curRank = RankUtils.getRank(mmoPlayer, abstractSubSkill);
|
||||||
int nextRank = 0;
|
int nextRank = 0;
|
||||||
|
|
||||||
if(curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0)
|
if(curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0)
|
||||||
@ -352,7 +347,7 @@ public class TextComponentFactory {
|
|||||||
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
|
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
|
addRanked(componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(mmoPlayer, abstractSubSkill), nextRank);
|
||||||
|
|
||||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.DescriptionHeader")));
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.DescriptionHeader")));
|
||||||
componentBuilder.append(Component.newline()).append(Component.text(abstractSubSkill.getDescription())).append(Component.newline());
|
componentBuilder.append(Component.newline()).append(Component.text(abstractSubSkill.getDescription())).append(Component.newline());
|
||||||
@ -362,16 +357,16 @@ public class TextComponentFactory {
|
|||||||
componentBuilder.append(Component.newline());
|
componentBuilder.append(Component.newline());
|
||||||
|
|
||||||
//Finally, add details to the tooltip
|
//Finally, add details to the tooltip
|
||||||
abstractSubSkill.addStats(componentBuilder, player);
|
abstractSubSkill.addStats(componentBuilder, mmoPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentBuilder.build();
|
return componentBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent.Builder setupSkillComponentNameStyle(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
private static TextComponent.Builder setupSkillComponentNameStyle(@NotNull McMMOPlayer mmoPlayer, @NotNull String skillName, @NotNull SubSkillType subSkillType, boolean skillUnlocked) {
|
||||||
TextComponent.Builder componentBuilder;
|
TextComponent.Builder componentBuilder;
|
||||||
if (skillUnlocked) {
|
if (skillUnlocked) {
|
||||||
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
|
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(mmoPlayer, subSkillType) && subSkillType.getNumRanks() > 1)
|
||||||
componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName));
|
componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName));
|
||||||
else
|
else
|
||||||
componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.SkillName", skillName));
|
componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.SkillName", skillName));
|
||||||
@ -381,13 +376,13 @@ public class TextComponentFactory {
|
|||||||
return componentBuilder;
|
return componentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextComponent.Builder getNewComponentBuilder(String skillName) {
|
private static TextComponent.Builder getNewComponentBuilder(@NotNull String skillName) {
|
||||||
TextComponent.Builder componentBuilder = Component.text().content(skillName);
|
TextComponent.Builder componentBuilder = Component.text().content(skillName);
|
||||||
componentBuilder.append(Component.newline());
|
componentBuilder.append(Component.newline());
|
||||||
return componentBuilder;
|
return componentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addRanked(TextColor ccRank, TextColor ccCurRank, TextColor ccPossessive, TextColor ccNumRanks, TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
|
private static void addRanked(@NotNull TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
|
||||||
if (numRanks > 0) {
|
if (numRanks > 0) {
|
||||||
//Rank: x
|
//Rank: x
|
||||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank)))).append(Component.newline());
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank)))).append(Component.newline());
|
||||||
@ -395,32 +390,34 @@ public class TextComponentFactory {
|
|||||||
//Next Rank: x
|
//Next Rank: x
|
||||||
if(nextRank > rank)
|
if(nextRank > rank)
|
||||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank)))).append(Component.newline());
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank)))).append(Component.newline());
|
||||||
|
|
||||||
/*componentBuilder.append(" " + LocaleLoader.getString("JSON.RankPossesive") + " ").color(ccPossessive);
|
|
||||||
componentBuilder.append(String.valueOf(numRanks)).color(ccNumRanks);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addLocked(SubSkillType subSkillType, TextColor ccLocked, TextColor ccLevelRequirement, TextColor ccLevelRequired, TextComponent.Builder componentBuilder) {
|
private static void addLocked(@NotNull SubSkillType subSkillType, @NotNull TextColor ccLocked, @NotNull TextColor ccLevelRequirement,
|
||||||
|
@NotNull TextColor ccLevelRequired, @NotNull TextComponent.Builder componentBuilder) {
|
||||||
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
||||||
componentBuilder.append(Component.text(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, 1)), ccLevelRequired));
|
componentBuilder.append(Component.text(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, 1)), ccLevelRequired));
|
||||||
//componentBuilder.append(Component.newline());
|
//componentBuilder.append(Component.newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addLocked(AbstractSubSkill abstractSubSkill, TextColor ccLocked, TextColor ccLevelRequirement, TextColor ccLevelRequired, TextComponent.Builder componentBuilder) {
|
private static void addLocked(@NotNull AbstractSubSkill abstractSubSkill, @NotNull TextColor ccLocked,
|
||||||
|
@NotNull TextColor ccLevelRequirement, @NotNull TextColor ccLevelRequired,
|
||||||
|
@NotNull TextComponent.Builder componentBuilder) {
|
||||||
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
||||||
componentBuilder.append(Component.text(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, 1)), ccLevelRequired));
|
componentBuilder.append(Component.text(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, 1)), ccLevelRequired));
|
||||||
//componentBuilder.append(Component.newline());
|
//componentBuilder.append(Component.newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addLocked(TextColor ccLocked, TextColor ccLevelRequirement, TextComponent.Builder componentBuilder) {
|
private static void addLocked(@NotNull TextColor ccLocked,
|
||||||
|
@NotNull TextColor ccLevelRequirement,
|
||||||
|
@NotNull TextComponent.Builder componentBuilder) {
|
||||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Locked"), ccLocked, TextDecoration.BOLD));
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Locked"), ccLocked, TextDecoration.BOLD));
|
||||||
componentBuilder.append(Component.newline()).append(Component.newline());
|
componentBuilder.append(Component.newline()).append(Component.newline());
|
||||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.LevelRequirement") + ": ", ccLevelRequirement));
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.LevelRequirement") + ": ", ccLevelRequirement));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static Component getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player)
|
private static @NotNull Component getSubSkillHoverEventJSON(@NotNull SubSkillType subSkillType, @NotNull McMMOPlayer mmoPlayer)
|
||||||
{
|
{
|
||||||
String skillName = subSkillType.getLocaleName();
|
String skillName = subSkillType.getLocaleName();
|
||||||
|
|
||||||
@ -438,9 +435,9 @@ public class TextComponentFactory {
|
|||||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||||
|
|
||||||
//SubSkillType Name
|
//SubSkillType Name
|
||||||
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, subSkillType));
|
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(mmoPlayer, skillName, subSkillType, RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType));
|
||||||
|
|
||||||
if(!RankUtils.hasUnlockedSubskill(player, subSkillType))
|
if(!RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType))
|
||||||
{
|
{
|
||||||
//Skill is not unlocked yet
|
//Skill is not unlocked yet
|
||||||
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
||||||
@ -450,7 +447,7 @@ public class TextComponentFactory {
|
|||||||
//RANK
|
//RANK
|
||||||
if(subSkillType.getNumRanks() > 0)
|
if(subSkillType.getNumRanks() > 0)
|
||||||
{
|
{
|
||||||
int curRank = RankUtils.getRank(player, subSkillType);
|
int curRank = RankUtils.getRank(mmoPlayer, subSkillType);
|
||||||
int nextRank = 0;
|
int nextRank = 0;
|
||||||
|
|
||||||
if(curRank < subSkillType.getNumRanks())
|
if(curRank < subSkillType.getNumRanks())
|
||||||
@ -458,7 +455,7 @@ public class TextComponentFactory {
|
|||||||
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
|
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
|
addRanked(componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(mmoPlayer, subSkillType), nextRank);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,7 +470,7 @@ public class TextComponentFactory {
|
|||||||
return componentBuilder.build();
|
return componentBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, TextComponent.Builder componentBuilder)
|
private static void addSubSkillTypeToHoverEventJSON(@NotNull AbstractSubSkill abstractSubSkill, @NotNull TextComponent.Builder componentBuilder)
|
||||||
{
|
{
|
||||||
if(abstractSubSkill.isSuperAbility())
|
if(abstractSubSkill.isSuperAbility())
|
||||||
{
|
{
|
||||||
@ -488,7 +485,7 @@ public class TextComponentFactory {
|
|||||||
componentBuilder.append(Component.newline());
|
componentBuilder.append(Component.newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getSubSkillTextComponents(Player player, List<Component> textComponents, PrimarySkillType parentSkill) {
|
public static void getSubSkillTextComponents(@NotNull McMMOPlayer mmoPlayer, @NotNull List<Component> textComponents, @NotNull PrimarySkillType parentSkill) {
|
||||||
for(SubSkillType subSkillType : SubSkillType.values())
|
for(SubSkillType subSkillType : SubSkillType.values())
|
||||||
{
|
{
|
||||||
if(subSkillType.getParentSkill() == parentSkill)
|
if(subSkillType.getParentSkill() == parentSkill)
|
||||||
@ -498,10 +495,10 @@ public class TextComponentFactory {
|
|||||||
if(subSkillType == SubSkillType.FISHING_MASTER_ANGLER && mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
|
if(subSkillType == SubSkillType.FISHING_MASTER_ANGLER && mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(Permissions.isSubSkillEnabled(player, subSkillType))
|
if(Permissions.isSubSkillEnabled(mmoPlayer, subSkillType))
|
||||||
{
|
{
|
||||||
if(!InteractionManager.hasSubSkill(subSkillType))
|
if(!InteractionManager.hasSubSkill(subSkillType))
|
||||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
|
textComponents.add(TextComponentFactory.getSubSkillTextComponent(mmoPlayer, subSkillType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -511,16 +508,16 @@ public class TextComponentFactory {
|
|||||||
{
|
{
|
||||||
if(abstractSubSkill.getPrimarySkill() == parentSkill)
|
if(abstractSubSkill.getPrimarySkill() == parentSkill)
|
||||||
{
|
{
|
||||||
if(Permissions.isSubSkillEnabled(player, abstractSubSkill))
|
if(Permissions.isSubSkillEnabled(mmoPlayer, abstractSubSkill))
|
||||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, abstractSubSkill));
|
textComponents.add(TextComponentFactory.getSubSkillTextComponent(mmoPlayer, abstractSubSkill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType)
|
public static @NotNull TextComponent getSubSkillUnlockedNotificationComponents(@NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkillType)
|
||||||
{
|
{
|
||||||
TextComponent.Builder unlockMessage = Component.text().content(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType)));
|
TextComponent.Builder unlockMessage = Component.text().content(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(mmoPlayer, subSkillType)));
|
||||||
unlockMessage.hoverEvent(HoverEvent.showText(getSubSkillHoverComponent(player, subSkillType)));
|
unlockMessage.hoverEvent(HoverEvent.showText(getSubSkillHoverComponent(mmoPlayer, subSkillType)));
|
||||||
unlockMessage.clickEvent(ClickEvent.runCommand("/"+subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
|
unlockMessage.clickEvent(ClickEvent.runCommand("/"+subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
|
||||||
return unlockMessage.build();
|
return unlockMessage.build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user