1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 17:53:00 +01:00

Compare commits

..

110 Commits

Author SHA1 Message Date
GJ
fcdb5abaea Reimplement Impact event 2013-11-12 12:25:09 -05:00
TfT_02
b1095ce1a6 Fix things after rebase 2013-11-12 17:05:25 +01:00
TfT_02
2497c62ada Move changelog entries to 1.4.08 2013-11-12 17:05:25 +01:00
GJ
997685b5ec More event work. 2013-11-12 17:05:24 +01:00
GJ
a65bcb9e5d More event work. 2013-11-12 17:05:24 +01:00
GJ
26d5db07ef Axe events. 2013-11-12 17:05:24 +01:00
GJ
d6fbf1be34 Move standard activation checks into activation function, Archery refactoring, Unarmed cleanup, start work on Axe events. 2013-11-12 17:05:24 +01:00
GJ
965035fa72 Archery events & bugfixes
- Added custom events for Skill Shot and Daze.
- Archery metadata is now stored directly as a location, rather than a
string.
- Fixed bug where arrows weren't properly tracked.
- Use HashMap instead of ArrayList for entity tracking.
2013-11-12 17:05:24 +01:00
GJ
a99293aa48 We should ALWAYS inform other plugins of what we're doing. 2013-11-12 17:05:24 +01:00
GJ
20967bea92 Add roll event, remove particle flag from the dodge event. 2013-11-12 17:05:24 +01:00
GJ
e10b70c422 Add event for Dodge 2013-11-12 17:05:24 +01:00
GJ
071c568353 Add boolean for particle effects to ability events. 2013-11-12 17:05:24 +01:00
GJ
d5fb19a7db Make ability events separate from skill events 2013-11-12 17:05:23 +01:00
GJ
badabeb8e4 Refactor experience events into separate packages.
Level events are now in one package, and XP events are now in a second
package.
2013-11-12 17:05:23 +01:00
GJ
d0a1d44fa2 Add new McMMOPlayerXpLossEvent 2013-11-12 17:05:23 +01:00
GJ
fdaa42edd3 Fire appropriate level change events for Hardcore mode. 2013-11-12 17:05:23 +01:00
GJ
e904e34556 Update Korean translation
Closes PR #1613 from @wolfdate25
2013-11-12 08:15:58 -05:00
TfT_02
445f805bb8 Set the treasure drop after using .clone()
Fixes #1603
2013-11-12 12:49:16 +01:00
t00thpick1
df77b9d0ed Parenthesis 2013-11-10 13:56:15 -05:00
t00thpick1
29f2525b58 Tend toward the smaller values, and configurable maximum for horse jump strength 2013-11-10 13:54:45 -05:00
TfT_02
5a68c7a335 Fixed bug which prevented gaining Acrobatics XP 2013-11-10 00:52:30 +01:00
GJ
69ef7f40d8 Command cleanup. 2013-11-08 23:14:11 +01:00
GJ
d1d6b80676 Allow repair of items without a recipe. 2013-11-08 10:52:43 -05:00
GJ
dfe83ff497 Fix divide by zero bug
Minimum Level & Minimum Quantity were accidentally flipped.
2013-11-07 09:13:56 -05:00
riking
e5acf6d936 Also clone fishing treasures, use alternate Wool method
The alternate wool method is testing, the treasure clone is there to stay ;)
2013-11-06 21:34:16 -08:00
riking
bca0ca6766 Fix Shake poisoning the treasure cache with Wither skeletons
The returned ItemStack is modified for both Sheep and Skeletons, so a copy should be returned.
2013-11-06 21:03:13 -08:00
GJ
f17b5faaf6 Parenthesis are good. 2013-11-06 14:52:19 -05:00
GJ
f20fa571f1 Update changelog. 2013-11-06 11:56:50 -05:00
GJ
b90d1c31c7 Updated localization files
Includes new Portuguese (Brazil) translation provided by @FabioZumbi12
in #1585

Includes new Korean translation provided by @wolfwork in #1258
2013-11-06 09:48:05 -05:00
GJ
cf56ca35eb Tweaked durability handling slightly.
Now routes everything through one function to handle enchants and max
durability. Use max durability from RepairableManager by default to
account for mod tools.
2013-11-06 08:45:20 -05:00
TfT_02
c31f5b5782 Account for Unbreaking enchantment when using abilities 2013-11-05 14:51:54 +01:00
GJ
af98c8eb59 Best way to handle minimum quantities.
Check repair function first, assuming the item isn't null, otherwise
check the config. If not found, check config.
2013-11-04 11:01:14 -05:00
TfT_02
3a10b2d83c Make sure we're not setting a bite chance > 1.0
Fixes #1592
2013-11-04 10:32:05 +01:00
TfT_02
32e7c48fd8 Change this message to something that makes sense
The old message was confusing see #1593
2013-11-03 22:49:39 +01:00
Glitchfinder
af578870c7 Defaulted quantities should be defaulted everywhere.
Fixes #1581
2013-11-03 09:40:04 -08:00
TfT_02
cd470d5497 Fix a NPE which occured when there was no backups folder 2013-11-03 14:09:41 +01:00
TfT_02
a9c5e2a04f Don't send a message to the console if no backups were deleted 2013-11-02 21:50:49 +01:00
TfT_02
0196fd8447 Fix the update checker 2013-11-02 21:49:20 +01:00
TfT_02
b1458840e7 Permissions should be lowercase 2013-11-02 19:29:36 +01:00
TfT_02
1fea786669 Added bypass permission for finding Fishing traps 2013-11-02 19:25:02 +01:00
TfT_02
6f9a57751e We can't schedule tasks in onDisable() 2013-11-01 17:39:03 +01:00
GJ
2e1c585005 Fix issue with updating players that are offline. 2013-11-01 12:38:40 -04:00
GJ
811626e67b Cleanup. 2013-11-01 11:54:51 -04:00
TfT_02
cdfd81a67a Cleanup ZipLibrary class 2013-11-01 16:44:03 +01:00
TfT_02
408b8b2107 Added automatic cleanup of backups folder
By default mcMMO keeps the following files:
 * All files from the last 24 hours
 * Daily backups of the past week
 * Weekly backups of the past months

Adds #1574
2013-11-01 16:43:56 +01:00
GJ
6d5f3a52f4 Don't process chat if the mcMMOPlayer is null.
The player should ALWAYS be online when chatting, but depending on
external plugins and applications, this is not always properly
implemented. Fixes #1578
2013-11-01 09:30:10 -04:00
GJ
2cdf08de9f Allow offline players for chat events.
This fixes issues with plugins or applications that rely on JSONAPI to
chat. Fixes #1578
2013-11-01 09:12:06 -04:00
GJ
71141a0f8d Minimum quantity should default to 2.
Fixes #1581
2013-11-01 08:22:14 -04:00
TfT_02
bded936af5 Cleanup our imports 2013-10-31 22:30:05 +01:00
GJ
caaac232d7 Cleanup CombatUtils.
Opting to stick with the if-else rather than the switch statement,
because I think it's slightly easier to read.
2013-10-31 15:03:06 -04:00
GJ
a9d51dad34 Clean up Smelting checks.
Now uses recipes to check if an item is the result of smelting.
2013-10-31 14:29:06 -04:00
GJ
88296da0af Removed MCPC+ workaround.
This has been fixed by MCPC+ starting with build 112.

Addresses #1549
2013-10-31 13:28:54 -04:00
GJ
de3c4f8fd7 Smelting now works with custom ores.
Also fixed exploit where smelting XP could be awarded for some
non-smeltable materials.
2013-10-31 13:25:06 -04:00
GJ
1785bab504 Fix bug with Salvage config value.
After our renames and updates, Salvage was not reading the config value
for the anvil material properly.
2013-10-31 09:09:52 -04:00
GJ
41da32cd1b Added options to disable various sound effects.
Fixes #1577
2013-10-31 09:03:29 -04:00
GJ
93d586592e Move these checks up.
These checks need to happen sooner because they may impact config
loading, specifically the MCPC+ check.

Fixes #1549
2013-10-31 08:15:30 -04:00
Glitchfinder
d6c6c75157 Experience is occasionally zero or cast to zero.
Fixes #1575 and fixes #1576
2013-10-30 15:49:47 -07:00
GJ
4889769522 Workaround MCPC+ shortcomings for now.
Fixes #1549
2013-10-30 15:33:37 -04:00
TfT_02
6c70de6a58 Also backup experience.yml 2013-10-30 12:33:34 +01:00
GJ
fd9154e009 Fixed bug with toggle commands not properly displaying the success message. 2013-10-29 11:45:27 -04:00
GJ
97b9214d6e Wrap these inside McMMOPlayer for easier access. 2013-10-29 11:02:57 -04:00
GJ
a8d1376533 More minor cleanup. 2013-10-29 10:01:30 -04:00
GJ
3be443c63c Cleanup some XP functions, remove unused scoreboard values, minor refactoring. 2013-10-29 09:49:41 -04:00
GJ
cc2c9eb21d Move this to the skill itself. 2013-10-28 16:32:40 -04:00
GJ
9b3ae5c729 These belong in their managers, not in McMMOPlayer 2013-10-28 16:14:52 -04:00
GJ
ccb7fc5886 Remove, don't just comment out. 2013-10-28 16:04:55 -04:00
GJ
60d69e3cc4 Create wrapper to handle all PTP data. 2013-10-28 15:49:48 -04:00
riking
f64f62492f Reinstate static color list, clarify intent 2013-10-28 12:47:25 -07:00
GJ
3fe936306b Oops. 2013-10-28 15:19:47 -04:00
GJ
c79f8043ad Use proper functions where they exist, and move functions to better locations. 2013-10-28 15:12:24 -04:00
GJ
8369ae4616 Don't use a class variable here. 2013-10-28 14:14:20 -04:00
GJ
4715688fe8 Update changelog. 2013-10-28 14:07:41 -04:00
GJ
62e03a4ef5 Black is hard to read. 2013-10-28 13:58:34 -04:00
GJ
9ef3c721df Formatting cleanup from the scoreboard update. Also handle skill permissions differently. 2013-10-28 13:04:46 -04:00
TfT_02
f55039ac6b Earn XP when using Shake
Adds #1564
2013-10-28 17:38:03 +01:00
TfT_02
be792a1052 Fix exploitPrevention() and add Javadocs 2013-10-28 15:39:47 +01:00
GJ
c612036db3 Don't try to find a treasure if there aren't any.
Fixes #1572
2013-10-28 08:52:55 -04:00
GJ
ad4ee6f402 Cleanup exploit prevention method. 2013-10-28 08:17:06 -04:00
TfT_02
49a5bd2ba6 We can move this check to exploitPrevention() 2013-10-26 00:50:31 +02:00
GJ
8aac6a992b Back to active development. 2013-10-25 17:11:54 -04:00
GJ
5da66f05d4 Update pom.xml for 1.4.07 release 2013-10-25 17:11:04 -04:00
GJ
134e0db2e9 Cleanup more of Riking's mess. 2013-10-25 17:07:56 -04:00
GJ
b3415ee2f4 Cleanup some of Riking's mess. 2013-10-25 17:05:36 -04:00
TfT_02
14175a6dfd Don't complain about missing Guide strings 2013-10-25 22:16:18 +02:00
TfT_02
7b3fb46a9a Improved AFK Acrobatics prevention mechanism 2013-10-25 22:02:39 +02:00
Kane York
0aea165a8f Add note about temporary dev build setup to README 2013-10-25 11:46:29 -07:00
riking
17b7a9bf10 Add message to /mcscoreboard time [n] 2013-10-25 11:41:21 -07:00
riking
bd611ee11c Add message to /mcscoreboard keep when a board is not shown 2013-10-25 11:39:24 -07:00
riking
c6ca65f5c9 Create a utility method in SkillUtils to easily check ability cooldowns 2013-10-25 09:49:02 -07:00
riking
95f15e68fe New and Improved Scoreboard System
- Scoreboards now AUTO-UPDATE
 - Scoreboards now COME IN COLOR
 - If you want, they can come in EVERY COLOR (Config setting)
 - Scoreboards can be displayed alongside chat output!
 - Prevention of denial of service to SQL via spamming /mctop using a cooldown
 - Added /mccooldown command to show cooldowns for all available skills
2013-10-25 09:49:02 -07:00
TfT_02
89dabaeb43 Hook location cleanup 2013-10-24 23:14:23 +02:00
TfT_02
c2e100b1e3 Use hook location in Master Angler 2013-10-24 21:19:24 +02:00
GJ
9f33c6cef1 Use addUnsafeEnchantment instead of addEnchantment
Since the enchantment was already present on the item, there's no need to check if it's valid. This also avoids any errors that may occur when trying to repair an item with non-standard enchants.

