mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
1 Commits
dev-comman
...
reformat-j
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c211874a27 |
@@ -7,11 +7,7 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.08-dev
|
Version 1.4.07-dev
|
||||||
+ Added the possibility to gain experience when using Fishing "Shake"
|
|
||||||
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
|
||||||
|
|
||||||
Version 1.4.07
|
|
||||||
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
+ 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 SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
|
||||||
+ Added more tiers to Fishing, Repair and Smelting!
|
+ Added more tiers to Fishing, Repair and Smelting!
|
||||||
@@ -34,12 +30,6 @@ Version 1.4.07
|
|||||||
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
|
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
|
||||||
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
|
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
|
||||||
+ Added Quartz and Name Tags to the default Excavation treasures
|
+ Added Quartz and Name Tags to the default Excavation treasures
|
||||||
+ Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus
|
|
||||||
+ Added cooldown to commands with heavy database access to prevent denial of service
|
|
||||||
+ Added /mcscoreboard keep, to keep the scoreboard up forever
|
|
||||||
+ Added Rainbow Mode to scoreboards
|
|
||||||
+ Added new /mccooldowns command to show all ability cooldowns
|
|
||||||
+ Commands may now both print text and display a scoreboard
|
|
||||||
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
||||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||||
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||||
@@ -61,8 +51,6 @@ Version 1.4.07
|
|||||||
! Changed format of repair.vanilla.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 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 "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
|
||||||
! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
|
|
||||||
! Changed Hardcore modes, they will also subtract experience
|
|
||||||
! Changed various values to double in advanced.yml for the sake of consistency.
|
! 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 Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
|
||||||
! Nerfed Archery damage to eliminate constant one-hit kills.
|
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||||
@@ -73,7 +61,6 @@ Version 1.4.07
|
|||||||
! Admin and Party chat prefixes are now customizable
|
! Admin and Party chat prefixes are now customizable
|
||||||
! Changed the color of party leader names in Party chat
|
! Changed the color of party leader names in Party chat
|
||||||
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
||||||
! Improved AFK Acrobatics prevention mechanism
|
|
||||||
! Improved profile saving
|
! Improved profile saving
|
||||||
! Improved partial name matcher
|
! Improved partial name matcher
|
||||||
! Improved update checker
|
! Improved update checker
|
||||||
@@ -81,8 +68,6 @@ Version 1.4.07
|
|||||||
! Party item share category states are now saved when the server shuts down.
|
! Party item share category states are now saved when the server shuts down.
|
||||||
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
|
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
|
||||||
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
|
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
|
||||||
! Massively improved scoreboard handling
|
|
||||||
! Reworked scoreboard configuration (config.yml) - **you will need to update**
|
|
||||||
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
- 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 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 Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
## The RPG lovers mod
|
## The RPG lovers mod
|
||||||
|
|
||||||
### Dev builds
|
### Dev builds
|
||||||
Our latest development builds are available ~~[here](http://ci.mcmmo.info)~~. Unfortunately, the mcMMO site is down; a temporary dev build location is hosted [here](http://ci.ecocitycraft.com/job/mcMMO/).
|
Our latest development builds are available [here](http://ci.mcmmo.info).
|
||||||
|
|
||||||
### Brief Description
|
### Brief Description
|
||||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||||
@@ -29,8 +29,6 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
|||||||
(https://github.com/TfT-02)
|
(https://github.com/TfT-02)
|
||||||
[]
|
[]
|
||||||
(https://github.com/t00thpick1)
|
(https://github.com/t00thpick1)
|
||||||
[]
|
|
||||||
(https://github.com/riking)
|
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.08-dev1</version>
|
<version>1.4.07-dev2</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>Jenkins</system>
|
<system>Jenkins</system>
|
||||||
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
|
<url>ci.mcmmo.org</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ public final class ChatAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param plugin The plugin sending the message
|
||||||
* @param sender The name of the sender
|
* @param sender The name of the sender
|
||||||
* @param displayName The display name of the sender
|
* @param displayName The display name of the sender
|
||||||
* @param party The name of the party to send to
|
* @param party The name of the party to send to
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||||
@@ -33,9 +33,9 @@ public final class ChatAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param plugin The plugin sending the message
|
||||||
* @param sender The name of the sender to display in the chat
|
* @param sender The name of the sender to display in the chat
|
||||||
* @param party The name of the party to send to
|
* @param party The name of the party to send to
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||||
@@ -47,10 +47,10 @@ public final class ChatAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param plugin The plugin sending the message
|
||||||
* @param sender The name of the sender
|
* @param sender The name of the sender
|
||||||
* @param displayName The display 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) {
|
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
||||||
@@ -61,8 +61,8 @@ public final class ChatAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param plugin The plugin sending the message
|
||||||
* @param sender The name of the sender to display in the chat
|
* @param sender The name of the sender to display in the chat
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
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.
|
* Check if a player is currently talking in party chat.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return true if the player is using party chat, false otherwise
|
* @return true if the player is using party chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingPartyChat(Player player) {
|
public static boolean isUsingPartyChat(Player player) {
|
||||||
@@ -83,6 +84,7 @@ public final class ChatAPI {
|
|||||||
* Check if a player is currently talking in party chat.
|
* Check if a player is currently talking in party chat.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
|
*
|
||||||
* @return true if the player is using party chat, false otherwise
|
* @return true if the player is using party chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingPartyChat(String playerName) {
|
public static boolean isUsingPartyChat(String playerName) {
|
||||||
@@ -93,6 +95,7 @@ public final class ChatAPI {
|
|||||||
* Check if a player is currently talking in admin chat.
|
* Check if a player is currently talking in admin chat.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is using admin chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingAdminChat(Player player) {
|
public static boolean isUsingAdminChat(Player player) {
|
||||||
@@ -103,6 +106,7 @@ public final class ChatAPI {
|
|||||||
* Check if a player is currently talking in admin chat.
|
* Check if a player is currently talking in admin chat.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
|
*
|
||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is using admin chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingAdminChat(String playerName) {
|
public static boolean isUsingAdminChat(String playerName) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param skillType A string that may or may not be a skill
|
* @param skillType A string that may or may not be a skill
|
||||||
|
*
|
||||||
* @return true if this is a valid mcMMO skill
|
* @return true if this is a valid mcMMO skill
|
||||||
*/
|
*/
|
||||||
public static boolean isValidSkillType(String skillType) {
|
public static boolean isValidSkillType(String skillType) {
|
||||||
@@ -38,12 +39,15 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param skillType the skill to check
|
* @param skillType the skill to check
|
||||||
|
*
|
||||||
* @return true if this is a valid, non-child mcMMO skill
|
* @return true if this is a valid, non-child mcMMO skill
|
||||||
*/
|
*/
|
||||||
public static boolean isNonChildSkill(String skillType) {
|
public static boolean isNonChildSkill(String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
|
|
||||||
if (skill == null) return false;
|
if (skill == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return !skill.isChildSkill();
|
return !skill.isChildSkill();
|
||||||
}
|
}
|
||||||
@@ -58,9 +62,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
@@ -79,10 +83,10 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to add XP to
|
* @param playerName The player to add XP to
|
||||||
* @param skillType The skill to add XP to
|
* @param skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||||
@@ -94,9 +98,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
@@ -110,10 +114,10 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to add XP to
|
* @param playerName The player to add XP to
|
||||||
* @param skillType The skill to add XP to
|
* @param skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||||
@@ -125,9 +129,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
@@ -143,10 +147,10 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to add XP to
|
* @param playerName The player to add XP to
|
||||||
* @param skillType The skill to add XP to
|
* @param skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||||
@@ -161,9 +165,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
@@ -176,11 +180,12 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXP(Player player, String skillType) {
|
public static int getXP(Player player, String skillType) {
|
||||||
@@ -193,11 +198,12 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get XP for
|
* @param playerName The player to get XP for
|
||||||
* @param skillType The skill to get XP for
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXP(String playerName, String skillType) {
|
public static int getOfflineXP(String playerName, String skillType) {
|
||||||
@@ -209,11 +215,12 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static float getXPRaw(Player player, String skillType) {
|
public static float getXPRaw(Player player, String skillType) {
|
||||||
@@ -226,11 +233,12 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get XP for
|
* @param playerName The player to get XP for
|
||||||
* @param skillType The skill to get XP for
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||||
@@ -242,11 +250,12 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param skillType The skill to get the XP amount for
|
||||||
|
*
|
||||||
* @return the total amount of XP needed to reach the next level
|
* @return the total amount of XP needed to reach the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXPToNextLevel(Player player, String skillType) {
|
public static int getXPToNextLevel(Player player, String skillType) {
|
||||||
@@ -259,11 +268,12 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get XP for
|
* @param playerName The player to get XP for
|
||||||
* @param skillType The skill to get XP for
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the total amount of XP needed to reach the next level
|
* @return the total amount of XP needed to reach the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||||
@@ -275,11 +285,12 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param skillType The skill to get the XP amount for
|
||||||
|
*
|
||||||
* @return the amount of XP remaining until the next level
|
* @return the amount of XP remaining until the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXPRemaining(Player player, String skillType) {
|
public static int getXPRemaining(Player player, String skillType) {
|
||||||
@@ -296,11 +307,12 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get XP for
|
* @param playerName The player to get XP for
|
||||||
* @param skillType The skill to get XP for
|
* @param skillType The skill to get XP for
|
||||||
|
*
|
||||||
* @return the amount of XP needed to reach the next level
|
* @return the amount of XP needed to reach the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||||
@@ -316,9 +328,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType Type of skill to add levels to
|
||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
@@ -332,10 +344,10 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to add levels to
|
* @param playerName The player to add levels to
|
||||||
* @param skillType Type of skill to add levels to
|
* @param skillType Type of skill to add levels to
|
||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||||
@@ -362,8 +374,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param skillType The skill to get the level for
|
||||||
|
*
|
||||||
* @return the level of a given skill
|
* @return the level of a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
@@ -378,10 +391,11 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get the level for
|
* @param playerName The player to get the level for
|
||||||
* @param skillType The skill to get the level for
|
* @param skillType The skill to get the level for
|
||||||
|
*
|
||||||
* @return the level of a given skill
|
* @return the level of a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static int getLevelOffline(String playerName, String skillType) {
|
public static int getLevelOffline(String playerName, String skillType) {
|
||||||
@@ -394,6 +408,7 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to get the power level for
|
* @param player The player to get the power level for
|
||||||
|
*
|
||||||
* @return the power level of the player
|
* @return the power level of the player
|
||||||
*/
|
*/
|
||||||
public static int getPowerLevel(Player player) {
|
public static int getPowerLevel(Player player) {
|
||||||
@@ -406,6 +421,7 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to get the power level for
|
* @param playerName The player to get the power level for
|
||||||
|
*
|
||||||
* @return the power level of the player
|
* @return the power level of the player
|
||||||
*
|
*
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
@@ -427,6 +443,7 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param skillType The skill to get the level cap for
|
* @param skillType The skill to get the level cap for
|
||||||
|
*
|
||||||
* @return the level cap of a given skill
|
* @return the level cap of a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
@@ -452,16 +469,16 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
* @param skillType The skill 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
|
|
||||||
*
|
*
|
||||||
* @return the position on the leaderboard
|
* @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) {
|
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -472,12 +489,12 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
*
|
*
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
|
||||||
*
|
|
||||||
* @return the position on the power level leaderboard
|
* @return the position on the power level leaderboard
|
||||||
|
*
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static int getPlayerRankOverall(String playerName) {
|
public static int getPlayerRankOverall(String playerName) {
|
||||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -485,8 +502,8 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to set the level of
|
* @param player The player to set the level of
|
||||||
* @param skillType The skill to set the level for
|
* @param skillType The skill to set the level for
|
||||||
* @param skillLevel The value to set the level to
|
* @param skillLevel The value to set the level to
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
@@ -501,10 +518,10 @@ public final class ExperienceAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to set the level of
|
* @param playerName The player to set the level of
|
||||||
* @param skillType The skill to set the level for
|
* @param skillType The skill to set the level for
|
||||||
* @param skillLevel The value to set the level to
|
* @param skillLevel The value to set the level to
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||||
@@ -516,11 +533,11 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to set the XP for
|
||||||
* @param newValue The value to set the XP to
|
* @param newValue The value to set the XP to
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXP(Player player, String skillType, int newValue) {
|
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.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to set the XP of
|
* @param playerName The player to set the XP of
|
||||||
* @param skillType The skill to set the XP for
|
* @param skillType The skill to set the XP for
|
||||||
* @param newValue The value to set the XP to
|
* @param newValue The value to set the XP to
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||||
@@ -549,11 +566,11 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType The skill to change the XP for
|
||||||
* @param xp The amount of XP to remove
|
* @param xp The amount of XP to remove
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void removeXP(Player player, String skillType, int xp) {
|
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.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param playerName The player to change the XP of
|
* @param playerName The player to change the XP of
|
||||||
* @param skillType The skill to change the XP for
|
* @param skillType The skill to change the XP for
|
||||||
* @param xp The amount of XP to remove
|
* @param xp The amount of XP to remove
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
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.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to check the party name of
|
* @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
|
* @return the name of the player's party, or null if not in a party
|
||||||
*/
|
*/
|
||||||
public static String getPartyName(Player player) {
|
public static String getPartyName(Player player) {
|
||||||
@@ -37,6 +38,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return true if the player is in a party, false otherwise
|
* @return true if the player is in a party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inParty(Player player) {
|
public static boolean inParty(Player player) {
|
||||||
@@ -50,6 +52,7 @@ public final class PartyAPI {
|
|||||||
*
|
*
|
||||||
* @param playera The first player to check
|
* @param playera The first player to check
|
||||||
* @param playerb The second player to check
|
* @param playerb The second player to check
|
||||||
|
*
|
||||||
* @return true if the two players are in the same party, false otherwise
|
* @return true if the two players are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player playera, Player playerb) {
|
public static boolean inSameParty(Player playera, Player playerb) {
|
||||||
@@ -72,7 +75,7 @@ public final class PartyAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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
|
* @param partyName The party to add the player to
|
||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
@@ -102,6 +105,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
|
*
|
||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public static String getPartyLeader(String partyName) {
|
public static String getPartyLeader(String partyName) {
|
||||||
@@ -114,7 +118,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param partyName The name of the party to set the leader of
|
* @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) {
|
public static void setPartyLeader(String partyName, String player) {
|
||||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||||
@@ -126,6 +130,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -145,6 +150,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return all the player names in the player's party
|
* @return all the player names in the player's party
|
||||||
*/
|
*/
|
||||||
public static LinkedHashSet<String> getMembers(Player player) {
|
public static LinkedHashSet<String> getMembers(Player player) {
|
||||||
@@ -157,6 +163,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param partyName The party to check
|
* @param partyName The party to check
|
||||||
|
*
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(String partyName) {
|
public static List<Player> getOnlineMembers(String partyName) {
|
||||||
@@ -169,6 +176,7 @@ public final class PartyAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return all online players in the player's party
|
* @return all online players in the player's party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(Player player) {
|
public static List<Player> getOnlineMembers(Player player) {
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class KrakenCommand implements TabExecutor {
|
public class KrakenCommand implements TabExecutor {
|
||||||
@@ -40,10 +41,10 @@ public class KrakenCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0], true);
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,25 @@ package com.gmail.nossr50.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
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.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McscoreboardCommand implements TabExecutor {
|
public class McscoreboardCommand implements TabExecutor {
|
||||||
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
|
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@@ -22,49 +28,94 @@ public class McscoreboardCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
clearScoreboard(player);
|
||||||
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
if (args[0].equalsIgnoreCase("clear")) {
|
||||||
ScoreboardManager.clearBoard(sender.getName());
|
clearScoreboard(player);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("rank")) {
|
||||||
if (args[0].equalsIgnoreCase("keep")) {
|
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||||
if (!Config.getInstance().getAllowKeepBoard()) {
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ScoreboardManager.isBoardShown(sender.getName())) {
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
|
ScoreboardManager.enablePlayerRankScoreboard(player);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("stats")) {
|
||||||
|
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreboardManager.keepBoard(sender.getName());
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
||||||
return true;
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("top")) {
|
||||||
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return help(sender);
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
|
if (!args[0].equalsIgnoreCase("top")) {
|
||||||
if (CommandUtils.isInvalidInteger(sender, args[1])) {
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int time = Math.abs(Integer.parseInt(args[1]));
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
ScoreboardManager.setRevertTimer(sender.getName(), time);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return help(sender);
|
if (StringUtils.isInt(args[1])) {
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (!args[0].equalsIgnoreCase("top")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidInteger(sender, args[2])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return help(sender);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,17 +123,20 @@ public class McscoreboardCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
|
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size()));
|
||||||
|
case 2:
|
||||||
|
if (args[0].equalsIgnoreCase("top")) {
|
||||||
|
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||||
|
}
|
||||||
|
// Fallthrough
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean help(CommandSender sender) {
|
private void clearScoreboard(Player player) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
|
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
|
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MobhealthCommand implements TabExecutor {
|
public class MobhealthCommand implements TabExecutor {
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public abstract class ToggleCommand implements TabExecutor {
|
public abstract class ToggleCommand implements TabExecutor {
|
||||||
@@ -45,15 +46,19 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer = UserManager.getPlayer(args[0], true);
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = mcMMOPlayer.getPlayer();
|
player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (CommandUtils.isOffline(sender, player)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
applyCommandAction();
|
applyCommandAction();
|
||||||
sendSuccessMessage(sender);
|
sendSuccessMessage(sender);
|
||||||
return true;
|
return true;
|
||||||
@@ -75,7 +80,10 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||||
|
|
||||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||||
|
|
||||||
protected abstract void applyCommandAction();
|
protected abstract void applyCommandAction();
|
||||||
|
|
||||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,9 +108,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||||
|
|
||||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||||
|
|
||||||
protected abstract void handleCommand(SkillType skill);
|
protected abstract void handleCommand(SkillType skill);
|
||||||
|
|
||||||
protected abstract void handlePlayerMessageAll();
|
protected abstract void handlePlayerMessageAll();
|
||||||
|
|
||||||
protected abstract void handlePlayerMessageSkill();
|
protected abstract void handlePlayerMessageSkill();
|
||||||
|
|
||||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||||
@@ -148,7 +152,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,10 +129,15 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean checkTogglePermissions();
|
protected abstract boolean checkTogglePermissions();
|
||||||
|
|
||||||
protected abstract boolean checkModifyPermissions();
|
protected abstract boolean checkModifyPermissions();
|
||||||
|
|
||||||
protected abstract boolean checkEnabled(String skill);
|
protected abstract boolean checkEnabled(String skill);
|
||||||
|
|
||||||
protected abstract void enable(String skill);
|
protected abstract void enable(String skill);
|
||||||
|
|
||||||
protected abstract void disable(String skill);
|
protected abstract void disable(String skill);
|
||||||
|
|
||||||
protected abstract void modify();
|
protected abstract void modify();
|
||||||
|
|
||||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||||
|
|||||||
@@ -9,23 +9,34 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInviteCommand implements CommandExecutor {
|
public class PartyInviteCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
|
String targetName = Misc.getMatchedPlayerName(args[1]);
|
||||||
|
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
||||||
|
|
||||||
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = mcMMOTarget.getPlayer();
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
if (playerName.equalsIgnoreCase(args[1])) {
|
if (player.equals(target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PartyManager.inSameParty(player, target)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,20 +45,6 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1], true);
|
|
||||||
|
|
||||||
if (mcMMOTarget == null) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player target = mcMMOTarget.getPlayer();
|
|
||||||
|
|
||||||
if (PartyManager.inSameParty(player, target)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Party playerParty = mcMMOPlayer.getParty();
|
Party playerParty = mcMMOPlayer.getParty();
|
||||||
mcMMOTarget.setPartyInvite(playerParty);
|
mcMMOTarget.setPartyInvite(playerParty);
|
||||||
|
|
||||||
|
|||||||
@@ -9,26 +9,31 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
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.player.UserManager;
|
||||||
|
|
||||||
public class PartyJoinCommand implements CommandExecutor {
|
public class PartyJoinCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOTarget;
|
||||||
|
private Player target;
|
||||||
|
private Party targetParty;
|
||||||
|
|
||||||
private McMMOPlayer mcMMOPlayer;
|
private McMMOPlayer mcMMOPlayer;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Party targetParty;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
player = (Player) sender;
|
|
||||||
mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
// Verify target exists and is in a different party than the player
|
// Verify target exists and is in a different party than the player
|
||||||
if (!canJoinParty(sender, args[1])) {
|
if (!canJoinParty(sender, args[1])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
String password = getPassword(args);
|
String password = getPassword(args);
|
||||||
|
|
||||||
// Make sure party passwords match
|
// Make sure party passwords match
|
||||||
@@ -62,21 +67,25 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canJoinParty(CommandSender sender, String targetName) {
|
private boolean canJoinParty(CommandSender sender, String targetName) {
|
||||||
// Short-circuit for joining your own party
|
targetName = Misc.getMatchedPlayerName(targetName);
|
||||||
if (sender.getName().equalsIgnoreCase(targetName)) {
|
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
|
||||||
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetParty = PartyManager.getPlayerParty(targetName);
|
target = mcMMOTarget.getPlayer();
|
||||||
|
|
||||||
if (targetParty == null) {
|
if (!mcMMOTarget.inParty()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't join your own party
|
player = (Player) sender;
|
||||||
if (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty)) {
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
targetParty = mcMMOTarget.getParty();
|
||||||
|
|
||||||
|
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
|||||||
Player target = mcMMOPlayer.getPtpRequest();
|
Player target = mcMMOPlayer.getPtpRequest();
|
||||||
mcMMOPlayer.removePtpRequest();
|
mcMMOPlayer.removePtpRequest();
|
||||||
|
|
||||||
if (!PtpCommand.canTeleport(player, target.getName())) {
|
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTeleportRequest(player, Misc.getMatchedPlayerName(args[0]));
|
sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -113,8 +113,8 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTeleportRequest(Player player, String targetName) {
|
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
||||||
if (!canTeleport(player, targetName)) {
|
if (!canTeleport(sender, player, targetName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,21 +132,20 @@ public class PtpCommand implements TabExecutor {
|
|||||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
|
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean canTeleport(Player player, String targetName) {
|
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
|
||||||
target = mcMMO.p.getServer().getPlayerExact(targetName);
|
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||||
|
|
||||||
if (target == null) {
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target = mcMMOTarget.getPlayer();
|
||||||
|
|
||||||
if (player.equals(target)) {
|
if (player.equals(target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOTarget = UserManager.getPlayer(target);
|
|
||||||
|
|
||||||
if (!PartyManager.inSameParty(player, target)) {
|
if (!PartyManager.inSameParty(player, target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public class InspectCommand implements TabExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
@@ -40,12 +44,9 @@ public class InspectCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
||||||
|
return true;
|
||||||
if (!Config.getInstance().getInspectUseChat()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||||
@@ -79,12 +80,9 @@ public class InspectCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
|
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
||||||
|
return true;
|
||||||
if (!Config.getInstance().getInspectUseChat()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabExecutor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public class MccooldownCommand implements TabExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (Config.getInstance().getCooldownUseBoard()) {
|
|
||||||
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
|
||||||
|
|
||||||
if (!Config.getInstance().getCooldownUseChat()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
|
||||||
|
|
||||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
|
||||||
if (!ability.getPermissions(player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
|
|
||||||
|
|
||||||
if (seconds <= 0) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,12 +13,13 @@ import org.bukkit.util.StringUtil;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McrankCommand implements TabExecutor {
|
public class McrankCommand implements TabExecutor {
|
||||||
@@ -35,7 +36,13 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(sender, sender.getName());
|
if (Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||||
|
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
display(sender, sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -49,10 +56,9 @@ public class McrankCommand implements TabExecutor {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
playerName = mcMMOPlayer.getPlayer().getName();
|
||||||
playerName = player.getName();
|
|
||||||
|
|
||||||
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
|
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +66,13 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(sender, playerName);
|
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||||
|
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
display(sender, playerName);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -80,20 +92,6 @@ public class McrankCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void display(CommandSender sender, String playerName) {
|
private void display(CommandSender sender, String playerName) {
|
||||||
if (sender instanceof Player) {
|
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
|
||||||
|
|
||||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.actualizeDatabaseATS();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
|
|
||||||
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
|
|
||||||
|
|
||||||
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -25,29 +26,28 @@ public class McstatsCommand implements TabExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
if (Config.getInstance().getStatsUseBoard()) {
|
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
|
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
|
||||||
if (!Config.getInstance().getStatsUseChat()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
|
||||||
|
|
||||||
CommandUtils.printGatheringSkills(player);
|
|
||||||
CommandUtils.printCombatSkills(player);
|
|
||||||
CommandUtils.printMiscSkills(player);
|
|
||||||
|
|
||||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
|
||||||
|
|
||||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||||
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||||
|
|
||||||
|
CommandUtils.printGatheringSkills(player);
|
||||||
|
CommandUtils.printCombatSkills(player);
|
||||||
|
CommandUtils.printMiscSkills(player);
|
||||||
|
|
||||||
|
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||||
|
|
||||||
|
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,40 +11,36 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MctopCommand implements TabExecutor {
|
public class MctopCommand implements TabExecutor {
|
||||||
|
private SkillType skill;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
SkillType skill = null;
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
display(1, skill, sender, command);
|
display(1, "ALL", sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (StringUtils.isInt(args[0])) {
|
if (StringUtils.isInt(args[0])) {
|
||||||
display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
|
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = extractSkill(sender, args[0]);
|
if (!extractSkill(sender, args[0])) {
|
||||||
|
|
||||||
if (skill == null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(1, skill, sender, command);
|
display(1, skill.toString(), sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -52,13 +48,11 @@ public class MctopCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = extractSkill(sender, args[0]);
|
if (!extractSkill(sender, args[0])) {
|
||||||
|
|
||||||
if (skill == null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
|
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -76,44 +70,35 @@ public class MctopCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(int page, SkillType skill, CommandSender sender, Command command) {
|
private void display(int page, String skill, CommandSender sender, Command command) {
|
||||||
if (skill != null && !Permissions.mctop(sender, skill)) {
|
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
|
||||||
|
}
|
||||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
display(page, skill, sender);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.actualizeDatabaseATS();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display(page, skill, sender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(int page, SkillType skill, CommandSender sender) {
|
private void display(int page, String query, CommandSender sender) {
|
||||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
|
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||||
boolean useChat = useBoard ? Config.getInstance().getTopUseChat() : true;
|
|
||||||
|
|
||||||
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SkillType extractSkill(CommandSender sender, String skillName) {
|
private boolean extractSkill(CommandSender sender, String skillName) {
|
||||||
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillType skill = SkillType.getSkill(skillName);
|
skill = SkillType.getSkill(skillName);
|
||||||
|
|
||||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return skill;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@@ -84,9 +83,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||||
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation();
|
Biome biome = player.getLocation().getBlock().getBiome();
|
||||||
|
|
||||||
Biome biome = location.getBlock().getBiome();
|
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
|
|
||||||
public SkillCommand(SkillType skill) {
|
public SkillCommand(SkillType skill) {
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
skillName = skill.getName();
|
skillName = skill.getSkillName();
|
||||||
skillGuideCommand = new SkillGuideCommand(skill);
|
skillGuideCommand = new SkillGuideCommand(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,14 +69,17 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
permissionsCheck();
|
permissionsCheck();
|
||||||
dataCalculations();
|
dataCalculations();
|
||||||
|
|
||||||
if (Config.getInstance().getSkillUseBoard()) {
|
|
||||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!skill.isChildSkill()) {
|
if (!skill.isChildSkill()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
|
||||||
|
if (Config.getInstance().getSkillScoreboardEnabled()) {
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
|
ScoreboardManager.enablePlayerSkillScoreboard(mcMMOPlayer, skill);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||||
@@ -87,7 +90,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||||
|
|
||||||
for (SkillType parent : parents) {
|
for (SkillType parent : parents) {
|
||||||
player.sendMessage(parent.getName() + " - " + 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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +150,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
length = Math.min(length, maxLength);
|
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() {
|
protected void luckyEffectsDisplay() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
|||||||
private String invalidPage;
|
private String invalidPage;
|
||||||
|
|
||||||
public SkillGuideCommand(SkillType skillType) {
|
public SkillGuideCommand(SkillType skillType) {
|
||||||
header = LocaleLoader.getString("Guides.Header", skillType.getName());
|
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
|
||||||
guide = getGuide(skillType);
|
guide = getGuide(skillType);
|
||||||
|
|
||||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||||
|
|||||||
@@ -786,15 +786,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* KRAKEN STUFF */
|
/* KRAKEN STUFF */
|
||||||
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
|
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
|
||||||
|
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
|
||||||
|
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
|
||||||
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
|
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
|
||||||
public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
|
public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
|
||||||
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
|
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
|
||||||
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
|
|
||||||
public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
|
|
||||||
public boolean getKrakenGlobalEffectsEnabled() { return config.getBoolean("Kraken.Global_Effects", false); }
|
|
||||||
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
|
|
||||||
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", ""); }
|
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", ""); }
|
||||||
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
|
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
|
||||||
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
|
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
|
||||||
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
|
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
|
||||||
|
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
|
||||||
|
public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,44 +45,24 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Scoreboards */
|
/* Scoreboards */
|
||||||
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
|
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
|
||||||
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
|
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
|
if (getMcstatsScoreboardTime() != -1 && getMcstatsScoreboardTime() <= 0) {
|
||||||
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
|
reason.add("Scoreboards.Mcstats.Display_Time should be greater than 0 or -1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
|
if (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
|
||||||
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
|
reason.add("Scoreboards.Mctop.Display_Time should be greater than 0 or -1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
|
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
|
||||||
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
|
reason.add("Scoreboards.Inspect.Display_Time should be greater than 0 or -1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
|
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||||
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
|
||||||
}
|
|
||||||
|
|
||||||
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
|
|
||||||
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(getRankUseChat() || getRankUseBoard())) {
|
|
||||||
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(getTopUseChat() || getTopUseBoard())) {
|
|
||||||
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(getStatsUseChat() || getStatsUseBoard())) {
|
|
||||||
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(getInspectUseChat() || getInspectUseBoard())) {
|
|
||||||
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Database Purging */
|
/* Database Purging */
|
||||||
@@ -232,35 +212,22 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||||
|
|
||||||
/* Scoreboards */
|
/* Scoreboards */
|
||||||
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
|
||||||
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
||||||
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
|
||||||
|
|
||||||
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
|
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
||||||
public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
|
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
||||||
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
|
|
||||||
|
|
||||||
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
|
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
||||||
public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
|
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
||||||
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
|
|
||||||
|
|
||||||
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
|
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
|
||||||
public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
|
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
|
||||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
|
|
||||||
|
|
||||||
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
|
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||||
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
|
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||||
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
|
|
||||||
|
|
||||||
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
|
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
||||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
|
|
||||||
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
|
|
||||||
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
|
|
||||||
|
|
||||||
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
|
||||||
|
|
||||||
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
|
||||||
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
|
||||||
|
|
||||||
/* Database Purging */
|
/* Database Purging */
|
||||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||||
@@ -303,7 +270,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* SMP Mods */
|
/* SMP Mods */
|
||||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
|
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||||
|
|
||||||
@@ -422,9 +389,8 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||||
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
|
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||||
public boolean getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
|
||||||
|
|
||||||
/* Level Caps */
|
/* Level Caps */
|
||||||
public int getPowerLevelCap() {
|
public int getPowerLevelCap() {
|
||||||
|
|||||||
@@ -29,13 +29,7 @@ public abstract class ConfigLoader {
|
|||||||
protected void loadFile() {
|
protected void loadFile() {
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||||
|
plugin.saveResource(configFile.getPath(), false);
|
||||||
try {
|
|
||||||
plugin.saveResource(fileName, false); // Normal files
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||||
|
|||||||
@@ -102,10 +102,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
reason.add("Experience.Fishing.Base should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getFishingShakeXP() <= 0) {
|
|
||||||
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Repair */
|
/* Repair */
|
||||||
if (getRepairXPBase() <= 0) {
|
if (getRepairXPBase() <= 0) {
|
||||||
reason.add("Experience.Repair.Base should be greater than 0!");
|
reason.add("Experience.Repair.Base should be greater than 0!");
|
||||||
@@ -201,7 +197,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||||
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
|
||||||
|
|
||||||
/* Repair */
|
/* Repair */
|
||||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||||
|
|||||||
@@ -52,10 +52,12 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadArmor("Boots", customBoots);
|
while (!needsUpdate) {
|
||||||
loadArmor("Chestplates", customChestplates);
|
loadArmor("Boots", customBoots);
|
||||||
loadArmor("Helmets", customHelmets);
|
loadArmor("Chestplates", customChestplates);
|
||||||
loadArmor("Leggings", customLeggings);
|
loadArmor("Helmets", customHelmets);
|
||||||
|
loadArmor("Leggings", customLeggings);
|
||||||
|
}
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
@@ -64,10 +66,6 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadArmor(String armorType, List<Material> materialList) {
|
private void loadArmor(String armorType, List<Material> materialList) {
|
||||||
if (needsUpdate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||||
|
|
||||||
if (armorSection == null) {
|
if (armorSection == null) {
|
||||||
@@ -85,7 +83,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
Material armorMaterial = Material.matchMaterial(armorName);
|
Material armorMaterial = Material.matchMaterial(armorName);
|
||||||
|
|
||||||
if (armorMaterial == null) {
|
if (armorMaterial == null) {
|
||||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
|
plugin.getLogger().warning("Invalid material name. This item will be skipped.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +91,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
||||||
|
|
||||||
if (repairMaterial == null) {
|
if (repairMaterial == null) {
|
||||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
|
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||||
repairable = false;
|
repairable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
loadBlocks("Excavation", customExcavationBlocks);
|
while (!needsUpdate) {
|
||||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
loadBlocks("Excavation", customExcavationBlocks);
|
||||||
loadBlocks("Mining", customMiningBlocks);
|
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
loadBlocks("Mining", customMiningBlocks);
|
||||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||||
|
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
@@ -56,10 +58,6 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||||
if (needsUpdate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||||
|
|
||||||
if (skillSection == null) {
|
if (skillSection == null) {
|
||||||
|
|||||||
@@ -58,12 +58,14 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadTool("Axes", customAxes);
|
while (!needsUpdate) {
|
||||||
loadTool("Bows", customBows);
|
loadTool("Axes", customAxes);
|
||||||
loadTool("Hoes", customHoes);
|
loadTool("Bows", customBows);
|
||||||
loadTool("Pickaxes", customPickaxes);
|
loadTool("Hoes", customHoes);
|
||||||
loadTool("Shovels", customShovels);
|
loadTool("Pickaxes", customPickaxes);
|
||||||
loadTool("Swords", customSwords);
|
loadTool("Shovels", customShovels);
|
||||||
|
loadTool("Swords", customSwords);
|
||||||
|
}
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
@@ -72,10 +74,6 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadTool(String toolType, List<Material> materialList) {
|
private void loadTool(String toolType, List<Material> materialList) {
|
||||||
if (needsUpdate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||||
|
|
||||||
if (toolSection == null) {
|
if (toolSection == null) {
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
|
|
||||||
public interface DatabaseManager {
|
public interface DatabaseManager {
|
||||||
// One month in milliseconds
|
// One month in milliseconds
|
||||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||||
// During convertUsers, how often to output a status
|
|
||||||
public final int progressInterval = 200;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge users with 0 power level from the database.
|
* Purge users with 0 power level from the database.
|
||||||
@@ -29,6 +26,7 @@ public interface DatabaseManager {
|
|||||||
* Remove a user from the database.
|
* Remove a user from the database.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the user to remove
|
* @param playerName The name of the user to remove
|
||||||
|
*
|
||||||
* @return true if the user was successfully removed, false otherwise
|
* @return true if the user was successfully removed, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean removeUser(String playerName);
|
public boolean removeUser(String playerName);
|
||||||
@@ -37,30 +35,30 @@ public interface DatabaseManager {
|
|||||||
* Save a user to the database.
|
* Save a user to the database.
|
||||||
*
|
*
|
||||||
* @param profile The profile of the player to save
|
* @param profile The profile of the player to save
|
||||||
|
*
|
||||||
* @return true if successful, false on failure
|
* @return true if successful, false on failure
|
||||||
*/
|
*/
|
||||||
public boolean saveUser(PlayerProfile profile);
|
public boolean saveUser(PlayerProfile profile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve leaderboard info.
|
* Retrieve leaderboard info.
|
||||||
*
|
*
|
||||||
* @param skillName The skill to retrieve info on
|
* @param skillName The skill to retrieve info on
|
||||||
* @param pageNumber Which page in the leaderboards to retrieve
|
* @param pageNumber Which page in the leaderboards to retrieve
|
||||||
* @param statsPerPage The number of stats per page
|
* @param statsPerPage The number of stats per page
|
||||||
* @return the requested leaderboard information
|
*
|
||||||
*/
|
* @return the requested leaderboard information
|
||||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage);
|
*/
|
||||||
|
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve rank info into a HashMap from SkillType to the rank.
|
* Retrieve rank info.
|
||||||
* <p>
|
|
||||||
* The special value <code>null</code> is used to represent the Power
|
|
||||||
* Level rank (the combination of all skill levels).
|
|
||||||
*
|
*
|
||||||
* @param playerName The name of the user to retrieve the rankings for
|
* @param playerName The name of the user to retrieve the rankings for
|
||||||
|
*
|
||||||
* @return the requested rank information
|
* @return the requested rank information
|
||||||
*/
|
*/
|
||||||
public Map<SkillType, Integer> readRank(String playerName);
|
public Map<String, Integer> readRank(String playerName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new user to the database.
|
* Add a new user to the database.
|
||||||
@@ -73,10 +71,11 @@ public interface DatabaseManager {
|
|||||||
* Load a player from the database.
|
* Load a player from the database.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to load from the database
|
* @param playerName The name of the player to load from the database
|
||||||
* @param createNew Whether to create a new record if the player is not
|
* @param createNew Whether to create a new record if the player is not
|
||||||
* found
|
* found
|
||||||
|
*
|
||||||
* @return The player's data, or an unloaded PlayerProfile if not found
|
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||||
* and createNew is false
|
* and createNew is false
|
||||||
*/
|
*/
|
||||||
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
||||||
|
|
||||||
|
|||||||
@@ -285,24 +285,24 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
|
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName));
|
||||||
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
||||||
|
|
||||||
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<SkillType, Integer> readRank(String playerName) {
|
public Map<String, Integer> readRank(String playerName) {
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
|
|
||||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
|
|
||||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
skills.put(null, getPlayerRank(playerName, powerLevels));
|
skills.put("ALL", getPlayerRank(playerName, powerLevels));
|
||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
@@ -400,16 +400,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// I have no idea why it's necessary to inline tryClose() here, but it removes
|
tryClose(in);
|
||||||
// a resource leak warning, and I'm trusting the compiler on this one.
|
|
||||||
if (in != null) {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,8 +411,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
public void convertUsers(DatabaseManager destination) {
|
public void convertUsers(DatabaseManager destination) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
int convertedUsers = 0;
|
|
||||||
long startMillis = System.currentTimeMillis();
|
|
||||||
|
|
||||||
synchronized (fileWritingLock) {
|
synchronized (fileWritingLock) {
|
||||||
try {
|
try {
|
||||||
@@ -438,8 +427,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
convertedUsers++;
|
|
||||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|||||||
@@ -188,11 +188,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||||
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
|
String query = skillName.equalsIgnoreCase("ALL") ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skillName;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
@@ -230,8 +230,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<SkillType, Integer> readRank(String playerName) {
|
public Map<String, Integer> readRank(String playerName) {
|
||||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
@@ -262,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put(skillType, rank + resultSet.getRow());
|
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put(null, rank + resultSet.getRow());
|
skills.put("ALL", rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,8 +447,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
+ "WHERE u.user = ?");
|
+ "WHERE u.user = ?");
|
||||||
List<String> usernames = getStoredUsers();
|
List<String> usernames = getStoredUsers();
|
||||||
ResultSet result = null;
|
ResultSet result = null;
|
||||||
int convertedUsers = 0;
|
|
||||||
long startMillis = System.currentTimeMillis();
|
|
||||||
for (String playerName : usernames) {
|
for (String playerName : usernames) {
|
||||||
statement.setString(1, playerName);
|
statement.setString(1, playerName);
|
||||||
try {
|
try {
|
||||||
@@ -460,8 +458,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
convertedUsers++;
|
|
||||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
@@ -481,20 +477,20 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check connection status and re-establish if dead or stale.
|
* Check connection status and re-establish if dead or stale.
|
||||||
*
|
* <p/>
|
||||||
* If the very first immediate attempt fails, further attempts
|
* If the very first immediate attempt fails, further attempts
|
||||||
* will be made in progressively larger intervals up to MAX_WAIT
|
* will be made in progressively larger intervals up to MAX_WAIT
|
||||||
* intervals.
|
* intervals.
|
||||||
*
|
* <p/>
|
||||||
* This allows for MySQL to time out idle connections as needed by
|
* This allows for MySQL to time out idle connections as needed by
|
||||||
* server operator, without affecting McMMO, while still providing
|
* server operator, without affecting McMMO, while still providing
|
||||||
* protection against a database outage taking down Bukkit's tick
|
* protection against a database outage taking down Bukkit's tick
|
||||||
* processing loop due to attempting a database connection each
|
* processing loop due to attempting a database connection each
|
||||||
* time McMMO needs the database.
|
* time McMMO needs the database.
|
||||||
*
|
*
|
||||||
* @return the boolean value for whether or not we are connected
|
* @return the boolean value for whether or not we are connected
|
||||||
*/
|
*/
|
||||||
public boolean checkConnected() {
|
public boolean checkConnected() {
|
||||||
boolean isClosed = true;
|
boolean isClosed = true;
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
@@ -850,6 +846,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Attempt to write the SQL query.
|
* Attempt to write the SQL query.
|
||||||
*
|
*
|
||||||
* @param sql Query to write.
|
* @param sql Query to write.
|
||||||
|
*
|
||||||
* @return true if the query was successfully written, false otherwise.
|
* @return true if the query was successfully written, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean write(String sql) {
|
private boolean write(String sql) {
|
||||||
@@ -885,6 +882,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||||
*
|
*
|
||||||
* @param sql SQL query to execute
|
* @param sql SQL query to execute
|
||||||
|
*
|
||||||
* @return the number of rows affected
|
* @return the number of rows affected
|
||||||
*/
|
*/
|
||||||
private int update(String sql) {
|
private int update(String sql) {
|
||||||
@@ -919,6 +917,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Read SQL query.
|
* Read SQL query.
|
||||||
*
|
*
|
||||||
* @param sql SQL query to read
|
* @param sql SQL query to read
|
||||||
|
*
|
||||||
* @return the rows in this SQL query
|
* @return the rows in this SQL query
|
||||||
*/
|
*/
|
||||||
private HashMap<Integer, ArrayList<String>> read(String sql) {
|
private HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||||
@@ -964,6 +963,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Get the Integer. Only return first row / first field.
|
* Get the Integer. Only return first row / first field.
|
||||||
*
|
*
|
||||||
* @param statement SQL query to execute
|
* @param statement SQL query to execute
|
||||||
|
*
|
||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
private int readInt(PreparedStatement statement) {
|
private int readInt(PreparedStatement statement) {
|
||||||
@@ -1107,6 +1107,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Retrieve the database id for a player
|
* Retrieve the database id for a player
|
||||||
*
|
*
|
||||||
* @param playerName The name of the user to retrieve the id for
|
* @param playerName The name of the user to retrieve the id for
|
||||||
|
*
|
||||||
* @return the requested id or -1 if not found
|
* @return the requested id or -1 if not found
|
||||||
*/
|
*/
|
||||||
private int readId(String playerName) {
|
private int readId(String playerName) {
|
||||||
|
|||||||
@@ -7,6 +7,5 @@ public enum DatabaseUpdateType {
|
|||||||
MOB_HEALTHBARS,
|
MOB_HEALTHBARS,
|
||||||
PARTY_NAMES,
|
PARTY_NAMES,
|
||||||
KILL_ORPHANS,
|
KILL_ORPHANS,
|
||||||
DROPPED_SPOUT
|
DROPPED_SPOUT;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,6 @@ public class McMMOPlayer {
|
|||||||
private int lastSalvageClick;
|
private int lastSalvageClick;
|
||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
|
|
||||||
private Location hookLocation;
|
|
||||||
|
|
||||||
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||||
|
|
||||||
@@ -97,7 +95,6 @@ public class McMMOPlayer {
|
|||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
private int teleportATS;
|
private int teleportATS;
|
||||||
private long databaseATS;
|
|
||||||
private int chimeraWingLastUse;
|
private int chimeraWingLastUse;
|
||||||
private Location teleportCommence;
|
private Location teleportCommence;
|
||||||
|
|
||||||
@@ -269,6 +266,7 @@ public class McMMOPlayer {
|
|||||||
* Get the mode of an ability.
|
* Get the mode of an ability.
|
||||||
*
|
*
|
||||||
* @param ability The ability to check
|
* @param ability The ability to check
|
||||||
|
*
|
||||||
* @return true if the ability is enabled, false otherwise
|
* @return true if the ability is enabled, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getAbilityMode(AbilityType ability) {
|
public boolean getAbilityMode(AbilityType ability) {
|
||||||
@@ -278,7 +276,7 @@ public class McMMOPlayer {
|
|||||||
/**
|
/**
|
||||||
* Set the mode of an ability.
|
* 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
|
* @param isActive True if the ability is active, false otherwise
|
||||||
*/
|
*/
|
||||||
public void setAbilityMode(AbilityType ability, boolean isActive) {
|
public void setAbilityMode(AbilityType ability, boolean isActive) {
|
||||||
@@ -289,6 +287,7 @@ public class McMMOPlayer {
|
|||||||
* Get the informed state of an ability
|
* Get the informed state of an ability
|
||||||
*
|
*
|
||||||
* @param ability The ability to check
|
* @param ability The ability to check
|
||||||
|
*
|
||||||
* @return true if the ability is informed, false otherwise
|
* @return true if the ability is informed, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getAbilityInformed(AbilityType ability) {
|
public boolean getAbilityInformed(AbilityType ability) {
|
||||||
@@ -298,7 +297,7 @@ public class McMMOPlayer {
|
|||||||
/**
|
/**
|
||||||
* Set the informed state of an ability.
|
* 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
|
* @param isInformed True if the ability is informed, false otherwise
|
||||||
*/
|
*/
|
||||||
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
|
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
|
||||||
@@ -309,6 +308,7 @@ public class McMMOPlayer {
|
|||||||
* Get the current prep mode of a tool.
|
* Get the current prep mode of a tool.
|
||||||
*
|
*
|
||||||
* @param tool Tool to get the mode for
|
* @param tool Tool to get the mode for
|
||||||
|
*
|
||||||
* @return true if the tool is prepped, false otherwise
|
* @return true if the tool is prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getToolPreparationMode(ToolType tool) {
|
public boolean getToolPreparationMode(ToolType tool) {
|
||||||
@@ -339,7 +339,7 @@ public class McMMOPlayer {
|
|||||||
/**
|
/**
|
||||||
* Set the current prep mode of a tool.
|
* 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
|
* @param isPrepared true if the tool should be prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
||||||
@@ -350,6 +350,7 @@ public class McMMOPlayer {
|
|||||||
* Get the current prep ATS of a tool.
|
* Get the current prep ATS of a tool.
|
||||||
*
|
*
|
||||||
* @param tool Tool to get the ATS for
|
* @param tool Tool to get the ATS for
|
||||||
|
*
|
||||||
* @return the ATS for the tool
|
* @return the ATS for the tool
|
||||||
*/
|
*/
|
||||||
public long getToolPreparationATS(ToolType tool) {
|
public long getToolPreparationATS(ToolType tool) {
|
||||||
@@ -360,7 +361,7 @@ public class McMMOPlayer {
|
|||||||
* Set the current prep ATS of a tool.
|
* Set the current prep ATS of a tool.
|
||||||
*
|
*
|
||||||
* @param tool Tool to set the ATS for
|
* @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) {
|
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||||
@@ -428,14 +429,6 @@ public class McMMOPlayer {
|
|||||||
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDatabaseATS() {
|
|
||||||
return databaseATS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void actualizeDatabaseATS() {
|
|
||||||
databaseATS = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Repair Anvil Placement
|
* Repair Anvil Placement
|
||||||
*/
|
*/
|
||||||
@@ -510,18 +503,6 @@ public class McMMOPlayer {
|
|||||||
godMode = !godMode;
|
godMode = !godMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Fishing: Master Angler
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Location getHookLocation() {
|
|
||||||
return hookLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHookLocation(Location hookLocation) {
|
|
||||||
this.hookLocation = hookLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skill notifications
|
* Skill notifications
|
||||||
*/
|
*/
|
||||||
@@ -543,7 +524,7 @@ public class McMMOPlayer {
|
|||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||||
if (type.getPermissions(player)) {
|
if (Permissions.skillEnabled(player, type)) {
|
||||||
powerLevel += profile.getSkillLevel(type);
|
powerLevel += profile.getSkillLevel(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,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
|
* 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 skillType Skill being used
|
||||||
* @param xp Experience amount to process
|
* @param xp Experience amount to process
|
||||||
*/
|
*/
|
||||||
public void beginXpGain(SkillType skillType, float xp) {
|
public void beginXpGain(SkillType skillType, float xp) {
|
||||||
if (xp == 0) {
|
if (xp == 0) {
|
||||||
@@ -566,7 +547,7 @@ public class McMMOPlayer {
|
|||||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||||
|
|
||||||
for (SkillType parentSkill : parentSkills) {
|
for (SkillType parentSkill : parentSkills) {
|
||||||
if (parentSkill.getPermissions(player)) {
|
if (Permissions.skillEnabled(player, parentSkill)) {
|
||||||
beginXpGain(parentSkill, xp / parentSkills.size());
|
beginXpGain(parentSkill, xp / parentSkills.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,7 +567,7 @@ public class McMMOPlayer {
|
|||||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
|
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
|
||||||
*
|
*
|
||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
* @param xp Experience amount to process
|
* @param xp Experience amount to process
|
||||||
*/
|
*/
|
||||||
public void beginUnsharedXpGain(SkillType skillType, float xp) {
|
public void beginUnsharedXpGain(SkillType skillType, float xp) {
|
||||||
xp = modifyXpGain(skillType, xp);
|
xp = modifyXpGain(skillType, xp);
|
||||||
@@ -598,10 +579,10 @@ public class McMMOPlayer {
|
|||||||
* Applies an experience gain
|
* Applies an experience gain
|
||||||
*
|
*
|
||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
* @param xp Experience amount to add
|
* @param xp Experience amount to add
|
||||||
*/
|
*/
|
||||||
public void applyXpGain(SkillType skillType, float xp) {
|
public void applyXpGain(SkillType skillType, float xp) {
|
||||||
if (!skillType.getPermissions(player)) {
|
if (!Permissions.skillEnabled(player, skillType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,7 +785,8 @@ public class McMMOPlayer {
|
|||||||
* Modifies an experience gain using skill modifiers, global rate and perks
|
* Modifies an experience gain using skill modifiers, global rate and perks
|
||||||
*
|
*
|
||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
* @param xp Experience amount to process
|
* @param xp Experience amount to process
|
||||||
|
*
|
||||||
* @return Modified experience
|
* @return Modified experience
|
||||||
*/
|
*/
|
||||||
private float modifyXpGain(SkillType skillType, float xp) {
|
private float modifyXpGain(SkillType skillType, float xp) {
|
||||||
@@ -854,7 +836,7 @@ public class McMMOPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeRemaining = calculateTimeRemaining(ability);
|
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||||
|
|
||||||
if (timeRemaining > 0) {
|
if (timeRemaining > 0) {
|
||||||
/*
|
/*
|
||||||
@@ -924,7 +906,7 @@ public class McMMOPlayer {
|
|||||||
*/
|
*/
|
||||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
||||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||||
int timeRemaining = calculateTimeRemaining(ability);
|
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||||
|
|
||||||
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||||
@@ -941,16 +923,4 @@ public class McMMOPlayer {
|
|||||||
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the time remaining until the ability's cooldown expires.
|
|
||||||
*
|
|
||||||
* @param ability AbilityType whose cooldown to check
|
|
||||||
*
|
|
||||||
* @return the number of seconds remaining before the cooldown expires
|
|
||||||
*/
|
|
||||||
public int calculateTimeRemaining(AbilityType ability) {
|
|
||||||
long deactivatedTimestamp = profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR;
|
|
||||||
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ public class PlayerProfile {
|
|||||||
* Get the current DATS of a skill.
|
* Get the current DATS of a skill.
|
||||||
*
|
*
|
||||||
* @param abilityType Ability to get the DATS for
|
* @param abilityType Ability to get the DATS for
|
||||||
|
*
|
||||||
* @return the DATS for the ability
|
* @return the DATS for the ability
|
||||||
*/
|
*/
|
||||||
public long getSkillDATS(AbilityType abilityType) {
|
public long getSkillDATS(AbilityType abilityType) {
|
||||||
@@ -125,8 +126,8 @@ public class PlayerProfile {
|
|||||||
/**
|
/**
|
||||||
* Set the current DATS of a skill.
|
* Set the current DATS of a skill.
|
||||||
*
|
*
|
||||||
* @param abilityType Ability to set the DATS for
|
* @param abilityType Ability to set the DATS for
|
||||||
* @param DATS the DATS of the ability
|
* @param DATS the DATS of the ability
|
||||||
*/
|
*/
|
||||||
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
||||||
int wearsOff = (int) (DATS * .001D);
|
int wearsOff = (int) (DATS * .001D);
|
||||||
@@ -181,7 +182,7 @@ public class PlayerProfile {
|
|||||||
* Remove Xp from a skill.
|
* Remove Xp from a skill.
|
||||||
*
|
*
|
||||||
* @param skillType Type of skill to modify
|
* @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) {
|
public void removeXp(SkillType skillType, int xp) {
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
@@ -197,7 +198,7 @@ public class PlayerProfile {
|
|||||||
* Modify a skill level.
|
* Modify a skill level.
|
||||||
*
|
*
|
||||||
* @param skillType Type of skill to modify
|
* @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) {
|
public void modifySkill(SkillType skillType, int newValue) {
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
@@ -214,7 +215,7 @@ public class PlayerProfile {
|
|||||||
* Add levels to a skill.
|
* Add levels to a skill.
|
||||||
*
|
*
|
||||||
* @param skillType Type of skill to add levels to
|
* @param skillType Type of skill to add levels to
|
||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*/
|
*/
|
||||||
public void addLevels(SkillType skillType, int levels) {
|
public void addLevels(SkillType skillType, int levels) {
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
@@ -230,7 +231,7 @@ public class PlayerProfile {
|
|||||||
/**
|
/**
|
||||||
* Add Experience to a skill.
|
* 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
|
* @param experience Number of experience to add
|
||||||
*/
|
*/
|
||||||
public void addExperience(SkillType skillType, int experience) {
|
public void addExperience(SkillType skillType, int experience) {
|
||||||
@@ -247,6 +248,7 @@ public class PlayerProfile {
|
|||||||
* Get the total amount of Xp before the next level.
|
* Get the total amount of Xp before the next level.
|
||||||
*
|
*
|
||||||
* @param skillType Type of skill to check
|
* @param skillType Type of skill to check
|
||||||
|
*
|
||||||
* @return the total amount of Xp until next level
|
* @return the total amount of Xp until next level
|
||||||
*/
|
*/
|
||||||
public int getXpToLevel(SkillType skillType) {
|
public int getXpToLevel(SkillType skillType) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills;
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@@ -13,7 +11,6 @@ import com.gmail.nossr50.util.BlockUtils;
|
|||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public enum AbilityType {
|
public enum AbilityType {
|
||||||
BERSERK(
|
BERSERK(
|
||||||
@@ -65,9 +62,6 @@ public enum AbilityType {
|
|||||||
"Swords.Skills.SS.Refresh",
|
"Swords.Skills.SS.Refresh",
|
||||||
"Swords.Skills.SS.Other.Off"),
|
"Swords.Skills.SS.Other.Off"),
|
||||||
|
|
||||||
/**
|
|
||||||
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
|
|
||||||
*/
|
|
||||||
BLAST_MINING(
|
BLAST_MINING(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -75,15 +69,19 @@ public enum AbilityType {
|
|||||||
"Mining.Blast.Refresh",
|
"Mining.Blast.Refresh",
|
||||||
null),
|
null),
|
||||||
|
|
||||||
/**
|
LEAF_BLOWER(
|
||||||
* No cooldown - always active
|
null,
|
||||||
*/
|
null,
|
||||||
LEAF_BLOWER,
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
|
||||||
/**
|
BLOCK_CRACKER(
|
||||||
* Not a first-class Ability - part of Berserk
|
null,
|
||||||
*/
|
null,
|
||||||
BLOCK_CRACKER;
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
private String abilityOn;
|
private String abilityOn;
|
||||||
private String abilityOff;
|
private String abilityOff;
|
||||||
@@ -91,20 +89,6 @@ public enum AbilityType {
|
|||||||
private String abilityRefresh;
|
private String abilityRefresh;
|
||||||
private String abilityPlayerOff;
|
private String abilityPlayerOff;
|
||||||
|
|
||||||
/**
|
|
||||||
* Those abilities that have a cooldown saved to the database.
|
|
||||||
*/
|
|
||||||
public static final List<AbilityType> NORMAL_ABILITIES = ImmutableList.of(BERSERK, BLAST_MINING, GIGA_DRILL_BREAKER, GREEN_TERRA, SERRATED_STRIKES, SKULL_SPLITTER, SUPER_BREAKER, TREE_FELLER);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Those abilities that do not have a cooldown saved to the database.
|
|
||||||
*/
|
|
||||||
public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
|
|
||||||
|
|
||||||
private AbilityType() {
|
|
||||||
this(null, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||||
this.abilityOn = abilityOn;
|
this.abilityOn = abilityOn;
|
||||||
this.abilityOff = abilityOff;
|
this.abilityOff = abilityOff;
|
||||||
@@ -141,10 +125,6 @@ public enum AbilityType {
|
|||||||
return LocaleLoader.getString(this.abilityRefresh);
|
return LocaleLoader.getString(this.abilityRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return StringUtils.getPrettyAbilityString(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String baseString = name();
|
String baseString = name();
|
||||||
@@ -170,6 +150,7 @@ public enum AbilityType {
|
|||||||
* Get the permissions for this ability.
|
* Get the permissions for this ability.
|
||||||
*
|
*
|
||||||
* @param player Player to check permissions for
|
* @param player Player to check permissions for
|
||||||
|
*
|
||||||
* @return true if the player has permissions, false otherwise
|
* @return true if the player has permissions, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getPermissions(Player player) {
|
public boolean getPermissions(Player player) {
|
||||||
@@ -213,6 +194,7 @@ public enum AbilityType {
|
|||||||
* Check if a block is affected by this ability.
|
* Check if a block is affected by this ability.
|
||||||
*
|
*
|
||||||
* @param blockState the block to check
|
* @param blockState the block to check
|
||||||
|
*
|
||||||
* @return true if the block is affected by this ability, false otherwise
|
* @return true if the block is affected by this ability, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean blockCheck(BlockState blockState) {
|
public boolean blockCheck(BlockState blockState) {
|
||||||
@@ -247,7 +229,8 @@ public enum AbilityType {
|
|||||||
* Check to see if ability should be triggered.
|
* Check to see if ability should be triggered.
|
||||||
*
|
*
|
||||||
* @param player The player using the ability
|
* @param player The player using the ability
|
||||||
* @param block The block modified by the ability
|
* @param block The block modified by the ability
|
||||||
|
*
|
||||||
* @return true if the ability should activate, false otherwise
|
* @return true if the ability should activate, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean triggerCheck(Player player, Block block) {
|
public boolean triggerCheck(Player player, Block block) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@@ -25,7 +24,6 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
|||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -72,7 +70,7 @@ public enum SkillType {
|
|||||||
nonChildSkills.add(skill);
|
nonChildSkills.add(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
names.add(skill.getName());
|
names.add(skill.getSkillName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(names);
|
Collections.sort(names);
|
||||||
@@ -193,11 +191,7 @@ public enum SkillType {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getSkillName() {
|
||||||
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
|
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPermissions(Player player) {
|
|
||||||
return Permissions.skillEnabled(player, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public enum ToolType {
|
|||||||
* Check to see if the item is of the appropriate type.
|
* Check to see if the item is of the appropriate type.
|
||||||
*
|
*
|
||||||
* @param itemStack The item to check
|
* @param itemStack The item to check
|
||||||
|
*
|
||||||
* @return true if the item is the right type, false otherwise
|
* @return true if the item is the right type, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean inHand(ItemStack itemStack) {
|
public boolean inHand(ItemStack itemStack) {
|
||||||
|
|||||||
@@ -156,19 +156,19 @@ public class BlockListener implements Listener {
|
|||||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||||
* Instead, we check it inside the drops handler.
|
* Instead, we check it inside the drops handler.
|
||||||
*/
|
*/
|
||||||
if (SkillType.HERBALISM.getPermissions(player)) {
|
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||||
herbalismManager.herbalismBlockCheck(blockState);
|
herbalismManager.herbalismBlockCheck(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && SkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||||
miningManager.miningBlockCheck(blockState);
|
miningManager.miningBlockCheck(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||||
|
|
||||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
@@ -180,7 +180,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* EXCAVATION */
|
/* EXCAVATION */
|
||||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && SkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
||||||
excavationManager.excavationBlockCheck(blockState);
|
excavationManager.excavationBlockCheck(blockState);
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
Player player = Misc.getPlayerFromFurnace(furnaceBlock);
|
Player player = Misc.getPlayerFromFurnace(furnaceBlock);
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
|||||||
import com.gmail.nossr50.util.Motd;
|
import com.gmail.nossr50.util.Motd;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
@@ -68,7 +69,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerTeleportEvents.
|
* Monitor PlayerTeleportEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of setting the
|
* These events are monitored for the purpose of setting the
|
||||||
* player's last teleportation timestamp, in order to prevent
|
* player's last teleportation timestamp, in order to prevent
|
||||||
* possible Acrobatics exploitation.
|
* possible Acrobatics exploitation.
|
||||||
@@ -88,7 +89,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerDeathEvents at the lowest priority.
|
* Handle PlayerDeathEvents at the lowest priority.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are used to modify the death message of a player when
|
* These events are used to modify the death message of a player when
|
||||||
* needed to correct issues potentially caused by the custom naming used
|
* needed to correct issues potentially caused by the custom naming used
|
||||||
* for mob healthbars.
|
* for mob healthbars.
|
||||||
@@ -114,7 +115,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerDeathEvents.
|
* Monitor PlayerDeathEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of dealing the penalties
|
* These events are monitored for the purpose of dealing the penalties
|
||||||
* associated with hardcore and vampirism modes. If neither of these
|
* associated with hardcore and vampirism modes. If neither of these
|
||||||
* modes are enabled, or if the player who died has hardcore bypass
|
* modes are enabled, or if the player who died has hardcore bypass
|
||||||
@@ -150,7 +151,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerChangedWorldEvents.
|
* Monitor PlayerChangedWorldEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of removing god mode or
|
* 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
|
* player parties if they are not allowed on the world the player has
|
||||||
* changed to.
|
* changed to.
|
||||||
@@ -173,7 +174,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerDropItemEvents.
|
* Monitor PlayerDropItemEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of flagging sharable
|
* These events are monitored for the purpose of flagging sharable
|
||||||
* dropped items, as well as removing ability buffs from pickaxes
|
* dropped items, as well as removing ability buffs from pickaxes
|
||||||
* and shovels.
|
* and shovels.
|
||||||
@@ -194,7 +195,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerFishEvents at the highest priority.
|
* Handle PlayerFishEvents at the highest priority.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are used for the purpose of handling our anti-exploit
|
* These events are used for the purpose of handling our anti-exploit
|
||||||
* code, as well as dealing with ice fishing.
|
* code, as well as dealing with ice fishing.
|
||||||
*
|
*
|
||||||
@@ -204,7 +205,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerFishHighest(PlayerFishEvent event) {
|
public void onPlayerFishHighest(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerFishEvents.
|
* Monitor PlayerFishEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of handling the various
|
* These events are monitored for the purpose of handling the various
|
||||||
* Fishing skills and abilities.
|
* Fishing skills and abilities.
|
||||||
*
|
*
|
||||||
@@ -249,7 +250,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +281,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerPickupItemEvents at the highest priority.
|
* Handle PlayerPickupItemEvents at the highest priority.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are used to handle item sharing between party members and
|
* These events are used to handle item sharing between party members and
|
||||||
* are also used to handle item pickup for the Unarmed skill.
|
* are also used to handle item pickup for the Unarmed skill.
|
||||||
*
|
*
|
||||||
@@ -321,7 +322,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerQuitEvents.
|
* Monitor PlayerQuitEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of resetting player
|
* These events are monitored for the purpose of resetting player
|
||||||
* variables and other garbage collection tasks that must take place when
|
* variables and other garbage collection tasks that must take place when
|
||||||
* a player exits the server.
|
* a player exits the server.
|
||||||
@@ -346,7 +347,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerJoinEvents.
|
* Monitor PlayerJoinEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of initializing player
|
* These events are monitored for the purpose of initializing player
|
||||||
* variables, as well as handling the MOTD display and other important
|
* variables, as well as handling the MOTD display and other important
|
||||||
* join messages.
|
* join messages.
|
||||||
@@ -362,6 +363,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserManager.addUser(player).actualizeRespawnATS();
|
UserManager.addUser(player).actualizeRespawnATS();
|
||||||
|
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||||
|
|
||||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||||
Motd.displayAll(player);
|
Motd.displayAll(player);
|
||||||
@@ -379,7 +381,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerRespawnEvents.
|
* Monitor PlayerRespawnEvents.
|
||||||
* <p>
|
* <p/>
|
||||||
* These events are monitored for the purpose of setting the
|
* These events are monitored for the purpose of setting the
|
||||||
* player's last respawn timestamp, in order to prevent
|
* player's last respawn timestamp, in order to prevent
|
||||||
* possible exploitation.
|
* possible exploitation.
|
||||||
@@ -421,7 +423,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@@ -460,7 +462,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
// Cancel repairing an enchanted item
|
// Cancel repairing an enchanted item
|
||||||
@@ -658,7 +660,7 @@ public class PlayerListener implements Listener {
|
|||||||
// Do these ACTUALLY have to be lower case to work properly?
|
// Do these ACTUALLY have to be lower case to work properly?
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
String skillName = skill.toString().toLowerCase();
|
String skillName = skill.toString().toLowerCase();
|
||||||
String localizedName = skill.getName().toLowerCase();
|
String localizedName = skill.getSkillName().toLowerCase();
|
||||||
|
|
||||||
if (lowerCaseCommand.equals(localizedName)) {
|
if (lowerCaseCommand.equals(localizedName)) {
|
||||||
event.setMessage(message.replace(command, skillName));
|
event.setMessage(message.replace(command, skillName));
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
|
|
||||||
public class ScoreboardsListener implements Listener {
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ScoreboardManager.setupPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
ScoreboardManager.teardownPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
|
||||||
ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
|
||||||
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
|
||||||
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
|
||||||
public final class LocaleLoader {
|
public final class LocaleLoader {
|
||||||
@@ -15,7 +14,7 @@ public final class LocaleLoader {
|
|||||||
private static ResourceBundle bundle = null;
|
private static ResourceBundle bundle = null;
|
||||||
private static ResourceBundle enBundle = null;
|
private static ResourceBundle enBundle = null;
|
||||||
|
|
||||||
private LocaleLoader() {};
|
private LocaleLoader() {}
|
||||||
|
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
return getString(key, (Object[]) null);
|
return getString(key, (Object[]) null);
|
||||||
@@ -24,8 +23,9 @@ public final class LocaleLoader {
|
|||||||
/**
|
/**
|
||||||
* Gets the appropriate string from the Locale files.
|
* 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
|
* @param messageArguments Any arguments to be added to the string
|
||||||
|
*
|
||||||
* @return The properly formatted locale string
|
* @return The properly formatted locale string
|
||||||
*/
|
*/
|
||||||
public static String getString(String key, Object... messageArguments) {
|
public static String getString(String key, Object... messageArguments) {
|
||||||
@@ -41,10 +41,6 @@ public final class LocaleLoader {
|
|||||||
return getString(key, enBundle, messageArguments);
|
return getString(key, enBundle, messageArguments);
|
||||||
}
|
}
|
||||||
catch (MissingResourceException ex2) {
|
catch (MissingResourceException ex2) {
|
||||||
if (!key.contains("Guides")) {
|
|
||||||
mcMMO.p.getLogger().warning("Could not find locale string: " + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '!' + key + '!';
|
return '!' + key + '!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.gmail.nossr50.listeners.BlockListener;
|
|||||||
import com.gmail.nossr50.listeners.EntityListener;
|
import com.gmail.nossr50.listeners.EntityListener;
|
||||||
import com.gmail.nossr50.listeners.InventoryListener;
|
import com.gmail.nossr50.listeners.InventoryListener;
|
||||||
import com.gmail.nossr50.listeners.PlayerListener;
|
import com.gmail.nossr50.listeners.PlayerListener;
|
||||||
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
|
||||||
import com.gmail.nossr50.listeners.SelfListener;
|
import com.gmail.nossr50.listeners.SelfListener;
|
||||||
import com.gmail.nossr50.listeners.WorldListener;
|
import com.gmail.nossr50.listeners.WorldListener;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -34,7 +33,6 @@ import com.gmail.nossr50.party.PartyManager;
|
|||||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||||
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
|
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.child.ChildConfig;
|
import com.gmail.nossr50.skills.child.ChildConfig;
|
||||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||||
@@ -50,11 +48,10 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
|||||||
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
||||||
import com.gmail.nossr50.util.experience.FormulaManager;
|
import com.gmail.nossr50.util.experience.FormulaManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
import net.h31ix.updater.mcmmo.Updater;
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
|
import net.h31ix.updater.mcmmo.Updater.UpdateResult;
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
|
import net.h31ix.updater.mcmmo.Updater.UpdateType;
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
@@ -81,8 +78,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
/* Plugin Checks */
|
/* Plugin Checks */
|
||||||
private static boolean combatTagEnabled;
|
private static boolean combatTagEnabled;
|
||||||
private static boolean healthBarPluginEnabled;
|
private static boolean healthBarPluginEnabled;
|
||||||
private static boolean noCheatPlusPluginEnabled;
|
|
||||||
private static boolean compatNoCheatPlusPluginEnabled;
|
|
||||||
private static boolean mcpcEnabled;
|
private static boolean mcpcEnabled;
|
||||||
|
|
||||||
// Config Validation Check
|
// Config Validation Check
|
||||||
@@ -125,11 +120,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcpcEnabled = getServer().getName().equals("MCPC+");
|
|
||||||
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
||||||
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
||||||
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
|
mcpcEnabled = getServer().getName().equals("MCPC+");
|
||||||
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
|
|
||||||
|
|
||||||
if (mcpcEnabled) {
|
if (mcpcEnabled) {
|
||||||
checkModConfigs();
|
checkModConfigs();
|
||||||
@@ -139,11 +132,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
|
|
||||||
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
|
||||||
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
@@ -155,7 +143,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
||||||
ScoreboardManager.setupPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||||
@@ -195,12 +182,12 @@ public class mcMMO extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||||
PartyManager.saveParties(); // Save our parties
|
PartyManager.saveParties(); // Save our parties
|
||||||
ScoreboardManager.teardownAll();
|
|
||||||
formulaManager.saveFormula();
|
formulaManager.saveFormula();
|
||||||
placeStore.saveAll(); // Save our metadata
|
placeStore.saveAll(); // Save our metadata
|
||||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||||
}
|
}
|
||||||
catch (NullPointerException e) {}
|
catch (NullPointerException e) {
|
||||||
|
}
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||||
@@ -326,14 +313,14 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
|
Updater updater = new Updater(this, "mcmmo", mcmmo, UpdateType.NO_DOWNLOAD, false);
|
||||||
|
|
||||||
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
|
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
|
||||||
this.updateAvailable = false;
|
this.updateAvailable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
if (updater.getLatestVersionString().contains("-beta") && !Config.getInstance().getPreferBeta()) {
|
||||||
this.updateAvailable = false;
|
this.updateAvailable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -384,7 +371,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new EntityListener(this), this);
|
pluginManager.registerEvents(new EntityListener(this), this);
|
||||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||||
pluginManager.registerEvents(new SelfListener(), this);
|
pluginManager.registerEvents(new SelfListener(), this);
|
||||||
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
|
||||||
pluginManager.registerEvents(new WorldListener(this), this);
|
pluginManager.registerEvents(new WorldListener(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,9 +407,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
else if (kickIntervalTicks > 0) {
|
else if (kickIntervalTicks > 0) {
|
||||||
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update power level tag scoreboards
|
|
||||||
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkModConfigs() {
|
private void checkModConfigs() {
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Check if a party with a given name already exists.
|
* 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
|
* @param partyName The name of the party to check
|
||||||
|
*
|
||||||
* @return true if a party with that name exists, false otherwise
|
* @return true if a party with that name exists, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean checkPartyExistence(Player player, String partyName) {
|
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.
|
* 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
|
* @param newPartyName The name of the party being joined
|
||||||
|
*
|
||||||
* @return true if the party was joined successfully, false otherwise
|
* @return true if the party was joined successfully, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
|
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.
|
* 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
|
* @param secondPlayer The second player
|
||||||
|
*
|
||||||
* @return true if they are in the same party, false otherwise
|
* @return true if they are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||||
@@ -92,6 +95,7 @@ public final class PartyManager {
|
|||||||
* Get the near party members.
|
* Get the near party members.
|
||||||
*
|
*
|
||||||
* @param mcMMOPlayer The player to check
|
* @param mcMMOPlayer The player to check
|
||||||
|
*
|
||||||
* @return the near party members
|
* @return the near party members
|
||||||
*/
|
*/
|
||||||
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
|
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.
|
* Get a list of all players in this player's party.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
public static LinkedHashSet<String> getAllMembers(Player player) {
|
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.
|
* Get a list of all online players in this party.
|
||||||
*
|
*
|
||||||
* @param partyName The party to check
|
* @param partyName The party to check
|
||||||
|
*
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(String partyName) {
|
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.
|
* Get a list of all online players in this party.
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
|
*
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(Player player) {
|
public static List<Player> getOnlineMembers(Player player) {
|
||||||
@@ -152,6 +159,7 @@ public final class PartyManager {
|
|||||||
* Retrieve a party by its name
|
* Retrieve a party by its name
|
||||||
*
|
*
|
||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
|
*
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public static Party getParty(String partyName) {
|
public static Party getParty(String partyName) {
|
||||||
@@ -168,6 +176,7 @@ public final class PartyManager {
|
|||||||
* Retrieve a party by a members name
|
* Retrieve a party by a members name
|
||||||
*
|
*
|
||||||
* @param playerName The members name
|
* @param playerName The members name
|
||||||
|
*
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public static Party getPlayerParty(String playerName) {
|
public static Party getPlayerParty(String playerName) {
|
||||||
@@ -184,6 +193,7 @@ public final class PartyManager {
|
|||||||
* Retrieve a party by member
|
* Retrieve a party by member
|
||||||
*
|
*
|
||||||
* @param player The member
|
* @param player The member
|
||||||
|
*
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public static Party getParty(Player player) {
|
public static Party getParty(Player player) {
|
||||||
@@ -205,7 +215,7 @@ public final class PartyManager {
|
|||||||
* Remove a player from a party.
|
* Remove a player from a party.
|
||||||
*
|
*
|
||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(OfflinePlayer player, Party party) {
|
public static void removeFromParty(OfflinePlayer player, Party party) {
|
||||||
LinkedHashSet<String> members = party.getMembers();
|
LinkedHashSet<String> members = party.getMembers();
|
||||||
@@ -253,8 +263,8 @@ public final class PartyManager {
|
|||||||
* Create a new party
|
* Create a new party
|
||||||
*
|
*
|
||||||
* @param mcMMOPlayer The player to add to the party
|
* @param mcMMOPlayer The player to add to the party
|
||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
* @param password The password for this party, null if there was no password
|
* @param password The password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
@@ -275,9 +285,10 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Check if a player can join a party
|
* Check if a player can join a party
|
||||||
*
|
*
|
||||||
* @param player The player trying to join a party
|
* @param player The player trying to join a party
|
||||||
* @param party The party
|
* @param party The party
|
||||||
* @param password The password provided by the player
|
* @param password The password provided by the player
|
||||||
|
*
|
||||||
* @return true if the player can join the party
|
* @return true if the player can join the party
|
||||||
*/
|
*/
|
||||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
||||||
@@ -326,7 +337,7 @@ public final class PartyManager {
|
|||||||
* Add a player to a party
|
* Add a player to a party
|
||||||
*
|
*
|
||||||
* @param mcMMOPlayer The player to add to the 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) {
|
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||||
String playerName = mcMMOPlayer.getPlayer().getName();
|
String playerName = mcMMOPlayer.getPlayer().getName();
|
||||||
@@ -340,6 +351,7 @@ public final class PartyManager {
|
|||||||
* Get the leader of a party.
|
* Get the leader of a party.
|
||||||
*
|
*
|
||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
|
*
|
||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public static String getPartyLeader(String partyName) {
|
public static String getPartyLeader(String partyName) {
|
||||||
@@ -352,7 +364,7 @@ public final class PartyManager {
|
|||||||
* Set the leader of a party.
|
* Set the leader of a party.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to set as leader
|
* @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) {
|
public static void setPartyLeader(String playerName, Party party) {
|
||||||
String leaderName = party.getLeader();
|
String leaderName = party.getLeader();
|
||||||
@@ -389,6 +401,7 @@ public final class PartyManager {
|
|||||||
* Check if a string is a valid party name.
|
* Check if a string is a valid party name.
|
||||||
*
|
*
|
||||||
* @param partyName The party name to check
|
* @param partyName The party name to check
|
||||||
|
*
|
||||||
* @return true if this is a valid party, false otherwise
|
* @return true if this is a valid party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isParty(String partyName) {
|
public static boolean isParty(String partyName) {
|
||||||
@@ -474,10 +487,11 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Handle party change event.
|
* 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 oldPartyName The name of the old party
|
||||||
* @param newPartyName The name of the new 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
|
* @return true if the change event was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||||
@@ -501,7 +515,7 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Notify party members when a player joins.
|
* 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
|
* @param playerName The name of the player that joined
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersJoin(Party party, String playerName) {
|
private static void informPartyMembersJoin(Party party, String playerName) {
|
||||||
@@ -513,7 +527,7 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Notify party members when a party member quits.
|
* 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
|
* @param playerName The name of the player that left
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersQuit(Party party, String playerName) {
|
private static void informPartyMembersQuit(Party party, String playerName) {
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ public final class ShareHandler {
|
|||||||
/**
|
/**
|
||||||
* Distribute Xp amongst party members.
|
* 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 mcMMOPlayer Player initiating the Xp gain
|
||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
|
*
|
||||||
* @return True is the xp has been shared
|
* @return True is the xp has been shared
|
||||||
*/
|
*/
|
||||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||||
@@ -56,8 +57,9 @@ public final class ShareHandler {
|
|||||||
/**
|
/**
|
||||||
* Distribute Items amongst party members.
|
* 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
|
* @param mcMMOPlayer Player who picked up the item
|
||||||
|
*
|
||||||
* @return True if the item has been shared
|
* @return True if the item has been shared
|
||||||
*/
|
*/
|
||||||
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {
|
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {
|
||||||
|
|||||||
@@ -2,38 +2,25 @@ package com.gmail.nossr50.runnables.commands;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
|
|
||||||
public class McrankCommandAsyncTask extends BukkitRunnable {
|
public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final boolean useBoard, useChat;
|
|
||||||
|
|
||||||
public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) {
|
|
||||||
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
|
||||||
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
|
||||||
|
|
||||||
if (useBoard) {
|
|
||||||
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public McrankCommandAsyncTask(String playerName, CommandSender sender) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.useBoard = useBoard;
|
|
||||||
this.useChat = useChat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Map<SkillType, Integer> skills = mcMMO.getDatabaseManager().readRank(playerName);
|
Map<String, Integer> skills = mcMMO.getDatabaseManager().readRank(playerName);
|
||||||
|
|
||||||
new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(mcMMO.p, 1);
|
new McrankCommandDisplayTask(skills, sender, playerName).runTaskLater(mcMMO.p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,37 +9,21 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the results of McrankCommandAsyncTask to the sender.
|
|
||||||
*/
|
|
||||||
public class McrankCommandDisplayTask extends BukkitRunnable {
|
public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||||
private final Map<SkillType, Integer> skills;
|
private final Map<String, Integer> skills;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private final boolean useBoard, useChat;
|
|
||||||
|
|
||||||
McrankCommandDisplayTask(Map<SkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
|
public McrankCommandDisplayTask(Map<String, Integer> skills, CommandSender sender, String playerName) {
|
||||||
this.skills = skills;
|
this.skills = skills;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
this.useBoard = useBoard;
|
|
||||||
this.useChat = useChat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (useBoard) {
|
|
||||||
displayBoard();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useChat){
|
|
||||||
displayChat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayChat() {
|
|
||||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||||
Integer rank;
|
Integer rank;
|
||||||
|
|
||||||
@@ -47,24 +31,15 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||||
|
|
||||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
if (!skill.getPermissions(player)) {
|
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rank = skills.get(skill);
|
rank = skills.get(skill.name());
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getName(), (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(null);
|
rank = skills.get("ALL");
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayBoard() {
|
|
||||||
if (sender.getName().equalsIgnoreCase(playerName)) {
|
|
||||||
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ScoreboardManager.showPlayerRankScoreboardOthers((Player) sender, playerName, skills);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,40 +2,27 @@ package com.gmail.nossr50.runnables.commands;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
|
|
||||||
public class MctopCommandAsyncTask extends BukkitRunnable {
|
public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||||
private final CommandSender sender;
|
private CommandSender sender;
|
||||||
private final SkillType skill;
|
private String skill;
|
||||||
private final int page;
|
private int page;
|
||||||
private final boolean useBoard, useChat;
|
|
||||||
|
|
||||||
public MctopCommandAsyncTask(int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
|
||||||
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
|
||||||
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
|
||||||
|
|
||||||
if (useBoard) {
|
|
||||||
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public MctopCommandAsyncTask(int page, String skill, CommandSender sender) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.useBoard = useBoard;
|
|
||||||
this.useChat = useChat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final List<PlayerStat> userStats = mcMMO.getDatabaseManager().readLeaderboard(skill, page, 10);
|
final List<PlayerStat> userStats = mcMMO.getDatabaseManager().readLeaderboard(skill, page, 10);
|
||||||
|
|
||||||
new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1);
|
new MctopCommandDisplayTask(userStats, page, skill, sender).runTaskLater(mcMMO.p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,71 +4,44 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the results of {@link MctopCommandAsyncTask} to the sender.
|
|
||||||
*/
|
|
||||||
public class MctopCommandDisplayTask extends BukkitRunnable {
|
public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||||
private final List<PlayerStat> userStats;
|
private List<PlayerStat> userStats;
|
||||||
private final CommandSender sender;
|
private CommandSender sender;
|
||||||
private final SkillType skill;
|
private String skill;
|
||||||
private final int page;
|
private int page;
|
||||||
private final boolean useBoard, useChat;
|
|
||||||
|
|
||||||
MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
public MctopCommandDisplayTask(List<PlayerStat> userStats, int page, String skill, CommandSender sender) {
|
||||||
this.userStats = userStats;
|
this.userStats = userStats;
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.useBoard = useBoard;
|
|
||||||
this.useChat = useChat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (useBoard) {
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
displayBoard();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useChat) {
|
|
||||||
displayChat();
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayChat() {
|
|
||||||
if (skill == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int place = (page * 10) - 9;
|
int place = (page * 10) - 9;
|
||||||
|
|
||||||
for (PlayerStat stat : userStats) {
|
for (PlayerStat stat : userStats) {
|
||||||
// Format:
|
String digit = ((place < 10) ? "0" : "") + String.valueOf(place);
|
||||||
// 01. Playername - skill value
|
|
||||||
// 12. Playername - skill value
|
// Format: 1. Playername - skill value
|
||||||
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
sender.sendMessage(digit + ". " + ChatColor.GREEN + stat.name + " - " + ChatColor.WHITE + stat.statVal);
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void displayBoard() {
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||||
if (skill == null) {
|
|
||||||
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ScoreboardManager.showTopScoreboard((Player) sender, skill, page, userStats);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
|||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class FormulaConversionTask extends BukkitRunnable {
|
public class FormulaConversionTask extends BukkitRunnable {
|
||||||
@@ -25,8 +23,6 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int convertedUsers = 0;
|
|
||||||
long startMillis = System.currentTimeMillis();
|
|
||||||
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
|
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
@@ -47,8 +43,6 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
editValues(profile);
|
editValues(profile);
|
||||||
}
|
}
|
||||||
convertedUsers++;
|
|
||||||
Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis);
|
|
||||||
}
|
}
|
||||||
mcMMO.getFormulaManager().setPreviousFormulaType(formulaType);
|
mcMMO.getFormulaManager().setPreviousFormulaType(formulaType);
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.gmail.nossr50.runnables.player;
|
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
|
|
||||||
public class PowerLevelUpdatingTask extends BukkitRunnable {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!ScoreboardManager.powerLevelHeartbeat()) {
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.gmail.nossr50.runnables.scoreboards;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
|
public class ScoreboardChangeTask extends BukkitRunnable {
|
||||||
|
private Player player;
|
||||||
|
private Scoreboard oldScoreboard;
|
||||||
|
|
||||||
|
public ScoreboardChangeTask(Player player, Scoreboard oldScoreboard) {
|
||||||
|
this.player = player;
|
||||||
|
this.oldScoreboard = oldScoreboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (player.isOnline()) {
|
||||||
|
player.setScoreboard(oldScoreboard);
|
||||||
|
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.clearPendingTask(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,7 +94,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
|||||||
* Add a LivingEntity to the bleedList if it is not in it.
|
* Add a LivingEntity to the bleedList if it is not in it.
|
||||||
*
|
*
|
||||||
* @param entity LivingEntity to add
|
* @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) {
|
public static void add(LivingEntity entity, int ticks) {
|
||||||
int newTicks = ticks;
|
int newTicks = ticks;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class KrakenAttackTask extends BukkitRunnable {
|
|||||||
private Creature kraken;
|
private Creature kraken;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Location location;
|
private Location location;
|
||||||
private final boolean GLOBAL_EFFECTS = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
|
private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled();
|
||||||
private final String DEFEAT_MESSAGE = AdvancedConfig.getInstance().getPlayerDefeatMessage();
|
private final String DEFEAT_MESSAGE = AdvancedConfig.getInstance().getPlayerDefeatMessage();
|
||||||
private final String ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
|
private final String ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
|
||||||
|
|
||||||
@@ -37,7 +37,16 @@ public class KrakenAttackTask extends BukkitRunnable {
|
|||||||
if (player.isValid() && playerLocation.getBlock().isLiquid()) {
|
if (player.isValid() && playerLocation.getBlock().isLiquid()) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|
||||||
krakenAttack(playerLocation, world);
|
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
||||||
|
|
||||||
|
if (GLOBAL_SOUNDS) {
|
||||||
|
world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
world.strikeLightningEffect(playerLocation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
|
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
|
||||||
@@ -74,24 +83,20 @@ public class KrakenAttackTask extends BukkitRunnable {
|
|||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|
||||||
kraken.teleport(player);
|
kraken.teleport(player);
|
||||||
krakenAttack(location, world);
|
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
||||||
|
|
||||||
|
if (GLOBAL_SOUNDS) {
|
||||||
|
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
kraken.remove();
|
kraken.remove();
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void krakenAttack(Location playerLocation, World world) {
|
|
||||||
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
|
||||||
|
|
||||||
if (GLOBAL_EFFECTS) {
|
|
||||||
world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
|
||||||
world.strikeLightningEffect(playerLocation);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
|
||||||
world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ public final class Acrobatics {
|
|||||||
|
|
||||||
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
|
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
|
||||||
|
|
||||||
|
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
|
||||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||||
|
|
||||||
private Acrobatics() {};
|
private Acrobatics() {}
|
||||||
|
|
||||||
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
|
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
|
||||||
return Math.max(damage / damageModifier, 1.0);
|
return Math.max(damage / damageModifier, 1.0);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -8,7 +7,6 @@ import org.bukkit.entity.LightningStrike;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -20,15 +18,14 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class AcrobaticsManager extends SkillManager {
|
public class AcrobaticsManager extends SkillManager {
|
||||||
private int fallTries = 0;
|
|
||||||
Location lastFallLocation;
|
|
||||||
|
|
||||||
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, SkillType.ACROBATICS);
|
super(mcMMOPlayer, SkillType.ACROBATICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRoll() {
|
public boolean canRoll() {
|
||||||
return !exploitPrevention() && Permissions.roll(getPlayer());
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDodge(Entity damager) {
|
public boolean canDodge(Entity damager) {
|
||||||
@@ -47,6 +44,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
* Handle the damage reduction and XP gain from the Dodge ability
|
* Handle the damage reduction and XP gain from the Dodge ability
|
||||||
*
|
*
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @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
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public double dodgeCheck(double damage) {
|
public double dodgeCheck(double damage) {
|
||||||
@@ -75,6 +73,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
* Handle the damage reduction and XP gain from the Roll ability
|
* Handle the damage reduction and XP gain from the Roll ability
|
||||||
*
|
*
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @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
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public double rollCheck(double damage) {
|
public double rollCheck(double damage) {
|
||||||
@@ -96,8 +95,6 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
applyXpGain(calculateRollXP(damage, false));
|
applyXpGain(calculateRollXP(damage, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
lastFallLocation = player.getLocation();
|
|
||||||
|
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +102,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
* Handle the damage reduction and XP gain from the Graceful Roll ability
|
* Handle the damage reduction and XP gain from the Graceful Roll ability
|
||||||
*
|
*
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @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
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
private double gracefulRollCheck(double damage) {
|
private double gracefulRollCheck(double damage) {
|
||||||
@@ -123,33 +121,6 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the player is "farming" Acrobatics XP using
|
|
||||||
* exploits in the game.
|
|
||||||
*
|
|
||||||
* @return true if exploits are detected, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean exploitPrevention() {
|
|
||||||
if (!Config.getInstance().getAcrobaticsPreventAFK()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = getPlayer();
|
|
||||||
|
|
||||||
if (player.getItemInHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location fallLocation = player.getLocation();
|
|
||||||
|
|
||||||
boolean sameLocation = (lastFallLocation != null && Misc.isNear(lastFallLocation, fallLocation, 2));
|
|
||||||
|
|
||||||
fallTries = sameLocation ? fallTries + 1 : Math.max(fallTries - 1, 0);
|
|
||||||
lastFallLocation = fallLocation;
|
|
||||||
|
|
||||||
return fallTries > Config.getInstance().getAcrobaticsAFKMaxTries();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
|
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
|
||||||
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
|
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Calculate bonus XP awarded for Archery when hitting a far-away target.
|
* 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
|
* @param damager The {@link Entity} who shot the arrow
|
||||||
*/
|
*/
|
||||||
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
||||||
@@ -69,7 +69,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* Handle the effects of the Daze ability
|
* Handle the effects of the Daze ability
|
||||||
*
|
*
|
||||||
* @param defender The {@link Player} being affected by the 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) {
|
public double daze(Player defender, Arrow arrow) {
|
||||||
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
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 target The {@link LivingEntity} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @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) {
|
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
|
||||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class AxesManager extends SkillManager {
|
|||||||
short maxDurability = mcMMO.getRepairableManager().isRepairable(armorType) ? mcMMO.getRepairableManager().getRepairable(armorType).getMaximumDurability() : armorType.getMaxDurability();
|
short maxDurability = mcMMO.getRepairableManager().isRepairable(armorType) ? mcMMO.getRepairableManager().getRepairable(armorType).getMaximumDurability() : armorType.getMaxDurability();
|
||||||
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
||||||
|
|
||||||
SkillUtils.handleDurabilityChange(armor, (int) Math.min(modifiedDurabilityDamage, maxDurabilityDamage));
|
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class Excavation {
|
|||||||
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
|
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check.
|
* @param blockState The {@link BlockState} of the block to check.
|
||||||
|
*
|
||||||
* @return the list of treasures that could be found
|
* @return the list of treasures that could be found
|
||||||
*/
|
*/
|
||||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public final class Fishing {
|
|||||||
* Finds the possible drops of an entity
|
* Finds the possible drops of an entity
|
||||||
*
|
*
|
||||||
* @param target Targeted entity
|
* @param target Targeted entity
|
||||||
|
*
|
||||||
* @return possibleDrops List of ItemStack that can be dropped
|
* @return possibleDrops List of ItemStack that can be dropped
|
||||||
*/
|
*/
|
||||||
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
||||||
@@ -135,6 +136,7 @@ public final class Fishing {
|
|||||||
* Randomly chooses a drop among the list
|
* Randomly chooses a drop among the list
|
||||||
*
|
*
|
||||||
* @param possibleDrops List of ItemStack that can be dropped
|
* @param possibleDrops List of ItemStack that can be dropped
|
||||||
|
*
|
||||||
* @return Chosen ItemStack
|
* @return Chosen ItemStack
|
||||||
*/
|
*/
|
||||||
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
||||||
|
|||||||
@@ -103,31 +103,31 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
|
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
|
||||||
|
|
||||||
|
Location location = player.getLocation();
|
||||||
|
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
|
||||||
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
|
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
|
||||||
|
|
||||||
if (!unleashMessage.isEmpty()) {
|
if (!unleashMessage.isEmpty()) {
|
||||||
player.sendMessage(unleashMessage);
|
player.sendMessage(unleashMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = player.getLocation();
|
if (AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled()) {
|
||||||
boolean globalEffectsEnabled = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
|
|
||||||
|
|
||||||
if (globalEffectsEnabled) {
|
|
||||||
world.strikeLightningEffect(location);
|
|
||||||
world.strikeLightningEffect(location);
|
|
||||||
world.strikeLightningEffect(location);
|
|
||||||
|
|
||||||
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
|
||||||
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
|
||||||
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
|
||||||
|
|
||||||
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String globalMessage = AdvancedConfig.getInstance().getServerUnleashMessage();
|
||||||
|
|
||||||
|
if (!globalMessage.isEmpty()) {
|
||||||
|
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (player.getItemInHand().getType() == Material.FISHING_ROD) {
|
if (player.getItemInHand().getType() == Material.FISHING_ROD) {
|
||||||
player.setItemInHand(null);
|
player.setItemInHand(null);
|
||||||
}
|
}
|
||||||
@@ -277,12 +277,9 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
public void masterAngler(Fish hook) {
|
public void masterAngler(Fish hook) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Location location = hook.getLocation();
|
Biome biome = player.getLocation().getBlock().getBiome();
|
||||||
Biome biome = location.getBlock().getBiome();
|
|
||||||
double biteChance = hook.getBiteChance();
|
double biteChance = hook.getBiteChance();
|
||||||
|
|
||||||
mcMMOPlayer.setHookLocation(location);
|
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
@@ -432,7 +429,6 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
Misc.dropItem(target.getLocation(), drop);
|
Misc.dropItem(target.getLocation(), drop);
|
||||||
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
||||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,11 +451,6 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
|
List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
|
||||||
|
|
||||||
if (fishingTreasures.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
|
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -472,6 +463,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemStack treasureDrop = treasure.getDrop();
|
ItemStack treasureDrop = treasure.getDrop();
|
||||||
|
|
||||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||||
|
|
||||||
if (maxDurability > 0) {
|
if (maxDurability > 0) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class Herbalism {
|
|||||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
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.
|
* 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
|
* @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
|
* @return the number of bonus drops to award from the blocks in this plant
|
||||||
*/
|
*/
|
||||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||||
@@ -92,6 +94,7 @@ public class Herbalism {
|
|||||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBlockCheck() {
|
public boolean canBlockCheck() {
|
||||||
return !(Config.getInstance().getHerbalismPreventAFK() && getPlayer().isInsideVehicle());
|
return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGreenThumbBlock(BlockState blockState) {
|
public boolean canGreenThumbBlock(BlockState blockState) {
|
||||||
@@ -78,8 +78,9 @@ public class HerbalismManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Handle the Farmer's Diet ability
|
* 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
|
* @param eventFoodLevel The initial change in hunger from the event
|
||||||
|
*
|
||||||
* @return the modified change in hunger for the event
|
* @return the modified change in hunger for the event
|
||||||
*/
|
*/
|
||||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||||
@@ -90,6 +91,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* Process the Green Terra ability.
|
* Process the Green Terra ability.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processGreenTerra(BlockState blockState) {
|
public boolean processGreenTerra(BlockState blockState) {
|
||||||
@@ -114,8 +116,6 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
*/
|
*/
|
||||||
public void herbalismBlockCheck(BlockState blockState) {
|
public void herbalismBlockCheck(BlockState blockState) {
|
||||||
@@ -180,6 +180,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* Process the Green Thumb ability for blocks.
|
* Process the Green Thumb ability for blocks.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||||
@@ -195,6 +196,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* Process the Hylian Luck ability.
|
* Process the Hylian Luck ability.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processHylianLuck(BlockState blockState) {
|
public boolean processHylianLuck(BlockState blockState) {
|
||||||
@@ -246,6 +248,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* Process the Shroom Thumb ability.
|
* Process the Shroom Thumb ability.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processShroomThumb(BlockState blockState) {
|
public boolean processShroomThumb(BlockState blockState) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -172,6 +173,7 @@ public class MiningManager extends SkillManager {
|
|||||||
* Increases the blast radius of the explosion.
|
* Increases the blast radius of the explosion.
|
||||||
*
|
*
|
||||||
* @param radius to modify
|
* @param radius to modify
|
||||||
|
*
|
||||||
* @return modified radius
|
* @return modified radius
|
||||||
*/
|
*/
|
||||||
public float biggerBombs(float radius) {
|
public float biggerBombs(float radius) {
|
||||||
@@ -285,10 +287,12 @@ public class MiningManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean blastMiningCooldownOver() {
|
private boolean blastMiningCooldownOver() {
|
||||||
int timeRemaining = mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING);
|
Player player = getPlayer();
|
||||||
|
PlayerProfile profile = getProfile();
|
||||||
|
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player);
|
||||||
|
|
||||||
if (timeRemaining > 0) {
|
if (timeRemaining > 0) {
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,8 +253,9 @@ public class RepairManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Computes repair bonuses.
|
* 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
|
* @param repairAmount The base amount of durability repaired to the item
|
||||||
|
*
|
||||||
* @return The final amount of durability repaired to the item
|
* @return The final amount of durability repaired to the item
|
||||||
*/
|
*/
|
||||||
private short repairCalculate(short durability, int repairAmount) {
|
private short repairCalculate(short durability, int repairAmount) {
|
||||||
@@ -327,7 +328,7 @@ public class RepairManager extends SkillManager {
|
|||||||
int enchantLevel = enchant.getValue();
|
int enchantLevel = enchant.getValue();
|
||||||
|
|
||||||
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
item.addEnchantment(enchantment, enchantLevel - 1);
|
||||||
downgraded = true;
|
downgraded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public enum RepairItemType {
|
|||||||
* Get the base permissions associated with this RepairItemType.
|
* Get the base permissions associated with this RepairItemType.
|
||||||
*
|
*
|
||||||
* @param player The player to check the permissions for
|
* @param player The player to check the permissions for
|
||||||
|
*
|
||||||
* @return true if the player has permissions, false otherwise
|
* @return true if the player has permissions, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getPermissions(Player player) {
|
public boolean getPermissions(Player player) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface Repairable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
|
* 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
|
* 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
|
* @return the minimum number of items
|
||||||
@@ -57,7 +57,7 @@ public interface Repairable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the base repair durability on which to calculate bonuses.
|
* Gets the base repair durability on which to calculate bonuses.
|
||||||
*
|
* <p/>
|
||||||
* This is actually the maximum durability divided by the minimum quantity
|
* This is actually the maximum durability divided by the minimum quantity
|
||||||
*
|
*
|
||||||
* @return the base repair durability
|
* @return the base repair durability
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
* Process the Flux Mining ability.
|
* Process the Flux Mining ability.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
|
*
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processFluxMining(BlockState blockState) {
|
public boolean processFluxMining(BlockState blockState) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
* Handle the effects of the Counter Attack ability
|
* Handle the effects of the Counter Attack ability
|
||||||
*
|
*
|
||||||
* @param attacker The {@link LivingEntity} being affected by the ability
|
* @param attacker The {@link LivingEntity} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public void counterAttackChecks(LivingEntity attacker, double damage) {
|
public void counterAttackChecks(LivingEntity attacker, double damage) {
|
||||||
if (Swords.counterAttackRequiresBlock && !getPlayer().isBlocking()) {
|
if (Swords.counterAttackRequiresBlock && !getPlayer().isBlocking()) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class Taming {
|
|||||||
|
|
||||||
case WOLF:
|
case WOLF:
|
||||||
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
|
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
|
||||||
|
|
||||||
case HORSE:
|
case HORSE:
|
||||||
return LocaleLoader.getString("Taming.Summon.Fail.Horse");
|
return LocaleLoader.getString("Taming.Summon.Fail.Horse");
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.gmail.nossr50.skills.taming;
|
|||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Ocelot;
|
import org.bukkit.entity.Ocelot;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Horse;
|
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -87,7 +87,7 @@ public class TamingManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Apply the Fast Food Service ability.
|
* Apply the Fast Food Service ability.
|
||||||
*
|
*
|
||||||
* @param wolf The wolf using the ability
|
* @param wolf The wolf using the ability
|
||||||
* @param damage The damage being absorbed by the wolf
|
* @param damage The damage being absorbed by the wolf
|
||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, double damage) {
|
public void fastFoodService(Wolf wolf, double damage) {
|
||||||
@@ -108,7 +108,7 @@ public class TamingManager extends SkillManager {
|
|||||||
*
|
*
|
||||||
* @param target The LivingEntity to apply Gore on
|
* @param target The LivingEntity to apply Gore on
|
||||||
* @param damage The initial damage
|
* @param damage The initial damage
|
||||||
* @param wolf The wolf using the ability
|
* @param wolf The wolf using the ability
|
||||||
*/
|
*/
|
||||||
public double gore(LivingEntity target, double damage, Wolf wolf) {
|
public double gore(LivingEntity target, double damage, Wolf wolf) {
|
||||||
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
||||||
@@ -197,7 +197,7 @@ public class TamingManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Handle the Call of the Wild ability.
|
* Handle the Call of the Wild ability.
|
||||||
*
|
*
|
||||||
* @param type The type of entity to summon.
|
* @param type The type of entity to summon.
|
||||||
* @param summonAmount The amount of material needed to summon the entity
|
* @param summonAmount The amount of material needed to summon the entity
|
||||||
*/
|
*/
|
||||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ public class Unarmed {
|
|||||||
|
|
||||||
nextSlot++;
|
nextSlot++;
|
||||||
}
|
}
|
||||||
} else if (firstEmpty != -1) {
|
}
|
||||||
|
else if (firstEmpty != -1) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
dropStack.setAmount(dropAmount);
|
dropStack.setAmount(dropAmount);
|
||||||
inventory.setItem(firstEmpty, dropStack);
|
inventory.setItem(firstEmpty, dropStack);
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* Check Iron Grip ability success
|
* Check Iron Grip ability success
|
||||||
*
|
*
|
||||||
* @param defender The defending player
|
* @param defender The defending player
|
||||||
|
*
|
||||||
* @return true if the defender was not disarmed, false otherwise
|
* @return true if the defender was not disarmed, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean hasIronGrip(Player defender) {
|
private boolean hasIronGrip(Player defender) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public final class Woodcutting {
|
public final class Woodcutting {
|
||||||
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
|
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
|
||||||
@@ -33,15 +32,16 @@ public final class Woodcutting {
|
|||||||
protected enum ExperienceGainMethod {
|
protected enum ExperienceGainMethod {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
TREE_FELLER,
|
TREE_FELLER,
|
||||||
};
|
}
|
||||||
|
|
||||||
private Woodcutting() {}
|
private Woodcutting() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the experience reward from a log
|
* Retrieves the experience reward from a log
|
||||||
*
|
*
|
||||||
* @param blockState Log being broken
|
* @param blockState Log being broken
|
||||||
* @param experienceGainMethod How the log is being broken
|
* @param experienceGainMethod How the log is being broken
|
||||||
|
*
|
||||||
* @return Amount of experience
|
* @return Amount of experience
|
||||||
*/
|
*/
|
||||||
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
||||||
@@ -141,7 +141,7 @@ public final class Woodcutting {
|
|||||||
/**
|
/**
|
||||||
* Processes Tree Feller in a recursive manner
|
* Processes Tree Feller in a recursive manner
|
||||||
*
|
*
|
||||||
* @param blockState Block being checked
|
* @param blockState Block being checked
|
||||||
* @param treeFellerBlocks List of blocks to be removed
|
* @param treeFellerBlocks List of blocks to be removed
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@@ -209,7 +209,8 @@ public final class Woodcutting {
|
|||||||
* Handles the durability loss
|
* Handles the durability loss
|
||||||
*
|
*
|
||||||
* @param treeFellerBlocks List of blocks to be removed
|
* @param treeFellerBlocks List of blocks to be removed
|
||||||
* @param inHand tool being used
|
* @param inHand tool being used
|
||||||
|
*
|
||||||
* @return True if the tool can sustain the durability loss
|
* @return True if the tool can sustain the durability loss
|
||||||
*/
|
*/
|
||||||
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
|
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
|
||||||
@@ -228,8 +229,12 @@ public final class Woodcutting {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillUtils.handleDurabilityChange(inHand, durabilityLoss);
|
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
|
||||||
return (inHand.getDurability() < inHandMaterial.getMaxDurability());
|
short maxDurability = inHandMaterial.getMaxDurability();
|
||||||
|
boolean overMax = (finalDurability >= maxDurability);
|
||||||
|
|
||||||
|
inHand.setDurability(overMax ? maxDurability : finalDurability);
|
||||||
|
return !overMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,12 +242,13 @@ public final class Woodcutting {
|
|||||||
* list of blocks used for future recursive calls of
|
* list of blocks used for future recursive calls of
|
||||||
* 'processTree()'
|
* 'processTree()'
|
||||||
*
|
*
|
||||||
* @param blockState Block to be added
|
* @param blockState Block to be added
|
||||||
* @param futureCenterBlocks List of blocks that will be used to call
|
* @param futureCenterBlocks List of blocks that will be used to call
|
||||||
* 'processTree()'
|
* 'processTree()'
|
||||||
* @param treeFellerBlocks List of blocks to be removed
|
* @param treeFellerBlocks List of blocks to be removed
|
||||||
|
*
|
||||||
* @return true if and only if the given blockState was a Log not already
|
* @return true if and only if the given blockState was a Log not already
|
||||||
* in treeFellerBlocks.
|
* in treeFellerBlocks.
|
||||||
*/
|
*/
|
||||||
private static boolean handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, Set<BlockState> treeFellerBlocks) {
|
private static boolean handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, Set<BlockState> treeFellerBlocks) {
|
||||||
if (treeFellerBlocks.contains(blockState) || mcMMO.getPlaceStore().isTrue(blockState)) {
|
if (treeFellerBlocks.contains(blockState) || mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public final class BlockUtils {
|
|||||||
* Checks to see if a given block awards XP.
|
* Checks to see if a given block awards XP.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block awards XP, false otherwise
|
* @return true if the block awards XP, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean shouldBeWatched(BlockState blockState) {
|
public static boolean shouldBeWatched(BlockState blockState) {
|
||||||
@@ -31,6 +32,7 @@ public final class BlockUtils {
|
|||||||
* Check if a given block should allow for the activation of abilities
|
* Check if a given block should allow for the activation of abilities
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should allow ability activation, false otherwise
|
* @return true if the block should allow ability activation, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canActivateAbilities(BlockState blockState) {
|
public static boolean canActivateAbilities(BlockState blockState) {
|
||||||
@@ -72,6 +74,7 @@ public final class BlockUtils {
|
|||||||
* Check if a given block is an ore
|
* Check if a given block is an ore
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block is an ore, false otherwise
|
* @return true if the block is an ore, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isOre(BlockState blockState) {
|
public static boolean isOre(BlockState blockState) {
|
||||||
@@ -96,6 +99,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block can be made mossy
|
* Determine if a given block can be made mossy
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block can be made mossy, false otherwise
|
* @return true if the block can be made mossy, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canMakeMossy(BlockState blockState) {
|
public static boolean canMakeMossy(BlockState blockState) {
|
||||||
@@ -119,6 +123,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block should be affected by Green Terra
|
* Determine if a given block should be affected by Green Terra
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should affected by Green Terra, false otherwise
|
* @return true if the block should affected by Green Terra, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByGreenTerra(BlockState blockState) {
|
public static boolean affectedByGreenTerra(BlockState blockState) {
|
||||||
@@ -157,6 +162,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block should be affected by Super Breaker
|
* Determine if a given block should be affected by Super Breaker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should affected by Super Breaker, false otherwise
|
* @return true if the block should affected by Super Breaker, false otherwise
|
||||||
*/
|
*/
|
||||||
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
||||||
@@ -179,6 +185,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block should be affected by Giga Drill Breaker
|
* Determine if a given block should be affected by Giga Drill Breaker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should affected by Giga Drill Breaker, false otherwise
|
* @return true if the block should affected by Giga Drill Breaker, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||||
@@ -203,6 +210,7 @@ public final class BlockUtils {
|
|||||||
* Check if a given block is a log
|
* Check if a given block is a log
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block is a log, false otherwise
|
* @return true if the block is a log, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLog(BlockState blockState) {
|
public static boolean isLog(BlockState blockState) {
|
||||||
@@ -221,6 +229,7 @@ public final class BlockUtils {
|
|||||||
* Check if a given block is a leaf
|
* Check if a given block is a leaf
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block is a leaf, false otherwise
|
* @return true if the block is a leaf, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeaves(BlockState blockState) {
|
public static boolean isLeaves(BlockState blockState) {
|
||||||
@@ -237,6 +246,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block should be affected by Flux Mining
|
* Determine if a given block should be affected by Flux Mining
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should affected by Flux Mining, false otherwise
|
* @return true if the block should affected by Flux Mining, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByFluxMining(BlockState blockState) {
|
public static boolean affectedByFluxMining(BlockState blockState) {
|
||||||
@@ -254,6 +264,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block can activate Herbalism abilities
|
* Determine if a given block can activate Herbalism abilities
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block can be activate Herbalism abilities, false otherwise
|
* @return true if the block can be activate Herbalism abilities, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canActivateHerbalism(BlockState blockState) {
|
public static boolean canActivateHerbalism(BlockState blockState) {
|
||||||
@@ -272,6 +283,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block should be affected by Block Cracker
|
* Determine if a given block should be affected by Block Cracker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block should affected by Block Cracker, false otherwise
|
* @return true if the block should affected by Block Cracker, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByBlockCracker(BlockState blockState) {
|
public static boolean affectedByBlockCracker(BlockState blockState) {
|
||||||
@@ -288,6 +300,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block can be made into Mycelium
|
* Determine if a given block can be made into Mycelium
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block can be made in Mycelium, false otherwise
|
* @return true if the block can be made in Mycelium, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canMakeShroomy(BlockState blockState) {
|
public static boolean canMakeShroomy(BlockState blockState) {
|
||||||
@@ -305,6 +318,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block is an mcMMO anvil
|
* Determine if a given block is an mcMMO anvil
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
*
|
||||||
* @return true if the block is an mcMMO anvil, false otherwise
|
* @return true if the block is an mcMMO anvil, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMcMMOAnvil(BlockState blockState) {
|
public static boolean isMcMMOAnvil(BlockState blockState) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public final class ChimaeraWing {
|
|||||||
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
|
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
|
||||||
int cooldown = Config.getInstance().getChimaeraCooldown();
|
int cooldown = Config.getInstance().getChimaeraCooldown();
|
||||||
|
|
||||||
if (cooldown > 0 ) {
|
if (cooldown > 0) {
|
||||||
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
|
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
|
||||||
|
|
||||||
if (timeRemaining > 0) {
|
if (timeRemaining > 0) {
|
||||||
|
|||||||
@@ -68,9 +68,10 @@ public class EventUtils {
|
|||||||
/**
|
/**
|
||||||
* Simulate a block break event.
|
* Simulate a block break event.
|
||||||
*
|
*
|
||||||
* @param block The block to break
|
* @param block The block to break
|
||||||
* @param player The player breaking the block
|
* @param player The player breaking the block
|
||||||
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
||||||
|
*
|
||||||
* @return true if the event wasn't cancelled, false otherwise
|
* @return true if the event wasn't cancelled, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) {
|
public static boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) {
|
||||||
@@ -119,7 +120,7 @@ public class EventUtils {
|
|||||||
profile.setSkillXpLevel(skill, profile.getSkillXpLevelRaw(skill) + event.getRawXpGained());
|
profile.setSkillXpLevel(skill, profile.getSkillXpLevelRaw(skill) + event.getRawXpGained());
|
||||||
}
|
}
|
||||||
|
|
||||||
return !isCancelled;
|
return isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, AbilityType ability) {
|
public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, AbilityType ability) {
|
||||||
|
|||||||
@@ -19,27 +19,22 @@ public final class HardcoreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||||
int totalLevelsLost = 0;
|
int totalLost = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||||
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
||||||
int playerSkillXpLevel = playerProfile.getSkillXpLevel(skillType);
|
|
||||||
|
|
||||||
if (playerSkillLevel <= 0) {
|
if (playerSkillLevel <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double statsLost = playerSkillLevel * (statLossPercentage * 0.01D);
|
int levelsLost = (int) (playerSkillLevel * (statLossPercentage * 0.01D));
|
||||||
int levelsLost = (int) statsLost;
|
totalLost += levelsLost;
|
||||||
int xpLost = (int) Math.floor(playerSkillXpLevel * (statsLost - levelsLost));
|
|
||||||
|
|
||||||
totalLevelsLost += levelsLost;
|
|
||||||
|
|
||||||
playerProfile.modifySkill(skillType, playerSkillLevel - levelsLost);
|
playerProfile.modifySkill(skillType, playerSkillLevel - levelsLost);
|
||||||
playerProfile.removeXp(skillType, xpLost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PlayerDeath", totalLevelsLost));
|
player.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PlayerDeath", totalLost));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invokeVampirism(Player killer, Player victim) {
|
public static void invokeVampirism(Player killer, Player victim) {
|
||||||
@@ -51,7 +46,7 @@ public final class HardcoreManager {
|
|||||||
|
|
||||||
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
|
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
|
||||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||||
int totalLevelsStolen = 0;
|
int totalStolen = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||||
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
||||||
@@ -61,24 +56,16 @@ public final class HardcoreManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int victimSkillXpLevel = victimProfile.getSkillXpLevel(skillType);
|
int levelsStolen = (int) (victimSkillLevel * (vampirismStatLeechPercentage * 0.01D));
|
||||||
|
totalStolen += levelsStolen;
|
||||||
double statsStolen = victimSkillLevel * (vampirismStatLeechPercentage * 0.01D);
|
|
||||||
int levelsStolen = (int) statsStolen;
|
|
||||||
int xpStolen = (int) Math.floor(victimSkillXpLevel * (statsStolen - levelsStolen));
|
|
||||||
|
|
||||||
totalLevelsStolen += levelsStolen;
|
|
||||||
|
|
||||||
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
||||||
killerProfile.addExperience(skillType, xpStolen);
|
|
||||||
|
|
||||||
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
||||||
victimProfile.removeXp(skillType, xpStolen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalLevelsStolen > 0) {
|
if (totalStolen > 0) {
|
||||||
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Success", totalLevelsStolen, victim.getName()));
|
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Success", totalStolen, victim.getName()));
|
||||||
victim.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Victim.Success", killer.getName(), totalLevelsStolen));
|
victim.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Victim.Success", killer.getName(), totalStolen));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Failure", victim.getName()));
|
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Failure", victim.getName()));
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ import java.io.FileReader;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -25,48 +26,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public final class HolidayManager {
|
public final class HolidayManager {
|
||||||
static String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary";
|
|
||||||
private static ArrayList<String> hasCelebrated;
|
private static ArrayList<String> hasCelebrated;
|
||||||
|
private static final Random rand = new Random();
|
||||||
private static final List<Color> ALL_COLORS;
|
|
||||||
private static final List<ChatColor> ALL_CHAT_COLORS;
|
|
||||||
private static final List<ChatColor> CHAT_FORMATS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<Color> colors = new ArrayList<Color>();
|
|
||||||
List<ChatColor> chatColors = new ArrayList<ChatColor>();
|
|
||||||
List<ChatColor> chatFormats = new ArrayList<ChatColor>();
|
|
||||||
|
|
||||||
for (ChatColor color : ChatColor.values()) {
|
|
||||||
if (color.isColor()) {
|
|
||||||
chatColors.add(color);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chatFormats.add(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DyeColor color : DyeColor.values()) {
|
|
||||||
colors.add(color.getFireworkColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.shuffle(chatColors, Misc.getRandom());
|
|
||||||
Collections.shuffle(colors, Misc.getRandom());
|
|
||||||
Collections.shuffle(chatFormats, Misc.getRandom());
|
|
||||||
|
|
||||||
ALL_CHAT_COLORS = ImmutableList.copyOf(chatColors);
|
|
||||||
ALL_COLORS = ImmutableList.copyOf(colors);
|
|
||||||
CHAT_FORMATS = ImmutableList.copyOf(chatFormats);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HolidayManager() {}
|
private HolidayManager() {}
|
||||||
|
|
||||||
// This gets called onEnable
|
// This gets called onEnable
|
||||||
public static void createAnniversaryFile() {
|
public static void createAnniversaryFile() {
|
||||||
File anniversaryFile = new File(anniversaryFilePath);
|
File anniversaryFile = new File(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary");
|
||||||
|
|
||||||
if (!anniversaryFile.exists()) {
|
if (!anniversaryFile.exists()) {
|
||||||
try {
|
try {
|
||||||
@@ -81,7 +50,7 @@ public final class HolidayManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
hasCelebrated.clear();
|
hasCelebrated.clear();
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(anniversaryFilePath));
|
BufferedReader reader = new BufferedReader(new FileReader(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
@@ -99,7 +68,7 @@ public final class HolidayManager {
|
|||||||
// This gets called onDisable
|
// This gets called onDisable
|
||||||
public static void saveAnniversaryFiles() {
|
public static void saveAnniversaryFiles() {
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath));
|
BufferedWriter writer = new BufferedWriter(new FileWriter(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
||||||
for (String player : hasCelebrated) {
|
for (String player : hasCelebrated) {
|
||||||
writer.write(player);
|
writer.write(player);
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
@@ -134,7 +103,7 @@ public final class HolidayManager {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
final int firework_amount = 10;
|
final int firework_amount = 10;
|
||||||
for (int i = 0; i < firework_amount; i++) {
|
for (int i = 0; i < firework_amount; i++) {
|
||||||
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
|
int delay = (int) (rand.nextDouble() * 3 * 20) + 4;
|
||||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -170,7 +139,18 @@ public final class HolidayManager {
|
|||||||
* b i k
|
* b i k
|
||||||
* b i k
|
* b i k
|
||||||
*/
|
*/
|
||||||
Object[] colorParams = new Object[]{chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose()};
|
String colorA = chatColorChoose();
|
||||||
|
String colorB = chatColorChoose();
|
||||||
|
String colorC = chatColorChoose();
|
||||||
|
String colorD = chatColorChoose();
|
||||||
|
String colorE = chatColorChoose();
|
||||||
|
String colorF = chatColorChoose();
|
||||||
|
String colorG = chatColorChoose();
|
||||||
|
String colorH = chatColorChoose();
|
||||||
|
String colorI = chatColorChoose();
|
||||||
|
String colorJ = chatColorChoose();
|
||||||
|
String colorK = chatColorChoose();
|
||||||
|
Object[] colorParams = new Object[]{colorA, colorB, colorC, colorD, colorE, colorF, colorG, colorH, colorI, colorJ, colorK};
|
||||||
sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
|
sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
|
||||||
sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
|
sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
|
||||||
sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
|
sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
|
||||||
@@ -190,32 +170,93 @@ public final class HolidayManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void spawnFireworks(Player player) {
|
private static void spawnFireworks(Player player) {
|
||||||
int power = (int) (Misc.getRandom().nextDouble() * 3) + 1;
|
int power = (int) (rand.nextDouble() * 3) + 1;
|
||||||
Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
|
int type = (int) (rand.nextDouble() * 5) + 1;
|
||||||
double varX = Misc.getRandom().nextGaussian() * 3;
|
double varX = rand.nextGaussian() * 3;
|
||||||
double varZ = Misc.getRandom().nextGaussian() * 3;
|
double varZ = rand.nextGaussian() * 3;
|
||||||
|
|
||||||
|
Type typen;
|
||||||
|
switch (type) {
|
||||||
|
case 2:
|
||||||
|
typen = Type.BALL_LARGE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
typen = Type.BURST;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
typen = Type.CREEPER;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
typen = Type.STAR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
typen = Type.BALL;
|
||||||
|
}
|
||||||
|
|
||||||
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
|
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
|
||||||
FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
|
FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
|
||||||
FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
|
FireworkEffect effect = FireworkEffect.builder().flicker(rand.nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(typen).trail(rand.nextBoolean()).build();
|
||||||
fireworkmeta.addEffect(effect);
|
fireworkmeta.addEffect(effect);
|
||||||
fireworkmeta.setPower(power);
|
fireworkmeta.setPower(power);
|
||||||
fireworks.setFireworkMeta(fireworkmeta);
|
fireworks.setFireworkMeta(fireworkmeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Color> colorChoose() {
|
private static List<Color> colorChoose() {
|
||||||
return ALL_COLORS.subList(0, Math.max(Misc.getRandom().nextInt(ALL_COLORS.size() + 1), 1));
|
// Thanks Zomis and Tejpbit for the help with this function!
|
||||||
|
Collections.shuffle(ALL_COLORS, rand);
|
||||||
|
|
||||||
|
int numberOfColors = rand.nextInt(ALL_COLORS.size());
|
||||||
|
List<Color> choosenColors = ALL_COLORS.subList(0, numberOfColors);
|
||||||
|
|
||||||
|
return new ArrayList<Color>(choosenColors); // don't let caller modify ALL_COLORS
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String chatColorChoose() {
|
private static String chatColorChoose() {
|
||||||
StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(Misc.getRandom().nextInt(ALL_CHAT_COLORS.size())).toString());
|
StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(rand.nextInt(ALL_CHAT_COLORS.size())).toString());
|
||||||
|
|
||||||
for (ChatColor chatFormat : CHAT_FORMATS) {
|
for (ChatColor CHAT_FORMAT : CHAT_FORMATS) {
|
||||||
if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
|
if (rand.nextInt(4) == 0) {
|
||||||
ret.append(chatFormat);
|
ret.append(CHAT_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final List<Color> ALL_COLORS;
|
||||||
|
private static final List<ChatColor> ALL_CHAT_COLORS;
|
||||||
|
private static final ChatColor[] CHAT_FORMATS = new ChatColor[]{ChatColor.BOLD, ChatColor.ITALIC, ChatColor.UNDERLINE, ChatColor.STRIKETHROUGH};
|
||||||
|
|
||||||
|
static {
|
||||||
|
ALL_COLORS = Arrays.asList(
|
||||||
|
Color.AQUA,
|
||||||
|
Color.BLACK,
|
||||||
|
Color.BLUE,
|
||||||
|
Color.FUCHSIA,
|
||||||
|
Color.GRAY,
|
||||||
|
Color.GREEN,
|
||||||
|
Color.LIME,
|
||||||
|
Color.MAROON,
|
||||||
|
Color.NAVY,
|
||||||
|
Color.OLIVE,
|
||||||
|
Color.ORANGE,
|
||||||
|
Color.PURPLE,
|
||||||
|
Color.RED,
|
||||||
|
Color.SILVER,
|
||||||
|
Color.TEAL,
|
||||||
|
Color.WHITE,
|
||||||
|
Color.YELLOW
|
||||||
|
);
|
||||||
|
ALL_CHAT_COLORS = new ArrayList<ChatColor>(16);
|
||||||
|
for (ChatColor c : ChatColor.values()) {
|
||||||
|
if (c.isColor()) {
|
||||||
|
ALL_CHAT_COLORS.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.shuffle(ALL_CHAT_COLORS, rand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a bow.
|
* Checks if the item is a bow.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a bow, false otherwise
|
* @return true if the item is a bow, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isBow(ItemStack item) {
|
public static boolean isBow(ItemStack item) {
|
||||||
@@ -37,6 +38,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a sword.
|
* Checks if the item is a sword.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a sword, false otherwise
|
* @return true if the item is a sword, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isSword(ItemStack item) {
|
public static boolean isSword(ItemStack item) {
|
||||||
@@ -59,6 +61,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a hoe.
|
* Checks if the item is a hoe.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a hoe, false otherwise
|
* @return true if the item is a hoe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHoe(ItemStack item) {
|
public static boolean isHoe(ItemStack item) {
|
||||||
@@ -81,6 +84,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a shovel.
|
* Checks if the item is a shovel.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a shovel, false otherwise
|
* @return true if the item is a shovel, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isShovel(ItemStack item) {
|
public static boolean isShovel(ItemStack item) {
|
||||||
@@ -103,6 +107,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is an axe.
|
* Checks if the item is an axe.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is an axe, false otherwise
|
* @return true if the item is an axe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isAxe(ItemStack item) {
|
public static boolean isAxe(ItemStack item) {
|
||||||
@@ -125,6 +130,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a pickaxe.
|
* Checks if the item is a pickaxe.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a pickaxe, false otherwise
|
* @return true if the item is a pickaxe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isPickaxe(ItemStack item) {
|
public static boolean isPickaxe(ItemStack item) {
|
||||||
@@ -147,6 +153,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a helmet.
|
* Checks if the item is a helmet.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a helmet, false otherwise
|
* @return true if the item is a helmet, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHelmet(ItemStack item) {
|
public static boolean isHelmet(ItemStack item) {
|
||||||
@@ -169,6 +176,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a chestplate.
|
* Checks if the item is a chestplate.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a chestplate, false otherwise
|
* @return true if the item is a chestplate, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isChestplate(ItemStack item) {
|
public static boolean isChestplate(ItemStack item) {
|
||||||
@@ -191,6 +199,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a pair of pants.
|
* Checks if the item is a pair of pants.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a pair of pants, false otherwise
|
* @return true if the item is a pair of pants, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeggings(ItemStack item) {
|
public static boolean isLeggings(ItemStack item) {
|
||||||
@@ -213,6 +222,7 @@ public class ItemUtils {
|
|||||||
* Checks if the item is a pair of boots.
|
* Checks if the item is a pair of boots.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a pair of boots, false otherwise
|
* @return true if the item is a pair of boots, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isBoots(ItemStack item) {
|
public static boolean isBoots(ItemStack item) {
|
||||||
@@ -235,6 +245,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a wearable armor piece.
|
* Checks to see if an item is a wearable armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is armor, false otherwise
|
* @return true if the item is armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isArmor(ItemStack item) {
|
public static boolean isArmor(ItemStack item) {
|
||||||
@@ -245,6 +256,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a wearable *vanilla* armor piece.
|
* Checks to see if an item is a wearable *vanilla* armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is armor, false otherwise
|
* @return true if the item is armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMinecraftArmor(ItemStack item) {
|
public static boolean isMinecraftArmor(ItemStack item) {
|
||||||
@@ -255,6 +267,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a leather armor piece.
|
* Checks to see if an item is a leather armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is leather armor, false otherwise
|
* @return true if the item is leather armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeatherArmor(ItemStack item) {
|
public static boolean isLeatherArmor(ItemStack item) {
|
||||||
@@ -274,6 +287,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a gold armor piece.
|
* Checks to see if an item is a gold armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is gold armor, false otherwise
|
* @return true if the item is gold armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isGoldArmor(ItemStack item) {
|
public static boolean isGoldArmor(ItemStack item) {
|
||||||
@@ -293,6 +307,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is an iron armor piece.
|
* Checks to see if an item is an iron armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is iron armor, false otherwise
|
* @return true if the item is iron armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isIronArmor(ItemStack item) {
|
public static boolean isIronArmor(ItemStack item) {
|
||||||
@@ -312,6 +327,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a diamond armor piece.
|
* Checks to see if an item is a diamond armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is diamond armor, false otherwise
|
* @return true if the item is diamond armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDiamondArmor(ItemStack item) {
|
public static boolean isDiamondArmor(ItemStack item) {
|
||||||
@@ -331,6 +347,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a chainmail armor piece.
|
* Checks to see if an item is a chainmail armor piece.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is chainmail armor, false otherwise
|
* @return true if the item is chainmail armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isChainmailArmor(ItemStack item) {
|
public static boolean isChainmailArmor(ItemStack item) {
|
||||||
@@ -350,6 +367,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a *vanilla* tool.
|
* Checks to see if an item is a *vanilla* tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a tool, false otherwise
|
* @return true if the item is a tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMinecraftTool(ItemStack item) {
|
public static boolean isMinecraftTool(ItemStack item) {
|
||||||
@@ -360,6 +378,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a stone tool.
|
* Checks to see if an item is a stone tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a stone tool, false otherwise
|
* @return true if the item is a stone tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isStoneTool(ItemStack item) {
|
public static boolean isStoneTool(ItemStack item) {
|
||||||
@@ -380,6 +399,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a wooden tool.
|
* Checks to see if an item is a wooden tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a wooden tool, false otherwise
|
* @return true if the item is a wooden tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isWoodTool(ItemStack item) {
|
public static boolean isWoodTool(ItemStack item) {
|
||||||
@@ -400,6 +420,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a string tool.
|
* Checks to see if an item is a string tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a string tool, false otherwise
|
* @return true if the item is a string tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isStringTool(ItemStack item) {
|
public static boolean isStringTool(ItemStack item) {
|
||||||
@@ -418,6 +439,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a gold tool.
|
* Checks to see if an item is a gold tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a stone tool, false otherwise
|
* @return true if the item is a stone tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isGoldTool(ItemStack item) {
|
public static boolean isGoldTool(ItemStack item) {
|
||||||
@@ -438,6 +460,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is an iron tool.
|
* Checks to see if an item is an iron tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is an iron tool, false otherwise
|
* @return true if the item is an iron tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isIronTool(ItemStack item) {
|
public static boolean isIronTool(ItemStack item) {
|
||||||
@@ -461,6 +484,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a diamond tool.
|
* Checks to see if an item is a diamond tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a diamond tool, false otherwise
|
* @return true if the item is a diamond tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDiamondTool(ItemStack item) {
|
public static boolean isDiamondTool(ItemStack item) {
|
||||||
@@ -481,6 +505,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is enchantable.
|
* Checks to see if an item is enchantable.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is enchantable, false otherwise
|
* @return true if the item is enchantable, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isEnchantable(ItemStack item) {
|
public static boolean isEnchantable(ItemStack item) {
|
||||||
@@ -545,6 +570,7 @@ public class ItemUtils {
|
|||||||
* Check if an item is sharable.
|
* Check if an item is sharable.
|
||||||
*
|
*
|
||||||
* @param item Item that will get shared
|
* @param item Item that will get shared
|
||||||
|
*
|
||||||
* @return True if the item can be shared.
|
* @return True if the item can be shared.
|
||||||
*/
|
*/
|
||||||
public static boolean isSharable(ItemStack item) {
|
public static boolean isSharable(ItemStack item) {
|
||||||
@@ -559,6 +585,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a mining drop.
|
* Checks to see if an item is a mining drop.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a mining drop, false otherwise
|
* @return true if the item is a mining drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMiningDrop(ItemStack item) {
|
public static boolean isMiningDrop(ItemStack item) {
|
||||||
@@ -591,6 +618,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a herbalism drop.
|
* Checks to see if an item is a herbalism drop.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a herbalism drop, false otherwise
|
* @return true if the item is a herbalism drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHerbalismDrop(ItemStack item) {
|
public static boolean isHerbalismDrop(ItemStack item) {
|
||||||
@@ -626,6 +654,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a mob drop.
|
* Checks to see if an item is a mob drop.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a mob drop, false otherwise
|
* @return true if the item is a mob drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMobDrop(ItemStack item) {
|
public static boolean isMobDrop(ItemStack item) {
|
||||||
@@ -668,6 +697,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a woodcutting drop.
|
* Checks to see if an item is a woodcutting drop.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a woodcutting drop, false otherwise
|
* @return true if the item is a woodcutting drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isWoodcuttingDrop(ItemStack item) {
|
public static boolean isWoodcuttingDrop(ItemStack item) {
|
||||||
@@ -687,6 +717,7 @@ public class ItemUtils {
|
|||||||
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
|
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a miscellaneous drop, false otherwise
|
* @return true if the item is a miscellaneous drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMiscDrop(ItemStack item) {
|
public static boolean isMiscDrop(ItemStack item) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public final class Misc {
|
|||||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||||
public static final int TICK_CONVERSION_FACTOR = 20;
|
public static final int TICK_CONVERSION_FACTOR = 20;
|
||||||
|
|
||||||
public static final long PLAYER_DATABASE_COOLDOWN_MILLIS = 1750;
|
|
||||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ public final class Misc {
|
|||||||
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
|
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
|
||||||
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
|
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
|
||||||
|
|
||||||
private Misc() {};
|
private Misc() {}
|
||||||
|
|
||||||
public static float getFizzPitch() {
|
public static float getFizzPitch() {
|
||||||
return 2.6F + (getRandom().nextFloat() - getRandom().nextFloat()) * 0.8F;
|
return 2.6F + (getRandom().nextFloat() - getRandom().nextFloat()) * 0.8F;
|
||||||
@@ -70,6 +69,7 @@ public final class Misc {
|
|||||||
* Get the upgrade tier of the item in hand.
|
* Get the upgrade tier of the item in hand.
|
||||||
*
|
*
|
||||||
* @param inHand The item to check the tier of
|
* @param inHand The item to check the tier of
|
||||||
|
*
|
||||||
* @return the tier of the item
|
* @return the tier of the item
|
||||||
*/
|
*/
|
||||||
public static int getTier(ItemStack inHand) {
|
public static int getTier(ItemStack inHand) {
|
||||||
@@ -100,9 +100,10 @@ public final class Misc {
|
|||||||
/**
|
/**
|
||||||
* Determine if two locations are near each other.
|
* Determine if two locations are near each other.
|
||||||
*
|
*
|
||||||
* @param first The first location
|
* @param first The first location
|
||||||
* @param second The second location
|
* @param second The second location
|
||||||
* @param maxDistance The max distance apart
|
* @param maxDistance The max distance apart
|
||||||
|
*
|
||||||
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
|
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isNear(Location first, Location second, double maxDistance) {
|
public static boolean isNear(Location first, Location second, double maxDistance) {
|
||||||
@@ -123,7 +124,7 @@ public final class Misc {
|
|||||||
* Drop items at a given location.
|
* Drop items at a given location.
|
||||||
*
|
*
|
||||||
* @param location The location to drop the items at
|
* @param location The location to drop the items at
|
||||||
* @param is The items to drop
|
* @param is The items to drop
|
||||||
* @param quantity The amount of items to drop
|
* @param quantity The amount of items to drop
|
||||||
*/
|
*/
|
||||||
public static void dropItems(Location location, ItemStack is, int quantity) {
|
public static void dropItems(Location location, ItemStack is, int quantity) {
|
||||||
@@ -136,8 +137,8 @@ public final class Misc {
|
|||||||
* Randomly drop an item at a given location.
|
* Randomly drop an item at a given location.
|
||||||
*
|
*
|
||||||
* @param location The location to drop the items at
|
* @param location The location to drop the items at
|
||||||
* @param is The item to drop
|
* @param is The item to drop
|
||||||
* @param chance The percentage chance for the item to drop
|
* @param chance The percentage chance for the item to drop
|
||||||
*/
|
*/
|
||||||
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
||||||
if (random.nextInt(100) < chance) {
|
if (random.nextInt(100) < chance) {
|
||||||
@@ -149,7 +150,7 @@ public final class Misc {
|
|||||||
* Drop items with random quantity at a given location.
|
* Drop items with random quantity at a given location.
|
||||||
*
|
*
|
||||||
* @param location The location to drop the items at
|
* @param location The location to drop the items at
|
||||||
* @param is The item to drop
|
* @param is The item to drop
|
||||||
* @param quantity The amount of items to drop
|
* @param quantity The amount of items to drop
|
||||||
*/
|
*/
|
||||||
public static void randomDropItems(Location location, ItemStack is, int quantity) {
|
public static void randomDropItems(Location location, ItemStack is, int quantity) {
|
||||||
@@ -170,7 +171,7 @@ public final class Misc {
|
|||||||
/**
|
/**
|
||||||
* Drop an item at a given location.
|
* Drop an item at a given location.
|
||||||
*
|
*
|
||||||
* @param location The location to drop the item at
|
* @param location The location to drop the item at
|
||||||
* @param itemStack The item to drop
|
* @param itemStack The item to drop
|
||||||
*/
|
*/
|
||||||
public static void dropItem(Location location, ItemStack itemStack) {
|
public static void dropItem(Location location, ItemStack itemStack) {
|
||||||
@@ -199,12 +200,6 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printProgress(int convertedUsers, int progressInterval, long startMillis) {
|
|
||||||
if ((convertedUsers % progressInterval) == 0) {
|
|
||||||
mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resendChunkRadiusAt(Player player, int radius) {
|
public static void resendChunkRadiusAt(Player player, int radius) {
|
||||||
Chunk chunk = player.getLocation().getChunk();
|
Chunk chunk = player.getLocation().getChunk();
|
||||||
int chunkX = chunk.getX();
|
int chunkX = chunk.getX();
|
||||||
@@ -265,11 +260,12 @@ public final class Misc {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
|
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
|
||||||
*
|
* <p/>
|
||||||
* This list is not sorted in any particular order.
|
* This list is not sorted in any particular order.
|
||||||
* If an exact match is found, the returned list will only contain a single result.
|
* If an exact match is found, the returned list will only contain a single result.
|
||||||
*
|
*
|
||||||
* @param partialName Name to match
|
* @param partialName Name to match
|
||||||
|
*
|
||||||
* @return List of all possible names
|
* @return List of all possible names
|
||||||
*/
|
*/
|
||||||
public static List<String> matchPlayer(String partialName) {
|
public static List<String> matchPlayer(String partialName) {
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class MobHealthbarUtils {
|
public final class MobHealthbarUtils {
|
||||||
private MobHealthbarUtils() {};
|
private MobHealthbarUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix issues with death messages caused by the mob healthbars.
|
* Fix issues with death messages caused by the mob healthbars.
|
||||||
*
|
*
|
||||||
* @param deathMessage The original death message
|
* @param deathMessage The original death message
|
||||||
* @param player The player who died
|
* @param player The player who died
|
||||||
|
*
|
||||||
* @return the fixed death message
|
* @return the fixed death message
|
||||||
*/
|
*/
|
||||||
public static String fixDeathMessage(String deathMessage, Player player) {
|
public static String fixDeathMessage(String deathMessage, Player player) {
|
||||||
@@ -158,6 +159,7 @@ public final class MobHealthbarUtils {
|
|||||||
* Check if a given LivingEntity is a boss.
|
* Check if a given LivingEntity is a boss.
|
||||||
*
|
*
|
||||||
* @param livingEntity The {@link LivingEntity} of the livingEntity to check
|
* @param livingEntity The {@link LivingEntity} of the livingEntity to check
|
||||||
|
*
|
||||||
* @return true if the livingEntity is a boss, false otherwise
|
* @return true if the livingEntity is a boss, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isBoss(LivingEntity livingEntity) {
|
public static boolean isBoss(LivingEntity livingEntity) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public final class ModUtils {
|
|||||||
* Get the custom tool associated with an item.
|
* Get the custom tool associated with an item.
|
||||||
*
|
*
|
||||||
* @param item The item to check
|
* @param item The item to check
|
||||||
|
*
|
||||||
* @return the tool if it exists, null otherwise
|
* @return the tool if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||||
@@ -41,6 +42,7 @@ public final class ModUtils {
|
|||||||
* Get the custom entity associated with an entity.
|
* Get the custom entity associated with an entity.
|
||||||
*
|
*
|
||||||
* @param entity The entity to check
|
* @param entity The entity to check
|
||||||
|
*
|
||||||
* @return the entity is if exists, null otherwise
|
* @return the entity is if exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public static CustomEntity getCustomEntity(Entity entity) {
|
public static CustomEntity getCustomEntity(Entity entity) {
|
||||||
@@ -51,6 +53,7 @@ public final class ModUtils {
|
|||||||
* Get the custom block associated with an block.
|
* Get the custom block associated with an block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the bloc to check
|
* @param blockState The BlockState of the bloc to check
|
||||||
|
*
|
||||||
* @return the block if it exists, null otherwise
|
* @return the block if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||||
@@ -61,6 +64,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is a woodcutting block.
|
* Check if a custom block is a woodcutting block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents a custom woodcutting block, false otherwise
|
* @return true if the block represents a custom woodcutting block, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||||
@@ -71,6 +75,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block should not activate abilites.
|
* Check if a custom block should not activate abilites.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents an ability block, false otherwise
|
* @return true if the block represents an ability block, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||||
@@ -81,6 +86,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is a mining block.
|
* Check if a custom block is a mining block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents a custom mining block, false otherwise
|
* @return true if the block represents a custom mining block, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||||
@@ -91,6 +97,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is an excavation block.
|
* Check if a custom block is an excavation block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents a custom excavation block, false otherwise
|
* @return true if the block represents a custom excavation block, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||||
@@ -101,6 +108,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is an herbalism block.
|
* Check if a custom block is an herbalism block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents a custom herbalism block, false otherwise
|
* @return true if the block represents a custom herbalism block, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||||
@@ -111,6 +119,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is a leaf block.
|
* Check if a custom block is a leaf block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents leaves, false otherwise
|
* @return true if the block represents leaves, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||||
@@ -121,6 +130,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is a log block.
|
* Check if a custom block is a log block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents a log, false otherwise
|
* @return true if the block represents a log, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||||
@@ -131,6 +141,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom block is an ore block.
|
* Check if a custom block is an ore block.
|
||||||
*
|
*
|
||||||
* @param blockState The BlockState of the block to check
|
* @param blockState The BlockState of the block to check
|
||||||
|
*
|
||||||
* @return true if the block represents an ore, false otherwise
|
* @return true if the block represents an ore, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomOreBlock(BlockState blockState) {
|
public static boolean isCustomOreBlock(BlockState blockState) {
|
||||||
@@ -141,6 +152,7 @@ public final class ModUtils {
|
|||||||
* Checks to see if an item is a custom tool.
|
* Checks to see if an item is a custom tool.
|
||||||
*
|
*
|
||||||
* @param item Item to check
|
* @param item Item to check
|
||||||
|
*
|
||||||
* @return true if the item is a custom tool, false otherwise
|
* @return true if the item is a custom tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomTool(ItemStack item) {
|
public static boolean isCustomTool(ItemStack item) {
|
||||||
@@ -151,6 +163,7 @@ public final class ModUtils {
|
|||||||
* Checks to see if an entity is a custom entity.
|
* Checks to see if an entity is a custom entity.
|
||||||
*
|
*
|
||||||
* @param entity Entity to check
|
* @param entity Entity to check
|
||||||
|
*
|
||||||
* @return true if the entity is a custom entity, false otherwise
|
* @return true if the entity is a custom entity, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomEntity(Entity entity) {
|
public static boolean isCustomEntity(Entity entity) {
|
||||||
@@ -161,6 +174,7 @@ public final class ModUtils {
|
|||||||
* Check if a custom entity is a boss.
|
* Check if a custom entity is a boss.
|
||||||
*
|
*
|
||||||
* @param entity The entity to check
|
* @param entity The entity to check
|
||||||
|
*
|
||||||
* @return true if the entity represents a boss, false otherwise
|
* @return true if the entity represents a boss, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomBossEntity(Entity entity) {
|
public static boolean isCustomBossEntity(Entity entity) {
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package com.gmail.nossr50.util;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|
||||||
|
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
/**
|
/**
|
||||||
* Gets a capitalized version of the target string.
|
* Gets a capitalized version of the target string.
|
||||||
*
|
*
|
||||||
* @param target String to capitalize
|
* @param target String to capitalize
|
||||||
|
*
|
||||||
* @return the capitalized string
|
* @return the capitalized string
|
||||||
*/
|
*/
|
||||||
public static String getCapitalized(String target) {
|
public static String getCapitalized(String target) {
|
||||||
@@ -24,10 +23,6 @@ public class StringUtils {
|
|||||||
return createPrettyEnumString(entity.toString());
|
return createPrettyEnumString(entity.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrettyAbilityString(AbilityType ability) {
|
|
||||||
return createPrettyEnumString(ability.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String createPrettyEnumString(String baseString) {
|
private static String createPrettyEnumString(String baseString) {
|
||||||
String[] substrings = baseString.split("_");
|
String[] substrings = baseString.split("_");
|
||||||
String prettyString = "";
|
String prettyString = "";
|
||||||
@@ -50,6 +45,7 @@ public class StringUtils {
|
|||||||
* Gets the int represented by this string.
|
* Gets the int represented by this string.
|
||||||
*
|
*
|
||||||
* @param string The string to parse
|
* @param string The string to parse
|
||||||
|
*
|
||||||
* @return the int represented by this string
|
* @return the int represented by this string
|
||||||
*/
|
*/
|
||||||
public static int getInt(String string) {
|
public static int getInt(String string) {
|
||||||
@@ -65,6 +61,7 @@ public class StringUtils {
|
|||||||
* Gets the long represented by this string.
|
* Gets the long represented by this string.
|
||||||
*
|
*
|
||||||
* @param string The string to parse
|
* @param string The string to parse
|
||||||
|
*
|
||||||
* @return the long represented by this string
|
* @return the long represented by this string
|
||||||
*/
|
*/
|
||||||
public static long getLong(String string) {
|
public static long getLong(String string) {
|
||||||
@@ -80,6 +77,7 @@ public class StringUtils {
|
|||||||
* Determine if a string represents an Integer
|
* Determine if a string represents an Integer
|
||||||
*
|
*
|
||||||
* @param string String to check
|
* @param string String to check
|
||||||
|
*
|
||||||
* @return true if the string is an Integer, false otherwise
|
* @return true if the string is an Integer, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isInt(String string) {
|
public static boolean isInt(String string) {
|
||||||
@@ -96,6 +94,7 @@ public class StringUtils {
|
|||||||
* Determine if a string represents a Double
|
* Determine if a string represents a Double
|
||||||
*
|
*
|
||||||
* @param string String to check
|
* @param string String to check
|
||||||
|
*
|
||||||
* @return true if the string is a Double, false otherwise
|
* @return true if the string is a Double, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDouble(String string) {
|
public static boolean isDouble(String string) {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Loads a specific chunklet
|
* Loads a specific chunklet
|
||||||
*
|
*
|
||||||
* @param cx Chunklet X coordinate that needs to be loaded
|
* @param cx Chunklet X coordinate that needs to be loaded
|
||||||
* @param cy Chunklet Y coordinate that needs to be loaded
|
* @param cy Chunklet Y coordinate that needs to be loaded
|
||||||
* @param cz Chunklet Z coordinate that needs to be loaded
|
* @param cz Chunklet Z coordinate that needs to be loaded
|
||||||
* @param world World that the chunklet needs to be loaded in
|
* @param world World that the chunklet needs to be loaded in
|
||||||
*/
|
*/
|
||||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||||
@@ -17,9 +17,9 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Unload a specific chunklet
|
* Unload a specific chunklet
|
||||||
*
|
*
|
||||||
* @param cx Chunklet X coordinate that needs to be unloaded
|
* @param cx Chunklet X coordinate that needs to be unloaded
|
||||||
* @param cy Chunklet Y coordinate that needs to be unloaded
|
* @param cy Chunklet Y coordinate that needs to be unloaded
|
||||||
* @param cz Chunklet Z coordinate that needs to be unloaded
|
* @param cz Chunklet Z coordinate that needs to be unloaded
|
||||||
* @param world World that the chunklet needs to be unloaded from
|
* @param world World that the chunklet needs to be unloaded from
|
||||||
*/
|
*/
|
||||||
public void unloadChunklet(int cx, int cy, int cz, World world);
|
public void unloadChunklet(int cx, int cy, int cz, World world);
|
||||||
@@ -27,8 +27,8 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Load a given Chunk's Chunklet data
|
* Load a given Chunk's Chunklet data
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is to be loaded
|
* @param cx Chunk X coordinate that is to be loaded
|
||||||
* @param cz Chunk Z coordinate that is to be loaded
|
* @param cz Chunk Z coordinate that is to be loaded
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
public void loadChunk(int cx, int cz, World world);
|
public void loadChunk(int cx, int cz, World world);
|
||||||
@@ -36,8 +36,8 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Unload a given Chunk's Chunklet data
|
* Unload a given Chunk's Chunklet data
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is to be unloaded
|
* @param cx Chunk X coordinate that is to be unloaded
|
||||||
* @param cz Chunk Z coordinate that is to be unloaded
|
* @param cz Chunk Z coordinate that is to be unloaded
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
public void unloadChunk(int cx, int cz, World world);
|
public void unloadChunk(int cx, int cz, World world);
|
||||||
@@ -45,8 +45,8 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Informs the ChunkletManager a chunk is loaded
|
* Informs the ChunkletManager a chunk is loaded
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is loaded
|
* @param cx Chunk X coordinate that is loaded
|
||||||
* @param cz Chunk Z coordinate that is loaded
|
* @param cz Chunk Z coordinate that is loaded
|
||||||
* @param world World that the chunk was loaded in
|
* @param world World that the chunk was loaded in
|
||||||
*/
|
*/
|
||||||
public void chunkLoaded(int cx, int cz, World world);
|
public void chunkLoaded(int cx, int cz, World world);
|
||||||
@@ -54,8 +54,8 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Informs the ChunkletManager a chunk is unloaded
|
* Informs the ChunkletManager a chunk is unloaded
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is unloaded
|
* @param cx Chunk X coordinate that is unloaded
|
||||||
* @param cz Chunk Z coordinate that is unloaded
|
* @param cz Chunk Z coordinate that is unloaded
|
||||||
* @param world World that the chunk was unloaded in
|
* @param world World that the chunk was unloaded in
|
||||||
*/
|
*/
|
||||||
public void chunkUnloaded(int cx, int cz, World world);
|
public void chunkUnloaded(int cx, int cz, World world);
|
||||||
@@ -94,10 +94,11 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Check to see if a given location is set to true
|
* Check to see if a given location is set to true
|
||||||
*
|
*
|
||||||
* @param x X coordinate to check
|
* @param x X coordinate to check
|
||||||
* @param y Y coordinate to check
|
* @param y Y coordinate to check
|
||||||
* @param z Z coordinate to check
|
* @param z Z coordinate to check
|
||||||
* @param world World to check in
|
* @param world World to check in
|
||||||
|
*
|
||||||
* @return true if the given location is set to true, false if otherwise
|
* @return true if the given location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(int x, int y, int z, World world);
|
public boolean isTrue(int x, int y, int z, World world);
|
||||||
@@ -106,6 +107,7 @@ public interface ChunkletManager {
|
|||||||
* Check to see if a given block location is set to true
|
* Check to see if a given block location is set to true
|
||||||
*
|
*
|
||||||
* @param block Block location to check
|
* @param block Block location to check
|
||||||
|
*
|
||||||
* @return true if the given block location is set to true, false if otherwise
|
* @return true if the given block location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(Block block);
|
public boolean isTrue(Block block);
|
||||||
@@ -113,9 +115,9 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||||
*
|
*
|
||||||
* @param x X coordinate to set
|
* @param x X coordinate to set
|
||||||
* @param y Y coordinate to set
|
* @param y Y coordinate to set
|
||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
public void setTrue(int x, int y, int z, World world);
|
public void setTrue(int x, int y, int z, World world);
|
||||||
@@ -130,9 +132,9 @@ public interface ChunkletManager {
|
|||||||
/**
|
/**
|
||||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||||
*
|
*
|
||||||
* @param x X coordinate to set
|
* @param x X coordinate to set
|
||||||
* @param y Y coordinate to set
|
* @param y Y coordinate to set
|
||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
public void setFalse(int x, int y, int z, World world);
|
public void setFalse(int x, int y, int z, World world);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public interface ChunkletStore extends Serializable {
|
|||||||
* @param x x coordinate in current chunklet
|
* @param x x coordinate in current chunklet
|
||||||
* @param y y coordinate in current chunklet
|
* @param y y coordinate in current chunklet
|
||||||
* @param z z coordinate in current chunklet
|
* @param z z coordinate in current chunklet
|
||||||
|
*
|
||||||
* @return true if the value is true at the given coordinates, false if otherwise
|
* @return true if the value is true at the given coordinates, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(int x, int y, int z);
|
public boolean isTrue(int x, int y, int z);
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cStore ChunkletStore to save
|
* @param cStore ChunkletStore to save
|
||||||
* @param location Where on the disk to put it
|
* @param location Where on the disk to put it
|
||||||
*/
|
*/
|
||||||
private void serializeChunkletStore(ChunkletStore cStore, File location) {
|
private void serializeChunkletStore(ChunkletStore cStore, File location) {
|
||||||
@@ -345,6 +345,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param location Where on the disk to read from
|
* @param location Where on the disk to read from
|
||||||
|
*
|
||||||
* @return ChunkletStore from the specified location
|
* @return ChunkletStore from the specified location
|
||||||
*/
|
*/
|
||||||
private ChunkletStore deserializeChunkletStore(File location) {
|
private ChunkletStore deserializeChunkletStore(File location) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bukkit.block.Block;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A ChunkletManager implementation that does nothing and returns false for all checks.
|
* A ChunkletManager implementation that does nothing and returns false for all checks.
|
||||||
*
|
* <p/>
|
||||||
* Useful for turning off Chunklets without actually doing much work
|
* Useful for turning off Chunklets without actually doing much work
|
||||||
*/
|
*/
|
||||||
public class NullChunkletManager implements ChunkletManager {
|
public class NullChunkletManager implements ChunkletManager {
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Loads a specific chunklet
|
* Loads a specific chunklet
|
||||||
*
|
*
|
||||||
* @param cx Chunklet X coordinate that needs to be loaded
|
* @param cx Chunklet X coordinate that needs to be loaded
|
||||||
* @param cy Chunklet Y coordinate that needs to be loaded
|
* @param cy Chunklet Y coordinate that needs to be loaded
|
||||||
* @param cz Chunklet Z coordinate that needs to be loaded
|
* @param cz Chunklet Z coordinate that needs to be loaded
|
||||||
* @param world World that the chunklet needs to be loaded in
|
* @param world World that the chunklet needs to be loaded in
|
||||||
*/
|
*/
|
||||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||||
@@ -29,9 +29,9 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Unload a specific chunklet
|
* Unload a specific chunklet
|
||||||
*
|
*
|
||||||
* @param cx Chunklet X coordinate that needs to be unloaded
|
* @param cx Chunklet X coordinate that needs to be unloaded
|
||||||
* @param cy Chunklet Y coordinate that needs to be unloaded
|
* @param cy Chunklet Y coordinate that needs to be unloaded
|
||||||
* @param cz Chunklet Z coordinate that needs to be unloaded
|
* @param cz Chunklet Z coordinate that needs to be unloaded
|
||||||
* @param world World that the chunklet needs to be unloaded from
|
* @param world World that the chunklet needs to be unloaded from
|
||||||
*/
|
*/
|
||||||
public void unloadChunklet(int cx, int cy, int cz, World world);
|
public void unloadChunklet(int cx, int cy, int cz, World world);
|
||||||
@@ -39,8 +39,8 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Load a given Chunk's Chunklet data
|
* Load a given Chunk's Chunklet data
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is to be loaded
|
* @param cx Chunk X coordinate that is to be loaded
|
||||||
* @param cz Chunk Z coordinate that is to be loaded
|
* @param cz Chunk Z coordinate that is to be loaded
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
public void loadChunk(int cx, int cz, World world, Entity[] entities);
|
public void loadChunk(int cx, int cz, World world, Entity[] entities);
|
||||||
@@ -48,8 +48,8 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Unload a given Chunk's Chunklet data
|
* Unload a given Chunk's Chunklet data
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is to be unloaded
|
* @param cx Chunk X coordinate that is to be unloaded
|
||||||
* @param cz Chunk Z coordinate that is to be unloaded
|
* @param cz Chunk Z coordinate that is to be unloaded
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
public void unloadChunk(int cx, int cz, World world);
|
public void unloadChunk(int cx, int cz, World world);
|
||||||
@@ -57,8 +57,8 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Saves a given Chunk's Chunklet data
|
* Saves a given Chunk's Chunklet data
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is to be saved
|
* @param cx Chunk X coordinate that is to be saved
|
||||||
* @param cz Chunk Z coordinate that is to be saved
|
* @param cz Chunk Z coordinate that is to be saved
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
public void saveChunk(int cx, int cz, World world);
|
public void saveChunk(int cx, int cz, World world);
|
||||||
@@ -68,8 +68,8 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Informs the ChunkletManager a chunk is loaded
|
* Informs the ChunkletManager a chunk is loaded
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is loaded
|
* @param cx Chunk X coordinate that is loaded
|
||||||
* @param cz Chunk Z coordinate that is loaded
|
* @param cz Chunk Z coordinate that is loaded
|
||||||
* @param world World that the chunk was loaded in
|
* @param world World that the chunk was loaded in
|
||||||
*/
|
*/
|
||||||
public void chunkLoaded(int cx, int cz, World world);
|
public void chunkLoaded(int cx, int cz, World world);
|
||||||
@@ -77,8 +77,8 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Informs the ChunkletManager a chunk is unloaded
|
* Informs the ChunkletManager a chunk is unloaded
|
||||||
*
|
*
|
||||||
* @param cx Chunk X coordinate that is unloaded
|
* @param cx Chunk X coordinate that is unloaded
|
||||||
* @param cz Chunk Z coordinate that is unloaded
|
* @param cz Chunk Z coordinate that is unloaded
|
||||||
* @param world World that the chunk was unloaded in
|
* @param world World that the chunk was unloaded in
|
||||||
*/
|
*/
|
||||||
public void chunkUnloaded(int cx, int cz, World world);
|
public void chunkUnloaded(int cx, int cz, World world);
|
||||||
@@ -117,10 +117,11 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Check to see if a given location is set to true
|
* Check to see if a given location is set to true
|
||||||
*
|
*
|
||||||
* @param x X coordinate to check
|
* @param x X coordinate to check
|
||||||
* @param y Y coordinate to check
|
* @param y Y coordinate to check
|
||||||
* @param z Z coordinate to check
|
* @param z Z coordinate to check
|
||||||
* @param world World to check in
|
* @param world World to check in
|
||||||
|
*
|
||||||
* @return true if the given location is set to true, false if otherwise
|
* @return true if the given location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(int x, int y, int z, World world);
|
public boolean isTrue(int x, int y, int z, World world);
|
||||||
@@ -129,6 +130,7 @@ public interface ChunkManager {
|
|||||||
* Check to see if a given block location is set to true
|
* Check to see if a given block location is set to true
|
||||||
*
|
*
|
||||||
* @param block Block location to check
|
* @param block Block location to check
|
||||||
|
*
|
||||||
* @return true if the given block location is set to true, false if otherwise
|
* @return true if the given block location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(Block block);
|
public boolean isTrue(Block block);
|
||||||
@@ -137,6 +139,7 @@ public interface ChunkManager {
|
|||||||
* Check to see if a given BlockState location is set to true
|
* Check to see if a given BlockState location is set to true
|
||||||
*
|
*
|
||||||
* @param blockState BlockState to check
|
* @param blockState BlockState to check
|
||||||
|
*
|
||||||
* @return true if the given BlockState location is set to true, false if otherwise
|
* @return true if the given BlockState location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(BlockState blockState);
|
public boolean isTrue(BlockState blockState);
|
||||||
@@ -144,9 +147,9 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||||
*
|
*
|
||||||
* @param x X coordinate to set
|
* @param x X coordinate to set
|
||||||
* @param y Y coordinate to set
|
* @param y Y coordinate to set
|
||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
public void setTrue(int x, int y, int z, World world);
|
public void setTrue(int x, int y, int z, World world);
|
||||||
@@ -168,9 +171,9 @@ public interface ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||||
*
|
*
|
||||||
* @param x X coordinate to set
|
* @param x X coordinate to set
|
||||||
* @param y Y coordinate to set
|
* @param y Y coordinate to set
|
||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
public void setFalse(int x, int y, int z, World world);
|
public void setFalse(int x, int y, int z, World world);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public interface ChunkStore extends Serializable {
|
|||||||
* @param x x coordinate in current chunklet
|
* @param x x coordinate in current chunklet
|
||||||
* @param y y coordinate in current chunklet
|
* @param y y coordinate in current chunklet
|
||||||
* @param z z coordinate in current chunklet
|
* @param z z coordinate in current chunklet
|
||||||
|
*
|
||||||
* @return true if the value is true at the given coordinates, false if otherwise
|
* @return true if the value is true at the given coordinates, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isTrue(int x, int y, int z);
|
public boolean isTrue(int x, int y, int z);
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
try {
|
try {
|
||||||
chunkStore = readChunkStore(world, cx, cz);
|
chunkStore = readChunkStore(world, cx, cz);
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
if (chunkStore == null) {
|
if (chunkStore == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ public class PrimitiveChunkStore implements ChunkStore {
|
|||||||
try {
|
try {
|
||||||
store[x][z][y] = temp[x][y][z];
|
store[x][z][y] = temp[x][y][z];
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user