Update code style

This commit is contained in:
nossr50 2019-04-24 22:52:53 -07:00
parent dc758a6dfc
commit 02a69cbb05
334 changed files with 4660 additions and 5158 deletions

View File

@ -8,7 +8,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public final class AbilityAPI { public final class AbilityAPI {
private AbilityAPI() {} private AbilityAPI() {
}
public static boolean berserkEnabled(Player player) { public static boolean berserkEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK); return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);

View File

@ -10,7 +10,8 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public final class ChatAPI { public final class ChatAPI {
private ChatAPI() {} private ChatAPI() {
}
/** /**
* Send a message to all members of a party * Send a message to all members of a party

View File

@ -19,7 +19,8 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
public final class ExperienceAPI { public final class ExperienceAPI {
private ExperienceAPI() {} private ExperienceAPI() {
}
/** /**
* Returns whether given string is a valid type of skill suitable for the * Returns whether given string is a valid type of skill suitable for the
@ -63,7 +64,6 @@ public final class ExperienceAPI {
* @param player The player to add XP to * @param player The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
@Deprecated @Deprecated
@ -80,7 +80,6 @@ public final class ExperienceAPI {
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -98,7 +97,6 @@ public final class ExperienceAPI {
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
* @param isUnshared true if the XP cannot be shared with party members * @param isUnshared true if the XP cannot be shared with party members
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -129,15 +127,13 @@ public final class ExperienceAPI {
* </br> * </br>
* This function is designed for API usage. * This function is designed for API usage.
* *
* @deprecated We're using uuids to get an offline player
* replaced by {@link #addRawXPOffline(UUID uuid, String skillType, float XP)}
*
* @param playerName The player to add XP to * @param playerName The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @deprecated We're using uuids to get an offline player
* replaced by {@link #addRawXPOffline(UUID uuid, String skillType, float XP)}
*/ */
@Deprecated @Deprecated
public static void addRawXPOffline(String playerName, String skillType, float XP) { public static void addRawXPOffline(String playerName, String skillType, float XP) {
@ -152,7 +148,6 @@ public final class ExperienceAPI {
* @param uuid The UUID of player to add XP to * @param uuid The UUID of player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -168,7 +163,6 @@ public final class ExperienceAPI {
* @param player The player to add XP to * @param player The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
@Deprecated @Deprecated
@ -185,7 +179,6 @@ public final class ExperienceAPI {
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -201,7 +194,6 @@ public final class ExperienceAPI {
* @param playerName The player to add XP to * @param playerName The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -218,7 +210,6 @@ public final class ExperienceAPI {
* @param player The player to add XP to * @param player The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
@Deprecated @Deprecated
@ -235,7 +226,6 @@ public final class ExperienceAPI {
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -253,7 +243,6 @@ public final class ExperienceAPI {
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
* @param isUnshared true if the XP cannot be shared with party members * @param isUnshared true if the XP cannot be shared with party members
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -276,7 +265,6 @@ public final class ExperienceAPI {
* @param playerName The player to add XP to * @param playerName The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -296,7 +284,6 @@ public final class ExperienceAPI {
* @param player The player to add XP to * @param player The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
@Deprecated @Deprecated
@ -314,7 +301,6 @@ public final class ExperienceAPI {
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -333,7 +319,6 @@ public final class ExperienceAPI {
* @param XP The amount of XP to add * @param XP The amount of XP to add
* @param xpGainReason The reason to gain XP * @param xpGainReason The reason to gain XP
* @param isUnshared true if the XP cannot be shared with party members * @param isUnshared true if the XP cannot be shared with party members
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
*/ */
@ -354,7 +339,6 @@ public final class ExperienceAPI {
* @param player The player to get XP for * @param player The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -370,7 +354,6 @@ public final class ExperienceAPI {
* @param playerName The player to get XP for * @param playerName The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -388,7 +371,6 @@ public final class ExperienceAPI {
* @param uuid The player to get XP for * @param uuid The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -405,7 +387,6 @@ public final class ExperienceAPI {
* @param player The player to get XP for * @param player The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -421,7 +402,6 @@ public final class ExperienceAPI {
* @param playerName The player to get XP for * @param playerName The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -439,7 +419,6 @@ public final class ExperienceAPI {
* @param uuid The player to get XP for * @param uuid The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -456,7 +435,6 @@ public final class ExperienceAPI {
* @param player The player to get the XP amount for * @param player The player to get the XP amount for
* @param skillType The skill to get the XP amount for * @param skillType The skill to get the XP amount for
* @return the total amount of XP needed to reach the next level * @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -472,7 +450,6 @@ public final class ExperienceAPI {
* @param playerName The player to get XP for * @param playerName The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the total amount of XP needed to reach the next level * @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -490,7 +467,6 @@ public final class ExperienceAPI {
* @param uuid The player to get XP for * @param uuid The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the total amount of XP needed to reach the next level * @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -507,7 +483,6 @@ public final class ExperienceAPI {
* @param player The player to get the XP amount for * @param player The player to get the XP amount for
* @param skillType The skill to get the XP amount for * @param skillType The skill to get the XP amount for
* @return the amount of XP remaining until the next level * @return the amount of XP remaining until the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -527,7 +502,6 @@ public final class ExperienceAPI {
* @param playerName The player to get XP for * @param playerName The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP needed to reach the next level * @return the amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -548,7 +522,6 @@ public final class ExperienceAPI {
* @param uuid The player to get XP for * @param uuid The player to get XP for
* @param skillType The skill to get XP for * @param skillType The skill to get XP for
* @return the amount of XP needed to reach the next level * @return the amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -568,7 +541,6 @@ public final class ExperienceAPI {
* @param player The player to add levels to * @param player The player to add levels to
* @param skillType Type of skill to add levels to * @param skillType Type of skill to add levels to
* @param levels Number of levels to add * @param levels Number of levels to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addLevel(Player player, String skillType, int levels) { public static void addLevel(Player player, String skillType, int levels) {
@ -583,7 +555,6 @@ public final class ExperienceAPI {
* @param playerName The player to add levels to * @param playerName The player to add levels to
* @param skillType Type of skill to add levels to * @param skillType Type of skill to add levels to
* @param levels Number of levels to add * @param levels Number of levels to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -615,7 +586,6 @@ public final class ExperienceAPI {
* @param uuid The player to add levels to * @param uuid The player to add levels to
* @param skillType Type of skill to add levels to * @param skillType Type of skill to add levels to
* @param levels Number of levels to add * @param levels Number of levels to add
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -646,7 +616,6 @@ public final class ExperienceAPI {
* @param player The player to get the level for * @param player The player to get the level for
* @param skillType The skill to get the level for * @param skillType The skill to get the level for
* @return the level of a given skill * @return the level of a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevel(Player player, String skillType) { public static int getLevel(Player player, String skillType) {
@ -661,7 +630,6 @@ public final class ExperienceAPI {
* @param playerName The player to get the level for * @param playerName The player to get the level for
* @param skillType The skill to get the level for * @param skillType The skill to get the level for
* @return the level of a given skill * @return the level of a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -678,7 +646,6 @@ public final class ExperienceAPI {
* @param uuid The player to get the level for * @param uuid The player to get the level for
* @param skillType The skill to get the level for * @param skillType The skill to get the level for
* @return the level of a given skill * @return the level of a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -705,7 +672,6 @@ public final class ExperienceAPI {
* *
* @param playerName The player to get the power level for * @param playerName The player to get the power level for
* @return the power level of the player * @return the power level of the player
*
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@Deprecated @Deprecated
@ -727,7 +693,6 @@ public final class ExperienceAPI {
* *
* @param uuid The player to get the power level for * @param uuid The player to get the power level for
* @return the power level of the player * @return the power level of the player
*
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static int getPowerLevelOffline(UUID uuid) { public static int getPowerLevelOffline(UUID uuid) {
@ -748,7 +713,6 @@ public final class ExperienceAPI {
* *
* @param skillType The skill to get the level cap for * @param skillType The skill to get the level cap for
* @return the level cap of a given skill * @return the level cap of a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevelCap(String skillType) { public static int getLevelCap(String skillType) {
@ -762,7 +726,6 @@ public final class ExperienceAPI {
* *
* @param skillType The skill to get the level cap for * @param skillType The skill to get the level cap for
* @return the level cap of a given skill * @return the level cap of a given skill
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevelCap(PrimarySkillType skillType) { public static int getLevelCap(PrimarySkillType skillType) {
@ -771,11 +734,11 @@ public final class ExperienceAPI {
/** /**
* Checks whether or not a specific skill is level capped * Checks whether or not a specific skill is level capped
*
* @param skillType target skill * @param skillType target skill
* @return true if the skill has a level cap * @return true if the skill has a level cap
*/ */
public static boolean isSkillLevelCapped(PrimarySkillType skillType) public static boolean isSkillLevelCapped(PrimarySkillType skillType) {
{
return mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(skillType); return mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(skillType);
} }
@ -797,12 +760,10 @@ public final class ExperienceAPI {
* *
* @param playerName The name of the player to check * @param playerName The name of the player to check
* @param skillType The skill to check * @param skillType The skill to check
* * @return the position on the leaderboard
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*/ */
@Deprecated @Deprecated
public static int getPlayerRankSkill(String playerName, String skillType) { public static int getPlayerRankSkill(String playerName, String skillType) {
@ -816,12 +777,10 @@ public final class ExperienceAPI {
* *
* @param uuid The name of the player to check * @param uuid The name of the player to check
* @param skillType The skill to check * @param skillType The skill to check
* * @return the position on the leaderboard
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*/ */
public static int getPlayerRankSkill(UUID uuid, String skillType) { public static int getPlayerRankSkill(UUID uuid, String skillType) {
return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(getNonChildSkillType(skillType)); return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(getNonChildSkillType(skillType));
@ -833,10 +792,8 @@ public final class ExperienceAPI {
* This function is designed for API usage. * This function is designed for API usage.
* *
* @param playerName The name of the player to check * @param playerName The name of the player to check
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard * @return the position on the power level leaderboard
* @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@Deprecated @Deprecated
public static int getPlayerRankOverall(String playerName) { public static int getPlayerRankOverall(String playerName) {
@ -849,10 +806,8 @@ public final class ExperienceAPI {
* This function is designed for API usage. * This function is designed for API usage.
* *
* @param uuid The name of the player to check * @param uuid The name of the player to check
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard * @return the position on the power level leaderboard
* @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static int getPlayerRankOverall(UUID uuid) { public static int getPlayerRankOverall(UUID uuid) {
return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(null); return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(null);
@ -866,7 +821,6 @@ public final class ExperienceAPI {
* @param player The player to set the level of * @param player The player to set the level of
* @param skillType The skill to set the level for * @param skillType The skill to set the level for
* @param skillLevel The value to set the level to * @param skillLevel The value to set the level to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void setLevel(Player player, String skillType, int skillLevel) { public static void setLevel(Player player, String skillType, int skillLevel) {
@ -881,7 +835,6 @@ public final class ExperienceAPI {
* @param playerName The player to set the level of * @param playerName The player to set the level of
* @param skillType The skill to set the level for * @param skillType The skill to set the level for
* @param skillLevel The value to set the level to * @param skillLevel The value to set the level to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -898,7 +851,6 @@ public final class ExperienceAPI {
* @param uuid The player to set the level of * @param uuid The player to set the level of
* @param skillType The skill to set the level for * @param skillType The skill to set the level for
* @param skillLevel The value to set the level to * @param skillLevel The value to set the level to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@ -914,7 +866,6 @@ public final class ExperienceAPI {
* @param player The player to set the XP of * @param player The player to set the XP of
* @param skillType The skill to set the XP for * @param skillType The skill to set the XP for
* @param newValue The value to set the XP to * @param newValue The value to set the XP to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -930,7 +881,6 @@ public final class ExperienceAPI {
* @param playerName The player to set the XP of * @param playerName The player to set the XP of
* @param skillType The skill to set the XP for * @param skillType The skill to set the XP for
* @param newValue The value to set the XP to * @param newValue The value to set the XP to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -948,7 +898,6 @@ public final class ExperienceAPI {
* @param uuid The player to set the XP of * @param uuid The player to set the XP of
* @param skillType The skill to set the XP for * @param skillType The skill to set the XP for
* @param newValue The value to set the XP to * @param newValue The value to set the XP to
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -965,7 +914,6 @@ public final class ExperienceAPI {
* @param player The player to change the XP of * @param player The player to change the XP of
* @param skillType The skill to change the XP for * @param skillType The skill to change the XP for
* @param xp The amount of XP to remove * @param xp The amount of XP to remove
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
@ -981,7 +929,6 @@ public final class ExperienceAPI {
* @param playerName The player to change the XP of * @param playerName The player to change the XP of
* @param skillType The skill to change the XP for * @param skillType The skill to change the XP for
* @param xp The amount of XP to remove * @param xp The amount of XP to remove
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -999,7 +946,6 @@ public final class ExperienceAPI {
* @param uuid The player to change the XP of * @param uuid The player to change the XP of
* @param skillType The skill to change the XP for * @param skillType The skill to change the XP for
* @param xp The amount of XP to remove * @param xp The amount of XP to remove
*
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
@ -1014,7 +960,6 @@ public final class ExperienceAPI {
* This function is designed for API usage. * This function is designed for API usage.
* *
* @param level The level to get the amount of XP for * @param level The level to get the amount of XP for
*
* @throws InvalidFormulaTypeException if the given formulaType is not valid * @throws InvalidFormulaTypeException if the given formulaType is not valid
*/ */
public static int getXpNeededToLevel(int level) { public static int getXpNeededToLevel(int level) {
@ -1028,7 +973,6 @@ public final class ExperienceAPI {
* *
* @param level The level to get the amount of XP for * @param level The level to get the amount of XP for
* @param formulaType The formula type to get the amount of XP for * @param formulaType The formula type to get the amount of XP for
*
* @throws InvalidFormulaTypeException if the given formulaType is not valid * @throws InvalidFormulaTypeException if the given formulaType is not valid
*/ */
public static int getXpNeededToLevel(int level, String formulaType) { public static int getXpNeededToLevel(int level, String formulaType) {
@ -1037,17 +981,14 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
*
* @param blockStates the blocks to reward XP for * @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player * @param mcMMOPlayer the target player
*/ */
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) {
{ for (BlockState bs : blockStates) {
for(BlockState bs : blockStates) for (PrimarySkillType skillType : PrimarySkillType.values()) {
{ if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
for(PrimarySkillType skillType : PrimarySkillType.values())
{
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
@ -1056,16 +997,14 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
*
* @param blockStates the blocks to reward XP for * @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player * @param mcMMOPlayer the target player
* @param skillType target primary skill * @param skillType target primary skill
*/ */
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
{ for (BlockState bs : blockStates) {
for(BlockState bs : blockStates) if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
{
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
@ -1073,15 +1012,13 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
*
* @param blockState The target blockstate * @param blockState The target blockstate
* @param mcMMOPlayer The target player * @param mcMMOPlayer The target player
*/ */
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) {
{ for (PrimarySkillType skillType : PrimarySkillType.values()) {
for(PrimarySkillType skillType : PrimarySkillType.values()) if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
{
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
@ -1089,20 +1026,18 @@ public final class ExperienceAPI {
/** /**
* Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
*
* @param blockState The target blockstate * @param blockState The target blockstate
* @param mcMMOPlayer The target player * @param mcMMOPlayer The target player
* @param skillType target primary skill * @param skillType target primary skill
*/ */
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
{ if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }
// Utility methods follow. // Utility methods follow.
private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) { private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerUniqueId); PlayerProfile profile = getOfflineProfile(playerUniqueId);
@ -1182,10 +1117,10 @@ public final class ExperienceAPI {
} }
/** /**
* @deprecated Use UserManager::getPlayer(Player player) instead
* @param player target player * @param player target player
* @return McMMOPlayer for that player if the profile is loaded, otherwise null * @return McMMOPlayer for that player if the profile is loaded, otherwise null
* @throws McMMOPlayerNotFoundException * @throws McMMOPlayerNotFoundException
* @deprecated Use UserManager::getPlayer(Player player) instead
*/ */
@Deprecated @Deprecated
private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException { private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {

View File

@ -13,7 +13,8 @@ import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
public final class PartyAPI { public final class PartyAPI {
private PartyAPI() {} private PartyAPI() {
}
/** /**
* Get the name of the party a player is in. * Get the name of the party a player is in.
@ -90,8 +91,7 @@ public final class PartyAPI {
if (party == null) { if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) { } else if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) {
if(PartyManager.isPartyFull(player, party)) if (PartyManager.isPartyFull(player, party)) {
{
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString()); NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
return; return;
} }
@ -103,15 +103,16 @@ public final class PartyAPI {
/** /**
* The max party size of the server * The max party size of the server
* Limits are only enforced if the enforcement setting is on * Limits are only enforced if the enforcement setting is on
*
* @return the max party size on this server * @return the max party size on this server
*/ */
public static int getMaxPartySize() public static int getMaxPartySize() {
{
return mcMMO.getConfigManager().getConfigParty().getPartySizeLimit(); return mcMMO.getConfigManager().getConfigParty().getPartySizeLimit();
} }
/** /**
* Checks if parties are currently size capped which is determined by the user config * Checks if parties are currently size capped which is determined by the user config
*
* @return true if parties are size capped * @return true if parties are size capped
*/ */
public static boolean isPartySizeCapped() { public static boolean isPartySizeCapped() {

View File

@ -7,7 +7,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public final class SkillAPI { public final class SkillAPI {
private SkillAPI() {} private SkillAPI() {
}
/** /**
* Returns a list of strings with mcMMO's skills * Returns a list of strings with mcMMO's skills

View File

@ -41,24 +41,20 @@ public abstract class ChatManager {
* Party Chat Spying * Party Chat Spying
* Party messages will be copied to people with the mcmmo.admin.chatspy permission node * Party messages will be copied to people with the mcmmo.admin.chatspy permission node
*/ */
if(event instanceof McMMOPartyChatEvent) if (event instanceof McMMOPartyChatEvent) {
{
//We need to grab the party chat name //We need to grab the party chat name
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//Find the people with permissions //Find the people with permissions
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
{
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
//Check for toggled players //Check for toggled players
if(mcMMOPlayer.isPartyChatSpying()) if (mcMMOPlayer.isPartyChatSpying()) {
{
Party adminParty = mcMMOPlayer.getParty(); Party adminParty = mcMMOPlayer.getParty();
//Only message admins not part of this party //Only message admins not part of this party
if(adminParty != null) if (adminParty != null) {
{
//TODO: Incorporate JSON //TODO: Incorporate JSON
if (!adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) if (!adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty()))
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message)); player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));

View File

@ -70,17 +70,14 @@ public class McImportCommand implements CommandExecutor {
materialNames.get(type).add(materialName); materialNames.get(type).add(materialName);
} }
} } catch (FileNotFoundException e) {
catch (FileNotFoundException e) {
mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)"); mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)");
mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log"); mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log");
return; return;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return; return;
} } finally {
finally {
tryClose(in); tryClose(in);
} }
@ -114,8 +111,7 @@ public class McImportCommand implements CommandExecutor {
} }
try { try {
c.close(); c.close();
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -200,14 +196,11 @@ public class McImportCommand implements CommandExecutor {
String skillName = "UNIDENTIFIED"; String skillName = "UNIDENTIFIED";
if (materialName.contains("ORE")) { if (materialName.contains("ORE")) {
skillName = "Mining"; skillName = "Mining";
} } else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting"; skillName = "Woodcutting";
} } else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism"; skillName = "Herbalism";
} } else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
skillName = "Excavation"; skillName = "Excavation";
} }
@ -222,8 +215,7 @@ public class McImportCommand implements CommandExecutor {
if (skillName.equals("Mining")) { if (skillName.equals("Mining")) {
skillContents.add(" " + " " + "Smelting_XP_Gain: 9"); skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
} } else if (skillName.equals("Woodcutting")) {
else if (skillName.equals("Woodcutting")) {
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG")); skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
} }
} }
@ -239,20 +231,15 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED"; String toolType = "UNIDENTIFIED";
if (materialName.contains("PICKAXE")) { if (materialName.contains("PICKAXE")) {
toolType = "Pickaxes"; toolType = "Pickaxes";
} } else if (materialName.contains("AXE")) {
else if (materialName.contains("AXE")) {
toolType = "Axes"; toolType = "Axes";
} } else if (materialName.contains("BOW")) {
else if (materialName.contains("BOW")) {
toolType = "Bows"; toolType = "Bows";
} } else if (materialName.contains("HOE")) {
else if (materialName.contains("HOE")) {
toolType = "Hoes"; toolType = "Hoes";
} } else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
toolType = "Shovels"; toolType = "Shovels";
} } else if (materialName.contains("SWORD")) {
else if (materialName.contains("SWORD")) {
toolType = "Swords"; toolType = "Swords";
} }
@ -279,14 +266,11 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED"; String toolType = "UNIDENTIFIED";
if (materialName.contains("BOOT") || materialName.contains("SHOE")) { if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
toolType = "Boots"; toolType = "Boots";
} } else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
toolType = "Chestplates"; toolType = "Chestplates";
} } else if (materialName.contains("HELM") || materialName.contains("HAT")) {
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
toolType = "Helmets"; toolType = "Helmets";
} } else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
toolType = "Leggings"; toolType = "Leggings";
} }

View File

@ -22,9 +22,6 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES; private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience"); private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static { static {
ArrayList<String> formulaTypes = new ArrayList<>(); ArrayList<String> formulaTypes = new ArrayList<>();
ArrayList<String> databaseTypes = new ArrayList<>(); ArrayList<String> databaseTypes = new ArrayList<>();
@ -52,14 +49,16 @@ public class McconvertCommand implements TabExecutor {
} }
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args); return databaseConvertCommand.onCommand(sender, command, label, args);
} } else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args); return experienceConvertCommand.onCommand(sender, command, label, args);
} }

View File

@ -71,7 +71,10 @@ public abstract class ToggleCommand implements TabExecutor {
} }
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender); protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer); protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName); protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
} }

View File

@ -36,8 +36,7 @@ public class XprateCommand implements TabExecutor {
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"), LocaleLoader.getString("Commands.Event.Stop"),
LocaleLoader.getString("Commands.Event.Stop.Subtitle"), LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
@ -65,18 +64,15 @@ public class XprateCommand implements TabExecutor {
if (CommandUtils.shouldDisableToggle(args[1])) { if (CommandUtils.shouldDisableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(false); mcMMO.p.setXPEventEnabled(false);
} } else if (CommandUtils.shouldEnableToggle(args[1])) {
else if (CommandUtils.shouldEnableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(true); mcMMO.p.setXPEventEnabled(true);
} } else {
else {
return false; return false;
} }
int newXpRate = Integer.parseInt(args[0]); int newXpRate = Integer.parseInt(args[0]);
if(newXpRate < 0) if (newXpRate < 0) {
{
sender.sendMessage(ChatColor.RED + LocaleLoader.getString("Commands.NegativeNumberWarn")); sender.sendMessage(ChatColor.RED + LocaleLoader.getString("Commands.NegativeNumberWarn"));
return true; return true;
} }
@ -84,8 +80,7 @@ public class XprateCommand implements TabExecutor {
ExperienceConfig.getInstance().setGlobalXPMultiplier(newXpRate); ExperienceConfig.getInstance().setGlobalXPMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"), LocaleLoader.getString("Commands.Event.Start"),
LocaleLoader.getString("Commands.Event.XP", newXpRate), LocaleLoader.getString("Commands.Event.XP", newXpRate),
@ -93,8 +88,7 @@ public class XprateCommand implements TabExecutor {
} }
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate)); sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
} }

View File

@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class ChatCommand implements TabExecutor { public abstract class ChatCommand implements TabExecutor {
private ChatMode chatMode;
protected ChatManager chatManager; protected ChatManager chatManager;
private ChatMode chatMode;
public ChatCommand(ChatMode chatMode) { public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode; this.chatMode = chatMode;
@ -47,8 +47,7 @@ public abstract class ChatCommand implements TabExecutor {
if (mcMMOPlayer.isChatEnabled(chatMode)) { if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender); disableChatMode(mcMMOPlayer, sender);
} } else {
else {
enableChatMode(mcMMOPlayer, sender); enableChatMode(mcMMOPlayer, sender);
} }

View File

@ -38,8 +38,7 @@ public class PartyChatCommand extends ChatCommand {
} }
message = buildChatMessage(args, 0); message = buildChatMessage(args, 0);
} } else {
else {
if (args.length < 2) { if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify")); sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return; return;

View File

@ -41,8 +41,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
} }
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz); oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
} } catch (Throwable e) {
catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true; return true;

View File

@ -26,8 +26,7 @@ public class McremoveCommand implements TabExecutor {
if (mcMMO.getDatabaseManager().removeUser(playerName)) { if (mcMMO.getDatabaseManager().removeUser(playerName)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
} } else {
else {
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
} }

View File

@ -29,8 +29,7 @@ public class AddxpCommand extends ExperienceCommand {
return; return;
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND); UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} } else {
else {
profile.addXp(skill, value); profile.addXp(skill, value);
profile.scheduleAsyncSave(); profile.scheduleAsyncSave();
} }

View File

@ -20,6 +20,14 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
@ -45,15 +53,13 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && skill.isChildSkill()) {
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
} }
//Profile not loaded //Profile not loaded
if(UserManager.getPlayer(sender.getName()) == null) if (UserManager.getPlayer(sender.getName()) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -78,8 +84,7 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && skill.isChildSkill()) {
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
} }
@ -103,8 +108,7 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
editValues(null, profile, skill, value); editValues(null, profile, skill, value);
} } else {
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
} }
@ -130,24 +134,19 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
protected abstract boolean permissionsCheckSelf(CommandSender sender); protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender); protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value); protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value); protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill); protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) { private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName))); return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
} }
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
@ -157,8 +156,7 @@ public abstract class ExperienceCommand implements TabExecutor {
if (player != null) { if (player != null) {
handlePlayerMessageAll(player, value); handlePlayerMessageAll(player, value);
} }
} } else {
else {
handleCommand(player, profile, skill, value); handleCommand(player, profile, skill, value);
if (player != null) { if (player != null) {

View File

@ -27,6 +27,14 @@ import java.util.UUID;
* value/quantity argument is removed. * value/quantity argument is removed.
*/ */
public class SkillresetCommand implements TabExecutor { public class SkillresetCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
@ -47,8 +55,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
skill = null; skill = null;
} } else {
else {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
@ -67,8 +74,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[1].equalsIgnoreCase("all")) { if (args[1].equalsIgnoreCase("all")) {
skill = null; skill = null;
} } else {
else {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
@ -89,8 +95,7 @@ public class SkillresetCommand implements TabExecutor {
} }
editValues(null, profile, skill); editValues(null, profile, skill);
} } else {
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
} }
@ -149,15 +154,6 @@ public class SkillresetCommand implements TabExecutor {
return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName); return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
} }
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
@ -167,8 +163,7 @@ public class SkillresetCommand implements TabExecutor {
if (player != null) { if (player != null) {
handlePlayerMessageAll(player); handlePlayerMessageAll(player);
} }
} } else {
else {
handleCommand(player, profile, skill); handleCommand(player, profile, skill);
if (player != null) { if (player != null) {

View File

@ -17,8 +17,7 @@ public class PartyAcceptCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -18,8 +18,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -11,8 +11,7 @@ import org.bukkit.entity.Player;
public class PartyChangePasswordCommand implements CommandExecutor { public class PartyChangePasswordCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -79,8 +79,7 @@ public class PartyCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -210,8 +209,7 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
//Not Loaded //Not Loaded
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); return ImmutableList.of();
} }

View File

@ -18,8 +18,7 @@ public class PartyCreateCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -15,8 +15,7 @@ public class PartyDisbandCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -22,8 +22,7 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
case 1: case 1:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -69,8 +68,7 @@ public class PartyInfoCommand implements CommandExecutor {
if (isUnlockedFeature(party, partyFeature)) { if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(partyFeature.getLocaleString()); unlockedPartyFeatures.add(partyFeature.getLocaleString());
} } else {
else {
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString()); lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
} }
} }

View File

@ -26,8 +26,7 @@ public class PartyInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -54,8 +53,7 @@ public class PartyInviteCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mcMMOPlayer.getParty();
if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if(PartyManager.isPartyFull(target, playerParty)) if (PartyManager.isPartyFull(target, playerParty)) {
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite",
target.getName(), playerParty.toString(), target.getName(), playerParty.toString(),
mcMMO.getConfigManager().getConfigParty().getPartySizeLimit())); mcMMO.getConfigManager().getConfigParty().getPartySizeLimit()));

View File

@ -17,8 +17,7 @@ import org.bukkit.entity.Player;
public class PartyItemShareCommand implements CommandExecutor { public class PartyItemShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -47,19 +46,16 @@ public class PartyItemShareCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[2])) { if (CommandUtils.shouldEnableToggle(args[2])) {
toggle = true; toggle = true;
} } else if (CommandUtils.shouldDisableToggle(args[2])) {
else if (CommandUtils.shouldDisableToggle(args[2])) {
toggle = false; toggle = false;
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true; return true;
} }
try { try {
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle); handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} } catch (IllegalArgumentException ex) {
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
} }

View File

@ -34,8 +34,7 @@ public class PartyJoinCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -63,8 +62,7 @@ public class PartyJoinCommand implements CommandExecutor {
} }
if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if(PartyManager.isPartyFull(player, targetParty)) if (PartyManager.isPartyFull(player, targetParty)) {
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true; return true;
} }

View File

@ -18,8 +18,7 @@ public class PartyKickCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -17,8 +17,7 @@ public class PartyLockCommand implements CommandExecutor {
case 1: case 1:
if (args[0].equalsIgnoreCase("lock")) { if (args[0].equalsIgnoreCase("lock")) {
togglePartyLock(sender, true); togglePartyLock(sender, true);
} } else if (args[0].equalsIgnoreCase("unlock")) {
else if (args[0].equalsIgnoreCase("unlock")) {
togglePartyLock(sender, false); togglePartyLock(sender, false);
} }
@ -32,11 +31,9 @@ public class PartyLockCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[1])) { if (CommandUtils.shouldEnableToggle(args[1])) {
togglePartyLock(sender, true); togglePartyLock(sender, true);
} } else if (CommandUtils.shouldDisableToggle(args[1])) {
else if (CommandUtils.shouldDisableToggle(args[1])) {
togglePartyLock(sender, false); togglePartyLock(sender, false);
} } else {
else {
sendUsageStrings(sender); sendUsageStrings(sender);
} }
@ -54,8 +51,7 @@ public class PartyLockCommand implements CommandExecutor {
} }
private void togglePartyLock(CommandSender sender, boolean lock) { private void togglePartyLock(CommandSender sender, boolean lock) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
} }

View File

@ -18,8 +18,7 @@ public class PartyQuitCommand implements CommandExecutor {
case 1: case 1:
Player player = (Player) sender; Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -16,8 +16,7 @@ public class PartyRenameCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -30,20 +30,15 @@ public enum PartySubcommandType {
if (commandName.equalsIgnoreCase("?")) { if (commandName.equalsIgnoreCase("?")) {
return HELP; return HELP;
} } else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT; return QUIT;
} } else if (commandName.equalsIgnoreCase("leader")) {
else if (commandName.equalsIgnoreCase("leader")) {
return OWNER; return OWNER;
} } else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
return XPSHARE; return XPSHARE;
} } else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE; return ITEMSHARE;
} } else if (commandName.equalsIgnoreCase("ally")) {
else if (commandName.equalsIgnoreCase("ally")) {
return ALLIANCE; return ALLIANCE;
} }

View File

@ -16,8 +16,7 @@ import org.bukkit.entity.Player;
public class PartyXpShareCommand implements CommandExecutor { public class PartyXpShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -33,11 +32,9 @@ public class PartyXpShareCommand implements CommandExecutor {
case 2: case 2:
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.NONE); handleChangingShareMode(party, ShareMode.NONE);
} } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.EQUAL); handleChangingShareMode(party, ShareMode.EQUAL);
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
} }

View File

@ -14,8 +14,7 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -20,12 +20,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PartyAllianceCommand implements TabExecutor { public class PartyAllianceCommand implements TabExecutor {
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private Player player; private Player player;
private Party playerParty; private Party playerParty;
private Party targetParty; private Party targetParty;
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
@ -36,8 +34,7 @@ public class PartyAllianceCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -15,8 +15,7 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -25,8 +25,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }

View File

@ -20,8 +20,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
if (ptpRecord.isConfirmRequired()) { if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
} }

View File

@ -20,8 +20,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -55,8 +54,7 @@ public class PtpAcceptCommand implements CommandExecutor {
if (!Permissions.partyTeleportWorld(target, targetWorld)) { if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true; return true;
} } else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true; return true;
} }

View File

@ -35,6 +35,64 @@ public class PtpCommand implements TabExecutor {
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
if (!target.isValid()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if (UserManager.getPlayer(targetPlayer) == null) {
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
if (UserManager.getPlayer(teleportingPlayer) == null) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
} else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -44,8 +102,7 @@ public class PtpCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{
if (!WorldGuardManager.getInstance().hasMainFlag(player)) if (!WorldGuardManager.getInstance().hasMainFlag(player))
return true; return true;
} }
@ -58,8 +115,7 @@ public class PtpCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -136,8 +192,7 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); return ImmutableList.of();
} }
@ -182,65 +237,4 @@ public class PtpCommand implements TabExecutor {
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout()));
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
if (!target.isValid()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if(UserManager.getPlayer(targetPlayer) == null)
{
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
if(UserManager.getPlayer(teleportingPlayer) == null)
{
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
} }

View File

@ -20,8 +20,7 @@ public class PtpToggleCommand implements CommandExecutor {
if (ptpRecord.isEnabled()) { if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
} }

View File

@ -65,8 +65,7 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(CommandUtils.displaySkill(profile, skill)); sender.sendMessage(CommandUtils.displaySkill(profile, skill));
} }
} } else {
else {
Player target = mcMMOPlayer.getPlayer(); Player target = mcMMOPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
@ -74,8 +73,7 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true; return true;
} }
} } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true; return true;
} }

View File

@ -38,8 +38,7 @@ public class MccooldownCommand implements TabExecutor {
} }
} }
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -58,8 +57,7 @@ public class MccooldownCommand implements TabExecutor {
if (seconds <= 0) { if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
} } else {
else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
} }
} }

View File

@ -62,8 +62,7 @@ public class McrankCommand implements TabExecutor {
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} } else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
return true; return true;
} }
@ -91,8 +90,7 @@ public class McrankCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if(mcMMOPlayer == null) if (mcMMOPlayer == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return; return;
} }

View File

@ -26,8 +26,7 @@ public class McstatsCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -53,8 +52,7 @@ public class McstatsCommand implements TabExecutor {
if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().isLevelCapEnabled()) { if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().isLevelCapEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
} } else {
else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
} }

