From d3c47935d4a916b24b23e28a0905bc64539e1a7d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 12 Jan 2019 19:56:54 -0800 Subject: [PATCH] Some refactoring --- .../com/gmail/nossr50/api/AbilityAPI.java | 32 +++---- .../commands/player/MccooldownCommand.java | 4 +- .../java/com/gmail/nossr50/config/Config.java | 6 +- .../database/FlatfileDatabaseManager.java | 36 ++++---- .../nossr50/database/SQLDatabaseManager.java | 36 ++++---- .../nossr50/datatypes/player/McMMOPlayer.java | 56 ++++++------ .../datatypes/player/PlayerProfile.java | 20 ++--- .../datatypes/skills/PrimarySkill.java | 22 ++--- .../datatypes/skills/SubSkillType.java | 2 +- ...uperAbility.java => SuperAbilityType.java} | 5 +- .../skills/subskills/acrobatics/Roll.java | 6 +- .../abilities/McMMOPlayerAbilityEvent.java | 6 +- .../nossr50/listeners/BlockListener.java | 16 ++-- .../nossr50/listeners/InteractionManager.java | 83 ----------------- .../nossr50/listeners/PlayerListener.java | 5 +- .../runnables/skills/AbilityCooldownTask.java | 10 +-- .../runnables/skills/AbilityDisableTask.java | 10 +-- .../runnables/skills/ToolLowerTask.java | 4 +- .../nossr50/skills/axes/AxesManager.java | 4 +- .../skills/herbalism/HerbalismManager.java | 4 +- .../nossr50/skills/mining/MiningManager.java | 19 ++-- .../nossr50/skills/swords/SwordsManager.java | 4 +- .../nossr50/skills/taming/TamingManager.java | 4 +- .../skills/unarmed/UnarmedManager.java | 4 +- .../woodcutting/WoodcuttingManager.java | 4 +- .../com/gmail/nossr50/util/EventUtils.java | 4 +- .../com/gmail/nossr50/util/StringUtils.java | 5 +- .../util/player/NotificationManager.java | 88 +++++++++++++++++++ .../util/scoreboards/ScoreboardManager.java | 18 ++-- .../util/scoreboards/ScoreboardWrapper.java | 14 +-- .../gmail/nossr50/util/skills/SkillUtils.java | 9 +- .../resources/locale/locale_en_US.properties | 2 +- 32 files changed, 271 insertions(+), 271 deletions(-) rename src/main/java/com/gmail/nossr50/datatypes/skills/{SuperAbility.java => SuperAbilityType.java} (96%) create mode 100644 src/main/java/com/gmail/nossr50/util/player/NotificationManager.java diff --git a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java index 5571ceba3..bf52a284d 100644 --- a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java +++ b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.api; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -12,37 +12,37 @@ public final class AbilityAPI { private AbilityAPI() {} public static boolean berserkEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.BERSERK); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK); } public static boolean gigaDrillBreakerEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.GIGA_DRILL_BREAKER); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER); } public static boolean greenTerraEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.GREEN_TERRA); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA); } public static boolean serratedStrikesEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.SERRATED_STRIKES); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES); } public static boolean skullSplitterEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.SKULL_SPLITTER); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER); } public static boolean superBreakerEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.SUPER_BREAKER); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER); } public static boolean treeFellerEnabled(Player player) { - return UserManager.getPlayer(player).getAbilityMode(SuperAbility.TREE_FELLER); + return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER); } public static boolean isAnyAbilityEnabled(Player player) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - for (SuperAbility ability : SuperAbility.values()) { + for (SuperAbilityType ability : SuperAbilityType.values()) { if (mcMMOPlayer.getAbilityMode(ability)) { return true; } @@ -56,31 +56,31 @@ public final class AbilityAPI { } public static void setBerserkCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.BERSERK, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown); } public static void setGigaDrillBreakerCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.GIGA_DRILL_BREAKER, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown); } public static void setGreenTerraCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.GREEN_TERRA, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown); } public static void setSerratedStrikesCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.SERRATED_STRIKES, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown); } public static void setSkullSplitterCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.SKULL_SPLITTER, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown); } public static void setSuperBreakerCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.SUPER_BREAKER, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown); } public static void setTreeFellerCooldown(Player player, long cooldown) { - UserManager.getPlayer(player).setAbilityDATS(SuperAbility.TREE_FELLER, cooldown); + UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown); } public static boolean isBleeding(LivingEntity entity) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index 1e6a306b4..960fcd63b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.player; import java.util.List; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; @@ -45,7 +45,7 @@ public class MccooldownCommand implements TabExecutor { player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); - for (SuperAbility ability : SuperAbility.values()) { + for (SuperAbilityType ability : SuperAbilityType.values()) { if (!ability.getPermissions(player)) { continue; } diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 102753bf8..cdc788173 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.config; import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier; import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.party.PartyFeature; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.util.StringUtils; import org.bukkit.Material; @@ -454,8 +454,8 @@ public class Config extends AutoUpdateConfigLoader { public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); } public boolean getAbilitiesGateEnabled() { return config.getBoolean("Abilities.Activation.Level_Gate_Abilities"); } - public int getCooldown(SuperAbility ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); } - public int getMaxLength(SuperAbility ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); } + public int getCooldown(SuperAbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); } + public int getMaxLength(SuperAbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); } /* Durability Settings */ public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); } diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index e8ac13d03..8be546a07 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -19,7 +19,7 @@ import java.util.UUID; import com.gmail.nossr50.datatypes.player.UniqueDataType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.OfflinePlayer; import com.gmail.nossr50.mcMMO; @@ -348,17 +348,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager { writer.append(":"); writer.append(profile.getSkillLevel(PrimarySkill.TAMING)).append(":"); writer.append(profile.getSkillXpLevel(PrimarySkill.TAMING)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.BERSERK)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.GIGA_DRILL_BREAKER)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.TREE_FELLER)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.GREEN_TERRA)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.SERRATED_STRIKES)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.SKULL_SPLITTER)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.SUPER_BREAKER)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.BERSERK)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.TREE_FELLER)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.GREEN_TERRA)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.SERRATED_STRIKES)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER)).append(":"); writer.append(":"); writer.append(profile.getSkillLevel(PrimarySkill.FISHING)).append(":"); writer.append(profile.getSkillXpLevel(PrimarySkill.FISHING)).append(":"); - writer.append((int) profile.getAbilityDATS(SuperAbility.BLAST_MINING)).append(":"); + writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":"); writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":"); @@ -1145,7 +1145,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { private PlayerProfile loadFromLine(String[] character) { Map skills = getSkillMapFromLine(character); // Skill levels Map skillsXp = new EnumMap(PrimarySkill.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbility.class); // Ability & Cooldown + Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown Map uniquePlayerDataMap = new EnumMap(UniqueDataType.class); MobHealthbarType mobHealthbarType; int scoreboardTipsShown; @@ -1167,17 +1167,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager { skillsXp.put(PrimarySkill.ALCHEMY, (float) Integer.valueOf(character[EXP_ALCHEMY])); // Taming - Unused - skillsDATS.put(SuperAbility.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER])); + skillsDATS.put(SuperAbilityType.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER])); // Repair - Unused - skillsDATS.put(SuperAbility.TREE_FELLER, Integer.valueOf(character[COOLDOWN_TREE_FELLER])); - skillsDATS.put(SuperAbility.BERSERK, Integer.valueOf(character[COOLDOWN_BERSERK])); - skillsDATS.put(SuperAbility.GREEN_TERRA, Integer.valueOf(character[COOLDOWN_GREEN_TERRA])); - skillsDATS.put(SuperAbility.GIGA_DRILL_BREAKER, Integer.valueOf(character[COOLDOWN_GIGA_DRILL_BREAKER])); + skillsDATS.put(SuperAbilityType.TREE_FELLER, Integer.valueOf(character[COOLDOWN_TREE_FELLER])); + skillsDATS.put(SuperAbilityType.BERSERK, Integer.valueOf(character[COOLDOWN_BERSERK])); + skillsDATS.put(SuperAbilityType.GREEN_TERRA, Integer.valueOf(character[COOLDOWN_GREEN_TERRA])); + skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[COOLDOWN_GIGA_DRILL_BREAKER])); // Archery - Unused - skillsDATS.put(SuperAbility.SERRATED_STRIKES, Integer.valueOf(character[COOLDOWN_SERRATED_STRIKES])); - skillsDATS.put(SuperAbility.SKULL_SPLITTER, Integer.valueOf(character[COOLDOWN_SKULL_SPLITTER])); + skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, Integer.valueOf(character[COOLDOWN_SERRATED_STRIKES])); + skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, Integer.valueOf(character[COOLDOWN_SKULL_SPLITTER])); // Acrobatics - Unused - skillsDATS.put(SuperAbility.BLAST_MINING, Integer.valueOf(character[COOLDOWN_BLAST_MINING])); + skillsDATS.put(SuperAbilityType.BLAST_MINING, Integer.valueOf(character[COOLDOWN_BLAST_MINING])); try { mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]); diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 526f07a52..40d491568 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.UpgradeType; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.UniqueDataType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask; @@ -289,14 +289,14 @@ public final class SQLDatabaseManager implements DatabaseManager { + " mining = ?, woodcutting = ?, unarmed = ?" + ", herbalism = ?, excavation = ?, swords = ?" + ", axes = ?, blast_mining = ?, chimaera_wing = ? WHERE user_id = ?"); - statement.setLong(1, profile.getAbilityDATS(SuperAbility.SUPER_BREAKER)); - statement.setLong(2, profile.getAbilityDATS(SuperAbility.TREE_FELLER)); - statement.setLong(3, profile.getAbilityDATS(SuperAbility.BERSERK)); - statement.setLong(4, profile.getAbilityDATS(SuperAbility.GREEN_TERRA)); - statement.setLong(5, profile.getAbilityDATS(SuperAbility.GIGA_DRILL_BREAKER)); - statement.setLong(6, profile.getAbilityDATS(SuperAbility.SERRATED_STRIKES)); - statement.setLong(7, profile.getAbilityDATS(SuperAbility.SKULL_SPLITTER)); - statement.setLong(8, profile.getAbilityDATS(SuperAbility.BLAST_MINING)); + statement.setLong(1, profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER)); + statement.setLong(2, profile.getAbilityDATS(SuperAbilityType.TREE_FELLER)); + statement.setLong(3, profile.getAbilityDATS(SuperAbilityType.BERSERK)); + statement.setLong(4, profile.getAbilityDATS(SuperAbilityType.GREEN_TERRA)); + statement.setLong(5, profile.getAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER)); + statement.setLong(6, profile.getAbilityDATS(SuperAbilityType.SERRATED_STRIKES)); + statement.setLong(7, profile.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER)); + statement.setLong(8, profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)); statement.setLong(9, profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS)); statement.setInt(10, id); success = (statement.executeUpdate() != 0); @@ -1054,7 +1054,7 @@ public final class SQLDatabaseManager implements DatabaseManager { private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { Map skills = new EnumMap(PrimarySkill.class); // Skill & Level Map skillsXp = new EnumMap(PrimarySkill.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbility.class); // Ability & Cooldown + Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown Map uniqueData = new EnumMap(UniqueDataType.class); //Chimaera wing cooldown and other misc info MobHealthbarType mobHealthbarType; UUID uuid; @@ -1095,17 +1095,17 @@ public final class SQLDatabaseManager implements DatabaseManager { skillsXp.put(PrimarySkill.ALCHEMY, result.getFloat(OFFSET_XP + 13)); // Taming - Unused - result.getInt(OFFSET_DATS + 1) - skillsDATS.put(SuperAbility.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2)); + skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2)); // Repair - Unused - result.getInt(OFFSET_DATS + 3) - skillsDATS.put(SuperAbility.TREE_FELLER, result.getInt(OFFSET_DATS + 4)); - skillsDATS.put(SuperAbility.BERSERK, result.getInt(OFFSET_DATS + 5)); - skillsDATS.put(SuperAbility.GREEN_TERRA, result.getInt(OFFSET_DATS + 6)); - skillsDATS.put(SuperAbility.GIGA_DRILL_BREAKER, result.getInt(OFFSET_DATS + 7)); + skillsDATS.put(SuperAbilityType.TREE_FELLER, result.getInt(OFFSET_DATS + 4)); + skillsDATS.put(SuperAbilityType.BERSERK, result.getInt(OFFSET_DATS + 5)); + skillsDATS.put(SuperAbilityType.GREEN_TERRA, result.getInt(OFFSET_DATS + 6)); + skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, result.getInt(OFFSET_DATS + 7)); // Archery - Unused - result.getInt(OFFSET_DATS + 8) - skillsDATS.put(SuperAbility.SERRATED_STRIKES, result.getInt(OFFSET_DATS + 9)); - skillsDATS.put(SuperAbility.SKULL_SPLITTER, result.getInt(OFFSET_DATS + 10)); + skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, result.getInt(OFFSET_DATS + 9)); + skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, result.getInt(OFFSET_DATS + 10)); // Acrobatics - Unused - result.getInt(OFFSET_DATS + 11) - skillsDATS.put(SuperAbility.BLAST_MINING, result.getInt(OFFSET_DATS + 12)); + skillsDATS.put(SuperAbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12)); uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_DATS + 13)); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 79a01872a..2ad945c44 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -8,11 +8,10 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.XPGainReason; -import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.party.PartyManager; @@ -40,6 +39,7 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -50,7 +50,6 @@ import com.gmail.nossr50.util.sounds.SoundType; import org.apache.commons.lang.Validate; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; @@ -81,8 +80,8 @@ public class McMMOPlayer { private boolean godMode; private boolean chatSpy = false; //Off by default - private final Map abilityMode = new HashMap(); - private final Map abilityInformed = new HashMap(); + private final Map abilityMode = new HashMap(); + private final Map abilityInformed = new HashMap(); private final Map toolMode = new HashMap(); @@ -123,9 +122,9 @@ public class McMMOPlayer { mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p); } - for (SuperAbility superAbility : SuperAbility.values()) { - abilityMode.put(superAbility, false); - abilityInformed.put(superAbility, true); // This is intended + for (SuperAbilityType superAbilityType : SuperAbilityType.values()) { + abilityMode.put(superAbilityType, false); + abilityInformed.put(superAbilityType, true); // This is intended } for (ToolType toolType : ToolType.values()) { @@ -201,7 +200,7 @@ public class McMMOPlayer { * Reset the mode of all abilities. */ public void resetAbilityMode() { - for (SuperAbility ability : SuperAbility.values()) { + for (SuperAbilityType ability : SuperAbilityType.values()) { // Correctly disable and handle any special deactivate code new AbilityDisableTask(this, ability).run(); } @@ -213,7 +212,7 @@ public class McMMOPlayer { * @param ability The ability to check * @return true if the ability is enabled, false otherwise */ - public boolean getAbilityMode(SuperAbility ability) { + public boolean getAbilityMode(SuperAbilityType ability) { return abilityMode.get(ability); } @@ -223,7 +222,7 @@ public class McMMOPlayer { * @param ability The ability to check * @param isActive True if the ability is active, false otherwise */ - public void setAbilityMode(SuperAbility ability, boolean isActive) { + public void setAbilityMode(SuperAbilityType ability, boolean isActive) { abilityMode.put(ability, isActive); } @@ -233,7 +232,7 @@ public class McMMOPlayer { * @param ability The ability to check * @return true if the ability is informed, false otherwise */ - public boolean getAbilityInformed(SuperAbility ability) { + public boolean getAbilityInformed(SuperAbilityType ability) { return abilityInformed.get(ability); } @@ -243,7 +242,7 @@ public class McMMOPlayer { * @param ability The ability to check * @param isInformed True if the ability is informed, false otherwise */ - public void setAbilityInformed(SuperAbility ability, boolean isInformed) { + public void setAbilityInformed(SuperAbilityType ability, boolean isInformed) { abilityInformed.put(ability, isInformed); } @@ -517,8 +516,7 @@ public class McMMOPlayer { SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP); } - InteractionManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkill, profile.getSkillLevel(primarySkill)); - //player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(primarySkill.toString()) + ".Skillup", levelsGained, getSkillLevel(primarySkill))); + NotificationManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkill, profile.getSkillLevel(primarySkill)); } /* @@ -731,7 +729,7 @@ public class McMMOPlayer { */ public void checkAbilityActivation(PrimarySkill skill) { ToolType tool = skill.getTool(); - SuperAbility ability = skill.getAbility(); + SuperAbilityType ability = skill.getAbility(); if (getAbilityMode(ability)) { return; @@ -744,8 +742,10 @@ public class McMMOPlayer { { if(getSkillLevel(skill) < skill.getSkillAbilityGate()) { + int diff = skill.getSkillAbilityGate() - getSkillLevel(skill); + //Inform the player they are not yet skilled enough - player.sendMessage(LocaleLoader.getString("Skills.AbilityGateRequirementFail")); + NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), skill.getName()); return; } } @@ -758,7 +758,7 @@ public class McMMOPlayer { * We show them the too tired message when they take action. */ if (skill == PrimarySkill.WOODCUTTING || skill == PrimarySkill.AXES) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); + NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); } return; @@ -774,7 +774,7 @@ public class McMMOPlayer { ParticleEffectUtils.playAbilityEnabledEffect(player); if (useChatNotifications()) { - InteractionManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn()); + NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn()); //player.sendMessage(ability.getAbilityOn()); } @@ -784,7 +784,7 @@ public class McMMOPlayer { profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); setAbilityMode(ability, true); - if (ability == SuperAbility.SUPER_BREAKER || ability == SuperAbility.GIGA_DRILL_BREAKER) { + if (ability == SuperAbilityType.SUPER_BREAKER || ability == SuperAbilityType.GIGA_DRILL_BREAKER) { SkillUtils.handleAbilitySpeedIncrease(player); } @@ -807,13 +807,13 @@ public class McMMOPlayer { return; } - for (SuperAbility superAbility : SuperAbility.values()) { - if (getAbilityMode(superAbility)) { + for (SuperAbilityType superAbilityType : SuperAbilityType.values()) { + if (getAbilityMode(superAbilityType)) { return; } } - SuperAbility ability = skill.getAbility(); + SuperAbilityType ability = skill.getAbility(); ToolType tool = skill.getTool(); /* @@ -825,13 +825,13 @@ public class McMMOPlayer { int timeRemaining = calculateTimeRemaining(ability); if (!getAbilityMode(ability) && timeRemaining > 0) { - InteractionManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); + NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); return; } } if (Config.getInstance().getAbilityMessagesEnabled()) { - InteractionManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); + NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); } setToolPreparationMode(tool, true); @@ -842,11 +842,11 @@ public class McMMOPlayer { /** * Calculate the time remaining until the ability's cooldown expires. * - * @param ability SuperAbility whose cooldown to check + * @param ability SuperAbilityType whose cooldown to check * * @return the number of seconds remaining before the cooldown expires */ - public int calculateTimeRemaining(SuperAbility ability) { + public int calculateTimeRemaining(SuperAbilityType ability) { long deactivatedTimestamp = profile.getAbilityDATS(ability) * Misc.TIME_CONVERSION_FACTOR; return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR); } @@ -894,7 +894,7 @@ public class McMMOPlayer { profile.addXp(skill, xp); } - public void setAbilityDATS(SuperAbility ability, long DATS) { + public void setAbilityDATS(SuperAbilityType ability, long DATS) { profile.setAbilityDATS(ability, DATS); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 8b7cf13d0..16c1d9d14 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -7,7 +7,7 @@ import java.util.UUID; import java.util.concurrent.DelayQueue; import com.gmail.nossr50.datatypes.skills.PrimarySkill; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig; @@ -33,7 +33,7 @@ public class PlayerProfile { /* Skill Data */ private final Map skills = new HashMap(); // Skill & Level private final Map skillsXp = new HashMap(); // Skill & XP - private final Map abilityDATS = new HashMap(); // Ability & Cooldown + private final Map abilityDATS = new HashMap(); // Ability & Cooldown private final Map uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..) // Store previous XP gains for deminished returns @@ -52,8 +52,8 @@ public class PlayerProfile { mobHealthbarType = Config.getInstance().getMobHealthbarDefault(); scoreboardTipsShown = 0; - for (SuperAbility superAbility : SuperAbility.values()) { - abilityDATS.put(superAbility, 0); + for (SuperAbilityType superAbilityType : SuperAbilityType.values()) { + abilityDATS.put(superAbilityType, 0); } for (PrimarySkill primarySkill : PrimarySkill.NON_CHILD_SKILLS) { @@ -76,7 +76,7 @@ public class PlayerProfile { this.loaded = isLoaded; } - public PlayerProfile(String playerName, UUID uuid, Map levelData, Map xpData, Map cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown, Map uniqueProfileData) { + public PlayerProfile(String playerName, UUID uuid, Map levelData, Map xpData, Map cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown, Map uniqueProfileData) { this.playerName = playerName; this.uuid = uuid; this.mobHealthbarType = mobHealthbarType; @@ -175,20 +175,20 @@ public class PlayerProfile { /** * Get the current deactivation timestamp of an ability. * - * @param ability The {@link SuperAbility} to get the DATS for + * @param ability The {@link SuperAbilityType} to get the DATS for * @return the deactivation timestamp for the ability */ - public long getAbilityDATS(SuperAbility ability) { + public long getAbilityDATS(SuperAbilityType ability) { return abilityDATS.get(ability); } /** * Set the current deactivation timestamp of an ability. * - * @param ability The {@link SuperAbility} to set the DATS for + * @param ability The {@link SuperAbilityType} to set the DATS for * @param DATS the DATS of the ability */ - protected void setAbilityDATS(SuperAbility ability, long DATS) { + protected void setAbilityDATS(SuperAbilityType ability, long DATS) { changed = true; abilityDATS.put(ability, (int) (DATS * .001D)); @@ -200,7 +200,7 @@ public class PlayerProfile { protected void resetCooldowns() { changed = true; - for (SuperAbility ability : abilityDATS.keySet()) { + for (SuperAbilityType ability : abilityDATS.keySet()) { abilityDATS.put(ability, 0); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkill.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkill.java index 73eebbb02..738435b42 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkill.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkill.java @@ -39,22 +39,22 @@ public enum PrimarySkill { ACROBATICS(AcrobaticsManager.class, Color.WHITE, ImmutableList.of(SubSkillType.ACROBATICS_DODGE, SubSkillType.ACROBATICS_ROLL)), ALCHEMY(AlchemyManager.class, Color.FUCHSIA, ImmutableList.of(SubSkillType.ALCHEMY_CATALYSIS, SubSkillType.ALCHEMY_CONCOCTIONS)), ARCHERY(ArcheryManager.class, Color.MAROON, ImmutableList.of(SubSkillType.ARCHERY_DAZE, SubSkillType.ARCHERY_ARROW_RETRIEVAL, SubSkillType.ARCHERY_SKILL_SHOT)), - AXES(AxesManager.class, Color.AQUA, SuperAbility.SKULL_SPLITTER, ToolType.AXE, ImmutableList.of(SubSkillType.AXES_SKULL_SPLITTER, SubSkillType.AXES_ARMOR_IMPACT, SubSkillType.AXES_AXE_MASTERY, SubSkillType.AXES_CRITICAL_STRIKES, SubSkillType.AXES_GREATER_IMPACT)), - EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), SuperAbility.GIGA_DRILL_BREAKER, ToolType.SHOVEL, ImmutableList.of(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, SubSkillType.EXCAVATION_TREASURE_HUNTER)), + AXES(AxesManager.class, Color.AQUA, SuperAbilityType.SKULL_SPLITTER, ToolType.AXE, ImmutableList.of(SubSkillType.AXES_SKULL_SPLITTER, SubSkillType.AXES_ARMOR_IMPACT, SubSkillType.AXES_AXE_MASTERY, SubSkillType.AXES_CRITICAL_STRIKES, SubSkillType.AXES_GREATER_IMPACT)), + EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), SuperAbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL, ImmutableList.of(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, SubSkillType.EXCAVATION_TREASURE_HUNTER)), FISHING(FishingManager.class, Color.NAVY, ImmutableList.of(SubSkillType.FISHING_FISHERMANS_DIET, SubSkillType.FISHING_TREASURE_HUNTER, SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_MAGIC_HUNTER, SubSkillType.FISHING_MASTER_ANGLER, SubSkillType.FISHING_SHAKE)), - HERBALISM(HerbalismManager.class, Color.GREEN, SuperAbility.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SubSkillType.HERBALISM_FARMERS_DIET, SubSkillType.HERBALISM_GREEN_THUMB, SubSkillType.HERBALISM_DOUBLE_DROPS, SubSkillType.HERBALISM_HYLIAN_LUCK, SubSkillType.HERBALISM_SHROOM_THUMB)), - MINING(MiningManager.class, Color.GRAY, SuperAbility.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SubSkillType.MINING_SUPER_BREAKER, SubSkillType.MINING_DEMOLITIONS_EXPERTISE, SubSkillType.MINING_BIGGER_BOMBS, SubSkillType.MINING_BLAST_MINING, SubSkillType.MINING_DOUBLE_DROPS)), + HERBALISM(HerbalismManager.class, Color.GREEN, SuperAbilityType.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SubSkillType.HERBALISM_FARMERS_DIET, SubSkillType.HERBALISM_GREEN_THUMB, SubSkillType.HERBALISM_DOUBLE_DROPS, SubSkillType.HERBALISM_HYLIAN_LUCK, SubSkillType.HERBALISM_SHROOM_THUMB)), + MINING(MiningManager.class, Color.GRAY, SuperAbilityType.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SubSkillType.MINING_SUPER_BREAKER, SubSkillType.MINING_DEMOLITIONS_EXPERTISE, SubSkillType.MINING_BIGGER_BOMBS, SubSkillType.MINING_BLAST_MINING, SubSkillType.MINING_DOUBLE_DROPS)), REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_REPAIR_MASTERY, SubSkillType.REPAIR_SUPER_REPAIR)), SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SubSkillType.SALVAGE_ADVANCED_SALVAGE, SubSkillType.SALVAGE_ARCANE_SALVAGE)), SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SubSkillType.SMELTING_FLUX_MINING, SubSkillType.SMELTING_FUEL_EFFICIENCY, SubSkillType.SMELTING_SECOND_SMELT)), - SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), SuperAbility.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SubSkillType.SWORDS_SERRATED_STRIKES, SubSkillType.SWORDS_BLEED, SubSkillType.SWORDS_COUNTER_ATTACK)), + SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), SuperAbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SubSkillType.SWORDS_SERRATED_STRIKES, SubSkillType.SWORDS_BLEED, SubSkillType.SWORDS_COUNTER_ATTACK)), TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SubSkillType.TAMING_BEAST_LORE, SubSkillType.TAMING_CALL_OF_THE_WILD, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE, SubSkillType.TAMING_FAST_FOOD_SERVICE, SubSkillType.TAMING_GORE, SubSkillType.TAMING_HOLY_HOUND, SubSkillType.TAMING_SHARPENED_CLAWS, SubSkillType.TAMING_SHOCK_PROOF, SubSkillType.TAMING_THICK_FUR, SubSkillType.TAMING_PUMMEL)), - UNARMED(UnarmedManager.class, Color.BLACK, SuperAbility.BERSERK, ToolType.FISTS, ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_IRON_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)), - WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbility.TREE_FELLER, ToolType.AXE, ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_BARK_SURGEON, SubSkillType.WOODCUTTING_SPLINTER, SubSkillType.WOODCUTTING_NATURES_BOUNTY, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)); + UNARMED(UnarmedManager.class, Color.BLACK, SuperAbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_IRON_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)), + WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_BARK_SURGEON, SubSkillType.WOODCUTTING_SPLINTER, SubSkillType.WOODCUTTING_NATURES_BOUNTY, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)); private Class managerClass; private Color runescapeColor; - private SuperAbility ability; + private SuperAbilityType ability; private ToolType tool; private List subSkillTypes; @@ -101,7 +101,7 @@ public enum PrimarySkill { this(managerClass, runescapeColor, null, null, subSkillTypes); } - private PrimarySkill(Class managerClass, Color runescapeColor, SuperAbility ability, ToolType tool, List subSkillTypes) { + private PrimarySkill(Class managerClass, Color runescapeColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { this.managerClass = managerClass; this.runescapeColor = runescapeColor; this.ability = ability; @@ -113,7 +113,7 @@ public enum PrimarySkill { return managerClass; } - public SuperAbility getAbility() { + public SuperAbilityType getAbility() { return ability; } @@ -211,7 +211,7 @@ public enum PrimarySkill { return null; } - public static PrimarySkill byAbility(SuperAbility ability) { + public static PrimarySkill byAbility(SuperAbilityType ability) { for (PrimarySkill type : values()) { if (type.getAbility() == ability) { return type; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index f7e1b9675..611acd1bb 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -100,7 +100,7 @@ public enum SubSkillType { WOODCUTTING_HARVEST_LUMBER(3); private final int numRanks; - //TODO: SuperAbility should also contain flags for active by default? Not sure if it should work that way. + //TODO: SuperAbilityType should also contain flags for active by default? Not sure if it should work that way. /** * If our SubSkillType has more than 1 rank define it diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbility.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java similarity index 96% rename from src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbility.java rename to src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index b057533c6..694b859b4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbility.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -5,12 +5,11 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -public enum SuperAbility { +public enum SuperAbilityType { BERSERK( "Unarmed.Skills.Berserk.On", "Unarmed.Skills.Berserk.Off", @@ -77,7 +76,7 @@ public enum SuperAbility { private String abilityRefresh; private String abilityPlayerOff; - private SuperAbility(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + private SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { this.abilityOn = abilityOn; this.abilityOff = abilityOff; this.abilityPlayer = abilityPlayer; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index 7890a9b6c..237c74928 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -8,13 +8,13 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.XPGainReason; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.RandomChance; -import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillActivationType; @@ -217,7 +217,7 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance { double modifiedDamage = calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); if (!isFatal(player, modifiedDamage) && SkillUtils.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player, getPrimarySkill(), skillLevel, getActivationChance(mcMMOPlayer))) { - InteractionManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); + NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); //player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) { @@ -251,7 +251,7 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance { double modifiedDamage = calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); if (!isFatal(player, modifiedDamage) && SkillUtils.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player, getPrimarySkill(), skillLevel, getActivationChance(mcMMOPlayer))) { - InteractionManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); + NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); return modifiedDamage; diff --git a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java index 6b88fb024..b2dd7656c 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java @@ -1,20 +1,20 @@ package com.gmail.nossr50.events.skills.abilities; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.entity.Player; -import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent { - private SuperAbility ability; + private SuperAbilityType ability; protected McMMOPlayerAbilityEvent(Player player, PrimarySkill skill) { super(player, skill); ability = skill.getAbility(); } - public SuperAbility getAbility() { + public SuperAbilityType getAbility() { return ability; } } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 0358ab505..d5f94dd50 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; @@ -244,7 +244,7 @@ public class BlockListener implements Listener { ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); excavationManager.excavationBlockCheck(blockState); - if (mcMMOPlayer.getAbilityMode(SuperAbility.GIGA_DRILL_BREAKER)) { + if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) { excavationManager.gigaDrillBreaker(blockState); } } @@ -334,12 +334,12 @@ public class BlockListener implements Listener { ItemStack heldItem = player.getInventory().getItemInMainHand(); if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbility.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbility.GIGA_DRILL_BREAKER))) { + if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) { SkillUtils.removeAbilityBuff(heldItem); } } else { - if ((mcMMOPlayer.getAbilityMode(SuperAbility.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbility.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { + if ((mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { SkillUtils.handleAbilitySpeedDecrease(player); } } @@ -366,7 +366,7 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (mcMMOPlayer.getAbilityMode(SuperAbility.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) { + if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) { SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ); } } @@ -398,13 +398,13 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (mcMMOPlayer.getAbilityMode(SuperAbility.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) { + if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) { if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) { blockState.update(true); } } - else if (mcMMOPlayer.getAbilityMode(SuperAbility.BERSERK) && heldItem.getType() == Material.AIR) { - if (SuperAbility.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) { + else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) { + if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) { event.setInstaBreak(true); SoundManager.sendSound(player, block.getLocation(), SoundType.POP); } diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index c243c25d3..a2b1dd01d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -1,22 +1,10 @@ package com.gmail.nossr50.listeners; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction; -import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.TextComponentFactory; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; import org.bukkit.event.Event; import java.util.ArrayList; @@ -91,77 +79,6 @@ public class InteractionManager { } } - /** - * Sends players notifications from mcMMO - * This does this by sending out an event so other plugins can cancel it - * @param player target player - * @param notificationType notifications defined type - * @param key the locale key for the notifications defined message - */ - public static void sendPlayerInformation(Player player, NotificationType notificationType, String key) - { - - ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; - - TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType); - McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); - - sendNotification(player, customEvent); - } - - public static void sendOtherPlayersSkillInfo(Player source, NotificationType notificationType, String key, String... values) - { - Location location = source.getLocation(); - for (Player otherPlayer : source.getWorld().getPlayers()) { - if (otherPlayer != source && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - sendPlayerInformation(otherPlayer, notificationType, key, values); - } - } - } - - public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) - { - ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; - - TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, notificationType, values); - McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); - - sendNotification(player, customEvent); - } - - private static void sendNotification(Player player, McMMOPlayerNotificationEvent customEvent) { - if (customEvent.isCancelled()) - return; - - player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent()); - } - - private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, ChatMessageType destination, TextComponent message) { - //Init event - McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player, - notificationType, message, destination); - - //Call event - Bukkit.getServer().getPluginManager().callEvent(customEvent); - return customEvent; - } - - /** - * Handles sending level up notifications to a mcMMOPlayer - * @param mcMMOPlayer target mcMMOPlayer - * @param skillName skill that leveled up - * @param newLevel new level of that skill - */ - public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkill skillName, int newLevel) - { - ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; - - TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(mcMMOPlayer, skillName, newLevel); - McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent); - - sendNotification(mcMMOPlayer.getPlayer(), customEvent); - } - /** * Returns the list that contains all unique instances of registered Interaction classes * Interactions are extensions of abstract classes that represent modifying behaviours in Minecraft through events diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ac83eea86..b17d0b742 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -8,7 +8,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; @@ -30,7 +30,6 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.*; @@ -310,7 +309,7 @@ public class PlayerListener implements Listener { } } - if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack) && !Config.getInstance().getUnarmedItemsAsUnarmed()) || mcMMOPlayer.getAbilityMode(SuperAbility.BERSERK)) { + if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack) && !Config.getInstance().getUnarmedItemsAsUnarmed()) || mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK)) { boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop); boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess; event.setCancelled(cancel); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java index ff14c55ce..091190ade 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java @@ -1,17 +1,17 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; -import com.gmail.nossr50.listeners.InteractionManager; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.datatypes.player.McMMOPlayer; public class AbilityCooldownTask extends BukkitRunnable { private McMMOPlayer mcMMOPlayer; - private SuperAbility ability; + private SuperAbilityType ability; - public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbility ability) { + public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { this.mcMMOPlayer = mcMMOPlayer; this.ability = ability; } @@ -24,7 +24,7 @@ public class AbilityCooldownTask extends BukkitRunnable { mcMMOPlayer.setAbilityInformed(ability, true); - InteractionManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh()); + NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh()); //mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh()); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 37f9c7d53..3fb94db13 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; -import com.gmail.nossr50.listeners.InteractionManager; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.entity.Player; @@ -19,9 +19,9 @@ import com.gmail.nossr50.util.skills.SkillUtils; public class AbilityDisableTask extends BukkitRunnable { private McMMOPlayer mcMMOPlayer; - private SuperAbility ability; + private SuperAbilityType ability; - public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbility ability) { + public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { this.mcMMOPlayer = mcMMOPlayer; this.ability = ability; } @@ -59,7 +59,7 @@ public class AbilityDisableTask extends BukkitRunnable { if (mcMMOPlayer.useChatNotifications()) { //player.sendMessage(ability.getAbilityOff()); - InteractionManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff()); + NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff()); } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index a5479f5ba..0b750fec3 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.listeners.InteractionManager; +import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.config.Config; @@ -26,7 +26,7 @@ public class ToolLowerTask extends BukkitRunnable { mcMMOPlayer.setToolPreparationMode(tool, false); if (Config.getInstance().getAbilityMessagesEnabled()) { - InteractionManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); + NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index a3f2ec47a..3cd013625 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.axes; import java.util.Map; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.util.skills.*; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -10,7 +11,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.locale.LocaleLoader; @@ -41,7 +41,7 @@ public class AxesManager extends SkillManager { } public boolean canUseSkullSplitter(LivingEntity target) { - return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbility.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); + return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); } public boolean canActivateAbility() { diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 2737803b7..6a5fe4529 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -55,7 +55,7 @@ public class HerbalismManager extends SkillManager { } public boolean canGreenTerraBlock(BlockState blockState) { - return mcMMOPlayer.getAbilityMode(SuperAbility.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); + return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); } public boolean canActivateAbility() { @@ -63,7 +63,7 @@ public class HerbalismManager extends SkillManager { } public boolean canGreenTerraPlant() { - return mcMMOPlayer.getAbilityMode(SuperAbility.GREEN_TERRA); + return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 09672e3ab..14394e474 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -3,12 +3,10 @@ package com.gmail.nossr50.skills.mining; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.XPGainReason; -import com.gmail.nossr50.listeners.InteractionManager; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.skills.SkillManager; @@ -17,6 +15,7 @@ import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.inventory.ItemStack; @@ -106,17 +105,17 @@ public class MiningManager extends SkillManager { TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); - //SkillUtils.sendSkillMessage(player, SuperAbility.BLAST_MINING.getAbilityPlayer(player)); - InteractionManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); + //SkillUtils.sendSkillMessage(player, SuperAbilityType.BLAST_MINING.getAbilityPlayer(player)); + NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); //player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata()); tnt.setFuseTicks(0); targetBlock.setType(Material.AIR); - mcMMOPlayer.setAbilityDATS(SuperAbility.BLAST_MINING, System.currentTimeMillis()); - mcMMOPlayer.setAbilityInformed(SuperAbility.BLAST_MINING, false); - new AbilityCooldownTask(mcMMOPlayer, SuperAbility.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, SuperAbility.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); + mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis()); + mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false); + new AbilityCooldownTask(mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); } /** @@ -291,11 +290,11 @@ public class MiningManager extends SkillManager { } private boolean blastMiningCooldownOver() { - int timeRemaining = mcMMOPlayer.calculateTimeRemaining(SuperAbility.BLAST_MINING); + int timeRemaining = mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.BLAST_MINING); if (timeRemaining > 0) { //getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); - InteractionManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf("timeRemaining")); + NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf("timeRemaining")); return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 8f4fc498a..f96bcbc69 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -4,7 +4,7 @@ import java.util.Map; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.util.skills.SkillActivationType; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -40,7 +40,7 @@ public class SwordsManager extends SkillManager { } public boolean canUseSerratedStrike() { - return mcMMOPlayer.getAbilityMode(SuperAbility.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer()); + return mcMMOPlayer.getAbilityMode(SuperAbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer()); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index e65182b70..ca5c678d6 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.XPGainReason; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillWeightedActivationCheckEvent; -import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.BleedTimerTask; @@ -18,6 +17,7 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillActivationType; @@ -330,7 +330,7 @@ public class TamingManager extends SkillManager { for (Entity entity : player.getNearbyEntities(range, range, range)) { if (entity.getType() == type) { - InteractionManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILURE, Taming.getCallOfTheWildFailureMessage(type)); + NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILURE, Taming.getCallOfTheWildFailureMessage(type)); return false; } } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 28c406b62..94854d92e 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.skills.unarmed; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.locale.LocaleLoader; @@ -38,7 +38,7 @@ public class UnarmedManager extends SkillManager { } public boolean canUseBerserk() { - return mcMMOPlayer.getAbilityMode(SuperAbility.BERSERK) && Permissions.berserk(getPlayer()); + return mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && Permissions.berserk(getPlayer()); } public boolean canDisarm(LivingEntity target) { diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 4a836928c..4b3ed81d3 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.skills.woodcutting; import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.XPGainReason; import com.gmail.nossr50.locale.LocaleLoader; @@ -34,7 +34,7 @@ public class WoodcuttingManager extends SkillManager { } public boolean canUseTreeFeller(ItemStack heldItem) { - return mcMMOPlayer.getAbilityMode(SuperAbility.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem); + return mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem); } protected boolean canGetDoubleDrops() { diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index 95d613f54..17e345b38 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.XPGainReason; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; @@ -354,7 +354,7 @@ public class EventUtils { return !isCancelled; } - public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, SuperAbility ability) { + public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, SuperAbilityType ability) { McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkill.byAbility(ability)); mcMMO.p.getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java index 9f28c39a7..31d1e77d4 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -1,9 +1,8 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.party.PartyFeature; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.Material; -import org.bukkit.TreeSpecies; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; import org.bukkit.entity.EntityType; @@ -29,7 +28,7 @@ public class StringUtils { return createPrettyString(entity.toString()); } - public static String getPrettyAbilityString(SuperAbility ability) { + public static String getPrettyAbilityString(SuperAbilityType ability) { return createPrettyString(ability.toString()); } diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java new file mode 100644 index 000000000..68e4fe2d1 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -0,0 +1,88 @@ +package com.gmail.nossr50.util.player; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.interactions.NotificationType; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.PrimarySkill; +import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.TextComponentFactory; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class NotificationManager { + /** + * Sends players notifications from mcMMO + * This does this by sending out an event so other plugins can cancel it + * @param player target player + * @param notificationType notifications defined type + * @param key the locale key for the notifications defined message + */ + public static void sendPlayerInformation(Player player, NotificationType notificationType, String key) + { + + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); + + sendNotification(player, customEvent); + } + + public static void sendOtherPlayersSkillInfo(Player source, NotificationType notificationType, String key, String... values) + { + Location location = source.getLocation(); + for (Player otherPlayer : source.getWorld().getPlayers()) { + if (otherPlayer != source && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { + sendPlayerInformation(otherPlayer, notificationType, key, values); + } + } + } + + public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) + { + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + + TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, notificationType, values); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); + + sendNotification(player, customEvent); + } + + private static void sendNotification(Player player, McMMOPlayerNotificationEvent customEvent) { + if (customEvent.isCancelled()) + return; + + player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent()); + } + + private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, ChatMessageType destination, TextComponent message) { + //Init event + McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player, + notificationType, message, destination); + + //Call event + Bukkit.getServer().getPluginManager().callEvent(customEvent); + return customEvent; + } + + /** + * Handles sending level up notifications to a mcMMOPlayer + * @param mcMMOPlayer target mcMMOPlayer + * @param skillName skill that leveled up + * @param newLevel new level of that skill + */ + public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkill skillName, int newLevel) + { + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(mcMMOPlayer, skillName, newLevel); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent); + + sendNotification(mcMMOPlayer.getPlayer(), customEvent); + } +} diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 6a691ee59..3262054d7 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; import com.gmail.nossr50.datatypes.skills.PrimarySkill; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -51,8 +51,8 @@ public class ScoreboardManager { static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall"); static final Map skillLabels; - static final Map abilityLabelsColored; - static final Map abilityLabelsSkill; + static final Map abilityLabelsColored; + static final Map abilityLabelsSkill; /* * Initializes the static properties of this class @@ -62,8 +62,8 @@ public class ScoreboardManager { * We need immutable objects for our Scoreboard's labels */ ImmutableMap.Builder skillLabelBuilder = ImmutableMap.builder(); - ImmutableMap.Builder abilityLabelBuilder = ImmutableMap.builder(); - ImmutableMap.Builder abilityLabelSkillBuilder = ImmutableMap.builder(); + ImmutableMap.Builder abilityLabelBuilder = ImmutableMap.builder(); + ImmutableMap.Builder abilityLabelSkillBuilder = ImmutableMap.builder(); /* * Builds the labels for our ScoreBoards @@ -98,7 +98,7 @@ public class ScoreboardManager { abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName())); if (type == PrimarySkill.MINING) { - abilityLabelBuilder.put(SuperAbility.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbility.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName())); } } @@ -120,14 +120,14 @@ public class ScoreboardManager { abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getName())); if (type == PrimarySkill.MINING) { - abilityLabelBuilder.put(SuperAbility.BLAST_MINING, formatAbility(SuperAbility.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName())); } } } } - for (SuperAbility type : SuperAbility.values()) { - abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbility.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName())); + for (SuperAbilityType type : SuperAbilityType.values()) { + abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName())); } skillLabels = skillLabelBuilder.build(); diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index c92f30661..bf5c1d2e0 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.util.scoreboards; import java.util.List; import java.util.Map; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.events.scoreboard.*; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -18,7 +19,6 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; -import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.child.FamilyTree; @@ -463,10 +463,10 @@ public class ScoreboardWrapper { if (targetSkill == PrimarySkill.MINING) { // Special-Case: Mining has two abilities, both with cooldowns - Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbility.SUPER_BREAKER)); - Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbility.BLAST_MINING)); - int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbility.SUPER_BREAKER), 0); - int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbility.BLAST_MINING), 0); + Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbilityType.SUPER_BREAKER)); + Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbilityType.BLAST_MINING)); + int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.SUPER_BREAKER), 0); + int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.BLAST_MINING), 0); cooldownSB.setScore(secondsSB); cooldownBM.setScore(secondsBM); @@ -474,7 +474,7 @@ public class ScoreboardWrapper { stopUpdating = (secondsSB == 0 && secondsBM == 0); } else { - SuperAbility ability = targetSkill.getAbility(); + SuperAbilityType ability = targetSkill.getAbility(); Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability)); int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0); @@ -495,7 +495,7 @@ public class ScoreboardWrapper { case COOLDOWNS_BOARD: boolean anyCooldownsActive = false; - for (SuperAbility ability : SuperAbility.values()) { + for (SuperAbilityType ability : SuperAbilityType.values()) { int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0); if (seconds != 0) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index bdf83c9fa..16aa008cb 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -6,20 +6,20 @@ import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.skills.SuperAbility; +import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.XPGainReason; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.RandomChance; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillWeightedActivationCheckEvent; -import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.Location; import org.bukkit.Material; @@ -33,7 +33,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.awt.*; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; @@ -138,7 +137,7 @@ public class SkillUtils { for (Player otherPlayer : player.getWorld().getPlayers()) { if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - InteractionManager.sendOtherPlayersSkillInfo(player, notificationType, key); + NotificationManager.sendOtherPlayersSkillInfo(player, notificationType, key); } } } @@ -180,7 +179,7 @@ public class SkillUtils { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PrimarySkill skill = mcMMOPlayer.getAbilityMode(SuperAbility.SUPER_BREAKER) ? PrimarySkill.MINING : PrimarySkill.EXCAVATION; + PrimarySkill skill = mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) ? PrimarySkill.MINING : PrimarySkill.EXCAVATION; int ticks = PerksUtils.handleActivationPerks(player, 2 + (mcMMOPlayer.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR; PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index e53ec3a78..aa3f1b21a 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -883,7 +883,7 @@ Skills.ChildStats=[[YELLOW]]{0}[[GREEN]]{1} Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s) Skills.Cancelled=[[RED]]{0} cancelled! Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0}[[GREEN]]. Left-click to cancel. -Skills.AbilityGateRequirementFail=[[YELLOW]]You are not yet skilled enough to perform this task. +Skills.AbilityGateRequirementFail=[[RED]]You require [[YELLOW]]{0}[[RED]] more levels of [[GOLD]]{1}[[RED]] to use this super ability. #STATISTICS Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=- Stats.Header.Gathering=[[GOLD]]-=GATHERING SKILLS=-