Fixes #1561
2013-10-22 09:57:13 -04:00
GJ
7e241e3993 Useless else statement. 2013-10-21 13:15:41 -04:00
GJ
bc51505150 More cleanup. 2013-10-21 08:31:35 -04:00
TfT_02
e0599a0dea Subtract XP with Hardcore mode
Adds #1529
2013-10-20 20:02:16 +02:00
TfT_02
d410251595 Changed kraken default behavior
It will no longer broadcast chat messages globally by default, as well as strike lightning on it's target. Instead it will spawn explosion effects.
2013-10-20 17:04:50 +02:00
TfT_02
810c74dc2a Fixed bug which prevented players from leveling up
Any affected players will get their levels back when they gain some
more XP in that particular skill.
2013-10-19 14:08:04 +02:00
TfT_02
100f2c7e56 Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus 2013-10-19 00:27:07 +02:00
TfT_02
e13e5295e8 Notify about updates if user is running dev1 and beta1 is available 2013-10-18 17:25:21 +02:00
TfT_02
b100b7bcc7 Gravity's Updater version 2.0 2013-10-18 16:58:12 +02:00
TfT_02
f4ff8518c2 Cleanup progress feedback 2013-10-18 16:43:37 +02:00
riking
dbd27b641e Give periodic status messages to the console in conversion 2013-10-18 16:40:44 +02:00
TfT_02
4a428a47af Fix bug with HolidayManager and some cleanup 2013-10-18 16:24:01 +02:00
GJ
3252137ed7 Update locale files. 2013-10-18 10:20:38 -04:00
GJ
68c4b99d1b Oops. 2013-10-18 10:16:51 -04:00
GJ
f282891d0a More info for armor errors. 2013-10-18 10:15:23 -04:00
GJ
7f4e3fedb3 Need different methods for mod files and regular files. 2013-10-18 10:12:55 -04:00
GJ
2042e0cdbd How did I not realize this would loop forever... 2013-10-18 10:02:11 -04:00
GJ
2662fee9fb ACTUALLY use the proper path. 2013-10-18 10:02:10 -04:00
224 changed files with 7305 additions and 5395 deletions

View File

@@ -7,7 +7,23 @@ Key:
! Change
- Removal
Version 1.4.07-dev
Version 1.4.08-dev
+ Added the possibility to gain experience when using Fishing "Shake"
+ Added config options to disable various sound effects
+ Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP.
+ Added automatic cleanup of backups folder.
+ Added bypass permission for finding Fishing traps
= Fixed bug with toggle commands not properly displaying the success message.
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
= Fixed bug with Salvage not reading the config value for the anvil material.
= Fixed exploit where you could receive smelting XP for improper items
= Fixed bug where the Unbreaking enchantment was ignored when using "Super Breaker" or "Giga Drill Breaker"
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
= Fixed McMMOPlayerDisarmEvent reporting the skill level of the defending player, not the attacking player.
= Fixed bug where arrow retrieval was not properly detecting entities that already existed in the tracker
! Updated localization files
Version 1.4.07
+ 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,6 +46,12 @@ Version 1.4.07-dev
+ 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
@@ -51,6 +73,8 @@ Version 1.4.07-dev
! 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.
@@ -61,6 +85,7 @@ Version 1.4.07-dev
! 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
@@ -68,6 +93,8 @@ Version 1.4.07-dev
! 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.

View File

@@ -2,7 +2,7 @@
## The RPG lovers mod
### Dev builds
Our latest development builds are available [here](http://ci.mcmmo.info).
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/).
### 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,6 +29,8 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)]
(https://github.com/riking)
## Compiling

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.07-dev2</version>
<version>1.4.08-dev1</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>ci.mcmmo.org</url>
<system>Jenkins</system>
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
</ciManagement>
</project>

View File

@@ -50,34 +50,34 @@ public final class AbilityAPI {
}
public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).getProfile().resetCooldowns();
UserManager.getPlayer(player).resetCooldowns();
}
public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.BERSERK, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.BERSERK, cooldown);
}
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
}
public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GREEN_TERRA, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
}
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SERRATED_STRIKES, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
}
public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SKULL_SPLITTER, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
}
public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SUPER_BREAKER, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
}
public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.TREE_FELLER, cooldown);
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
}
}

View File