View File

@ -54,8 +54,7 @@ public class AcrobaticsCommand extends SkillCommand {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll"); AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if(abstractSubSkill != null) if (abstractSubSkill != null) {
{
double rollChance, graceChance; double rollChance, graceChance;
//Chance to roll at half //Chance to roll at half

View File

@ -31,8 +31,7 @@ public class AlchemyCommand extends SkillCommand {
protected String[] calculateAbilityDisplayValues(Player player) { protected String[] calculateAbilityDisplayValues(Player player) {
//TODO: Needed? //TODO: Needed?
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return new String[]{"DATA NOT LOADED", "DATA NOT LOADED"}; return new String[]{"DATA NOT LOADED", "DATA NOT LOADED"};
} }

View File

@ -116,8 +116,7 @@ public class FishingCommand extends SkillCommand {
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier); biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
} }
if(canInnerPeace) if (canInnerPeace) {
{
innerPeaceMult = String.valueOf(fishingManager.getInnerPeaceMultiplier()); innerPeaceMult = String.valueOf(fishingManager.getInnerPeaceMultiplier());
} }
} }
@ -170,8 +169,7 @@ public class FishingCommand extends SkillCommand {
String.valueOf(recordTreasure))); String.valueOf(recordTreasure)));
} }
if(canInnerPeace) if (canInnerPeace) {
{
messages.add(getStatMessage(SubSkillType.FISHING_INNER_PEACE, innerPeaceMult)); messages.add(getStatMessage(SubSkillType.FISHING_INNER_PEACE, innerPeaceMult));
} }

