mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
70 Commits
newtiers
...
reformat-j
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c211874a27 | ||
|
|
e8e2dcff46 | ||
|
|
3b09012b35 | ||
|
|
a774733af4 | ||
|
|
4a7e1e2b94 | ||
|
|
b8c1f868f5 | ||
|
|
3f56a8fbcf | ||
|
|
d8e86d0fc7 | ||
|
|
e125700b43 | ||
|
|
819a1c62ed | ||
|
|
4bc446e306 | ||
|
|
7f2f15d88e | ||
|
|
be4736fffd | ||
|
|
b4f4de4628 | ||
|
|
b9c652ef2b | ||
|
|
bf4e8d43ea | ||
|
|
468fbdab56 | ||
|
|
309dfd50cd | ||
|
|
44e3e4d1e1 | ||
|
|
476f426590 | ||
|
|
766f1f4127 | ||
|
|
b3cf9bf839 | ||
|
|
056f7cc93b | ||
|
|
741f629ab8 | ||
|
|
dd64c4008b | ||
|
|
3a5de8e2ce | ||
|
|
2d78c0738d | ||
|
|
77617ebee2 | ||
|
|
67e9d9c535 | ||
|
|
800786111c | ||
|
|
ed8197bd50 | ||
|
|
82f8c4ce36 | ||
|
|
b1cf7d0348 | ||
|
|
ae77313007 | ||
|
|
49cbaad47f | ||
|
|
1d96ed72dc | ||
|
|
ec378d046f | ||
|
|
a25dc24c6c | ||
|
|
68eb51a3d0 | ||
|
|
2eda3a9c83 | ||
|
|
ad8e200a84 | ||
|
|
0c83bf2a80 | ||
|
|
6eaec5ffab | ||
|
|
8a2c5fb051 | ||
|
|
9485869014 | ||
|
|
e1bf55b077 | ||
|
|
81140824e4 | ||
|
|
d5545de81f | ||
|
|
8632baed27 | ||
|
|
9aaea7e44f | ||
|
|
c2f8f4d016 | ||
|
|
5131e74349 | ||
|
|
3927427b5b | ||
|
|
4aef4c63fc | ||
|
|
fb4777e7f0 | ||
|
|
d8f3a54f9b | ||
|
|
de964a3a60 | ||
|
|
ce3bc07aa8 | ||
|
|
5a6bb363cf | ||
|
|
3f9c98d72e | ||
|
|
96b54387fe | ||
|
|
70eb67dd6a | ||
|
|
77f9f40065 | ||
|
|
14ae1a69c4 | ||
|
|
c9858dfd49 | ||
|
|
f75fe3cc89 | ||
|
|
c19ccbccac | ||
|
|
2f90e533a5 | ||
|
|
0cd0919447 | ||
|
|
e8b886fcc6 |
@@ -8,6 +8,9 @@ Key:
|
||||
- Removal
|
||||
|
||||
Version 1.4.07-dev
|
||||
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
||||
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
|
||||
+ Added more tiers to Fishing, Repair and Smelting!
|
||||
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
|
||||
+ Added horses to the "Shake" ability
|
||||
+ Added ability to summon horses via "Call of the Wild" using apples
|
||||
@@ -40,12 +43,16 @@ Version 1.4.07-dev
|
||||
= Fixed a bug where squid were not awarding XP.
|
||||
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
|
||||
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
|
||||
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
|
||||
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
|
||||
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
|
||||
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed default XP multiplier for repairing shears
|
||||
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
|
||||
! Changed various values to double in advanced.yml for the sake of consistency.
|
||||
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
|
||||
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||
! Changed the way Repair hands out XP, also added config options to control Repair XP
|
||||
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
|
||||
@@ -53,6 +60,7 @@ Version 1.4.07-dev
|
||||
! Vampirism can now be enabled without having Skill Death Penalty enabled
|
||||
! Admin and Party chat prefixes are now customizable
|
||||
! Changed the color of party leader names in Party chat
|
||||
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
||||
! Improved profile saving
|
||||
! Improved partial name matcher
|
||||
! Improved update checker
|
||||
@@ -62,6 +70,7 @@ Version 1.4.07-dev
|
||||
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
|
||||
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
||||
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
|
||||
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
|
||||
- Removed SpoutPlugin support
|
||||
|
||||
Version 1.4.06
|
||||
|
||||
8
pom.xml
8
pom.xml
@@ -30,6 +30,14 @@
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>mods</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/mods</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -18,11 +18,11 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
@@ -33,9 +33,9 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
@@ -47,10 +47,10 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param message The message to send
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
||||
@@ -61,8 +61,8 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
@@ -73,6 +73,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
@@ -83,6 +84,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
*
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(String playerName) {
|
||||
@@ -93,6 +95,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
@@ -103,6 +106,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
*
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(String playerName) {
|
||||
|
||||
@@ -24,6 +24,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType A string that may or may not be a skill
|
||||
*
|
||||
* @return true if this is a valid mcMMO skill
|
||||
*/
|
||||
public static boolean isValidSkillType(String skillType) {
|
||||
@@ -38,12 +39,15 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType the skill to check
|
||||
*
|
||||
* @return true if this is a valid, non-child mcMMO skill
|
||||
*/
|
||||
public static boolean isNonChildSkill(String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) return false;
|
||||
if (skill == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !skill.isChildSkill();
|
||||
}
|
||||
@@ -58,9 +62,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -79,10 +83,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @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
|
||||
*/
|
||||
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||
@@ -94,9 +98,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -110,10 +114,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @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
|
||||
*/
|
||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||
@@ -125,9 +129,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -143,10 +147,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @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
|
||||
*/
|
||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||
@@ -161,9 +165,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -176,11 +180,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
@@ -193,11 +198,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXP(String playerName, String skillType) {
|
||||
@@ -209,11 +215,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static float getXPRaw(Player player, String skillType) {
|
||||
@@ -226,11 +233,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||
@@ -242,11 +250,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
@@ -259,11 +268,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||
@@ -275,11 +285,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static int getXPRemaining(Player player, String skillType) {
|
||||
@@ -296,11 +307,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||
@@ -316,9 +328,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 levels Number of levels to add
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -332,10 +344,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @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
|
||||
*/
|
||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||
@@ -362,8 +374,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -378,10 +391,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static int getLevelOffline(String playerName, String skillType) {
|
||||
@@ -394,6 +408,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the power level for
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
@@ -406,6 +421,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get the power level for
|
||||
*
|
||||
* @return the power level of the player
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
@@ -414,7 +430,7 @@ public final class ExperienceAPI {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
@@ -427,6 +443,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType The skill to get the level cap for
|
||||
*
|
||||
* @return the level cap of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -452,13 +469,13 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @param skillType The skill to check
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
* @param skillType The skill to check
|
||||
*
|
||||
* @return the position on the leaderboard
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
|
||||
@@ -472,9 +489,9 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getPlayerRankOverall(String playerName) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
|
||||
@@ -485,8 +502,8 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -501,10 +518,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||
@@ -516,11 +533,11 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 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
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
@@ -533,11 +550,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||
@@ -549,11 +566,11 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @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 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
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
@@ -566,11 +583,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||
|
||||
@@ -21,6 +21,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
*
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
@@ -37,6 +38,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
@@ -50,6 +52,7 @@ public final class PartyAPI {
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
*
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
@@ -72,7 +75,7 @@ public final class PartyAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
@@ -102,6 +105,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
@@ -114,7 +118,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param player The player to set as leader
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
@@ -126,6 +130,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -145,6 +150,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the player names in the player's party
|
||||
*/
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
@@ -157,6 +163,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
@@ -169,6 +176,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PartyChatManager extends ChatManager {
|
||||
@Override
|
||||
protected void sendMessage() {
|
||||
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
||||
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||
message = message.replaceFirst(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||
}
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
|
||||
@@ -24,6 +24,6 @@ public class McabilityCommand extends ToggleCommand {
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ public class McgodCommand extends ToggleCommand {
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -44,11 +45,11 @@ public class MobhealthCommand implements TabExecutor {
|
||||
try {
|
||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||
playerProfile.setMobHealthbarType(type);
|
||||
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage("Invalid type!"); //TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,10 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
|
||||
protected abstract void applyCommandAction();
|
||||
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
|
||||
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
|
||||
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
@@ -39,17 +39,12 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class McconvertCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
// Custom stuff
|
||||
databaseTypes.remove(DatabaseType.CUSTOM);
|
||||
databaseTypes.remove(DatabaseType.CUSTOM.toString());
|
||||
|
||||
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
|
||||
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -22,11 +20,14 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddxpCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -35,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -109,9 +108,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
|
||||
protected abstract void handleCommand(SkillType skill);
|
||||
|
||||
protected abstract void handlePlayerMessageAll();
|
||||
|
||||
protected abstract void handlePlayerMessageSkill();
|
||||
|
||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||
@@ -149,7 +152,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class MmoeditCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -23,20 +20,16 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
if (player == null || value == skillLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
|
||||
if (value > skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
|
||||
}
|
||||
else if (value < skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
|
||||
}
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillresetCommand extends ExperienceCommand {
|
||||
private CommandSender sender;
|
||||
@@ -103,11 +102,16 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
int levelsRemoved = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class HardcoreCommand extends HardcoreModeCommand {
|
||||
|
||||
private void toggle(boolean enable) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skillType.setHardcoreStatLossEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
|
||||
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
|
||||
|
||||
@@ -129,10 +129,15 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean checkTogglePermissions();
|
||||
|
||||
protected abstract boolean checkModifyPermissions();
|
||||
|
||||
protected abstract boolean checkEnabled(String skill);
|
||||
|
||||
protected abstract void enable(String skill);
|
||||
|
||||
protected abstract void disable(String skill);
|
||||
|
||||
protected abstract void modify();
|
||||
|
||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||
|
||||
@@ -48,16 +48,16 @@ public class VampirismCommand extends HardcoreModeCommand {
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enabled) {
|
||||
private void toggle(boolean enable) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skillType.setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
|
||||
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ import org.bukkit.util.StringUtil;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@@ -177,25 +177,7 @@ public class PtpCommand implements TabExecutor {
|
||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||
}
|
||||
else {
|
||||
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
teleportingPlayer.teleport(targetPlayer);
|
||||
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
||||
|
||||
mcMMOPlayer.actualizePtpLastUse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,22 +52,20 @@ public class InspectCommand implements TabExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
|
||||
for (SkillType skill : SkillType.GATHERING_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
|
||||
for (SkillType skill : SkillType.COMBAT_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
|
||||
for (SkillType skill : SkillType.MISC_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
@@ -4,22 +4,32 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String magicChanceLucky;
|
||||
private String chanceRaining = "";
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private int fishermansDietRank;
|
||||
private String biteChance;
|
||||
|
||||
private String trapTreasure;
|
||||
private String commonTreasure;
|
||||
private String uncommonTreasure;
|
||||
private String rareTreasure;
|
||||
private String epicTreasure;
|
||||
private String legendaryTreasure;
|
||||
private String recordTreasure;
|
||||
|
||||
private String magicChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
@@ -38,16 +48,24 @@ public class FishingCommand extends SkillCommand {
|
||||
// TREASURE HUNTER
|
||||
if (canTreasureHunt) {
|
||||
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
|
||||
if (isStorming) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
enchantChance *= 1.1D;
|
||||
}
|
||||
// Item drop rates
|
||||
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
|
||||
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
|
||||
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
|
||||
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
|
||||
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
|
||||
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
|
||||
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
|
||||
|
||||
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
|
||||
magicChance = treasureHunterStrings[0];
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
// Magic hunter drop rates
|
||||
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
|
||||
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
|
||||
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
|
||||
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
|
||||
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
|
||||
|
||||
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
|
||||
}
|
||||
|
||||
// SHAKE
|
||||
@@ -64,15 +82,15 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
}
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
||||
}
|
||||
|
||||
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
||||
@@ -106,20 +124,20 @@ public class FishingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
if (canIceFish) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,31 +148,13 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", magicChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
@@ -167,5 +167,31 @@ public class FishingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||
}
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -114,18 +115,18 @@ public class MiningCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
||||
@@ -136,7 +137,7 @@ public class MiningCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
||||
|
||||
@@ -6,9 +6,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
@@ -145,7 +146,7 @@ public class RepairCommand extends SkillCommand {
|
||||
if (canArcaneForge) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
|
||||
|
||||
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -46,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
skillName = SkillUtils.getSkillName(skill);
|
||||
skillName = skill.getSkillName();
|
||||
skillGuideCommand = new SkillGuideCommand(skill);
|
||||
}
|
||||
|
||||
@@ -91,7 +90,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
length = Math.min(length, maxLength);
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
|
||||
}
|
||||
|
||||
protected void luckyEffectsDisplay() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -9,17 +10,16 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillGuideCommand implements CommandExecutor {
|
||||
private String header;
|
||||
private String[] guide;
|
||||
private ArrayList<String> guide;
|
||||
|
||||
private String invalidPage;
|
||||
|
||||
public SkillGuideCommand(SkillType skillType) {
|
||||
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
|
||||
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
|
||||
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
|
||||
guide = getGuide(skillType);
|
||||
|
||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private int getTotalPageNumber() {
|
||||
return (int) Math.ceil(guide.length / 8.0);
|
||||
return (int) Math.ceil(guide.size() / 8.0);
|
||||
}
|
||||
|
||||
private void sendGuide(CommandSender sender, int pageNumber) {
|
||||
@@ -76,15 +76,38 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
|
||||
// Add targeted strings
|
||||
while (allStrings.size() < 9) {
|
||||
if (pageIndexStart + allStrings.size() > guide.length) {
|
||||
if (pageIndexStart + allStrings.size() > guide.size()) {
|
||||
allStrings.add("");
|
||||
}
|
||||
else {
|
||||
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
|
||||
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
|
||||
return allStrings;
|
||||
}
|
||||
|
||||
private ArrayList<String> getGuide(SkillType skillType) {
|
||||
ArrayList<String> guide = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n");
|
||||
|
||||
if (section[0].startsWith("!")) {
|
||||
break;
|
||||
}
|
||||
|
||||
guide.addAll(Arrays.asList(section));
|
||||
|
||||
if (section.length < 8) {
|
||||
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
|
||||
guide.add("");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return guide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SmeltingCommand extends SkillCommand {
|
||||
@@ -94,7 +95,7 @@ public class SmeltingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -328,7 +328,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -16,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
public abstract class ConfigLoader {
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
private File configFile;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
@@ -34,7 +29,7 @@ public abstract class ConfigLoader {
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
plugin.saveResource(configFile.getPath(), false);
|
||||
}
|
||||
else {
|
||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||
@@ -45,53 +40,6 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream == null) {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try {
|
||||
outputStream = new FileOutputStream(configFile);
|
||||
|
||||
int read;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
}
|
||||
@@ -118,4 +66,19 @@ public abstract class ConfigLoader {
|
||||
public File getFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void backup() {
|
||||
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
||||
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
||||
|
||||
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||
|
||||
if (plugin.getResource(fileName) != null) {
|
||||
plugin.saveResource(fileName, true);
|
||||
}
|
||||
|
||||
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||
loadFile();
|
||||
loadKeys();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.entity.EntityType;
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
@@ -85,6 +85,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
|
||||
}
|
||||
|
||||
if (getDodgeXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getRollXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFallXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Fishing */
|
||||
if (getFishingBaseXP() <= 0) {
|
||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
||||
@@ -176,6 +188,13 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* Materials */
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
/* Acrobatics */
|
||||
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
|
||||
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
|
||||
|
||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
|
||||
|
||||
@@ -10,14 +10,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
@@ -26,7 +28,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
super("mods", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -50,10 +52,17 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
while (!needsUpdate) {
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Material> materialList) {
|
||||
@@ -66,6 +75,11 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
if (config.contains(armorType + "." + armorName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Material armorMaterial = Material.matchMaterial(armorName);
|
||||
|
||||
if (armorMaterial == null) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
@@ -16,6 +15,8 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private static CustomBlockConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
@@ -28,7 +29,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
|
||||
public CustomBlockConfig() {
|
||||
super("ModConfigs", "blocks.yml");
|
||||
super("mods", "blocks.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -42,11 +43,18 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
while (!needsUpdate) {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||
@@ -59,6 +67,11 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
|
||||
for (String blockName : skillConfigSet) {
|
||||
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
String[] blockInfo = blockName.split("[|]");
|
||||
|
||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||
@@ -78,27 +91,6 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||
|
||||
boolean shouldDropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item");
|
||||
Material dropMaterial = Material.matchMaterial(config.getString(skillType + "." + blockName + ".Drop_Item_Name"));
|
||||
|
||||
if (shouldDropItem && dropMaterial == null) {
|
||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself. - " + blockInfo[0]);
|
||||
shouldDropItem = false;
|
||||
}
|
||||
|
||||
ItemStack itemDrop;
|
||||
|
||||
if (shouldDropItem) {
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value");
|
||||
itemDrop = (new MaterialData(dropMaterial, dropData)).toItemStack(1);
|
||||
}
|
||||
else {
|
||||
itemDrop = blockMaterialData.toItemStack(1);
|
||||
}
|
||||
|
||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterialData);
|
||||
}
|
||||
@@ -112,7 +104,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, xp));
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
|
||||
public CustomEntityConfig() {
|
||||
super("ModConfigs", "entities.yml");
|
||||
super("mods", "entities.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
if (config.getConfigurationSection("Hostile") != null) {
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
for (String entityName : config.getKeys(false)) {
|
||||
Class<?> clazz = null;
|
||||
String className = config.getString(entityName + ".Class", "");
|
||||
|
||||
@@ -12,13 +12,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private static CustomToolConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
@@ -31,7 +34,7 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
|
||||
private CustomToolConfig() {
|
||||
super("ModConfigs", "tools.yml");
|
||||
super("mods", "tools.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -55,12 +58,19 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
loadTool("Pickaxes", customPickaxes);
|
||||
loadTool("Shovels", customShovels);
|
||||
loadTool("Swords", customSwords);
|
||||
while (!needsUpdate) {
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
loadTool("Pickaxes", customPickaxes);
|
||||
loadTool("Shovels", customShovels);
|
||||
loadTool("Swords", customSwords);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Material> materialList) {
|
||||
@@ -73,6 +83,11 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
|
||||
for (String toolName : toolConfigSet) {
|
||||
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Material toolMaterial = Material.matchMaterial(toolName);
|
||||
|
||||
if (toolMaterial == null) {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class BlastMiningRank extends Rank {
|
||||
|
||||
private double blastDamageDecrease;
|
||||
private double oreBonus;
|
||||
private double debrisReduction;
|
||||
private int dropMultiplier;
|
||||
private double blastRadiusModifier;
|
||||
|
||||
public BlastMiningRank(int level, double blastDamageDecrease, double oreBonus, double debrisReduction, int dropMultiplier, double blastRadiusModifier) {
|
||||
super(level);
|
||||
this.blastDamageDecrease = blastDamageDecrease;
|
||||
this.oreBonus = oreBonus;
|
||||
this.debrisReduction = debrisReduction;
|
||||
this.dropMultiplier = dropMultiplier;
|
||||
this.blastRadiusModifier = blastRadiusModifier;
|
||||
}
|
||||
|
||||
public BlastMiningRank(ConfigurationSection section) {
|
||||
this(section.getInt("Level"), section.getDouble("BlastDamageDecrease"), section.getDouble("OreBonus"), section.getDouble("DebrisReduction"), section.getInt("DropMultiplier"), section.getDouble("BlastRadiusModifier"));
|
||||
}
|
||||
|
||||
public double getBlastDamageDecrease() {
|
||||
return blastDamageDecrease;
|
||||
}
|
||||
|
||||
public double getOreBonus() {
|
||||
return oreBonus;
|
||||
}
|
||||
|
||||
public double getDebrisReduction() {
|
||||
return debrisReduction;
|
||||
}
|
||||
|
||||
public int getDropMultiplier() {
|
||||
return dropMultiplier;
|
||||
}
|
||||
|
||||
public double getBlastRadiusModifier() {
|
||||
return blastRadiusModifier;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class FishingRank extends Rank {
|
||||
|
||||
private double shakeChance;
|
||||
private int xpBoost;
|
||||
|
||||
private FishingRank(int level, double shakeChance, int xpBoost) {
|
||||
super(level);
|
||||
this.shakeChance = shakeChance;
|
||||
this.xpBoost = xpBoost;
|
||||
}
|
||||
|
||||
public FishingRank(ConfigurationSection section) {
|
||||
this(section.getInt("Level"), section.getDouble("ShakeChance"), section.getInt("VanillaXPBoost"));
|
||||
}
|
||||
|
||||
public double getShakeChance() {
|
||||
return shakeChance;
|
||||
}
|
||||
|
||||
public int getXpBoost() {
|
||||
return xpBoost;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
public abstract class Rank {
|
||||
private int level;
|
||||
|
||||
public Rank(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
|
||||
public class RankLoader extends ConfigLoader {
|
||||
|
||||
private List<FishingRank> fishingRanks;
|
||||
private List<SmeltingRank> smeltingRanks;
|
||||
private List<BlastMiningRank> blastMiningRanks;
|
||||
private List<RepairRank> repairRanks;
|
||||
private static RankLoader instance;
|
||||
|
||||
private RankLoader() {
|
||||
super("ranks.yml");
|
||||
fishingRanks = new ArrayList<FishingRank>();
|
||||
smeltingRanks = new ArrayList<SmeltingRank>();
|
||||
blastMiningRanks = new ArrayList<BlastMiningRank>();
|
||||
repairRanks = new ArrayList<RepairRank>();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static RankLoader getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new RankLoader();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Ranks.Fishing");
|
||||
RankComparator rankComparator = new RankComparator();
|
||||
for (String rank : section.getKeys(false)) {
|
||||
fishingRanks.add(new FishingRank(section.getConfigurationSection(rank)));
|
||||
}
|
||||
Collections.sort(fishingRanks, rankComparator);
|
||||
|
||||
section = config.getConfigurationSection("Ranks.BlastMining");
|
||||
for (String rank : section.getKeys(false)) {
|
||||
blastMiningRanks.add(new BlastMiningRank(section.getConfigurationSection(rank)));
|
||||
}
|
||||
Collections.sort(blastMiningRanks, rankComparator);
|
||||
|
||||
section = config.getConfigurationSection("Ranks.Repair");
|
||||
for (String rank : section.getKeys(false)) {
|
||||
repairRanks.add(new RepairRank(section.getConfigurationSection(rank)));
|
||||
}
|
||||
Collections.sort(repairRanks, rankComparator);
|
||||
|
||||
section = config.getConfigurationSection("Ranks.Smelting");
|
||||
for (String rank : section.getKeys(false)) {
|
||||
smeltingRanks.add(new SmeltingRank(section.getConfigurationSection(rank)));
|
||||
}
|
||||
Collections.sort(smeltingRanks, rankComparator);
|
||||
}
|
||||
|
||||
public FishingRank getFishingRank(int level) {
|
||||
Iterator<FishingRank> it = fishingRanks.iterator();
|
||||
while (it.hasNext()) {
|
||||
FishingRank rank = it.next();
|
||||
if (rank.getLevel() > level) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RepairRank getRepairRank(int level) {
|
||||
Iterator<RepairRank> it = repairRanks.iterator();
|
||||
while (it.hasNext()) {
|
||||
RepairRank rank = it.next();
|
||||
if (rank.getLevel() > level) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SmeltingRank getSmeltingRank(int level) {
|
||||
Iterator<SmeltingRank> it = smeltingRanks.iterator();
|
||||
while (it.hasNext()) {
|
||||
SmeltingRank rank = it.next();
|
||||
if (rank.getLevel() > level) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlastMiningRank getBlastMiningRank(int level) {
|
||||
Iterator<BlastMiningRank> it = blastMiningRanks.iterator();
|
||||
while (it.hasNext()) {
|
||||
BlastMiningRank rank = it.next();
|
||||
if (rank.getLevel() > level) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class RankComparator implements Comparator<Rank> {
|
||||
@Override
|
||||
public int compare(Rank o1, Rank o2) {
|
||||
return Integer.valueOf(o1.getLevel()).compareTo(Integer.valueOf(o2.getLevel()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class RepairRank extends Rank {
|
||||
|
||||
private double downgradeChance;
|
||||
private double keepEnchantsChance;
|
||||
|
||||
public RepairRank(int level, double downgradeChance, double keepEnchantsChance) {
|
||||
super(level);
|
||||
this.downgradeChance = downgradeChance;
|
||||
this.keepEnchantsChance = keepEnchantsChance;
|
||||
}
|
||||
|
||||
public RepairRank(ConfigurationSection section) {
|
||||
this(section.getInt("Level"), section.getDouble("DowngradeChance"), section.getDouble("KeepEnchantsChance"));
|
||||
}
|
||||
|
||||
public double getDowngradeChance() {
|
||||
return downgradeChance;
|
||||
}
|
||||
|
||||
public double getKeepEnchantsChance() {
|
||||
return keepEnchantsChance;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.gmail.nossr50.config.tiers;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class SmeltingRank extends Rank {
|
||||
|
||||
private int xpMultiplier;
|
||||
|
||||
public SmeltingRank(int level, int xpMultiplier) {
|
||||
super(level);
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
public SmeltingRank(ConfigurationSection section) {
|
||||
this(section.getInt("Level"), section.getInt("VanillaXPMultiplier"));
|
||||
}
|
||||
|
||||
public int getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -14,10 +16,13 @@ import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
private static TreasureConfig instance;
|
||||
@@ -57,7 +62,8 @@ public class TreasureConfig extends ConfigLoader {
|
||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||
|
||||
private TreasureConfig() {
|
||||
super("treasures.yml");
|
||||
@@ -75,15 +81,14 @@ public class TreasureConfig extends ConfigLoader {
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
if (config.getConfigurationSection("Treasures") != null) {
|
||||
plugin.getLogger().warning("You are using an old version of the treasures.yml file.");
|
||||
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
|
||||
plugin.getLogger().warning("Shake, Hylian Luck, Fishing, and Excavation will not work properly until you do.");
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
loadTreaures("Fishing");
|
||||
loadTreaures("Excavation");
|
||||
loadTreaures("Hylian_Luck");
|
||||
loadEnchantments();
|
||||
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
@@ -104,6 +109,13 @@ public class TreasureConfig extends ConfigLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize fishing HashMap
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (!fishingRewards.containsKey(rarity)) {
|
||||
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
||||
}
|
||||
}
|
||||
|
||||
for (String treasureName : treasureSection.getKeys(false)) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
@@ -130,12 +142,12 @@ public class TreasureConfig extends ConfigLoader {
|
||||
reason.add("Invalid material: " + treasureName);
|
||||
}
|
||||
|
||||
if (amount < 1) {
|
||||
reason.add("Invalid amount: " + amount);
|
||||
if (amount <= 0) {
|
||||
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
|
||||
}
|
||||
|
||||
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
|
||||
reason.add("Invalid data: " + data);
|
||||
reason.add("Data of " + treasureName + " is invalid! " + data);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,31 +159,27 @@ public class TreasureConfig extends ConfigLoader {
|
||||
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
|
||||
|
||||
if (xp < 0) {
|
||||
reason.add("Invalid xp: " + xp);
|
||||
reason.add(treasureName + " has an invalid XP value: " + xp);
|
||||
}
|
||||
|
||||
if (dropChance < 0.0D) {
|
||||
reason.add("Invalid Drop_Chance: " + dropChance);
|
||||
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
}
|
||||
|
||||
if (dropLevel < 0) {
|
||||
reason.add("Invalid Drop_Level: " + dropLevel);
|
||||
reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Specific Types
|
||||
*/
|
||||
int maxLevel = 0;
|
||||
Rarity rarity = null;
|
||||
|
||||
if (isFishing) {
|
||||
maxLevel = config.getInt(type + "." + treasureName + ".Max_Level");
|
||||
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
|
||||
|
||||
if (maxLevel < -1) {
|
||||
reason.add("Invalid Max_Level: " + maxLevel);
|
||||
}
|
||||
|
||||
if (maxLevel != -1 && maxLevel < dropLevel) {
|
||||
reason.add("Max_Level must be -1 or greater than Drop_Level!");
|
||||
if (rarity == null) {
|
||||
reason.add("Invalid Rarity for item: " + treasureName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +229,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
if (isFishing) {
|
||||
fishingRewards.add(new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel));
|
||||
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||
}
|
||||
else if (isShake) {
|
||||
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||
@@ -345,4 +353,37 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadEnchantments() {
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fishingEnchantments.containsKey(rarity)) {
|
||||
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
|
||||
}
|
||||
|
||||
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
|
||||
|
||||
if (enchantmentSection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
||||
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||
|
||||
if (enchantment == null) {
|
||||
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
||||
continue;
|
||||
}
|
||||
|
||||
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public interface DatabaseManager {
|
||||
* Remove a user from the database.
|
||||
*
|
||||
* @param playerName The name of the user to remove
|
||||
*
|
||||
* @return true if the user was successfully removed, false otherwise
|
||||
*/
|
||||
public boolean removeUser(String playerName);
|
||||
@@ -34,23 +35,27 @@ public interface DatabaseManager {
|
||||
* Save a user to the database.
|
||||
*
|
||||
* @param profile The profile of the player to save
|
||||
*
|
||||
* @return true if successful, false on failure
|
||||
*/
|
||||
public void saveUser(PlayerProfile profile);
|
||||
public boolean saveUser(PlayerProfile profile);
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName The skill to retrieve info on
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @param statsPerPage The number of stats per page
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName The skill to retrieve info on
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @param statsPerPage The number of stats per page
|
||||
*
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
||||
|
||||
/**
|
||||
* Retrieve rank info.
|
||||
*
|
||||
* @param playerName The name of the user to retrieve the rankings for
|
||||
*
|
||||
* @return the requested rank information
|
||||
*/
|
||||
public Map<String, Integer> readRank(String playerName);
|
||||
@@ -66,10 +71,11 @@ public interface DatabaseManager {
|
||||
* Load a player 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
|
||||
* found
|
||||
* @param createNew Whether to create a new record if the player is not
|
||||
* found
|
||||
*
|
||||
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||
* and createNew is false
|
||||
* and createNew is false
|
||||
*/
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class DatabaseManagerFactory {
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
if (customManager != null) {
|
||||
try {
|
||||
return createCustomDatabaseManager(customManager);
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
@@ -29,17 +29,18 @@ public class DatabaseManagerFactory {
|
||||
/**
|
||||
* Sets the custom DatabaseManager class for mcMMO to use. This should be
|
||||
* called prior to mcMMO enabling.
|
||||
* <p>
|
||||
* <p/>
|
||||
* The provided class must have an empty constructor, which is the one
|
||||
* that will be used.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This method is intended for API use, but it should not be considered
|
||||
* stable. This method is subject to change and/or removal in future
|
||||
* versions.
|
||||
*
|
||||
* @param clazz the DatabaseManager class to use
|
||||
*
|
||||
* @throws IllegalArgumentException if the provided class does not have
|
||||
* an empty constructor
|
||||
* an empty constructor
|
||||
*/
|
||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||
try {
|
||||
@@ -63,13 +64,24 @@ public class DatabaseManagerFactory {
|
||||
case SQL:
|
||||
return new SQLDatabaseManager();
|
||||
|
||||
case CUSTOM:
|
||||
try {
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Why is clazz never used here?
|
||||
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
|
||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
|
||||
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -122,9 +121,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
catch (NumberFormatException e) {
|
||||
}
|
||||
if (lastPlayed == 0) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
|
||||
lastPlayed = player.getLastPlayed();
|
||||
rewrite = true;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
return worked;
|
||||
}
|
||||
|
||||
public void saveUser(PlayerProfile profile) {
|
||||
public boolean saveUser(PlayerProfile profile) {
|
||||
String playerName = profile.getPlayerName();
|
||||
|
||||
BufferedReader in = null;
|
||||
@@ -272,9 +272,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
@@ -296,7 +298,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
}
|
||||
|
||||
@@ -385,9 +387,14 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
PlayerProfile p = loadFromLine(character);
|
||||
in.close();
|
||||
return p;
|
||||
}
|
||||
|
||||
// Didn't find the player, create a new one
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return new PlayerProfile(playerName, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -397,10 +404,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return new PlayerProfile(playerName, true);
|
||||
}
|
||||
// Return unloaded profile
|
||||
return new PlayerProfile(playerName);
|
||||
}
|
||||
|
||||
@@ -434,11 +438,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkConnected() {
|
||||
// Not implemented
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getStoredUsers() {
|
||||
ArrayList<String> users = new ArrayList<String>();
|
||||
BufferedReader in = null;
|
||||
@@ -493,6 +492,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
|
||||
BufferedReader in = null;
|
||||
String playerName = null;
|
||||
// Read from the FlatFile database and fill our arrays with information
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@@ -501,7 +501,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] data = line.split(":");
|
||||
String playerName = data[0];
|
||||
playerName = data[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||
@@ -523,7 +523,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -23,6 +22,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
|
||||
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
@@ -51,6 +51,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
checkStructure();
|
||||
|
||||
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void purgePowerlessUsers() {
|
||||
@@ -92,7 +94,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
|
||||
|
||||
processPurge(usernames);
|
||||
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");;
|
||||
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");
|
||||
}
|
||||
|
||||
public boolean removeUser(String playerName) {
|
||||
@@ -113,9 +115,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void saveUser(PlayerProfile profile) {
|
||||
public boolean saveUser(PlayerProfile profile) {
|
||||
if (!checkConnected()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
int userId = readId(profile.getPlayerName());
|
||||
@@ -123,15 +125,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
newUser(profile.getPlayerName());
|
||||
userId = readId(profile.getPlayerName());
|
||||
if (userId == -1) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean success = true;
|
||||
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
||||
|
||||
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||
saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
||||
saveLongs(
|
||||
success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||
success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
||||
success &= saveLongs(
|
||||
"UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||
+ ", herbalism = ?, excavation = ?, swords = ?"
|
||||
@@ -145,7 +147,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
|
||||
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
|
||||
profile.getSkillDATS(AbilityType.BLAST_MINING));
|
||||
saveIntegers(
|
||||
success &= saveIntegers(
|
||||
"UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
@@ -164,7 +166,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillLevel(SkillType.FISHING),
|
||||
userId);
|
||||
saveIntegers(
|
||||
success &= saveIntegers(
|
||||
"UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
@@ -183,6 +185,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillXpLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillXpLevel(SkillType.FISHING),
|
||||
userId);
|
||||
return success;
|
||||
}
|
||||
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||
@@ -234,7 +237,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
ResultSet resultSet;
|
||||
|
||||
try {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
String skillName = skillType.name().toLowerCase();
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
@@ -343,6 +346,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
||||
return loadPlayerProfile(playerName, create, true);
|
||||
}
|
||||
|
||||
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
|
||||
if (!checkConnected()) {
|
||||
return new PlayerProfile(playerName, false); // return fake profile if not connected
|
||||
}
|
||||
@@ -372,7 +379,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
result.close();
|
||||
return ret;
|
||||
}
|
||||
catch (SQLException e) {}
|
||||
catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
result.close();
|
||||
}
|
||||
@@ -392,6 +400,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
// Problem, nothing was returned
|
||||
|
||||
// Quit if this is second time around
|
||||
if (!retry) {
|
||||
return new PlayerProfile(playerName, false);
|
||||
}
|
||||
|
||||
// First, read User Id - this is to check for orphans
|
||||
|
||||
int id = readId(playerName);
|
||||
@@ -400,14 +413,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// There is no such user
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return loadPlayerProfile(playerName, false, false);
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, create);
|
||||
// Return unloaded profile if can't create
|
||||
return new PlayerProfile(playerName, false);
|
||||
}
|
||||
// There is such a user
|
||||
writeMissingRows(id);
|
||||
// Retry, and abort on re-failure
|
||||
return loadPlayerProfile(playerName, false);
|
||||
return loadPlayerProfile(playerName, create, false);
|
||||
}
|
||||
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
@@ -452,28 +467,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
*
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
*
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attempting a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
* <p/>
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
* <p/>
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attempting a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public boolean checkConnected() {
|
||||
boolean isClosed = true;
|
||||
boolean isValid = false;
|
||||
@@ -569,7 +586,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
@@ -828,6 +846,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Attempt to write the SQL query.
|
||||
*
|
||||
* @param sql Query to write.
|
||||
*
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
private boolean write(String sql) {
|
||||
@@ -863,6 +882,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
*
|
||||
* @return the number of rows affected
|
||||
*/
|
||||
private int update(String sql) {
|
||||
@@ -897,6 +917,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Read SQL query.
|
||||
*
|
||||
* @param sql SQL query to read
|
||||
*
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
private HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
@@ -942,6 +963,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Get the Integer. Only return first row / first field.
|
||||
*
|
||||
* @param statement SQL query to execute
|
||||
*
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
private int readInt(PreparedStatement statement) {
|
||||
@@ -1020,7 +1042,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveIntegers(String sql, int... args) {
|
||||
private boolean saveIntegers(String sql, int... args) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1032,9 +1054,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1048,7 +1072,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveLongs(String sql, int id, long... args) {
|
||||
private boolean saveLongs(String sql, int id, long... args) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1061,9 +1085,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
statement.setInt(i++, id);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1081,6 +1107,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Retrieve the database id for a player
|
||||
*
|
||||
* @param playerName The name of the user to retrieve the id for
|
||||
*
|
||||
* @return the requested id or -1 if not found
|
||||
*/
|
||||
private int readId(String playerName) {
|
||||
@@ -1098,7 +1125,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return id;
|
||||
}
|
||||
|
||||
private void saveLogin(int id, long login) {
|
||||
private boolean saveLogin(int id, long login) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1106,9 +1133,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setLong(1, login);
|
||||
statement.setInt(2, id);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1122,7 +1151,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveHuds(int userId, String mobHealthBar) {
|
||||
private boolean saveHuds(int userId, String mobHealthBar) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1130,9 +1159,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setString(1, mobHealthBar);
|
||||
statement.setInt(2, userId);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
|
||||
@@ -7,6 +7,5 @@ public enum DatabaseUpdateType {
|
||||
MOB_HEALTHBARS,
|
||||
PARTY_NAMES,
|
||||
KILL_ORPHANS,
|
||||
DROPPED_SPOUT
|
||||
;
|
||||
DROPPED_SPOUT;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,19 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomBlock {
|
||||
private int xpGain;
|
||||
private ItemStack itemDrop;
|
||||
private int minimumDropAmount;
|
||||
private int maximumDropAmount;
|
||||
private boolean canDoubleDrop;
|
||||
|
||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int xpGain) {
|
||||
public CustomBlock(int xpGain, boolean canDoubleDrop) {
|
||||
this.xpGain = xpGain;
|
||||
this.itemDrop = itemDrop;
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
this.canDoubleDrop = canDoubleDrop;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
return xpGain;
|
||||
}
|
||||
|
||||
public ItemStack getItemDrop() {
|
||||
return itemDrop;
|
||||
}
|
||||
|
||||
public int getMinimumDropAmount() {
|
||||
return minimumDropAmount;
|
||||
}
|
||||
|
||||
public int getMaximumDropAmount() {
|
||||
return maximumDropAmount;
|
||||
public boolean isDoubleDropEnabled() {
|
||||
return canDoubleDrop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,14 @@ import java.util.Set;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
@@ -17,11 +22,11 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
@@ -38,9 +43,12 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -123,6 +131,69 @@ public class McMMOPlayer {
|
||||
toolMode.put(toolType, false);
|
||||
toolATS.put(toolType, 0);
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
mcMMO.p.getLogger().warning("Unable to load the PlayerProfile for " + playerName + ". Will retry over the next several seconds.");
|
||||
new RetryProfileLoadingTask().runTaskTimerAsynchronously(mcMMO.p, 11L, 31L);
|
||||
}
|
||||
}
|
||||
|
||||
private class RetryProfileLoadingTask extends BukkitRunnable {
|
||||
private static final int MAX_TRIES = 5;
|
||||
private final String playerName = McMMOPlayer.this.player.getName();
|
||||
private int attempt = 0;
|
||||
|
||||
// WARNING: ASYNC TASK
|
||||
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
|
||||
@Override
|
||||
public void run() {
|
||||
// Quit if they logged out
|
||||
if (!player.isOnline()) {
|
||||
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + playerName + " - player logged out");
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the message that we're doing the recovery
|
||||
if (attempt == 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Notice"));
|
||||
}
|
||||
|
||||
// Increment attempt counter and try
|
||||
attempt++;
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
||||
// If successful, schedule the apply
|
||||
if (profile.isLoaded()) {
|
||||
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Success"));
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've failed five times, give up
|
||||
if (attempt >= MAX_TRIES) {
|
||||
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + playerName);
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Recovery.AdminFailureNotice", playerName), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Failure").split("\n"));
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||
private final PlayerProfile profile;
|
||||
|
||||
private ApplySuccessfulProfile(PlayerProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
// Synchronized task
|
||||
// No database access permitted
|
||||
@Override
|
||||
public void run() {
|
||||
McMMOPlayer.this.profile = profile;
|
||||
}
|
||||
}
|
||||
|
||||
public AcrobaticsManager getAcrobaticsManager() {
|
||||
@@ -195,6 +266,7 @@ public class McMMOPlayer {
|
||||
* Get the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
*
|
||||
* @return true if the ability is enabled, false otherwise
|
||||
*/
|
||||
public boolean getAbilityMode(AbilityType ability) {
|
||||
@@ -204,7 +276,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param ability The ability to check
|
||||
* @param isActive True if the ability is active, false otherwise
|
||||
*/
|
||||
public void setAbilityMode(AbilityType ability, boolean isActive) {
|
||||
@@ -215,6 +287,7 @@ public class McMMOPlayer {
|
||||
* Get the informed state of an ability
|
||||
*
|
||||
* @param ability The ability to check
|
||||
*
|
||||
* @return true if the ability is informed, false otherwise
|
||||
*/
|
||||
public boolean getAbilityInformed(AbilityType ability) {
|
||||
@@ -224,7 +297,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the informed state of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param ability The ability to check
|
||||
* @param isInformed True if the ability is informed, false otherwise
|
||||
*/
|
||||
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
|
||||
@@ -235,6 +308,7 @@ public class McMMOPlayer {
|
||||
* Get the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to get the mode for
|
||||
*
|
||||
* @return true if the tool is prepped, false otherwise
|
||||
*/
|
||||
public boolean getToolPreparationMode(ToolType tool) {
|
||||
@@ -265,7 +339,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to set the mode for
|
||||
* @param tool Tool to set the mode for
|
||||
* @param isPrepared true if the tool should be prepped, false otherwise
|
||||
*/
|
||||
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
||||
@@ -276,6 +350,7 @@ public class McMMOPlayer {
|
||||
* Get the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to get the ATS for
|
||||
*
|
||||
* @return the ATS for the tool
|
||||
*/
|
||||
public long getToolPreparationATS(ToolType tool) {
|
||||
@@ -286,7 +361,7 @@ public class McMMOPlayer {
|
||||
* Set the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to set the ATS for
|
||||
* @param ATS the ATS of the tool
|
||||
* @param ATS the ATS of the tool
|
||||
*/
|
||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
@@ -448,7 +523,7 @@ public class McMMOPlayer {
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
@@ -461,7 +536,7 @@ public class McMMOPlayer {
|
||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate, perks, and may be shared with the party
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginXpGain(SkillType skillType, float xp) {
|
||||
if (xp == 0) {
|
||||
@@ -492,7 +567,7 @@ public class McMMOPlayer {
|
||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginUnsharedXpGain(SkillType skillType, float xp) {
|
||||
xp = modifyXpGain(skillType, xp);
|
||||
@@ -504,7 +579,7 @@ public class McMMOPlayer {
|
||||
* Applies an experience gain
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, float xp) {
|
||||
if (!Permissions.skillEnabled(player, skillType)) {
|
||||
@@ -521,17 +596,45 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
|
||||
|
||||
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
||||
SkillUtils.xpCheckSkill(skillType, player, profile);
|
||||
checkXp(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the XP of a skill.
|
||||
*
|
||||
* @param skillType The skill to check
|
||||
*/
|
||||
private void checkXp(SkillType skillType) {
|
||||
int levelsGained = 0;
|
||||
float xpRemoved = 0;
|
||||
|
||||
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) {
|
||||
int xp = profile.getXpToLevel(skillType);
|
||||
xpRemoved += xp;
|
||||
|
||||
profile.removeXp(skillType, xp);
|
||||
levelsGained++;
|
||||
profile.skillUp(skillType, 1);
|
||||
}
|
||||
else {
|
||||
profile.addLevels(skillType, 0); // This seems kinda pointless... why do we have this again?
|
||||
}
|
||||
}
|
||||
|
||||
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -682,7 +785,8 @@ public class McMMOPlayer {
|
||||
* Modifies an experience gain using skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*
|
||||
* @return Modified experience
|
||||
*/
|
||||
private float modifyXpGain(SkillType skillType, float xp) {
|
||||
@@ -716,4 +820,107 @@ public class McMMOPlayer {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if an ability can be activated.
|
||||
*
|
||||
* @param skill The skill the ability is based on
|
||||
*/
|
||||
public void checkAbilityActivation(SkillType skill) {
|
||||
ToolType tool = skill.getTool();
|
||||
AbilityType ability = skill.getAbility();
|
||||
|
||||
setToolPreparationMode(tool, false);
|
||||
|
||||
if (getAbilityMode(ability)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
/*
|
||||
* Axes and Woodcutting are odd because they share the same tool.
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
|
||||
|
||||
// Notify people that ability has been activated
|
||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||
|
||||
if (useChatNotifications()) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
}
|
||||
|
||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||
|
||||
// Enable the ability
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
setAbilityMode(ability, true);
|
||||
|
||||
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
SkillUtils.handleAbilitySpeedIncrease(player);
|
||||
}
|
||||
|
||||
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void processAbilityActivation(SkillType skill) {
|
||||
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getAbilityUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
if (getAbilityMode(abilityType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AbilityType ability = skill.getAbility();
|
||||
ToolType tool = skill.getTool();
|
||||
|
||||
/*
|
||||
* Woodcutting & Axes need to be treated differently.
|
||||
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
|
||||
*/
|
||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||
|
||||
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||
player.sendMessage(tool.getRaiseTool());
|
||||
}
|
||||
|
||||
setToolPreparationATS(tool, System.currentTimeMillis());
|
||||
setToolPreparationMode(tool, true);
|
||||
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PlayerProfile {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class PlayerProfile {
|
||||
* Calling this constructor is considered loading the profile.
|
||||
*/
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
|
||||
this(playerName, true);
|
||||
this(playerName);
|
||||
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
|
||||
@@ -66,12 +66,14 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!changed) {
|
||||
if (!changed || !loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.getDatabaseManager().saveUser(this);
|
||||
changed = false;
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(this);
|
||||
if (changed) {
|
||||
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
@@ -114,6 +116,7 @@ public class PlayerProfile {
|
||||
* Get the current DATS of a skill.
|
||||
*
|
||||
* @param abilityType Ability to get the DATS for
|
||||
*
|
||||
* @return the DATS for the ability
|
||||
*/
|
||||
public long getSkillDATS(AbilityType abilityType) {
|
||||
@@ -123,8 +126,8 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Set the current DATS of a skill.
|
||||
*
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
*/
|
||||
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
||||
int wearsOff = (int) (DATS * .001D);
|
||||
@@ -150,11 +153,7 @@ public class PlayerProfile {
|
||||
*/
|
||||
|
||||
public int getSkillLevel(SkillType skillType) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return getChildSkillLevel(skillType);
|
||||
}
|
||||
|
||||
return skills.get(skillType);
|
||||
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType);
|
||||
}
|
||||
|
||||
public float getSkillXpLevelRaw(SkillType skillType) {
|
||||
@@ -183,7 +182,7 @@ public class PlayerProfile {
|
||||
* Remove Xp from a skill.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXp(SkillType skillType, int xp) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -199,7 +198,7 @@ public class PlayerProfile {
|
||||
* Modify a skill level.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param newValue New level value for the skill
|
||||
* @param newValue New level value for the skill
|
||||
*/
|
||||
public void modifySkill(SkillType skillType, int newValue) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -216,7 +215,7 @@ public class PlayerProfile {
|
||||
* Add levels to a skill.
|
||||
*
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public void addLevels(SkillType skillType, int levels) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -232,7 +231,7 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Add Experience to a skill.
|
||||
*
|
||||
* @param skillType Type of skill to add experience to
|
||||
* @param skillType Type of skill to add experience to
|
||||
* @param experience Number of experience to add
|
||||
*/
|
||||
public void addExperience(SkillType skillType, int experience) {
|
||||
@@ -249,6 +248,7 @@ public class PlayerProfile {
|
||||
* Get the total amount of Xp before the next level.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
*
|
||||
* @return the total amount of Xp until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
@@ -148,6 +150,7 @@ public enum AbilityType {
|
||||
* Get the permissions for this ability.
|
||||
*
|
||||
* @param player Player to check permissions for
|
||||
*
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
@@ -191,6 +194,7 @@ public enum AbilityType {
|
||||
* Check if a block is affected by this ability.
|
||||
*
|
||||
* @param blockState the block to check
|
||||
*
|
||||
* @return true if the block is affected by this ability, false otherwise
|
||||
*/
|
||||
public boolean blockCheck(BlockState blockState) {
|
||||
@@ -220,4 +224,24 @@ public enum AbilityType {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if ability should be triggered.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block modified by the ability
|
||||
*
|
||||
* @return true if the ability should activate, false otherwise
|
||||
*/
|
||||
public boolean triggerCheck(Player player, Block block) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
case BLOCK_CRACKER:
|
||||
case LEAF_BLOWER:
|
||||
return blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -51,15 +50,34 @@ public enum SkillType {
|
||||
|
||||
public static final List<String> SKILL_NAMES;
|
||||
|
||||
public static final List<SkillType> CHILD_SKILLS;
|
||||
public static final List<SkillType> NON_CHILD_SKILLS;
|
||||
|
||||
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
|
||||
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
|
||||
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, REPAIR, SMELTING);
|
||||
|
||||
static {
|
||||
List<SkillType> childSkills = new ArrayList<SkillType>();
|
||||
List<SkillType> nonChildSkills = new ArrayList<SkillType>();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
for (SkillType skill : values()) {
|
||||
names.add(SkillUtils.getSkillName(skill));
|
||||
if (skill.isChildSkill()) {
|
||||
childSkills.add(skill);
|
||||
}
|
||||
else {
|
||||
nonChildSkills.add(skill);
|
||||
}
|
||||
|
||||
names.add(skill.getSkillName());
|
||||
}
|
||||
|
||||
Collections.sort(names);
|
||||
SKILL_NAMES = ImmutableList.copyOf(names);
|
||||
|
||||
CHILD_SKILLS = ImmutableList.copyOf(childSkills);
|
||||
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
|
||||
}
|
||||
|
||||
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
|
||||
@@ -109,10 +127,18 @@ public enum SkillType {
|
||||
return Config.getInstance().getHardcoreStatLossEnabled(this);
|
||||
}
|
||||
|
||||
public void setHardcoreStatLossEnabled(boolean enable) {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(this, enable);
|
||||
}
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled(this);
|
||||
}
|
||||
|
||||
public void setHardcoreVampirismEnabled(boolean enable) {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(this, enable);
|
||||
}
|
||||
|
||||
public ToolType getTool() {
|
||||
return tool;
|
||||
}
|
||||
@@ -143,33 +169,14 @@ public enum SkillType {
|
||||
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
|
||||
public boolean isChildSkill() {
|
||||
switch (this) {
|
||||
case SMELTING:
|
||||
return true;
|
||||
case SMELTING:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static SkillType[] nonChildSkills() {
|
||||
return new SkillType[] {SkillType.ACROBATICS,
|
||||
SkillType.ARCHERY,
|
||||
SkillType.AXES,
|
||||
SkillType.EXCAVATION,
|
||||
SkillType.FISHING,
|
||||
SkillType.HERBALISM,
|
||||
SkillType.MINING,
|
||||
SkillType.REPAIR,
|
||||
SkillType.SWORDS,
|
||||
SkillType.TAMING,
|
||||
SkillType.UNARMED,
|
||||
SkillType.WOODCUTTING };
|
||||
}
|
||||
|
||||
public static SkillType[] childSkills() {
|
||||
return new SkillType[] { SkillType.SMELTING };
|
||||
}
|
||||
|
||||
public Color getRunescapeModeColor() {
|
||||
return runescapeColor;
|
||||
}
|
||||
@@ -183,4 +190,8 @@ public enum SkillType {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public enum ToolType {
|
||||
* Check to see if the item is of the appropriate type.
|
||||
*
|
||||
* @param itemStack The item to check
|
||||
*
|
||||
* @return true if the item is the right type, false otherwise
|
||||
*/
|
||||
public boolean inHand(ItemStack itemStack) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public class EnchantmentTreasure {
|
||||
private Enchantment enchantment;
|
||||
private int level;
|
||||
|
||||
public EnchantmentTreasure(Enchantment enchantment, int level) {
|
||||
this.setEnchantment(enchantment);
|
||||
this.setLevel(level);
|
||||
}
|
||||
|
||||
public Enchantment getEnchantment() {
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,8 @@ package com.gmail.nossr50.datatypes.treasure;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FishingTreasure extends Treasure {
|
||||
private int maxLevel;
|
||||
|
||||
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
this.setMaxLevel(maxLevel);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public void setMaxLevel(int maxLevel) {
|
||||
this.maxLevel = maxLevel;
|
||||
public FishingTreasure(ItemStack drop, int xp) {
|
||||
super(drop, xp, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
public enum Rarity {
|
||||
RECORD,
|
||||
LEGENDARY,
|
||||
EPIC,
|
||||
RARE,
|
||||
UNCOMMON,
|
||||
COMMON,
|
||||
TRAP;
|
||||
|
||||
public static Rarity getRarity(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return COMMON;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,28 +3,16 @@ package com.gmail.nossr50.events.skills.abilities;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private AbilityType abilityType;
|
||||
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
abilityType = skill.getAbility();
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ability type involved in this event
|
||||
*/
|
||||
public AbilityType getAbilityType() {
|
||||
return abilityType;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,10 @@ package com.gmail.nossr50.events.skills.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
|
||||
|
||||
private AbilityType ability;
|
||||
|
||||
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
|
||||
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
this.ability = skill.getAbility();
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.events.skills.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
|
||||
private AbilityType ability;
|
||||
|
||||
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
ability = skill.getAbility();
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
protected McMMOPlayerFishingEvent(Player player) {
|
||||
super(player, SkillType.FISHING);
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
|
||||
private ItemStack treasure;
|
||||
private int xp;
|
||||
|
||||
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
|
||||
super(player, SkillType.FISHING);
|
||||
super(player);
|
||||
this.treasure = treasure;
|
||||
this.xp = xp;
|
||||
}
|
||||
@@ -27,14 +21,6 @@ public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent imple
|
||||
this.treasure = item;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
|
||||
|
||||
private Map<Enchantment, Integer> enchants;
|
||||
|
||||
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
|
||||
|
||||
@@ -1,30 +1,16 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
|
||||
private ItemStack drop;
|
||||
|
||||
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
|
||||
super(player, SkillType.FISHING);
|
||||
super(player);
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
|
||||
public ItemStack getDrop() {
|
||||
return drop;
|
||||
}
|
||||
@@ -32,5 +18,4 @@ public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Canc
|
||||
public void setDrop(ItemStack drop) {
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
@@ -84,7 +84,7 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isSticky()) {
|
||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||
@@ -149,7 +149,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* Green Terra */
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -280,19 +280,19 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,17 +339,17 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
||||
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (AbilityType.BERSERK.triggerCheck(player, block)) {
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||
}
|
||||
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
|
||||
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && AbilityType.BLOCK_CRACKER.triggerCheck(player, block)) {
|
||||
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && AbilityType.LEAF_BLOWER.triggerCheck(player, block)) {
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||
}
|
||||
|
||||
@@ -459,6 +459,22 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle EntityExplode events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.blockList().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle FoodLevelChange events that involve modifying the event.
|
||||
*
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.HardcoreManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -68,7 +69,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerTeleportEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of setting the
|
||||
* player's last teleportation timestamp, in order to prevent
|
||||
* possible Acrobatics exploitation.
|
||||
@@ -88,7 +89,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerDeathEvents at the lowest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used to modify the death message of a player when
|
||||
* needed to correct issues potentially caused by the custom naming used
|
||||
* for mob healthbars.
|
||||
@@ -114,7 +115,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeathEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of dealing the penalties
|
||||
* associated with hardcore and vampirism modes. If neither of these
|
||||
* modes are enabled, or if the player who died has hardcore bypass
|
||||
@@ -150,7 +151,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerChangedWorldEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of removing god mode or
|
||||
* player parties if they are not allowed on the world the player has
|
||||
* changed to.
|
||||
@@ -173,7 +174,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDropItemEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of flagging sharable
|
||||
* dropped items, as well as removing ability buffs from pickaxes
|
||||
* and shovels.
|
||||
@@ -194,7 +195,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerFishEvents at the highest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used for the purpose of handling our anti-exploit
|
||||
* code, as well as dealing with ice fishing.
|
||||
*
|
||||
@@ -239,7 +240,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerFishEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of handling the various
|
||||
* Fishing skills and abilities.
|
||||
*
|
||||
@@ -280,7 +281,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerPickupItemEvents at the highest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used to handle item sharing between party members and
|
||||
* are also used to handle item pickup for the Unarmed skill.
|
||||
*
|
||||
@@ -321,7 +322,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerQuitEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of resetting player
|
||||
* variables and other garbage collection tasks that must take place when
|
||||
* a player exits the server.
|
||||
@@ -346,7 +347,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerJoinEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of initializing player
|
||||
* variables, as well as handling the MOTD display and other important
|
||||
* join messages.
|
||||
@@ -380,7 +381,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerRespawnEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of setting the
|
||||
* player's last respawn timestamp, in order to prevent
|
||||
* possible exploitation.
|
||||
@@ -514,15 +515,15 @@ public class PlayerListener implements Listener {
|
||||
if (BlockUtils.canActivateAbilities(blockState)) {
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
if (BlockUtils.canActivateHerbalism(blockState)) {
|
||||
SkillUtils.activationCheck(player, SkillType.HERBALISM);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
SkillUtils.activationCheck(player, SkillType.AXES);
|
||||
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillUtils.activationCheck(player, SkillType.MINING);
|
||||
SkillUtils.activationCheck(player, SkillType.SWORDS);
|
||||
SkillUtils.activationCheck(player, SkillType.UNARMED);
|
||||
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
ChimaeraWing.activationCheck(player);
|
||||
@@ -534,14 +535,14 @@ public class PlayerListener implements Listener {
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
|
||||
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
if (herbalismManager.processShroomThumb(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
@@ -551,13 +552,13 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
SkillUtils.activationCheck(player, SkillType.AXES);
|
||||
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillUtils.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillUtils.activationCheck(player, SkillType.MINING);
|
||||
SkillUtils.activationCheck(player, SkillType.SWORDS);
|
||||
SkillUtils.activationCheck(player, SkillType.UNARMED);
|
||||
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
@@ -659,7 +660,7 @@ public class PlayerListener implements Listener {
|
||||
// Do these ACTUALLY have to be lower case to work properly?
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String skillName = skill.toString().toLowerCase();
|
||||
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
|
||||
String localizedName = skill.getSkillName().toLowerCase();
|
||||
|
||||
if (lowerCaseCommand.equals(localizedName)) {
|
||||
event.setMessage(message.replace(command, skillName));
|
||||
|
||||
@@ -14,7 +14,7 @@ public final class LocaleLoader {
|
||||
private static ResourceBundle bundle = null;
|
||||
private static ResourceBundle enBundle = null;
|
||||
|
||||
private LocaleLoader() {};
|
||||
private LocaleLoader() {}
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, (Object[]) null);
|
||||
@@ -23,8 +23,9 @@ public final class LocaleLoader {
|
||||
/**
|
||||
* Gets the appropriate string from the Locale files.
|
||||
*
|
||||
* @param key The key to look up the string with
|
||||
* @param key The key to look up the string with
|
||||
* @param messageArguments Any arguments to be added to the string
|
||||
*
|
||||
* @return The properly formatted locale string
|
||||
*/
|
||||
public static String getString(String key, Object... messageArguments) {
|
||||
@@ -46,7 +47,7 @@ public final class LocaleLoader {
|
||||
}
|
||||
|
||||
private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException {
|
||||
return formatString(bundle.getString(key).replace("\'", "''"), messageArguments);
|
||||
return formatString(bundle.getString(key), messageArguments);
|
||||
}
|
||||
|
||||
public static String formatString(String string, Object... messageArguments) {
|
||||
@@ -56,6 +57,7 @@ public final class LocaleLoader {
|
||||
string = formatter.format(messageArguments);
|
||||
}
|
||||
|
||||
string.replaceAll("\'", "''");
|
||||
string = addColors(string);
|
||||
|
||||
return string;
|
||||
|
||||
@@ -35,10 +35,10 @@ import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.child.ChildConfig;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -91,6 +91,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
||||
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
|
||||
public final static String customNameKey = "mcMMO: Custom Name";
|
||||
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
||||
public final static String droppedItemKey = "mcMMO: Tracked Item";
|
||||
@@ -185,7 +186,8 @@ public class mcMMO extends JavaPlugin {
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
}
|
||||
catch (NullPointerException e) {}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
@@ -287,9 +289,23 @@ public class mcMMO extends JavaPlugin {
|
||||
private void setupFilePaths() {
|
||||
mcmmo = getFile();
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
modDirectory = mainDirectory + "mods" + File.separator;
|
||||
fixFilePaths();
|
||||
}
|
||||
|
||||
private void fixFilePaths() {
|
||||
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
|
||||
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
|
||||
|
||||
if (oldFlatfilePath.exists()) {
|
||||
oldFlatfilePath.renameTo(new File(flatFileDirectory));
|
||||
}
|
||||
|
||||
if (oldModPath.exists()) {
|
||||
oldModPath.renameTo(new File(modDirectory));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
@@ -342,7 +358,7 @@ public class mcMMO extends JavaPlugin {
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
|
||||
repairableManager = new SimpleRepairableManager(repairables.size());
|
||||
repairableManager.registerRepairables(repairables);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if a party with a given name already exists.
|
||||
*
|
||||
* @param player The player to notify
|
||||
* @param player The player to notify
|
||||
* @param partyName The name of the party to check
|
||||
*
|
||||
* @return true if a party with that name exists, false otherwise
|
||||
*/
|
||||
public static boolean checkPartyExistence(Player player, String partyName) {
|
||||
@@ -47,8 +48,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Attempt to change parties or join a new party.
|
||||
*
|
||||
* @param mcMMOPlayer The player changing or joining parties
|
||||
* @param mcMMOPlayer The player changing or joining parties
|
||||
* @param newPartyName The name of the party being joined
|
||||
*
|
||||
* @return true if the party was joined successfully, false otherwise
|
||||
*/
|
||||
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
|
||||
@@ -73,8 +75,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
*
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
@@ -92,6 +95,7 @@ public final class PartyManager {
|
||||
* Get the near party members.
|
||||
*
|
||||
* @param mcMMOPlayer The player to check
|
||||
*
|
||||
* @return the near party members
|
||||
*/
|
||||
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
|
||||
@@ -116,6 +120,7 @@ public final class PartyManager {
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static LinkedHashSet<String> getAllMembers(Player player) {
|
||||
@@ -128,6 +133,7 @@ public final class PartyManager {
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
@@ -138,6 +144,7 @@ public final class PartyManager {
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
@@ -152,6 +159,7 @@ public final class PartyManager {
|
||||
* Retrieve a party by its name
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(String partyName) {
|
||||
@@ -168,6 +176,7 @@ public final class PartyManager {
|
||||
* Retrieve a party by a members name
|
||||
*
|
||||
* @param playerName The members name
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getPlayerParty(String playerName) {
|
||||
@@ -184,16 +193,13 @@ public final class PartyManager {
|
||||
* Retrieve a party by member
|
||||
*
|
||||
* @param player The member
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty();
|
||||
}
|
||||
|
||||
return getPlayerParty(player.getName());
|
||||
return mcMMOPlayer.getParty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +215,7 @@ public final class PartyManager {
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param player The player to remove
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void removeFromParty(OfflinePlayer player, Party party) {
|
||||
LinkedHashSet<String> members = party.getMembers();
|
||||
@@ -257,8 +263,8 @@ public final class PartyManager {
|
||||
* Create a new party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
*/
|
||||
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
@@ -279,9 +285,10 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
*
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
||||
@@ -330,7 +337,7 @@ public final class PartyManager {
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
String playerName = mcMMOPlayer.getPlayer().getName();
|
||||
@@ -344,6 +351,7 @@ public final class PartyManager {
|
||||
* Get the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
@@ -356,7 +364,7 @@ public final class PartyManager {
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param playerName The name of the player to set as leader
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void setPartyLeader(String playerName, Party party) {
|
||||
String leaderName = party.getLeader();
|
||||
@@ -393,6 +401,7 @@ public final class PartyManager {
|
||||
* Check if a string is a valid party name.
|
||||
*
|
||||
* @param partyName The party name to check
|
||||
*
|
||||
* @return true if this is a valid party, false otherwise
|
||||
*/
|
||||
public static boolean isParty(String partyName) {
|
||||
@@ -478,10 +487,11 @@ public final class PartyManager {
|
||||
/**
|
||||
* Handle party change event.
|
||||
*
|
||||
* @param player The player changing parties
|
||||
* @param player The player changing parties
|
||||
* @param oldPartyName The name of the old party
|
||||
* @param newPartyName The name of the new party
|
||||
* @param reason The reason for changing parties
|
||||
* @param reason The reason for changing parties
|
||||
*
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||
@@ -505,7 +515,7 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a player joins.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that joined
|
||||
*/
|
||||
private static void informPartyMembersJoin(Party party, String playerName) {
|
||||
@@ -517,7 +527,7 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a party member quits.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that left
|
||||
*/
|
||||
private static void informPartyMembersQuit(Party party, String playerName) {
|
||||
|
||||
@@ -22,9 +22,10 @@ public final class ShareHandler {
|
||||
/**
|
||||
* Distribute Xp amongst party members.
|
||||
*
|
||||
* @param xp Xp without party sharing
|
||||
* @param xp Xp without party sharing
|
||||
* @param mcMMOPlayer Player initiating the Xp gain
|
||||
* @param skillType Skill being used
|
||||
* @param skillType Skill being used
|
||||
*
|
||||
* @return True is the xp has been shared
|
||||
*/
|
||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||
@@ -56,8 +57,9 @@ public final class ShareHandler {
|
||||
/**
|
||||
* Distribute Items amongst party members.
|
||||
*
|
||||
* @param drop Item that will get shared
|
||||
* @param drop Item that will get shared
|
||||
* @param mcMMOPlayer Player who picked up the item
|
||||
*
|
||||
* @return True if the item has been shared
|
||||
*/
|
||||
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
private final Map<String, Integer> skills;
|
||||
@@ -31,13 +30,13 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = skills.get(skill.name());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skill), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getSkillName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||
}
|
||||
|
||||
rank = skills.get("ALL");
|
||||
|
||||
@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FormulaConversionTask extends BukkitRunnable {
|
||||
private void editValues(PlayerProfile profile) {
|
||||
mcMMO.p.debug("========================================================================");
|
||||
mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":");
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
int oldLevel = profile.getSkillLevel(skillType);
|
||||
int oldXPLevel = profile.getSkillXpLevel(skillType);
|
||||
int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||
|
||||
/**
|
||||
* This task is in charge of sending a MySQL ping over the MySQL connection
|
||||
* every hour to prevent the connection from timing out and losing players'
|
||||
* data when they join.
|
||||
* <p/>
|
||||
* A WeakReference is used to keep the database instance, because
|
||||
* {@link com.gmail.nossr50.commands.database.ConvertDatabaseCommand database
|
||||
* conversion} may create a SQLDatabaseManager that will be thrown out. If a
|
||||
* normal reference was used, the conversion would cause a combined data and
|
||||
* resource leak through this task.
|
||||
*/
|
||||
public class SQLDatabaseKeepaliveTask extends BukkitRunnable {
|
||||
WeakReference<SQLDatabaseManager> databaseInstance;
|
||||
|
||||
public SQLDatabaseKeepaliveTask(SQLDatabaseManager dbman) {
|
||||
databaseInstance = new WeakReference<SQLDatabaseManager>(dbman);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SQLDatabaseManager dbman = databaseInstance.get();
|
||||
if (dbman != null) {
|
||||
dbman.checkConnected();
|
||||
}
|
||||
else {
|
||||
// This happens when the database was started for a conversion,
|
||||
// or discarded by its creator for any other reason. If this code
|
||||
// was not present, we would leak the connection resources.
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -58,6 +58,6 @@ public class TeleportationWarmup extends BukkitRunnable {
|
||||
}
|
||||
}
|
||||
|
||||
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
@@ -47,8 +46,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
break;
|
||||
}
|
||||
|
||||
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability));
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
EventUtils.callAbilityDeactivateEvent(player, ability);
|
||||
|
||||
mcMMOPlayer.setAbilityMode(ability, false);
|
||||
mcMMOPlayer.setAbilityInformed(ability, false);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
* Add a LivingEntity to the bleedList if it is not in it.
|
||||
*
|
||||
* @param entity LivingEntity to add
|
||||
* @param ticks Number of bleeding ticks
|
||||
* @param ticks Number of bleeding ticks
|
||||
*/
|
||||
public static void add(LivingEntity entity, int ticks) {
|
||||
int newTicks = ticks;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
|
||||
public final class Acrobatics {
|
||||
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
|
||||
@@ -16,14 +17,16 @@ public final class Acrobatics {
|
||||
public static double gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
|
||||
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
|
||||
|
||||
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
|
||||
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
|
||||
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
|
||||
public static int dodgeXpModifier = ExperienceConfig.getInstance().getDodgeXPModifier();
|
||||
public static int rollXpModifier = ExperienceConfig.getInstance().getRollXPModifier();
|
||||
public static int fallXpModifier = ExperienceConfig.getInstance().getFallXPModifier();
|
||||
|
||||
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
|
||||
|
||||
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
|
||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||
|
||||
private Acrobatics() {};
|
||||
private Acrobatics() {}
|
||||
|
||||
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
|
||||
return Math.max(damage / damageModifier, 1.0);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
@@ -42,6 +44,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Dodge ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
public double dodgeCheck(double damage) {
|
||||
@@ -70,6 +73,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Roll ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
public double rollCheck(double damage) {
|
||||
@@ -83,12 +87,12 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||
applyXpGain((float) (damage * Acrobatics.rollXpModifier));
|
||||
applyXpGain(calculateRollXP(damage, true));
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain((float) (damage * Acrobatics.fallXpModifier));
|
||||
applyXpGain(calculateRollXP(damage, false));
|
||||
}
|
||||
|
||||
return damage;
|
||||
@@ -98,6 +102,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Graceful Roll ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
private double gracefulRollCheck(double damage) {
|
||||
@@ -105,12 +110,12 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel)) {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||
applyXpGain((float) (damage * Acrobatics.rollXpModifier));
|
||||
applyXpGain(calculateRollXP(damage, true));
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain((float) (damage * Acrobatics.fallXpModifier));
|
||||
applyXpGain(calculateRollXP(damage, false));
|
||||
}
|
||||
|
||||
return damage;
|
||||
@@ -123,4 +128,15 @@ public class AcrobaticsManager extends SkillManager {
|
||||
private boolean isFatal(double damage) {
|
||||
return getPlayer().getHealth() - damage < 1;
|
||||
}
|
||||
|
||||
private float calculateRollXP(double damage, boolean isRoll) {
|
||||
ItemStack boots = getPlayer().getInventory().getBoots();
|
||||
float xp = (float) (damage * (isRoll ? Acrobatics.rollXpModifier : Acrobatics.fallXpModifier));
|
||||
|
||||
if (boots != null && boots.containsEnchantment(Enchantment.PROTECTION_FALL)) {
|
||||
xp *= Acrobatics.featherFallXPModifier;
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ArcheryManager extends SkillManager {
|
||||
/**
|
||||
* Calculate bonus XP awarded for Archery when hitting a far-away target.
|
||||
*
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
* @param damager The {@link Entity} who shot the arrow
|
||||
*/
|
||||
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
||||
@@ -69,7 +69,7 @@ public class ArcheryManager extends SkillManager {
|
||||
* Handle the effects of the Daze ability
|
||||
*
|
||||
* @param defender The {@link Player} being affected by the ability
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double daze(Player defender, Arrow arrow) {
|
||||
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||
@@ -98,7 +98,7 @@ public class ArcheryManager extends SkillManager {
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
|
||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
|
||||
|
||||
for (SkillType skill : SkillType.childSkills()) {
|
||||
for (SkillType skill : SkillType.CHILD_SKILLS) {
|
||||
plugin.debug("Finding parents of " + skill.name());
|
||||
|
||||
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Excavation {
|
||||
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check.
|
||||
*
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
|
||||
@@ -15,27 +15,15 @@ import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class Fishing {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier5(); }
|
||||
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank5(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5(); }},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier4(); }
|
||||
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank4(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4(); }},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier3(); }
|
||||
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank3(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3(); }},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier2(); }
|
||||
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank2(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2(); }},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier1(); }
|
||||
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank1(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1(); }};
|
||||
public enum Tier {
|
||||
EIGHT(8),
|
||||
SEVEN(7),
|
||||
SIX(6),
|
||||
FIVE(5),
|
||||
FOUR(4),
|
||||
THREE(3),
|
||||
TWO(2),
|
||||
ONE(1);
|
||||
|
||||
int numerical;
|
||||
|
||||
@@ -47,9 +35,17 @@ public final class Fishing {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected double getShakeChance();
|
||||
abstract protected int getVanillaXPBoostModifier();
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getFishingTierLevel(this);
|
||||
}
|
||||
|
||||
protected double getShakeChance() {
|
||||
return AdvancedConfig.getInstance().getShakeChance(this);
|
||||
}
|
||||
|
||||
protected int getVanillaXPBoostModifier() {
|
||||
return AdvancedConfig.getInstance().getFishingVanillaXPModifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<Material, List<Enchantment>>();
|
||||
@@ -66,6 +62,7 @@ public final class Fishing {
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param target Targeted entity
|
||||
*
|
||||
* @return possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
||||
@@ -139,6 +136,7 @@ public final class Fishing {
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
||||
|
||||
@@ -26,10 +26,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
@@ -38,18 +42,18 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -62,17 +66,18 @@ public class FishingManager extends SkillManager {
|
||||
private int fishingTries = 0;
|
||||
private long fishingTimestamp = 0L;
|
||||
private Location fishingTarget;
|
||||
private Item fishingCatch;
|
||||
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.FISHING);
|
||||
}
|
||||
|
||||
public boolean canShake(Entity target) {
|
||||
return target instanceof LivingEntity && getSkillLevel() >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(getPlayer());
|
||||
return target instanceof LivingEntity && getSkillLevel() >= Tier.ONE.getLevel() && Permissions.shake(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canMasterAngler() {
|
||||
return Permissions.masterAngler(getPlayer());
|
||||
return getSkillLevel() >= AdvancedConfig.getInstance().getMasterAnglerUnlockLevel() && Permissions.masterAngler(getPlayer());
|
||||
}
|
||||
|
||||
public boolean unleashTheKraken() {
|
||||
@@ -203,10 +208,7 @@ public class FishingManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(blockBreakEvent);
|
||||
|
||||
return !blockBreakEvent.isCancelled();
|
||||
return EventUtils.simulateBlockBreak(block, player, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,8 +248,9 @@ public class FishingManager extends SkillManager {
|
||||
/**
|
||||
* Handle the Fisherman's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
*
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
|
||||
@@ -269,20 +272,20 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
// Recast in the new spot
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerFishEvent(getPlayer(), null, hook, PlayerFishEvent.State.FISHING));
|
||||
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
||||
}
|
||||
|
||||
public void masterAngler(Fish hook) {
|
||||
Player player = getPlayer();
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
double biteChance = Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0);
|
||||
double biteChance = hook.getBiteChance();
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
biteChance = biteChance * 2.0;
|
||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
}
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||
biteChance = biteChance * 2.0;
|
||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
||||
}
|
||||
|
||||
hook.setBiteChance(biteChance);
|
||||
@@ -294,37 +297,33 @@ public class FishingManager extends SkillManager {
|
||||
* @param fishingCatch The {@link Item} initially caught
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
this.fishingCatch = fishingCatch;
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
|
||||
treasure = getFishingTreasure();
|
||||
this.fishingCatch = null;
|
||||
}
|
||||
|
||||
if (treasure != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.ItemFound"));
|
||||
|
||||
treasureXp = treasure.getXp();
|
||||
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
|
||||
|
||||
McMMOPlayerFishingTreasureEvent event;
|
||||
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||
|
||||
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop)) {
|
||||
enchants = handleMagicHunter(treasureDrop);
|
||||
event = new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
|
||||
}
|
||||
|
||||
McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
treasureDrop = event.getTreasure();
|
||||
treasureXp = event.getXp();
|
||||
}
|
||||
else {
|
||||
event = new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
treasureDrop = event.getTreasure();
|
||||
treasureXp = event.getXp();
|
||||
|
||||
if (event.isCancelled()) {
|
||||
treasureDrop = null;
|
||||
treasureXp = 0;
|
||||
}
|
||||
@@ -339,10 +338,9 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (enchanted) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
|
||||
}
|
||||
|
||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
}
|
||||
}
|
||||
@@ -354,6 +352,7 @@ public class FishingManager extends SkillManager {
|
||||
* Handle the vanilla XP boost for Fishing
|
||||
*
|
||||
* @param experience The amount of experience initially awarded by the event
|
||||
*
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public int handleVanillaXpBoost(int experience) {
|
||||
@@ -439,28 +438,32 @@ public class FishingManager extends SkillManager {
|
||||
* @return The {@link FishingTreasure} found, or null if no treasure was found.
|
||||
*/
|
||||
private FishingTreasure getFishingTreasure() {
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
int skillLevel = getSkillLevel();
|
||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
for (FishingTreasure treasure : TreasureConfig.getInstance().fishingRewards) {
|
||||
int maxLevel = treasure.getMaxLevel();
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
double dropRate = TreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity);
|
||||
|
||||
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
|
||||
rewards.add(treasure);
|
||||
if (diceRoll <= dropRate) {
|
||||
if (rarity == Rarity.TRAP) {
|
||||
handleTraps();
|
||||
break;
|
||||
}
|
||||
|
||||
List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
|
||||
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
|
||||
break;
|
||||
}
|
||||
|
||||
diceRoll -= dropRate;
|
||||
}
|
||||
|
||||
if (rewards.isEmpty()) {
|
||||
if (treasure == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
@@ -470,41 +473,92 @@ public class FishingManager extends SkillManager {
|
||||
return treasure;
|
||||
}
|
||||
|
||||
private void handleTraps() {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (Misc.getRandom().nextBoolean()) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Boom"));
|
||||
|
||||
TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(fishingCatch.getLocation(), EntityType.PRIMED_TNT);
|
||||
fishingCatch.setPassenger(tnt);
|
||||
|
||||
Vector velocity = fishingCatch.getVelocity();
|
||||
double magnitude = velocity.length();
|
||||
fishingCatch.setVelocity(velocity.multiply((magnitude + 1) / magnitude));
|
||||
|
||||
tnt.setMetadata(mcMMO.tntsafeMetadataKey, mcMMO.metadataValue);
|
||||
tnt.setFuseTicks(3 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Poison"));
|
||||
|
||||
ThrownPotion thrownPotion = player.getWorld().spawn(fishingCatch.getLocation(), ThrownPotion.class);
|
||||
thrownPotion.setItem(new Potion(PotionType.POISON).splash().toItemStack(1));
|
||||
|
||||
fishingCatch.setPassenger(thrownPotion);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Magic Hunter ability
|
||||
*
|
||||
* @param treasureDrop The {@link ItemStack} to enchant
|
||||
*
|
||||
* @return true if the item has been enchanted
|
||||
*/
|
||||
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
|
||||
Player player = getPlayer();
|
||||
int activationChance = this.activationChance;
|
||||
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||
List<EnchantmentTreasure> fishingEnchantments = null;
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
activationChance *= Fishing.STORM_MODIFIER;
|
||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
|
||||
|
||||
if (diceRoll <= dropRate) {
|
||||
fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
|
||||
break;
|
||||
}
|
||||
|
||||
diceRoll -= dropRate;
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||
if (fishingEnchantments == null) {
|
||||
return enchants;
|
||||
}
|
||||
|
||||
List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop);
|
||||
List<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
|
||||
List<EnchantmentTreasure> possibleEnchants = new ArrayList<EnchantmentTreasure>();
|
||||
|
||||
for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) {
|
||||
if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) {
|
||||
possibleEnchants.add(enchantmentTreasure);
|
||||
}
|
||||
}
|
||||
|
||||
if (possibleEnchants.isEmpty()) {
|
||||
return enchants;
|
||||
}
|
||||
|
||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||
Collections.shuffle(possibleEnchants, Misc.getRandom());
|
||||
|
||||
int specificChance = 1;
|
||||
|
||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||
for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) {
|
||||
Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment();
|
||||
|
||||
if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enchants.put(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
|
||||
enchants.put(possibleEnchantment, enchantmentTreasure.getLevel());
|
||||
|
||||
specificChance++;
|
||||
specificChance *= 2;
|
||||
}
|
||||
|
||||
return enchants;
|
||||
|
||||
@@ -33,6 +33,7 @@ public class Herbalism {
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
@@ -62,6 +63,7 @@ public class Herbalism {
|
||||
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||
*
|
||||
* @return the number of bonus drops to award from the blocks in this plant
|
||||
*/
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
@@ -92,6 +94,7 @@ public class Herbalism {
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public enum HerbalismBlock {
|
||||
BROWN_MUSHROOM(Material.BROWN_MUSHROOM),
|
||||
CACTUS(Material.CACTUS),
|
||||
CARROT(Material.CARROT, Material.CARROT_ITEM),
|
||||
COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())),
|
||||
CROPS(Material.CROPS, Material.WHEAT),
|
||||
MELON_BLOCK(Material.MELON_BLOCK, Material.MELON),
|
||||
NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK),
|
||||
POTATO(Material.POTATO, Material.POTATO_ITEM),
|
||||
PUMPKIN(Material.PUMPKIN),
|
||||
RED_MUSHROOM(Material.RED_MUSHROOM),
|
||||
RED_ROSE(Material.RED_ROSE),
|
||||
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE),
|
||||
VINE(Material.VINE),
|
||||
WATER_LILY(Material.WATER_LILY),
|
||||
YELLOW_FLOWER(Material.YELLOW_FLOWER);
|
||||
|
||||
private Material blockType;
|
||||
private ItemStack dropItem;
|
||||
|
||||
private final static Map<Material, HerbalismBlock> BY_MATERIAL = Maps.newHashMap();
|
||||
|
||||
private HerbalismBlock(Material blockType) {
|
||||
this(blockType, new ItemStack(blockType));
|
||||
}
|
||||
|
||||
private HerbalismBlock(Material blockType, Material dropType) {
|
||||
this(blockType, new ItemStack(dropType));
|
||||
}
|
||||
|
||||
private HerbalismBlock(Material blockType, ItemStack dropItem) {
|
||||
this.blockType = blockType;
|
||||
this.dropItem = dropItem;
|
||||
}
|
||||
|
||||
static {
|
||||
for (HerbalismBlock herbalismBlock : values()) {
|
||||
BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getDropItem() {
|
||||
return dropItem;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.HERBALISM, blockType);
|
||||
}
|
||||
|
||||
public boolean canDoubleDrop() {
|
||||
return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType);
|
||||
}
|
||||
|
||||
public boolean hasGreenThumbPermission(Player player) {
|
||||
return Permissions.greenThumbPlant(player, blockType);
|
||||
}
|
||||
|
||||
public static HerbalismBlock getHerbalismBlock(Material blockType) {
|
||||
return BY_MATERIAL.get(blockType);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
@@ -17,6 +18,7 @@ import org.bukkit.material.NetherWarts;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@@ -28,6 +30,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -75,8 +78,9 @@ public class HerbalismManager extends SkillManager {
|
||||
/**
|
||||
* Handle the Farmer's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
*
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||
@@ -87,6 +91,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenTerra(BlockState blockState) {
|
||||
@@ -111,11 +116,10 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material material = blockState.getType();
|
||||
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
|
||||
|
||||
@@ -123,21 +127,32 @@ public class HerbalismManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material);
|
||||
ItemStack drop = null;
|
||||
if (!canBlockCheck()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<ItemStack> drops = null;
|
||||
int amount = 1;
|
||||
int xp = 0;
|
||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||
|
||||
if (herbalismBlock != null) {
|
||||
if (herbalismBlock.hasGreenThumbPermission(getPlayer())) {
|
||||
if (ModUtils.isCustomHerbalismBlock(blockState)) {
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && customBlock.isDoubleDropEnabled()) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Permissions.greenThumbPlant(player, material)) {
|
||||
processGreenThumbPlants(blockState, greenTerra);
|
||||
}
|
||||
|
||||
xp = herbalismBlock.getXpGain();
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
||||
|
||||
if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) {
|
||||
drop = herbalismBlock.getDropItem();
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.doubleDrops(player, skill)) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
}
|
||||
|
||||
if (!oneBlockPlant) {
|
||||
@@ -145,27 +160,18 @@ public class HerbalismManager extends SkillManager {
|
||||
xp *= amount;
|
||||
}
|
||||
}
|
||||
else {
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
if (Permissions.doubleDrops(getPlayer(), skill)) {
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
drop = customBlock.getItemDrop();
|
||||
amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount;
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
|
||||
if (drop == null) {
|
||||
if (drops == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||
Misc.dropItems(blockState.getLocation(), drop, amount);
|
||||
for (ItemStack item : drops) {
|
||||
Misc.dropItems(blockState.getLocation(), item, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +180,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Green Thumb ability for blocks.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||
@@ -189,6 +196,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Hylian Luck ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processHylianLuck(BlockState blockState) {
|
||||
@@ -223,14 +231,16 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (treasures.isEmpty()) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (treasures.isEmpty() || EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -238,6 +248,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Shroom Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processShroomThumb(BlockState blockState) {
|
||||
@@ -275,7 +286,28 @@ public class HerbalismManager extends SkillManager {
|
||||
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = (blockState.getType() == Material.CROPS) ? new ItemStack(Material.SEEDS) : HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
||||
ItemStack seed = null;
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case CARROT:
|
||||
seed = new ItemStack(Material.CARROT_ITEM);
|
||||
break;
|
||||
|
||||
case CROPS:
|
||||
seed = new ItemStack(Material.SEEDS);
|
||||
break;
|
||||
|
||||
case NETHER_WARTS:
|
||||
seed = new ItemStack(Material.NETHER_STALK);
|
||||
break;
|
||||
|
||||
case POTATO:
|
||||
seed = new ItemStack(Material.POTATO_ITEM);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
return;
|
||||
|
||||
@@ -7,63 +7,15 @@ import com.gmail.nossr50.config.Config;
|
||||
|
||||
public class BlastMining {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
EIGHT(8) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank8(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank8(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank8(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank8(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank8(); }},
|
||||
SEVEN(7) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank7(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank7(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank7(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank7(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank7(); }},
|
||||
SIX(6) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank6(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank6(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank6(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank6(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank6(); }},
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank5(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank5(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank5(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank5(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank5(); }},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank4(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank4(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank4(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank4(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank4(); }},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank3(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank3(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank3(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank3(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank3(); }},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank2(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank2(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank2(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank2(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank2(); }},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank1(); }
|
||||
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank1(); }
|
||||
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank1(); }
|
||||
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank1(); }
|
||||
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1(); }
|
||||
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank1(); }};
|
||||
public enum Tier {
|
||||
EIGHT(8),
|
||||
SEVEN(7),
|
||||
SIX(6),
|
||||
FIVE(5),
|
||||
FOUR(4),
|
||||
THREE(3),
|
||||
TWO(2),
|
||||
ONE(1);
|
||||
|
||||
int numerical;
|
||||
|
||||
@@ -75,12 +27,29 @@ public class BlastMining {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected double getBlastRadiusModifier();
|
||||
abstract protected double getOreBonus();
|
||||
abstract protected double getDebrisReduction();
|
||||
abstract protected double getBlastDamageDecrease();
|
||||
abstract protected int getDropMultiplier();
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getBlastMiningRankLevel(this);
|
||||
}
|
||||
|
||||
protected double getBlastRadiusModifier() {
|
||||
return AdvancedConfig.getInstance().getBlastRadiusModifier(this);
|
||||
}
|
||||
|
||||
protected double getOreBonus() {
|
||||
return AdvancedConfig.getInstance().getOreBonus(this);
|
||||
}
|
||||
|
||||
protected double getDebrisReduction() {
|
||||
return AdvancedConfig.getInstance().getDebrisReduction(this);
|
||||
}
|
||||
|
||||
protected double getBlastDamageDecrease() {
|
||||
return AdvancedConfig.getInstance().getBlastDamageDecrease(this);
|
||||
}
|
||||
|
||||
protected int getDropMultiplier() {
|
||||
return AdvancedConfig.getInstance().getDropMultiplier(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Material detonator = Config.getInstance().getDetonatorItem();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -8,7 +7,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
@@ -26,11 +24,13 @@ public class Mining {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType);
|
||||
|
||||
if (blockType == Material.GLOWING_REDSTONE_ORE) {
|
||||
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
|
||||
}
|
||||
else if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
|
||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
if (xp == 0) {
|
||||
if (blockType == Material.GLOWING_REDSTONE_ORE) {
|
||||
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
|
||||
}
|
||||
else if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
}
|
||||
|
||||
return xp;
|
||||
@@ -86,10 +86,7 @@ public class Mining {
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
protected static void handleMiningDrops(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
switch (blockType) {
|
||||
switch (blockState.getType()) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case EMERALD_ORE:
|
||||
@@ -102,36 +99,21 @@ public class Mining {
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case OBSIDIAN:
|
||||
case REDSTONE_ORE:
|
||||
case SANDSTONE:
|
||||
case QUARTZ_ORE:
|
||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
||||
Misc.dropItem(location, drop);
|
||||
}
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
return;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
||||
Misc.dropItem(location, drop);
|
||||
}
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
ItemStack dropItem = customBlock.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
}
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -69,7 +71,7 @@ public class MiningManager extends SkillManager {
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
}
|
||||
|
||||
if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
if ((ModUtils.isCustomMiningBlock(blockState) && !ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ public class MiningManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||
|
||||
if (targetBlock.getType() != Material.TNT || !SkillUtils.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) {
|
||||
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -171,6 +173,7 @@ public class MiningManager extends SkillManager {
|
||||
* Increases the blast radius of the explosion.
|
||||
*
|
||||
* @param radius to modify
|
||||
*
|
||||
* @return modified radius
|
||||
*/
|
||||
public float biggerBombs(float radius) {
|
||||
|
||||
@@ -4,23 +4,15 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class ArcaneForging {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); }
|
||||
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); }
|
||||
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); }
|
||||
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); }
|
||||
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); }
|
||||
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); }
|
||||
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); }
|
||||
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); }
|
||||
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }};
|
||||
public enum Tier {
|
||||
EIGHT(8),
|
||||
SEVEN(7),
|
||||
SIX(6),
|
||||
FIVE(5),
|
||||
FOUR(4),
|
||||
THREE(3),
|
||||
TWO(2),
|
||||
ONE(1);
|
||||
|
||||
int numerical;
|
||||
|
||||
@@ -32,9 +24,17 @@ public class ArcaneForging {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected double getKeepEnchantChance();
|
||||
abstract protected double getDowngradeEnchantChance();
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getArcaneForgingRankLevel(this);
|
||||
}
|
||||
|
||||
protected double getKeepEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChance(this);
|
||||
}
|
||||
|
||||
protected double getDowngradeEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChance(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||
|
||||
@@ -127,14 +127,14 @@ public class Repair {
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
@@ -115,10 +116,7 @@ public class RepairManager extends SkillManager {
|
||||
short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?
|
||||
|
||||
// Call event
|
||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -255,8 +253,9 @@ public class RepairManager extends SkillManager {
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
*
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
private short repairCalculate(short durability, int repairAmount) {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class RepairableManagerFactory {
|
||||
public static RepairableManager getRepairManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairableManager();
|
||||
}
|
||||
|
||||
public static RepairableManager getRepairManager(int repairablesSize) {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairableManager(repairablesSize);
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
@@ -33,9 +33,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
for (String key : keys) {
|
||||
if (config.contains("Repairables." + key + ".ItemId")) {
|
||||
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
||||
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
|
||||
plugin.getLogger().warning("Repair will not work properly until you do.");
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum RepairItemType {
|
||||
* Get the base permissions associated with this RepairItemType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
*
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
|
||||
public interface Repairable {
|
||||
/**
|
||||
* Gets the type of this repairable item
|
||||
@@ -40,7 +41,7 @@ public interface Repairable {
|
||||
|
||||
/**
|
||||
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
|
||||
*
|
||||
* <p/>
|
||||
* This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords
|
||||
*
|
||||
* @return the minimum number of items
|
||||
@@ -56,7 +57,7 @@ public interface Repairable {
|
||||
|
||||
/**
|
||||
* Gets the base repair durability on which to calculate bonuses.
|
||||
*
|
||||
* <p/>
|
||||
* This is actually the maximum durability divided by the minimum quantity
|
||||
*
|
||||
* @return the base repair durability
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user