@@ -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,44 +73,40 @@ 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) {
return UserManager.getPlayer(player).getPartyChatMode();
return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY);
}
/**
* 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) {
return UserManager.getPlayer(playerName).getPartyChatMode();
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
}
/**
* 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) {
return UserManager.getPlayer(player).getAdminChatMode();
return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN);
}
/**
* 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) {
return UserManager.getPlayer(playerName).getAdminChatMode();
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
}
/**
@@ -119,7 +115,7 @@ public final class ChatAPI {
* @param player The player to toggle party chat on.
*/
public static void togglePartyChat(Player player) {
UserManager.getPlayer(player).togglePartyChat();
UserManager.getPlayer(player).toggleChat(ChatMode.PARTY);
}
/**
@@ -128,7 +124,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on.
*/
public static void togglePartyChat(String playerName) {
UserManager.getPlayer(playerName).togglePartyChat();
UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY);
}
/**
@@ -137,7 +133,7 @@ public final class ChatAPI {
* @param player The player to toggle admin chat on.
*/
public static void toggleAdminChat(Player player) {
UserManager.getPlayer(player).toggleAdminChat();
UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN);
}
/**
@@ -146,7 +142,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on.
*/
public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).toggleAdminChat();
UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN);
}
private static ChatManager getPartyChatManager(Plugin plugin, String party) {

View File

@@ -24,7 +24,6 @@ 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) {
@@ -39,15 +38,12 @@ 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();
}
@@ -62,9 +58,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
*/
@@ -83,10 +79,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) {
@@ -98,9 +94,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
*/
@@ -114,10 +110,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) {
@@ -129,9 +125,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
*/
@@ -147,10 +143,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) {
@@ -165,9 +161,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
*/
@@ -180,16 +176,15 @@ 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) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(getNonChildSkillType(skillType));
return UserManager.getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType));
}
/**
@@ -198,12 +193,11 @@ 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) {
@@ -215,16 +209,15 @@ 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) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(getNonChildSkillType(skillType));
return UserManager.getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType));
}
/**
@@ -233,12 +226,11 @@ 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) {
@@ -250,16 +242,15 @@ 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) {
return UserManager.getPlayer(player).getProfile().getXpToLevel(getNonChildSkillType(skillType));
return UserManager.getPlayer(player).getXpToLevel(getNonChildSkillType(skillType));
}
/**
@@ -268,12 +259,11 @@ 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) {
@@ -285,12 +275,11 @@ 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) {
@@ -307,12 +296,11 @@ 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) {
@@ -328,14 +316,14 @@ 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
*/
public static void addLevel(Player player, String skillType, int levels) {
UserManager.getPlayer(player).getProfile().addLevels(getSkillType(skillType), levels);
UserManager.getPlayer(player).addLevels(getSkillType(skillType), levels);
}
/**
@@ -344,10 +332,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) {
@@ -374,15 +362,14 @@ 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
*/
public static int getLevel(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillLevel(getSkillType(skillType));
return UserManager.getPlayer(player).getSkillLevel(getSkillType(skillType));
}
/**
@@ -391,11 +378,10 @@ 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) {
@@ -408,7 +394,6 @@ 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) {
@@ -421,7 +406,6 @@ 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
@@ -443,7 +427,6 @@ 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
@@ -469,16 +452,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
* @param skillType The skill to check
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getPlayerRankSkill(String playerName, String skillType) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
}
@@ -489,12 +472,12 @@ public final class ExperienceAPI {
*
* @param playerName The name of the player to check
*
* @return the position on the power level leaderboard
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard
*/
public static int getPlayerRankOverall(String playerName) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
}
/**
@@ -502,14 +485,14 @@ 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
*/
public static void setLevel(Player player, String skillType, int skillLevel) {
UserManager.getPlayer(player).getProfile().modifySkill(getSkillType(skillType), skillLevel);
UserManager.getPlayer(player).modifySkill(getSkillType(skillType), skillLevel);
}
/**
@@ -518,10 +501,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) {
@@ -533,15 +516,15 @@ 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) {
UserManager.getPlayer(player).getProfile().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
UserManager.getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
}
/**
@@ -550,11 +533,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) {
@@ -566,15 +549,15 @@ 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) {
UserManager.getPlayer(player).getProfile().removeXp(getNonChildSkillType(skillType), xp);
UserManager.getPlayer(player).removeXp(getNonChildSkillType(skillType), xp);
}
/**
@@ -583,11 +566,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) {
@@ -599,18 +582,7 @@ public final class ExperienceAPI {
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName);
if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
for (SkillType parentSkill : parentSkills) {
profile.setSkillXpLevel(parentSkill, profile.getSkillLevel(parentSkill) + (XP / parentSkills.size()));
}
profile.save();
return;
}
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + XP);
profile.addXp(skill, XP);
profile.save();
}

View File

@@ -21,7 +21,6 @@ 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) {
@@ -38,7 +37,6 @@ 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) {
@@ -52,7 +50,6 @@ 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) {
@@ -75,7 +72,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) {
@@ -105,7 +102,6 @@ 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) {
@@ -118,7 +114,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));
@@ -130,7 +126,6 @@ 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
@@ -150,7 +145,6 @@ 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) {
@@ -163,7 +157,6 @@ 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) {
@@ -176,7 +169,6 @@ 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) {

View File

@@ -7,7 +7,6 @@ import java.util.Set;
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.datatypes.player.McMMOPlayer;
@@ -32,7 +31,7 @@ public class KrakenCommand implements TabExecutor {
return true;
}
UserManager.getPlayer((Player) sender).getFishingManager().unleashTheKraken();
UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
return true;
case 1:

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McabilityCommand extends ToggleCommand {
}
@Override
protected void applyCommandAction() {
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
mcMMOPlayer.toggleAbilityUse();
}
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.commands.database;
package com.gmail.nossr50.commands;
import java.util.ArrayList;
import java.util.Collections;
@@ -11,6 +11,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
@@ -23,23 +24,17 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static {
ArrayList<String> formulaTypes = new ArrayList<String>();
ArrayList<String> databaseTypes = new ArrayList<String>();
for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString());
}
Collections.sort(formulaTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
}
static {
ArrayList<String> databaseTypes = new ArrayList<String>();
for (DatabaseType type : DatabaseType.values()) {
databaseTypes.add(type.toString());
}
@@ -51,8 +46,12 @@ public class McconvertCommand implements TabExecutor {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
}
Collections.sort(formulaTypes);
Collections.sort(databaseTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
}
@Override

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McgodCommand extends ToggleCommand {
}
@Override
protected void applyCommandAction() {
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode();
}
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName));
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -17,17 +18,17 @@ public class McrefreshCommand extends ToggleCommand {
}
@Override
protected void applyCommandAction() {
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.getProfile().resetCooldowns();
mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetAbilityMode();
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
}
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
}
}

View File

@@ -6,21 +6,17 @@ 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.datatypes.skills.SkillType;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class McscoreboardCommand implements TabExecutor {
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -28,94 +24,49 @@ public class McscoreboardCommand implements TabExecutor {
return true;
}
Player player = (Player) sender;
switch (args.length) {
case 0:
clearScoreboard(player);
return true;
case 1:
if (args[0].equalsIgnoreCase("clear")) {
clearScoreboard(player);
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
ScoreboardManager.clearBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
return true;
}
else if (args[0].equalsIgnoreCase("rank")) {
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
if (args[0].equalsIgnoreCase("keep")) {
if (!Config.getInstance().getAllowKeepBoard()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
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
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
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;
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
return true;
}
return true;
return help(sender);
case 2:
if (!args[0].equalsIgnoreCase("top")) {
return false;
}
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
if (!Config.getInstance().getMctopScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
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;
return help(sender);
default:
return false;
return help(sender);
}
}
@@ -123,20 +74,17 @@ public class McscoreboardCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
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
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
default:
return ImmutableList.of();
}
}
private void clearScoreboard(Player player) {
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
private boolean 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"));
return true;
}
}

View File

@@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -40,11 +39,9 @@ public class MobhealthCommand implements TabExecutor {
switch (args.length) {
case 1:
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
playerProfile.setMobHealthbarType(type);
UserManager.getPlayer((Player) sender).getProfile().setMobHealthbarType(type);
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true;
}

View File

@@ -7,7 +7,6 @@ import java.util.Set;
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.datatypes.player.McMMOPlayer;
@@ -18,9 +17,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public abstract class ToggleCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
@@ -34,10 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
applyCommandAction();
applyCommandAction(UserManager.getPlayer(sender.getName()));
return true;
case 1:
@@ -47,20 +40,18 @@ public abstract class ToggleCommand implements TabExecutor {
}
String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;
}
player = mcMMOPlayer.getPlayer();
if (CommandUtils.isOffline(sender, player)) {
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
return true;
}
applyCommandAction();
sendSuccessMessage(sender);
applyCommandAction(mcMMOPlayer);
sendSuccessMessage(sender, playerName);
return true;
default:
@@ -80,10 +71,7 @@ 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);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
}

View File

@@ -18,11 +18,7 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
public class XprateCommand implements TabExecutor {
private double originalRate;
public XprateCommand() {
originalRate = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
}
private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -42,7 +38,7 @@ public class XprateCommand implements TabExecutor {
mcMMO.p.toggleXpEventEnabled();
}
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(ORIGINAL_XP_RATE);
return true;
case 2:

View File

@@ -21,9 +21,8 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public abstract class ChatCommand implements TabExecutor {
protected ChatMode chatMode;
private ChatMode chatMode;
protected ChatManager chatManager;
private McMMOPlayer mcMMOPlayer;
public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode;
@@ -32,19 +31,21 @@ public abstract class ChatCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
mcMMOPlayer = UserManager.getPlayer((Player) sender);
mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (chatMode.isEnabled(mcMMOPlayer)) {
disableChatMode(sender);
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
}
else {
enableChatMode(sender);
enableChatMode(mcMMOPlayer, sender);
}
return true;
@@ -55,9 +56,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer((Player) sender);
enableChatMode(sender);
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
}
@@ -66,9 +65,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer((Player) sender);
disableChatMode(sender);
disableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
}
@@ -108,23 +105,23 @@ public abstract class ChatCommand implements TabExecutor {
protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(CommandSender sender) {
private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
chatMode.enable(mcMMOPlayer);
mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage());
}
private void disableChatMode(CommandSender sender) {
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
chatMode.disable(mcMMOPlayer);
mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage());
}
}

View File

@@ -15,19 +15,21 @@ import com.google.common.collect.ImmutableList;
public class MmoshowdbCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 0) {
return false;
switch (args.length) {
case 0:
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
default:
return false;
}
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
}
@Override

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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.EventUtils;
@@ -19,11 +21,12 @@ public class AddlevelsCommand extends ExperienceCommand {
}
@Override
protected void handleCommand(SkillType skill) {
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player == null) {
profile.save();
return;
}
@@ -31,12 +34,12 @@ public class AddlevelsCommand extends ExperienceCommand {
}
@Override
protected void handlePlayerMessageAll() {
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
}
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName()));
protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
}
}

View File

@@ -1,10 +1,13 @@
package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class AddxpCommand extends ExperienceCommand {
@Override
@@ -18,22 +21,23 @@ public class AddxpCommand extends ExperienceCommand {
}
@Override
protected void handleCommand(SkillType skill) {
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
if (player != null) {
mcMMOPlayer.applyXpGain(skill, value);
UserManager.getPlayer(player).applyXpGain(skill, value);
}
else {
profile.addExperience(skill, value);
profile.addXp(skill, value);
profile.save();
}
}
@Override
protected void handlePlayerMessageAll() {
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
}
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
}
}

View File

@@ -22,14 +22,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public abstract class ExperienceCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
protected PlayerProfile profile;
protected boolean allSkills;
protected SkillType skill;
protected int value;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
@@ -47,12 +39,7 @@ public abstract class ExperienceCommand implements TabExecutor {
return true;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
cleanUp();
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), Integer.parseInt(args[1]));
return true;
case 3:
@@ -65,28 +52,27 @@ public abstract class ExperienceCommand implements TabExecutor {
return true;
}
SkillType skill = SkillType.getSkill(args[1]);
int value = Integer.parseInt(args[2]);
String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
editValues();
profile.save(); // Since this is a temporary profile, we save it here.
editValues(null, profile, skill, value);
}
else {
profile = mcMMOPlayer.getProfile();
player = mcMMOPlayer.getPlayer();
editValues();
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
}
handleSenderMessage(sender, playerName);
cleanUp();
handleSenderMessage(sender, playerName, skill);
return true;
default:
@@ -108,75 +94,44 @@ 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();
protected abstract void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, SkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) {
if (isInvalidInteger(sender, value) || isInvalidSkill(sender, skillName)) {
if (CommandUtils.isInvalidInteger(sender, value) || CommandUtils.isInvalidSkill(sender, skillName)) {
return false;
}
return true;
}
private boolean isInvalidInteger(CommandSender sender, String value) {
if (CommandUtils.isInvalidInteger(sender, value)) {
return true;
}
this.value = Integer.parseInt(value);
return false;
}
protected boolean isInvalidSkill(CommandSender sender, String skillName) {
if (skillName.equalsIgnoreCase("all")) {
allSkills = true;
return false;
}
else if (CommandUtils.isInvalidSkill(sender, skillName)) {
return true;
}
skill = SkillType.getSkill(skillName);
return false;
}
protected void handleSenderMessage(CommandSender sender, String playerName) {
if (allSkills) {
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues() {
if (allSkills) {
protected void editValues(Player player, PlayerProfile profile, SkillType skill, int value) {
if (skill == null) {
for (SkillType skillType : SkillType.values()) {
handleCommand(skillType);
handleCommand(player, profile, skillType, value);
}
if (player != null) {
handlePlayerMessageAll();
handlePlayerMessageAll(player, value);
}
}
else {
handleCommand(skill);
handleCommand(player, profile, skill, value);
if (player != null) {
handlePlayerMessageSkill();
handlePlayerMessageSkill(player, value, skill);
}
}
}
private void cleanUp() {
allSkills = false;
player = null;
}
}

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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.EventUtils;
@@ -19,13 +21,18 @@ public class MmoeditCommand extends ExperienceCommand {
}
@Override
protected void handleCommand(SkillType skill) {
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);
if (player == null || value == skillLevel) {
if (player == null) {
profile.save();
return;
}
if (value == skillLevel) {
return;
}
@@ -33,12 +40,12 @@ public class MmoeditCommand extends ExperienceCommand {
}
@Override
protected void handlePlayerMessageAll() {
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
}
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
}
}

View File

@@ -1,10 +1,18 @@
package com.gmail.nossr50.commands.experience;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
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.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.EventUtils;
@@ -12,18 +20,11 @@ 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.google.common.collect.ImmutableList;
public class SkillresetCommand extends ExperienceCommand {
private CommandSender sender;
private Command command;
private int argsLength;
public class SkillresetCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.command = command;
this.sender = sender;
argsLength = args.length;
switch (args.length) {
case 1:
if (CommandUtils.noConsoleUsage(sender)) {
@@ -35,15 +36,11 @@ public class SkillresetCommand extends ExperienceCommand {
return true;
}
if (isInvalidSkill(sender, args[0])) {
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), args.length, sender, command);
return true;
case 2:
@@ -52,32 +49,30 @@ public class SkillresetCommand extends ExperienceCommand {
return true;
}
if (isInvalidSkill(sender, args[1])) {
if (CommandUtils.isInvalidSkill(sender, args[1])) {
return true;
}
SkillType skill = SkillType.getSkill(args[1]);
String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
editValues();
profile.save(); // Since this is a temporary profile, we save it here.
editValues(null, profile, skill, args.length, sender, command);
}
else {
profile = mcMMOPlayer.getProfile();
player = mcMMOPlayer.getPlayer();
editValues();
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, args.length, sender, command);
}
handleSenderMessage(sender, playerName);
ExperienceCommand.handleSenderMessage(sender, playerName, skill);
return true;
default:
@@ -86,17 +81,38 @@ public class SkillresetCommand extends ExperienceCommand {
}
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return false;
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return false;
private void editValues(Player player, PlayerProfile profile, SkillType skill, int argsLength, CommandSender sender, Command command) {
if (skill == null) {
for (SkillType skillType : SkillType.values()) {
handleCommand(player, profile, skillType, argsLength, sender, command);
}
if (player != null) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
}
else {
handleCommand(player, profile, skill, argsLength, sender, command);
if (player != null) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
}
}
}
@Override
protected void handleCommand(SkillType skill) {
private void handleCommand(Player player, PlayerProfile profile, SkillType skill, int argsLength, CommandSender sender, Command command) {
if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) {
sender.sendMessage(command.getPermissionMessage());
return;
@@ -108,19 +124,10 @@ public class SkillresetCommand extends ExperienceCommand {
profile.modifySkill(skill, 0);
if (player == null) {
profile.save();
return;
}
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
}
@Override
protected void handlePlayerMessageAll() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
}
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -8,18 +10,18 @@ import com.gmail.nossr50.util.Permissions;
public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions() {
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.hardcoreToggle(sender);
}
@Override
protected boolean checkModifyPermissions() {
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender);
}
@Override
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
protected boolean checkEnabled(SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreStatLossEnabled()) {
return false;
@@ -29,35 +31,35 @@ public class HardcoreCommand extends HardcoreModeCommand {
return true;
}
return SkillType.getSkill(skill).getHardcoreStatLossEnabled();
return skill.getHardcoreStatLossEnabled();
}
@Override
protected void enable(String skill) {
toggle(true);
protected void enable(SkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(String skill) {
toggle(false);
protected void disable(SkillType skill) {
toggle(false, skill);
}
@Override
protected void modify() {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercent / 100D)));
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
private void toggle(boolean enable, SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreStatLossEnabled(enable);
}
}
else {
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
skill.setHardcoreStatLossEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
}
}

View File

@@ -17,31 +17,22 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
public abstract class HardcoreModeCommand implements TabExecutor {
protected CommandSender sender;
protected double newPercent;
protected DecimalFormat percent;
protected String skill;
public HardcoreModeCommand() {
percent = new DecimalFormat("##0.00%");
}
protected final DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
this.sender = sender;
if (!checkTogglePermissions()) {
if (!checkTogglePermissions(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (checkEnabled("ALL")) {
disable("ALL");
if (checkEnabled(null)) {
disable(null);
}
else {
enable("ALL");
enable(null);
}
return true;
@@ -53,7 +44,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
enable("ALL");
enable(null);
return true;
}
@@ -63,11 +54,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
disable("ALL");
disable(null);
return true;
}
if (isInvalidPercentage(sender, args[0])) {
if (CommandUtils.isInvalidDouble(sender, args[0])) {
return true;
}
@@ -76,16 +67,20 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
modify();
modify(sender, Double.parseDouble(args[0]));
return true;
case 2:
if (!args[0].equalsIgnoreCase("ALL") && CommandUtils.isChildSkill(sender, SkillType.getSkill(args[0]))) {
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
skill = args[0];
SkillType skill = SkillType.getSkill(args[0]);
if (!CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
@@ -103,7 +98,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
disable(skill);
enable(skill);
return true;
}
@@ -128,24 +123,10 @@ 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) {
if (CommandUtils.isInvalidDouble(sender, value)) {
return true;
}
newPercent = Double.parseDouble(value);
return false;
}
protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(SkillType skill);
protected abstract void enable(SkillType skill);
protected abstract void disable(SkillType skill);
protected abstract void modify(CommandSender sender, double newPercentage);
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -8,18 +10,18 @@ import com.gmail.nossr50.util.Permissions;
public class VampirismCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions() {
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender);
}
@Override
protected boolean checkModifyPermissions() {
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender);
}
@Override
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
protected boolean checkEnabled(SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreVampirismEnabled()) {
return false;
@@ -29,35 +31,35 @@ public class VampirismCommand extends HardcoreModeCommand {
return true;
}
return SkillType.getSkill(skill).getHardcoreVampirismEnabled();
return skill.getHardcoreVampirismEnabled();
}
@Override
protected void enable(String skill) {
toggle(true);
protected void enable(SkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(String skill) {
toggle(false);
protected void disable(SkillType skill) {
toggle(false, skill);
}
@Override
protected void modify() {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
private void toggle(boolean enable, SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreVampirismEnabled(enable);
}
}
else {
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
skill.setHardcoreVampirismEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
}
}

View File

@@ -10,24 +10,22 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
public class PartyChangePasswordCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty();
Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
unprotectParty(sender);
unprotectParty(party, sender);
return true;
case 2:
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
unprotectParty(sender);
unprotectParty(party, sender);
return true;
}
protectParty(sender, args[1]);
protectParty(party, sender, args[1]);
return true;
default:
@@ -37,15 +35,15 @@ public class PartyChangePasswordCommand implements CommandExecutor {
}
}
private void unprotectParty(CommandSender sender) {
playerParty.setLocked(true);
playerParty.setPassword(null);
private void unprotectParty(Party party, CommandSender sender) {
party.setLocked(true);
party.setPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
}
private void protectParty(CommandSender sender, String password) {
playerParty.setLocked(true);
playerParty.setPassword(password);
private void protectParty(Party party, CommandSender sender, String password) {
party.setLocked(true);
party.setPassword(password);
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
}
}

View File

@@ -24,9 +24,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class PartyCommand implements TabExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
@@ -71,13 +68,13 @@ public class PartyCommand implements TabExecutor {
return true;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
return printUsage(player);
}
return partyInfoCommand.onCommand(sender, command, label, args);
@@ -86,7 +83,7 @@ public class PartyCommand implements TabExecutor {
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return printUsage();
return printUsage(player);
}
// Can't use this for lock/unlock since they're handled by the same command
@@ -111,7 +108,7 @@ public class PartyCommand implements TabExecutor {
// Party member commands
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
return printUsage(player);
}
switch (subcommand) {
@@ -211,7 +208,7 @@ public class PartyCommand implements TabExecutor {
}
}
private boolean printUsage() {
private boolean printUsage(Player player) {
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));

View File

@@ -14,8 +14,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyExpShareCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getExpShareEnabled()) {
@@ -25,13 +23,13 @@ public class PartyExpShareCommand implements CommandExecutor {
switch (args.length) {
case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty();
Party party = UserManager.getPlayer((Player) sender).getParty();
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(ShareMode.NONE);
handleChangingShareMode(party, ShareMode.NONE);
}
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(ShareMode.EQUAL);
handleChangingShareMode(party, ShareMode.EQUAL);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
@@ -45,12 +43,12 @@ public class PartyExpShareCommand implements CommandExecutor {
}
}
private void handleChangingShareMode(ShareMode mode) {
playerParty.setXpShareMode(mode);
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setXpShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) {
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}

View File

@@ -16,36 +16,33 @@ import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
public class PartyInfoCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
case 1:
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
displayPartyHeader();
displayShareModeInfo();
displayMemberInfo();
displayPartyHeader(player, party);
displayShareModeInfo(party, player);
displayMemberInfo(player, mcMMOPlayer, party);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
return true;
}
}
private String createMembersList() {
private String createMembersList(Party party) {
StringBuilder memberList = new StringBuilder();
for (String memberName : playerParty.getMembers()) {
for (String memberName : party.getMembers()) {
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (playerParty.getLeader().equalsIgnoreCase(memberName)) {
if (party.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD);
}
else if (member != null) {
@@ -61,10 +58,10 @@ public class PartyInfoCommand implements CommandExecutor {
return memberList.toString();
}
private void displayShareModeInfo() {
private void displayShareModeInfo(Party party, Player player) {
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE);
boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) {
return;
@@ -75,11 +72,11 @@ public class PartyInfoCommand implements CommandExecutor {
String separator = "";
if (xpShareEnabled) {
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString());
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
}
if (itemShareEnabled) {
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString());
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
}
if (xpShareEnabled && itemShareEnabled) {
@@ -87,28 +84,23 @@ public class PartyInfoCommand implements CommandExecutor {
}
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
if (itemSharingActive) {
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories()));
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
}
}
private void displayPartyHeader() {
private void displayPartyHeader(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
if (playerParty.isLocked()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked"))));
}
private void displayMemberInfo() {
private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1;
int membersOnline = party.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
player.sendMessage(createMembersList());
player.sendMessage(createMembersList(party));
}
}

View File

@@ -15,8 +15,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyItemShareCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getItemShareEnabled()) {
@@ -24,9 +22,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) {
case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty();
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
if (mode == null) {
@@ -34,11 +33,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true;
}
handleChangingShareMode(mode);
handleChangingShareMode(party, mode);
return true;
case 3:
playerParty = UserManager.getPlayer((Player) sender).getParty();
boolean toggle = false;
if (CommandUtils.shouldEnableToggle(args[2])) {
@@ -53,7 +51,7 @@ public class PartyItemShareCommand implements CommandExecutor {
}
try {
handleToggleItemShareCategory(ItemShareType.valueOf(args[1].toUpperCase()), toggle);
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
}
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
@@ -68,22 +66,22 @@ public class PartyItemShareCommand implements CommandExecutor {
}
}
private void handleChangingShareMode(ShareMode mode) {
playerParty.setItemShareMode(mode);
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setItemShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) {
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}
private void handleToggleItemShareCategory(ItemShareType type, boolean toggle) {
playerParty.setSharingDrops(type, toggle);
private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
party.setSharingDrops(type, toggle);
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : playerParty.getOnlineMembers()) {
for (Player member : party.getOnlineMembers()) {
member.sendMessage(toggleMessage);
}
}

View File

@@ -14,25 +14,33 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyJoinCommand implements CommandExecutor {
private McMMOPlayer mcMMOTarget;
private Player target;
private Party targetParty;
private McMMOPlayer mcMMOPlayer;
private Player player;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
case 3:
// Verify target exists and is in a different party than the player
if (!canJoinParty(sender, args[1])) {
String targetName = Misc.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
}
mcMMOPlayer = UserManager.getPlayer((Player) sender);
player = mcMMOPlayer.getPlayer();
Player target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return true;
}
String password = getPassword(args);
@@ -65,31 +73,4 @@ public class PartyJoinCommand implements CommandExecutor {
return null;
}
private boolean canJoinParty(CommandSender sender, String targetName) {
targetName = Misc.getMatchedPlayerName(targetName);
mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return false;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}
return true;
}
}

View File

@@ -12,19 +12,15 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyLockCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("lock")) {
lockParty(sender, command.getPermissionMessage());
togglePartyLock(sender, true);
}
else if (args[0].equalsIgnoreCase("unlock")) {
unlockParty(sender, command.getPermissionMessage());
togglePartyLock(sender, false);
}
return true;
@@ -36,10 +32,10 @@ public class PartyLockCommand implements CommandExecutor {
}
if (CommandUtils.shouldEnableToggle(args[1])) {
lockParty(sender, command.getPermissionMessage());
togglePartyLock(sender, true);
}
else if (CommandUtils.shouldDisableToggle(args[1])) {
unlockParty(sender, command.getPermissionMessage());
togglePartyLock(sender, false);
}
else {
sendUsageStrings(sender);
@@ -53,44 +49,25 @@ public class PartyLockCommand implements CommandExecutor {
}
}
/**
* Handle locking a party.
*/
private void lockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsLocked"));
return;
}
playerParty.setLocked(true);
sender.sendMessage(LocaleLoader.getString("Party.Locked"));
}
/**
* Handle unlocking a party.
*/
private void unlockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (!playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
return;
}
playerParty.setLocked(false);
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
}
private void togglePartyLock(CommandSender sender, boolean lock) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
if (lock ? party.isLocked() : !party.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return;
}
party.setLocked(lock);
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
}
}

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
if (mcMMOPlayer.getPtpConfirmRequired()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
}
mcMMOPlayer.togglePtpConfirmRequired();
ptpRecord.toggleConfirmRequired();
return true;
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -22,21 +22,21 @@ public class PtpAcceptCommand implements CommandExecutor {
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
if (!mcMMOPlayer.hasPtpRequest()) {
if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
return true;
}
if ((mcMMOPlayer.getPtpTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
mcMMOPlayer.removePtpRequest();
if ((ptpRecord.getTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true;
}
Player target = mcMMOPlayer.getPtpRequest();
mcMMOPlayer.removePtpRequest();
Player target = ptpRecord.getRequestor();
ptpRecord.removeRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
return true;

View File

@@ -13,6 +13,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -27,9 +28,6 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public class PtpCommand implements TabExecutor {
private static Player target;
private static McMMOPlayer mcMMOTarget;
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
@@ -77,7 +75,7 @@ public class PtpCommand implements TabExecutor {
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPtpLastUse();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
@@ -118,13 +116,18 @@ public class PtpCommand implements TabExecutor {
return;
}
if (!mcMMOTarget.getPtpConfirmRequired()) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();
if (!ptpRecord.isConfirmRequired()) {
handleTeleportWarmup(player, target);
return;
}
mcMMOTarget.setPtpRequest(player);
mcMMOTarget.actualizePtpTimeout();
ptpRecord.setRequestor(player);
ptpRecord.actualizeTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
@@ -133,13 +136,13 @@ public class PtpCommand implements TabExecutor {
}
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
target = mcMMOTarget.getPlayer();
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
@@ -151,7 +154,7 @@ public class PtpCommand implements TabExecutor {
return false;
}
if (!mcMMOTarget.getPtpEnabled()) {
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
@@ -166,7 +169,7 @@ public class PtpCommand implements TabExecutor {
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
mcMMOTarget = UserManager.getPlayer(targetPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpToggleCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
if (mcMMOPlayer.getPtpEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
}
mcMMOPlayer.togglePtpUse();
ptpRecord.toggleEnabled();
return true;
}
}

View File

@@ -29,10 +29,6 @@ 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);
@@ -44,9 +40,12 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
return true;
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
@@ -80,9 +79,12 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
return true;
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));

View File

@@ -0,0 +1,70 @@
package com.gmail.nossr50.commands.player;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class MccooldownCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (Config.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) {
return true;
}
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
if (!ability.getPermissions(player)) {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
}
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -13,12 +13,12 @@ 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;
@@ -36,13 +36,7 @@ public class McrankCommand implements TabExecutor {
return true;
}
if (Config.getInstance().getMcrankScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
}
else {
display(sender, sender.getName());
}
display(sender, sender.getName());
return true;
@@ -56,9 +50,10 @@ public class McrankCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName();
Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) {
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true;
}
}
@@ -66,13 +61,7 @@ public class McrankCommand implements TabExecutor {
return true;
}
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
}
else {
display(sender, playerName);
}
display(sender, playerName);
return true;
default:
@@ -92,6 +81,20 @@ public class McrankCommand implements TabExecutor {
}
private void display(CommandSender sender, String playerName) {
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}
}

