mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
1 Commits
1.4.07
...
reformat-j
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c211874a27 |
@@ -7,7 +7,7 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.07
|
||||
Version 1.4.07-dev
|
||||
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
||||
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
|
||||
+ Added more tiers to Fishing, Repair and Smelting!
|
||||
@@ -30,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 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 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.
|
||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||
@@ -57,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 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 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.
|
||||
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
|
||||
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||
@@ -69,7 +61,6 @@ Version 1.4.07
|
||||
! Admin and Party chat prefixes are now customizable
|
||||
! Changed the color of party leader names in Party chat
|
||||
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
||||
! Improved AFK Acrobatics prevention mechanism
|
||||
! Improved profile saving
|
||||
! Improved partial name matcher
|
||||
! Improved update checker
|
||||
@@ -77,8 +68,6 @@ Version 1.4.07
|
||||
! 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)
|
||||
! 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
|
||||
- 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.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
## The RPG lovers mod
|
||||
|
||||
### 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
|
||||
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/t00thpick1)
|
||||
[]
|
||||
(https://github.com/riking)
|
||||
|
||||
## Compiling
|
||||
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.07</version>
|
||||
<version>1.4.07-dev2</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -143,7 +143,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
|
||||
<system>Jenkins</system>
|
||||
<url>ci.mcmmo.org</url>
|
||||
</ciManagement>
|
||||
</project>
|
||||
|
||||
@@ -18,11 +18,11 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
@@ -33,9 +33,9 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
@@ -47,10 +47,10 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param message The message to send
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
||||
@@ -61,8 +61,8 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
@@ -73,6 +73,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
@@ -83,6 +84,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
*
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(String playerName) {
|
||||
@@ -93,6 +95,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
@@ -103,6 +106,7 @@ public final class ChatAPI {
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
*
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(String playerName) {
|
||||
|
||||
@@ -24,6 +24,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType A string that may or may not be a skill
|
||||
*
|
||||
* @return true if this is a valid mcMMO skill
|
||||
*/
|
||||
public static boolean isValidSkillType(String skillType) {
|
||||
@@ -38,12 +39,15 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType the skill to check
|
||||
*
|
||||
* @return true if this is a valid, non-child mcMMO skill
|
||||
*/
|
||||
public static boolean isNonChildSkill(String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) return false;
|
||||
if (skill == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !skill.isChildSkill();
|
||||
}
|
||||
@@ -58,9 +62,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -79,10 +83,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||
@@ -94,9 +98,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -110,10 +114,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||
@@ -125,9 +129,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -143,10 +147,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||
@@ -161,9 +165,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -176,11 +180,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
@@ -193,11 +198,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXP(String playerName, String skillType) {
|
||||
@@ -209,11 +215,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getXPRaw(Player player, String skillType) {
|
||||
@@ -226,11 +233,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||
@@ -242,11 +250,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
*
|
||||
* @return the total amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
@@ -259,11 +268,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the total amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||
@@ -275,11 +285,12 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
*
|
||||
* @return the amount of XP remaining until the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXPRemaining(Player player, String skillType) {
|
||||
@@ -296,11 +307,12 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
*
|
||||
* @return the amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||
@@ -316,9 +328,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@@ -332,10 +344,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||
@@ -362,8 +374,9 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the level for
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
*
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -378,10 +391,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
*
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getLevelOffline(String playerName, String skillType) {
|
||||
@@ -394,6 +408,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the power level for
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
@@ -406,6 +421,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get the power level for
|
||||
*
|
||||
* @return the power level of the player
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
@@ -427,6 +443,7 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType The skill to get the level cap for
|
||||
*
|
||||
* @return the level cap of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -452,16 +469,16 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @param skillType The skill to check
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
* @param skillType The skill to check
|
||||
*
|
||||
* @return the position on the leaderboard
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
|
||||
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
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*
|
||||
* @return the position on the power level leaderboard
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getPlayerRankOverall(String playerName) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -485,8 +502,8 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
@@ -501,10 +518,10 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||
@@ -516,11 +533,11 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
@@ -533,11 +550,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||
@@ -549,11 +566,11 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
@@ -566,11 +583,11 @@ public final class ExperienceAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||
|
||||
@@ -21,6 +21,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
*
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
@@ -37,6 +38,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
@@ -50,6 +52,7 @@ public final class PartyAPI {
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
*
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
@@ -72,7 +75,7 @@ public final class PartyAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
@@ -102,6 +105,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
@@ -114,7 +118,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param player The player to set as leader
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
@@ -126,6 +130,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -145,6 +150,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the player names in the player's party
|
||||
*/
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
@@ -157,6 +163,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
@@ -169,6 +176,7 @@ public final class PartyAPI {
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
|
||||
@@ -2,79 +2,141 @@ package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McscoreboardCommand implements TabExecutor {
|
||||
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear", "reset");
|
||||
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
help(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
ScoreboardManager.clearBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("keep")) {
|
||||
if (!Config.getInstance().getAllowKeepBoard()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
if (!ScoreboardManager.isBoardShown(sender.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
|
||||
return true;
|
||||
}
|
||||
ScoreboardManager.keepBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
|
||||
if (args.length == 1) {
|
||||
help(sender);
|
||||
return true;
|
||||
}
|
||||
if (CommandUtils.isInvalidInteger(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
int time = Math.abs(Integer.parseInt(args[1]));
|
||||
ScoreboardManager.setRevertTimer(sender.getName(), time);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
|
||||
}
|
||||
else {
|
||||
help(sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
private void help(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
clearScoreboard(player);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear")) {
|
||||
clearScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("rank")) {
|
||||
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("stats")) {
|
||||
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
||||
}
|
||||
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 true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("top")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
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:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
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:
|
||||
break;
|
||||
return ImmutableList.of();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void clearScoreboard(Player player) {
|
||||
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MobhealthCommand implements TabExecutor {
|
||||
|
||||
@@ -80,7 +80,10 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
|
||||
protected abstract void applyCommandAction();
|
||||
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
}
|
||||
|
||||
@@ -108,9 +108,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
|
||||
protected abstract void handleCommand(SkillType skill);
|
||||
|
||||
protected abstract void handlePlayerMessageAll();
|
||||
|
||||
protected abstract void handlePlayerMessageSkill();
|
||||
|
||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||
|
||||
@@ -129,10 +129,15 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected abstract boolean checkTogglePermissions();
|
||||
|
||||
protected abstract boolean checkModifyPermissions();
|
||||
|
||||
protected abstract boolean checkEnabled(String skill);
|
||||
|
||||
protected abstract void enable(String skill);
|
||||
|
||||
protected abstract void disable(String skill);
|
||||
|
||||
protected abstract void modify();
|
||||
|
||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||
|
||||
@@ -29,6 +29,10 @@ public class InspectCommand implements TabExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
@@ -40,9 +44,9 @@ public class InspectCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
||||
if (!Config.getInstance().getInspectUseChat()) return true;
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
@@ -76,9 +80,9 @@ public class InspectCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
|
||||
if (!Config.getInstance().getInspectUseChat()) return true;
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
|
||||
@@ -1,98 +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 org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
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;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||
if (!hasPermission(player, ability)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int seconds = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
|
||||
if (seconds <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getAbilityName()));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getAbilityName(), Integer.toString(seconds)));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPermission(Permissible permissible, AbilityType ability) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
return Permissions.berserk(permissible);
|
||||
case BLAST_MINING:
|
||||
return Permissions.remoteDetonation(permissible);
|
||||
case BLOCK_CRACKER:
|
||||
return Permissions.blockCracker(permissible);
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Permissions.gigaDrillBreaker(permissible);
|
||||
case GREEN_TERRA:
|
||||
return Permissions.greenTerra(permissible);
|
||||
case LEAF_BLOWER:
|
||||
return Permissions.leafBlower(permissible);
|
||||
case SERRATED_STRIKES:
|
||||
return Permissions.serratedStrikes(permissible);
|
||||
case SKULL_SPLITTER:
|
||||
return Permissions.skullSplitter(permissible);
|
||||
case SUPER_BREAKER:
|
||||
return Permissions.superBreaker(permissible);
|
||||
case TREE_FELLER:
|
||||
return Permissions.treeFeller(permissible);
|
||||
default:
|
||||
mcMMO.p.getLogger().warning("MccooldownCommand - couldn't check permission for AbilityType." + ability.name());
|
||||
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.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@@ -35,7 +36,13 @@ public class McrankCommand implements TabExecutor {
|
||||
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;
|
||||
|
||||
@@ -59,7 +66,13 @@ public class McrankCommand implements TabExecutor {
|
||||
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;
|
||||
|
||||
default:
|
||||
@@ -79,17 +92,6 @@ public class McrankCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private void display(CommandSender sender, String playerName) {
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.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);
|
||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -25,25 +26,28 @@ public class McstatsCommand implements TabExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (Config.getInstance().getStatsUseBoard()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
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));
|
||||
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -11,39 +11,36 @@ import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
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 MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
SkillType skill;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, null, sender, command);
|
||||
display(1, "ALL", sender, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Math.abs(Integer.parseInt(args[0])), null, sender, command);
|
||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill, sender, command);
|
||||
display(1, skill.toString(), sender, command);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@@ -51,11 +48,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
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;
|
||||
|
||||
default:
|
||||
@@ -73,41 +70,35 @@ public class MctopCommand implements TabExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, SkillType skill, CommandSender sender, Command command) {
|
||||
if (skill != null && !Permissions.mctop(sender, skill)) {
|
||||
private void display(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.actualizeDatabaseATS();
|
||||
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
|
||||
}
|
||||
else {
|
||||
display(page, skill, sender);
|
||||
}
|
||||
|
||||
display(page, skill, sender);
|
||||
}
|
||||
|
||||
private void display(int page, SkillType skill, CommandSender sender) {
|
||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
|
||||
boolean useChat = useBoard ? Config.getInstance().getTopUseChat() : true;
|
||||
|
||||
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
private void display(int page, String query, CommandSender sender) {
|
||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
private SkillType extractSkill(CommandSender sender, String skillName) {
|
||||
private boolean extractSkill(CommandSender sender, String skillName) {
|
||||
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||
return null;
|
||||
}
|
||||
SkillType skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (skill != null && CommandUtils.isChildSkill(sender, skill)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return skill;
|
||||
skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
@@ -84,9 +83,7 @@ public class FishingCommand extends SkillCommand {
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation();
|
||||
|
||||
Biome biome = location.getBlock().getBiome();
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
|
||||
@@ -69,15 +69,17 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
permissionsCheck();
|
||||
dataCalculations();
|
||||
|
||||
if (Config.getInstance().getSkillUseBoard()) {
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
}
|
||||
|
||||
if (!skill.isChildSkill()) {
|
||||
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("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 {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||
@@ -148,7 +150,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
length = Math.min(length, maxLength);
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
|
||||
}
|
||||
|
||||
protected void luckyEffectsDisplay() {
|
||||
|
||||
@@ -786,15 +786,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/* KRAKEN STUFF */
|
||||
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 double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
|
||||
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 getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
|
||||
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
|
||||
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,52 +45,26 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Scoreboards */
|
||||
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
|
||||
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
|
||||
if (getMcstatsScoreboardTime() != -1 && getMcstatsScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcstats.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
|
||||
if (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mctop.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
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) {
|
||||
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!");
|
||||
}
|
||||
|
||||
/* Skill.Print setting removed, as I can't think of a good use for it
|
||||
if (!(getSkillUseChat() || getSkillUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Commands.Skill must be true!");
|
||||
}
|
||||
// */
|
||||
|
||||
/* Database Purging */
|
||||
if (getPurgeInterval() < -1) {
|
||||
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
|
||||
@@ -238,36 +212,22 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||
|
||||
/* Scoreboards */
|
||||
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
||||
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
||||
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
||||
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
|
||||
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
||||
|
||||
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
|
||||
public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
|
||||
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
|
||||
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
||||
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
||||
|
||||
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
|
||||
public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
|
||||
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
|
||||
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
||||
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
||||
|
||||
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
|
||||
public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
|
||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
|
||||
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
|
||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
|
||||
|
||||
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
|
||||
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
|
||||
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
|
||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||
|
||||
// public boolean getSkillUseChat() { return config.getBoolean("Scoreboard.Types.Skill.Print", false); }
|
||||
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
|
||||
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); }
|
||||
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
@@ -310,7 +270,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* SMP Mods */
|
||||
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 getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
@@ -364,8 +324,8 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
|
||||
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
||||
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.getConfigString()); }
|
||||
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.getConfigString()); }
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
||||
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||
@@ -430,7 +390,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* AFK Leveling */
|
||||
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); }
|
||||
|
||||
/* Level Caps */
|
||||
|
||||
@@ -29,13 +29,7 @@ public abstract class ConfigLoader {
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||
|
||||
try {
|
||||
plugin.saveResource(fileName, false); // Normal files
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
||||
}
|
||||
plugin.saveResource(configFile.getPath(), false);
|
||||
}
|
||||
else {
|
||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||
|
||||
@@ -52,10 +52,12 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
while (!needsUpdate) {
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
@@ -64,10 +66,6 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Material> materialList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if (armorSection == null) {
|
||||
@@ -85,7 +83,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
Material armorMaterial = Material.matchMaterial(armorName);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -93,7 +91,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,13 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
while (!needsUpdate) {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
@@ -56,10 +58,6 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
|
||||
if (skillSection == null) {
|
||||
|
||||
@@ -58,12 +58,14 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
loadTool("Pickaxes", customPickaxes);
|
||||
loadTool("Shovels", customShovels);
|
||||
loadTool("Swords", customSwords);
|
||||
while (!needsUpdate) {
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
loadTool("Pickaxes", customPickaxes);
|
||||
loadTool("Shovels", customShovels);
|
||||
loadTool("Swords", customSwords);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
@@ -72,10 +74,6 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Material> materialList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
|
||||
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.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
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.
|
||||
@@ -29,6 +26,7 @@ public interface DatabaseManager {
|
||||
* Remove a user from the database.
|
||||
*
|
||||
* @param playerName The name of the user to remove
|
||||
*
|
||||
* @return true if the user was successfully removed, false otherwise
|
||||
*/
|
||||
public boolean removeUser(String playerName);
|
||||
@@ -37,30 +35,30 @@ public interface DatabaseManager {
|
||||
* Save a user to the database.
|
||||
*
|
||||
* @param profile The profile of the player to save
|
||||
*
|
||||
* @return true if successful, false on failure
|
||||
*/
|
||||
public boolean saveUser(PlayerProfile profile);
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName The skill to retrieve info on
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @param statsPerPage The number of stats per page
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage);
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName The skill to retrieve info on
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @param statsPerPage The number of stats per page
|
||||
*
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
||||
|
||||
/**
|
||||
* Retrieve rank info into a HashMap from SkillType to the rank.
|
||||
* <p>
|
||||
* The special value <code>null</code> is used to represent the Power
|
||||
* Level rank (the combination of all skill levels).
|
||||
* Retrieve rank info.
|
||||
*
|
||||
* @param playerName The name of the user to retrieve the rankings for
|
||||
*
|
||||
* @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.
|
||||
@@ -73,10 +71,11 @@ public interface DatabaseManager {
|
||||
* Load a player from the database.
|
||||
*
|
||||
* @param playerName The name of the player to load from the database
|
||||
* @param createNew Whether to create a new record if the player is not
|
||||
* found
|
||||
* @param createNew Whether to create a new record if the player is not
|
||||
* found
|
||||
*
|
||||
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||
* and createNew is false
|
||||
* and createNew is false
|
||||
*/
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
||||
|
||||
|
||||
@@ -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();
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -400,16 +400,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
// I have no idea why it's necessary to inline tryClose() here, but it removes
|
||||
// a resource leak warning, and I'm trusting the compiler on this one.
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
tryClose(in);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,8 +411,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@@ -438,8 +427,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
convertedUsers++;
|
||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -188,11 +188,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
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>();
|
||||
|
||||
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;
|
||||
PreparedStatement statement = null;
|
||||
|
||||
@@ -230,8 +230,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public Map<SkillType, Integer> readRank(String playerName) {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
public Map<String, Integer> readRank(String playerName) {
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
if (checkConnected()) {
|
||||
ResultSet resultSet;
|
||||
@@ -262,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType, rank + resultSet.getRow());
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -299,7 +299,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(null, rank + resultSet.getRow());
|
||||
skills.put("ALL", rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -447,8 +447,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "WHERE u.user = ?");
|
||||
List<String> usernames = getStoredUsers();
|
||||
ResultSet result = null;
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
for (String playerName : usernames) {
|
||||
statement.setString(1, playerName);
|
||||
try {
|
||||
@@ -460,8 +458,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
convertedUsers++;
|
||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
@@ -481,20 +477,20 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
*
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
*
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attempting a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
* <p/>
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
* <p/>
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attempting a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public boolean checkConnected() {
|
||||
boolean isClosed = true;
|
||||
boolean isValid = false;
|
||||
@@ -850,6 +846,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Attempt to write the SQL query.
|
||||
*
|
||||
* @param sql Query to write.
|
||||
*
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
private boolean write(String sql) {
|
||||
@@ -885,6 +882,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
*
|
||||
* @return the number of rows affected
|
||||
*/
|
||||
private int update(String sql) {
|
||||
@@ -919,6 +917,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Read SQL query.
|
||||
*
|
||||
* @param sql SQL query to read
|
||||
*
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
private HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
@@ -964,6 +963,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Get the Integer. Only return first row / first field.
|
||||
*
|
||||
* @param statement SQL query to execute
|
||||
*
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
private int readInt(PreparedStatement statement) {
|
||||
@@ -1107,6 +1107,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Retrieve the database id for a player
|
||||
*
|
||||
* @param playerName The name of the user to retrieve the id for
|
||||
*
|
||||
* @return the requested id or -1 if not found
|
||||
*/
|
||||
private int readId(String playerName) {
|
||||
|
||||
@@ -7,6 +7,5 @@ public enum DatabaseUpdateType {
|
||||
MOB_HEALTHBARS,
|
||||
PARTY_NAMES,
|
||||
KILL_ORPHANS,
|
||||
DROPPED_SPOUT
|
||||
;
|
||||
DROPPED_SPOUT;
|
||||
}
|
||||
|
||||
@@ -86,8 +86,6 @@ public class McMMOPlayer {
|
||||
private int lastSalvageClick;
|
||||
private boolean godMode;
|
||||
|
||||
private Location hookLocation;
|
||||
|
||||
private final Map<AbilityType, Boolean> abilityMode = 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 respawnATS;
|
||||
private int teleportATS;
|
||||
private long databaseATS;
|
||||
private int chimeraWingLastUse;
|
||||
private Location teleportCommence;
|
||||
|
||||
@@ -269,6 +266,7 @@ public class McMMOPlayer {
|
||||
* Get the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
*
|
||||
* @return true if the ability is enabled, false otherwise
|
||||
*/
|
||||
public boolean getAbilityMode(AbilityType ability) {
|
||||
@@ -278,7 +276,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param ability The ability to check
|
||||
* @param isActive True if the ability is active, false otherwise
|
||||
*/
|
||||
public void setAbilityMode(AbilityType ability, boolean isActive) {
|
||||
@@ -289,6 +287,7 @@ public class McMMOPlayer {
|
||||
* Get the informed state of an ability
|
||||
*
|
||||
* @param ability The ability to check
|
||||
*
|
||||
* @return true if the ability is informed, false otherwise
|
||||
*/
|
||||
public boolean getAbilityInformed(AbilityType ability) {
|
||||
@@ -298,7 +297,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the informed state of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param ability The ability to check
|
||||
* @param isInformed True if the ability is informed, false otherwise
|
||||
*/
|
||||
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
|
||||
@@ -309,6 +308,7 @@ public class McMMOPlayer {
|
||||
* Get the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to get the mode for
|
||||
*
|
||||
* @return true if the tool is prepped, false otherwise
|
||||
*/
|
||||
public boolean getToolPreparationMode(ToolType tool) {
|
||||
@@ -339,7 +339,7 @@ public class McMMOPlayer {
|
||||
/**
|
||||
* Set the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to set the mode for
|
||||
* @param tool Tool to set the mode for
|
||||
* @param isPrepared true if the tool should be prepped, false otherwise
|
||||
*/
|
||||
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
||||
@@ -350,6 +350,7 @@ public class McMMOPlayer {
|
||||
* Get the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to get the ATS for
|
||||
*
|
||||
* @return the ATS for the tool
|
||||
*/
|
||||
public long getToolPreparationATS(ToolType tool) {
|
||||
@@ -360,7 +361,7 @@ public class McMMOPlayer {
|
||||
* Set the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to set the ATS for
|
||||
* @param ATS the ATS of the tool
|
||||
* @param ATS the ATS of the tool
|
||||
*/
|
||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
@@ -428,14 +429,6 @@ public class McMMOPlayer {
|
||||
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public long getDatabaseATS() {
|
||||
return databaseATS;
|
||||
}
|
||||
|
||||
public void actualizeDatabaseATS() {
|
||||
databaseATS = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
@@ -510,18 +503,6 @@ public class McMMOPlayer {
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fishing: Master Angler
|
||||
*/
|
||||
|
||||
public Location getHookLocation() {
|
||||
return hookLocation;
|
||||
}
|
||||
|
||||
public void setHookLocation(Location hookLocation) {
|
||||
this.hookLocation = hookLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill notifications
|
||||
*/
|
||||
@@ -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
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginXpGain(SkillType skillType, float xp) {
|
||||
if (xp == 0) {
|
||||
@@ -586,7 +567,7 @@ public class McMMOPlayer {
|
||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginUnsharedXpGain(SkillType skillType, float xp) {
|
||||
xp = modifyXpGain(skillType, xp);
|
||||
@@ -598,7 +579,7 @@ public class McMMOPlayer {
|
||||
* Applies an experience gain
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, float xp) {
|
||||
if (!Permissions.skillEnabled(player, skillType)) {
|
||||
@@ -804,7 +785,8 @@ public class McMMOPlayer {
|
||||
* Modifies an experience gain using skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @param xp Experience amount to process
|
||||
*
|
||||
* @return Modified experience
|
||||
*/
|
||||
private float modifyXpGain(SkillType skillType, float xp) {
|
||||
@@ -854,7 +836,7 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
/*
|
||||
@@ -924,7 +906,7 @@ public class McMMOPlayer {
|
||||
*/
|
||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||
|
||||
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
|
||||
@@ -116,6 +116,7 @@ public class PlayerProfile {
|
||||
* Get the current DATS of a skill.
|
||||
*
|
||||
* @param abilityType Ability to get the DATS for
|
||||
*
|
||||
* @return the DATS for the ability
|
||||
*/
|
||||
public long getSkillDATS(AbilityType abilityType) {
|
||||
@@ -125,8 +126,8 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Set the current DATS of a skill.
|
||||
*
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
*/
|
||||
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
||||
int wearsOff = (int) (DATS * .001D);
|
||||
@@ -181,7 +182,7 @@ public class PlayerProfile {
|
||||
* Remove Xp from a skill.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXp(SkillType skillType, int xp) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -197,7 +198,7 @@ public class PlayerProfile {
|
||||
* Modify a skill level.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param newValue New level value for the skill
|
||||
* @param newValue New level value for the skill
|
||||
*/
|
||||
public void modifySkill(SkillType skillType, int newValue) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -214,7 +215,7 @@ public class PlayerProfile {
|
||||
* Add levels to a skill.
|
||||
*
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public void addLevels(SkillType skillType, int levels) {
|
||||
if (skillType.isChildSkill()) {
|
||||
@@ -230,7 +231,7 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Add Experience to a skill.
|
||||
*
|
||||
* @param skillType Type of skill to add experience to
|
||||
* @param skillType Type of skill to add experience to
|
||||
* @param experience Number of experience to add
|
||||
*/
|
||||
public void addExperience(SkillType skillType, int experience) {
|
||||
@@ -247,6 +248,7 @@ public class PlayerProfile {
|
||||
* Get the total amount of Xp before the next level.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
*
|
||||
* @return the total amount of Xp until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -13,11 +11,9 @@ import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(
|
||||
"Unarmed.Skills.Berserk.Name",
|
||||
"Unarmed.Skills.Berserk.On",
|
||||
"Unarmed.Skills.Berserk.Off",
|
||||
"Unarmed.Skills.Berserk.Other.On",
|
||||
@@ -25,7 +21,6 @@ public enum AbilityType {
|
||||
"Unarmed.Skills.Berserk.Other.Off"),
|
||||
|
||||
SUPER_BREAKER(
|
||||
"Mining.Skills.SuperBreaker.Name",
|
||||
"Mining.Skills.SuperBreaker.On",
|
||||
"Mining.Skills.SuperBreaker.Off",
|
||||
"Mining.Skills.SuperBreaker.Other.On",
|
||||
@@ -33,7 +28,6 @@ public enum AbilityType {
|
||||
"Mining.Skills.SuperBreaker.Other.Off"),
|
||||
|
||||
GIGA_DRILL_BREAKER(
|
||||
"Excavation.Skills.GigaDrillBreaker.Name",
|
||||
"Excavation.Skills.GigaDrillBreaker.On",
|
||||
"Excavation.Skills.GigaDrillBreaker.Off",
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.On",
|
||||
@@ -41,7 +35,6 @@ public enum AbilityType {
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
|
||||
|
||||
GREEN_TERRA(
|
||||
"Herbalism.Skills.GTe.Name",
|
||||
"Herbalism.Skills.GTe.On",
|
||||
"Herbalism.Skills.GTe.Off",
|
||||
"Herbalism.Skills.GTe.Other.On",
|
||||
@@ -49,7 +42,6 @@ public enum AbilityType {
|
||||
"Herbalism.Skills.GTe.Other.Off"),
|
||||
|
||||
SKULL_SPLITTER(
|
||||
"Axes.Skills.SS.Name",
|
||||
"Axes.Skills.SS.On",
|
||||
"Axes.Skills.SS.Off",
|
||||
"Axes.Skills.SS.Other.On",
|
||||
@@ -57,7 +49,6 @@ public enum AbilityType {
|
||||
"Axes.Skills.SS.Other.Off"),
|
||||
|
||||
TREE_FELLER(
|
||||
"Woodcutting.Skills.TreeFeller.Name",
|
||||
"Woodcutting.Skills.TreeFeller.On",
|
||||
"Woodcutting.Skills.TreeFeller.Off",
|
||||
"Woodcutting.Skills.TreeFeller.Other.On",
|
||||
@@ -65,81 +56,40 @@ public enum AbilityType {
|
||||
"Woodcutting.Skills.TreeFeller.Other.Off"),
|
||||
|
||||
SERRATED_STRIKES(
|
||||
"Swords.Skills.SS.Name",
|
||||
"Swords.Skills.SS.On",
|
||||
"Swords.Skills.SS.Off",
|
||||
"Swords.Skills.SS.Other.On",
|
||||
"Swords.Skills.SS.Refresh",
|
||||
"Swords.Skills.SS.Other.Off"),
|
||||
|
||||
/**
|
||||
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
|
||||
*/
|
||||
BLAST_MINING(
|
||||
"Mining.Blast.Name",
|
||||
null,
|
||||
null,
|
||||
"Mining.Blast.Other.On",
|
||||
"Mining.Blast.Refresh",
|
||||
null),
|
||||
|
||||
/**
|
||||
* No cooldown - always active
|
||||
*/
|
||||
LEAF_BLOWER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null),
|
||||
|
||||
/**
|
||||
* Not a first-class Ability - part of Berserk
|
||||
*/
|
||||
BLOCK_CRACKER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
private String abilityName;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
private String abilityRefresh;
|
||||
private String abilityPlayerOff;
|
||||
|
||||
/**
|
||||
* Those abilities that have a cooldown saved to the database.
|
||||
*/
|
||||
public static final List<AbilityType> NORMAL_ABILITIES;
|
||||
/**
|
||||
* Those abilities that do not have a cooldown saved to the database.
|
||||
*/
|
||||
public static final List<AbilityType> NON_NORMAL_ABILITIES;
|
||||
|
||||
static {
|
||||
NORMAL_ABILITIES = ImmutableList.of(
|
||||
BERSERK,
|
||||
SUPER_BREAKER,
|
||||
GIGA_DRILL_BREAKER,
|
||||
GREEN_TERRA,
|
||||
SKULL_SPLITTER,
|
||||
TREE_FELLER,
|
||||
SERRATED_STRIKES,
|
||||
BLAST_MINING
|
||||
);
|
||||
NON_NORMAL_ABILITIES = ImmutableList.of(
|
||||
LEAF_BLOWER,
|
||||
BLOCK_CRACKER
|
||||
);
|
||||
}
|
||||
|
||||
private AbilityType(String abilityName, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.abilityName = abilityName;
|
||||
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
@@ -155,17 +105,6 @@ public enum AbilityType {
|
||||
return Config.getInstance().getMaxLength(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* May return null
|
||||
* @return ability name, or null if unavailable
|
||||
*/
|
||||
public String getAbilityName() {
|
||||
if (this.abilityName == null) {
|
||||
return null;
|
||||
}
|
||||
return LocaleLoader.getString(this.abilityName);
|
||||
}
|
||||
|
||||
public String getAbilityOn() {
|
||||
return LocaleLoader.getString(this.abilityOn);
|
||||
}
|
||||
@@ -186,11 +125,6 @@ public enum AbilityType {
|
||||
return LocaleLoader.getString(this.abilityRefresh);
|
||||
}
|
||||
|
||||
public String getConfigString() {
|
||||
// If toString() changes, place old code here to not break config.yml
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String baseString = name();
|
||||
@@ -216,6 +150,7 @@ public enum AbilityType {
|
||||
* Get the permissions for this ability.
|
||||
*
|
||||
* @param player Player to check permissions for
|
||||
*
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
@@ -259,6 +194,7 @@ public enum AbilityType {
|
||||
* Check if a block is affected by this ability.
|
||||
*
|
||||
* @param blockState the block to check
|
||||
*
|
||||
* @return true if the block is affected by this ability, false otherwise
|
||||
*/
|
||||
public boolean blockCheck(BlockState blockState) {
|
||||
@@ -293,7 +229,8 @@ public enum AbilityType {
|
||||
* Check to see if ability should be triggered.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean triggerCheck(Player player, Block block) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public enum ToolType {
|
||||
* Check to see if the item is of the appropriate type.
|
||||
*
|
||||
* @param itemStack The item to check
|
||||
*
|
||||
* @return true if the item is the right type, false otherwise
|
||||
*/
|
||||
public boolean inHand(ItemStack itemStack) {
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -68,7 +69,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerTeleportEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of setting the
|
||||
* player's last teleportation timestamp, in order to prevent
|
||||
* possible Acrobatics exploitation.
|
||||
@@ -88,7 +89,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerDeathEvents at the lowest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used to modify the death message of a player when
|
||||
* needed to correct issues potentially caused by the custom naming used
|
||||
* for mob healthbars.
|
||||
@@ -114,7 +115,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeathEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of dealing the penalties
|
||||
* associated with hardcore and vampirism modes. If neither of these
|
||||
* modes are enabled, or if the player who died has hardcore bypass
|
||||
@@ -150,7 +151,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerChangedWorldEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of removing god mode or
|
||||
* player parties if they are not allowed on the world the player has
|
||||
* changed to.
|
||||
@@ -173,7 +174,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDropItemEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of flagging sharable
|
||||
* dropped items, as well as removing ability buffs from pickaxes
|
||||
* and shovels.
|
||||
@@ -194,7 +195,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerFishEvents at the highest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used for the purpose of handling our anti-exploit
|
||||
* code, as well as dealing with ice fishing.
|
||||
*
|
||||
@@ -239,7 +240,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerFishEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of handling the various
|
||||
* Fishing skills and abilities.
|
||||
*
|
||||
@@ -280,7 +281,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Handle PlayerPickupItemEvents at the highest priority.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are used to handle item sharing between party members and
|
||||
* are also used to handle item pickup for the Unarmed skill.
|
||||
*
|
||||
@@ -321,7 +322,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerQuitEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of resetting player
|
||||
* variables and other garbage collection tasks that must take place when
|
||||
* a player exits the server.
|
||||
@@ -346,7 +347,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerJoinEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of initializing player
|
||||
* variables, as well as handling the MOTD display and other important
|
||||
* join messages.
|
||||
@@ -362,6 +363,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
UserManager.addUser(player).actualizeRespawnATS();
|
||||
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
@@ -379,7 +381,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerRespawnEvents.
|
||||
* <p>
|
||||
* <p/>
|
||||
* These events are monitored for the purpose of setting the
|
||||
* player's last respawn timestamp, in order to prevent
|
||||
* possible exploitation.
|
||||
|
||||
@@ -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
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
ScoreboardManager.setupPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
ScoreboardManager.teardownPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent e) {
|
||||
ScoreboardManager.handleLevelUp(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent e) {
|
||||
ScoreboardManager.handleXp(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent e) {
|
||||
ScoreboardManager.cooldownUpdate(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import java.util.ResourceBundle;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public final class LocaleLoader {
|
||||
@@ -15,7 +14,7 @@ public final class LocaleLoader {
|
||||
private static ResourceBundle bundle = null;
|
||||
private static ResourceBundle enBundle = null;
|
||||
|
||||
private LocaleLoader() {};
|
||||
private LocaleLoader() {}
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, (Object[]) null);
|
||||
@@ -24,8 +23,9 @@ public final class LocaleLoader {
|
||||
/**
|
||||
* Gets the appropriate string from the Locale files.
|
||||
*
|
||||
* @param key The key to look up the string with
|
||||
* @param key The key to look up the string with
|
||||
* @param messageArguments Any arguments to be added to the string
|
||||
*
|
||||
* @return The properly formatted locale string
|
||||
*/
|
||||
public static String getString(String key, Object... messageArguments) {
|
||||
@@ -41,10 +41,6 @@ public final class LocaleLoader {
|
||||
return getString(key, enBundle, messageArguments);
|
||||
}
|
||||
catch (MissingResourceException ex2) {
|
||||
if (!key.contains("Guides")) {
|
||||
mcMMO.p.getLogger().warning("Could not find locale string: " + key);
|
||||
}
|
||||
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
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.database.UserPurgeTask;
|
||||
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.skills.child.ChildConfig;
|
||||
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.experience.FormulaManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
|
||||
import net.h31ix.updater.mcmmo.Updater;
|
||||
import net.h31ix.updater.mcmmo.Updater.UpdateResult;
|
||||
import net.h31ix.updater.mcmmo.Updater.UpdateType;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
@@ -81,8 +78,6 @@ public class mcMMO extends JavaPlugin {
|
||||
/* Plugin Checks */
|
||||
private static boolean combatTagEnabled;
|
||||
private static boolean healthBarPluginEnabled;
|
||||
private static boolean noCheatPlusPluginEnabled;
|
||||
private static boolean compatNoCheatPlusPluginEnabled;
|
||||
private static boolean mcpcEnabled;
|
||||
|
||||
// Config Validation Check
|
||||
@@ -125,11 +120,9 @@ public class mcMMO extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
mcpcEnabled = getServer().getName().equals("MCPC+");
|
||||
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
||||
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
||||
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
|
||||
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
|
||||
mcpcEnabled = getServer().getName().equals("MCPC+");
|
||||
|
||||
if (mcpcEnabled) {
|
||||
checkModConfigs();
|
||||
@@ -139,11 +132,6 @@ public class mcMMO extends JavaPlugin {
|
||||
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();
|
||||
|
||||
registerEvents();
|
||||
@@ -155,7 +143,6 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
||||
ScoreboardManager.setupPlayer(player);
|
||||
}
|
||||
|
||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||
@@ -195,12 +182,12 @@ public class mcMMO extends JavaPlugin {
|
||||
try {
|
||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties(); // Save our parties
|
||||
ScoreboardManager.teardownAll();
|
||||
formulaManager.saveFormula();
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
}
|
||||
catch (NullPointerException e) {}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
@@ -326,14 +313,14 @@ public class mcMMO extends JavaPlugin {
|
||||
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) {
|
||||
this.updateAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
||||
if (updater.getLatestVersionString().contains("-beta") && !Config.getInstance().getPreferBeta()) {
|
||||
this.updateAvailable = false;
|
||||
return;
|
||||
}
|
||||
@@ -384,7 +371,6 @@ public class mcMMO extends JavaPlugin {
|
||||
pluginManager.registerEvents(new EntityListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new SelfListener(), this);
|
||||
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
||||
pluginManager.registerEvents(new WorldListener(this), this);
|
||||
}
|
||||
|
||||
@@ -421,9 +407,6 @@ public class mcMMO extends JavaPlugin {
|
||||
else if (kickIntervalTicks > 0) {
|
||||
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() {
|
||||
|
||||
@@ -31,8 +31,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if a party with a given name already exists.
|
||||
*
|
||||
* @param player The player to notify
|
||||
* @param player The player to notify
|
||||
* @param partyName The name of the party to check
|
||||
*
|
||||
* @return true if a party with that name exists, false otherwise
|
||||
*/
|
||||
public static boolean checkPartyExistence(Player player, String partyName) {
|
||||
@@ -47,8 +48,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Attempt to change parties or join a new party.
|
||||
*
|
||||
* @param mcMMOPlayer The player changing or joining parties
|
||||
* @param mcMMOPlayer The player changing or joining parties
|
||||
* @param newPartyName The name of the party being joined
|
||||
*
|
||||
* @return true if the party was joined successfully, false otherwise
|
||||
*/
|
||||
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
|
||||
@@ -73,8 +75,9 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
*
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
@@ -92,6 +95,7 @@ public final class PartyManager {
|
||||
* Get the near party members.
|
||||
*
|
||||
* @param mcMMOPlayer The player to check
|
||||
*
|
||||
* @return the near party members
|
||||
*/
|
||||
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
|
||||
@@ -116,6 +120,7 @@ public final class PartyManager {
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static LinkedHashSet<String> getAllMembers(Player player) {
|
||||
@@ -128,6 +133,7 @@ public final class PartyManager {
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
@@ -138,6 +144,7 @@ public final class PartyManager {
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param player The player to check
|
||||
*
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
@@ -152,6 +159,7 @@ public final class PartyManager {
|
||||
* Retrieve a party by its name
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(String partyName) {
|
||||
@@ -168,6 +176,7 @@ public final class PartyManager {
|
||||
* Retrieve a party by a members name
|
||||
*
|
||||
* @param playerName The members name
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getPlayerParty(String playerName) {
|
||||
@@ -184,6 +193,7 @@ public final class PartyManager {
|
||||
* Retrieve a party by member
|
||||
*
|
||||
* @param player The member
|
||||
*
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(Player player) {
|
||||
@@ -205,7 +215,7 @@ public final class PartyManager {
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param player The player to remove
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void removeFromParty(OfflinePlayer player, Party party) {
|
||||
LinkedHashSet<String> members = party.getMembers();
|
||||
@@ -253,8 +263,8 @@ public final class PartyManager {
|
||||
* Create a new party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
*/
|
||||
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
@@ -275,9 +285,10 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
*
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
||||
@@ -326,7 +337,7 @@ public final class PartyManager {
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
String playerName = mcMMOPlayer.getPlayer().getName();
|
||||
@@ -340,6 +351,7 @@ public final class PartyManager {
|
||||
* Get the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
*
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
@@ -352,7 +364,7 @@ public final class PartyManager {
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param playerName The name of the player to set as leader
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void setPartyLeader(String playerName, Party party) {
|
||||
String leaderName = party.getLeader();
|
||||
@@ -389,6 +401,7 @@ public final class PartyManager {
|
||||
* Check if a string is a valid party name.
|
||||
*
|
||||
* @param partyName The party name to check
|
||||
*
|
||||
* @return true if this is a valid party, false otherwise
|
||||
*/
|
||||
public static boolean isParty(String partyName) {
|
||||
@@ -474,10 +487,11 @@ public final class PartyManager {
|
||||
/**
|
||||
* Handle party change event.
|
||||
*
|
||||
* @param player The player changing parties
|
||||
* @param player The player changing parties
|
||||
* @param oldPartyName The name of the old party
|
||||
* @param newPartyName The name of the new party
|
||||
* @param reason The reason for changing parties
|
||||
* @param reason The reason for changing parties
|
||||
*
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||
@@ -501,7 +515,7 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a player joins.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that joined
|
||||
*/
|
||||
private static void informPartyMembersJoin(Party party, String playerName) {
|
||||
@@ -513,7 +527,7 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a party member quits.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that left
|
||||
*/
|
||||
private static void informPartyMembersQuit(Party party, String playerName) {
|
||||
|
||||
@@ -22,9 +22,10 @@ public final class ShareHandler {
|
||||
/**
|
||||
* Distribute Xp amongst party members.
|
||||
*
|
||||
* @param xp Xp without party sharing
|
||||
* @param xp Xp without party sharing
|
||||
* @param mcMMOPlayer Player initiating the Xp gain
|
||||
* @param skillType Skill being used
|
||||
* @param skillType Skill being used
|
||||
*
|
||||
* @return True is the xp has been shared
|
||||
*/
|
||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||
@@ -56,8 +57,9 @@ public final class ShareHandler {
|
||||
/**
|
||||
* Distribute Items amongst party members.
|
||||
*
|
||||
* @param drop Item that will get shared
|
||||
* @param drop Item that will get shared
|
||||
* @param mcMMOPlayer Player who picked up the item
|
||||
*
|
||||
* @return True if the item has been shared
|
||||
*/
|
||||
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {
|
||||
|
||||
@@ -2,34 +2,25 @@ package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||
private final String playerName;
|
||||
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.sender = sender;
|
||||
this.useBoard = useBoard;
|
||||
this.useChat = useChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,36 +10,20 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
/**
|
||||
* Display the results of McrankCommandAsyncTask to the sender.
|
||||
*/
|
||||
public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
private final Map<SkillType, Integer> skills;
|
||||
private final Map<String, Integer> skills;
|
||||
private final CommandSender sender;
|
||||
private final String playerName;
|
||||
private final boolean useBoard, useChat;
|
||||
|
||||
/*package-private*/ 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.sender = sender;
|
||||
this.playerName = playerName;
|
||||
this.useBoard = useBoard;
|
||||
this.useChat = useChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
if (useChat){
|
||||
displayChat();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayChat() {
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
Integer rank;
|
||||
|
||||
@@ -51,20 +35,11 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = skills.get(skill);
|
||||
rank = skills.get(skill.name());
|
||||
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)));
|
||||
}
|
||||
|
||||
public void displayBoard() {
|
||||
if (playerName == null || sender.getName().equalsIgnoreCase(playerName)) {
|
||||
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
|
||||
}
|
||||
else {
|
||||
ScoreboardManager.showPlayerRankScoreboardOthers((Player) sender, playerName, skills);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,36 +2,27 @@ package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
private final CommandSender sender;
|
||||
private final SkillType skill;
|
||||
private final int page;
|
||||
private final boolean useBoard, useChat;
|
||||
private CommandSender sender;
|
||||
private String skill;
|
||||
private int page;
|
||||
|
||||
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.skill = skill;
|
||||
this.sender = sender;
|
||||
this.useBoard = useBoard;
|
||||
this.useChat = useChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
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,69 +4,44 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
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 {
|
||||
private final List<PlayerStat> userStats;
|
||||
private final CommandSender sender;
|
||||
private final SkillType skill;
|
||||
private final int page;
|
||||
private final boolean useBoard, useChat;
|
||||
private List<PlayerStat> userStats;
|
||||
private CommandSender sender;
|
||||
private String skill;
|
||||
private int page;
|
||||
|
||||
/*package-private*/ 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.page = page;
|
||||
this.skill = skill;
|
||||
this.sender = sender;
|
||||
this.useBoard = useBoard;
|
||||
this.useChat = useChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void displayChat() {
|
||||
if (skill == null) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getSkillName()));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
|
||||
for (PlayerStat stat : userStats) {
|
||||
// Format:
|
||||
// 01. Playername - skill value
|
||||
// 12. Playername - skill value
|
||||
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
||||
String digit = ((place < 10) ? "0" : "") + String.valueOf(place);
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + stat.name + " - " + ChatColor.WHITE + stat.statVal);
|
||||
place++;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayBoard() {
|
||||
if (skill == null) {
|
||||
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
|
||||
}
|
||||
else {
|
||||
ScoreboardManager.showTopScoreboard((Player) sender, skill, page, userStats);
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class FormulaConversionTask extends BukkitRunnable {
|
||||
@@ -25,8 +23,6 @@ public class FormulaConversionTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
PlayerProfile profile;
|
||||
@@ -47,8 +43,6 @@ public class FormulaConversionTask extends BukkitRunnable {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
editValues(profile);
|
||||
}
|
||||
convertedUsers++;
|
||||
Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis);
|
||||
}
|
||||
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.
|
||||
*
|
||||
* @param entity LivingEntity to add
|
||||
* @param ticks Number of bleeding ticks
|
||||
* @param ticks Number of bleeding ticks
|
||||
*/
|
||||
public static void add(LivingEntity entity, int ticks) {
|
||||
int newTicks = ticks;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class KrakenAttackTask extends BukkitRunnable {
|
||||
private Creature kraken;
|
||||
private Player player;
|
||||
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 ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
|
||||
|
||||
@@ -37,7 +37,16 @@ public class KrakenAttackTask extends BukkitRunnable {
|
||||
if (player.isValid() && playerLocation.getBlock().isLiquid()) {
|
||||
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 {
|
||||
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
|
||||
@@ -74,24 +83,20 @@ public class KrakenAttackTask extends BukkitRunnable {
|
||||
World world = player.getWorld();
|
||||
|
||||
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 {
|
||||
kraken.remove();
|
||||
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 boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
|
||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||
|
||||
private Acrobatics() {};
|
||||
private Acrobatics() {}
|
||||
|
||||
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
|
||||
return Math.max(damage / damageModifier, 1.0);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -8,7 +7,6 @@ import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -20,9 +18,6 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AcrobaticsManager extends SkillManager {
|
||||
private int fallTries = 0;
|
||||
Location lastFallLocation;
|
||||
|
||||
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.ACROBATICS);
|
||||
}
|
||||
@@ -30,7 +25,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
public boolean canRoll() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !exploitPrevention() && Permissions.roll(player);
|
||||
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
|
||||
}
|
||||
|
||||
public boolean canDodge(Entity damager) {
|
||||
@@ -49,6 +44,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Dodge ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
public double dodgeCheck(double damage) {
|
||||
@@ -77,6 +73,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Roll ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
public double rollCheck(double damage) {
|
||||
@@ -98,8 +95,6 @@ public class AcrobaticsManager extends SkillManager {
|
||||
applyXpGain(calculateRollXP(damage, false));
|
||||
}
|
||||
|
||||
lastFallLocation = player.getLocation();
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
@@ -107,6 +102,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Graceful Roll ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
private double gracefulRollCheck(double damage) {
|
||||
@@ -125,25 +121,6 @@ public class AcrobaticsManager extends SkillManager {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public boolean exploitPrevention() {
|
||||
if (!Config.getInstance().getAcrobaticsAFKDisabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPlayer().isInsideVehicle()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Location fallLocation = getPlayer().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) {
|
||||
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.
|
||||
*
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
* @param damager The {@link Entity} who shot the arrow
|
||||
*/
|
||||
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
||||
@@ -69,7 +69,7 @@ public class ArcheryManager extends SkillManager {
|
||||
* Handle the effects of the Daze ability
|
||||
*
|
||||
* @param defender The {@link Player} being affected by the ability
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double daze(Player defender, Arrow arrow) {
|
||||
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||
@@ -98,7 +98,7 @@ public class ArcheryManager extends SkillManager {
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
|
||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Excavation {
|
||||
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check.
|
||||
*
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
|
||||
@@ -62,6 +62,7 @@ public final class Fishing {
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param target Targeted entity
|
||||
*
|
||||
* @return possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
||||
@@ -135,6 +136,7 @@ public final class Fishing {
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
||||
|
||||
@@ -103,31 +103,31 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
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();
|
||||
|
||||
if (!unleashMessage.isEmpty()) {
|
||||
player.sendMessage(unleashMessage);
|
||||
}
|
||||
|
||||
Location location = player.getLocation();
|
||||
boolean globalEffectsEnabled = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
|
||||
|
||||
if (globalEffectsEnabled) {
|
||||
world.strikeLightningEffect(location);
|
||||
world.strikeLightningEffect(location);
|
||||
world.strikeLightningEffect(location);
|
||||
|
||||
if (AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled()) {
|
||||
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 {
|
||||
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());
|
||||
}
|
||||
|
||||
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) {
|
||||
player.setItemInHand(null);
|
||||
}
|
||||
@@ -277,12 +277,9 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
public void masterAngler(Fish hook) {
|
||||
Player player = getPlayer();
|
||||
Location location = hook.getLocation();
|
||||
Biome biome = location.getBlock().getBiome();
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
double biteChance = hook.getBiteChance();
|
||||
|
||||
mcMMOPlayer.setHookLocation(location);
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class Herbalism {
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
@@ -62,6 +63,7 @@ public class Herbalism {
|
||||
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||
*
|
||||
* @return the number of bonus drops to award from the blocks in this plant
|
||||
*/
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
@@ -92,6 +94,7 @@ public class Herbalism {
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
|
||||
@@ -78,8 +78,9 @@ public class HerbalismManager extends SkillManager {
|
||||
/**
|
||||
* Handle the Farmer's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
*
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||
@@ -90,6 +91,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenTerra(BlockState blockState) {
|
||||
@@ -114,8 +116,6 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
@@ -180,6 +180,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Green Thumb ability for blocks.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||
@@ -195,6 +196,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Hylian Luck ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processHylianLuck(BlockState blockState) {
|
||||
@@ -246,6 +248,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Shroom Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processShroomThumb(BlockState blockState) {
|
||||
|
||||
@@ -173,6 +173,7 @@ public class MiningManager extends SkillManager {
|
||||
* Increases the blast radius of the explosion.
|
||||
*
|
||||
* @param radius to modify
|
||||
*
|
||||
* @return modified radius
|
||||
*/
|
||||
public float biggerBombs(float radius) {
|
||||
@@ -288,7 +289,7 @@ public class MiningManager extends SkillManager {
|
||||
private boolean blastMiningCooldownOver() {
|
||||
Player player = getPlayer();
|
||||
PlayerProfile profile = getProfile();
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(AbilityType.BLAST_MINING, profile, player);
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
|
||||
@@ -253,8 +253,9 @@ public class RepairManager extends SkillManager {
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
*
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
private short repairCalculate(short durability, int repairAmount) {
|
||||
@@ -327,7 +328,7 @@ public class RepairManager extends SkillManager {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
||||
item.addEnchantment(enchantment, enchantLevel - 1);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum RepairItemType {
|
||||
* Get the base permissions associated with this RepairItemType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
*
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface Repairable {
|
||||
|
||||
/**
|
||||
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
|
||||
*
|
||||
* <p/>
|
||||
* This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords
|
||||
*
|
||||
* @return the minimum number of items
|
||||
@@ -57,7 +57,7 @@ public interface Repairable {
|
||||
|
||||
/**
|
||||
* Gets the base repair durability on which to calculate bonuses.
|
||||
*
|
||||
* <p/>
|
||||
* This is actually the maximum durability divided by the minimum quantity
|
||||
*
|
||||
* @return the base repair durability
|
||||
|
||||
@@ -35,6 +35,7 @@ public class SmeltingManager extends SkillManager {
|
||||
* Process the Flux Mining ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processFluxMining(BlockState blockState) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SwordsManager extends SkillManager {
|
||||
* Handle the effects of the Counter Attack 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) {
|
||||
if (Swords.counterAttackRequiresBlock && !getPlayer().isBlocking()) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Taming {
|
||||
|
||||
case WOLF:
|
||||
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
|
||||
|
||||
|
||||
case 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.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -87,7 +87,7 @@ public class TamingManager extends SkillManager {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 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) {
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||
|
||||
@@ -80,7 +80,8 @@ public class Unarmed {
|
||||
|
||||
nextSlot++;
|
||||
}
|
||||
} else if (firstEmpty != -1) {
|
||||
}
|
||||
else if (firstEmpty != -1) {
|
||||
drop.remove();
|
||||
dropStack.setAmount(dropAmount);
|
||||
inventory.setItem(firstEmpty, dropStack);
|
||||
|
||||
@@ -132,6 +132,7 @@ public class UnarmedManager extends SkillManager {
|
||||
* Check Iron Grip ability success
|
||||
*
|
||||
* @param defender The defending player
|
||||
*
|
||||
* @return true if the defender was not disarmed, false otherwise
|
||||
*/
|
||||
private boolean hasIronGrip(Player defender) {
|
||||
|
||||
@@ -32,15 +32,16 @@ public final class Woodcutting {
|
||||
protected enum ExperienceGainMethod {
|
||||
DEFAULT,
|
||||
TREE_FELLER,
|
||||
};
|
||||
}
|
||||
|
||||
private Woodcutting() {}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @return Amount of experience
|
||||
*/
|
||||
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
||||
@@ -140,7 +141,7 @@ public final class Woodcutting {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
/*
|
||||
@@ -208,7 +209,8 @@ public final class Woodcutting {
|
||||
* Handles the durability loss
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
|
||||
@@ -240,12 +242,13 @@ public final class Woodcutting {
|
||||
* list of blocks used for future recursive calls of
|
||||
* 'processTree()'
|
||||
*
|
||||
* @param blockState Block to be added
|
||||
* @param blockState Block to be added
|
||||
* @param futureCenterBlocks List of blocks that will be used to call
|
||||
* 'processTree()'
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
* 'processTree()'
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*
|
||||
* @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) {
|
||||
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.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block awards XP, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should allow ability activation, false otherwise
|
||||
*/
|
||||
public static boolean canActivateAbilities(BlockState blockState) {
|
||||
@@ -72,6 +74,7 @@ public final class BlockUtils {
|
||||
* Check if a given block is an ore
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(BlockState blockState) {
|
||||
@@ -96,6 +99,7 @@ public final class BlockUtils {
|
||||
* Determine if a given block can be made mossy
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block can be made mossy, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should affected by Green Terra, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should affected by Super Breaker, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should affected by Giga Drill Breaker, false otherwise
|
||||
*/
|
||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||
@@ -203,6 +210,7 @@ public final class BlockUtils {
|
||||
* Check if a given block is a log
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block is a log, false otherwise
|
||||
*/
|
||||
public static boolean isLog(BlockState blockState) {
|
||||
@@ -221,6 +229,7 @@ public final class BlockUtils {
|
||||
* Check if a given block is a leaf
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block is a leaf, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should affected by Flux Mining, false otherwise
|
||||
*/
|
||||
public static boolean affectedByFluxMining(BlockState blockState) {
|
||||
@@ -254,6 +264,7 @@ public final class BlockUtils {
|
||||
* Determine if a given block can activate Herbalism abilities
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block can be activate Herbalism abilities, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block should affected by Block Cracker, false otherwise
|
||||
*/
|
||||
public static boolean affectedByBlockCracker(BlockState blockState) {
|
||||
@@ -288,6 +300,7 @@ public final class BlockUtils {
|
||||
* Determine if a given block can be made into Mycelium
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block can be made in Mycelium, false otherwise
|
||||
*/
|
||||
public static boolean canMakeShroomy(BlockState blockState) {
|
||||
@@ -305,6 +318,7 @@ public final class BlockUtils {
|
||||
* Determine if a given block is an mcMMO anvil
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
*
|
||||
* @return true if the block is an mcMMO anvil, false otherwise
|
||||
*/
|
||||
public static boolean isMcMMOAnvil(BlockState blockState) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class ChimaeraWing {
|
||||
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
|
||||
int cooldown = Config.getInstance().getChimaeraCooldown();
|
||||
|
||||
if (cooldown > 0 ) {
|
||||
if (cooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
|
||||
@@ -68,9 +68,10 @@ public class EventUtils {
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
* @param block The block to break
|
||||
* @param player The player breaking the block
|
||||
* @param block The block to break
|
||||
* @param player The player breaking the block
|
||||
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
||||
*
|
||||
* @return true if the event wasn't cancelled, false otherwise
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
return !isCancelled;
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, AbilityType ability) {
|
||||
|
||||
@@ -19,27 +19,22 @@ public final class HardcoreManager {
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
int totalLevelsLost = 0;
|
||||
int totalLost = 0;
|
||||
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
||||
int playerSkillXpLevel = playerProfile.getSkillXpLevel(skillType);
|
||||
|
||||
if (playerSkillLevel <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double statsLost = playerSkillLevel * (statLossPercentage * 0.01D);
|
||||
int levelsLost = (int) statsLost;
|
||||
int xpLost = (int) Math.floor(playerSkillXpLevel * (statsLost - levelsLost));
|
||||
|
||||
totalLevelsLost += levelsLost;
|
||||
int levelsLost = (int) (playerSkillLevel * (statLossPercentage * 0.01D));
|
||||
totalLost += 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) {
|
||||
@@ -51,7 +46,7 @@ public final class HardcoreManager {
|
||||
|
||||
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
int totalLevelsStolen = 0;
|
||||
int totalStolen = 0;
|
||||
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
||||
@@ -61,24 +56,16 @@ public final class HardcoreManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
int victimSkillXpLevel = victimProfile.getSkillXpLevel(skillType);
|
||||
|
||||
double statsStolen = victimSkillLevel * (vampirismStatLeechPercentage * 0.01D);
|
||||
int levelsStolen = (int) statsStolen;
|
||||
int xpStolen = (int) Math.floor(victimSkillXpLevel * (statsStolen - levelsStolen));
|
||||
|
||||
totalLevelsStolen += levelsStolen;
|
||||
int levelsStolen = (int) (victimSkillLevel * (vampirismStatLeechPercentage * 0.01D));
|
||||
totalStolen += levelsStolen;
|
||||
|
||||
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
||||
killerProfile.addExperience(skillType, xpStolen);
|
||||
|
||||
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
||||
victimProfile.removeXp(skillType, xpStolen);
|
||||
}
|
||||
|
||||
if (totalLevelsStolen > 0) {
|
||||
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Success", totalLevelsStolen, victim.getName()));
|
||||
victim.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Victim.Success", killer.getName(), totalLevelsStolen));
|
||||
if (totalStolen > 0) {
|
||||
killer.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Killer.Success", totalStolen, victim.getName()));
|
||||
victim.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.Victim.Success", killer.getName(), totalStolen));
|
||||
}
|
||||
else {
|
||||
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.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -25,48 +26,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public final class HolidayManager {
|
||||
static String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary";
|
||||
private static ArrayList<String> hasCelebrated;
|
||||
|
||||
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 static final Random rand = new Random();
|
||||
|
||||
private HolidayManager() {}
|
||||
|
||||
// This gets called onEnable
|
||||
public static void createAnniversaryFile() {
|
||||
File anniversaryFile = new File(anniversaryFilePath);
|
||||
File anniversaryFile = new File(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary");
|
||||
|
||||
if (!anniversaryFile.exists()) {
|
||||
try {
|
||||
@@ -81,7 +50,7 @@ public final class HolidayManager {
|
||||
|
||||
try {
|
||||
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();
|
||||
|
||||
while (line != null) {
|
||||
@@ -99,7 +68,7 @@ public final class HolidayManager {
|
||||
// This gets called onDisable
|
||||
public static void saveAnniversaryFiles() {
|
||||
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) {
|
||||
writer.write(player);
|
||||
writer.newLine();
|
||||
@@ -134,7 +103,7 @@ public final class HolidayManager {
|
||||
if (sender instanceof Player) {
|
||||
final int firework_amount = 10;
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -170,7 +139,18 @@ public final class HolidayManager {
|
||||
* 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_\\(/_ %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));
|
||||
@@ -190,32 +170,93 @@ public final class HolidayManager {
|
||||
}
|
||||
|
||||
private static void spawnFireworks(Player player) {
|
||||
int power = (int) (Misc.getRandom().nextDouble() * 3) + 1;
|
||||
Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
|
||||
double varX = Misc.getRandom().nextGaussian() * 3;
|
||||
double varZ = Misc.getRandom().nextGaussian() * 3;
|
||||
int power = (int) (rand.nextDouble() * 3) + 1;
|
||||
int type = (int) (rand.nextDouble() * 5) + 1;
|
||||
double varX = rand.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);
|
||||
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.setPower(power);
|
||||
fireworks.setFireworkMeta(fireworkmeta);
|
||||
}
|
||||
|
||||
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() {
|
||||
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) {
|
||||
if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
|
||||
ret.append(chatFormat);
|
||||
for (ChatColor CHAT_FORMAT : CHAT_FORMATS) {
|
||||
if (rand.nextInt(4) == 0) {
|
||||
ret.append(CHAT_FORMAT);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a bow, false otherwise
|
||||
*/
|
||||
public static boolean isBow(ItemStack item) {
|
||||
@@ -37,6 +38,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a sword.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a sword, false otherwise
|
||||
*/
|
||||
public static boolean isSword(ItemStack item) {
|
||||
@@ -59,6 +61,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a hoe.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a hoe, false otherwise
|
||||
*/
|
||||
public static boolean isHoe(ItemStack item) {
|
||||
@@ -81,6 +84,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a shovel.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
public static boolean isShovel(ItemStack item) {
|
||||
@@ -103,6 +107,7 @@ public class ItemUtils {
|
||||
* Checks if the item is an axe.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is an axe, false otherwise
|
||||
*/
|
||||
public static boolean isAxe(ItemStack item) {
|
||||
@@ -125,6 +130,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a pickaxe.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a pickaxe, false otherwise
|
||||
*/
|
||||
public static boolean isPickaxe(ItemStack item) {
|
||||
@@ -147,6 +153,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a helmet.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a helmet, false otherwise
|
||||
*/
|
||||
public static boolean isHelmet(ItemStack item) {
|
||||
@@ -169,6 +176,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a chestplate.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a chestplate, false otherwise
|
||||
*/
|
||||
public static boolean isChestplate(ItemStack item) {
|
||||
@@ -191,6 +199,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a pair of pants.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a pair of pants, false otherwise
|
||||
*/
|
||||
public static boolean isLeggings(ItemStack item) {
|
||||
@@ -213,6 +222,7 @@ public class ItemUtils {
|
||||
* Checks if the item is a pair of boots.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a pair of boots, false otherwise
|
||||
*/
|
||||
public static boolean isBoots(ItemStack item) {
|
||||
@@ -235,6 +245,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a wearable armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
public static boolean isMinecraftArmor(ItemStack item) {
|
||||
@@ -255,6 +267,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a leather armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is leather armor, false otherwise
|
||||
*/
|
||||
public static boolean isLeatherArmor(ItemStack item) {
|
||||
@@ -274,6 +287,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a gold armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is gold armor, false otherwise
|
||||
*/
|
||||
public static boolean isGoldArmor(ItemStack item) {
|
||||
@@ -293,6 +307,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is an iron armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is iron armor, false otherwise
|
||||
*/
|
||||
public static boolean isIronArmor(ItemStack item) {
|
||||
@@ -312,6 +327,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a diamond armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is diamond armor, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondArmor(ItemStack item) {
|
||||
@@ -331,6 +347,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a chainmail armor piece.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is chainmail armor, false otherwise
|
||||
*/
|
||||
public static boolean isChainmailArmor(ItemStack item) {
|
||||
@@ -350,6 +367,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a *vanilla* tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a tool, false otherwise
|
||||
*/
|
||||
public static boolean isMinecraftTool(ItemStack item) {
|
||||
@@ -360,6 +378,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a stone tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isStoneTool(ItemStack item) {
|
||||
@@ -380,6 +399,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a wooden tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a wooden tool, false otherwise
|
||||
*/
|
||||
public static boolean isWoodTool(ItemStack item) {
|
||||
@@ -400,6 +420,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a string tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a string tool, false otherwise
|
||||
*/
|
||||
public static boolean isStringTool(ItemStack item) {
|
||||
@@ -418,6 +439,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a gold tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isGoldTool(ItemStack item) {
|
||||
@@ -438,6 +460,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is an iron tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is an iron tool, false otherwise
|
||||
*/
|
||||
public static boolean isIronTool(ItemStack item) {
|
||||
@@ -461,6 +484,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a diamond tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a diamond tool, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondTool(ItemStack item) {
|
||||
@@ -481,6 +505,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is enchantable.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is enchantable, false otherwise
|
||||
*/
|
||||
public static boolean isEnchantable(ItemStack item) {
|
||||
@@ -545,6 +570,7 @@ public class ItemUtils {
|
||||
* Check if an item is sharable.
|
||||
*
|
||||
* @param item Item that will get shared
|
||||
*
|
||||
* @return True if the item can be shared.
|
||||
*/
|
||||
public static boolean isSharable(ItemStack item) {
|
||||
@@ -559,6 +585,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a mining drop.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a mining drop, false otherwise
|
||||
*/
|
||||
public static boolean isMiningDrop(ItemStack item) {
|
||||
@@ -591,6 +618,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a herbalism drop.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a herbalism drop, false otherwise
|
||||
*/
|
||||
public static boolean isHerbalismDrop(ItemStack item) {
|
||||
@@ -626,6 +654,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a mob drop.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a mob drop, false otherwise
|
||||
*/
|
||||
public static boolean isMobDrop(ItemStack item) {
|
||||
@@ -668,6 +697,7 @@ public class ItemUtils {
|
||||
* Checks to see if an item is a woodcutting drop.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a woodcutting drop, false otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a miscellaneous drop, false otherwise
|
||||
*/
|
||||
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 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 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_VOLUME = 0.75F; // Use max volume always
|
||||
|
||||
private Misc() {};
|
||||
private Misc() {}
|
||||
|
||||
public static float getFizzPitch() {
|
||||
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.
|
||||
*
|
||||
* @param inHand The item to check the tier of
|
||||
*
|
||||
* @return the tier of the item
|
||||
*/
|
||||
public static int getTier(ItemStack inHand) {
|
||||
@@ -100,9 +100,10 @@ public final class Misc {
|
||||
/**
|
||||
* Determine if two locations are near each other.
|
||||
*
|
||||
* @param first The first location
|
||||
* @param second The second location
|
||||
* @param first The first location
|
||||
* @param second The second location
|
||||
* @param maxDistance The max distance apart
|
||||
*
|
||||
* @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) {
|
||||
@@ -123,7 +124,7 @@ public final class Misc {
|
||||
* Drop items at a given location.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
*/
|
||||
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
||||
if (random.nextInt(100) < chance) {
|
||||
@@ -149,7 +150,7 @@ public final class Misc {
|
||||
* Drop items with random quantity at a given location.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param location The location to drop the item at
|
||||
* @param location The location to drop the item at
|
||||
* @param itemStack The item to drop
|
||||
*/
|
||||
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) {
|
||||
Chunk chunk = player.getLocation().getChunk();
|
||||
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.
|
||||
*
|
||||
* <p/>
|
||||
* This list is not sorted in any particular order.
|
||||
* If an exact match is found, the returned list will only contain a single result.
|
||||
*
|
||||
* @param partialName Name to match
|
||||
*
|
||||
* @return List of all possible names
|
||||
*/
|
||||
public static List<String> matchPlayer(String partialName) {
|
||||
|
||||
@@ -16,13 +16,14 @@ import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class MobHealthbarUtils {
|
||||
private MobHealthbarUtils() {};
|
||||
private MobHealthbarUtils() {}
|
||||
|
||||
/**
|
||||
* Fix issues with death messages caused by the mob healthbars.
|
||||
*
|
||||
* @param deathMessage The original death message
|
||||
* @param player The player who died
|
||||
* @param player The player who died
|
||||
*
|
||||
* @return the fixed death message
|
||||
*/
|
||||
public static String fixDeathMessage(String deathMessage, Player player) {
|
||||
@@ -158,6 +159,7 @@ public final class MobHealthbarUtils {
|
||||
* Check if a given LivingEntity is a boss.
|
||||
*
|
||||
* @param livingEntity The {@link LivingEntity} of the livingEntity to check
|
||||
*
|
||||
* @return true if the livingEntity is a boss, false otherwise
|
||||
*/
|
||||
public static boolean isBoss(LivingEntity livingEntity) {
|
||||
|
||||
@@ -31,6 +31,7 @@ public final class ModUtils {
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
*
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
@@ -41,6 +42,7 @@ public final class ModUtils {
|
||||
* Get the custom entity associated with an entity.
|
||||
*
|
||||
* @param entity The entity to check
|
||||
*
|
||||
* @return the entity is if exists, null otherwise
|
||||
*/
|
||||
public static CustomEntity getCustomEntity(Entity entity) {
|
||||
@@ -51,6 +53,7 @@ public final class ModUtils {
|
||||
* Get the custom block associated with an block.
|
||||
*
|
||||
* @param blockState The BlockState of the bloc to check
|
||||
*
|
||||
* @return the block if it exists, null otherwise
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||
@@ -61,6 +64,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is a woodcutting block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents a custom woodcutting block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||
@@ -71,6 +75,7 @@ public final class ModUtils {
|
||||
* Check if a custom block should not activate abilites.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents an ability block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||
@@ -81,6 +86,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is a mining block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents a custom mining block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||
@@ -91,6 +97,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is an excavation block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents a custom excavation block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||
@@ -101,6 +108,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is an herbalism block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents a custom herbalism block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||
@@ -111,6 +119,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is a leaf block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents leaves, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||
@@ -121,6 +130,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is a log block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||
@@ -131,6 +141,7 @@ public final class ModUtils {
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
*
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(BlockState blockState) {
|
||||
@@ -141,6 +152,7 @@ public final class ModUtils {
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack item) {
|
||||
@@ -151,6 +163,7 @@ public final class ModUtils {
|
||||
* Checks to see if an entity is a custom entity.
|
||||
*
|
||||
* @param entity Entity to check
|
||||
*
|
||||
* @return true if the entity is a custom entity, false otherwise
|
||||
*/
|
||||
public static boolean isCustomEntity(Entity entity) {
|
||||
@@ -161,6 +174,7 @@ public final class ModUtils {
|
||||
* Check if a custom entity is a boss.
|
||||
*
|
||||
* @param entity The entity to check
|
||||
*
|
||||
* @return true if the entity represents a boss, false otherwise
|
||||
*/
|
||||
public static boolean isCustomBossEntity(Entity entity) {
|
||||
|
||||
@@ -8,6 +8,7 @@ public class StringUtils {
|
||||
* Gets a capitalized version of the target string.
|
||||
*
|
||||
* @param target String to capitalize
|
||||
*
|
||||
* @return the capitalized string
|
||||
*/
|
||||
public static String getCapitalized(String target) {
|
||||
@@ -44,6 +45,7 @@ public class StringUtils {
|
||||
* Gets the int represented by this string.
|
||||
*
|
||||
* @param string The string to parse
|
||||
*
|
||||
* @return the int represented by this string
|
||||
*/
|
||||
public static int getInt(String string) {
|
||||
@@ -59,6 +61,7 @@ public class StringUtils {
|
||||
* Gets the long represented by this string.
|
||||
*
|
||||
* @param string The string to parse
|
||||
*
|
||||
* @return the long represented by this string
|
||||
*/
|
||||
public static long getLong(String string) {
|
||||
@@ -74,6 +77,7 @@ public class StringUtils {
|
||||
* Determine if a string represents an Integer
|
||||
*
|
||||
* @param string String to check
|
||||
*
|
||||
* @return true if the string is an Integer, false otherwise
|
||||
*/
|
||||
public static boolean isInt(String string) {
|
||||
@@ -90,6 +94,7 @@ public class StringUtils {
|
||||
* Determine if a string represents a Double
|
||||
*
|
||||
* @param string String to check
|
||||
*
|
||||
* @return true if the string is a Double, false otherwise
|
||||
*/
|
||||
public static boolean isDouble(String string) {
|
||||
|
||||
@@ -7,9 +7,9 @@ public interface ChunkletManager {
|
||||
/**
|
||||
* Loads a specific chunklet
|
||||
*
|
||||
* @param cx Chunklet X 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 cx Chunklet X 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 world World that the chunklet needs to be loaded in
|
||||
*/
|
||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||
@@ -17,9 +17,9 @@ public interface ChunkletManager {
|
||||
/**
|
||||
* Unload a specific chunklet
|
||||
*
|
||||
* @param cx Chunklet X 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 cx Chunklet X 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 world World that the chunklet needs to be unloaded from
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param cx Chunk X coordinate that is to be loaded
|
||||
* @param cz Chunk Z 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 world World that the Chunk is in
|
||||
*/
|
||||
public void loadChunk(int cx, int cz, World world);
|
||||
@@ -36,8 +36,8 @@ public interface ChunkletManager {
|
||||
/**
|
||||
* Unload a given Chunk's Chunklet data
|
||||
*
|
||||
* @param cx Chunk X coordinate that is to be unloaded
|
||||
* @param cz Chunk Z 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 world World that the Chunk is in
|
||||
*/
|
||||
public void unloadChunk(int cx, int cz, World world);
|
||||
@@ -45,8 +45,8 @@ public interface ChunkletManager {
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is loaded
|
||||
*
|
||||
* @param cx Chunk X coordinate that is loaded
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param cx Chunk X coordinate that is loaded
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param world World that the chunk was loaded in
|
||||
*/
|
||||
public void chunkLoaded(int cx, int cz, World world);
|
||||
@@ -54,8 +54,8 @@ public interface ChunkletManager {
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is unloaded
|
||||
*
|
||||
* @param cx Chunk X coordinate that is unloaded
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param cx Chunk X coordinate that is unloaded
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param world World that the chunk was unloaded in
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to check
|
||||
* @param y Y coordinate to check
|
||||
* @param z Z coordinate to check
|
||||
* @param x X coordinate to check
|
||||
* @param y Y coordinate to check
|
||||
* @param z Z coordinate to check
|
||||
* @param world World to check in
|
||||
*
|
||||
* @return true if the given location is set to true, false if otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param block Block location to check
|
||||
*
|
||||
* @return true if the given block location is set to true, false if otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
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 y y 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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return ChunkletStore from the specified 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.
|
||||
*
|
||||
* <p/>
|
||||
* Useful for turning off Chunklets without actually doing much work
|
||||
*/
|
||||
public class NullChunkletManager implements ChunkletManager {
|
||||
|
||||
@@ -19,9 +19,9 @@ public interface ChunkManager {
|
||||
/**
|
||||
* Loads a specific chunklet
|
||||
*
|
||||
* @param cx Chunklet X 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 cx Chunklet X 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 world World that the chunklet needs to be loaded in
|
||||
*/
|
||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||
@@ -29,9 +29,9 @@ public interface ChunkManager {
|
||||
/**
|
||||
* Unload a specific chunklet
|
||||
*
|
||||
* @param cx Chunklet X 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 cx Chunklet X 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 world World that the chunklet needs to be unloaded from
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param cx Chunk X coordinate that is to be loaded
|
||||
* @param cz Chunk Z 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 world World that the Chunk is in
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param cx Chunk X coordinate that is to be unloaded
|
||||
* @param cz Chunk Z 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 world World that the Chunk is in
|
||||
*/
|
||||
public void unloadChunk(int cx, int cz, World world);
|
||||
@@ -57,8 +57,8 @@ public interface ChunkManager {
|
||||
/**
|
||||
* Saves a given Chunk's Chunklet data
|
||||
*
|
||||
* @param cx Chunk X coordinate that is to be saved
|
||||
* @param cz Chunk Z 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 world World that the Chunk is in
|
||||
*/
|
||||
public void saveChunk(int cx, int cz, World world);
|
||||
@@ -68,8 +68,8 @@ public interface ChunkManager {
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is loaded
|
||||
*
|
||||
* @param cx Chunk X coordinate that is loaded
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param cx Chunk X coordinate that is loaded
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param world World that the chunk was loaded in
|
||||
*/
|
||||
public void chunkLoaded(int cx, int cz, World world);
|
||||
@@ -77,8 +77,8 @@ public interface ChunkManager {
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is unloaded
|
||||
*
|
||||
* @param cx Chunk X coordinate that is unloaded
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param cx Chunk X coordinate that is unloaded
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param world World that the chunk was unloaded in
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to check
|
||||
* @param y Y coordinate to check
|
||||
* @param z Z coordinate to check
|
||||
* @param x X coordinate to check
|
||||
* @param y Y coordinate to check
|
||||
* @param z Z coordinate to check
|
||||
* @param world World to check in
|
||||
*
|
||||
* @return true if the given location is set to true, false if otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param block Block location to check
|
||||
*
|
||||
* @return true if the given block location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(Block block);
|
||||
@@ -137,6 +139,7 @@ public interface ChunkManager {
|
||||
* Check to see if a given BlockState location is set to true
|
||||
*
|
||||
* @param blockState BlockState to check
|
||||
*
|
||||
* @return true if the given BlockState location is set to true, false if otherwise
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
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 y y 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
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z);
|
||||
|
||||
@@ -160,7 +160,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
try {
|
||||
chunkStore = readChunkStore(world, cx, cz);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
catch (Exception e) {
|
||||
}
|
||||
|
||||
if (chunkStore == null) {
|
||||
return;
|
||||
|
||||
@@ -143,7 +143,8 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
try {
|
||||
store[x][z][y] = temp[x][y][z];
|
||||
}
|
||||
catch (Exception e) {}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
|
||||
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.gmail.nossr50.commands.hardcore.VampirismCommand;
|
||||
import com.gmail.nossr50.commands.party.PartyCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||
import com.gmail.nossr50.commands.player.MccooldownCommand;
|
||||
import com.gmail.nossr50.commands.player.McrankCommand;
|
||||
import com.gmail.nossr50.commands.player.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.player.MctopCommand;
|
||||
@@ -53,7 +52,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public final class CommandRegistrationManager {
|
||||
private CommandRegistrationManager() {};
|
||||
private CommandRegistrationManager() {}
|
||||
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
@@ -207,15 +206,6 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
private static void registerMccooldownCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mccooldown");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mccooldown"));
|
||||
command.setPermission("mcmmo.commands.mccooldown");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mccooldowns"));
|
||||
command.setExecutor(new MccooldownCommand());
|
||||
}
|
||||
|
||||
private static void registerMcabilityCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcability");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
|
||||
@@ -385,7 +375,8 @@ public final class CommandRegistrationManager {
|
||||
command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize
|
||||
command.setPermission("mcmmo.commands.mcscoreboard");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "<CLEAR | KEEP | TIME>"));
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "<CLEAR | RANK | STATS | TOP>"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.3", "mcscoreboard", "top", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||
command.setExecutor(new McscoreboardCommand());
|
||||
}
|
||||
|
||||
@@ -436,7 +427,6 @@ public final class CommandRegistrationManager {
|
||||
|
||||
// Player Commands
|
||||
registerInspectCommand();
|
||||
registerMccooldownCommand();
|
||||
registerMcrankCommand();
|
||||
registerMcstatsCommand();
|
||||
registerMctopCommand();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.util.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -59,7 +58,7 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
public static boolean hidden(CommandSender sender, Player target, boolean hasPermission) {
|
||||
if (sender instanceof Player && !((Player)sender).canSee(target) && !hasPermission) {
|
||||
if (sender instanceof Player && !((Player) sender).canSee(target) && !hasPermission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,8 +86,8 @@ public final class CommandUtils {
|
||||
/**
|
||||
* Checks if there is a valid mcMMOPlayer object.
|
||||
*
|
||||
* @param sender CommandSender who used the command
|
||||
* @param playerName name of the target player
|
||||
* @param sender CommandSender who used the command
|
||||
* @param playerName name of the target player
|
||||
* @param mcMMOPlayer mcMMOPlayer object of the target player
|
||||
*
|
||||
* @return true if the player is online and a valid mcMMOPlayer object was found
|
||||
@@ -98,9 +97,10 @@ public final class CommandUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
|
||||
if (!player.hasPlayedBefore()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
PlayerProfile playerProfile = new PlayerProfile(playerName, false);
|
||||
|
||||
if (unloadedProfile(sender, playerProfile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
|
||||
@@ -49,8 +49,9 @@ public class FormulaManager {
|
||||
* the amount of levels and experience, using the previously
|
||||
* used formula type.
|
||||
*
|
||||
* @param skillLevel Amount of levels
|
||||
* @param skillLevel Amount of levels
|
||||
* @param skillXPLevel Amount of experience
|
||||
*
|
||||
* @return The total amount of experience
|
||||
*/
|
||||
public int calculateTotalExperience(int skillLevel, int skillXPLevel) {
|
||||
@@ -69,9 +70,10 @@ public class FormulaManager {
|
||||
* Calculate how many levels a player should have using
|
||||
* the new formula type.
|
||||
*
|
||||
* @param skillType skill where new levels and experience are calculated for
|
||||
* @param experience total amount of experience
|
||||
* @param skillType skill where new levels and experience are calculated for
|
||||
* @param experience total amount of experience
|
||||
* @param formulaType The new {@link FormulaType}
|
||||
*
|
||||
* @return the amount of levels and experience
|
||||
*/
|
||||
public int[] calculateNewLevel(SkillType skillType, int experience, FormulaType formulaType) {
|
||||
@@ -99,8 +101,9 @@ public class FormulaManager {
|
||||
* if cache doesn't contain the given value it is calculated and added
|
||||
* to the cached data.
|
||||
*
|
||||
* @param level level to check
|
||||
* @param level level to check
|
||||
* @param formulaType The {@link FormulaType} used
|
||||
*
|
||||
* @return amount of experience needed to reach next level
|
||||
*/
|
||||
public int getCachedXpToLevel(int level, FormulaType formulaType) {
|
||||
|
||||
@@ -20,6 +20,7 @@ public final class UserManager {
|
||||
* Add a new user.
|
||||
*
|
||||
* @param player The player to create a user record for
|
||||
*
|
||||
* @return the player's {@link McMMOPlayer} object
|
||||
*/
|
||||
public static McMMOPlayer addUser(Player player) {
|
||||
@@ -74,6 +75,7 @@ public final class UserManager {
|
||||
* Get the McMMOPlayer of a player by name.
|
||||
*
|
||||
* @param playerName The name of the player whose McMMOPlayer to retrieve
|
||||
*
|
||||
* @return the player's McMMOPlayer object
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(String playerName) {
|
||||
@@ -84,6 +86,7 @@ public final class UserManager {
|
||||
* Get the McMMOPlayer of a player.
|
||||
*
|
||||
* @param player The player whose McMMOPlayer to retrieve
|
||||
*
|
||||
* @return the player's McMMOPlayer object
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(OfflinePlayer player) {
|
||||
|
||||
@@ -1,389 +1,328 @@
|
||||
package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.scoreboards.ScoreboardChangeTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class ScoreboardManager {
|
||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
||||
private static final Map<String, Scoreboard> PLAYER_SCOREBOARDS = new HashMap<String, Scoreboard>();
|
||||
private static final Scoreboard GLOBAL_STATS_SCOREBOARD = mcMMO.p.getServer().getScoreboardManager().getNewScoreboard();
|
||||
|
||||
// do not localize; these are internal identifiers
|
||||
static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
|
||||
static final String POWER_OBJECTIVE = "mcmmo_pwrlvl";
|
||||
private final static String PLAYER_STATS_HEADER = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
||||
private final static String PLAYER_RANK_HEADER = LocaleLoader.getString("Scoreboard.Header.PlayerRank");
|
||||
private final static String PLAYER_INSPECT_HEADER = LocaleLoader.getString("Scoreboard.Header.PlayerInspect");
|
||||
private final static String POWER_LEVEL_HEADER = LocaleLoader.getString("Scoreboard.Header.PowerLevel");
|
||||
|
||||
static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
||||
static final String HEADER_COOLDOWNS = LocaleLoader.getString("Scoreboard.Header.PlayerCooldowns");
|
||||
static final String HEADER_RANK = LocaleLoader.getString("Scoreboard.Header.PlayerRank");
|
||||
static final String TAG_POWER_LEVEL = LocaleLoader.getString("Scoreboard.Header.PowerLevel");
|
||||
private final static String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
||||
private final static String LEVEL = LocaleLoader.getString("Scoreboard.Misc.Level");
|
||||
private final static String CURRENT_XP = LocaleLoader.getString("Scoreboard.Misc.CurrentXP");
|
||||
private final static String REMAINING_XP = LocaleLoader.getString("Scoreboard.Misc.RemainingXP");
|
||||
private final static String OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall");
|
||||
|
||||
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
||||
private final static List<String> SCOREBOARD_TASKS = new ArrayList<String>();
|
||||
|
||||
static final OfflinePlayer LABEL_POWER_LEVEL = getOfflinePlayer(POWER_LEVEL);
|
||||
static final OfflinePlayer LABEL_LEVEL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Level"));
|
||||
static final OfflinePlayer LABEL_CURRENT_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.CurrentXP"));
|
||||
static final OfflinePlayer LABEL_REMAINING_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.RemainingXP"));
|
||||
static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown"));
|
||||
static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall"));
|
||||
|
||||
static final Map<SkillType, OfflinePlayer> skillLabels;
|
||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsColored;
|
||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill;
|
||||
static {
|
||||
ImmutableMap.Builder<SkillType, OfflinePlayer> b = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> c = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> d = ImmutableMap.builder();
|
||||
if (Config.getInstance().getScoreboardRainbows()) {
|
||||
Random shuffler = new Random(Bukkit.getWorlds().get(0).getSeed());
|
||||
List<ChatColor> colors = Arrays.asList(
|
||||
ChatColor.WHITE,
|
||||
ChatColor.YELLOW,
|
||||
ChatColor.LIGHT_PURPLE,
|
||||
ChatColor.RED,
|
||||
ChatColor.AQUA,
|
||||
ChatColor.GREEN,
|
||||
ChatColor.DARK_GRAY,
|
||||
ChatColor.BLUE,
|
||||
ChatColor.DARK_PURPLE,
|
||||
ChatColor.DARK_RED,
|
||||
ChatColor.DARK_AQUA,
|
||||
ChatColor.DARK_GREEN,
|
||||
ChatColor.DARK_BLUE
|
||||
);
|
||||
Collections.shuffle(colors, shuffler);
|
||||
int i = 0;
|
||||
for (SkillType type : SkillType.values()) {
|
||||
// Include child skills
|
||||
b.put(type, getOfflinePlayer(colors.get(i) + type.getSkillName()));
|
||||
if (type.getAbility() != null) {
|
||||
// the toString is the properly formatted verison for abilities
|
||||
c.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getAbilityName()));
|
||||
if (type == SkillType.MINING) {
|
||||
c.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getAbilityName()));
|
||||
}
|
||||
}
|
||||
if (++i == colors.size()) i = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
// Include child skills
|
||||
b.put(type, getOfflinePlayer(ChatColor.GREEN + type.getSkillName()));
|
||||
if (type.getAbility() != null) {
|
||||
// the toString is the properly formatted verison for abilities
|
||||
c.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getAbilityName()));
|
||||
if (type == SkillType.MINING) {
|
||||
c.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getAbilityName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (AbilityType type : AbilityType.NORMAL_ABILITIES) {
|
||||
if (type == AbilityType.BLAST_MINING) {
|
||||
// Special-case: get a different color
|
||||
d.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.BLUE + AbilityType.BLAST_MINING.getAbilityName()));
|
||||
}
|
||||
else {
|
||||
d.put(type, getOfflinePlayerDots(ChatColor.AQUA + type.getAbilityName()));
|
||||
}
|
||||
}
|
||||
|
||||
skillLabels = b.build();
|
||||
abilityLabelsColored = c.build();
|
||||
abilityLabelsSkill = d.build();
|
||||
}
|
||||
|
||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||
|
||||
private static OfflinePlayer getOfflinePlayer(String name) {
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
return Bukkit.getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
private static OfflinePlayer getOfflinePlayerDots(String name) {
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16 - 2) + "..";
|
||||
}
|
||||
return Bukkit.getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public enum SidebarType {
|
||||
NONE,
|
||||
SKILL_BOARD,
|
||||
STATS_BOARD,
|
||||
COOLDOWNS_BOARD,
|
||||
RANK_BOARD,
|
||||
TOP_BOARD;
|
||||
}
|
||||
|
||||
// **** Listener call-ins **** //
|
||||
|
||||
// Called by PlayerJoinEvent listener
|
||||
public static void setupPlayer(Player p) {
|
||||
PLAYER_SCOREBOARDS.put(p.getName(), ScoreboardWrapper.create(p));
|
||||
dirtyPowerLevels.add(p.getName());
|
||||
}
|
||||
|
||||
// Called by PlayerQuitEvent listener
|
||||
public static void teardownPlayer(Player p) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(p.getName());
|
||||
if (wrapper.revertTask != null) {
|
||||
wrapper.revertTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
// Called in onDisable()
|
||||
public static void teardownAll() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
teardownPlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Called by ScoreboardWrapper when its Player logs off and an action tries to be performed
|
||||
public static void cleanup(ScoreboardWrapper wrapper) {
|
||||
PLAYER_SCOREBOARDS.remove(wrapper.playerName);
|
||||
if (wrapper.revertTask != null) {
|
||||
wrapper.revertTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
// Called by internal level-up event listener
|
||||
public static void handleLevelUp(Player player, SkillType skill) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
if ((wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) || (wrapper.isStatsScoreboard()) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
|
||||
// Otherboards
|
||||
String playerName = player.getName();
|
||||
for (ScoreboardWrapper w : PLAYER_SCOREBOARDS.values()) {
|
||||
if (w.isStatsScoreboard() && playerName.equals(w.targetPlayer) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
dirtyPowerLevels.add(player.getName());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSkillLevelUpBoard()) {
|
||||
enablePlayerSkillLevelUpScoreboard(player, skill);
|
||||
}
|
||||
}
|
||||
|
||||
// Called by internal xp event listener
|
||||
public static void handleXp(Player player, SkillType skill) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
if (wrapper.isSkillScoreboard() && wrapper.targetSkill == skill && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
}
|
||||
|
||||
// Called by internal ability event listeners
|
||||
public static void cooldownUpdate(Player player, SkillType skill) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
if ((wrapper.isCooldownScoreboard() || wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
}
|
||||
|
||||
// **** Setup methods **** //
|
||||
|
||||
public static void enablePlayerSkillScoreboard(Player player, SkillType skill) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSkill(skill);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getSkillScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enablePlayerSkillLevelUpScoreboard(Player player, SkillType skill) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
// Do NOT run if already shown
|
||||
if (wrapper.isBoardShown()) {
|
||||
public static void setupPlayerScoreboard(String playerName) {
|
||||
if (PLAYER_SCOREBOARDS.containsKey(playerName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSkill(skill);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getSkillLevelUpTime());
|
||||
PLAYER_SCOREBOARDS.put(playerName, mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
|
||||
public static void enablePlayerStatsScoreboard(Player player) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSelfStats();
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeInspectStats(targetProfile);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getInspectScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enablePlayerCooldownScoreboard(Player player) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeCooldowns();
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showPlayerRankScoreboard(Player bukkitPlayer, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSelfRank();
|
||||
wrapper.acceptRankData(rank);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getRankScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showPlayerRankScoreboardOthers(Player bukkitPlayer, String targetName, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeInspectRank(targetName);
|
||||
wrapper.acceptRankData(rank);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getRankScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showTopScoreboard(Player player, SkillType skill, int pageNumber, List<PlayerStat> stats) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeTop(skill, pageNumber);
|
||||
wrapper.acceptLeaderboardData(stats);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getTopScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeTopPower(pageNumber);
|
||||
wrapper.acceptLeaderboardData(stats);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getTopScoreboardTime());
|
||||
}
|
||||
|
||||
// **** Helper methods **** //
|
||||
|
||||
/**
|
||||
* @return false if power levels are disabled
|
||||
*/
|
||||
public static boolean powerLevelHeartbeat() {
|
||||
Objective mainObjective = getPowerLevelObjective();
|
||||
if (mainObjective == null) {
|
||||
return false; // indicates
|
||||
public static void enablePowerLevelDisplay(Player player) {
|
||||
if (!Config.getInstance().getPowerLevelsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dirtyPowerLevels.isEmpty())
|
||||
mcMMO.p.getLogger().info(dirtyPowerLevels.toString());
|
||||
for (String playerName : dirtyPowerLevels) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(playerName);
|
||||
Player player = mcpl.getPlayer();
|
||||
int power = mcpl.getPowerLevel();
|
||||
Scoreboard scoreboard = player.getScoreboard();
|
||||
Objective objective;
|
||||
|
||||
mainObjective.getScore(player).setScore(power);
|
||||
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
||||
wrapper.updatePowerLevel(player, power);
|
||||
}
|
||||
}
|
||||
dirtyPowerLevels.clear();
|
||||
if (scoreboard.getObjective(DisplaySlot.BELOW_NAME) == null) {
|
||||
objective = scoreboard.registerNewObjective(POWER_LEVEL_HEADER.substring(0, Math.min(POWER_LEVEL_HEADER.length(), 16)), "dummy");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates the power level objective on the main scoreboard.
|
||||
* <p>
|
||||
* If power levels are disabled, the objective is deleted and null is
|
||||
* returned.
|
||||
*
|
||||
* @return the main scoreboard objective, or null if disabled
|
||||
*/
|
||||
public static Objective getPowerLevelObjective() {
|
||||
if (!Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
Objective obj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
if (obj != null) {
|
||||
obj.unregister();
|
||||
mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Objective powerObj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
if (powerObj == null) {
|
||||
powerObj = Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
|
||||
powerObj.setDisplayName(TAG_POWER_LEVEL);
|
||||
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
return powerObj;
|
||||
}
|
||||
|
||||
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
||||
if (displayTime == -1) {
|
||||
wrapper.showBoardWithNoRevert();
|
||||
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
else {
|
||||
wrapper.showBoardAndScheduleRevert(displayTime * Misc.TICK_CONVERSION_FACTOR);
|
||||
objective = scoreboard.getObjective(POWER_LEVEL_HEADER.substring(0, Math.min(POWER_LEVEL_HEADER.length(), 16)));
|
||||
|
||||
if (objective != null) {
|
||||
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Another plugin is using this scoreboard slot, so power levels cannot be enabled."); //TODO: Locale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBoardShown(String playerName) {
|
||||
return PLAYER_SCOREBOARDS.get(playerName).isBoardShown();
|
||||
public static void enablePlayerSkillScoreboard(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(skill.getSkillName());
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(skill.getSkillName(), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerSkillScores(mcMMOPlayer.getProfile(), skill, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getSkillScoreboardTime());
|
||||
}
|
||||
|
||||
public static void clearBoard(String playerName) {
|
||||
PLAYER_SCOREBOARDS.get(playerName).tryRevertBoard();
|
||||
public static void enablePlayerStatsScoreboard(McMMOPlayer mcMMOPlayer) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(PLAYER_STATS_HEADER.substring(0, Math.min(PLAYER_STATS_HEADER.length(), 16)));
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(PLAYER_STATS_HEADER.substring(0, Math.min(PLAYER_STATS_HEADER.length(), 16)), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerStatsScores(mcMMOPlayer, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getMcstatsScoreboardTime());
|
||||
}
|
||||
|
||||
public static void keepBoard(String playerName) {
|
||||
PLAYER_SCOREBOARDS.get(playerName).cancelRevert();
|
||||
public static void enablePlayerRankScoreboard(Player player) {
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(PLAYER_RANK_HEADER.substring(0, Math.min(PLAYER_RANK_HEADER.length(), 16)));
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(PLAYER_RANK_HEADER.substring(0, Math.min(PLAYER_RANK_HEADER.length(), 16)), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerRankScores(player, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getMcrankScoreboardTime());
|
||||
}
|
||||
|
||||
public static void setRevertTimer(String playerName, int seconds) {
|
||||
PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR);;
|
||||
public static void enablePlayerRankScoreboardOthers(Player player, String targetName) {
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(PLAYER_RANK_HEADER.substring(0, Math.min(PLAYER_RANK_HEADER.length(), 16)));
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(PLAYER_RANK_HEADER.substring(0, Math.min(PLAYER_RANK_HEADER.length(), 16)), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerRankOthersScores(targetName, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getMcrankScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enablePlayerInspectScoreboardOnline(Player player, McMMOPlayer mcMMOTarget) {
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(PLAYER_INSPECT_HEADER.substring(0, Math.min(PLAYER_INSPECT_HEADER.length(), 16)));
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(PLAYER_INSPECT_HEADER.substring(0, Math.min(PLAYER_INSPECT_HEADER.length(), 16)), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerInspectOnlineScores(mcMMOTarget, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getInspectScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enablePlayerInspectScoreboardOffline(Player player, PlayerProfile targetProfile) {
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
Scoreboard newScoreboard = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
Objective objective = newScoreboard.getObjective(PLAYER_INSPECT_HEADER.substring(0, Math.min(PLAYER_INSPECT_HEADER.length(), 16)));
|
||||
|
||||
if (objective == null) {
|
||||
objective = newScoreboard.registerNewObjective(PLAYER_INSPECT_HEADER.substring(0, Math.min(PLAYER_INSPECT_HEADER.length(), 16)), "dummy");
|
||||
}
|
||||
|
||||
updatePlayerInspectOfflineScores(targetProfile, objective);
|
||||
changeScoreboard(player, oldScoreboard, newScoreboard, Config.getInstance().getInspectScoreboardTime());
|
||||
}
|
||||
|
||||
public static void enableGlobalStatsScoreboard(Player player, String skillName, int pageNumber) {
|
||||
Objective oldObjective = GLOBAL_STATS_SCOREBOARD.getObjective(skillName);
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
|
||||
if (oldObjective != null) {
|
||||
oldObjective.unregister();
|
||||
}
|
||||
|
||||
Objective newObjective = GLOBAL_STATS_SCOREBOARD.registerNewObjective(skillName, "dummy");
|
||||
newObjective.setDisplayName(ChatColor.GOLD + (skillName.equalsIgnoreCase("all") ? POWER_LEVEL : SkillType.getSkill(skillName).getSkillName()));
|
||||
|
||||
updateGlobalStatsScores(player, newObjective, skillName, pageNumber);
|
||||
changeScoreboard(player, oldScoreboard, GLOBAL_STATS_SCOREBOARD, Config.getInstance().getMctopScoreboardTime());
|
||||
}
|
||||
|
||||
private static void updatePlayerSkillScores(PlayerProfile profile, SkillType skill, Objective objective) {
|
||||
Server server = mcMMO.p.getServer();
|
||||
int currentXP = profile.getSkillXpLevel(skill);
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(LEVEL)).setScore(profile.getSkillLevel(skill));
|
||||
objective.getScore(server.getOfflinePlayer(CURRENT_XP)).setScore(currentXP);
|
||||
objective.getScore(server.getOfflinePlayer(REMAINING_XP)).setScore(profile.getXpToLevel(skill) - currentXP);
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void updatePlayerStatsScores(McMMOPlayer mcMMOPlayer, Objective objective) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
Server server = mcMMO.p.getServer();
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(skill.getSkillName())).setScore(profile.getSkillLevel(skill));
|
||||
}
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(ChatColor.GOLD + POWER_LEVEL)).setScore(mcMMOPlayer.getPowerLevel());
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void updatePlayerRankScores(Player player, Objective objective) {
|
||||
String playerName = player.getName();
|
||||
Server server = mcMMO.p.getServer();
|
||||
Integer rank;
|
||||
|
||||
Map<String, Integer> skills = mcMMO.getDatabaseManager().readRank(playerName);
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = skills.get(skill.name());
|
||||
|
||||
if (rank != null) {
|
||||
objective.getScore(server.getOfflinePlayer(skill.getSkillName())).setScore(rank);
|
||||
}
|
||||
}
|
||||
|
||||
rank = skills.get("ALL");
|
||||
|
||||
if (rank != null) {
|
||||
objective.getScore(server.getOfflinePlayer(ChatColor.GOLD + OVERALL)).setScore(rank);
|
||||
}
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void updatePlayerRankOthersScores(String targetName, Objective objective) {
|
||||
Server server = mcMMO.p.getServer();
|
||||
Integer rank;
|
||||
|
||||
Map<String, Integer> skills = mcMMO.getDatabaseManager().readRank(targetName);
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
rank = skills.get(skill.name());
|
||||
|
||||
if (rank != null) {
|
||||
objective.getScore(server.getOfflinePlayer(skill.getSkillName())).setScore(rank);
|
||||
}
|
||||
}
|
||||
|
||||
rank = skills.get("ALL");
|
||||
|
||||
if (rank != null) {
|
||||
objective.getScore(server.getOfflinePlayer(ChatColor.GOLD + OVERALL)).setScore(rank);
|
||||
}
|
||||
|
||||
objective.setDisplayName(PLAYER_RANK_HEADER + ": " + targetName);
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void updatePlayerInspectOnlineScores(McMMOPlayer mcMMOTarget, Objective objective) {
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
PlayerProfile profile = mcMMOTarget.getProfile();
|
||||
Server server = mcMMO.p.getServer();
|
||||
int powerLevel = 0;
|
||||
int skillLevel;
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(target, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
skillLevel = profile.getSkillLevel(skill);
|
||||
objective.getScore(server.getOfflinePlayer(skill.getSkillName())).setScore(skillLevel);
|
||||
powerLevel += skillLevel;
|
||||
}
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(ChatColor.GOLD + POWER_LEVEL)).setScore(powerLevel);
|
||||
objective.setDisplayName(PLAYER_INSPECT_HEADER + target.getName());
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void updatePlayerInspectOfflineScores(PlayerProfile targetProfile, Objective objective) {
|
||||
Server server = mcMMO.p.getServer();
|
||||
int powerLevel = 0;
|
||||
int skillLevel;
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
skillLevel = targetProfile.getSkillLevel(skill);
|
||||
objective.getScore(server.getOfflinePlayer(skill.getSkillName())).setScore(skillLevel);
|
||||
powerLevel += skillLevel;
|
||||
}
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(ChatColor.GOLD + POWER_LEVEL)).setScore(powerLevel);
|
||||
objective.setDisplayName(PLAYER_INSPECT_HEADER + targetProfile.getPlayerName());
|
||||
}
|
||||
|
||||
private static void updateGlobalStatsScores(Player player, Objective objective, String skillName, int pageNumber) {
|
||||
int position = (pageNumber * 15) - 14;
|
||||
String startPosition = ((position < 10) ? "0" : "") + String.valueOf(position);
|
||||
String endPosition = String.valueOf(position + 14);
|
||||
Server server = mcMMO.p.getServer();
|
||||
|
||||
for (PlayerStat stat : mcMMO.getDatabaseManager().readLeaderboard(skillName, pageNumber, 15)) {
|
||||
String playerName = stat.name;
|
||||
playerName = (playerName.equals(player.getName()) ? ChatColor.GOLD : "") + playerName;
|
||||
|
||||
if (playerName.length() > 16) {
|
||||
playerName = playerName.substring(0, 16);
|
||||
}
|
||||
|
||||
objective.getScore(server.getOfflinePlayer(playerName)).setScore(stat.statVal);
|
||||
}
|
||||
|
||||
objective.setDisplayName(objective.getDisplayName() + " (" + startPosition + " - " + endPosition + ")");
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
private static void changeScoreboard(Player player, Scoreboard oldScoreboard, Scoreboard newScoreboard, int displayTime) {
|
||||
if (oldScoreboard != newScoreboard) {
|
||||
String playerName = player.getName();
|
||||
|
||||
player.setScoreboard(newScoreboard);
|
||||
enablePowerLevelDisplay(player);
|
||||
|
||||
if (displayTime != -1 && !SCOREBOARD_TASKS.contains(playerName)) {
|
||||
new ScoreboardChangeTask(player, oldScoreboard).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR);
|
||||
SCOREBOARD_TASKS.add(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearPendingTask(String playerName) {
|
||||
SCOREBOARD_TASKS.remove(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,543 +0,0 @@
|
||||
package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class ScoreboardWrapper {
|
||||
|
||||
// Initialization variables
|
||||
public final String playerName;
|
||||
private final Scoreboard board;
|
||||
private boolean tippedKeep = false;
|
||||
private boolean tippedClear = false;
|
||||
|
||||
// Internal usage variables (should exist)
|
||||
private SidebarType sidebarType;
|
||||
private Objective sidebarObj;
|
||||
private Objective powerObj;
|
||||
|
||||
// Parameter variables (May be null / invalid)
|
||||
private Scoreboard oldBoard = null;
|
||||
public String targetPlayer = null;
|
||||
public SkillType targetSkill = null;
|
||||
private PlayerProfile targetProfile = null;
|
||||
public int leaderboardPage = -1;
|
||||
|
||||
private ScoreboardWrapper(String playerName, Scoreboard s) {
|
||||
this.playerName = playerName;
|
||||
board = s;
|
||||
sidebarType = SidebarType.NONE;
|
||||
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
powerObj = board.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
|
||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
powerObj.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
for (McMMOPlayer mcpl : UserManager.getPlayers()) {
|
||||
powerObj.getScore(mcpl.getPlayer()).setScore(mcpl.getPowerLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ScoreboardWrapper create(Player p) {
|
||||
return new ScoreboardWrapper(p.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
|
||||
public BukkitTask updateTask = null;
|
||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper.this.updateSidebar();
|
||||
updateTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitTask revertTask = null;
|
||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper.this.tryRevertBoard();
|
||||
revertTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitTask cooldownTask = null;
|
||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper wrapper = ScoreboardWrapper.this;
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (wrapper.isBoardShown() && (wrapper.isSkillScoreboard() || wrapper.isCooldownScoreboard())) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
else {
|
||||
wrapper.stopCooldownUpdating();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void doSidebarUpdateSoon() {
|
||||
if (updateTask == null) {
|
||||
// To avoid spamming the scheduler, store the instance and run 2 ticks later
|
||||
updateTask = new ScoreboardQuickUpdate().runTaskLater(mcMMO.p, 2L);
|
||||
}
|
||||
}
|
||||
|
||||
private void startCooldownUpdating() {
|
||||
if (cooldownTask == null) {
|
||||
// Repeat every 5 seconds.
|
||||
// Cancels once all cooldowns are done, using stopCooldownUpdating().
|
||||
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopCooldownUpdating() {
|
||||
if (cooldownTask != null) {
|
||||
try {
|
||||
cooldownTask.cancel();
|
||||
} catch (Throwable ignored) {}
|
||||
cooldownTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSkillScoreboard() {
|
||||
return sidebarType == SidebarType.SKILL_BOARD;
|
||||
}
|
||||
|
||||
public boolean isCooldownScoreboard() {
|
||||
return sidebarType == SidebarType.COOLDOWNS_BOARD;
|
||||
}
|
||||
|
||||
public boolean isStatsScoreboard() {
|
||||
return sidebarType == SidebarType.STATS_BOARD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the old scoreboard, for use in reverting.
|
||||
*/
|
||||
public void setOldScoreboard() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
Scoreboard old = player.getScoreboard();
|
||||
if (old == board) { // Already displaying it
|
||||
if (oldBoard == null) {
|
||||
// (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to
|
||||
oldBoard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
}
|
||||
else {
|
||||
// Do nothing, we already have a prev board
|
||||
}
|
||||
}
|
||||
else {
|
||||
oldBoard = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void showBoardWithNoRevert() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
}
|
||||
player.setScoreboard(board);
|
||||
revertTask = null;
|
||||
}
|
||||
|
||||
public void showBoardAndScheduleRevert(int ticks) {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
}
|
||||
player.setScoreboard(board);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
|
||||
if (!tippedKeep) {
|
||||
tippedKeep = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Keep"));
|
||||
}
|
||||
else if (!tippedClear) {
|
||||
tippedClear = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Clear"));
|
||||
}
|
||||
}
|
||||
|
||||
public void tryRevertBoard() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldBoard != null) {
|
||||
if (player.getScoreboard() == board) {
|
||||
player.setScoreboard(oldBoard);
|
||||
oldBoard = null;
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Not reverting scoreboard for " + playerName + " - scoreboard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Was already reverted
|
||||
}
|
||||
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
revertTask = null;
|
||||
}
|
||||
sidebarType = SidebarType.NONE;
|
||||
targetPlayer = null;
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
}
|
||||
|
||||
public boolean isBoardShown() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return player.getScoreboard() == board;
|
||||
}
|
||||
|
||||
public void cancelRevert() {
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
}
|
||||
revertTask = null;
|
||||
}
|
||||
|
||||
// Board Type Changing 'API' methods
|
||||
|
||||
public void setTypeNone() {
|
||||
this.sidebarType = SidebarType.NONE;
|
||||
|
||||
targetPlayer = null;
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective("");
|
||||
}
|
||||
|
||||
public void setTypeSkill(SkillType skill) {
|
||||
this.sidebarType = SidebarType.SKILL_BOARD;
|
||||
targetSkill = skill;
|
||||
|
||||
targetPlayer = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(ScoreboardManager.skillLabels.get(skill).getName());
|
||||
}
|
||||
|
||||
public void setTypeSelfStats() {
|
||||
this.sidebarType = SidebarType.STATS_BOARD;
|
||||
|
||||
targetPlayer = null;
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(ScoreboardManager.HEADER_STATS);
|
||||
}
|
||||
|
||||
public void setTypeInspectStats(PlayerProfile profile) {
|
||||
this.sidebarType = SidebarType.STATS_BOARD;
|
||||
targetPlayer = profile.getPlayerName();
|
||||
targetProfile = profile;
|
||||
|
||||
targetSkill = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(LocaleLoader.getString("Scoreboard.Header.PlayerInspect", targetPlayer));
|
||||
}
|
||||
|
||||
public void setTypeCooldowns() {
|
||||
this.sidebarType = SidebarType.COOLDOWNS_BOARD;
|
||||
|
||||
targetPlayer = null;
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(ScoreboardManager.HEADER_COOLDOWNS);
|
||||
}
|
||||
|
||||
public void setTypeSelfRank() {
|
||||
this.sidebarType = SidebarType.RANK_BOARD;
|
||||
targetPlayer = null;
|
||||
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(ScoreboardManager.HEADER_RANK);
|
||||
}
|
||||
|
||||
public void setTypeInspectRank(String otherPlayer) {
|
||||
this.sidebarType = SidebarType.RANK_BOARD;
|
||||
targetPlayer = otherPlayer;
|
||||
|
||||
targetSkill = null;
|
||||
targetProfile = null;
|
||||
leaderboardPage = -1;
|
||||
|
||||
loadObjective(ScoreboardManager.HEADER_RANK);
|
||||
}
|
||||
|
||||
public void setTypeTopPower(int page) {
|
||||
this.sidebarType = SidebarType.TOP_BOARD;
|
||||
leaderboardPage = page;
|
||||
targetSkill = null;
|
||||
|
||||
targetPlayer = null;
|
||||
targetProfile = null;
|
||||
|
||||
int endPosition = page * 15;
|
||||
int startPosition = endPosition - 14;
|
||||
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.POWER_LEVEL, startPosition, endPosition));
|
||||
}
|
||||
|
||||
public void setTypeTop(SkillType skill, int page) {
|
||||
this.sidebarType = SidebarType.TOP_BOARD;
|
||||
leaderboardPage = page;
|
||||
targetSkill = skill;
|
||||
|
||||
targetPlayer = null;
|
||||
targetProfile = null;
|
||||
|
||||
int endPosition = page * 15;
|
||||
int startPosition = endPosition - 14;
|
||||
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill).getName(), startPosition, endPosition));
|
||||
}
|
||||
|
||||
// Setup for after a board type change
|
||||
protected void loadObjective(String displayName) {
|
||||
sidebarObj.unregister();
|
||||
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
}
|
||||
sidebarObj.setDisplayName(displayName);
|
||||
|
||||
updateSidebar();
|
||||
// Do last! Minimize packets!
|
||||
sidebarObj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load new values into the sidebar.
|
||||
*/
|
||||
private void updateSidebar() {
|
||||
try {
|
||||
updateTask.cancel();
|
||||
} catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care
|
||||
updateTask = null;
|
||||
|
||||
if (sidebarType == SidebarType.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player bukkitPlayer = Bukkit.getPlayerExact(playerName);
|
||||
if (bukkitPlayer == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcPlayer = UserManager.getPlayer(bukkitPlayer);
|
||||
PlayerProfile profile = mcPlayer.getProfile();
|
||||
|
||||
switch (sidebarType) {
|
||||
case NONE:
|
||||
break;
|
||||
|
||||
case SKILL_BOARD:
|
||||
Validate.notNull(targetSkill);
|
||||
if (!targetSkill.isChildSkill()) {
|
||||
int currentXP = profile.getSkillXpLevel(targetSkill);
|
||||
sidebarObj.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
||||
sidebarObj.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(profile.getXpToLevel(targetSkill) - currentXP);
|
||||
}
|
||||
else {
|
||||
Set<SkillType> parents = FamilyTree.getParents(targetSkill);
|
||||
for (SkillType parentSkill : parents) {
|
||||
sidebarObj.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(profile.getSkillLevel(parentSkill));
|
||||
}
|
||||
}
|
||||
sidebarObj.getScore(ScoreboardManager.LABEL_LEVEL).setScore(profile.getSkillLevel(targetSkill));
|
||||
if (targetSkill.getAbility() != null) {
|
||||
if (targetSkill != SkillType.MINING) {
|
||||
AbilityType ab = targetSkill.getAbility();
|
||||
Score cooldown = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(ab));
|
||||
int seconds = SkillUtils.calculateTimeLeft(ab, profile, bukkitPlayer);
|
||||
seconds = (seconds <= 0) ? 0 : seconds;
|
||||
if (seconds == 0) {
|
||||
cooldown.setScore(0);
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
cooldown.setScore(seconds);
|
||||
startCooldownUpdating();
|
||||
}
|
||||
} else {
|
||||
// Special-Case: Mining has two abilities, both with cooldowns
|
||||
AbilityType sb = AbilityType.SUPER_BREAKER;
|
||||
AbilityType bm = AbilityType.BLAST_MINING;
|
||||
Score cooldownSB = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(sb));
|
||||
Score cooldownBM = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(bm));
|
||||
int secondsSB = SkillUtils.calculateTimeLeft(sb, profile, bukkitPlayer);
|
||||
int secondsBM = SkillUtils.calculateTimeLeft(bm, profile, bukkitPlayer);
|
||||
secondsSB = (secondsSB <= 0) ? 0 : secondsSB;
|
||||
secondsBM = (secondsBM <= 0) ? 0 : secondsBM;
|
||||
if (secondsSB == 0 && secondsBM == 0) {
|
||||
cooldownSB.setScore(0);
|
||||
cooldownBM.setScore(0);
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
cooldownSB.setScore(secondsSB);
|
||||
cooldownBM.setScore(secondsBM);
|
||||
startCooldownUpdating();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COOLDOWNS_BOARD:
|
||||
boolean anyCooldownsActive = false;
|
||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||
int seconds = SkillUtils.calculateTimeLeft(ability, profile, bukkitPlayer);
|
||||
seconds = (seconds <= 0) ? 0 : seconds;
|
||||
if (seconds != 0) {
|
||||
anyCooldownsActive = true;
|
||||
}
|
||||
sidebarObj.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||
}
|
||||
|
||||
if (anyCooldownsActive) {
|
||||
startCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
break;
|
||||
|
||||
case STATS_BOARD:
|
||||
// Select the profile to read from
|
||||
PlayerProfile prof;
|
||||
if (targetProfile != null) {
|
||||
prof = targetProfile; // offline
|
||||
}
|
||||
else if (targetPlayer == null) {
|
||||
prof = profile; // self
|
||||
}
|
||||
else {
|
||||
prof = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
}
|
||||
// Calculate power level here
|
||||
int powerLevel = 0;
|
||||
for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level
|
||||
int level = prof.getSkillLevel(skill);
|
||||
if (!skill.isChildSkill())
|
||||
powerLevel += level;
|
||||
|
||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||
if (!Permissions.skillEnabled(bukkitPlayer, skill)) {
|
||||
continue;
|
||||
}
|
||||
sidebarObj.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
|
||||
}
|
||||
sidebarObj.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
|
||||
break;
|
||||
|
||||
case RANK_BOARD:
|
||||
case TOP_BOARD:
|
||||
/*
|
||||
* @see #acceptRankData(Map<SkillType, Integer> rank)
|
||||
* @see #acceptLeaderboardData(List<PlayerStat> stats)
|
||||
*/
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptRankData(Map<SkillType, Integer> rankData) {
|
||||
Integer rank;
|
||||
Player bukkitPlayer = Bukkit.getPlayerExact(playerName);
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(bukkitPlayer, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = rankData.get(skill);
|
||||
if (rank != null) {
|
||||
sidebarObj.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank);
|
||||
}
|
||||
}
|
||||
rank = rankData.get(null);
|
||||
if (rank != null) {
|
||||
sidebarObj.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(rank);
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptLeaderboardData(List<PlayerStat> leaderboardData) {
|
||||
for (PlayerStat stat : leaderboardData) {
|
||||
String statname = stat.name;
|
||||
if (statname.equals(playerName)) {
|
||||
statname = ChatColor.GOLD + "--You--";
|
||||
}
|
||||
sidebarObj.getScore(Bukkit.getOfflinePlayer(statname)).setScore(stat.statVal);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePowerLevel(Player leveledPlayer, int newPowerLevel) {
|
||||
powerObj.getScore(leveledPlayer).setScore(newPowerLevel);
|
||||
}
|
||||
}
|
||||
@@ -370,8 +370,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) {
|
||||
@@ -381,8 +381,8 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) {
|
||||
@@ -397,9 +397,9 @@ public final class CombatUtils {
|
||||
* Apply Area-of-Effect ability actions.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param type The type of skill being used
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param type The type of skill being used
|
||||
*/
|
||||
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, SkillType type) {
|
||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
|
||||
@@ -450,8 +450,8 @@ public final class CombatUtils {
|
||||
* Start the task that gives combat XP.
|
||||
*
|
||||
* @param mcMMOPlayer The attacking player
|
||||
* @param target The defending entity
|
||||
* @param skillType The skill being used
|
||||
* @param target The defending entity
|
||||
* @param skillType The skill being used
|
||||
*/
|
||||
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType, double multiplier) {
|
||||
double baseXP = 0;
|
||||
@@ -541,6 +541,7 @@ public final class CombatUtils {
|
||||
*
|
||||
* @param player The attacking Player
|
||||
* @param entity The defending Entity
|
||||
*
|
||||
* @return true if the Entity should be damaged, false otherwise.
|
||||
*/
|
||||
private static boolean shouldBeAffected(Player player, Entity entity) {
|
||||
@@ -577,8 +578,9 @@ public final class CombatUtils {
|
||||
/**
|
||||
* Checks to see if an entity is currently invincible.
|
||||
*
|
||||
* @param entity The {@link LivingEntity} to check
|
||||
* @param entity The {@link LivingEntity} to check
|
||||
* @param eventDamage The damage from the event the entity is involved in
|
||||
*
|
||||
* @return true if the entity is invincible, false otherwise
|
||||
*/
|
||||
public static boolean isInvincible(LivingEntity entity, double eventDamage) {
|
||||
@@ -593,7 +595,8 @@ public final class CombatUtils {
|
||||
* Checks to see if an entity is currently friendly toward a given player.
|
||||
*
|
||||
* @param attacker The player to check.
|
||||
* @param pet The entity to check.
|
||||
* @param pet The entity to check.
|
||||
*
|
||||
* @return true if the entity is friendly, false otherwise
|
||||
*/
|
||||
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public final class ParticleEffectUtils {
|
||||
|
||||
private ParticleEffectUtils() {};
|
||||
private ParticleEffectUtils() {}
|
||||
|
||||
public static void playBleedEffect(LivingEntity livingEntity) {
|
||||
if (!Config.getInstance().getBleedEffectEnabled()) {
|
||||
|
||||
@@ -9,7 +9,7 @@ public final class PerksUtils {
|
||||
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
||||
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
||||
|
||||
private PerksUtils() {};
|
||||
private PerksUtils() {}
|
||||
|
||||
public static int handleCooldownPerks(Player player, int cooldown) {
|
||||
if (Permissions.halvedCooldowns(player)) {
|
||||
@@ -67,7 +67,8 @@ public final class PerksUtils {
|
||||
* Calculate activation chance for a skill.
|
||||
*
|
||||
* @param player Player to check the activation chance for
|
||||
* @param skill SkillType to check the activation chance of
|
||||
* @param skill SkillType to check the activation chance of
|
||||
*
|
||||
* @return the activation chance with "lucky perk" accounted for
|
||||
*/
|
||||
public static int handleLuckyPerks(Player player, SkillType skill) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
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.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -45,8 +44,8 @@ public class SkillUtils {
|
||||
* Calculate the time remaining until the cooldown expires.
|
||||
*
|
||||
* @param deactivatedTimeStamp Time of deactivation
|
||||
* @param cooldown The length of the cooldown
|
||||
* @param player The Player to check for cooldown perks
|
||||
* @param cooldown The length of the cooldown
|
||||
* @param player The Player to check for cooldown perks
|
||||
*
|
||||
* @return the number of seconds remaining before the cooldown expires
|
||||
*/
|
||||
@@ -54,25 +53,12 @@ public class SkillUtils {
|
||||
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time remaining until the ability's cooldown expires.
|
||||
*
|
||||
* @param ability AbilityType whose cooldown to check
|
||||
* @param profile The PlayerProfile to get the cooldown from
|
||||
* @param player The Player to check for cooldown perks
|
||||
*
|
||||
* @return the number of seconds remaining before the cooldown expires
|
||||
*/
|
||||
public static int calculateTimeLeft(AbilityType ability, PlayerProfile profile, Player player) {
|
||||
return calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cooldown has expired.
|
||||
* This does NOT account for cooldown perks!
|
||||
*
|
||||
* @param deactivatedTimeStamp Time of deactivation in seconds
|
||||
* @param cooldown The length of the cooldown in seconds
|
||||
* @param cooldown The length of the cooldown in seconds
|
||||
*
|
||||
* @return true if the cooldown is expired
|
||||
*/
|
||||
@@ -84,6 +70,7 @@ public class SkillUtils {
|
||||
* Checks if the given string represents a valid skill
|
||||
*
|
||||
* @param skillName The name of the skill to check
|
||||
*
|
||||
* @return true if this is a valid skill, false otherwise
|
||||
*/
|
||||
public static boolean isSkill(String skillName) {
|
||||
@@ -185,6 +172,7 @@ public class SkillUtils {
|
||||
* Modify the durability of an ItemStack.
|
||||
*
|
||||
* @param itemStack The ItemStack which durability should be modified
|
||||
*
|
||||
* @return the itemStack with modified durability
|
||||
*/
|
||||
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
|
||||
|
||||
@@ -1,549 +0,0 @@
|
||||
/*
|
||||
* Updater for Bukkit.
|
||||
*
|
||||
* This class provides the means to safely and easily update a plugin, or check to see if it is updated using dev.bukkit.org
|
||||
*/
|
||||
|
||||
package net.gravitydevelopment.updater.mcmmo;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
/**
|
||||
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
|
||||
* <p/>
|
||||
* <b>VERY, VERY IMPORTANT</b>: Because there are no standards for adding auto-update toggles in your plugin's config, this system provides NO CHECK WITH YOUR CONFIG to make sure the user has allowed auto-updating.
|
||||
* <br>
|
||||
* It is a <b>BUKKIT POLICY</b> that you include a boolean value in your config that prevents the auto-updater from running <b>AT ALL</b>.
|
||||
* <br>
|
||||
* If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you attempt to submit it to dev.bukkit.org.
|
||||
* <p/>
|
||||
* An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to false you may NOT run the auto-updater.
|
||||
* <br>
|
||||
* If you are unsure about these rules, please read the plugin submission guidelines: http://goo.gl/8iU5l
|
||||
*
|
||||
* @author Gravity
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
public class Updater {
|
||||
|
||||
private Plugin plugin;
|
||||
private UpdateType type;
|
||||
private String versionName;
|
||||
private String versionLink;
|
||||
private String versionType;
|
||||
private String versionGameVersion;
|
||||
|
||||
private boolean announce; // Whether to announce file downloads
|
||||
|
||||
private URL url; // Connecting to RSS
|
||||
private File file; // The plugin's file
|
||||
private Thread thread; // Updater thread
|
||||
|
||||
private int id = -1; // Project's Curse ID
|
||||
private String apiKey = null; // BukkitDev ServerMods API key
|
||||
private static final String TITLE_VALUE = "name"; // Gets remote file's title
|
||||
private static final String LINK_VALUE = "downloadUrl"; // Gets remote file's download link
|
||||
private static final String TYPE_VALUE = "releaseType"; // Gets remote file's release type
|
||||
private static final String VERSION_VALUE = "gameVersion"; // Gets remote file's build version
|
||||
private static final String QUERY = "/servermods/files?projectIds="; // Path to GET
|
||||
private static final String HOST = "https://api.curseforge.com"; // Slugs will be appended to this to get to the project's RSS feed
|
||||
|
||||
private static final int BYTE_SIZE = 1024; // Used for downloading files
|
||||
private YamlConfiguration config; // Config file
|
||||
private String updateFolder;// The folder that downloads will be placed in
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
|
||||
|
||||
/**
|
||||
* Gives the dev the result of the update process. Can be obtained by called getResult().
|
||||
*/
|
||||
public enum UpdateResult {
|
||||
/**
|
||||
* The updater found an update, and has readied it to be loaded the next time the server restarts/reloads.
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* The updater did not find an update, and nothing was downloaded.
|
||||
*/
|
||||
NO_UPDATE,
|
||||
/**
|
||||
* The server administrator has disabled the updating system
|
||||
*/
|
||||
DISABLED,
|
||||
/**
|
||||
* The updater found an update, but was unable to download it.
|
||||
*/
|
||||
FAIL_DOWNLOAD,
|
||||
/**
|
||||
* For some reason, the updater was unable to contact dev.bukkit.org to download the file.
|
||||
*/
|
||||
FAIL_DBO,
|
||||
/**
|
||||
* When running the version check, the file on DBO did not contain the a version in the format 'vVersion' such as 'v1.0'.
|
||||
*/
|
||||
FAIL_NOVERSION,
|
||||
/**
|
||||
* The id provided by the plugin running the updater was invalid and doesn't exist on DBO.
|
||||
*/
|
||||
FAIL_BADID,
|
||||
/**
|
||||
* The server administrator has improperly configured their API key in the configuration
|
||||
*/
|
||||
FAIL_APIKEY,
|
||||
/**
|
||||
* The updater found an update, but because of the UpdateType being set to NO_DOWNLOAD, it wasn't downloaded.
|
||||
*/
|
||||
UPDATE_AVAILABLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the dev to specify the type of update that will be run.
|
||||
*/
|
||||
public enum UpdateType {
|
||||
/**
|
||||
* Run a version check, and then if the file is out of date, download the newest version.
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Don't run a version check, just find the latest update and download it.
|
||||
*/
|
||||
NO_VERSION_CHECK,
|
||||
/**
|
||||
* Get information about the version and the download size, but don't actually download anything.
|
||||
*/
|
||||
NO_DOWNLOAD
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the updater
|
||||
*
|
||||
* @param plugin The plugin that is checking for an update.
|
||||
* @param id The dev.bukkit.org id of the project
|
||||
* @param file The file that the plugin is running from, get this by doing this.getFile() from within your main class.
|
||||
* @param type Specify the type of update this will be. See {@link UpdateType}
|
||||
* @param announce True if the program should announce the progress of new updates in console
|
||||
*/
|
||||
public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
|
||||
this.plugin = plugin;
|
||||
this.type = type;
|
||||
this.announce = announce;
|
||||
this.file = file;
|
||||
this.id = id;
|
||||
this.updateFolder = plugin.getServer().getUpdateFolder();
|
||||
|
||||
final File pluginFile = plugin.getDataFolder().getParentFile();
|
||||
final File updaterFile = new File(pluginFile, "Updater");
|
||||
final File updaterConfigFile = new File(updaterFile, "config.yml");
|
||||
|
||||
if (!updaterFile.exists()) {
|
||||
updaterFile.mkdir();
|
||||
}
|
||||
if (!updaterConfigFile.exists()) {
|
||||
try {
|
||||
updaterConfigFile.createNewFile();
|
||||
}
|
||||
catch (final IOException e) {
|
||||
plugin.getLogger().severe("The updater could not create a configuration in " + updaterFile.getAbsolutePath());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.config = YamlConfiguration.loadConfiguration(updaterConfigFile);
|
||||
|
||||
this.config.options().header("This configuration file affects all plugins using the Updater system (version 2+ - http://forums.bukkit.org/threads/96681/ )" + '\n'
|
||||
+ "If you wish to use your API key, read http://wiki.bukkit.org/ServerMods_API and place it below." + '\n'
|
||||
+ "Some updating systems will not adhere to the disabled value, but these may be turned off in their plugin's configuration.");
|
||||
this.config.addDefault("api-key", "PUT_API_KEY_HERE");
|
||||
this.config.addDefault("disable", false);
|
||||
|
||||
if (this.config.get("api-key", null) == null) {
|
||||
this.config.options().copyDefaults(true);
|
||||
try {
|
||||
this.config.save(updaterConfigFile);
|
||||
}
|
||||
catch (final IOException e) {
|
||||
plugin.getLogger().severe("The updater could not save the configuration in " + updaterFile.getAbsolutePath());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.config.getBoolean("disable")) {
|
||||
this.result = UpdateResult.DISABLED;
|
||||
return;
|
||||
}
|
||||
|
||||
String key = this.config.getString("api-key");
|
||||
if (key.equalsIgnoreCase("PUT_API_KEY_HERE") || key.equals("")) {
|
||||
key = null;
|
||||
}
|
||||
|
||||
this.apiKey = key;
|
||||
|
||||
try {
|
||||
this.url = new URL(Updater.HOST + Updater.QUERY + id);
|
||||
}
|
||||
catch (final MalformedURLException e) {
|
||||
plugin.getLogger().severe("The project ID provided for updating, " + id + " is invalid.");
|
||||
this.result = UpdateResult.FAIL_BADID;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.thread = new Thread(new UpdateRunnable());
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the result of the update process.
|
||||
*/
|
||||
public Updater.UpdateResult getResult() {
|
||||
this.waitForThread();
|
||||
return this.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version's release type (release, beta, or alpha).
|
||||
*/
|
||||
public String getLatestType() {
|
||||
this.waitForThread();
|
||||
return this.versionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version's game version.
|
||||
*/
|
||||
public String getLatestGameVersion() {
|
||||
this.waitForThread();
|
||||
return this.versionGameVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version's name.
|
||||
*/
|
||||
public String getLatestName() {
|
||||
this.waitForThread();
|
||||
return this.versionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version's file link.
|
||||
*/
|
||||
public String getLatestFileLink() {
|
||||
this.waitForThread();
|
||||
return this.versionLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish
|
||||
* before allowing anyone to check the result.
|
||||
*/
|
||||
private void waitForThread() {
|
||||
if ((this.thread != null) && this.thread.isAlive()) {
|
||||
try {
|
||||
this.thread.join();
|
||||
}
|
||||
catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an update from dev.bukkit.org into the server's update folder.
|
||||
*/
|
||||
private void saveFile(File folder, String file, String u) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try {
|
||||
// Download the file
|
||||
final URL url = new URL(u);
|
||||
final int fileLength = url.openConnection().getContentLength();
|
||||
in = new BufferedInputStream(url.openStream());
|
||||
fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
|
||||
|
||||
final byte[] data = new byte[Updater.BYTE_SIZE];
|
||||
int count;
|
||||
if (this.announce) {
|
||||
this.plugin.getLogger().info("About to download a new update: " + this.versionName);
|
||||
}
|
||||
long downloaded = 0;
|
||||
while ((count = in.read(data, 0, Updater.BYTE_SIZE)) != -1) {
|
||||
downloaded += count;
|
||||
fout.write(data, 0, count);
|
||||
final int percent = (int) ((downloaded * 100) / fileLength);
|
||||
if (this.announce && ((percent % 10) == 0)) {
|
||||
this.plugin.getLogger().info("Downloading update: " + percent + "% of " + fileLength + " bytes.");
|
||||
}
|
||||
}
|
||||
//Just a quick check to make sure we didn't leave any files from last time...
|
||||
for (final File xFile : new File(this.plugin.getDataFolder().getParent(), this.updateFolder).listFiles()) {
|
||||
if (xFile.getName().endsWith(".zip")) {
|
||||
xFile.delete();
|
||||
}
|
||||
}
|
||||
// Check to see if it's a zip file, if it is, unzip it.
|
||||
final File dFile = new File(folder.getAbsolutePath() + "/" + file);
|
||||
if (dFile.getName().endsWith(".zip")) {
|
||||
// Unzip
|
||||
this.unzip(dFile.getCanonicalPath());
|
||||
}
|
||||
if (this.announce) {
|
||||
this.plugin.getLogger().info("Finished updating.");
|
||||
}
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
this.plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
|
||||
this.result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of Zip-File-Extractor, modified by Gravity for use with Bukkit
|
||||
*/
|
||||
private void unzip(String file) {
|
||||
try {
|
||||
final File fSourceZip = new File(file);
|
||||
final String zipPath = file.substring(0, file.length() - 4);
|
||||
ZipFile zipFile = new ZipFile(fSourceZip);
|
||||
Enumeration<? extends ZipEntry> e = zipFile.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
ZipEntry entry = e.nextElement();
|
||||
File destinationFilePath = new File(zipPath, entry.getName());
|
||||
destinationFilePath.getParentFile().mkdirs();
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
|
||||
int b;
|
||||
final byte buffer[] = new byte[Updater.BYTE_SIZE];
|
||||
final FileOutputStream fos = new FileOutputStream(destinationFilePath);
|
||||
final BufferedOutputStream bos = new BufferedOutputStream(fos, Updater.BYTE_SIZE);
|
||||
while ((b = bis.read(buffer, 0, Updater.BYTE_SIZE)) != -1) {
|
||||
bos.write(buffer, 0, b);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
final String name = destinationFilePath.getName();
|
||||
if (name.endsWith(".jar") && this.pluginFile(name)) {
|
||||
destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + "/" + name));
|
||||
}
|
||||
|
||||
entry = null;
|
||||
destinationFilePath = null;
|
||||
}
|
||||
e = null;
|
||||
zipFile.close();
|
||||
zipFile = null;
|
||||
|
||||
// Move any plugin data folders that were included to the right place, Bukkit won't do this for us.
|
||||
for (final File dFile : new File(zipPath).listFiles()) {
|
||||
if (dFile.isDirectory()) {
|
||||
if (this.pluginFile(dFile.getName())) {
|
||||
final File oFile = new File(this.plugin.getDataFolder().getParent(), dFile.getName()); // Get current dir
|
||||
final File[] contents = oFile.listFiles(); // List of existing files in the current dir
|
||||
for (final File cFile : dFile.listFiles()) // Loop through all the files in the new dir
|
||||
{
|
||||
boolean found = false;
|
||||
for (final File xFile : contents) // Loop through contents to see if it exists
|
||||
{
|
||||
if (xFile.getName().equals(cFile.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// Move the new file into the current dir
|
||||
cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName()));
|
||||
}
|
||||
else {
|
||||
// This file already exists, so we don't need it anymore.
|
||||
cFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dFile.delete();
|
||||
}
|
||||
new File(zipPath).delete();
|
||||
fSourceZip.delete();
|
||||
}
|
||||
catch (final IOException ex) {
|
||||
this.plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
|
||||
this.result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
ex.printStackTrace();
|
||||
}
|
||||
new File(file).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the name of a jar is one of the plugins currently installed, used for extracting the correct files out of a zip.
|
||||
*/
|
||||
private boolean pluginFile(String name) {
|
||||
for (final File file : new File("plugins").listFiles()) {
|
||||
if (file.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated
|
||||
*/
|
||||
private boolean versionCheck(String title) {
|
||||
if (type != UpdateType.NO_VERSION_CHECK) {
|
||||
String version = plugin.getDescription().getVersion();
|
||||
title = title.substring(6);
|
||||
|
||||
String[] oldTokens = version.split("-");
|
||||
String[] newTokens = title.split("-");
|
||||
|
||||
int oldVersion = Integer.parseInt(oldTokens[0].replaceAll("[.]", ""));
|
||||
int newVersion = Integer.parseInt(newTokens[0].replaceAll("[.]", ""));
|
||||
|
||||
// Check versions
|
||||
if (oldVersion < newVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check release vs. beta & dev
|
||||
if (newTokens.length == 0 && oldTokens.length == 2 && oldVersion == newVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check beta vs. dev
|
||||
if (version.contains("dev") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(3)) <= Integer.parseInt(newTokens[1].substring(4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check beta vs. beta
|
||||
if (version.contains("beta") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(4)) < Integer.parseInt(newTokens[1].substring(4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldTokens.length == 2 && !version.contains("beta") && !version.contains("dev")) {
|
||||
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
|
||||
result = UpdateResult.FAIL_NOVERSION;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean read() {
|
||||
try {
|
||||
final URLConnection conn = this.url.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
|
||||
if (this.apiKey != null) {
|
||||
conn.addRequestProperty("X-API-Key", this.apiKey);
|
||||
}
|
||||
conn.addRequestProperty("User-Agent", "Updater (by Gravity)");
|
||||
|
||||
conn.setDoOutput(true);
|
||||
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
final String response = reader.readLine();
|
||||
|
||||
final JSONArray array = (JSONArray) JSONValue.parse(response);
|
||||
|
||||
if (array.size() == 0) {
|
||||
this.plugin.getLogger().warning("The updater could not find any files for the project id " + this.id);
|
||||
this.result = UpdateResult.FAIL_BADID;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.versionName = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TITLE_VALUE);
|
||||
this.versionLink = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.LINK_VALUE);
|
||||
this.versionType = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TYPE_VALUE);
|
||||
this.versionGameVersion = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.VERSION_VALUE);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (final IOException e) {
|
||||
if (e.getMessage().contains("HTTP response code: 403")) {
|
||||
this.plugin.getLogger().warning("dev.bukkit.org rejected the API key provided in plugins/Updater/config.yml");
|
||||
this.plugin.getLogger().warning("Please double-check your configuration to ensure it is correct.");
|
||||
this.result = UpdateResult.FAIL_APIKEY;
|
||||
}
|
||||
else {
|
||||
this.plugin.getLogger().warning("The updater could not contact dev.bukkit.org for updating.");
|
||||
this.plugin.getLogger().warning("If you have not recently modified your configuration and this is the first time you are seeing this message, the site may be experiencing temporary downtime.");
|
||||
this.result = UpdateResult.FAIL_DBO;
|
||||
}
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateRunnable implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Updater.this.url != null) {
|
||||
// Obtain the results of the project's file feed
|
||||
if (Updater.this.read()) {
|
||||
if (Updater.this.versionCheck(Updater.this.versionName)) {
|
||||
if ((Updater.this.versionLink != null) && (Updater.this.type != UpdateType.NO_DOWNLOAD)) {
|
||||
String name = Updater.this.file.getName();
|
||||
// If it's a zip file, it shouldn't be downloaded as the plugin's name
|
||||
if (Updater.this.versionLink.endsWith(".zip")) {
|
||||
final String[] split = Updater.this.versionLink.split("/");
|
||||
name = split[split.length - 1];
|
||||
}
|
||||
Updater.this.saveFile(new File(Updater.this.plugin.getDataFolder().getParent(), Updater.this.updateFolder), name, Updater.this.versionLink);
|
||||
}
|
||||
else {
|
||||
Updater.this.result = UpdateResult.UPDATE_AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
531
src/main/java/net/h31ix/updater/mcmmo/Updater.java
Normal file
531
src/main/java/net/h31ix/updater/mcmmo/Updater.java
Normal file
@@ -0,0 +1,531 @@
|
||||
/*
|
||||
* Updater for Bukkit.
|
||||
*
|
||||
* This class provides the means to safely and easily update a plugin, or check to see if it is updated using dev.bukkit.org
|
||||
*/
|
||||
|
||||
package net.h31ix.updater.mcmmo;
|
||||
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
|
||||
* <p/>
|
||||
* <b>VERY, VERY IMPORTANT</b>: Because there are no standards for adding auto-update toggles in your plugin's config, this system provides NO CHECK WITH YOUR CONFIG to make sure the user has allowed auto-updating.
|
||||
* <br>
|
||||
* It is a <b>BUKKIT POLICY</b> that you include a boolean value in your config that prevents the auto-updater from running <b>AT ALL</b>.
|
||||
* <br>
|
||||
* If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you attempt to submit it to dev.bukkit.org.
|
||||
* <p/>
|
||||
* An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to false you may NOT run the auto-updater.
|
||||
* <br>
|
||||
* If you are unsure about these rules, please read the plugin submission guidelines: http://goo.gl/8iU5l
|
||||
*
|
||||
* @author H31IX
|
||||
*/
|
||||
|
||||
public class Updater {
|
||||
private Plugin plugin;
|
||||
private UpdateType type;
|
||||
private String versionTitle;
|
||||
private String versionLink;
|
||||
private long totalSize; // Holds the total size of the file
|
||||
//private double downloadedSize; TODO: Holds the number of bytes downloaded
|
||||
private int sizeLine; // Used for detecting file size
|
||||
private int multiplier; // Used for determining when to broadcast download updates
|
||||
private boolean announce; // Whether to announce file downloads
|
||||
private URL url; // Connecting to RSS
|
||||
private File file; // The plugin's file
|
||||
private Thread thread; // Updater thread
|
||||
private static final String DBOUrl = "http://dev.bukkit.org/server-mods/"; // Slugs will be appended to this to get to the project's RSS feed
|
||||
private static final int BYTE_SIZE = 1024; // Used for downloading files
|
||||
private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
|
||||
// Strings for reading RSS
|
||||
private static final String TITLE = "title";
|
||||
private static final String LINK = "link";
|
||||
private static final String ITEM = "item";
|
||||
|
||||
/**
|
||||
* Gives the dev the result of the update process. Can be obtained by called getResult().
|
||||
*/
|
||||
public enum UpdateResult {
|
||||
/**
|
||||
* The updater found an update, and has readied it to be loaded the next time the server restarts/reloads.
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* The updater did not find an update, and nothing was downloaded.
|
||||
*/
|
||||
NO_UPDATE,
|
||||
/**
|
||||
* The updater found an update, but was unable to download it.
|
||||
*/
|
||||
FAIL_DOWNLOAD,
|
||||
/**
|
||||
* For some reason, the updater was unable to contact dev.bukkit.org to download the file.
|
||||
*/
|
||||
FAIL_DBO,
|
||||
/**
|
||||
* When running the version check, the file on DBO did not contain the a version in the format 'vVersion' such as 'v1.0'.
|
||||
*/
|
||||
FAIL_NOVERSION,
|
||||
/**
|
||||
* The slug provided by the plugin running the updater was invalid and doesn't exist on DBO.
|
||||
*/
|
||||
FAIL_BADSLUG,
|
||||
/**
|
||||
* The updater found an update, but because of the UpdateType being set to NO_DOWNLOAD, it wasn't downloaded.
|
||||
*/
|
||||
UPDATE_AVAILABLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the dev to specify the type of update that will be run.
|
||||
*/
|
||||
public enum UpdateType {
|
||||
/**
|
||||
* Run a version check, and then if the file is out of date, download the newest version.
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Don't run a version check, just find the latest update and download it.
|
||||
*/
|
||||
NO_VERSION_CHECK,
|
||||
/**
|
||||
* Get information about the version and the download size, but don't actually download anything.
|
||||
*/
|
||||
NO_DOWNLOAD
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the updater
|
||||
*
|
||||
* @param plugin The plugin that is checking for an update.
|
||||
* @param slug The dev.bukkit.org slug of the project (http://dev.bukkit.org/server-mods/SLUG_IS_HERE)
|
||||
* @param file The file that the plugin is running from, get this by doing this.getFile() from within your main class.
|
||||
* @param type Specify the type of update this will be. See {@link UpdateType}
|
||||
* @param announce True if the program should announce the progress of new updates in console
|
||||
*/
|
||||
public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce) {
|
||||
this.plugin = plugin;
|
||||
this.type = type;
|
||||
this.announce = announce;
|
||||
this.file = file;
|
||||
try {
|
||||
// Obtain the results of the project's file feed
|
||||
url = new URL(DBOUrl + slug + "/files.rss");
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
// Invalid slug
|
||||
plugin.getLogger().warning("The author of this plugin (" + plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system");
|
||||
plugin.getLogger().warning("The project slug given ('" + slug + "') is invalid. Please nag the author about this.");
|
||||
result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
|
||||
}
|
||||
thread = new Thread(new UpdateRunnable());
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the result of the update process.
|
||||
*/
|
||||
public Updater.UpdateResult getResult() {
|
||||
waitForThread();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total bytes of the file (can only be used after running a version check or a normal run).
|
||||
*/
|
||||
public long getFileSize() {
|
||||
waitForThread();
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version string latest file avaliable online.
|
||||
*/
|
||||
public String getLatestVersionString() {
|
||||
waitForThread();
|
||||
return versionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish
|
||||
* before alloowing anyone to check the result.
|
||||
*/
|
||||
public void waitForThread() {
|
||||
if (thread.isAlive()) {
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an update from dev.bukkit.org into the server's update folder.
|
||||
*/
|
||||
private void saveFile(File folder, String file, String u) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try {
|
||||
// Download the file
|
||||
URL url = new URL(u);
|
||||
int fileLength = url.openConnection().getContentLength();
|
||||
in = new BufferedInputStream(url.openStream());
|
||||
fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
|
||||
|
||||
byte[] data = new byte[BYTE_SIZE];
|
||||
int count;
|
||||
if (announce) {
|
||||
plugin.getLogger().info("About to download a new update: " + versionTitle);
|
||||
}
|
||||
long downloaded = 0;
|
||||
while ((count = in.read(data, 0, BYTE_SIZE)) != -1) {
|
||||
downloaded += count;
|
||||
fout.write(data, 0, count);
|
||||
int percent = (int) (downloaded * 100 / fileLength);
|
||||
if (announce & (percent % 10 == 0)) {
|
||||
plugin.getLogger().info("Downloading update: " + percent + "% of " + fileLength + " bytes.");
|
||||
}
|
||||
}
|
||||
//Just a quick check to make sure we didn't leave any files from last time...
|
||||
for (File xFile : new File("plugins/" + updateFolder).listFiles()) {
|
||||
if (xFile.getName().endsWith(".zip")) {
|
||||
xFile.delete();
|
||||
}
|
||||
}
|
||||
// Check to see if it's a zip file, if it is, unzip it.
|
||||
File dFile = new File(folder.getAbsolutePath() + "/" + file);
|
||||
if (dFile.getName().endsWith(".zip")) {
|
||||
// Unzip
|
||||
unzip(dFile.getCanonicalPath());
|
||||
}
|
||||
if (announce) {
|
||||
plugin.getLogger().info("Finished updating.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of Zip-File-Extractor, modified by H31IX for use with Bukkit
|
||||
*/
|
||||
private void unzip(String file) {
|
||||
try {
|
||||
File fSourceZip = new File(file);
|
||||
String zipPath = file.substring(0, file.length() - 4);
|
||||
ZipFile zipFile = new ZipFile(fSourceZip);
|
||||
Enumeration<? extends ZipEntry> e = zipFile.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
ZipEntry entry = e.nextElement();
|
||||
File destinationFilePath = new File(zipPath, entry.getName());
|
||||
destinationFilePath.getParentFile().mkdirs();
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
|
||||
int b;
|
||||
byte buffer[] = new byte[BYTE_SIZE];
|
||||
FileOutputStream fos = new FileOutputStream(destinationFilePath);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos, BYTE_SIZE);
|
||||
while ((b = bis.read(buffer, 0, BYTE_SIZE)) != -1) {
|
||||
bos.write(buffer, 0, b);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
String name = destinationFilePath.getName();
|
||||
if (name.endsWith(".jar") && pluginFile(name)) {
|
||||
destinationFilePath.renameTo(new File("plugins/" + updateFolder + "/" + name));
|
||||
}
|
||||
|
||||
entry = null;
|
||||
destinationFilePath = null;
|
||||
}
|
||||
e = null;
|
||||
zipFile.close();
|
||||
zipFile = null;
|
||||
// Move any plugin data folders that were included to the right place, Bukkit won't do this for us.
|
||||
for (File dFile : new File(zipPath).listFiles()) {
|
||||
if (dFile.isDirectory()) {
|
||||
if (pluginFile(dFile.getName())) {
|
||||
File oFile = new File("plugins/" + dFile.getName()); // Get current dir
|
||||
File[] contents = oFile.listFiles(); // List of existing files in the current dir
|
||||
for (File cFile : dFile.listFiles()) // Loop through all the files in the new dir
|
||||
{
|
||||
boolean found = false;
|
||||
for (File xFile : contents) // Loop through contents to see if it exists
|
||||
{
|
||||
if (xFile.getName().equals(cFile.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// Move the new file into the current dir
|
||||
cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName()));
|
||||
}
|
||||
else {
|
||||
// This file already exists, so we don't need it anymore.
|
||||
cFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dFile.delete();
|
||||
}
|
||||
new File(zipPath).delete();
|
||||
fSourceZip.delete();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
}
|
||||
new File(file).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the name of a jar is one of the plugins currently installed, used for extracting the correct files out of a zip.
|
||||
*/
|
||||
public boolean pluginFile(String name) {
|
||||
for (File file : new File("plugins").listFiles()) {
|
||||
if (file.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the direct download file url from the file's page.
|
||||
*/
|
||||
private String getFile(String link) {
|
||||
String download = null;
|
||||
try {
|
||||
// Open a connection to the page
|
||||
URL url = new URL(link);
|
||||
URLConnection urlConn = url.openConnection();
|
||||
InputStreamReader inStream = new InputStreamReader(urlConn.getInputStream());
|
||||
BufferedReader buff = new BufferedReader(inStream);
|
||||
|
||||
int counter = 0;
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
counter++;
|
||||
// Search for the download link
|
||||
if (line.contains("<li class=\"user-action user-action-download\">")) {
|
||||
// Get the raw link
|
||||
download = line.split("<a href=\"")[1].split("\">Download</a>")[0];
|
||||
}
|
||||
// Search for size
|
||||
else if (line.contains("<dt>Size</dt>")) {
|
||||
sizeLine = counter + 1;
|
||||
}
|
||||
else if (counter == sizeLine) {
|
||||
String size = line.replaceAll("<dd>", "").replaceAll("</dd>", "");
|
||||
multiplier = size.contains("MiB") ? 1048576 : 1024;
|
||||
size = size.replace(" KiB", "").replace(" MiB", "");
|
||||
totalSize = (long) (Double.parseDouble(size) * multiplier);
|
||||
}
|
||||
}
|
||||
urlConn = null;
|
||||
inStream = null;
|
||||
buff.close();
|
||||
buff = null;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().warning("The auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DBO;
|
||||
return null;
|
||||
}
|
||||
return download;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated
|
||||
*/
|
||||
private boolean versionCheck(String title) {
|
||||
if (type != UpdateType.NO_VERSION_CHECK) {
|
||||
String version = plugin.getDescription().getVersion();
|
||||
title = title.substring(6);
|
||||
|
||||
String[] oldTokens = version.split("-");
|
||||
String[] newTokens = title.split("-");
|
||||
|
||||
int oldVersion = Integer.parseInt(oldTokens[0].replaceAll("[.]", ""));
|
||||
int newVersion = Integer.parseInt(newTokens[0].replaceAll("[.]", ""));
|
||||
|
||||
// Check versions
|
||||
if (oldVersion < newVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check release vs. beta & dev
|
||||
if (newTokens.length == 0 && oldTokens.length == 2 && oldVersion == newVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check beta vs. dev
|
||||
if (version.contains("dev") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(3)) < Integer.parseInt(newTokens[1].substring(4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check beta vs. beta
|
||||
if (version.contains("beta") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(4)) < Integer.parseInt(newTokens[1].substring(4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldTokens.length == 2 && !version.contains("beta") && !version.contains("dev")) {
|
||||
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
|
||||
result = UpdateResult.FAIL_NOVERSION;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of RSS Reader by Vogella, modified by H31IX for use with Bukkit
|
||||
*/
|
||||
private boolean readFeed() {
|
||||
try {
|
||||
// Set header values intial to the empty string
|
||||
String title = "";
|
||||
String link = "";
|
||||
// First create a new XMLInputFactory
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
// Setup a new eventReader
|
||||
InputStream in = read();
|
||||
if (in != null) {
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
|
||||
// Read the XML document
|
||||
while (eventReader.hasNext()) {
|
||||
XMLEvent event = eventReader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
if (event.asStartElement().getName().getLocalPart().equals(TITLE)) {
|
||||
event = eventReader.nextEvent();
|
||||
title = event.asCharacters().getData();
|
||||
continue;
|
||||
}
|
||||
if (event.asStartElement().getName().getLocalPart().equals(LINK)) {
|
||||
event = eventReader.nextEvent();
|
||||
link = event.asCharacters().getData();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (event.isEndElement()) {
|
||||
if (event.asEndElement().getName().getLocalPart().equals(ITEM)) {
|
||||
// Store the title and link of the first entry we get - the first file on the list is all we need
|
||||
versionTitle = title;
|
||||
versionLink = link;
|
||||
// All done, we don't need to know about older files.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (XMLStreamException e) {
|
||||
plugin.getLogger().warning("Could not reach dev.bukkit.org for update checking. Is it offline?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the RSS feed
|
||||
*/
|
||||
private InputStream read() {
|
||||
try {
|
||||
return url.openStream();
|
||||
}
|
||||
catch (IOException e) {
|
||||
plugin.getLogger().warning("Could not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateRunnable implements Runnable {
|
||||
|
||||
public void run() {
|
||||
if (url != null) {
|
||||
// Obtain the results of the project's file feed
|
||||
if (readFeed()) {
|
||||
if (versionCheck(versionTitle)) {
|
||||
String fileLink = getFile(versionLink);
|
||||
if (fileLink != null && type != UpdateType.NO_DOWNLOAD) {
|
||||
String name = file.getName();
|
||||
// If it's a zip file, it shouldn't be downloaded as the plugin's name
|
||||
if (fileLink.endsWith(".zip")) {
|
||||
String[] split = fileLink.split("/");
|
||||
name = split[split.length - 1];
|
||||
}
|
||||
saveFile(new File("plugins/" + updateFolder), name, fileLink);
|
||||
}
|
||||
else {
|
||||
result = UpdateResult.UPDATE_AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,11 +499,11 @@ Kraken:
|
||||
Name: The Kraken
|
||||
Attack_Interval_Seconds: 1
|
||||
Attack_Damage: 1.0
|
||||
Global_Effects: false
|
||||
Global_Sounds: true
|
||||
Allow_Escaping: false
|
||||
Unleashed_Message:
|
||||
Server: (PLAYER) has unleashed the kraken!
|
||||
Player: THE KRAKEN HAS BEEN UNLEASHED!
|
||||
Defeated_Message:
|
||||
Escape: You have escaped from the kraken!
|
||||
Killed: You have slain the kraken!
|
||||
Killed: You have slain the kraken!
|
||||
@@ -27,62 +27,35 @@ General:
|
||||
# Should mcMMO over-write configs to update, or make new ones ending in .new?
|
||||
Config_Update_Overwrite: true
|
||||
|
||||
#
|
||||
# Settings for the mcMMO scoreboards
|
||||
###
|
||||
Scoreboard:
|
||||
# Display player's power levels below their names?
|
||||
Power_Level_Tags: false
|
||||
|
||||
# Allow players to use "/mcscoreboard keep" to keep the scoreboard up
|
||||
Allow_Keep: true
|
||||
|
||||
# Add some more color on the board :-)
|
||||
Rainbows: false
|
||||
|
||||
# Settings for each type of scoreboard
|
||||
Types:
|
||||
# Settings for /mcrank
|
||||
# The sub-options (Print, Board, Display_Time) are the same for each type.
|
||||
Rank:
|
||||
# Should the command output be printed in chat?
|
||||
Print: false
|
||||
# Should the command output be displayed in the scoreboard sidebar?
|
||||
Board: true
|
||||
# Amount of time (seconds) to display in the sidebar before clearing.
|
||||
# To display permanently, use "/mcscoreboard keep" or set to -1
|
||||
Display_Time: 15
|
||||
# Settings for /mctop
|
||||
Top:
|
||||
Print: true
|
||||
Board: true
|
||||
Display_Time: 15
|
||||
# Settings for /mcstats
|
||||
Stats:
|
||||
Print: false
|
||||
Board: true
|
||||
Display_Time: 15
|
||||
# Settings for /inspect
|
||||
Inspect:
|
||||
Print: false
|
||||
Board: true
|
||||
Display_Time: 20
|
||||
# Settings for /mccooldown
|
||||
Cooldown:
|
||||
Print: true
|
||||
Board: true
|
||||
Display_Time: 41
|
||||
# Settings for /<skillname> (e.g. /mining, /unarmed)
|
||||
# No "print" option is given here; the information will always be displayed in chat.
|
||||
# It should also be noted that this display is pretty dang cool.
|
||||
Skill:
|
||||
Board: true
|
||||
Display_Time: 30
|
||||
|
||||
# Should the board be shown when a player levels up, and for how long?
|
||||
# It is recommended to NOT have LevelUp_Time be -1, as this may confuse players.
|
||||
LevelUp_Board: true
|
||||
LevelUp_Time: 5
|
||||
Scoreboards:
|
||||
# Should mcMMO use scoreboards for /inspect?
|
||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||
Inspect:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO use scoreboards for /mcrank?
|
||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||
Mcrank:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO use scoreboards for /mcstats?
|
||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||
Mcstats:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO use scoreboards for /mctop?
|
||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||
Mctop:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO use scoreboards for /skillname (/mining, /fishing, etc.)?
|
||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||
Skillname:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO display power levels on scoreboards? (below player name-tags)
|
||||
Power_Level:
|
||||
Use: false
|
||||
|
||||
Mob_Healthbar:
|
||||
# Default display for mob health bars - HEARTS, BAR, or DISABLED
|
||||
@@ -231,7 +204,6 @@ Skills:
|
||||
Enabled_For_PVP: true
|
||||
Enabled_For_PVE: true
|
||||
Prevent_AFK_Leveling: true
|
||||
Max_Tries_At_Same_Location: 3
|
||||
Prevent_Dodge_Lightning: false
|
||||
Prevent_XP_After_Teleport: true
|
||||
Level_Cap: 0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user