View File

@ -27,26 +27,22 @@ public class MmoInfoCommand implements TabExecutor {
/* /*
* Only allow players to use this command * Only allow players to use this command
*/ */
if(commandSender instanceof Player) if (commandSender instanceof Player) {
{
if (args.length < 1) if (args.length < 1)
return false; return false;
Player player = (Player) commandSender; Player player = (Player) commandSender;
if(Permissions.mmoinfo(player)) if (Permissions.mmoinfo(player)) {
{
if (args == null || args[0] == null) if (args == null || args[0] == null)
return false; return false;
if(args[0].equalsIgnoreCase( "???")) if (args[0].equalsIgnoreCase("???")) {
{
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
return true; return true;
} else if(InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) } else if (InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) {
{
displayInfo(player, args[0]); displayInfo(player, args[0]);
return true; return true;
} }
@ -70,12 +66,10 @@ public class MmoInfoCommand implements TabExecutor {
} }
} }
private void displayInfo(Player player, String subSkillName) private void displayInfo(Player player, String subSkillName) {
{
//Check to see if the skill exists in the new system //Check to see if the skill exists in the new system
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName); AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName);
if(abstractSubSkill != null) if (abstractSubSkill != null) {
{
/* New System Skills are programmable */ /* New System Skills are programmable */
abstractSubSkill.printInfo(player); abstractSubSkill.printInfo(player);
//TextComponentFactory.sendPlayerUrlHeader(player); //TextComponentFactory.sendPlayerUrlHeader(player);
@ -89,8 +83,7 @@ public class MmoInfoCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
} }
for(SubSkillType subSkillType : SubSkillType.values()) for (SubSkillType subSkillType : SubSkillType.values()) {
{
if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName)) if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
subSkillName = subSkillType.getWikiName(subSkillType.toString()); subSkillName = subSkillType.getWikiName(subSkillType.toString());
} }

View File

@ -33,11 +33,9 @@ import java.util.Set;
public abstract class SkillCommand implements TabExecutor { public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill; protected PrimarySkillType skill;
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00"); protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
private CommandExecutor skillGuideCommand; private CommandExecutor skillGuideCommand;
public SkillCommand(PrimarySkillType skill) { public SkillCommand(PrimarySkillType skill) {
@ -46,6 +44,15 @@ public abstract class SkillCommand implements TabExecutor {
skillGuideCommand = new SkillGuideCommand(skill); skillGuideCommand = new SkillGuideCommand(skill);
} }
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -56,8 +63,7 @@ public abstract class SkillCommand implements TabExecutor {
return true; return true;
} }
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
@ -73,8 +79,7 @@ public abstract class SkillCommand implements TabExecutor {
//Send the players a few blank lines to make finding the top of the skill command easier //Send the players a few blank lines to make finding the top of the skill command easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for(int i = 0; i < 2; i++) for (int i = 0; i < 2; i++) {
{
player.sendMessage(""); player.sendMessage("");
} }
@ -105,8 +110,7 @@ public abstract class SkillCommand implements TabExecutor {
//Link Header //Link Header
if(mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks()) if (mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks()) {
{
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player); TextComponentFactory.sendPlayerUrlHeader(player);
} }
@ -146,8 +150,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if(!skill.isChildSkill()) if (!skill.isChildSkill()) {
{
/* /*
* NON-CHILD SKILLS * NON-CHILD SKILLS
*/ */
@ -173,10 +176,8 @@ public abstract class SkillCommand implements TabExecutor {
StringBuilder parentMessage = new StringBuilder(); StringBuilder parentMessage = new StringBuilder();
for(int i = 0; i < parentList.size(); i++) for (int i = 0; i < parentList.size(); i++) {
{ if (i + 1 < parentList.size()) {
if(i+1 < parentList.size())
{
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))));
parentMessage.append(ChatColor.GRAY + ", "); parentMessage.append(ChatColor.GRAY + ", ");
} else { } else {
@ -237,11 +238,9 @@ public abstract class SkillCommand implements TabExecutor {
int length; int length;
if(abilityLengthCap <= 0) if (abilityLengthCap <= 0) {
{
length = 2 + (int) (skillValue / abilityLengthVar); length = 2 + (int) (skillValue / abilityLengthVar);
} } else {
else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar); length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
} }
@ -254,35 +253,22 @@ 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 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 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();
if (isCustom) if (isCustom)
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars)); return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars));
else else {
{
String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars); String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
return LocaleLoader.getString(templateKey, mergedList); return LocaleLoader.getString(templateKey, mergedList);
} }
} }
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
protected abstract void dataCalculations(Player player, float skillValue); protected abstract void dataCalculations(Player player, float skillValue);
protected abstract void permissionsCheck(Player player); protected abstract void permissionsCheck(Player player);
@ -295,12 +281,12 @@ public abstract class SkillCommand implements TabExecutor {
/** /**
* Checks if a player can use a skill * Checks if a player can use a skill
*
* @param player target player * @param player target player
* @param subSkillType target subskill * @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked * @return true if the player has permission and has the skill unlocked
*/ */
protected boolean canUseSubskill(Player player, SubSkillType subSkillType) protected boolean canUseSubskill(Player player, SubSkillType subSkillType) {
{
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType); return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
} }
} }

View File

@ -75,8 +75,7 @@ public class SkillGuideCommand implements CommandExecutor {
while (allStrings.size() < 9) { while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) { if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add(""); allStrings.add("");
} } else {
else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1))); allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
} }
} }

View File

@ -94,8 +94,7 @@ public class SwordsCommand extends SkillCommand {
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : "")); + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
} }
if(canUseSubskill(player, SubSkillType.SWORDS_STAB)) if (canUseSubskill(player, SubSkillType.SWORDS_STAB)) {
{
messages.add(getStatMessage(SubSkillType.SWORDS_STAB, messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage()))); String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage())));
} }

View File

@ -130,16 +130,12 @@ public class AdvancedConfig extends ConfigValidated {
super("advanced", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); super("advanced", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
} }
@Override
public void unload() {
//do nothing
}
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated
@ -147,6 +143,11 @@ public class AdvancedConfig extends ConfigValidated {
return mcMMO.getConfigManager().getAdvancedConfig(); return mcMMO.getConfigManager().getAdvancedConfig();
} }
@Override
public void unload() {
//do nothing
}
/** /**
* The version of this config * The version of this config
* *
@ -239,8 +240,7 @@ public class AdvancedConfig extends ConfigValidated {
} }
/* AXES */ /* AXES */
if(getAxeMasteryRankDamageMultiplier() < 0) if (getAxeMasteryRankDamageMultiplier() < 0) {
{
reason.add(SKILLS + "." + AXES + "." + AXE_MASTERY + "." + RANK_DAMAGE_MULTIPLIER + " should be at least 0!"); reason.add(SKILLS + "." + AXES + "." + AXE_MASTERY + "." + RANK_DAMAGE_MULTIPLIER + " should be at least 0!");
} }
@ -499,6 +499,7 @@ public class AdvancedConfig extends ConfigValidated {
/** /**
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level. * This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
* It returns a different value depending on whether or not the server is in retro mode * It returns a different value depending on whether or not the server is in retro mode
*
* @return the level at which abilities stop increasing in length * @return the level at which abilities stop increasing in length
*/ */
public int getAbilityLengthCap() { public int getAbilityLengthCap() {
@ -511,6 +512,7 @@ public class AdvancedConfig extends ConfigValidated {
/** /**
* This returns the frequency at which abilities will increase in length * This returns the frequency at which abilities will increase in length
* It returns a different value depending on whether or not the server is in retro mode * It returns a different value depending on whether or not the server is in retro mode
*
* @return the number of levels required per ability length increase * @return the number of levels required per ability length increase
*/ */
public int getAbilityLength() { public int getAbilityLength() {
@ -520,12 +522,15 @@ public class AdvancedConfig extends ConfigValidated {
return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, RETRO_MODE, INCREASE_LEVEL); return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, RETRO_MODE, INCREASE_LEVEL);
} }
public int getEnchantBuff() { return getIntValue(SKILLS, GENERAL, ABILITY, ENCHANT_BUFF); } public int getEnchantBuff() {
return getIntValue(SKILLS, GENERAL, ABILITY, ENCHANT_BUFF);
}
/** /**
* Grabs the max bonus level for a skill used in RNG calculations * Grabs the max bonus level for a skill used in RNG calculations
* All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling * All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling
* A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling * A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling
*
* @param subSkillType target subskill * @param subSkillType target subskill
* @return the level at which this skills max benefits will be reached on the curve * @return the level at which this skills max benefits will be reached on the curve
*/ */
@ -550,30 +555,25 @@ public class AdvancedConfig extends ConfigValidated {
return maximumProbability; return maximumProbability;
} }
public double getMaximumProbability(AbstractSubSkill abstractSubSkill) public double getMaximumProbability(AbstractSubSkill abstractSubSkill) {
{
return getMaximumProbability(abstractSubSkill.getSubSkillType()); return getMaximumProbability(abstractSubSkill.getSubSkillType());
} }
/* Notification Settings */ /* Notification Settings */
public boolean doesSkillCommandSendBlankLines() public boolean doesSkillCommandSendBlankLines() {
{
return getBooleanValue(FEEDBACK, SKILL_COMMAND, BLANK_LINES_ABOVE_HEADER); return getBooleanValue(FEEDBACK, SKILL_COMMAND, BLANK_LINES_ABOVE_HEADER);
} }
public boolean doesNotificationUseActionBar(NotificationType notificationType) public boolean doesNotificationUseActionBar(NotificationType notificationType) {
{
return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), ENABLED); return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), ENABLED);
} }
public boolean doesNotificationSendCopyToChat(NotificationType notificationType) public boolean doesNotificationSendCopyToChat(NotificationType notificationType) {
{
return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), SEND_COPY_OF_MESSAGE_TO_CHAT); return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), SEND_COPY_OF_MESSAGE_TO_CHAT);
} }
public boolean useTitlesForXPEvent() public boolean useTitlesForXPEvent() {
{
return getBooleanValue(FEEDBACK, EVENTS, XP, SEND_TITLES); return getBooleanValue(FEEDBACK, EVENTS, XP, SEND_TITLES);
} }
@ -595,35 +595,72 @@ public class AdvancedConfig extends ConfigValidated {
} }
/* ACROBATICS */ /* ACROBATICS */
public double getDodgeDamageModifier() { return getDoubleValue(SKILLS, ACROBATICS, DODGE, DAMAGE_MODIFIER); } public double getDodgeDamageModifier() {
return getDoubleValue(SKILLS, ACROBATICS, DODGE, DAMAGE_MODIFIER);
}
public double getRollDamageThreshold() { return getDoubleValue(SKILLS, ACROBATICS, ROLL, DAMAGE_THRESHOLD); } public double getRollDamageThreshold() {
return getDoubleValue(SKILLS, ACROBATICS, ROLL, DAMAGE_THRESHOLD);
}
public double getGracefulRollDamageThreshold() { return getDoubleValue(SKILLS, ACROBATICS, GRACEFUL_ROLL, DAMAGE_THRESHOLD); } public double getGracefulRollDamageThreshold() {
return getDoubleValue(SKILLS, ACROBATICS, GRACEFUL_ROLL, DAMAGE_THRESHOLD);
}
/* ALCHEMY */ /* ALCHEMY */
public int getCatalysisMaxBonusLevel() { return getIntValue(SKILLS, ALCHEMY, CATALYSIS, MAX_BONUS_LEVEL); } public int getCatalysisMaxBonusLevel() {
return getIntValue(SKILLS, ALCHEMY, CATALYSIS, MAX_BONUS_LEVEL);
}
public double getCatalysisMinSpeed() { return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MIN_SPEED); } public double getCatalysisMinSpeed() {
public double getCatalysisMaxSpeed() { return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MAX_SPEED); } return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MIN_SPEED);
}
public double getCatalysisMaxSpeed() {
return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MAX_SPEED);
}
/* ARCHERY */ /* ARCHERY */
public double getSkillShotRankDamageMultiplier() { return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, RANK_DAMAGE_MULTIPLIER); } public double getSkillShotRankDamageMultiplier() {
public double getSkillShotDamageMax() { return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, MAX_DAMAGE); } return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, RANK_DAMAGE_MULTIPLIER);
}
public double getDazeBonusDamage() { return getDoubleValue(SKILLS, ARCHERY, DAZE, BONUS_DAMAGE); } public double getSkillShotDamageMax() {
return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, MAX_DAMAGE);
}
public double getForceMultiplier() { return getDoubleValue(SKILLS, ARCHERY, FORCE_MULTIPLIER); } public double getDazeBonusDamage() {
return getDoubleValue(SKILLS, ARCHERY, DAZE, BONUS_DAMAGE);
}
public double getForceMultiplier() {
return getDoubleValue(SKILLS, ARCHERY, FORCE_MULTIPLIER);
}
/* AXES */ /* AXES */
public double getAxeMasteryRankDamageMultiplier() { return getDoubleValue(SKILLS, AXES, AXE_MASTERY, RANK_DAMAGE_MULTIPLIER); } public double getAxeMasteryRankDamageMultiplier() {
return getDoubleValue(SKILLS, AXES, AXE_MASTERY, RANK_DAMAGE_MULTIPLIER);
}
public double getCriticalStrikesPVPModifier() { return getDoubleValue(SKILLS, AXES, CRITICAL_STRIKES, PVP_MODIFIER); } public double getCriticalStrikesPVPModifier() {
public double getCriticalStrikesPVEModifier() { return getDoubleValue(SKILLS, AXES, CRITICAL_STRIKES, PVE_MODIFIER); } return getDoubleValue(SKILLS, AXES, CRITICAL_STRIKES, PVP_MODIFIER);
}
public double getGreaterImpactChance() { return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, CHANCE); } public double getCriticalStrikesPVEModifier() {
public double getGreaterImpactModifier() { return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, KNOCKBACK_MODIFIER); } return getDoubleValue(SKILLS, AXES, CRITICAL_STRIKES, PVE_MODIFIER);
public double getGreaterImpactBonusDamage() { return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, BONUS_DAMAGE); } }
public double getGreaterImpactChance() {
return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, CHANCE);
}
public double getGreaterImpactModifier() {
return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, KNOCKBACK_MODIFIER);
}
public double getGreaterImpactBonusDamage() {
return getDoubleValue(SKILLS, AXES, GREATER_IMPACT, BONUS_DAMAGE);
}
public int getArmorImpactIncreaseLevel() { public int getArmorImpactIncreaseLevel() {
int increaseLevel = getIntValue(SKILLS, AXES, ARMOR_IMPACT, INCREASE_LEVEL); int increaseLevel = getIntValue(SKILLS, AXES, ARMOR_IMPACT, INCREASE_LEVEL);
@ -634,18 +671,33 @@ public class AdvancedConfig extends ConfigValidated {
return increaseLevel; return increaseLevel;
} }
public double getImpactChance() { return getDoubleValue(SKILLS, AXES, ARMOR_IMPACT, CHANCE); } public double getImpactChance() {
public double getArmorImpactMaxDurabilityDamage() { return getDoubleValue(SKILLS, AXES, ARMOR_IMPACT, MAX_PERCENTAGE_DURABILITY_DAMAGE); } return getDoubleValue(SKILLS, AXES, ARMOR_IMPACT, CHANCE);
}
public double getSkullSplitterModifier() { return getDoubleValue(SKILLS, AXES, SKULL_SPLITTER, DAMAGE_MODIFIER); } public double getArmorImpactMaxDurabilityDamage() {
return getDoubleValue(SKILLS, AXES, ARMOR_IMPACT, MAX_PERCENTAGE_DURABILITY_DAMAGE);
}
public double getSkullSplitterModifier() {
return getDoubleValue(SKILLS, AXES, SKULL_SPLITTER, DAMAGE_MODIFIER);
}
/* EXCAVATION */ /* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml //Nothing to configure, everything is already configurable in config.yml
/* FISHING */ /* FISHING */
public double getShakeChance(int rank) { return getDoubleValue(SKILLS, FISHING, SHAKE, CHANCE, RANK, String.valueOf(rank)); } public double getShakeChance(int rank) {
public double getMasterAnglerBoatModifier() {return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BOAT_MODIFIER); } return getDoubleValue(SKILLS, FISHING, SHAKE, CHANCE, RANK, String.valueOf(rank));
public double getMasterAnglerBiomeModifier() {return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BIOME_MODIFIER); } }
public double getMasterAnglerBoatModifier() {
return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BOAT_MODIFIER);
}
public double getMasterAnglerBiomeModifier() {
return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BIOME_MODIFIER);
}
/* HERBALISM */ /* HERBALISM */
//public int getFarmerDietRankChange() { return getIntValue(SKILLS, ".Herbalism.FarmersDiet.RankChange"); } //public int getFarmerDietRankChange() { return getIntValue(SKILLS, ".Herbalism.FarmersDiet.RankChange"); }
@ -653,67 +705,152 @@ public class AdvancedConfig extends ConfigValidated {
//public int getGreenThumbStageChange() { return getIntValue(SKILLS, ".Herbalism.GreenThumb.StageChange"); } //public int getGreenThumbStageChange() { return getIntValue(SKILLS, ".Herbalism.GreenThumb.StageChange"); }
/* MINING */ /* MINING */
public boolean getDoubleDropSilkTouchEnabled() { return getBooleanValue(SKILLS, MINING, "DoubleDrops", "SilkTouch"); } public boolean getDoubleDropSilkTouchEnabled() {
public int getBlastMiningRankLevel(int rank) { return getIntValue(SKILLS, MINING, BLAST_MINING, RANK, LEVELS, RANK, String.valueOf(rank)); } return getBooleanValue(SKILLS, MINING, "DoubleDrops", "SilkTouch");
public double getBlastDamageDecrease(int rank) { return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_DAMAGE_DECREASE, RANK, String.valueOf(rank)); } }
public double getOreBonus(int rank) { return getDoubleValue(SKILLS, MINING, BLAST_MINING, ORE_BONUS, RANK, String.valueOf(rank)); }
public double getDebrisReduction(int rank) { return getDoubleValue(SKILLS, MINING, BLAST_MINING, DEBRIS_REDUCTION, RANK, String.valueOf(rank)); } public int getBlastMiningRankLevel(int rank) {
public int getDropMultiplier(int rank) { return getIntValue(SKILLS, MINING, BLAST_MINING, DROP_MULTIPLIER, RANK, String.valueOf(rank)); } return getIntValue(SKILLS, MINING, BLAST_MINING, RANK, LEVELS, RANK, String.valueOf(rank));
public double getBlastRadiusModifier(int rank) { return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_RADIUS, MODIFIER, RANK, String.valueOf(rank)); } }
public double getBlastDamageDecrease(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_DAMAGE_DECREASE, RANK, String.valueOf(rank));
}
public double getOreBonus(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, ORE_BONUS, RANK, String.valueOf(rank));
}
public double getDebrisReduction(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, DEBRIS_REDUCTION, RANK, String.valueOf(rank));
}
public int getDropMultiplier(int rank) {
return getIntValue(SKILLS, MINING, BLAST_MINING, DROP_MULTIPLIER, RANK, String.valueOf(rank));
}
public double getBlastRadiusModifier(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_RADIUS, MODIFIER, RANK, String.valueOf(rank));
}
/* REPAIR */ /* REPAIR */
public double getRepairMasteryMaxBonus() { return getDoubleValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_PERCENTAGE); } public double getRepairMasteryMaxBonus() {
return getDoubleValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_PERCENTAGE);
}
//public int getRepairMasteryMaxLevel() { return getIntValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_LEVEL); } //public int getRepairMasteryMaxLevel() { return getIntValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_LEVEL); }
/* Arcane Forging */ /* Arcane Forging */
public boolean getArcaneForgingEnchantLossEnabled() { return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, MAY_LOSE_ENCHANTS); } public boolean getArcaneForgingEnchantLossEnabled() {
public double getArcaneForgingKeepEnchantsChance(int rank) { return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, KEEP_ENCHANTS, CHANCE, RANK, String.valueOf(rank)); } return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, MAY_LOSE_ENCHANTS);
}
public boolean getArcaneForgingDowngradeEnabled() { return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES_ENABLED); } public double getArcaneForgingKeepEnchantsChance(int rank) {
public double getArcaneForgingDowngradeChance(int rank) { return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES, CHANCE, RANK, String.valueOf(rank)); } return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, KEEP_ENCHANTS, CHANCE, RANK, String.valueOf(rank));
}
public boolean getArcaneForgingDowngradeEnabled() {
return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES_ENABLED);
}
public double getArcaneForgingDowngradeChance(int rank) {
return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES, CHANCE, RANK, String.valueOf(rank));
}
/* SALVAGE */ /* SALVAGE */
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_DOWNGRADE_ENABLED); } public boolean getArcaneSalvageEnchantDowngradeEnabled() {
public boolean getArcaneSalvageEnchantLossEnabled() { return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_LOSS_ENABLED); } return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_DOWNGRADE_ENABLED);
}
public double getArcaneSalvageExtractFullEnchantsChance(int rank) { return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_FULL_ENCHANT, RANK, String.valueOf(rank)); } public boolean getArcaneSalvageEnchantLossEnabled() {
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_PARTIAL_ENCHANT, RANK, String.valueOf(rank)); } return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_LOSS_ENABLED);
}
public double getArcaneSalvageExtractFullEnchantsChance(int rank) {
return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_FULL_ENCHANT, RANK, String.valueOf(rank));
}
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) {
return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_PARTIAL_ENCHANT, RANK, String.valueOf(rank));
}
/* SMELTING */ /* SMELTING */
//public int getBurnModifierMaxLevel() { return getIntValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MAX_BONUS_LEVEL); } //public int getBurnModifierMaxLevel() { return getIntValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MAX_BONUS_LEVEL); }
public double getBurnTimeMultiplier() { return getDoubleValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MULTIPLIER); } public double getBurnTimeMultiplier() {
return getDoubleValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MULTIPLIER);
}
public int getSmeltingRankLevel(int rank) { return getIntValue(SKILLS, SMELTING, RANK, LEVELS, RANK, String.valueOf(rank)); } public int getSmeltingRankLevel(int rank) {
return getIntValue(SKILLS, SMELTING, RANK, LEVELS, RANK, String.valueOf(rank));
}
public int getSmeltingVanillaXPBoostMultiplier(int rank) { return getIntValue(SKILLS, SMELTING, VANILLA_XPMULTIPLIER, RANK, String.valueOf(rank)); } public int getSmeltingVanillaXPBoostMultiplier(int rank) {
return getIntValue(SKILLS, SMELTING, VANILLA_XPMULTIPLIER, RANK, String.valueOf(rank));
}
/* SWORDS */ /* SWORDS */
public double getRuptureDamagePlayer() { return getDoubleValue(SKILLS, SWORDS, RUPTURE, DAMAGE_PLAYER); } public double getRuptureDamagePlayer() {
public double getRuptureDamageMobs() { return getDoubleValue(SKILLS, SWORDS, RUPTURE, DAMAGE_MOBS); } return getDoubleValue(SKILLS, SWORDS, RUPTURE, DAMAGE_PLAYER);
}
public int getRuptureMaxTicks() { return getIntValue(SKILLS, SWORDS, RUPTURE, MAX_TICKS); } public double getRuptureDamageMobs() {
public int getRuptureBaseTicks() { return getIntValue(SKILLS, SWORDS, RUPTURE, BASE_TICKS); } return getDoubleValue(SKILLS, SWORDS, RUPTURE, DAMAGE_MOBS);
}
public double getCounterAttackModifier() { return getDoubleValue(SKILLS, SWORDS, COUNTER_ATTACK, DAMAGE_MODIFIER); } public int getRuptureMaxTicks() {
return getIntValue(SKILLS, SWORDS, RUPTURE, MAX_TICKS);
}
public double getSerratedStrikesModifier() { return getDoubleValue(SKILLS, SWORDS, SERRATED_STRIKES, DAMAGE_MODIFIER); } public int getRuptureBaseTicks() {
return getIntValue(SKILLS, SWORDS, RUPTURE, BASE_TICKS);
}
public double getCounterAttackModifier() {
return getDoubleValue(SKILLS, SWORDS, COUNTER_ATTACK, DAMAGE_MODIFIER);
}
public double getSerratedStrikesModifier() {
return getDoubleValue(SKILLS, SWORDS, SERRATED_STRIKES, DAMAGE_MODIFIER);
}
//public int getSerratedStrikesTicks() { return getIntValue(SKILLS, SWORDS, SERRATED_STRIKES, RUPTURE, TICKS); } //public int getSerratedStrikesTicks() { return getIntValue(SKILLS, SWORDS, SERRATED_STRIKES, RUPTURE, TICKS); }
/* TAMING */ /* TAMING */
public double getGoreModifier() { return getDoubleValue(SKILLS, TAMING, GORE, MODIFIER); } public double getGoreModifier() {
public double getFastFoodChance() { return getDoubleValue(SKILLS, TAMING, FAST_FOOD_SERVICE, CHANCE); } return getDoubleValue(SKILLS, TAMING, GORE, MODIFIER);
public double getPummelChance() { return getDoubleValue(SKILLS, TAMING, PUMMEL, CHANCE); } }
public double getThickFurModifier() { return getDoubleValue(SKILLS, TAMING, THICK_FUR, MODIFIER); }
public double getShockProofModifier() { return getDoubleValue(SKILLS, TAMING, SHOCK_PROOF, MODIFIER); }
public double getSharpenedClawsBonus() { return getDoubleValue(SKILLS, TAMING, SHARPENED_CLAWS, BONUS); } public double getFastFoodChance() {
return getDoubleValue(SKILLS, TAMING, FAST_FOOD_SERVICE, CHANCE);
}
public double getMinHorseJumpStrength() { return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MIN_HORSE_JUMP_STRENGTH); } public double getPummelChance() {
public double getMaxHorseJumpStrength() { return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MAX_HORSE_JUMP_STRENGTH); } return getDoubleValue(SKILLS, TAMING, PUMMEL, CHANCE);
}
public double getThickFurModifier() {
return getDoubleValue(SKILLS, TAMING, THICK_FUR, MODIFIER);
}
public double getShockProofModifier() {
return getDoubleValue(SKILLS, TAMING, SHOCK_PROOF, MODIFIER);
}
public double getSharpenedClawsBonus() {
return getDoubleValue(SKILLS, TAMING, SHARPENED_CLAWS, BONUS);
}
public double getMinHorseJumpStrength() {
return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MIN_HORSE_JUMP_STRENGTH);
}
public double getMaxHorseJumpStrength() {
return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MAX_HORSE_JUMP_STRENGTH);
}
/* UNARMED */ /* UNARMED */
public boolean getDisarmProtected() { return getBooleanValue(SKILLS, UNARMED, DISARM, ANTI_THEFT); } public boolean getDisarmProtected() {
return getBooleanValue(SKILLS, UNARMED, DISARM, ANTI_THEFT);
}
/* WOODCUTTING */ /* WOODCUTTING */
} }