View File

@@ -8,7 +8,6 @@ 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;
@@ -26,28 +25,29 @@ public class McstatsCommand implements TabExecutor {
switch (args.length) {
case 0:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
ScoreboardManager.setupPlayerScoreboard(player.getName());
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
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));
}
else {
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()));
}
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
return true;

View File

@@ -11,36 +11,41 @@ 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.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.player.UserManager;
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 = null;
switch (args.length) {
case 0:
display(1, "ALL", sender, command);
display(1, skill, sender, command);
return true;
case 1:
if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
return true;
}
if (!extractSkill(sender, args[0])) {
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(1, skill.toString(), sender, command);
display(1, skill, sender, command);
return true;
case 2:
@@ -48,11 +53,13 @@ public class MctopCommand implements TabExecutor {
return true;
}
if (!extractSkill(sender, args[0])) {
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command);
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
return true;
default:
@@ -70,35 +77,44 @@ public class MctopCommand implements TabExecutor {
}
}
private void display(int page, String skill, CommandSender sender, Command command) {
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
private void display(int page, SkillType skill, CommandSender sender, Command command) {
if (skill != null && !Permissions.mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
}
else {
display(page, skill, sender);
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}
mcMMOPlayer.actualizeDatabaseATS();
}
display(page, skill, sender);
}
private void display(int page, String query, CommandSender sender) {
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
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 boolean extractSkill(CommandSender sender, String skillName) {
private SkillType extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) {
return false;
return null;
}
skill = SkillType.getSkill(skillName);
SkillType skill = SkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) {
return false;
return null;
}
return true;
return skill;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
@@ -22,75 +27,71 @@ public class AcrobaticsCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// DODGE
if (canDodge) {
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance);
String[] dodgeStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance, isLucky);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
}
// ROLL
if (canRoll) {
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance);
String[] rollStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance, isLucky);
rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1];
}
// GRACEFUL ROLL
if (canGracefulRoll) {
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance);
String[] gracefulRollStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance, isLucky);
gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canDodge = Permissions.dodge(player);
canRoll = Permissions.roll(player);
canGracefulRoll = Permissions.gracefulRoll(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
messages.add(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
messages.add(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
messages.add(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery;
@@ -21,7 +26,7 @@ public class ArcheryCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SKILL SHOT
if (canSkillShot) {
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
@@ -30,65 +35,61 @@ public class ArcheryCommand extends SkillCommand {
// DAZE
if (canDaze) {
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
String[] dazeStrings = calculateAbilityDisplayValues(skillValue, Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus, isLucky);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
}
// RETRIEVE
if (canRetrieve) {
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
String[] retrieveStrings = calculateAbilityDisplayValues(skillValue, Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance, isLucky);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canSkillShot = Permissions.bonusDamage(player, skill);
canDaze = Permissions.daze(player);
canRetrieve = Permissions.arrowRetrieval(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
messages.add(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
messages.add(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
messages.add(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
@@ -24,7 +29,7 @@ public class AxesCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// IMPACT
if (canImpact) {
impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel);
@@ -32,14 +37,14 @@ public class AxesCommand extends SkillCommand {
// SKULL SPLITTER
if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues();
String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1];
}
// CRITICAL STRIKES
if (canCritical) {
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
String[] criticalStrikeStrings = calculateAbilityDisplayValues(skillValue, Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance, isLucky);
critChance = criticalStrikeStrings[0];
critChanceLucky = criticalStrikeStrings[1];
}
@@ -51,7 +56,7 @@ public class AxesCommand extends SkillCommand {
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalStrikes(player);
canBonusDamage = Permissions.bonusDamage(player, skill);
@@ -60,60 +65,56 @@ public class AxesCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
messages.add(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
}
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -16,48 +21,44 @@ public class ExcavationCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GIGA DRILL BREAKER
if (canGigaDrill) {
String gigaDrillStrings[] = calculateLengthDisplayValues();
String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasureHunter(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
return messages;
}
}

View File

@@ -1,7 +1,12 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
@@ -10,6 +15,7 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -42,48 +48,57 @@ public class FishingCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
boolean isStorming = player.getWorld().hasStorm();
// TREASURE HUNTER
if (canTreasureHunt) {
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
lootTier = fishingManager.getLootTier();
// Item drop rates
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
trapTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP) / 100.0);
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
// Magic hunter drop rates
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
double totalEnchantChance = 0;
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
}
magicChance = percent.format(totalEnchantChance / 100.0);
}
// SHAKE
if (canShake) {
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability());
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability(), isLucky);
shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1];
}
// FISHERMAN'S DIET
if (canFishermansDiet) {
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
fishermansDietRank = calculateRank(skillValue, Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
}
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
Biome biome = player.getLocation().getBlock().getBiome();
Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
Biome biome = location.getBlock().getBiome();
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
@@ -93,12 +108,12 @@ public class FishingCommand extends SkillCommand {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
}
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0, isLucky)[0];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canTreasureHunt = Permissions.fishingTreasureHunter(player);
canMagicHunt = Permissions.magicHunter(player);
canShake = Permissions.shake(player);
@@ -108,63 +123,57 @@ public class FishingCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
}
if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
messages.add(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
messages.add(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
messages.add(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
}
if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
messages.add(LocaleLoader.getString("Fishing.Ability.IceFishing"));
}
}
@@ -172,10 +181,10 @@ public class FishingCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
messages.add(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
}
@@ -183,15 +192,17 @@ public class FishingCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
messages.add(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
messages.add(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
return messages;
}
}

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -34,52 +38,52 @@ public class HerbalismCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GREEN TERRA
if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues();
String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1];
}
// FARMERS DIET
if (canFarmersDiet) {
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
farmersDietRank = calculateRank(skillValue, Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
}
// GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
greenThumbStage = calculateRank(skillValue, Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
String[] greenThumbStrings = calculateAbilityDisplayValues(skillValue, Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance, isLucky);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// HYLIAN LUCK
if (hasHylianLuck) {
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
String[] hylianLuckStrings = calculateAbilityDisplayValues(skillValue, Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance, isLucky);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
}
// SHROOM THUMB
if (canShroomThumb) {
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
String[] shroomThumbStrings = calculateAbilityDisplayValues(skillValue, Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance, isLucky);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
hasHylianLuck = Permissions.hylianLuck(player);
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
@@ -90,76 +94,72 @@ public class HerbalismCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
}
if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
}
if (canGreenThumbBlocks) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
}
if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
}
if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
}
if (canGreenThumbBlocks || canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
}
if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
messages.add(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
}
if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
messages.add(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
}
if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
messages.add(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
messages.add(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -7,6 +12,7 @@ import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
@@ -32,24 +38,24 @@ public class MiningCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SUPER BREAKER
if (canSuperBreaker) {
String[] superBreakerStrings = calculateLengthDisplayValues();
String[] superBreakerStrings = calculateLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1];
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance);
String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();
@@ -61,7 +67,7 @@ public class MiningCommand extends SkillCommand {
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canBiggerBombs = Permissions.biggerBombs(player);
canBlast = Permissions.remoteDetonation(player);
canDemoExpert = Permissions.demolitionsExpertise(player);
@@ -70,58 +76,52 @@ public class MiningCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
}
if (canBlast) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
}
if (canBiggerBombs) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
}
if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
}
if (canBlast) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
}
@@ -129,10 +129,10 @@ public class MiningCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
messages.add(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
}
}
@@ -140,11 +140,13 @@ public class MiningCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
}
}
return messages;
}
}

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -11,6 +15,7 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class RepairCommand extends SkillCommand {
private String repairMasteryBonus;
@@ -40,7 +45,7 @@ public class RepairCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
@@ -60,14 +65,14 @@ public class RepairCommand extends SkillCommand {
// SUPER REPAIR
if (canSuperRepair) {
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance);
String[] superRepairStrings = calculateAbilityDisplayValues(skillValue, Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance, isLucky);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canSuperRepair = Permissions.superRepair(player);
canMasterRepair = Permissions.repairMastery(player);
canArcaneForge = Permissions.arcaneForging(player);
@@ -83,78 +88,76 @@ public class RepairCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
}
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
if (canRepairLeather || canRepairString || canRepairWood || canRepairStone || canRepairIron || canRepairGold || canRepairDiamond) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
}
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
}
/* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
}
if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
}
if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
}
if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
}
if (canSalvage && Repair.salvageUnlockLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canArcaneForge || canMasterRepair || canSuperRepair;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
messages.add(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
messages.add(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
}
if (canArcaneForge) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
messages.add(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
if (ArcaneForging.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
}
if (ArcaneForging.arcaneForgingDowngrades) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
}
}
return messages;
}
}

View File

@@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
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.skills.child.FamilyTree;
@@ -28,15 +27,7 @@ import com.google.common.collect.ImmutableList;
public abstract class SkillCommand implements TabExecutor {
protected SkillType skill;
protected String skillName;
protected Player player;
protected PlayerProfile profile;
protected McMMOPlayer mcMMOPlayer;
protected float skillValue;
protected boolean isLucky;
protected boolean hasEndurance;
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
@@ -45,7 +36,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) {
this.skill = skill;
skillName = skill.getSkillName();
skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill);
}
@@ -55,31 +46,26 @@ public abstract class SkillCommand implements TabExecutor {
return true;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
switch (args.length) {
case 0:
profile = mcMMOPlayer.getProfile();
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
skillValue = profile.getSkillLevel(skill);
isLucky = Permissions.lucky(sender, skill);
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
float skillValue = mcMMOPlayer.getSkillLevel(skill);
permissionsCheck();
dataCalculations();
permissionsCheck(player);
dataCalculations(player, skillValue, isLucky);
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()))));
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)));
}
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
@@ -90,21 +76,34 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) {
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
}
}
if (effectsHeaderPermissions()) {
List<String> effectMessages = effectsDisplay();
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
for (String message : effectMessages) {
player.sendMessage(message);
}
}
effectsDisplay();
List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (statsHeaderPermissions()) {
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
}
statsDisplay();
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
return true;
@@ -124,11 +123,11 @@ public abstract class SkillCommand implements TabExecutor {
}
}
protected int calculateRank(int maxLevel, int rankChangeLevel) {
protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
}
protected String[] calculateAbilityDisplayValues(double chance) {
protected String[] calculateAbilityDisplayValues(double chance, boolean isLucky) {
String[] displayValues = new String[2];
displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D);
@@ -137,11 +136,11 @@ public abstract class SkillCommand implements TabExecutor {
return displayValues;
}
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) {
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel));
protected String[] calculateAbilityDisplayValues(float skillValue, int maxBonusLevel, double maxChance, boolean isLucky) {
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
}
protected String[] calculateLengthDisplayValues() {
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
@@ -150,25 +149,14 @@ 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() {
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
}
protected abstract void dataCalculations(Player player, float skillValue, boolean isLucky);
protected abstract void dataCalculations();
protected abstract void permissionsCheck(Player player);
protected abstract void permissionsCheck();
protected abstract List<String> effectsDisplay();
protected abstract boolean effectsHeaderPermissions();
protected abstract void effectsDisplay();
protected abstract boolean statsHeaderPermissions();
protected abstract void statsDisplay();
protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
}

View File

@@ -15,13 +15,11 @@ public class SkillGuideCommand implements CommandExecutor {
private String header;
private ArrayList<String> guide;
private String invalidPage;
private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(SkillType skillType) {
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
guide = getGuide(skillType);
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(SkillType skill) {
header = LocaleLoader.getString("Guides.Header", skill.getName());
guide = getGuide(skill);
}
@Override
@@ -68,8 +66,8 @@ public class SkillGuideCommand implements CommandExecutor {
}
}
private ArrayList<String> grabPageContents(int pagenum) {
int pageIndexStart = 8 * (pagenum - 1); // Determine what string to start at
private ArrayList<String> grabPageContents(int page) {
int pageIndexStart = 8 * (page - 1); // Determine what string to start at
ArrayList<String> allStrings = new ArrayList<String>();
allStrings.add(header);
@@ -84,15 +82,15 @@ public class SkillGuideCommand implements CommandExecutor {
}
}
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
allStrings.add("Page " + page + " of " + getTotalPageNumber());
return allStrings;
}
private ArrayList<String> getGuide(SkillType skillType) {
private ArrayList<String> getGuide(SkillType skill) {
ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n");
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;

View File

@@ -1,11 +1,17 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier;
@@ -24,7 +30,7 @@ public class SmeltingCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
@@ -32,21 +38,21 @@ public class SmeltingCommand extends SkillCommand {
// SECOND SMELT
if (canSecondSmelt) {
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
String[] secondSmeltStrings = calculateAbilityDisplayValues(skillValue, Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance, isLucky);
secondSmeltChance = secondSmeltStrings[0];
secondSmeltChanceLucky = secondSmeltStrings[1];
}
// FLUX MINING
if (canFluxMine) {
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance, isLucky);
fluxMiningChance = fluxMiningStrings[0];
fluxMiningChanceLucky = fluxMiningStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canFuelEfficiency = Permissions.fuelEfficiency(player);
canSecondSmelt = Permissions.doubleDrops(player, skill);
canFluxMine = Permissions.fluxMining(player);
@@ -54,64 +60,60 @@ public class SmeltingCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
}
if (canVanillaXPBoost) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
}
if (canFluxMine) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
messages.add(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
messages.add(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
}
if (canVanillaXPBoost) {
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", mcMMOPlayer.getSmeltingManager().getVanillaXpMultiplier()));
messages.add(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier()));
}
}
if (canFluxMine) {
if (skillValue < Smelting.fluxMiningUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
messages.add(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
}
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.swords.Swords;
@@ -23,10 +28,10 @@ public class SwordsCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SERRATED STRIKES
if (canSerratedStrike) {
String[] serratedStrikesStrings = calculateLengthDisplayValues();
String[] serratedStrikesStrings = calculateLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
}
@@ -35,68 +40,64 @@ public class SwordsCommand extends SkillCommand {
if (canBleed) {
bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks;
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance);
String[] bleedStrings = calculateAbilityDisplayValues(skillValue, Swords.bleedMaxBonusLevel, Swords.bleedMaxChance, isLucky);
bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1];
}
// COUNTER ATTACK
if (canCounter) {
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
String[] counterAttackStrings = calculateAbilityDisplayValues(skillValue, Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance, isLucky);
counterAttackChance = counterAttackStrings[0];
counterAttackChanceLucky = counterAttackStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canBleed = Permissions.bleed(player);
canCounter = Permissions.counterAttack(player);
canSerratedStrike = Permissions.serratedStrikes(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
messages.add(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
return messages;
}
}

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -27,16 +31,16 @@ public class TamingCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
if (canGore) {
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance);
String[] goreStrings = calculateAbilityDisplayValues(skillValue, Taming.goreMaxBonusLevel, Taming.goreMaxChance, isLucky);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
@@ -49,117 +53,113 @@ public class TamingCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
}
if (canSharpenedClaws) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
}
if (canEnvironmentallyAware) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
}
if (canThickFur) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
}
if (canShockProof) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
}
if (canFastFood) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
}
if (canHolyHound) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
}
if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canFastFood) {
if (skillValue < Taming.fastFoodServiceUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
}
}
if (canEnvironmentallyAware) {
if (skillValue < Taming.environmentallyAwareUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
}
}
if (canThickFur) {
if (skillValue < Taming.thickFurUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
}
}
if (canHolyHound) {
if (skillValue < Taming.holyHoundUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
}
}
if (canShockProof) {
if (skillValue < Taming.shockProofUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
}
}
if (canSharpenedClaws) {
if (skillValue < Taming.sharpenedClawsUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
}
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
messages.add(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.unarmed.Unarmed;
@@ -27,24 +32,24 @@ public class UnarmedCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// BERSERK
if (canBerserk) {
String[] berserkStrings = calculateLengthDisplayValues();
String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
}
// DISARM
if (canDisarm) {
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
String[] disarmStrings = calculateAbilityDisplayValues(skillValue, Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance, isLucky);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
}
// DEFLECT
if (canDeflect) {
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
String[] deflectStrings = calculateAbilityDisplayValues(skillValue, Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance, isLucky);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
}
@@ -56,14 +61,14 @@ public class UnarmedCommand extends SkillCommand {
// IRON GRIP
if (canIronGrip) {
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
String[] ironGripStrings = calculateAbilityDisplayValues(skillValue, Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance, isLucky);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.bonusDamage(player, skill);
canDeflect = Permissions.arrowDeflect(player);
@@ -72,60 +77,56 @@ public class UnarmedCommand extends SkillCommand {
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
}
return messages;
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -21,75 +26,71 @@ public class WoodcuttingCommand extends SkillCommand {
}
@Override
protected void dataCalculations() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// TREE FELLER
if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues();
String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1];
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
}
@Override
protected void permissionsCheck() {
protected void permissionsCheck(Player player) {
canTreeFell = Permissions.treeFeller(player);
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
canLeafBlow = Permissions.leafBlower(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDoubleDrop || canLeafBlow || canTreeFell;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
}
if (canLeafBlow) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
}
return messages;
}
@Override
protected boolean statsHeaderPermissions() {
return canDoubleDrop || canLeafBlow || canTreeFell;
}
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
@Override
protected void statsDisplay() {
if (canLeafBlow) {
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
if (skillValue < leafBlowerUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
}
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
messages.add(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
messages.add(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
}
return messages;
}
}

View File

@@ -526,6 +526,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
}
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
}
/* UNARMED */
if (getDisarmChanceMax() < 1) {
@@ -764,6 +767,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
/* UNARMED */
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm.ChanceMax", 33.0D); }
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm.MaxBonusLevel", 1000); }
@@ -786,15 +791,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); }
}

View File

@@ -45,24 +45,44 @@ public class Config extends AutoUpdateConfigLoader {
}
/* Scoreboards */
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Rank.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 (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Stats.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 (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
}
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
reason.add("Scoreboards.Inspect.Display_Time should be greater than 0 or -1!");
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (!(getRankUseChat() || getRankUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
}
if (!(getTopUseChat() || getTopUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
}
if (!(getStatsUseChat() || getStatsUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
}
if (!(getInspectUseChat() || getInspectUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
}
/* Database Purging */
@@ -185,8 +205,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
@@ -199,6 +217,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
try {
@@ -212,27 +232,46 @@ public class Config extends AutoUpdateConfigLoader {
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
/* Scoreboards */
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
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 getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.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 getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.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 getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.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 getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.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 getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", 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); }
/* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
/* Backups */
public boolean getBackupsEnabled() { return config.getBoolean("Backups.Enabled", true); }
public boolean getKeepLast24Hours() { return config.getBoolean("Backups.Keep.Last_24_Hours", true); }
public boolean getKeepDailyLastWeek() { return config.getBoolean("Backups.Keep.Daily_Last_Week", true); }
public boolean getKeepWeeklyPastMonth() { return config.getBoolean("Backups.Keep.Weekly_Past_Months", true); }
/* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
@@ -270,7 +309,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.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_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); }
@@ -283,6 +322,7 @@ public class Config extends AutoUpdateConfigLoader {
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
public boolean getChimaeraSoundEnabled() { return config.getBoolean("Items.Chimaera_Wing.Sound_Enabled", true); }
/* Particles */
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
@@ -366,8 +406,10 @@ public class Config extends AutoUpdateConfigLoader {
/* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_ID", "GOLD_BLOCK")); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_Material", "GOLD_BLOCK")); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
@@ -387,10 +429,12 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
/* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
public boolean getAcrobaticsPreventAFK() { 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 getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Level Caps */
public int getPowerLevelCap() {

View File

@@ -29,7 +29,13 @@ public abstract class ConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
plugin.debug("Creating mcMMO " + fileName + " File...");
plugin.saveResource(configFile.getPath(), false);
try {
plugin.saveResource(fileName, false); // Normal files
}
catch (IllegalArgumentException ex) {
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
}
else {
plugin.debug("Loading mcMMO " + fileName + " File...");

View File

@@ -102,6 +102,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience.Fishing.Base should be greater than 0!");
}
if (getFishingShakeXP() <= 0) {
reason.add("Experience.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience.Repair.Base should be greater than 0!");
@@ -197,6 +201,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }

View File

@@ -52,12 +52,10 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
while (!needsUpdate) {
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
}
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
if (needsUpdate) {
needsUpdate = false;
@@ -66,6 +64,10 @@ public class CustomArmorConfig extends ConfigLoader {
}
private void loadArmor(String armorType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
if (armorSection == null) {
@@ -83,7 +85,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.");
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
continue;
}
@@ -91,7 +93,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.");
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
repairable = false;
}
@@ -109,7 +111,7 @@ public class CustomArmorConfig extends ConfigLoader {
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
}
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
}
materialList.add(armorMaterial);

View File

@@ -43,13 +43,11 @@ public class CustomBlockConfig extends ConfigLoader {
@Override
protected void loadKeys() {
while (!needsUpdate) {
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
if (needsUpdate) {
needsUpdate = false;
@@ -58,6 +56,10 @@ public class CustomBlockConfig extends ConfigLoader {
}
private void loadBlocks(String skillType, List<MaterialData> blockList) {
if (needsUpdate) {
return;
}
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
if (skillSection == null) {
@@ -90,9 +92,11 @@ public class CustomBlockConfig extends ConfigLoader {
}
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
int smeltingXp = 0;
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
@@ -104,7 +108,7 @@ public class CustomBlockConfig extends ConfigLoader {
}
}
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
}
}

View File

@@ -58,14 +58,12 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
while (!needsUpdate) {
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
}
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
if (needsUpdate) {
needsUpdate = false;
@@ -74,6 +72,10 @@ public class CustomToolConfig extends ConfigLoader {
}
private void loadTool(String toolType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) {

View File

@@ -68,6 +68,7 @@ public class TreasureConfig extends ConfigLoader {
private TreasureConfig() {
super("treasures.yml");
loadKeys();
validate();
}
public static TreasureConfig getInstance() {
@@ -78,6 +79,43 @@ public class TreasureConfig extends ConfigLoader {
return instance;
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
double totalEnchantDropRate = 0;
double totalItemDropRate = 0;
for (Rarity rarity : Rarity.values()) {
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
totalEnchantDropRate += enchantDropRate;
totalItemDropRate += itemDropRate;
}
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
}
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
}
}
return noErrorsInConfig(reason);
}
@Override
protected void loadKeys() {
if (config.getConfigurationSection("Treasures") != null) {

View File

@@ -7,10 +7,13 @@ 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.
@@ -26,7 +29,6 @@ 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);
@@ -35,30 +37,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(String skillName, 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(SkillType skill, int pageNumber, int statsPerPage);
/**
* Retrieve rank info.
* 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).
*
* @param playerName The name of the user to retrieve the rankings for
*
* @return the requested rank information
*/
public Map<String, Integer> readRank(String playerName);
public Map<SkillType, Integer> readRank(String playerName);
/**
* Add a new user to the database.
@@ -71,11 +73,10 @@ 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);

View File

@@ -251,17 +251,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append(":");
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BERSERK)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.TREE_FELLER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GREEN_TERRA)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.BERSERK)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.TREE_FELLER)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.GREEN_TERRA)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.SUPER_BREAKER)).append(":");
writer.append(":");
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
writer.append((int) profile.getAbilityDATS(AbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
@@ -285,24 +285,24 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
updateLeaderboards();
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName));
List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
}
public Map<String, Integer> readRank(String playerName) {
public Map<SkillType, Integer> readRank(String playerName) {
updateLeaderboards();
Map<String, Integer> skills = new HashMap<String, Integer>();
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
}
skills.put("ALL", getPlayerRank(playerName, powerLevels));
skills.put(null, getPlayerRank(playerName, powerLevels));
return skills;
}
@@ -400,7 +400,16 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
e.printStackTrace();
}
finally {
tryClose(in);
// 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();
}
}
}
}
@@ -411,6 +420,8 @@ 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 {
@@ -427,6 +438,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
catch (Exception e) {
e.printStackTrace();
}
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
}
}
catch (Exception e) {

View File

@@ -139,14 +139,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ ", herbalism = ?, excavation = ?, swords = ?"
+ ", axes = ?, blast_mining = ? WHERE user_id = ?",
userId,
profile.getSkillDATS(AbilityType.SUPER_BREAKER),
profile.getSkillDATS(AbilityType.TREE_FELLER),
profile.getSkillDATS(AbilityType.BERSERK),
profile.getSkillDATS(AbilityType.GREEN_TERRA),
profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER),
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
profile.getSkillDATS(AbilityType.BLAST_MINING));
profile.getAbilityDATS(AbilityType.SUPER_BREAKER),
profile.getAbilityDATS(AbilityType.TREE_FELLER),
profile.getAbilityDATS(AbilityType.BERSERK),
profile.getAbilityDATS(AbilityType.GREEN_TERRA),
profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER),
profile.getAbilityDATS(AbilityType.SERRATED_STRIKES),
profile.getAbilityDATS(AbilityType.SKULL_SPLITTER),
profile.getAbilityDATS(AbilityType.BLAST_MINING));
success &= saveIntegers(
"UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
@@ -188,11 +188,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
return success;
}
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
List<PlayerStat> stats = new ArrayList<PlayerStat>();
if (checkConnected()) {
String query = skillName.equalsIgnoreCase("ALL") ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skillName;
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
ResultSet resultSet = null;
PreparedStatement statement = null;
@@ -230,8 +230,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
return stats;
}
public Map<String, Integer> readRank(String playerName) {
Map<String, Integer> skills = new HashMap<String, Integer>();
public Map<SkillType, Integer> readRank(String playerName) {
Map<SkillType, Integer> skills = new HashMap<SkillType, 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.name(), rank + resultSet.getRow());
skills.put(skillType, 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("ALL", rank + resultSet.getRow());
skills.put(null, rank + resultSet.getRow());
break;
}
}
@@ -447,6 +447,8 @@ 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 {
@@ -458,6 +460,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
catch (SQLException e) {
// Ignore
}
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
}
}
catch (SQLException e) {
@@ -477,20 +481,20 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
/**
* 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
*/
* 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
*/
public boolean checkConnected() {
boolean isClosed = true;
boolean isValid = false;
@@ -846,7 +850,6 @@ 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) {
@@ -882,7 +885,6 @@ 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) {
@@ -917,7 +919,6 @@ 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) {
@@ -963,7 +964,6 @@ 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,7 +1107,6 @@ 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) {

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.chat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
public enum ChatMode {
@@ -15,51 +14,6 @@ public enum ChatMode {
this.disabledMessage = disabledMessage;
}
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
return mcMMOPlayer.getAdminChatMode();
case PARTY:
return mcMMOPlayer.getPartyChatMode();
default:
return false;
}
}
public void disable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(false);
return;
default:
return;
}
}
public void enable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(true);
mcMMOPlayer.setPartyChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(true);
mcMMOPlayer.setAdminChat(false);
return;
default:
return;
}
}
public String getEnabledMessage() {
return enabledMessage;
}

View File

@@ -7,5 +7,6 @@ public enum DatabaseUpdateType {
MOB_HEALTHBARS,
PARTY_NAMES,
KILL_ORPHANS,
DROPPED_SPOUT;
DROPPED_SPOUT
;
}

View File

@@ -3,10 +3,12 @@ package com.gmail.nossr50.datatypes.mods;
public class CustomBlock {
private int xpGain;
private boolean canDoubleDrop;
private int smeltingXpGain;
public CustomBlock(int xpGain, boolean canDoubleDrop) {
public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) {
this.xpGain = xpGain;
this.canDoubleDrop = canDoubleDrop;
this.smeltingXpGain = smeltingXpGain;
}
public int getXpGain() {
@@ -16,4 +18,8 @@ public class CustomBlock {
public boolean isDoubleDropEnabled() {
return canDoubleDrop;
}
public int getSmeltingXpGain() {
return smeltingXpGain;
}
}

View File

@@ -0,0 +1,68 @@
package com.gmail.nossr50.datatypes.party;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Misc;
public class PartyTeleportRecord {
private Player requestor;
private boolean enabled, confirmRequired;
private int timeout, lastUse;
public PartyTeleportRecord() {
requestor = null;
enabled = true;
confirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
timeout = 0;
lastUse = 0;
}
public boolean isEnabled() {
return enabled;
}
public void toggleEnabled() {
enabled = !enabled;
}
public Player getRequestor() {
return requestor;
}
public void setRequestor(Player requestor) {
this.requestor = requestor;
}
public boolean hasRequest() {
return (requestor != null);
}
public void removeRequest() {
requestor = null;
}
public boolean isConfirmRequired() {
return confirmRequired;
}
public void toggleConfirmRequired() {
confirmRequired = !confirmRequired;
}
public int getLastUse() {
return lastUse;
}
public void actualizeLastUse() {
lastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public int getTimeout() {
return timeout;
}
public void actualizeTimeout() {
timeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}

View File

@@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -17,8 +16,10 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
@@ -36,7 +37,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager;
@@ -52,38 +52,25 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.apache.commons.lang.Validate;
public class McMMOPlayer {
private Player player;
private PlayerProfile profile;
/*
* Since SkillManager isn't a "polymorphic type" we may prefer to have one field for each of our
* class inheriting from SkillManager. This would also prevent the need for casting.
* However, by using the map and the loop in the constructor
* we make sure that all class inheriting from SkillManager are instanced.
* Which solution is better, I let you decide. - bm01
*/
private final Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
private Party party;
private Party invite;
private int itemShareModifier;
private Player ptpRequest;
private boolean ptpEnabled = true;
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
private long ptpTimeout;
private int ptpLastUse;
private PartyTeleportRecord ptpRecord;
private boolean partyChatMode;
private boolean adminChatMode;
private boolean displaySkillNotifications = true;
private boolean abilityUse = true;
private boolean placedRepairAnvil;
private int lastRepairClick;
private boolean placedSalvageAnvil;
private int lastSalvageClick;
private boolean godMode;
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
@@ -95,6 +82,7 @@ public class McMMOPlayer {
private int recentlyHurt;
private int respawnATS;
private int teleportATS;
private long databaseATS;
private int chimeraWingLastUse;
private Location teleportCommence;
@@ -106,6 +94,7 @@ public class McMMOPlayer {
this.player = player;
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
party = PartyManager.getPlayerParty(playerName);
ptpRecord = new PartyTeleportRecord();
/*
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
@@ -266,7 +255,6 @@ 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) {
@@ -276,7 +264,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) {
@@ -287,7 +275,6 @@ 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) {
@@ -297,7 +284,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) {
@@ -308,7 +295,6 @@ 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 +325,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,7 +336,6 @@ 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) {
@@ -361,7 +346,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);
@@ -429,66 +414,12 @@ public class McMMOPlayer {
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
/*
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
public long getDatabaseATS() {
return databaseATS;
}
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
/*
* Repair Anvil Usage
*/
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public void actualizeDatabaseATS() {
databaseATS = System.currentTimeMillis();
}
/*
@@ -524,8 +455,8 @@ public class McMMOPlayer {
int powerLevel = 0;
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
if (type.getPermissions(player)) {
powerLevel += getSkillLevel(type);
}
}
@@ -535,20 +466,23 @@ 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 skill Skill being used
* @param xp Experience amount to process
*/
public void beginXpGain(SkillType skillType, float xp) {
if (xp == 0) {
public void beginXpGain(SkillType skill, float xp) {
Validate.isTrue(xp >= 0.0, "XP gained should be greater than or equal to zero.");
if (xp <= 0.0) {
return;
}
if (skillType.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
float splitXp = xp / parentSkills.size();
for (SkillType parentSkill : parentSkills) {
if (Permissions.skillEnabled(player, parentSkill)) {
beginXpGain(parentSkill, xp / parentSkills.size());
if (parentSkill.getPermissions(player)) {
beginXpGain(parentSkill, splitXp);
}
}
@@ -556,33 +490,31 @@ public class McMMOPlayer {
}
// Return if the experience has been shared
if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) {
if (party != null && ShareHandler.handleXpShare(xp, this, skill)) {
return;
}
beginUnsharedXpGain(skillType, xp);
beginUnsharedXpGain(skill, xp);
}
/**
* 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 skill Skill being used
* @param xp Experience amount to process
*/
public void beginUnsharedXpGain(SkillType skillType, float xp) {
xp = modifyXpGain(skillType, xp);
applyXpGain(skillType, xp);
public void beginUnsharedXpGain(SkillType skill, float xp) {
applyXpGain(skill, modifyXpGain(skill, xp));
}
/**
* 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)) {
if (!skillType.getPermissions(player)) {
return;
}
@@ -596,7 +528,7 @@ public class McMMOPlayer {
return;
}
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
if (!EventUtils.handleXpChangeEvent(player, skillType, xp, true)) {
return;
}
@@ -610,31 +542,32 @@ public class McMMOPlayer {
* @param skillType The skill to check
*/
private void checkXp(SkillType skillType) {
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
return;
}
int levelsGained = 0;
float xpRemoved = 0;
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) {
int xp = profile.getXpToLevel(skillType);
xpRemoved += xp;
profile.removeXp(skillType, xp);
levelsGained++;
profile.skillUp(skillType, 1);
}
else {
profile.addLevels(skillType, 0); // This seems kinda pointless... why do we have this again?
}
while (getSkillXpLevelRaw(skillType) >= getXpToLevel(skillType)) {
if (hasReachedLevelCap(skillType)) {
setSkillXpLevel(skillType, 0);
break;
}
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
return;
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
xpRemoved += profile.levelUp(skillType);
levelsGained++;
}
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
return;
}
if (Config.getInstance().getLevelUpSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
}
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
}
/*
@@ -689,52 +622,8 @@ public class McMMOPlayer {
invite = null;
}
public boolean getPtpEnabled() {
return ptpEnabled;
}
public void togglePtpUse() {
ptpEnabled = !ptpEnabled;
}
public Player getPtpRequest() {
return ptpRequest;
}
public void setPtpRequest(Player ptpRequest) {
this.ptpRequest = ptpRequest;
}
public boolean hasPtpRequest() {
return (ptpRequest != null);
}
public void removePtpRequest() {
ptpRequest = null;
}
public boolean getPtpConfirmRequired() {
return ptpConfirmRequired;
}
public void togglePtpConfirmRequired() {
ptpConfirmRequired = !ptpConfirmRequired;
}
public int getPtpLastUse() {
return ptpLastUse;
}
public void actualizePtpLastUse() {
ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public long getPtpTimeout() {
return ptpTimeout;
}
public void actualizePtpTimeout() {
ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
public PartyTeleportRecord getPartyTeleportRecord() {
return ptpRecord;
}
public int getItemShareModifier() {
@@ -753,28 +642,67 @@ public class McMMOPlayer {
* Chat modes
*/
public boolean getAdminChatMode() {
return adminChatMode;
public boolean isChatEnabled(ChatMode mode) {
switch (mode) {
case ADMIN:
return adminChatMode;
case PARTY:
return partyChatMode;
default:
return false;
}
}
public void setAdminChat(boolean enabled) {
adminChatMode = enabled;
public void disableChat(ChatMode mode) {
switch (mode) {
case ADMIN:
adminChatMode = false;
return;
case PARTY:
partyChatMode = false;
return;
default:
return;
}
}
public void toggleAdminChat() {
adminChatMode = !adminChatMode;
public void enableChat(ChatMode mode) {
switch (mode) {
case ADMIN:
adminChatMode = true;
partyChatMode = false;
return;
case PARTY:
partyChatMode = true;
adminChatMode = false;
return;
default:
return;
}
}
public boolean getPartyChatMode() {
return partyChatMode;
}
public void toggleChat(ChatMode mode) {
switch (mode) {
case ADMIN:
adminChatMode = !adminChatMode;
partyChatMode = adminChatMode ? false : partyChatMode;
return;
public void setPartyChat(boolean enabled) {
partyChatMode = enabled;
}
case PARTY:
partyChatMode = !partyChatMode;
adminChatMode = partyChatMode ? false : adminChatMode;
return;
public void togglePartyChat() {
partyChatMode = !partyChatMode;
default:
return;
}
}
public boolean isUsingUnarmed() {
@@ -785,12 +713,11 @@ 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) {
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= profile.getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
return 0;
}
@@ -830,13 +757,17 @@ public class McMMOPlayer {
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
if (!getToolPreparationMode(tool) || !ability.getPermissions(player)) {
return;
}
setToolPreparationMode(tool, false);
if (getAbilityMode(ability)) {
return;
}
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
int timeRemaining = calculateTimeRemaining(ability);
if (timeRemaining > 0) {
/*
@@ -850,11 +781,11 @@ public class McMMOPlayer {
return;
}
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
if (!EventUtils.handlePlayerAbilityActivateEvent(player, ability)) {
return;
}
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
int ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
// Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player);
@@ -866,7 +797,7 @@ public class McMMOPlayer {
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
// Enable the ability
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true);
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
@@ -906,7 +837,7 @@ public class McMMOPlayer {
*/
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
int timeRemaining = calculateTimeRemaining(ability);
if (!getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
@@ -923,4 +854,67 @@ public class McMMOPlayer {
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
}
}
/**
* Calculate the time remaining until the ability's cooldown expires.
*
* @param ability AbilityType whose cooldown to check
*
* @return the number of seconds remaining before the cooldown expires
*/
public int calculateTimeRemaining(AbilityType ability) {
long deactivatedTimestamp = profile.getAbilityDATS(ability) * Misc.TIME_CONVERSION_FACTOR;
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
private boolean hasReachedLevelCap(SkillType skill) {
return (skill.getMaxLevel() < getSkillLevel(skill) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1);
}
/*
* These functions are wrapped from PlayerProfile so that we don't always have to store it alongside the McMMOPlayer object.
*/
public int getSkillLevel(SkillType skill) {
return profile.getSkillLevel(skill);
}
public float getSkillXpLevelRaw(SkillType skill) {
return profile.getSkillXpLevelRaw(skill);
}
public int getSkillXpLevel(SkillType skill) {
return profile.getSkillXpLevel(skill);
}
public void setSkillXpLevel(SkillType skill, float xpLevel) {
profile.setSkillXpLevel(skill, xpLevel);
}
public int getXpToLevel(SkillType skill) {
return profile.getXpToLevel(skill);
}
public void removeXp(SkillType skill, int xp) {
profile.removeXp(skill, xp);
}
public void modifySkill(SkillType skill, int level) {
profile.modifySkill(skill, level);
}
public void addLevels(SkillType skill, int levels) {
profile.addLevels(skill, levels);
}
public void addXp(SkillType skill, float xp) {
profile.addXp(skill, xp);
}
public void setAbilityDATS(AbilityType ability, long DATS) {
profile.setAbilityDATS(ability, DATS);
}
public void resetCooldowns() {
profile.resetCooldowns();
}
}

View File

@@ -4,8 +4,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
@@ -23,20 +21,19 @@ public class PlayerProfile {
/* HUDs */
private MobHealthbarType mobHealthbarType;
private Scoreboard playerStatsScoreboard;
/* Skill Data */
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
private final Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
private final Map<AbilityType, Integer> abilityDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
public PlayerProfile(String playerName) {
this.playerName = playerName;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
for (AbilityType abilityType : AbilityType.NORMAL_ABILITIES) {
abilityDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
@@ -50,17 +47,13 @@ public class PlayerProfile {
this.loaded = isLoaded;
}
/**
* Calling this constructor is considered loading the profile.
*/
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
this(playerName);
public PlayerProfile(String playerName, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
this.playerName = playerName;
this.mobHealthbarType = mobHealthbarType;
this.skills.putAll(argSkills);
this.skillsXp.putAll(argSkillsXp);
this.skillsDATS.putAll(argSkillsDats);
skills.putAll(levelData);
skillsXp.putAll(xpData);
abilityDATS.putAll(cooldownData);
loaded = true;
}
@@ -71,6 +64,7 @@ public class PlayerProfile {
}
changed = !mcMMO.getDatabaseManager().saveUser(this);
if (changed) {
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
}
@@ -96,55 +90,40 @@ public class PlayerProfile {
this.mobHealthbarType = mobHealthbarType;
}
/*
* Scoreboards
*/
public Scoreboard getPlayerStatsScoreboard() {
return playerStatsScoreboard;
}
public void setPlayerStatsScoreboard(Scoreboard statsScoreboard) {
this.playerStatsScoreboard = statsScoreboard;
}
/*
* Cooldowns
*/
/**
* Get the current DATS of a skill.
* Get the current deactivation timestamp of an ability.
*
* @param abilityType Ability to get the DATS for
*
* @return the DATS for the ability
* @param ability The {@link AbilityType} to get the DATS for
* @return the deactivation timestamp for the ability
*/
public long getSkillDATS(AbilityType abilityType) {
return skillsDATS.get(abilityType);
public long getAbilityDATS(AbilityType ability) {
return abilityDATS.get(ability);
}
/**
* Set the current DATS of a skill.
* Set the current deactivation timestamp of an ability.
*
* @param abilityType Ability to set the DATS for
* @param DATS the DATS of the ability
* @param ability The {@link AbilityType} to set the DATS for
* @param DATS the DATS of the ability
*/
public void setSkillDATS(AbilityType abilityType, long DATS) {
int wearsOff = (int) (DATS * .001D);
protected void setAbilityDATS(AbilityType ability, long DATS) {
changed = true;
skillsDATS.put(abilityType, wearsOff);
abilityDATS.put(ability, (int) (DATS * .001D));
}
/**
* Reset all skill cooldowns.
* Reset all ability cooldowns.
*/
public void resetCooldowns() {
protected void resetCooldowns() {
changed = true;
for (AbilityType ability : skillsDATS.keySet()) {
skillsDATS.put(ability, 0);
for (AbilityType ability : abilityDATS.keySet()) {
abilityDATS.put(ability, 0);
}
}
@@ -152,103 +131,108 @@ public class PlayerProfile {
* Xp Functions
*/
public int getSkillLevel(SkillType skillType) {
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType);
public int getSkillLevel(SkillType skill) {
return skill.isChildSkill() ? getChildSkillLevel(skill) : skills.get(skill);
}
public float getSkillXpLevelRaw(SkillType skillType) {
return skillsXp.get(skillType);
public float getSkillXpLevelRaw(SkillType skill) {
return skillsXp.get(skill);
}
public int getSkillXpLevel(SkillType skillType) {
return (int) Math.floor(getSkillXpLevelRaw(skillType));
public int getSkillXpLevel(SkillType skill) {
return (int) Math.floor(getSkillXpLevelRaw(skill));
}
public void setSkillXpLevel(SkillType skillType, float newValue) {
if (skillType.isChildSkill()) {
public void setSkillXpLevel(SkillType skill, float xpLevel) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skillsXp.put(skillType, newValue);
skillsXp.put(skill, xpLevel);
}
public void skillUp(SkillType skillType, int newValue) {
skills.put(skillType, skills.get(skillType) + newValue);
protected float levelUp(SkillType skill) {
float xpRemoved = getXpToLevel(skill);
changed = true;
skills.put(skill, skills.get(skill) + 1);
skillsXp.put(skill, skillsXp.get(skill) - xpRemoved);
return xpRemoved;
}
/**
* Remove Xp from a skill.
*
* @param skillType Type of skill to modify
* @param xp Amount of xp to remove
* @param skill Type of skill to modify
* @param xp Amount of xp to remove
*/
public void removeXp(SkillType skillType, int xp) {
if (skillType.isChildSkill()) {
public void removeXp(SkillType skill, int xp) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
skillsXp.put(skill, skillsXp.get(skill) - xp);
}
/**
* Modify a skill level.
*
* @param skillType Type of skill to modify
* @param newValue New level value for the skill
* @param skill Type of skill to modify
* @param level New level value for the skill
*/
public void modifySkill(SkillType skillType, int newValue) {
if (skillType.isChildSkill()) {
public void modifySkill(SkillType skill, int level) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skills.put(skillType, newValue);
skillsXp.put(skillType, 0F);
skills.put(skill, level);
skillsXp.put(skill, 0F);
}
/**
* Add levels to a skill.
*
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
* @param skill Type of skill to add levels to
* @param levels Number of levels to add
*/
public void addLevels(SkillType skillType, int levels) {
if (skillType.isChildSkill()) {
return;
}
changed = true;
skills.put(skillType, skills.get(skillType) + levels);
skillsXp.put(skillType, 0F);
public void addLevels(SkillType skill, int levels) {
modifySkill(skill, skills.get(skill) + levels);
}
/**
* Add Experience to a skill.
*
* @param skillType Type of skill to add experience to
* @param experience Number of experience to add
* @param skill Type of skill to add experience to
* @param xp Number of experience to add
*/
public void addExperience(SkillType skillType, int experience) {
if (skillType.isChildSkill()) {
return;
}
public void addXp(SkillType skill, float xp) {
changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) + experience);
if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
float dividedXP = (xp / parentSkills.size());
for (SkillType parentSkill : parentSkills) {
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
}
}
else {
skillsXp.put(skill, skillsXp.get(skill) + xp);
}
}
/**
* 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) {

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.datatypes.skills;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@@ -12,6 +14,8 @@ 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.On",
@@ -62,6 +66,9 @@ public enum AbilityType {
"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(
null,
null,
@@ -69,19 +76,15 @@ public enum AbilityType {
"Mining.Blast.Refresh",
null),
LEAF_BLOWER(
null,
null,
null,
null,
null),
/**
* No cooldown - always active
*/
LEAF_BLOWER,
BLOCK_CRACKER(
null,
null,
null,
null,
null);
/**
* Not a first-class Ability - part of Berserk
*/
BLOCK_CRACKER;
private String abilityOn;
private String abilityOff;
@@ -89,6 +92,20 @@ public enum AbilityType {
private String abilityRefresh;
private String abilityPlayerOff;
/**
* Those abilities that have a cooldown saved to the database.
*/
public static final List<AbilityType> NORMAL_ABILITIES = ImmutableList.of(BERSERK, BLAST_MINING, GIGA_DRILL_BREAKER, GREEN_TERRA, SERRATED_STRIKES, SKULL_SPLITTER, SUPER_BREAKER, TREE_FELLER);
/**
* Those abilities that do not have a cooldown saved to the database.
*/
public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
private AbilityType() {
this(null, null, null, null, null);
}
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
@@ -125,6 +142,10 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh);
}
public String getName() {
return StringUtils.getPrettyAbilityString(this);
}
@Override
public String toString() {
String baseString = name();
@@ -150,7 +171,6 @@ 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) {
@@ -194,7 +214,6 @@ 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) {
@@ -229,8 +248,7 @@ 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) {

View File

@@ -5,6 +5,9 @@ import java.util.Collections;
import java.util.List;
import org.bukkit.Color;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -24,7 +27,9 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.collect.ImmutableList;
@@ -70,7 +75,7 @@ public enum SkillType {
nonChildSkills.add(skill);
}
names.add(skill.getSkillName());
names.add(skill.getName());
}
Collections.sort(names);
@@ -162,7 +167,10 @@ public enum SkillType {
}
}
mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")");
if (!skillName.equalsIgnoreCase("all")) {
mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
}
return null;
}
@@ -177,10 +185,6 @@ public enum SkillType {
}
}
public Color getRunescapeModeColor() {
return runescapeColor;
}
public static SkillType byAbility(AbilityType ability) {
for (SkillType type : values()) {
if (type.getAbility() == ability) {
@@ -191,7 +195,19 @@ public enum SkillType {
return null;
}
public String getSkillName() {
public String getName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
}
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
public void celebrateLevelUp(Player player) {
ParticleEffectUtils.fireworkParticleShower(player, runescapeColor);
}
public boolean shouldProcess(Entity target) {
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? getPVPEnabled() : getPVEEnabled();
}
}

View File

@@ -34,7 +34,6 @@ 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) {

View File

@@ -1,18 +1,25 @@
package com.gmail.nossr50.events.skills.abilities;
package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
private boolean cancelled;
@Deprecated
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
super(player, skill);
cancelled = false;
}
public McMMOPlayerAbilityActivateEvent(Player player, AbilityType ability) {
super(player, ability);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}

View File

@@ -1,11 +1,17 @@
package com.gmail.nossr50.events.skills.abilities;
package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
@Deprecated
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
super(player, skill);
}
public McMMOPlayerAbilityDeactivateEvent(Player player, AbilityType ability) {
super(player, ability);
}
}

View File

@@ -0,0 +1,62 @@
package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
public abstract class McMMOPlayerAbilityEvent extends PlayerEvent {
private SkillType skill;
private AbilityType ability;
private boolean useParticleEffects;
@Deprecated
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
super(player);
ability = skill.getAbility();
useParticleEffects = true;
}
protected McMMOPlayerAbilityEvent(Player player, AbilityType ability) {
super(player);
this.ability = ability;
this.useParticleEffects = true;
}
protected McMMOPlayerAbilityEvent(Player player, AbilityType ability, boolean useParticleEffects) {
super(player);
this.ability = ability;
this.useParticleEffects = useParticleEffects;
}
@Deprecated
public SkillType getSkill() {
return skill;
}
public AbilityType getAbility() {
return ability;
}
public boolean useParticleEffects() {
return useParticleEffects;
}
public void shouldUseParticleEffects(boolean useParticleEffects) {
this.useParticleEffects = useParticleEffects;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -19,7 +19,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
}
/**

View File

@@ -1,8 +1,9 @@
package com.gmail.nossr50.events.experience;
package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerExperienceEvent;
/**
* Called when a user levels change

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience;
package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player;

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience;
package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player;

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerExperienceEvent;
public abstract class McMMOPlayerXpChangeEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerXpChangeEvent(Player player, SkillType skill) {
super(player, skill);
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience;
package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player;
@@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
/**
* Called when a player gains XP in a skill
*/
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
public class McMMOPlayerXpGainEvent extends McMMOPlayerXpChangeEvent {
private float xpGained;
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) {
@@ -31,7 +31,7 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
}
/**
* @param xpGained int amount of experience gained in this event
* @param xpGained float amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;

View File

@@ -0,0 +1,28 @@
package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerXpLossEvent extends McMMOPlayerXpChangeEvent {
private float xpLost;
public McMMOPlayerXpLossEvent(Player player, SkillType skill, float xpLost) {
super(player, skill);
this.xpLost = xpLost;
}
/**
* @return The amount of experience lost in this event
*/
public float getRawXpLost() {
return xpLost;
}
/**
* @param xpLost amount of experience lost in this event
*/
public void setRawXpLost(float xpLost) {
this.xpLost = xpLost;
}
}

View File

@@ -0,0 +1,40 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.util.player.UserManager;
public abstract class McMMOPlayerCombatEvent extends FakeEntityDamageByEntityEvent {
private Player player;
private SkillType skill;
private int skillLevel;
protected McMMOPlayerCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage, SkillType skill) {
super(damager, damagee, cause, damage);
this.player = player;
this.skill = skill;
skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
}
protected McMMOPlayerCombatEvent(Player player, Entity damagee, DamageCause cause, double damage, SkillType skill) {
super(player, damagee, cause, damage);
this.player = player;
this.skill = skill;
skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
}
public Player getPlayer() {
return player;
}
public SkillType getSkill() {
return skill;
}
public int getSkillLevel() {
return skillLevel;
}
}

View File

@@ -17,7 +17,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
}
/**

View File

@@ -0,0 +1,44 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
public abstract class McMMOPlayerTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
private ItemStack treasure;
private int xpGained;
protected McMMOPlayerTreasureEvent(Player player, SkillType skill, ItemStack treasure, int xpGained) {
super(player, skill);
this.treasure = treasure;
this.xpGained = xpGained;
this.cancelled = false;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public int getXpGained() {
return xpGained;
}
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@@ -1,20 +0,0 @@
package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
private AbilityType ability;
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
super(player, skill);
ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public abstract class McMMOPlayerAcrobaticsEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerAcrobaticsEvent(Player player) {
super(player, SkillType.ACROBATICS);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,30 @@
package com.gmail.nossr50.events.skills.acrobatics;
import org.bukkit.entity.Player;
public class McMMOPlayerDodgeEvent extends McMMOPlayerAcrobaticsEvent {
private double damageTaken;
private float xpGained;
public McMMOPlayerDodgeEvent(Player player, double damageTaken, float xpGained) {
super(player);
this.damageTaken = damageTaken;
this.xpGained = xpGained;
}
public double getDamageTaken() {
return damageTaken;
}
public void setDamageTaken(double damageTaken) {
this.damageTaken = damageTaken;
}
public float getXpGained() {
return xpGained;
}
public void setXpGained(float xpGained) {
this.xpGained = xpGained;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.events.skills.acrobatics;
import org.bukkit.entity.Player;
public class McMMOPlayerRollEvent extends McMMOPlayerAcrobaticsEvent {
private double damageTaken;
private float xpGained;
private boolean graceful;
public McMMOPlayerRollEvent(Player player, double damageTaken, float xpGained, boolean graceful) {
super(player);
this.damageTaken = damageTaken;
this.xpGained = xpGained;
this.graceful = graceful;
}
public double getDamageTaken() {
return damageTaken;
}
public void setDamageTaken(double damageTaken) {
this.damageTaken = damageTaken;
}
public float getXpGained() {
return xpGained;
}
public void setXpGained(float xpGained) {
this.xpGained = xpGained;
}
public boolean isGraceful() {
return graceful;
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
public class McMMOPlayerArcheryCombatEvent extends McMMOPlayerCombatEvent {
public McMMOPlayerArcheryCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage) {
super(player, damager, damagee, cause, damage, SkillType.ARCHERY);
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public abstract class McMMOPlayerArcheryEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerArcheryEvent(Player player) {
super(player, SkillType.ARCHERY);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.skills.archery.Archery;
public class McMMOPlayerDazeEvent extends McMMOPlayerArcheryCombatEvent {
public McMMOPlayerDazeEvent(Player player, Entity damager, Entity damagee) {
super(player, damager, damagee, DamageCause.PROJECTILE, Archery.dazeModifier);
}
}

View File

@@ -0,0 +1,10 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class McMMOPlayerSkillShotEvent extends McMMOPlayerArcheryCombatEvent {
public McMMOPlayerSkillShotEvent(Player player, Entity damager, Entity damagee, double damage) {
super(player, damager, damagee, DamageCause.PROJECTILE, damage);
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
public class McMMOPlayerAxeCombatEvent extends McMMOPlayerCombatEvent {
public McMMOPlayerAxeCombatEvent(Player player, Entity damagee, DamageCause cause, double damage) {
super(player, damagee, cause, damage, SkillType.AXES);
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public abstract class McMMOPlayerAxeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerAxeEvent(Player player) {
super(player, SkillType.AXES);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

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