View File

@ -13,13 +13,11 @@ public class BonusDropManager implements Unload {
private HashMap<Material, Boolean> bonusDropWhitelist; private HashMap<Material, Boolean> bonusDropWhitelist;
public BonusDropManager() public BonusDropManager() {
{
bonusDropWhitelist = new HashMap<>(); bonusDropWhitelist = new HashMap<>();
//Start by setting all Materials to false to avoid null checks //Start by setting all Materials to false to avoid null checks
for(Material material : Material.values()) for (Material material : Material.values()) {
{
registerMaterial(material, false); registerMaterial(material, false);
} }
} }
@ -31,27 +29,24 @@ public class BonusDropManager implements Unload {
/** /**
* Adds materials to the bonus drop whitelist * Adds materials to the bonus drop whitelist
*
* @param materials target material list * @param materials target material list
*/ */
public void addToWhitelistByMaterial(List<Material> materials) public void addToWhitelistByMaterial(List<Material> materials) {
{ for (Material material : materials) {
for(Material material : materials)
{
registerMaterial(material, true); registerMaterial(material, true);
} }
} }
/** /**
* Adds materials to the bonus drop whitelist * Adds materials to the bonus drop whitelist
*
* @param materials target material list * @param materials target material list
*/ */
public void addToWhitelistByNameID(List<String> materials) public void addToWhitelistByNameID(List<String> materials) {
{ for (String material : materials) {
for(String material : materials)
{
Material m = Material.matchMaterial(material); Material m = Material.matchMaterial(material);
if(m == null) if (m == null) {
{
mcMMO.p.getLogger().severe("Error registering Bonus Drop -- Invalid Minecraft Name ID: " + material); mcMMO.p.getLogger().severe("Error registering Bonus Drop -- Invalid Minecraft Name ID: " + material);
continue; continue;
} }
@ -62,6 +57,7 @@ public class BonusDropManager implements Unload {
/** /**
* Adds a material to the bonus drop whitelist * Adds a material to the bonus drop whitelist
*
* @param material target material * @param material target material
*/ */
private void registerMaterial(Material material, boolean isWhitelisted) { private void registerMaterial(Material material, boolean isWhitelisted) {
@ -70,11 +66,11 @@ public class BonusDropManager implements Unload {
/** /**
* Check if a material can provide bonus drops * Check if a material can provide bonus drops
*
* @param material target material * @param material target material
* @return true if the material can provide bonus drops * @return true if the material can provide bonus drops
*/ */
public boolean isBonusDropWhitelisted(Material material) public boolean isBonusDropWhitelisted(Material material) {
{
return bonusDropWhitelist.get(material); return bonusDropWhitelist.get(material);
} }
} }

View File

@ -21,22 +21,20 @@ import java.util.List;
public abstract class Config implements VersionedConfig, Unload { public abstract class Config implements VersionedConfig, Unload {
public static final String HOCON_FILE_EXTENSION = ".conf"; public static final String HOCON_FILE_EXTENSION = ".conf";
public final File DIRECTORY_DATA_FOLDER; //Directory that the file is in
public final String FILE_RELATIVE_PATH; //Relative Path to the file
protected final String DIRECTORY_DEFAULTS = "defaults";
/* SETTINGS */ /* SETTINGS */
//private static final String FILE_EXTENSION = ".conf"; //HOCON //private static final String FILE_EXTENSION = ".conf"; //HOCON
private boolean mergeNewKeys; //Whether or not to merge keys found in the default config private boolean mergeNewKeys; //Whether or not to merge keys found in the default config
private boolean removeOldKeys; //Whether or not to remove unused keys form the config private boolean removeOldKeys; //Whether or not to remove unused keys form the config
/* PATH VARS */
private boolean copyDefaults; //Whether or not to copy the default config when first creating the file private boolean copyDefaults; //Whether or not to copy the default config when first creating the file
private boolean generateDefaults; //Whether or not we use Configurate to generate a default file, if this is false we copy the file from the JAR private boolean generateDefaults; //Whether or not we use Configurate to generate a default file, if this is false we copy the file from the JAR
private String fileName; //The file name of the config private String fileName; //The file name of the config
/* PATH VARS */
public final File DIRECTORY_DATA_FOLDER; //Directory that the file is in
public final String FILE_RELATIVE_PATH; //Relative Path to the file
protected final String DIRECTORY_DEFAULTS = "defaults";
/* LOADERS */ /* LOADERS */
private HoconConfigurationLoader defaultCopyLoader; private HoconConfigurationLoader defaultCopyLoader;
private HoconConfigurationLoader userCopyLoader; private HoconConfigurationLoader userCopyLoader;
@ -78,8 +76,7 @@ public abstract class Config implements VersionedConfig, Unload {
FILE_RELATIVE_PATH = relativePath + fileName + HOCON_FILE_EXTENSION; //Relative path to config from a parent folder FILE_RELATIVE_PATH = relativePath + fileName + HOCON_FILE_EXTENSION; //Relative path to config from a parent folder
} }
public void initFullConfig() public void initFullConfig() {
{
//Attempt IO Operations //Attempt IO Operations
try { try {
//Makes sure we have valid Files corresponding to this config //Makes sure we have valid Files corresponding to this config
@ -106,8 +103,7 @@ public abstract class Config implements VersionedConfig, Unload {
* Registers with the config managers unloader * Registers with the config managers unloader
* The unloader runs when the plugin gets disabled which cleans up registries to make reloading safe * The unloader runs when the plugin gets disabled which cleans up registries to make reloading safe
*/ */
private void registerUnload() private void registerUnload() {
{
mcMMO.getConfigManager().registerUnloadable(this); mcMMO.getConfigManager().registerUnloadable(this);
} }
@ -115,13 +111,13 @@ public abstract class Config implements VersionedConfig, Unload {
* Registers with the config managers file list * Registers with the config managers file list
* Used for backing up configs with our zip library * Used for backing up configs with our zip library
*/ */
private void registerFileBackup() private void registerFileBackup() {
{
mcMMO.getConfigManager().registerUserFile(getUserConfigFile()); mcMMO.getConfigManager().registerUserFile(getUserConfigFile());
} }
/** /**
* Initializes the default copy File and the user config File * Initializes the default copy File and the user config File
*
* @throws IOException * @throws IOException
*/ */
private void initConfigFiles() throws IOException { private void initConfigFiles() throws IOException {
@ -135,8 +131,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Loads the root node for the default config File and user config File * Loads the root node for the default config File and user config File
*/ */
private void loadConfig() private void loadConfig() {
{
try { try {
final CommentedConfigurationNode defaultConfig = this.defaultCopyLoader.load(); final CommentedConfigurationNode defaultConfig = this.defaultCopyLoader.load();
defaultRootNode = defaultConfig; defaultRootNode = defaultConfig;
@ -152,20 +147,19 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Initializes the Configuration Loaders for this config * Initializes the Configuration Loaders for this config
*/ */
private void initConfigLoaders() private void initConfigLoaders() {
{
this.defaultCopyLoader = HoconConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).build(); this.defaultCopyLoader = HoconConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).build();
this.userCopyLoader = HoconConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).build(); this.userCopyLoader = HoconConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).build();
} }
/** /**
* Copies a new file from the JAR to the defaults directory and uses that new file to initialize our resourceConfigCopy * Copies a new file from the JAR to the defaults directory and uses that new file to initialize our resourceConfigCopy
* @see Config#resourceConfigCopy *
* @throws IOException * @throws IOException
* @see Config#resourceConfigCopy
*/ */
private File initDefaultConfig() throws IOException { private File initDefaultConfig() throws IOException {
if(generateDefaults) if (generateDefaults) {
{
return generateDefaultFile(); return generateDefaultFile();
} else } else
return copyDefaultFromJar(getDefaultConfigCopyRelativePath(), true); return copyDefaultFromJar(getDefaultConfigCopyRelativePath(), true);
@ -174,10 +168,10 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Generates a default config file using the Configurate library, makes use of @Setting and @ConfigSerializable annotations in the config file * Generates a default config file using the Configurate library, makes use of @Setting and @ConfigSerializable annotations in the config file
* Assigns the default root node to the newly loaded default config if successful * Assigns the default root node to the newly loaded default config if successful
*
* @return the File for the newly created config * @return the File for the newly created config
*/ */
private File generateDefaultFile() private File generateDefaultFile() {
{
mcMMO.p.getLogger().info("Attempting to create a default config for " + fileName); mcMMO.p.getLogger().info("Attempting to create a default config for " + fileName);
//Not sure if this will work properly... //Not sure if this will work properly...
@ -212,26 +206,23 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Attemps to load the config file if it exists, if it doesn't it copies a new one from within the JAR * Attemps to load the config file if it exists, if it doesn't it copies a new one from within the JAR
*
* @return user config File * @return user config File
* @see Config#resourceUserCopy
* @throws IOException * @throws IOException
* @see Config#resourceUserCopy
*/ */
private File initUserConfig() throws IOException { private File initUserConfig() throws IOException {
File userCopy = new File(DIRECTORY_DATA_FOLDER, FILE_RELATIVE_PATH); //Load the user file; File userCopy = new File(DIRECTORY_DATA_FOLDER, FILE_RELATIVE_PATH); //Load the user file;
if(userCopy.exists()) if (userCopy.exists()) {
{
// Yay // Yay
return userCopy; return userCopy;
} } else {
else
{
//If it's gone we copy default files //If it's gone we copy default files
//Note that we don't copy the values from the default copy put in /defaults/ that file exists only as a reference to admins and is unreliable //Note that we don't copy the values from the default copy put in /defaults/ that file exists only as a reference to admins and is unreliable
if (copyDefaults) if (copyDefaults)
return copyDefaultFromJar(FILE_RELATIVE_PATH, false); return copyDefaultFromJar(FILE_RELATIVE_PATH, false);
else else {
{
//Make a new empty file //Make a new empty file
userCopy.createNewFile(); userCopy.createNewFile();
return userCopy; return userCopy;
@ -241,6 +232,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Gets the File representation of the this users config * Gets the File representation of the this users config
*
* @return the users config File * @return the users config File
*/ */
public File getUserConfigFile() { public File getUserConfigFile() {
@ -249,13 +241,13 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Used to make a new config file at a specified relative output path inside the data directory by copying the matching file found in that same relative path within the JAR * Used to make a new config file at a specified relative output path inside the data directory by copying the matching file found in that same relative path within the JAR
*
* @param relativeOutputPath the path to the output file * @param relativeOutputPath the path to the output file
* @param deleteOld whether or not to delete the existing output file on disk * @param deleteOld whether or not to delete the existing output file on disk
* @return a copy of the default config within the JAR * @return a copy of the default config within the JAR
* @throws IOException * @throws IOException
*/ */
private File copyDefaultFromJar(String relativeOutputPath, boolean deleteOld) throws IOException private File copyDefaultFromJar(String relativeOutputPath, boolean deleteOld) throws IOException {
{
/* /*
* Gen a Default config from inside the JAR * Gen a Default config from inside the JAR
*/ */
@ -270,14 +262,12 @@ public abstract class Config implements VersionedConfig, Unload {
File targetFile = new File(DIRECTORY_DATA_FOLDER, relativeOutputPath); File targetFile = new File(DIRECTORY_DATA_FOLDER, relativeOutputPath);
//Wipe old default file on disk //Wipe old default file on disk
if (targetFile.exists() && deleteOld) if (targetFile.exists() && deleteOld) {
{
mcMMO.p.getLogger().info("Updating file " + relativeOutputPath); mcMMO.p.getLogger().info("Updating file " + relativeOutputPath);
targetFile.delete(); //Necessary? targetFile.delete(); //Necessary?
} }
if(!targetFile.exists()) if (!targetFile.exists()) {
{
targetFile.getParentFile().mkdirs(); targetFile.getParentFile().mkdirs();
targetFile.createNewFile(); //New File Boys targetFile.createNewFile(); //New File Boys
} }
@ -292,6 +282,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* The path to the defaults directory * The path to the defaults directory
*
* @return the path to the defaults directory * @return the path to the defaults directory
*/ */
private String getDefaultConfigCopyRelativePath() { private String getDefaultConfigCopyRelativePath() {
@ -301,6 +292,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Grabs the File representation of the default config, which is stored on disk in a defaults folder * Grabs the File representation of the default config, which is stored on disk in a defaults folder
* this file will be overwritten every time mcMMO starts to keep it up to date. * this file will be overwritten every time mcMMO starts to keep it up to date.
*
* @return the copy of the default config file, stored in the defaults directory * @return the copy of the default config file, stored in the defaults directory
*/ */
private File getDefaultConfigFile() { private File getDefaultConfigFile() {
@ -316,10 +308,10 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Configs are versioned based on when they had significant changes to keys * Configs are versioned based on when they had significant changes to keys
*
* @return current MainConfig Version String * @return current MainConfig Version String
*/ */
public String getVersion() public String getVersion() {
{
return String.valueOf(getConfigVersion()); return String.valueOf(getConfigVersion());
} }
@ -342,8 +334,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Compares the users config file to the default and adds any missing nodes and applies any necessary updates * Compares the users config file to the default and adds any missing nodes and applies any necessary updates
*/ */
private void updateConfig() private void updateConfig() {
{
mcMMO.p.getLogger().info(defaultRootNode.getChildrenMap().size() + " items in default children map"); mcMMO.p.getLogger().info(defaultRootNode.getChildrenMap().size() + " items in default children map");
mcMMO.p.getLogger().info(userRootNode.getChildrenMap().size() + " items in default root map"); mcMMO.p.getLogger().info(userRootNode.getChildrenMap().size() + " items in default root map");
@ -368,23 +359,21 @@ public abstract class Config implements VersionedConfig, Unload {
* Finds any keys in the users config that are not present in the default config and removes them * Finds any keys in the users config that are not present in the default config and removes them
*/ */
//TODO: Finish this //TODO: Finish this
private void removeOldKeys() private void removeOldKeys() {
{
if (!removeOldKeys) if (!removeOldKeys)
return; return;
for(CommentedConfigurationNode CommentedConfigurationNode : defaultRootNode.getChildrenList()) for (CommentedConfigurationNode CommentedConfigurationNode : defaultRootNode.getChildrenList()) {
{
} }
} }
/** /**
* Saves the current state information of the config to the users copy (which they may edit) * Saves the current state information of the config to the users copy (which they may edit)
*
* @throws IOException * @throws IOException
*/ */
private void saveUserCopy() throws IOException private void saveUserCopy() throws IOException {
{
mcMMO.p.getLogger().info("Saving new node"); mcMMO.p.getLogger().info("Saving new node");
userCopyLoader.save(userRootNode); userCopyLoader.save(userRootNode);
} }
@ -400,6 +389,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Returns the root node of this config * Returns the root node of this config
*
* @return the root node of this config * @return the root node of this config
*/ */
protected CommentedConfigurationNode getUserRootNode() { protected CommentedConfigurationNode getUserRootNode() {
@ -408,62 +398,67 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Gets an int from the config and casts it to short before returning * Gets an int from the config and casts it to short before returning
*
* @param path the path to the int * @param path the path to the int
* @return the value of the int after being cast to short at the node, null references will zero initialize * @return the value of the int after being cast to short at the node, null references will zero initialize
*/ */
public short getShortValue(String... path) { return (short) userRootNode.getNode(path).getInt();} public short getShortValue(String... path) {
return (short) userRootNode.getNode(path).getInt();
}
/** /**
* Grabs an int from the specified node * Grabs an int from the specified node
*
* @param path * @param path
* @return the int from the node, null references will zero initialize * @return the int from the node, null references will zero initialize
*/ */
public int getIntValue(String... path) public int getIntValue(String... path) {
{
return userRootNode.getNode(path).getInt(); return userRootNode.getNode(path).getInt();
} }
/** /**
* Grabs a double from the specified node * Grabs a double from the specified node
*
* @param path * @param path
* @return the double from the node, null references will zero initialize * @return the double from the node, null references will zero initialize
*/ */
public double getDoubleValue(String... path) public double getDoubleValue(String... path) {
{
return userRootNode.getNode(path).getDouble(); return userRootNode.getNode(path).getDouble();
} }
/** /**
* Grabs a long from the specified node * Grabs a long from the specified node
*
* @param path * @param path
* @return the long from the node, null references will zero initialize * @return the long from the node, null references will zero initialize
*/ */
public long getLongValue(String... path) public long getLongValue(String... path) {
{
return userRootNode.getNode(path).getLong(); return userRootNode.getNode(path).getLong();
} }
/** /**
* Grabs a boolean from the specified node * Grabs a boolean from the specified node
*
* @param path * @param path
* @return the boolean from the node, null references will zero initialize * @return the boolean from the node, null references will zero initialize
*/ */
public boolean getBooleanValue(String... path) public boolean getBooleanValue(String... path) {
{
return userRootNode.getNode(path).getBoolean(); return userRootNode.getNode(path).getBoolean();
} }
/** /**
* Grabs a string from the specified node * Grabs a string from the specified node
*
* @param path * @param path
* @return the string from the node, null references will zero initialize * @return the string from the node, null references will zero initialize
*/ */
public String getStringValue(String... path) public String getStringValue(String... path) {
{
return userRootNode.getNode(path).getString(); return userRootNode.getNode(path).getString();
} }
/** /**
* Checks to see if a node exists in the user's config file * Checks to see if a node exists in the user's config file
*
* @param path path to the node * @param path path to the node
* @return true if the node exists * @return true if the node exists
*/ */
@ -473,6 +468,7 @@ public abstract class Config implements VersionedConfig, Unload {
/** /**
* Returns the children of a specific node * Returns the children of a specific node
*
* @param path the path to the parent node * @param path the path to the parent node
* @return the list of children for the target parent node * @return the list of children for the target parent node
*/ */
@ -480,8 +476,7 @@ public abstract class Config implements VersionedConfig, Unload {
return userRootNode.getNode(path).getChildrenList(); return userRootNode.getNode(path).getChildrenList();
} }
public List<String> getListFromNode(String... path) throws ObjectMappingException public List<String> getListFromNode(String... path) throws ObjectMappingException {
{
return userRootNode.getNode(path).getList(TypeToken.of(String.class)); return userRootNode.getNode(path).getList(TypeToken.of(String.class));
} }
} }

View File

@ -9,11 +9,19 @@ import java.util.ArrayList;
* Constants relating to config folders and paths * Constants relating to config folders and paths
*/ */
public class ConfigConstants { public class ConfigConstants {
private final static String[] EXAMPLE_BLACKLIST_WORLDS = {"Example_15434453", "Example_2324423", "Example_323423465"};
public final static ArrayList<String> EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT; public final static ArrayList<String> EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT;
public final static String SKILL_SCALING_BENEFIT_EXPLANATION = "\nSub-Skills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + public final static String SKILL_SCALING_BENEFIT_EXPLANATION = "\nSub-Skills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " +
"\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of that sub-skill."; "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of that sub-skill.";
/* FOLDER NAMES */
public static final String FOLDER_NAME_CONFIG = "config";
public static final String FOLDER_NAME_SKILLS = "skills";
public static final String FOLDER_NAME_EXPERIENCE = "Experience Settings";
public static final String FOLDER_NAME_DEFAULTS = "defaults";
/* RELATIVE PATHS */
public final static String RELATIVE_PATH_CONFIG_DIR = File.separator + FOLDER_NAME_CONFIG + File.separator;
public final static String RELATIVE_PATH_SKILLS_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_SKILLS + File.separator;
public final static String RELATIVE_PATH_XP_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_EXPERIENCE + File.separator;
private final static String[] EXAMPLE_BLACKLIST_WORLDS = {"Example_15434453", "Example_2324423", "Example_323423465"};
//Add the worlds to the list //Add the worlds to the list
static { static {
@ -23,23 +31,12 @@ public class ConfigConstants {
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]); EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]);
} }
/* FOLDER NAMES */
public static final String FOLDER_NAME_CONFIG = "config";
public static final String FOLDER_NAME_SKILLS = "skills";
public static final String FOLDER_NAME_EXPERIENCE = "Experience Settings";
public static final String FOLDER_NAME_DEFAULTS = "defaults";
/* RELATIVE PATHS */
public final static String RELATIVE_PATH_CONFIG_DIR = File.separator + FOLDER_NAME_CONFIG + File.separator;
public final static String RELATIVE_PATH_SKILLS_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_SKILLS + File.separator;
public final static String RELATIVE_PATH_XP_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_EXPERIENCE + File.separator;
/** /**
* Return the data folder for mcMMO * Return the data folder for mcMMO
*
* @return the File for the data folder used by mcMMO * @return the File for the data folder used by mcMMO
*/ */
public static File getDataFolder() public static File getDataFolder() {
{
return mcMMO.p.getDataFolder(); return mcMMO.p.getDataFolder();
} }
@ -74,8 +71,7 @@ public class ConfigConstants {
/** /**
* Creates all directories used by mcMMO config files * Creates all directories used by mcMMO config files
*/ */
public static void makeAllConfigDirectories() public static void makeAllConfigDirectories() {
{
/* CONFIG DIRECTORY */ /* CONFIG DIRECTORY */
if (!getConfigFolder().exists()) if (!getConfigFolder().exists())

View File

@ -65,37 +65,32 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
/** /**
*
* The Config Manager handles initializing, loading, and unloading registers for all configs that mcMMO uses * The Config Manager handles initializing, loading, and unloading registers for all configs that mcMMO uses
* This makes sure that mcMMO properly loads and unloads its values on reload * This makes sure that mcMMO properly loads and unloads its values on reload
* * <p>
* Config Manager also holds all of our MultiConfigContainers * Config Manager also holds all of our MultiConfigContainers
*/ */
public final class ConfigManager { public final class ConfigManager {
/* UNLOAD REGISTER */ /* UNLOAD REGISTER */
SkillPropertiesManager skillPropertiesManager;
private ArrayList<Unload> unloadables; private ArrayList<Unload> unloadables;
private ArrayList<File> userFiles;
/* COLLECTION MANAGERS */ /* COLLECTION MANAGERS */
private ArrayList<File> userFiles;
private RepairableManager repairableManager; private RepairableManager repairableManager;
private SalvageableManager salvageableManager; private SalvageableManager salvageableManager;
private BonusDropManager bonusDropManager;
/* CUSTOM SERIALIZERS */ /* CUSTOM SERIALIZERS */
private BonusDropManager bonusDropManager;
private TypeSerializerCollection customSerializers;
/* MOD MANAGERS */ /* MOD MANAGERS */
//TODO: Add these back when modded servers become a thing again //TODO: Add these back when modded servers become a thing again
/* MISC MANAGERS */ /* MISC MANAGERS */
private TypeSerializerCollection customSerializers;
SkillPropertiesManager skillPropertiesManager;
private ExperienceMapManager experienceMapManager; private ExperienceMapManager experienceMapManager;
/* CONFIG INSTANCES */ /* CONFIG INSTANCES */
@ -163,14 +158,12 @@ public final class ConfigManager {
private ArrayList<String> configErrors; //Collect errors to whine about to server admins private ArrayList<String> configErrors; //Collect errors to whine about to server admins
public ConfigManager() public ConfigManager() {
{
unloadables = new ArrayList<>(); unloadables = new ArrayList<>();
userFiles = new ArrayList<>(); userFiles = new ArrayList<>();
} }
public void loadConfigs() public void loadConfigs() {
{
//Register Custom Serializers //Register Custom Serializers
registerCustomTypeSerializers(); registerCustomTypeSerializers();
@ -314,9 +307,12 @@ public final class ConfigManager {
customSerializers = TypeSerializers.getDefaultSerializers().newChild(); customSerializers = TypeSerializers.getDefaultSerializers().newChild();
mcMMO.p.getLogger().info("Registering custom type serializers for Configurate..."); mcMMO.p.getLogger().info("Registering custom type serializers for Configurate...");
customSerializers.registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<Material>() {
customSerializers.registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer()); }, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<PartyFeature>() {
}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<FormulaType>() {
}, new CustomEnumValueSerializer());
customSerializers.registerType(TypeToken.of(Repairable.class), new RepairableSerializer()); customSerializers.registerType(TypeToken.of(Repairable.class), new RepairableSerializer());
customSerializers.registerType(TypeToken.of(Salvageable.class), new SalvageableSerializer()); customSerializers.registerType(TypeToken.of(Salvageable.class), new SalvageableSerializer());
customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer()); customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer());
@ -325,22 +321,21 @@ public final class ConfigManager {
/** /**
* Gets the serializers registered and used by mcMMO * Gets the serializers registered and used by mcMMO
* This includes all default serializers * This includes all default serializers
*
* @return our custom serializers * @return our custom serializers
*/ */
public TypeSerializerCollection getCustomSerializers() { public TypeSerializerCollection getCustomSerializers() {
return customSerializers; return customSerializers;
} }
private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz) private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz) {
{
skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(primarySkillType, clazz)); skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(primarySkillType, clazz));
} }
/** /**
* Misc managers * Misc managers
*/ */
private void initMiscManagers() private void initMiscManagers() {
{
experienceMapManager = new ExperienceMapManager(); experienceMapManager = new ExperienceMapManager();
} }
@ -361,8 +356,7 @@ public final class ConfigManager {
/** /**
* Initializes any managers related to config collections * Initializes any managers related to config collections
*/ */
private void initCollectionManagers() private void initCollectionManagers() {
{
// Handles registration of repairables // Handles registration of repairables
repairableManager = new RepairableManager(getRepairables()); repairableManager = new RepairableManager(getRepairables());
unloadables.add(repairableManager); unloadables.add(repairableManager);
@ -378,30 +372,28 @@ public final class ConfigManager {
/** /**
* Get all loaded repairables (loaded from all repairable configs) * Get all loaded repairables (loaded from all repairable configs)
*
* @return the currently loaded repairables * @return the currently loaded repairables
*/ */
public ArrayList<Repairable> getRepairables() public ArrayList<Repairable> getRepairables() {
{
return getConfigRepair().getConfigRepairablesList(); return getConfigRepair().getConfigRepairablesList();
} }
/** /**
* Get all loaded salvageables (loaded from all salvageable configs) * Get all loaded salvageables (loaded from all salvageable configs)
*
* @return the currently loaded salvageables * @return the currently loaded salvageables
*/ */
public ArrayList<Salvageable> getSalvageables() public ArrayList<Salvageable> getSalvageables() {
{
return getConfigSalvage().getConfigSalvageablesList(); return getConfigSalvage().getConfigSalvageablesList();
} }
/** /**
* Unloads all config options (prepares for reload) * Unloads all config options (prepares for reload)
*/ */
public void unloadAllConfigsAndRegisters() public void unloadAllConfigsAndRegisters() {
{
//Unload //Unload
for(Unload unloadable : unloadables) for (Unload unloadable : unloadables) {
{
unloadable.unload(); unloadable.unload();
} }
@ -414,8 +406,7 @@ public final class ConfigManager {
* Registers an unloadable * Registers an unloadable
* Unloadables call unload() on plugin disable to cleanup registries * Unloadables call unload() on plugin disable to cleanup registries
*/ */
public void registerUnloadable(Unload unload) public void registerUnloadable(Unload unload) {
{
if (!unloadables.contains(unload)) if (!unloadables.contains(unload))
unloadables.add(unload); unloadables.add(unload);
} }
@ -424,8 +415,7 @@ public final class ConfigManager {
* Registers an unloadable * Registers an unloadable
* Unloadables call unload() on plugin disable to cleanup registries * Unloadables call unload() on plugin disable to cleanup registries
*/ */
public void registerUserFile(File userFile) public void registerUserFile(File userFile) {
{
if (!userFiles.contains(userFile)) if (!userFiles.contains(userFile))
userFiles.add(userFile); userFiles.add(userFile);
} }
@ -433,15 +423,13 @@ public final class ConfigManager {
/** /**
* Registers bonus drops from several skill configs * Registers bonus drops from several skill configs
*/ */
public void registerBonusDrops() public void registerBonusDrops() {
{
bonusDropManager.addToWhitelistByNameID(getConfigMining().getBonusDrops()); bonusDropManager.addToWhitelistByNameID(getConfigMining().getBonusDrops());
// bonusDropManager.addToWhitelistByNameID(configHerbalism.getBonusDrops()); // bonusDropManager.addToWhitelistByNameID(configHerbalism.getBonusDrops());
// bonusDropManager.addToWhitelistByNameID(configWoodcutting.getBonusDrops()); // bonusDropManager.addToWhitelistByNameID(configWoodcutting.getBonusDrops());
} }
public void validateConfigs() public void validateConfigs() {
{
} }
@ -451,10 +439,10 @@ public final class ConfigManager {
/** /**
* Used to back up our zip files real easily * Used to back up our zip files real easily
*
* @return * @return
*/ */
public ArrayList<File> getConfigFiles() public ArrayList<File> getConfigFiles() {
{
return userFiles; return userFiles;
} }
@ -510,9 +498,13 @@ public final class ConfigManager {
return experienceMapManager; return experienceMapManager;
} }
public ConfigDatabase getConfigDatabase() { return configDatabase.getConfig(); } public ConfigDatabase getConfigDatabase() {
return configDatabase.getConfig();
}
public ConfigScoreboard getConfigScoreboard() { return configScoreboard.getConfig(); } public ConfigScoreboard getConfigScoreboard() {
return configScoreboard.getConfig();
}
public ConfigLeveling getConfigLeveling() { public ConfigLeveling getConfigLeveling() {
return configLeveling.getConfig(); return configLeveling.getConfig();
@ -658,25 +650,22 @@ public final class ConfigManager {
* Checks if this plugin is using retro mode * Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system * Retro mode is a 0-1000 skill system
* Standard mode is scaled for 1-100 * Standard mode is scaled for 1-100
*
* @return true if retro mode is enabled * @return true if retro mode is enabled
*/ */
public boolean isRetroMode() public boolean isRetroMode() {
{
return getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled(); return getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled();
} }
public boolean isBonusDropsEnabled(Material material) public boolean isBonusDropsEnabled(Material material) {
{
return getBonusDropManager().isBonusDropWhitelisted(material); return getBonusDropManager().isBonusDropWhitelisted(material);
} }
public double getSkillMaxBonusLevel(SubSkillType subSkillType) public double getSkillMaxBonusLevel(SubSkillType subSkillType) {
{
return skillPropertiesManager.getMaxBonusLevel(subSkillType); return skillPropertiesManager.getMaxBonusLevel(subSkillType);
} }
public double getSkillMaxChance(SubSkillType subSkillType) public double getSkillMaxChance(SubSkillType subSkillType) {
{
return skillPropertiesManager.getMaxChance(subSkillType); return skillPropertiesManager.getMaxChance(subSkillType);
} }

View File

@ -13,8 +13,7 @@ public abstract class ConfigValidated extends Config implements UnsafeValueValid
* @param mergeNewKeys if true, the users config will add keys found in the internal file that are missing from the users file during load * @param mergeNewKeys if true, the users config will add keys found in the internal file that are missing from the users file during load
* @param copyDefaults if true, the users config file when it is first made will be a copy of an internal resource file of the same name and path * @param copyDefaults if true, the users config file when it is first made will be a copy of an internal resource file of the same name and path
*/ */
public ConfigValidated(String fileName, File pathToParentFolder, String relativePath, boolean generateDefaults, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) public ConfigValidated(String fileName, File pathToParentFolder, String relativePath, boolean generateDefaults, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
{
super(fileName, pathToParentFolder, relativePath, generateDefaults, mergeNewKeys, copyDefaults, removeOldKeys); super(fileName, pathToParentFolder, relativePath, generateDefaults, mergeNewKeys, copyDefaults, removeOldKeys);
validateEntries(); validateEntries();
} }

View File

@ -19,8 +19,9 @@ public class CoreSkillsConfig extends Config {
/** /**
* This grabs an instance of the class from the Config Manager * This grabs an instance of the class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated

View File

@ -4,11 +4,13 @@ import java.util.Collection;
/** /**
* Represents a class that contains a generic collection * Represents a class that contains a generic collection
*
* @param <T> * @param <T>
*/ */
public interface GenericCollectionContainer<T> { public interface GenericCollectionContainer<T> {
/** /**
* Grab the collection held by this class * Grab the collection held by this class
*
* @return the collection held by this class * @return the collection held by this class
*/ */
Collection<T> getLoadedCollection(); Collection<T> getLoadedCollection();

View File

@ -208,8 +208,9 @@ public class MainConfig extends ConfigValidated {
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated

View File

@ -23,8 +23,9 @@ public class RankConfig extends ConfigValidated {
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated

View File

@ -6,8 +6,7 @@ import com.gmail.nossr50.util.StringUtils;
public class SkillConfigFactory { public class SkillConfigFactory {
protected static SerializedConfigLoader initSkillConfig(PrimarySkillType primarySkillType, Class<?> clazz) protected static SerializedConfigLoader initSkillConfig(PrimarySkillType primarySkillType, Class<?> clazz) {
{
return new SerializedConfigLoader(clazz, return new SerializedConfigLoader(clazz,
primarySkillType.toString().toLowerCase() + ".conf", primarySkillType.toString().toLowerCase() + ".conf",
StringUtils.getCapitalized(primarySkillType.toString()), StringUtils.getCapitalized(primarySkillType.toString()),

View File

@ -14,37 +14,31 @@ public class SkillPropertiesManager {
private HashMap<SubSkillType, Double> maxBonusLevelMap; private HashMap<SubSkillType, Double> maxBonusLevelMap;
private HashMap<SubSkillType, Double> maxBonusPercentage; private HashMap<SubSkillType, Double> maxBonusPercentage;
public SkillPropertiesManager() public SkillPropertiesManager() {
{
maxChanceMap = new HashMap<>(); maxChanceMap = new HashMap<>();
maxBonusLevelMap = new HashMap<>(); maxBonusLevelMap = new HashMap<>();
maxBonusPercentage = new HashMap<>(); maxBonusPercentage = new HashMap<>();
} }
public void registerRNG(SubSkillType subSkillType, ConfigSubSkillScalingRNG config) public void registerRNG(SubSkillType subSkillType, ConfigSubSkillScalingRNG config) {
{
maxChanceMap.put(subSkillType, config.getMaxChance()); maxChanceMap.put(subSkillType, config.getMaxChance());
maxBonusLevelMap.put(subSkillType, config.getMaxBonusLevel()); maxBonusLevelMap.put(subSkillType, config.getMaxBonusLevel());
} }
public double getMaxChance(SubSkillType subSkillType) public double getMaxChance(SubSkillType subSkillType) {
{
return maxChanceMap.get(subSkillType); return maxChanceMap.get(subSkillType);
} }
public double getMaxBonusLevel(SubSkillType subSkillType) public double getMaxBonusLevel(SubSkillType subSkillType) {
{
return maxBonusLevelMap.get(subSkillType); return maxBonusLevelMap.get(subSkillType);
} }
public void fillRegisters() public void fillRegisters() {
{
fillRNGRegisters(); fillRNGRegisters();
} }
private void fillRNGRegisters() private void fillRNGRegisters() {
{
//Acrobatics //Acrobatics
registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getDodge().getRNGSettings()); registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getDodge().getRNGSettings());
registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getRoll().getRNGSettings()); registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getRoll().getRNGSettings());

View File

@ -24,8 +24,9 @@ public class SoundConfig extends ConfigValidated {
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated

View File

@ -13,18 +13,15 @@ public interface UnsafeValueValidation {
/** /**
* Prints all errors found when validating the config * Prints all errors found when validating the config
*/ */
default void validateEntries() default void validateEntries() {
{
/* /*
* Print Errors about Keys * Print Errors about Keys
*/ */
List<String> validKeyErrors = validateKeys(); // Validate Keys List<String> validKeyErrors = validateKeys(); // Validate Keys
if(validKeyErrors != null && validKeyErrors.size() > 0) if (validKeyErrors != null && validKeyErrors.size() > 0) {
{ for (String error : validKeyErrors) {
for(String error : validKeyErrors)
{
mcMMO.p.getLogger().severe(error); mcMMO.p.getLogger().severe(error);
} }
} }

View File

@ -6,6 +6,7 @@ package com.gmail.nossr50.config;
public interface VersionedConfig { public interface VersionedConfig {
/** /**
* The version of this config * The version of this config
*
* @return * @return
*/ */
double getConfigVersion(); double getConfigVersion();

View File

@ -86,8 +86,9 @@ public class ExperienceConfig extends ConfigValidated {
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated
@ -168,9 +169,6 @@ public class ExperienceConfig extends ConfigValidated {
return reason; return reason;
} }
/* /*
* FORMULA SETTINGS * FORMULA SETTINGS
*/ */
@ -185,8 +183,7 @@ public class ExperienceConfig extends ConfigValidated {
return getDoubleValue(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL); return getDoubleValue(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL);
} }
public void setGlobalXPMultiplier(double newXpMultiplier) public void setGlobalXPMultiplier(double newXpMultiplier) {
{
getUserRootNode().getNode(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL).setValue(newXpMultiplier); getUserRootNode().getNode(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL).setValue(newXpMultiplier);
} }
@ -266,6 +263,7 @@ public class ExperienceConfig extends ConfigValidated {
/** /**
* Gets the raw XP given for breaking this block, this does not include modifiers * Gets the raw XP given for breaking this block, this does not include modifiers
*
* @param skill The skill to give XP for * @param skill The skill to give XP for
* @param blockType the type of block * @param blockType the type of block
* @return the raw amount of XP for this block before modifiers * @return the raw amount of XP for this block before modifiers

View File

@ -4,13 +4,11 @@ import com.gmail.nossr50.util.StringUtils;
public final class HOCONUtil { public final class HOCONUtil {
public static String serializeENUMName(String hyphenedString) public static String serializeENUMName(String hyphenedString) {
{
String[] split = hyphenedString.split("_"); String[] split = hyphenedString.split("_");
StringBuilder formattedString = new StringBuilder(); StringBuilder formattedString = new StringBuilder();
for(int x = 0; x < split.length; x++) for (int x = 0; x < split.length; x++) {
{
if (x + 1 >= split.length) if (x + 1 >= split.length)
formattedString.append(StringUtils.getCapitalized(split[x])); formattedString.append(StringUtils.getCapitalized(split[x]));
else else
@ -20,13 +18,11 @@ public final class HOCONUtil {
return formattedString.toString(); return formattedString.toString();
} }
public static String deserializeENUMName(String serializedName) public static String deserializeENUMName(String serializedName) {
{
String[] split = serializedName.split("-"); String[] split = serializedName.split("-");
StringBuilder formattedString = new StringBuilder(); StringBuilder formattedString = new StringBuilder();
for(int x = 0; x < split.length; x++) for (int x = 0; x < split.length; x++) {
{
if (x + 1 >= split.length) if (x + 1 >= split.length)
formattedString.append(split[x].toUpperCase()); formattedString.append(split[x].toUpperCase());
else else

View File

@ -46,7 +46,8 @@ public class RepairableSerializer implements TypeSerializer<Repairable> {
/* Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) */ /* Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) */
String item = value.getNode(ITEM).getValue(TypeToken.of(String.class)); String item = value.getNode(ITEM).getValue(TypeToken.of(String.class));
List<String> repairItems = value.getNode(ITEMS_USED_TO_REPAIR).getValue(new TypeToken<List<String>>() {}); List<String> repairItems = value.getNode(ITEMS_USED_TO_REPAIR).getValue(new TypeToken<List<String>>() {
});
/*String itemConstant = HOCONUtil.deserializeENUMName(value.getNode("Item").getString()); /*String itemConstant = HOCONUtil.deserializeENUMName(value.getNode("Item").getString());
@ -74,8 +75,7 @@ public class RepairableSerializer implements TypeSerializer<Repairable> {
value.getNode(XP_MULTIPLIER).setValue(obj.getXpMultiplier()); value.getNode(XP_MULTIPLIER).setValue(obj.getXpMultiplier());
} }
private Enum getEnum(String enumConstant, TypeToken<?> type) throws ObjectMappingException private Enum getEnum(String enumConstant, TypeToken<?> type) throws ObjectMappingException {
{
//noinspection RedundantCast //noinspection RedundantCast
Optional<Enum> ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class), Optional<Enum> ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class),
enumConstant); // XXX: intellij says this cast is optional but it isnt enumConstant); // XXX: intellij says this cast is optional but it isnt

View File

@ -61,8 +61,7 @@ public class SalvageableSerializer implements TypeSerializer<Salvageable> {
value.getNode(OVERRIDE_LEVEL_REQUIREMENT).setValue(obj.getMinimumLevel()); value.getNode(OVERRIDE_LEVEL_REQUIREMENT).setValue(obj.getMinimumLevel());
} }
private Enum getEnum(String enumConstant, TypeToken<?> type) throws ObjectMappingException private Enum getEnum(String enumConstant, TypeToken<?> type) throws ObjectMappingException {
{
//noinspection RedundantCast //noinspection RedundantCast
Optional<Enum> ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class), Optional<Enum> ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class),
enumConstant); // XXX: intellij says this cast is optional but it isnt enumConstant); // XXX: intellij says this cast is optional but it isnt

View File

@ -49,6 +49,7 @@ import java.util.Objects;
/** /**
* Handles loading serialized configs with configurate * Handles loading serialized configs with configurate
*
* @param <T> the class type of the config * @param <T> the class type of the config
*/ */
public class SerializedConfigLoader<T> { public class SerializedConfigLoader<T> {
@ -61,20 +62,15 @@ public class SerializedConfigLoader<T> {
"\nOfficial mcMMO Discord - https://discord.gg/bJ7pFS9\n" + "\nOfficial mcMMO Discord - https://discord.gg/bJ7pFS9\n" +
"\nYou can also consult the new official wiki" + "\nYou can also consult the new official wiki" +
"\nhttps://mcmmo.org/wiki - Keep in mind the wiki is a WIP and may not have information about everything in mcMMO!"; "\nhttps://mcmmo.org/wiki - Keep in mind the wiki is a WIP and may not have information about everything in mcMMO!";
private ConfigurationOptions configurationOptions;
private CommentedConfigurationNode data;
private CommentedConfigurationNode fileData;
private final String ROOT_NODE_ADDRESS; private final String ROOT_NODE_ADDRESS;
private final Path path; private final Path path;
/** /**
* The parent configuration - values are inherited from this * The parent configuration - values are inherited from this
*/ */
private final SerializedConfigLoader parent; private final SerializedConfigLoader parent;
private ConfigurationOptions configurationOptions;
private CommentedConfigurationNode data;
private CommentedConfigurationNode fileData;
/** /**
* The loader (mapped to a file) used to read/write the config to disk * The loader (mapped to a file) used to read/write the config to disk
*/ */
@ -115,8 +111,7 @@ public class SerializedConfigLoader<T> {
} }
} }
private Path getPathFromFileName(String fileName) private Path getPathFromFileName(String fileName) {
{
File configFile = new File(ConfigConstants.getConfigFolder(), fileName); File configFile = new File(ConfigConstants.getConfigFolder(), fileName);
return configFile.toPath(); return configFile.toPath();
} }

View File

@ -5,14 +5,13 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class AntiExploit { public class AntiExploit {
public static final boolean SPAWNED_MOBS_DEFAULT = true;
private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true; private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true;
private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true; private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true;
public static final boolean SPAWNED_MOBS_DEFAULT = true;
/* /*
* CONFIG NODES * CONFIG NODES
*/ */
@Setting(value = "Endermen-Endermite-Fix", @Setting(value = "Endermen-Endermite-Fix",
comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." + comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." +
"\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" + "\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" +

View File

@ -6,12 +6,11 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigSectionExploitFishing { public class ConfigSectionExploitFishing {
private static final boolean PREVENT_FISHING_EXPLOITS_DEFAULT = true;
public static final int OVER_FISHING_LIMIT_DEFAULT = 3; public static final int OVER_FISHING_LIMIT_DEFAULT = 3;
public static final boolean ADMINS_OVER_FISHING_DEFAULT = true; public static final boolean ADMINS_OVER_FISHING_DEFAULT = true;
public static final float OVER_FISHING_SIZE = 1.0F; public static final float OVER_FISHING_SIZE = 1.0F;
public static final int FISHING_ROD_SPAM_THRESHOLD_MILLISECONDS_DEFAULT = 200; public static final int FISHING_ROD_SPAM_THRESHOLD_MILLISECONDS_DEFAULT = 200;
private static final boolean PREVENT_FISHING_EXPLOITS_DEFAULT = true;
@Setting(value = "Prevent-Fishing-AFK-Farming", @Setting(value = "Prevent-Fishing-AFK-Farming",
comment = "Prevents many methods for automatically farming Fishing XP." + comment = "Prevents many methods for automatically farming Fishing XP." +
"\nSuch as farming in the same spot more than once." + "\nSuch as farming in the same spot more than once." +

View File

@ -6,11 +6,10 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigSectionGeneral { public class ConfigSectionGeneral {
private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true;
private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true;
public static final boolean SPAWNED_MOBS_DEFAULT = true; public static final boolean SPAWNED_MOBS_DEFAULT = true;
public static final boolean TAMED_MOB_DEFAULT = true; public static final boolean TAMED_MOB_DEFAULT = true;
private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true;
private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true;
@Setting(value = "Endermen-Endermite-Fix", @Setting(value = "Endermen-Endermite-Fix",
comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." + comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." +
"\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" + "\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" +

View File

@ -8,18 +8,16 @@ public class ConfigCommandsAdminChat {
private static final String ADMIN_CHAT_PREFIX_DEFAULT = "&b[&f{0}&b]"; private static final String ADMIN_CHAT_PREFIX_DEFAULT = "&b[&f{0}&b]";
private static final boolean USE_DISPLAY_NAMES_DEFAULT = true; private static final boolean USE_DISPLAY_NAMES_DEFAULT = true;
@Setting(value = "Admin-Chat-Prefix", comment = "Formatting use at the beginning of an admin chat message." +
"\nYou can use & color codes here or type stuff like [[RED]]." +
"\nDefault value: "+ADMIN_CHAT_PREFIX_DEFAULT)
private String adminChatPrefix = ADMIN_CHAT_PREFIX_DEFAULT;
@Setting(value = "Whether or not to use Display Names for admin chat." + @Setting(value = "Whether or not to use Display Names for admin chat." +
"\nDisplay names are the current visible name of a player in the scoreboard, chat, and so on." + "\nDisplay names are the current visible name of a player in the scoreboard, chat, and so on." +
"\nThese names are modified by mods and are not necessarily the same nickname that a player has associated with their account." + "\nThese names are modified by mods and are not necessarily the same nickname that a player has associated with their account." +
"\nIf you turn this off, mcMMO will use a players registered nickname with their Minecraft account instead." + "\nIf you turn this off, mcMMO will use a players registered nickname with their Minecraft account instead." +
"\nDefault value: " + USE_DISPLAY_NAMES_DEFAULT) "\nDefault value: " + USE_DISPLAY_NAMES_DEFAULT)
public boolean useDisplayNames = USE_DISPLAY_NAMES_DEFAULT; public boolean useDisplayNames = USE_DISPLAY_NAMES_DEFAULT;
@Setting(value = "Admin-Chat-Prefix", comment = "Formatting use at the beginning of an admin chat message." +
"\nYou can use & color codes here or type stuff like [[RED]]." +
"\nDefault value: " + ADMIN_CHAT_PREFIX_DEFAULT)
private String adminChatPrefix = ADMIN_CHAT_PREFIX_DEFAULT;
public String getAdminChatPrefix() { public String getAdminChatPrefix() {
return adminChatPrefix; return adminChatPrefix;

View File

@ -53,10 +53,8 @@ public class ConfigSectionMySQL {
* HELPER METHODS * HELPER METHODS
*/ */
public int getMaxPoolSize(PoolIdentifier poolIdentifier) public int getMaxPoolSize(PoolIdentifier poolIdentifier) {
{ switch (poolIdentifier) {
switch (poolIdentifier)
{
case LOAD: case LOAD:
return userConfigSectionServer.getConfigSectionMaxPoolSize().getLoad(); return userConfigSectionServer.getConfigSectionMaxPoolSize().getLoad();
case SAVE: case SAVE:
@ -68,10 +66,8 @@ public class ConfigSectionMySQL {
} }
} }
public int getMaxConnections(PoolIdentifier poolIdentifier) public int getMaxConnections(PoolIdentifier poolIdentifier) {
{ switch (poolIdentifier) {
switch (poolIdentifier)
{
case LOAD: case LOAD:
return userConfigSectionServer.getConfigSectionMaxConnections().getLoad(); return userConfigSectionServer.getConfigSectionMaxConnections().getLoad();
case SAVE: case SAVE:

View File

@ -26,23 +26,19 @@ public class ConfigExperienceAlchemy {
return alchemyXPMap; return alchemyXPMap;
} }
public int getStageOnePotionXP() public int getStageOnePotionXP() {
{
return alchemyXPMap.get("Stage-One-Potion"); return alchemyXPMap.get("Stage-One-Potion");
} }
public int getStageTwoPotionXP() public int getStageTwoPotionXP() {
{
return alchemyXPMap.get("Stage-Two-Potion"); return alchemyXPMap.get("Stage-Two-Potion");
} }
public int getStageThreePotionXP() public int getStageThreePotionXP() {
{
return alchemyXPMap.get("Stage-Three-Potion"); return alchemyXPMap.get("Stage-Three-Potion");
} }
public int getStageFourPotionXP() public int getStageFourPotionXP() {
{
return alchemyXPMap.get("Stage-Four-Potion"); return alchemyXPMap.get("Stage-Four-Potion");
} }
@ -52,10 +48,8 @@ public class ConfigExperienceAlchemy {
return 0; return 0;
}*/ }*/
public int getPotionXPByStage(int potionStage) public int getPotionXPByStage(int potionStage) {
{ switch (potionStage) {
switch(potionStage)
{
case 1: case 1:
return getStageOnePotionXP(); return getStageOnePotionXP();
case 2: case 2:

View File

@ -9,6 +9,7 @@ import java.util.HashMap;
public class ConfigExperienceCombat { public class ConfigExperienceCombat {
private static final HashMap<String, Double> COMBAT_EXPERIENCE_DEFAULT; private static final HashMap<String, Double> COMBAT_EXPERIENCE_DEFAULT;
private static final boolean PVP_XP_ENABLED_DEFAULT = false;
static { static {
COMBAT_EXPERIENCE_DEFAULT = new HashMap<>(); COMBAT_EXPERIENCE_DEFAULT = new HashMap<>();
@ -73,8 +74,6 @@ public class ConfigExperienceCombat {
COMBAT_EXPERIENCE_DEFAULT.put("phantom", 4.0D); COMBAT_EXPERIENCE_DEFAULT.put("phantom", 4.0D);
} }
private static final boolean PVP_XP_ENABLED_DEFAULT = false;
@Setting(value = "Combat-XP-Multipliers") @Setting(value = "Combat-XP-Multipliers")
private HashMap<String, Double> combatExperienceMap = COMBAT_EXPERIENCE_DEFAULT; private HashMap<String, Double> combatExperienceMap = COMBAT_EXPERIENCE_DEFAULT;

View File

@ -8,8 +8,8 @@ import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigExperienceFishing { public class ConfigExperienceFishing {
private final static HashMap<String, Integer> FISHING_DEFAULT_XP_MAP;
public static final int SHAKE_XP_DEFAULT = 50; public static final int SHAKE_XP_DEFAULT = 50;
private final static HashMap<String, Integer> FISHING_DEFAULT_XP_MAP;
static { static {
FISHING_DEFAULT_XP_MAP = new HashMap<>(); FISHING_DEFAULT_XP_MAP = new HashMap<>();

View File

@ -2,12 +2,10 @@ package com.gmail.nossr50.config.hocon.notifications;
public class ActionBarNotificationSetting { public class ActionBarNotificationSetting {
public ActionBarNotificationSetting(boolean enabled, boolean sendCopyOfMessageToChat) public boolean enabled;
{ public boolean sendCopyOfMessageToChat;
public ActionBarNotificationSetting(boolean enabled, boolean sendCopyOfMessageToChat) {
this.enabled = enabled; this.enabled = enabled;
this.sendCopyOfMessageToChat = sendCopyOfMessageToChat; this.sendCopyOfMessageToChat = sendCopyOfMessageToChat;
} }
public boolean enabled;
public boolean sendCopyOfMessageToChat;
} }

View File

@ -7,7 +7,11 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
public class ConfigNotifications { public class ConfigNotifications {
public static final boolean SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT = true; public static final boolean SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT = true;
@Setting(value = "Action-Bar-Notifications", comment = "Settings related to action bar messages." +
"\nThe action bar is the area above your health and armor.")
public ConfigActionBarNotifications actionBarNotifications = new ConfigActionBarNotifications();
@Setting(value = "General", comment = "General settings for Notifications")
public ConfigNotificationGeneral configNotificationGeneral = new ConfigNotificationGeneral();
@Setting(value = "Super-Ability-Tool-Raising-Lowering-Notification", @Setting(value = "Super-Ability-Tool-Raising-Lowering-Notification",
comment = "Notifies the player when they go into the tool readying state for super abilities.") comment = "Notifies the player when they go into the tool readying state for super abilities.")
private boolean superAbilityToolMessage = SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT; private boolean superAbilityToolMessage = SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT;
@ -16,13 +20,6 @@ public class ConfigNotifications {
return superAbilityToolMessage; return superAbilityToolMessage;
} }
@Setting(value = "Action-Bar-Notifications", comment = "Settings related to action bar messages." +
"\nThe action bar is the area above your health and armor.")
public ConfigActionBarNotifications actionBarNotifications = new ConfigActionBarNotifications();
@Setting(value = "General", comment = "General settings for Notifications")
public ConfigNotificationGeneral configNotificationGeneral = new ConfigNotificationGeneral();
public ConfigActionBarNotifications getActionBarNotifications() { public ConfigActionBarNotifications getActionBarNotifications() {
return actionBarNotifications; return actionBarNotifications;
} }

View File

@ -91,6 +91,8 @@ public class ConfigParty {
return partyCombat.isPartyFriendlyFire(); return partyCombat.isPartyFriendlyFire();
} }
public boolean isPartySystemEnabled() { return partyGeneral.isEnablePartySystem(); } public boolean isPartySystemEnabled() {
return partyGeneral.isEnablePartySystem();
}
} }

View File

@ -6,9 +6,8 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigSectionPartyCleanup { public class ConfigSectionPartyCleanup {
private static final int AUTO_KICK_HOURS_DEFAULT = 12;
public static final int AUTO_KICK_CUTOFF_DAYS_DEFAULT = 7; public static final int AUTO_KICK_CUTOFF_DAYS_DEFAULT = 7;
private static final int AUTO_KICK_HOURS_DEFAULT = 12;
@Setting(value = "Hours-Between-Cleanup-Operations", @Setting(value = "Hours-Between-Cleanup-Operations",
comment = "How many hours between checking parties for members that meet auto kick requirements." + comment = "How many hours between checking parties for members that meet auto kick requirements." +
"\nDefault value: " + AUTO_KICK_HOURS_DEFAULT) "\nDefault value: " + AUTO_KICK_HOURS_DEFAULT)

View File

@ -10,20 +10,14 @@ import java.util.Map;
@ConfigSerializable @ConfigSerializable
public class ConfigSectionPartyLevel { public class ConfigSectionPartyLevel {
private static final HashMap<PartyFeature, Integer> PARTY_FEATURE_MAP_DEFAULT;
public static final boolean INFORM_PARTY_ON_LEVELUP_DEFAULT = true; public static final boolean INFORM_PARTY_ON_LEVELUP_DEFAULT = true;
public static final boolean PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT = true; public static final boolean PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT = true;
public static final int TELEPORT_DEFAULT = 2; public static final int TELEPORT_DEFAULT = 2;
public static final int ALLIANCE_DEFAULT = 5; public static final int ALLIANCE_DEFAULT = 5;
public static final int ITEM_SHARE_DEFAULT = 8; public static final int ITEM_SHARE_DEFAULT = 8;
public static final int XP_SHARE_DEFAULT = 10; public static final int XP_SHARE_DEFAULT = 10;
public static final int PARTY_CHAT_DEFAULT = 1; public static final int PARTY_CHAT_DEFAULT = 1;
private static final HashMap<PartyFeature, Integer> PARTY_FEATURE_MAP_DEFAULT;
static { static {
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>(); PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
@ -75,7 +69,6 @@ public class ConfigSectionPartyLevel {
private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT; private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
public int getPartyXpCurveMultiplier() { public int getPartyXpCurveMultiplier() {
return partyXPFormula.getPartyXpCurveMultiplier(); return partyXPFormula.getPartyXpCurveMultiplier();
} }
@ -88,5 +81,7 @@ public class ConfigSectionPartyLevel {
return informPartyMembersOnLevelup; return informPartyMembersOnLevelup;
} }
public Map<PartyFeature, Integer> getPartyFeatureUnlockMap() { return partyFeatureUnlockMap; } public Map<PartyFeature, Integer> getPartyFeatureUnlockMap() {
return partyFeatureUnlockMap;
}
} }

View File

@ -31,10 +31,8 @@ public class ConfigExperienceFormula {
return configExperienceFormulaExponential; return configExperienceFormulaExponential;
} }
public double getMultiplier(FormulaType formulaType) public double getMultiplier(FormulaType formulaType) {
{ switch (formulaType) {
switch(formulaType)
{
case LINEAR: case LINEAR:
return getLinearMultiplier(); return getLinearMultiplier();
case EXPONENTIAL: case EXPONENTIAL:
@ -44,10 +42,8 @@ public class ConfigExperienceFormula {
} }
} }
public int getBase(FormulaType formulaType) public int getBase(FormulaType formulaType) {
{ switch (formulaType) {
switch(formulaType)
{
case LINEAR: case LINEAR:
return getLinearBaseModifier(); return getLinearBaseModifier();
case EXPONENTIAL: case EXPONENTIAL:

View File

@ -95,10 +95,8 @@ public class ConfigLeveling {
* HELPER METHODS * HELPER METHODS
*/ */
public int getLevelCap(PrimarySkillType primarySkillType) public int getLevelCap(PrimarySkillType primarySkillType) {
{ switch (primarySkillType) {
switch(primarySkillType)
{
case ACROBATICS: case ACROBATICS:
return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().getLevelCap(); return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().getLevelCap();
case ALCHEMY: case ALCHEMY:
@ -134,10 +132,8 @@ public class ConfigLeveling {
} }
} }
public boolean isLevelCapEnabled(PrimarySkillType primarySkillType) public boolean isLevelCapEnabled(PrimarySkillType primarySkillType) {
{ switch (primarySkillType) {
switch(primarySkillType)
{
case ACROBATICS: case ACROBATICS:
return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().isLevelCapEnabled(); return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().isLevelCapEnabled();
case ALCHEMY: case ALCHEMY:

View File

@ -57,10 +57,8 @@ public class ConfigScoreboard {
return configSectionGeneral.isUseAbilityNameInsteadOfGeneric(); return configSectionGeneral.isUseAbilityNameInsteadOfGeneric();
} }
public boolean isScoreboardEnabled(ScoreboardManager.SidebarType sidebarType) public boolean isScoreboardEnabled(ScoreboardManager.SidebarType sidebarType) {
{ switch (sidebarType) {
switch(sidebarType)
{
case TOP_BOARD: case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isUseThisBoard(); return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isUseThisBoard();
case RANK_BOARD: case RANK_BOARD:
@ -76,10 +74,8 @@ public class ConfigScoreboard {
} }
} }
public boolean isScoreboardPrinting(ScoreboardManager.SidebarType sidebarType) public boolean isScoreboardPrinting(ScoreboardManager.SidebarType sidebarType) {
{ switch (sidebarType) {
switch(sidebarType)
{
case TOP_BOARD: case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isPrintToChat(); return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isPrintToChat();
case RANK_BOARD: case RANK_BOARD:
@ -94,10 +90,8 @@ public class ConfigScoreboard {
} }
} }
public int getScoreboardDisplayTime(ScoreboardManager.SidebarType sidebarType) public int getScoreboardDisplayTime(ScoreboardManager.SidebarType sidebarType) {
{ switch (sidebarType) {
switch(sidebarType)
{
case TOP_BOARD: case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().getDisplayTimeInSeconds(); return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().getDisplayTimeInSeconds();
case RANK_BOARD: case RANK_BOARD:

View File

@ -34,6 +34,7 @@ public class ConfigSubSkillScalingRNG {
/** /**
* The max chance for the RNG component of a subskill from the user config * The max chance for the RNG component of a subskill from the user config
*
* @return the max chance for the RNG component of a subskill * @return the max chance for the RNG component of a subskill
*/ */
public double getMaxChance() { public double getMaxChance() {

View File

@ -17,8 +17,7 @@ public class ConfigNameRegisterDefaults {
static { static {
BUKKIT_MATERIAL_NAME_LOOKUP_EXAMPLE = new ArrayList<>(); BUKKIT_MATERIAL_NAME_LOOKUP_EXAMPLE = new ArrayList<>();
for(Material m : Material.values()) for (Material m : Material.values()) {
{
BUKKIT_MATERIAL_NAME_LOOKUP_EXAMPLE.add(new MinecraftMaterialWrapper((m))); BUKKIT_MATERIAL_NAME_LOOKUP_EXAMPLE.add(new MinecraftMaterialWrapper((m)));
} }
} }

View File

@ -7,8 +7,7 @@ public class MinecraftMaterialWrapper {
private String fullyQualifiedName; private String fullyQualifiedName;
private String bukkitMaterialName; private String bukkitMaterialName;
public MinecraftMaterialWrapper(Material material) public MinecraftMaterialWrapper(Material material) {
{
this.name = material.getKey().getKey(); this.name = material.getKey().getKey();
this.fullyQualifiedName = material.getKey().toString(); this.fullyQualifiedName = material.getKey().toString();
this.bukkitMaterialName = material.toString(); this.bukkitMaterialName = material.toString();

View File

@ -8,11 +8,10 @@ import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigFishing { public class ConfigFishing {
@Setting(value = "General")
private ConfigFishingGeneral fishingGeneral = new ConfigFishingGeneral();
@Setting(value = "Sub-Skills") @Setting(value = "Sub-Skills")
public ConfigFishingSubskills fishingSubskills = new ConfigFishingSubskills(); public ConfigFishingSubskills fishingSubskills = new ConfigFishingSubskills();
@Setting(value = "General")
private ConfigFishingGeneral fishingGeneral = new ConfigFishingGeneral();
/* /*
* GETTERS BOILERPLATE * GETTERS BOILERPLATE
@ -50,8 +49,7 @@ public class ConfigFishing {
return getInnerPeace().getInnerPeaceVanillaXPMultiplier(); return getInnerPeace().getInnerPeaceVanillaXPMultiplier();
} }
public int getVanillaXPMultInnerPeace(int rank) public int getVanillaXPMultInnerPeace(int rank) {
{
return getInnerPeaceVanillaXPMultiplier().get(rank); return getInnerPeaceVanillaXPMultiplier().get(rank);
} }
} }

View File

@ -6,9 +6,9 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigFishingGeneral { public class ConfigFishingGeneral {
public static final double LURE_MODIFIER_DEFAULT = 4.0D;
private static final boolean ALWAYS_CATCH_FISH_DEFAULT = true; private static final boolean ALWAYS_CATCH_FISH_DEFAULT = true;
private static final boolean OVERRIDE_VANILLA_TREASURES = true; private static final boolean OVERRIDE_VANILLA_TREASURES = true;
public static final double LURE_MODIFIER_DEFAULT = 4.0D;
private static final boolean ALLOW_MCMMO_FISHING_REWARDS = true; private static final boolean ALLOW_MCMMO_FISHING_REWARDS = true;
@Setting(value = "Always-Catch-Fish", comment = "Enables fish to be caught alongside treasure." + @Setting(value = "Always-Catch-Fish", comment = "Enables fish to be caught alongside treasure." +

View File

@ -53,10 +53,8 @@ public class ConfigSuperAbilities {
return superAbilityLimits; return superAbilityLimits;
} }
public int getCooldownForSuper(SuperAbilityType superAbilityType) public int getCooldownForSuper(SuperAbilityType superAbilityType) {
{ switch (superAbilityType) {
switch(superAbilityType)
{
case BERSERK: case BERSERK:
return superAbilityCooldowns.getBerserk(); return superAbilityCooldowns.getBerserk();
case GREEN_TERRA: case GREEN_TERRA:
@ -79,10 +77,8 @@ public class ConfigSuperAbilities {
} }
} }
public int getMaxLengthForSuper(SuperAbilityType superAbilityType) public int getMaxLengthForSuper(SuperAbilityType superAbilityType) {
{ switch (superAbilityType) {
switch(superAbilityType)
{
case BERSERK: case BERSERK:
return superAbilityMaxLength.getBerserk(); return superAbilityMaxLength.getBerserk();
case GREEN_TERRA: case GREEN_TERRA:

View File

@ -71,13 +71,25 @@ public class PotionConfig extends ConfigCollection {
register(); register();
} }
/**
* This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future
*
* @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/
@Deprecated
public static PotionConfig getInstance() {
return mcMMO.getConfigManager().getPotionConfig();
}
@Override @Override
public void unload() { public void unload() {
potionMap.clear(); potionMap.clear();
} }
private void initIngredientLists() private void initIngredientLists() {
{
concoctionsIngredientsTierOne = new ArrayList<>(); concoctionsIngredientsTierOne = new ArrayList<>();
concoctionsIngredientsTierTwo = new ArrayList<>(); concoctionsIngredientsTierTwo = new ArrayList<>();
concoctionsIngredientsTierThree = new ArrayList<>(); concoctionsIngredientsTierThree = new ArrayList<>();
@ -88,18 +100,6 @@ public class PotionConfig extends ConfigCollection {
concoctionsIngredientsTierEight = new ArrayList<>(); concoctionsIngredientsTierEight = new ArrayList<>();
} }
/**
* This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager()
* @return the instance of this config
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/
@Deprecated
public static PotionConfig getInstance() {
return mcMMO.getConfigManager().getPotionConfig();
}
/** /**
* The version of this config * The version of this config
* *

View File

@ -33,8 +33,9 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated
@ -49,8 +50,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
public void register() { public void register() {
ConfigurationNode excavationTreasureNode = getUserRootNode().getNode(EXCAVATION); ConfigurationNode excavationTreasureNode = getUserRootNode().getNode(EXCAVATION);
if(excavationTreasureNode == null) if (excavationTreasureNode == null) {
{
mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined"); mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined");
return; return;
} }
@ -62,8 +62,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
//Treasure Material Definition //Treasure Material Definition
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
if(treasureMaterial != null) if (treasureMaterial != null) {
{
ConfigurationNode currentTreasure = excavationTreasureNode.getNode(treasureName); ConfigurationNode currentTreasure = excavationTreasureNode.getNode(treasureName);
//TODO: Rewrite the entire treasure system because it sucks //TODO: Rewrite the entire treasure system because it sucks
@ -84,38 +83,33 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class))); ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class)));
//VALIDATE AMOUNT //VALIDATE AMOUNT
if(amount <= 0) if (amount <= 0) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE XP //VALIDATE XP
if(xp <= 0) if (xp <= 0) {
{
mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
xp = 0; xp = 0;
} }
//VALIDATE DROP CHANCE //VALIDATE DROP CHANCE
if(dropChance <= 0) if (dropChance <= 0) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE DROP LEVEL //VALIDATE DROP LEVEL
if(dropLevel < 0) if (dropLevel < 0) {
{
mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?"); mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?");
dropLevel = 0; dropLevel = 0;
} }
//VALIDATE DROP SOURCES //VALIDATE DROP SOURCES
if(dropsFrom == null || dropsFrom.isEmpty()) if (dropsFrom == null || dropsFrom.isEmpty()) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
@ -125,8 +119,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
//Custom Name //Custom Name
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) if (currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) {
{
customName = currentTreasure.getNode(CUSTOM_NAME).getString(); customName = currentTreasure.getNode(CUSTOM_NAME).getString();
} }
@ -139,8 +132,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
/* /*
* Add to map * Add to map
*/ */
for(String dropBlock : dropsFrom) for (String dropBlock : dropsFrom) {
{
excavationMap.computeIfAbsent(dropBlock, k -> new ArrayList<>()); excavationMap.computeIfAbsent(dropBlock, k -> new ArrayList<>());
excavationMap.get(dropBlock).add(excavationTreasure); excavationMap.get(dropBlock).add(excavationTreasure);

View File

@ -44,11 +44,17 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>(); public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>(); public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
public FishingTreasureConfig() {
super("fishing_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
register();
}
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated
@ -56,11 +62,6 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
return mcMMO.getConfigManager().getFishingTreasureConfig(); return mcMMO.getConfigManager().getFishingTreasureConfig();
} }
public FishingTreasureConfig() {
super("fishing_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
register();
}
/** /**
* Register stuff * Register stuff
*/ */
@ -70,14 +71,12 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
ConfigurationNode fishingTreasureNode = getUserRootNode().getNode(FISHING); ConfigurationNode fishingTreasureNode = getUserRootNode().getNode(FISHING);
if(fishingTreasureNode == null) if (fishingTreasureNode == null) {
{
mcMMO.p.getLogger().info("Fishing treasures in treasures config not defined"); mcMMO.p.getLogger().info("Fishing treasures in treasures config not defined");
return; return;
} }
// Initialize fishing HashMap // Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) { for (Rarity rarity : Rarity.values()) {
if (!fishingRewards.containsKey(rarity)) { if (!fishingRewards.containsKey(rarity)) {
@ -92,8 +91,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
//Treasure Material Definition //Treasure Material Definition
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
if(treasureMaterial != null) if (treasureMaterial != null) {
{
ConfigurationNode currentTreasure = fishingTreasureNode.getNode(treasureName); ConfigurationNode currentTreasure = fishingTreasureNode.getNode(treasureName);
//TODO: Rewrite the entire treasure system because it sucks //TODO: Rewrite the entire treasure system because it sucks
@ -112,23 +110,20 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode(DROPS_FROM).getList(TypeToken.of(String.class))); ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode(DROPS_FROM).getList(TypeToken.of(String.class)));
//VALIDATE AMOUNT //VALIDATE AMOUNT
if(amount <= 0) if (amount <= 0) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE XP //VALIDATE XP
if(xp <= 0) if (xp <= 0) {
{
mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
xp = 0; xp = 0;
} }
//VALIDATE DROP SOURCES //VALIDATE DROP SOURCES
if(dropsFrom == null || dropsFrom.isEmpty()) if (dropsFrom == null || dropsFrom.isEmpty()) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
@ -138,8 +133,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
//Custom Name //Custom Name
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) if (currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) {
{
customName = currentTreasure.getNode(CUSTOM_NAME).getString(); customName = currentTreasure.getNode(CUSTOM_NAME).getString();
} }
@ -155,10 +149,8 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
String configRarity = currentTreasure.getNode(RARITY).getString(); String configRarity = currentTreasure.getNode(RARITY).getString();
for(Rarity rarity : Rarity.values()) for (Rarity rarity : Rarity.values()) {
{ if (rarity.toString().equalsIgnoreCase(configRarity)) {
if(rarity.toString().equalsIgnoreCase(configRarity))
{
/*if(fishingRewards.get(rarity) == null) /*if(fishingRewards.get(rarity) == null)
fishingRewards.put(rarity, new ArrayList<>());*/ fishingRewards.put(rarity, new ArrayList<>());*/
@ -185,8 +177,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
loadEnchantments(); loadEnchantments();
} }
private void loadShake(EntityType entityType) private void loadShake(EntityType entityType) {
{
ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString()); ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString());
if (shakeTreasureNode != null) if (shakeTreasureNode != null)
@ -199,8 +190,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
//Treasure Material Definition //Treasure Material Definition
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
if(treasureMaterial != null) if (treasureMaterial != null) {
{
ConfigurationNode currentTreasure = shakeTreasureNode.getNode(treasureName); ConfigurationNode currentTreasure = shakeTreasureNode.getNode(treasureName);
//TODO: Rewrite the entire treasure system because it sucks //TODO: Rewrite the entire treasure system because it sucks
@ -221,38 +211,33 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode(DROPS_FROM).getList(TypeToken.of(String.class))); ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode(DROPS_FROM).getList(TypeToken.of(String.class)));
//VALIDATE AMOUNT //VALIDATE AMOUNT
if(amount <= 0) if (amount <= 0) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE XP //VALIDATE XP
if(xp <= 0) if (xp <= 0) {
{
mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
xp = 0; xp = 0;
} }
//VALIDATE DROP CHANCE //VALIDATE DROP CHANCE
if(dropChance <= 0) if (dropChance <= 0) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE DROP LEVEL //VALIDATE DROP LEVEL
if(dropLevel < 0) if (dropLevel < 0) {
{
mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?"); mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?");
dropLevel = 0; dropLevel = 0;
} }
//VALIDATE DROP SOURCES //VALIDATE DROP SOURCES
if(dropsFrom == null || dropsFrom.isEmpty()) if (dropsFrom == null || dropsFrom.isEmpty()) {
{
mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
@ -262,8 +247,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
//Custom Name //Custom Name
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) if (currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) {
{
customName = currentTreasure.getNode(CUSTOM_NAME).getString(); customName = currentTreasure.getNode(CUSTOM_NAME).getString();
} }

View File

@ -36,8 +36,9 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
/** /**
* This grabs an instance of this config class from the Config Manager * This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future * This method is deprecated and will be removed in the future
* @see mcMMO#getConfigManager() *
* @return the instance of this config * @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/ */
@Deprecated @Deprecated
@ -52,8 +53,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
public void register() { public void register() {
ConfigurationNode herbalismTreasureNode = getUserRootNode().getNode(HYLIAN_LUCK); ConfigurationNode herbalismTreasureNode = getUserRootNode().getNode(HYLIAN_LUCK);
if(herbalismTreasureNode == null) if (herbalismTreasureNode == null) {
{
mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined"); mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined");
return; return;
} }
@ -65,8 +65,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
//Treasure Material Definition //Treasure Material Definition
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase()); Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
if(treasureMaterial != null) if (treasureMaterial != null) {
{
ConfigurationNode currentTreasure = herbalismTreasureNode.getNode(treasureName); ConfigurationNode currentTreasure = herbalismTreasureNode.getNode(treasureName);
//TODO: Rewrite the entire treasure system because it sucks //TODO: Rewrite the entire treasure system because it sucks
@ -87,38 +86,33 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class))); ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class)));
//VALIDATE AMOUNT //VALIDATE AMOUNT
if(amount <= 0) if (amount <= 0) {
{
mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE XP //VALIDATE XP
if(xp <= 0) if (xp <= 0) {
{
mcMMO.p.getLogger().info("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); mcMMO.p.getLogger().info("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
xp = 0; xp = 0;
} }
//VALIDATE DROP CHANCE //VALIDATE DROP CHANCE
if(dropChance <= 0) if (dropChance <= 0) {
{
mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?"); mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
} }
//VALIDATE DROP LEVEL //VALIDATE DROP LEVEL
if(dropLevel < 0) if (dropLevel < 0) {
{
mcMMO.p.getLogger().info("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?"); mcMMO.p.getLogger().info("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?");
dropLevel = 0; dropLevel = 0;
} }
//VALIDATE DROP SOURCES //VALIDATE DROP SOURCES
if(dropsFrom == null || dropsFrom.isEmpty()) if (dropsFrom == null || dropsFrom.isEmpty()) {
{
mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); mcMMO.p.getLogger().severe("Herbalism Hylian Luck Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid");
continue; continue;
@ -128,8 +122,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
//Custom Name //Custom Name
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) if (currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe")) {
{
customName = currentTreasure.getNode(CUSTOM_NAME).getString(); customName = currentTreasure.getNode(CUSTOM_NAME).getString();
} }
@ -142,8 +135,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
/* /*
* Add to map * Add to map
*/ */
for(String dropBlock : dropsFrom) for (String dropBlock : dropsFrom) {
{
if (dropBlock.equals("Bushes")) { if (dropBlock.equals("Bushes")) {
addHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure); addHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
addHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure); addHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);

View File

@ -24,6 +24,7 @@ public class TreasureFactory {
/** /**
* Make a new ExcavationTreasure * Make a new ExcavationTreasure
*
* @param material * @param material
* @param dropAmount * @param dropAmount
* @param xpReward * @param xpReward
@ -33,29 +34,25 @@ public class TreasureFactory {
* @param customLore * @param customLore
* @return * @return
*/ */
public static ExcavationTreasure makeExcavationTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) public static ExcavationTreasure makeExcavationTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore); ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
return new ExcavationTreasure(treasure, xpReward, dropChance, dropLevel); return new ExcavationTreasure(treasure, xpReward, dropChance, dropLevel);
} }
public static ShakeTreasure makeShakeTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) public static ShakeTreasure makeShakeTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore); ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
return new ShakeTreasure(treasure, xpReward, dropChance, dropLevel); return new ShakeTreasure(treasure, xpReward, dropChance, dropLevel);
} }
public static FishingTreasure makeFishingTreasure(Material material, int dropAmount, int xpReward, String customName, ConfigurationNode customLore) public static FishingTreasure makeFishingTreasure(Material material, int dropAmount, int xpReward, String customName, ConfigurationNode customLore) {
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore); ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
return new FishingTreasure(treasure, xpReward); return new FishingTreasure(treasure, xpReward);
} }
public static HylianTreasure makeHylianTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) public static HylianTreasure makeHylianTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore); ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
return new HylianTreasure(treasure, xpReward, dropChance, dropLevel); return new HylianTreasure(treasure, xpReward, dropChance, dropLevel);
@ -70,16 +67,14 @@ public class TreasureFactory {
treasure = makePotionItemStack(material, dropAmount, customName, customLore);*/ treasure = makePotionItemStack(material, dropAmount, customName, customLore);*/
/* ADD CUSTOM NAME */ /* ADD CUSTOM NAME */
if(customName != null) if (customName != null) {
{
ItemMeta itemMeta = treasure.getItemMeta(); ItemMeta itemMeta = treasure.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName)); itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
treasure.setItemMeta(itemMeta); treasure.setItemMeta(itemMeta);
} }
/* ADD CUSTOM LORE */ /* ADD CUSTOM LORE */
if(customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME)) if (customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME)) {
{
ItemMeta itemMeta = treasure.getItemMeta(); ItemMeta itemMeta = treasure.getItemMeta();
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
@ -97,16 +92,13 @@ public class TreasureFactory {
} }
//TODO: Do this later //TODO: Do this later
return treasure; return treasure;
} }
private static boolean isPotion(Material material) private static boolean isPotion(Material material) {
{ switch (material) {
switch(material)
{
case POTION: case POTION:
case SPLASH_POTION: case SPLASH_POTION:
case LINGERING_POTION: case LINGERING_POTION:

View File

@ -74,13 +74,12 @@ public interface DatabaseManager {
/** /**
* Load a player from the database. * Load a player from the database.
* *
* @deprecated replaced by {@link #loadPlayerProfile(String playerName, UUID uuid, boolean createNew)}
*
* @param playerName The name of the player to load from the database * @param playerName The name of the player to load from the database
* @param createNew Whether to create a new record if the player is not * @param createNew Whether to create a new record if the player is not
* found * found
* @return The player's data, or an unloaded PlayerProfile if not found * @return The player's data, or an unloaded PlayerProfile if not found
* and createNew is false * and createNew is false
* @deprecated replaced by {@link #loadPlayerProfile(String playerName, UUID uuid, boolean createNew)}
*/ */
@Deprecated @Deprecated
PlayerProfile loadPlayerProfile(String playerName, boolean createNew); PlayerProfile loadPlayerProfile(String playerName, boolean createNew);

Some files were not shown because too many files have changed in this diff Show More