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

Compare commits

..

144 Commits

Author SHA1 Message Date
GJ
0095f7f9c7 Update pom.xml for 1.4.07 beta release (finally!) 2013-09-12 14:20:18 -04:00
GJ
f53820e4de Update changelog. 2013-09-12 14:18:52 -04:00
GJ
25e4700ef9 Changed various values to double in advanced.yml for the sake of consistency. 2013-09-12 14:18:13 -04:00
GJ
58c7dcb705 Fix issues with double damage, double death messages, and other damage oddities.
Fixes #1450
2013-09-12 11:52:34 -04:00
GJ
44626c36a9 Nerfed Archery damage to eliminate constant one-hit kills 2013-09-11 11:43:06 -04:00
TfT_02
cfd5bfe2c4 Deal skillShot bonus damage properly 2013-09-11 17:08:59 +02:00
t00thpick1
f7928787dc Skill shot should be after deflect check 2013-09-11 10:17:24 -04:00
GJ
d6630a0eb5 Prevent multiple events from being fired. 2013-09-11 08:51:51 -04:00
GJ
af39e84aef Actually remove /mmoupdate, fix usage strings for /mcconvert, fix tab completion
Fixes #1451
2013-09-10 15:47:47 -04:00
TfT_02
93fe2ff504 Cleanup our imports 2013-09-10 15:28:11 +02:00
GJ
b42f2d4073 Refactor, plus store these values rather than checking them twice. 2013-09-10 08:38:06 -04:00
TfT_02
c5c231920d Cleaning up the changelog and comments 2013-09-09 23:19:59 +02:00
GJ
89ddf8c4fa Fixed issues with dealing damage to Entities 2013-09-09 20:41:06 +02:00
GJ
71ab678945 Fix bug where mcMMO damage wasn't awarding XP.
Fixes #1400
2013-09-09 12:00:37 -04:00
GJ
14daee3b1b Fixed a bug where squid were not awarding XP. 2013-09-09 10:46:26 -04:00
GJ
d2bbbb0fe7 More deprecation fixes. 2013-09-05 16:36:02 -04:00
GJ
fd8d9b02a9 Begin trying to remove newly-deprecated "magic numbers" 2013-09-05 14:55:08 -04:00
GJ
a639a37637 Add per-skill XP boost perks.
Fixes #1412
2013-09-03 09:24:58 -04:00
GJ
7eec53d621 Added Horses to Taming. 2013-08-30 14:25:46 -04:00
GJ
7523afffb5 Updated permissions for more control over Call of the Wild. 2013-08-30 13:50:34 -04:00
GJ
2c8b9334b6 THis should stay false. 2013-08-28 13:13:34 -04:00
GJ
d41ccf9072 Don't loop forever if not connected. 2013-08-28 13:12:24 -04:00
GJ
c98d298cf1 Actually make use of the checkConnected calls. 2013-08-28 11:44:58 -04:00
GJ
73d0b377ae Reduce code duplication. Also verify that our target is alive before trying to damage them.
Fixes #1403
2013-08-28 11:29:30 -04:00
TfT_02
df29306a1f Cleanup Javadocs and fix StackOverflowError 2013-08-26 22:09:29 +02:00
GJ
435522415d This is better too. 2013-08-26 12:20:56 -04:00
GJ
a17d1d3a2f More cleanup to PartyManager. 2013-08-26 11:55:35 -04:00
GJ
94a5bef62c Cleaning up PartyManager 2013-08-26 08:39:24 -04:00
GJ
2cd9a5658e Remove unused import 2013-08-26 08:39:24 -04:00
TfT_02
3c5bd3cedd Fix a NPE in MobHealthDisplayUpdateTask
Band aid for broken isValid() function.
Fixes #1396
2013-08-25 17:35:41 +02:00
GJ
8e02b57369 Align these. 2013-08-23 14:52:21 -04:00
GJ
935b8b7bc4 Update localization files. Adds Estonian translations for some strings. 2013-08-23 14:29:01 -04:00
TfT_02
9c54f8fd11 Fix Javadocs issues 2013-08-23 20:14:13 +02:00
GJ
6bfc1b84de Let's do this the right way. 2013-08-23 20:14:13 +02:00
TfT_02
59f545d5ce Fixed FakeEntityDamageByEntityEvent not getting fired 2013-08-23 20:14:13 +02:00
GJ
23983422e0 Cleanup & remove code duplication. 2013-08-23 14:08:16 -04:00
TfT_02
956bf2d763 Added McMMOPlayerLevelDownEvent and McMMOPlayerLevelChangeEvent 2013-08-23 19:54:30 +02:00
TfT_02
964b2636fb Move experience related settings from config.yml to experience.yml 2013-08-23 19:37:44 +02:00
GJ
490bc195d8 We don't care about teleports to the same spot. 2013-08-23 08:58:23 -04:00
TfT_02
0ce41150c6 Vampirism can now be enabled without having Skill Death Penalty enabled 2013-08-22 22:54:05 +02:00
TfT_02
0455416dec Reorganized Hardcore locale strings 2013-08-22 22:54:05 +02:00
TfT_02
a6e7febf77 Hardcore mode can now be toggled for each skill individually 2013-08-22 22:54:05 +02:00
GJ
ede0757d83 Remove /mmoupdate and replace with /mcconvert database 2013-08-22 22:33:06 +02:00
GJ
8282d84b16 Validate, and nicer loading. 2013-08-22 22:22:19 +02:00
GJ
223649ec28 Formatting and localizing. 2013-08-22 22:22:19 +02:00
TfT_02
68e433b3b7 Added new ExperienceFormula config and /mcconvert command 2013-08-22 22:22:19 +02:00
GJ
1a51b93ec9 Another quick check to avoid issues with NPCs. 2013-08-22 14:45:30 -04:00
GJ
c31ffa5ab4 Remove unused import. 2013-08-22 13:51:01 -04:00
TfT_02
ca6bee07ea Fix formatting 2013-08-22 00:37:48 +02:00
TfT_02
9acaa7b126 We're expecting a null object here as well. 2013-08-21 16:48:08 +02:00
gmcferrin
2bae937b28 Don't throw a warning if we're expecting a null object. 2013-08-21 14:20:12 +00:00
TfT_02
51bf989418 Counter Attack now only activates when the player is blocking
Closes #1018
2013-08-20 23:23:49 +02:00
GJ
07dd460d78 Validate in a seperate function. 2013-08-20 15:51:12 -04:00
GJ
045d74fb9d These were basically the same function. 2013-08-20 15:15:42 -04:00
GJ
c8c76f4174 Put this function in a better place. 2013-08-20 15:12:38 -04:00
GJ
83c4d09093 Fix formatting 2013-08-20 15:08:10 -04:00
GJ
50ef8d9610 Improvements to mcMMOPlayer lookup. 2013-08-20 14:10:49 -04:00
GJ
98c6abad36 No reason to cast here. 2013-08-19 15:14:33 -04:00
GJ
62146480db Hardcoding this is a bad idea. 2013-08-19 15:12:08 -04:00
TfT_02
6518d192ec Improved partial name matcher
Fixes #1164
2013-08-19 10:37:04 +02:00
TfT_02
3fe9cfee74 Slightly improved update checker feedback 2013-08-18 18:04:20 +02:00
T00thpick1
d495054eb5 Config Validation 2013-08-18 02:42:13 -04:00
T00thpick1
ce80636141 Min value for IronArm configurable 2013-08-18 02:38:57 -04:00
TfT_02
fe93be66ad Changed the color of party leader names in Party chat 2013-08-17 13:53:46 +02:00
TfT_02
1f712063bf Admin and Party chat prefixes are now customizable
Closes #578
2013-08-17 12:18:29 +02:00
TfT_02
560c3860b4 Fixed bug which allowed players to bypass fishing's exploit prevention
Fixes #1319
2013-08-17 10:11:46 +02:00
TfT_02
36f1a2d78a Changed the way Repair hands out XP
Closes #373
2013-08-15 20:50:19 +02:00
TfT_02
3ddd8d2056 Added API to get a players rank on the leaderboards 2013-08-13 09:37:45 +02:00
TfT_02
5441fcc374 Fix broken Dodge_DamageModifier config node
Also fix a derp with the validation of
Arcane_Forging.Keep_Enchants.Chance
2013-08-11 15:55:25 +02:00
TfT_02
1d83784820 Arcane Forging downgrade chance can also be 0
Fixes #1367
2013-08-11 09:26:02 +02:00
TfT_02
fb5bab6e92 String values are compared using '.equals()' not '==' 2013-08-10 22:24:13 +02:00
TfT_02
90fcf35c34 Javadocs cleanup 2013-08-10 20:10:45 +02:00
TfT_02
4ff6b5fbc7 Don't try to register listeners when mcMMO was disabled 2013-08-10 19:33:21 +02:00
TfT_02
ead1398132 Super Breaker & Giga Driller now use more durability
A configurable amount is added to the vanilla durability loss.

Use `Abilities.Tools.Durability_Loss` to disable (set to 0) or set it
to -1 for no durability loss while using abilities. Closes #1363
2013-08-09 22:21:45 +02:00
TfT_02
6330c4a69e Move the noErrorsInConfig check to Misc 2013-08-09 19:10:03 +02:00
TfT_02
dcc18049a1 Removed Abilities.Tools.Durability_Loss_Enabled
Set Abilities.Tools.Durability_Loss to 0 to disable instead.
Addresses #1357
2013-08-09 18:13:22 +02:00
TfT_02
fcb8909a54 Kick interval can be disabled with '-1'
Fixes #1356
2013-08-09 13:36:04 +02:00
TfT_02
37e3bfe7d9 Fixed formatting 2013-08-07 19:58:49 +02:00
riking
d61b837dcf Implement checkStructure() 2013-08-07 19:49:00 +02:00
riking
f079e22789 Use provided last-saved information for purge.
The new method, OfflinePlayer.getLastPlayed(), is used as a backup for when the data is unparsable.
TODO check if StringUtils is available here
2013-08-07 19:45:27 +02:00
TfT_02
1f53c62ced Added McMMOPlayerDeathPenaltyEvent
Called when a player dies and mcMMO tries to invoke Hardcore mode or
Vampirism
2013-08-07 01:21:52 +02:00
TfT_02
9fb4e0988b Save / load party itemshare category states.
Closes #1336
2013-08-07 00:38:17 +02:00
TfT_02
d8bbe459b9 Fix minor Javadoc errors 2013-08-07 00:15:51 +02:00
TfT_02
8bd7526b43 String values are compared using '.equals()' not '==' 2013-08-06 21:48:09 +02:00
TfT_02
24b1485555 Validate advanced.yml settings 2013-08-06 21:37:19 +02:00
TfT_02
7683dfc436 Move validation to proper location 2013-08-06 21:27:16 +02:00
TfT_02
ccbffca278 Validate config.yml settings 2013-08-06 21:17:14 +02:00
Glitchfinder
aeaab43f44 Fixing a multitude of reported NPEs. 2013-08-04 12:15:01 -07:00
Glitchfinder
a2450d2d07 If a variable can be null, check it before using it. 2013-08-04 11:48:44 -07:00
T00thpick1
c85bd8ab70 One more last try 2013-08-04 11:56:37 -04:00
T00thpick1
3f6bce0fc6 One last try 2013-08-04 11:51:34 -04:00
T00thpick1
e566b20e2b This might be important 2013-08-04 11:38:52 -04:00
T00thpick1
f37a7d759a Hack around nms bug 2013-08-04 11:34:04 -04:00
T00thpick1
d1341b0be0 Would help if I actualized the value... Fix dupe bug for realz 2013-08-04 11:05:53 -04:00
T00thpick1
4ea3d690db Fix Dupe bug...... why was this overlooked? 2013-08-03 11:37:29 -04:00
TfT_02
d5dc9895e4 Move Blast Mining activation check to MONITOR priority
Fixes #1331
2013-08-02 21:11:58 +02:00
Glitchfinder
b1fc72e8a9 When a variable can be null, check it before using it. Fixes #1308. 2013-08-01 08:47:14 -07:00
GJ
7479a02220 Update changelog. 2013-07-30 15:23:32 -04:00
GJ
d1bf48ad79 Fix bug where teleport location was never reset if warmup was set to 0
for Chimera Wing.

Fixes #1323
2013-07-30 15:20:18 -04:00
GJ
a345737b8b Add more detailed error messages on SQL connection failure.
Fixes #1322
2013-07-30 15:09:22 -04:00
GJ
c501ebb357 Clean up after our experience commands. Fixes #1324 2013-07-30 14:47:11 -04:00
GJ
15e0570a8c Else if > if 2013-07-29 08:45:30 -04:00
GJ
09e77c8c94 Move break event to the initial check. 2013-07-29 08:29:10 -04:00
TfT_02
f5c58f3679 Added config option for Acrobatics teleport cooldown,
also updated the changelog.
2013-07-29 00:57:43 +02:00
GJ
ddcbe64db6 Fix some possible issues with handler priority, more javadoc work. 2013-07-28 13:55:48 -04:00
GJ
c5137eb884 Begin work on cleaning up our listeners and their Javadocs. 2013-07-25 14:52:21 -04:00
GJ
e073eca458 Validation is important. 2013-07-24 20:29:32 -04:00
GJ
78f2e0a064 Check the range in a seperate function 2013-07-24 14:13:58 -04:00
TfT_02
df2defe969 Added extra settings for Call of the Wild
* Requested in issue #910
* Adds a setting to configure the range check
* Adds a setting to summon multiple pets with one summon
2013-07-24 20:01:26 +02:00
TfT_02
6d4a2feaae Slighty changed a Green Thumb string
Make this fit on one line in the chat window
2013-07-24 20:01:26 +02:00
GJ
8939fc09b3 Patch potential exploit relating to teleportation and acrobatics. 2013-07-24 13:57:53 -04:00
GJ
e0e574c19e Fix a potential issue with PTP and Chimera Wing teleportation cooldowns. 2013-07-24 13:50:33 -04:00
GJ
02126c93b9 This function is never used. 2013-07-24 12:35:28 -04:00
GJ
37671bad9a We already have the mcMMOPlayer here. 2013-07-24 12:30:02 -04:00
TfT_02
0e8ce005d7 This is also a change 2013-07-24 16:10:26 +02:00
GJ
584a225d6e Only get the mcMMOPlayer once. 2013-07-24 09:37:45 -04:00
riking
736359056f Add checkConnected() calls to re-establish dead SQL connections 2013-07-23 15:03:19 -07:00
TfT_02
bf2e527e72 Fixed NPE with Beast Lore
Fixes #1289
2013-07-22 11:35:48 +02:00
TfT_02
be7992d541 Disable all abilities when a player quits
Fixes #1295
2013-07-22 11:25:56 +02:00
TfT_02
435eb7f8b9 Added new experience curve option 2013-07-21 23:14:42 +02:00
GJ
001f1dbd3c Fix issue with truncating things that don't need truncating. 2013-07-17 13:45:31 -04:00
GJ
7b5372a985 Temporary fix for MCPC+ entity issues. This change will be reverted
after the fix is made in MCPC+.

Fixes #1197
2013-07-17 10:29:42 -04:00
GJ
1647ef4fae Fixed issue where locale strings could cause the scoreboard header to be
longer than 16 characters.

Fixes #1278
2013-07-17 08:18:54 -04:00
GJ
ee86f8244f Put ShareMode in its own class. 2013-07-15 09:56:45 -04:00
GJ
e518b58b23 Better way to do locale strings there. 2013-07-15 09:48:14 -04:00
GJ
5af1164b5c Tweak ShareHandler a bit. 2013-07-15 09:40:07 -04:00
GJ
c9aba059e2 Don't provide direct access to the players map. 2013-07-15 09:14:23 -04:00
GJ
dc9469c0cc Refactor to match standards set for where datatypes should be located. 2013-07-15 08:44:13 -04:00
TfT_02
696e82e622 Add missing Axes locale string
* Somehow, the message notifying a player that he was struck by Skull
Splitter wasn't in the locale files anymore.
 * Re-added this string and renamed it.
 * Fixes #1271
2013-07-15 13:18:13 +02:00
TfT_02
18a5ec73d7 Fixed Level up announcement
Fixes #1270
2013-07-14 10:58:51 +02:00
TfT_02
83ee8dd3f8 Update README.md
* Updated the about section so its similar with BukkitDev
 * Updated required libraries list, we're using EMetrics instead of Metrics
2013-07-11 20:53:35 +02:00
GJ
04224b309a Add snow to excavation. No treasures will drop from snow by default,
but they can be added to the treasures.yml file by specifying

"Drops_From:
	Snow: true"

Adds #1229
2013-07-11 14:41:23 -04:00
GJ
01a1cf5765 Update changelog. 2013-07-11 13:22:44 -04:00
GJ
8fdf4042bb Tweaked for readability. 2013-07-11 13:22:14 -04:00
GJ
621969459a Use profile instead of mcMMOPlayer 2013-07-11 13:19:04 -04:00
T00thpick1
6fe1c85592 Save on logout 2013-07-11 13:16:51 -04:00
T00thpick1
79346d92d7 Only save on changes 2013-07-11 13:16:42 -04:00
GJ
24ceeb626b Updated localization files 2013-07-11 13:03:38 -04:00
GJ
68727496ad Useless casting and elses. 2013-07-11 12:49:01 -04:00
GJ
d07b67b5bf Health and damage are now doubles, not ints. 2013-07-11 12:43:36 -04:00
GJ
4dc9c97978 Build from LATEST again. 2013-07-11 12:26:31 -04:00
GJ
99916f99fd Back to new development 2013-07-11 12:25:21 -04:00
GJ
4a5307f47b New 1.4.06 release before work starts on adding new features from 1.6 2013-07-11 12:09:24 -04:00
GJ
69aead58a7 Using getPlayerExact is faster. 2013-07-08 19:15:44 -04:00
179 changed files with 6443 additions and 2171 deletions

View File

@@ -7,7 +7,49 @@ Key:
! Change
- Removal
Version 1.4.06-dev
Version 1.4.07-dev
+ Added ability to summon horses via "Call of the Wild" using apples
+ Added XP gain to Taming for horses
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
+ Added new experience.yml config file! Moved all experience related settings from config.yml to experience.yml
+ Added support for EXPONENTIAL formula curves to experience.yml
+ Added new /mcconvert command to convert players levels and experience from one formula curve to another.
+ Added snow to Excavation blocks
+ Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level.
+ Added extra settings to config.yml for "Call of the Wild" (Taming)
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. Plus a config option to disable
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
= Fixed bug which allowed players to bypass fishing's exploit prevention
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
= Fixed bug with "Skull Splitter" not finding the locale string
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
= Fixed a bug with "Beast Lore" when the entity had no owner but was tamed.
= Fixed a bug where AbilityDeactivateEvent would throw an error if the player logged out before his ability ran out.
= Fixed a bug where LevelUpEvent would be called for an offline player.
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
= Fixed a bug where squid were not awarding XP.
! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
! Hardcore mode can now be toggled for each skill individually
! Vampirism can now be enabled without having Skill Death Penalty enabled
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Improved profile saving
! Improved partial name matcher
! Slightly improved update checker feedback
! Updated localization files
! 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)
- 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.
Version 1.4.06
+ Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop)
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands

View File

@@ -5,9 +5,7 @@
Our latest development builds are available [here](http://ci.mcmmo.info).
### Brief Description
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
If you want an original RPG experience like no other mod out there, mcMMO is for you.
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. Additionally, when run in conjuction with SpoutPlugin, mcMMO also has a custom XP bar to allow for easy tracking of progress towards leveling up. 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.
## About the Team
@@ -41,7 +39,7 @@ The typical command used to build mcMMO is: mvn clean package install
Required Libraries:
* Spout API
* JUnit
* Metrics
* EMetrics
* Bukkit
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.06-dev6</version>
<version>1.4.07-beta1</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -145,7 +145,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2-R1.0</version>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View File

@@ -5,8 +5,8 @@ import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;

View File

@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.child.FamilyTree;
@@ -90,7 +91,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
*/
public static void addMultipliedXP(Player player, String skillType, int XP) {
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
/**
@@ -106,7 +107,7 @@ public final class ExperienceAPI {
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
/**
@@ -123,7 +124,7 @@ public final class ExperienceAPI {
public static void addModifiedXP(Player player, String skillType, int XP) {
SkillType skill = getSkillType(skillType);
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
/**
@@ -141,7 +142,7 @@ public final class ExperienceAPI {
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
SkillType skill = getSkillType(skillType);
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
/**
@@ -435,6 +436,40 @@ public final class ExperienceAPI {
return Config.getInstance().getPowerLevelCap();
}
/**
* Get the position on the leaderboard of a player.
* </br>
* This function is designed for API usage.
*
* @param playerName The name of the player to check
* @param skillType The skill to check
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*/
public static int getPlayerRankSkill(String playerName, String skillType) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
}
/**
* Get the position on the power level leaderboard of a player.
* </br>
* This function is designed for API usage.
*
* @param playerName The name of the player to check
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard
*/
public static int getPlayerRankOverall(String playerName) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
}
/**
* Sets the level of a player in a specific skill type.
* </br>

View File

@@ -77,13 +77,12 @@ public final class PartyAPI {
*/
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party(playerName, partyName);
party = new Party(player.getName(), partyName);
}
PartyManager.addToParty(playerName, UserManager.getPlayer(player), party);
PartyManager.addToParty(UserManager.getPlayer(player), party);
}
/**
@@ -94,7 +93,7 @@ public final class PartyAPI {
* @param player The player to remove
*/
public static void removeFromParty(Player player) {
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
PartyManager.removeFromParty(UserManager.getPlayer(player));
}
/**

View File

@@ -7,7 +7,7 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), "Commands.AdminChat.Prefix");
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
}
@Override

View File

@@ -11,6 +11,7 @@ public abstract class ChatManager {
protected boolean useDisplayNames;
protected String chatPrefix;
protected String senderName;
protected String displayName;
protected String message;
@@ -27,8 +28,9 @@ public abstract class ChatManager {
return;
}
displayName = useDisplayNames ? event.getDisplayName() : event.getSender();
message = LocaleLoader.getString(chatPrefix, displayName) + event.getMessage();
senderName = event.getSender();
displayName = useDisplayNames ? event.getDisplayName() : senderName;
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
sendMessage();
}

View File

@@ -4,6 +4,8 @@ import java.util.HashMap;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.datatypes.chat.ChatMode;
public class ChatManagerFactory {
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.chat;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -11,7 +12,7 @@ public class PartyChatManager extends ChatManager {
private Party party;
protected PartyChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getPartyDisplayNames(), "Commands.Party.Chat.Prefix");
super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
}
public void setParty(Party party) {
@@ -25,6 +26,10 @@ public class PartyChatManager extends ChatManager {
@Override
protected void sendMessage() {
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
}
for (Player member : party.getOnlineMembers()) {
member.sendMessage(message);
}

View File

@@ -11,9 +11,11 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
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 KrakenCommand implements TabExecutor {
@@ -39,9 +41,10 @@ public class KrakenCommand implements TabExecutor {
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;
}
@@ -57,7 +60,7 @@ public class KrakenCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -16,6 +16,7 @@ import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class McscoreboardCommand implements TabExecutor {

View File

@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -45,9 +46,10 @@ public abstract class ToggleCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer(args[0]);
String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;
}
@@ -70,7 +72,7 @@ public abstract class ToggleCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -9,7 +9,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
@@ -21,7 +21,7 @@ public class XprateCommand implements TabExecutor {
private double originalRate;
public XprateCommand() {
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
originalRate = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
}
@Override
@@ -42,7 +42,7 @@ public class XprateCommand implements TabExecutor {
mcMMO.p.toggleXpEventEnabled();
}
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
return true;
case 2:
@@ -66,7 +66,7 @@ public class XprateCommand implements TabExecutor {
}
int newXpRate = Integer.parseInt(args[0]);
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.chat;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.datatypes.chat.ChatMode;
public class AdminChatCommand extends ChatCommand {
public AdminChatCommand() {

View File

@@ -12,7 +12,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;

View File

@@ -3,8 +3,8 @@ package com.gmail.nossr50.commands.chat;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;

View File

@@ -0,0 +1,79 @@
package com.gmail.nossr50.commands.database;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.util.player.UserManager;
public class ConvertDatabaseCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz;
try {
clazz = Class.forName(args[1]);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
catch (Exception e) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
try {
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
}
catch (Throwable t) {
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getName(), false);
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
}
UserManager.addUser(player);
}
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
return true;
default:
return false;
}
}
}

View File

@@ -0,0 +1,94 @@
package com.gmail.nossr50.commands.database;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.google.common.collect.ImmutableList;
public class McconvertCommand implements TabExecutor {
private static final List<String> FORMULA_TYPES;
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static {
ArrayList<String> formulaTypes = 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());
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM);
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
}
Collections.sort(databaseTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args);
}
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args);
}
return false;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size()));
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size()));
}
if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
}

View File

@@ -11,6 +11,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -21,15 +22,17 @@ public class McremoveCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false))) {
String playerName = Misc.getMatchedPlayerName(args[0]);
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}
if (mcMMO.getDatabaseManager().removeUser(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
if (mcMMO.getDatabaseManager().removeUser(playerName)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
}
else {
sender.sendMessage(args[0] + " could not be removed from the database."); // Pretty sure this should NEVER happen.
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
}
return true;
@@ -43,7 +46,7 @@ public class McremoveCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -9,6 +9,7 @@ import org.bukkit.command.TabExecutor;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
public class MmoshowdbCommand implements TabExecutor {
@@ -17,22 +18,16 @@ public class MmoshowdbCommand implements TabExecutor {
if (args.length != 0) {
return false;
}
else {
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
else {
if (Config.getInstance().getUseMySQL()) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "sql"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "flatfile"));
}
return true;
}
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,138 +0,0 @@
package com.gmail.nossr50.commands.database;
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.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.ConversionTask;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class MmoupdateCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
String argType = args[0];
String oldType = validateName(sender, args[0]);
if (oldType == null) {
return true;
}
String newType = getCurrentDb();
if (newType.equals(oldType)) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Same", argType));
return true;
}
DatabaseManager oldDb;
if (oldType == "sql") {
oldDb = DatabaseManagerFactory.createSQLDatabaseManager();
}
else if (oldType == "flatfile") {
oldDb = DatabaseManagerFactory.createFlatfileDatabaseManager();
}
else try {
@SuppressWarnings("unchecked")
Class<? extends DatabaseManager> clazz = (Class<? extends DatabaseManager>) Class.forName(oldType);
oldDb = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now
}
catch (Throwable e) {
return false;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start", oldType, newType));
// Convert the online players right away, without waiting
// first, flush out the current data
UserManager.saveAll();
UserManager.clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
// Get the profile from the old database and save it in the new
PlayerProfile profile = oldDb.loadPlayerProfile(player.getName(), false);
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
}
// Reload from the current database via UserManager
UserManager.addUser(player);
}
// Schedule the task for all users
new ConversionTask(oldDb, sender, oldType, newType).runTaskAsynchronously(mcMMO.p);
return true;
default:
break;
}
return false;
}
/**
* @return null - if type not recognized / class not found
* empty string - if type is same as current
* normalized string - if type is recognized
*/
private String validateName(CommandSender sender, String type) {
if (type.equalsIgnoreCase("sql") || type.equalsIgnoreCase("mysql")) {
return "sql";
}
if (type.equalsIgnoreCase("flatfile") || type.equalsIgnoreCase("file")) {
return "flatfile";
}
try {
Class<?> clazz = Class.forName(type);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
return null;
}
return type;
}
catch (Exception e) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
return null;
}
}
private String getCurrentDb() {
if (DatabaseManagerFactory.getCustomDatabaseManagerClass() != null) {
return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName();
}
if (Config.getInstance().getUseMySQL()) {
return "sql";
}
else {
return "flatfile";
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
return ImmutableList.of("flatfile", "sql", clazz.getName());
}
return ImmutableList.of("flatfile", "sql");
}
}

View File

@@ -0,0 +1,49 @@
package com.gmail.nossr50.commands.experience;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.util.player.UserManager;
public class ConvertExperienceCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
return true;
}
if (previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
UserManager.addUser(player);
}
return true;
default:
return false;
}
}
}

View File

@@ -15,6 +15,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -52,7 +53,7 @@ public abstract class ExperienceCommand implements TabExecutor {
profile = mcMMOPlayer.getProfile();
editValues();
allSkills = false;
cleanUp();
return true;
case 3:
@@ -65,11 +66,12 @@ public abstract class ExperienceCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer(args[0]);
String playerName = Misc.getMatchedPlayerName(args[0]);
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(args[0], false);
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
@@ -84,8 +86,8 @@ public abstract class ExperienceCommand implements TabExecutor {
editValues();
}
handleSenderMessage(sender, args[0]);
allSkills = false;
handleSenderMessage(sender, playerName);
cleanUp();
return true;
default:
@@ -97,7 +99,7 @@ public abstract class ExperienceCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
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()));
@@ -169,4 +171,9 @@ public abstract class ExperienceCommand implements TabExecutor {
}
}
}
private void cleanUp() {
allSkills = false;
player = null;
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -24,8 +25,17 @@ public class MmoeditCommand extends ExperienceCommand {
protected void handleCommand(SkillType skill) {
profile.modifySkill(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
if (player == null) {
return;
}
int skillLevel = profile.getSkillLevel(skill);
if (value > skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
}
else if (value < skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
}
}

View File

@@ -6,8 +6,9 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.locale.LocaleLoader;
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;
@@ -56,11 +57,12 @@ public class SkillresetCommand extends ExperienceCommand {
return true;
}
mcMMOPlayer = UserManager.getPlayer(args[0]);
String playerName = Misc.getMatchedPlayerName(args[0]);
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(args[0], false);
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
@@ -76,7 +78,7 @@ public class SkillresetCommand extends ExperienceCommand {
editValues();
}
handleSenderMessage(sender, args[0]);
handleSenderMessage(sender, playerName);
return true;
default:
@@ -104,7 +106,7 @@ public class SkillresetCommand extends ExperienceCommand {
profile.modifySkill(skill, 0);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
}
}

View File

@@ -2,22 +2,11 @@ package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected void disable() {
Config.getInstance().setHardcoreEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
}
@Override
protected void enable() {
Config.getInstance().setHardcoreEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
}
@Override
protected boolean checkTogglePermissions() {
return Permissions.hardcoreToggle(sender);
@@ -29,13 +18,46 @@ public class HardcoreCommand extends HardcoreModeCommand {
}
@Override
protected boolean checkEnabled() {
return Config.getInstance().getHardcoreEnabled();
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreStatLossEnabled()) {
return false;
}
}
return true;
}
return SkillType.getSkill(skill).getHardcoreStatLossEnabled();
}
@Override
protected void enable(String skill) {
toggle(true);
}
@Override
protected void disable(String skill) {
toggle(false);
}
@Override
protected void modify() {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercent / 100D)));
}
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
}
}
else {
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
}
}

View File

@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -19,6 +20,7 @@ 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%");
@@ -35,11 +37,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
if (checkEnabled()) {
disable();
if (checkEnabled("ALL")) {
disable("ALL");
}
else {
enable();
enable("ALL");
}
return true;
@@ -51,7 +53,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
enable();
enable("ALL");
return true;
}
@@ -61,7 +63,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
disable();
disable("ALL");
return true;
}
@@ -77,6 +79,36 @@ public abstract class HardcoreModeCommand implements TabExecutor {
modify();
return true;
case 2:
if (!args[0].equalsIgnoreCase("ALL") && CommandUtils.isChildSkill(sender, SkillType.getSkill(args[0]))) {
return true;
}
skill = args[0];
if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
if (CommandUtils.shouldDisableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
disable(skill);
return true;
}
return true;
default:
return false;
}
@@ -98,9 +130,9 @@ public abstract class HardcoreModeCommand implements TabExecutor {
protected abstract boolean checkTogglePermissions();
protected abstract boolean checkModifyPermissions();
protected abstract boolean checkEnabled();
protected abstract void enable();
protected abstract void disable();
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) {

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -17,25 +18,46 @@ public class VampirismCommand extends HardcoreModeCommand {
}
@Override
protected boolean checkEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled();
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreVampirismEnabled()) {
return false;
}
}
return true;
}
return SkillType.getSkill(skill).getHardcoreVampirismEnabled();
}
@Override
protected void enable() {
Config.getInstance().setHardcoreVampirismEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
protected void enable(String skill) {
toggle(true);
}
@Override
protected void disable() {
Config.getInstance().setHardcoreVampirismEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
protected void disable(String skill) {
toggle(false);
}
@Override
protected void modify() {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
}
private void toggle(boolean enabled) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
}
}
else {
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
}
}

View File

@@ -24,11 +24,11 @@ public class PartyAcceptCommand implements CommandExecutor {
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(player, mcMMOPlayer);
PartyManager.joinInvitedParty(mcMMOPlayer);
return true;
default:

View File

@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
public class PartyChangeOwnerCommand implements CommandExecutor {
@@ -16,13 +17,14 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
switch (args.length) {
case 2:
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String targetName = Misc.getMatchedPlayerName(args[1]);
if (!playerParty.getMembers().contains(args[1])) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
if (!playerParty.getMembers().contains(targetName)) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true;
}
PartyManager.setPartyLeader(args[1], playerParty);
PartyManager.setPartyLeader(targetName, playerParty);
return true;
default:

View File

@@ -20,6 +20,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class PartyCommand implements TabExecutor {
@@ -176,7 +177,7 @@ public class PartyCommand implements TabExecutor {
case INVITE:
case KICK:
case OWNER:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
case EXPSHARE:
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
@@ -191,7 +192,7 @@ public class PartyCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
playerNames = UserManager.getPlayers().keySet();
playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
}

View File

@@ -5,7 +5,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -17,22 +16,20 @@ public class PartyCreateCommand implements CommandExecutor {
switch (args.length) {
case 2:
case 3:
Party newParty = PartyManager.getParty(args[1]);
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
// Check to see if the party exists, and if it does cancel creating a new party
if (PartyManager.checkPartyExistence(player, newParty, args[1])) {
if (PartyManager.checkPartyExistence(player, args[1])) {
return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
return true;
}
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
return true;
default:

View File

@@ -7,9 +7,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -46,7 +45,7 @@ public class PartyExpShareCommand implements CommandExecutor {
}
}
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
private void handleChangingShareMode(ShareMode mode) {
playerParty.setXpShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -10,13 +9,14 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.util.player.UserManager;
public class PartyInfoCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@@ -26,7 +26,7 @@ public class PartyInfoCommand implements CommandExecutor {
case 0:
case 1:
player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
displayPartyHeader();
@@ -43,12 +43,12 @@ public class PartyInfoCommand implements CommandExecutor {
StringBuilder memberList = new StringBuilder();
for (String memberName : playerParty.getMembers()) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (playerParty.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD);
}
else if (member.isOnline()) {
else if (member != null) {
memberList.append(ChatColor.WHITE);
}
else {
@@ -64,7 +64,7 @@ public class PartyInfoCommand implements CommandExecutor {
private void displayShareModeInfo() {
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) {
return;
@@ -104,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
}
private void displayMemberInfo() {
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));

View File

@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -17,15 +18,17 @@ public class PartyInviteCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]);
String targetName = Misc.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) {
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
@@ -33,21 +36,20 @@ public class PartyInviteCommand implements CommandExecutor {
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.canInvite(player, playerParty)) {
if (!PartyManager.canInvite(mcMMOPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;

View File

@@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;

View File

@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -19,7 +20,6 @@ public class PartyJoinCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -41,12 +41,15 @@ public class PartyJoinCommand implements CommandExecutor {
return true;
}
String partyName = targetParty.getName();
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
return true;
}
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
return true;
default:
@@ -64,6 +67,7 @@ public class PartyJoinCommand implements CommandExecutor {
}
private boolean canJoinParty(CommandSender sender, String targetName) {
targetName = Misc.getMatchedPlayerName(targetName);
mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
@@ -79,11 +83,9 @@ public class PartyJoinCommand implements CommandExecutor {
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) {
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}

View File

@@ -73,8 +73,6 @@ public class PartyLockCommand implements CommandExecutor {
/**
* Handle unlocking a party.
*
* @return true if party is successfully unlocked, false otherwise.
*/
private void unlockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {

View File

@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -17,13 +18,14 @@ public class PartyQuitCommand implements CommandExecutor {
switch (args.length) {
case 1:
Player player = (Player) sender;
Party playerParty = UserManager.getPlayer(player).getParty();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true;
}
PartyManager.removeFromParty(player, playerParty);
PartyManager.removeFromParty(mcMMOPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;

View File

@@ -30,10 +30,9 @@ public class PartyRenameCommand implements CommandExecutor {
}
Player player = mcMMOPlayer.getPlayer();
Party newParty = PartyManager.getParty(newPartyName);
// Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) {
if (PartyManager.checkPartyExistence(player, newPartyName)) {
return true;
}

View File

@@ -23,6 +23,7 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public class PtpCommand implements TabExecutor {
@@ -76,10 +77,10 @@ public class PtpCommand implements TabExecutor {
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport();
long ptpLastUse = mcMMOPlayer.getPtpLastUse();
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
@@ -87,7 +88,7 @@ public class PtpCommand implements TabExecutor {
}
}
sendTeleportRequest(sender, player, args[0]);
sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
return true;
default:
@@ -102,7 +103,7 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
}
@@ -139,7 +140,6 @@ public class PtpCommand implements TabExecutor {
}
target = mcMMOTarget.getPlayer();
targetName = target.getName();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
@@ -196,6 +196,6 @@ public class PtpCommand implements TabExecutor {
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
mcMMOPlayer.actualizeRecentlyHurt();
mcMMOPlayer.actualizePtpLastUse();
}
}

View File

@@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -32,11 +33,12 @@ public class InspectCommand implements TabExecutor {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
String playerName = Misc.getMatchedPlayerName(args[0]);
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) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false); // Temporary Profile
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
return true;
@@ -47,7 +49,7 @@ public class InspectCommand implements TabExecutor {
return true;
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
@@ -103,7 +105,7 @@ public class InspectCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -14,10 +14,12 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class McrankCommand implements TabExecutor {
@@ -50,8 +52,8 @@ public class McrankCommand implements TabExecutor {
return true;
}
String playerName = args[0];
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName();
@@ -82,7 +84,7 @@ public class McrankCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayers().keySet();
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -13,6 +13,7 @@ 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 McstatsCommand implements TabExecutor {

View File

@@ -8,8 +8,8 @@ import com.gmail.nossr50.util.Permissions;
public class AxesCommand extends SkillCommand {
private String critChance;
private String critChanceLucky;
private float bonusDamage;
private float impactDamage;
private double bonusDamage;
private double impactDamage;
private String skullSplitterLength;
private String skullSplitterLengthEndurance;

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -36,7 +38,7 @@ public class TamingCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player);
canCallWild = Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
canFastFood = Permissions.fastFoodService(player);
canGore = Permissions.gore(player);

View File

@@ -14,7 +14,7 @@ public class UnarmedCommand extends SkillCommand {
private String disarmChanceLucky;
private String ironGripChance;
private String ironGripChanceLucky;
private int ironArmBonus;
private double ironArmBonus;
private boolean canBerserk;
private boolean canDisarm;

View File

@@ -10,6 +10,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
public class MchudCommand extends SpoutCommand {

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public class XplockCommand extends SpoutCommand {

View File

@@ -1,10 +1,14 @@
package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.List;
public class AdvancedConfig extends AutoUpdateConfigLoader {
private static AdvancedConfig instance;
private AdvancedConfig() {
super("advanced.yml");
validate();
}
public static AdvancedConfig getInstance() {
@@ -15,28 +19,785 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
return instance;
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
/* GENERAL */
if (getAbilityLength() < 1) {
reason.add("Skills.General.Ability_IncreaseLevel should be at least 1!");
}
if (getEnchantBuff() < 1) {
reason.add("Skills.General.Ability_EnchantBuff should be at least 1!");
}
/* ACROBATICS */
if (getDodgeChanceMax() < 1) {
reason.add("Skills.Acrobatics.Dodge_ChanceMax should be at least 1!");
}
if (getDodgeMaxBonusLevel() < 1) {
reason.add("Skills.Acrobatics.Dodge_MaxBonusLevel should be at least 1!");
}
if (getDodgeDamageModifier() <= 1) {
reason.add("Skills.Acrobatics.Dodge_DamageModifier should be greater than 1!");
}
if (getRollChanceMax() < 1) {
reason.add("Skills.Acrobatics.Roll_ChanceMax should be at least 1!");
}
if (getRollMaxBonusLevel() < 1) {
reason.add("Skills.Acrobatics.Roll_MaxBonusLevel should be at least 1!");
}
if (getRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.Roll_DamageThreshold should be at least 0!");
}
if (getGracefulRollChanceMax() < 1) {
reason.add("Skills.Acrobatics.GracefulRoll_ChanceMax should be at least 1!");
}
if (getGracefulRollMaxBonusLevel() < 1) {
reason.add("Skills.Acrobatics.GracefulRoll_MaxBonusLevel should be at least 1!");
}
if (getGracefulRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.GracefulRoll_DamageThreshold should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* ARCHERY */
if (getSkillShotIncreaseLevel() < 1) {
reason.add("Skills.Archery.SkillShot_IncreaseLevel should be at least 1!");
}
if (getSkillShotIncreasePercentage() <= 0) {
reason.add("Skills.Archery.SkillShot_IncreasePercentage should be greater than 0!");
}
if (getSkillShotBonusMax() < 0) {
reason.add("Skills.Archery.SkillShot_MaxBonus should be at least 0!");
}
if (getDazeBonusMax() < 1) {
reason.add("Skills.Acrobatics.Daze_MaxChance should be at least 1!");
}
if (getDazeMaxBonusLevel() < 1) {
reason.add("Skills.Acrobatics.Daze_MaxBonusLevel should be at least 1!");
}
if (getDazeModifier() < 0) {
reason.add("Skills.Acrobatics.Daze_BonusDamage should be at least 0!");
}
if (getRetrieveChanceMax() < 1) {
reason.add("Skills.Acrobatics.Retrieve_MaxBonus should be at least 1!");
}
if (getRetrieveMaxBonusLevel() < 1) {
reason.add("Skills.Acrobatics.Retrieve_MaxBonusLevel should be at least 1!");
}
if (getForceMultiplier() < 0) {
reason.add("Skills.Acrobatics.Force_Multiplier should be at least 0!");
}
/* AXES */
if (getBonusDamageAxesBonusMax() < 1) {
reason.add("Skills.Axes.DamageIncrease_MaxBonus should be at least 1!");
}
if (getBonusDamageAxesMaxBonusLevel() < 1) {
reason.add("Skills.Axes.DamageIncrease_MaxBonusLevel should be at least 1!");
}
if (getAxesCriticalChance() < 1) {
reason.add("Skills.Axes.AxesCritical_MaxChance should be at least 1!");
}
if (getAxesCriticalMaxBonusLevel() < 1) {
reason.add("Skills.Axes.AxesCritical_MaxBonusLevel should be at least 1!");
}
if (getAxesCriticalPVPModifier() < 1) {
reason.add("Skills.Axes.AxesCritical_PVP_Modifier should be at least 1!");
}
if (getAxesCriticalPVEModifier() < 1) {
reason.add("Skills.Axes.AxesCritical_PVE_Modifier should be at least 1!");
}
if (getGreaterImpactChance() < 1) {
reason.add("Skills.Axes.GreaterImpact_Chance should be at least 1!");
}
if (getGreaterImpactModifier() < 1) {
reason.add("Skills.Axes.GreaterImpact_KnockbackModifier should be at least 1!");
}
if (getGreaterImpactBonusDamage() < 1) {
reason.add("Skills.Axes.GreaterImpact_BonusDamage should be at least 1!");
}
if (getArmorImpactIncreaseLevel() < 1) {
reason.add("Skills.Axes.ArmorImpact_IncreaseLevel should be at least 1!");
}
if (getImpactChance() < 1) {
reason.add("Skills.Axes.ArmorImpact_Chance should be at least 1!");
}
if (getArmorImpactMaxDurabilityDamage() < 1) {
reason.add("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage should be at least 1!");
}
if (getSkullSplitterModifier() < 1) {
reason.add("Skills.Axes.SkullSplitter_DamagerModifier should be at least 1!");
}
/* FISHING */
if (getFishingTierLevelsTier1() >= getFishingTierLevelsTier2()) {
reason.add("Skills.Fishing.Tier_Levels.Tier1 should be less than Skills.Fishing.Tier_Levels.Tier2!");
}
if (getFishingTierLevelsTier2() >= getFishingTierLevelsTier3()) {
reason.add("Skills.Fishing.Tier_Levels.Tier2 should be less than Skills.Fishing.Tier_Levels.Tier3!");
}
if (getFishingTierLevelsTier3() >= getFishingTierLevelsTier4()) {
reason.add("Skills.Fishing.Tier_Levels.Tier3 should be less than Skills.Fishing.Tier_Levels.Tier4!");
}
if (getFishingTierLevelsTier4() >= getFishingTierLevelsTier5()) {
reason.add("Skills.Fishing.Tier_Levels.Tier4 should be less than Skills.Fishing.Tier_Levels.Tier5!");
}
if (getFishingMagicMultiplier() <= 0) {
reason.add("Skills.Fishing.MagicHunter_Multiplier should be greater than 0!");
}
if (getFishermanDietRankChange() < 1) {
reason.add("Skills.Fishing.Fisherman_Diet_RankChange should be at least 1!");
}
if (getIceFishingUnlockLevel() < 1) {
reason.add("Skills.Fishing.Ice_Fishing_UnlockLevel should be at least 1!");
}
if (getShakeUnlockLevel() < 1) {
reason.add("Skills.Fishing.Shake_UnlockLevel should be at least 1!");
}
if (getShakeChanceRank1() > getShakeChanceRank2()) {
reason.add("Skills.Fishing.Shake_Chance.Rank_1 should be less or equal to Skills.Fishing.Shake_Chance.Rank_2!");
}
if (getShakeChanceRank2() > getShakeChanceRank3()) {
reason.add("Skills.Fishing.Shake_Chance.Rank_2 should be less or equal to Skills.Fishing.Shake_Chance.Rank_3!");
}
if (getShakeChanceRank3() > getShakeChanceRank4()) {
reason.add("Skills.Fishing.Shake_Chance.Rank_3 should be less or equal to Skills.Fishing.Shake_Chance.Rank_4!");
}
if (getShakeChanceRank4() > getShakeChanceRank5()) {
reason.add("Skills.Fishing.Shake_Chance.Rank_4 should be less or equal to Skills.Fishing.Shake_Chance.Rank_5!");
}
if (getFishingVanillaXPModifierRank1() > getFishingVanillaXPModifierRank2()) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_1 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_2!");
}
if (getFishingVanillaXPModifierRank2() > getFishingVanillaXPModifierRank3()) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_2 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_3!");
}
if (getFishingVanillaXPModifierRank3() > getFishingVanillaXPModifierRank4()) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_3 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_4!");
}
if (getFishingVanillaXPModifierRank4() > getFishingVanillaXPModifierRank5()) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_4 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_5!");
}
if (getFishingVanillaXPModifierRank1() < 0) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_1 should be at least 0!");
}
if (getFishingVanillaXPModifierRank2() < 0) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_2 should be at least 0!");
}
if (getFishingVanillaXPModifierRank3() < 0) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_3 should be at least 0!");
}
if (getFishingVanillaXPModifierRank4() < 0) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_4 should be at least 0!");
}
if (getFishingVanillaXPModifierRank5() < 0) {
reason.add("Skills.Fishing.VanillaXPBoost.Rank_5 should be at least 0!");
}
/* HERBALISM */
if (getFarmerDietRankChange() < 1) {
reason.add("Skills.Herbalism.Farmer_Diet_RankChange should be at least 1!");
}
if (getGreenThumbStageChange() < 1) {
reason.add("Skills.Herbalism.GreenThumb_StageChange should be at least 1!");
}
if (getGreenThumbChanceMax() < 1) {
reason.add("Skills.Herbalism.GreenThumb_ChanceMax should be at least 1!");
}
if (getGreenThumbMaxLevel() < 1) {
reason.add("Skills.Herbalism.GreenThumb_MaxBonusLevel should be at least 1!");
}
if (getHerbalismDoubleDropsChanceMax() < 1) {
reason.add("Skills.Herbalism.DoubleDrops_ChanceMax should be at least 1!");
}
if (getHerbalismDoubleDropsMaxLevel() < 1) {
reason.add("Skills.Herbalism.DoubleDrops_MaxBonusLevel should be at least 1!");
}
if (getHylianLuckChanceMax() < 1) {
reason.add("Skills.Herbalism.HylianLuck_ChanceMax should be at least 1!");
}
if (getHylianLuckMaxLevel() < 1) {
reason.add("Skills.Herbalism.HylianLuck_MaxBonusLevel should be at least 1!");
}
if (getShroomThumbChanceMax() < 1) {
reason.add("Skills.Herbalism.ShroomThumb_ChanceMax should be at least 1!");
}
if (getShroomThumbMaxLevel() < 1) {
reason.add("Skills.Herbalism.ShroomThumb_MaxBonusLevel should be at least 1!");
}
/* MINING */
if (getMiningDoubleDropChance() < 1) {
reason.add("Skills.Mining.DoubleDrops_ChanceMax should be at least 1!");
}
if (getMiningDoubleDropMaxLevel() < 1) {
reason.add("Skills.Mining.DoubleDrops_MaxBonusLevel should be at least 1!");
}
if (getBlastMiningRank1() > getBlastMiningRank2()) {
reason.add("Skills.Mining.BlastMining_Rank1 should be less or equal to Skills.Mining.BlastMining_Rank2!");
}
if (getBlastMiningRank2() > getBlastMiningRank3()) {
reason.add("Skills.Mining.BlastMining_Rank2 should be less or equal to Skills.Mining.BlastMining_Rank3!");
}
if (getBlastMiningRank3() > getBlastMiningRank4()) {
reason.add("Skills.Mining.BlastMining_Rank3 should be less or equal to Skills.Mining.BlastMining_Rank4!");
}
if (getBlastMiningRank4() > getBlastMiningRank5()) {
reason.add("Skills.Mining.BlastMining_Rank4 should be less or equal to Skills.Mining.BlastMining_Rank5!");
}
if (getBlastMiningRank5() > getBlastMiningRank6()) {
reason.add("Skills.Mining.BlastMining_Rank5 should be less or equal to Skills.Mining.BlastMining_Rank6!");
}
if (getBlastMiningRank6() > getBlastMiningRank7()) {
reason.add("Skills.Mining.BlastMining_Rank6 should be less or equal to Skills.Mining.BlastMining_Rank7!");
}
if (getBlastMiningRank7() > getBlastMiningRank8()) {
reason.add("Skills.Mining.BlastMining_Rank7 should be less or equal to Skills.Mining.BlastMining_Rank8!");
}
if (getBlastDamageDecreaseRank1() > getBlastDamageDecreaseRank2()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank1 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank2!");
}
if (getBlastDamageDecreaseRank2() > getBlastDamageDecreaseRank3()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank2 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank3!");
}
if (getBlastDamageDecreaseRank3() > getBlastDamageDecreaseRank4()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank3 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank4!");
}
if (getBlastDamageDecreaseRank4() > getBlastDamageDecreaseRank5()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank4 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank5!");
}
if (getBlastDamageDecreaseRank5() > getBlastDamageDecreaseRank6()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank5 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank6!");
}
if (getBlastDamageDecreaseRank6() > getBlastDamageDecreaseRank7()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank6 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank7!");
}
if (getBlastDamageDecreaseRank7() > getBlastDamageDecreaseRank8()) {
reason.add("Skills.Mining.BlastDamageDecrease_Rank7 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank8!");
}
if (getOreBonusRank1() > getOreBonusRank2()) {
reason.add("Skills.Mining.OreBonus_Rank1 should be less or equal to Skills.Mining.OreBonus_Rank2!");
}
if (getOreBonusRank2() > getOreBonusRank3()) {
reason.add("Skills.Mining.OreBonus_Rank2 should be less or equal to Skills.Mining.OreBonus_Rank3!");
}
if (getOreBonusRank3() > getOreBonusRank4()) {
reason.add("Skills.Mining.OreBonus_Rank3 should be less or equal to Skills.Mining.OreBonus_Rank4!");
}
if (getOreBonusRank4() > getOreBonusRank5()) {
reason.add("Skills.Mining.OreBonus_Rank4 should be less or equal to Skills.Mining.OreBonus_Rank5!");
}
if (getOreBonusRank5() > getOreBonusRank6()) {
reason.add("Skills.Mining.OreBonus_Rank5 should be less or equal to Skills.Mining.OreBonus_Rank6!");
}
if (getOreBonusRank6() > getOreBonusRank7()) {
reason.add("Skills.Mining.OreBonus_Rank6 should be less or equal to Skills.Mining.OreBonus_Rank7!");
}
if (getOreBonusRank7() > getOreBonusRank8()) {
reason.add("Skills.Mining.OreBonus_Rank7 should be less or equal to Skills.Mining.OreBonus_Rank8!");
}
if (getDebrisReductionRank1() > getDebrisReductionRank2()) {
reason.add("Skills.Mining.DebrisReduction_Rank1 should be less or equal to Skills.Mining.DebrisReduction_Rank2!");
}
if (getDebrisReductionRank2() > getDebrisReductionRank3()) {
reason.add("Skills.Mining.DebrisReduction_Rank2 should be less or equal to Skills.Mining.DebrisReduction_Rank3!");
}
if (getDebrisReductionRank3() > getDebrisReductionRank4()) {
reason.add("Skills.Mining.DebrisReduction_Rank3 should be less or equal to Skills.Mining.DebrisReduction_Rank4!");
}
if (getDebrisReductionRank4() > getDebrisReductionRank5()) {
reason.add("Skills.Mining.DebrisReduction_Rank4 should be less or equal to Skills.Mining.DebrisReduction_Rank5!");
}
if (getDebrisReductionRank5() > getDebrisReductionRank6()) {
reason.add("Skills.Mining.DebrisReduction_Rank5 should be less or equal to Skills.Mining.DebrisReduction_Rank6!");
}
if (getDebrisReductionRank6() > getDebrisReductionRank7()) {
reason.add("Skills.Mining.DebrisReduction_Rank6 should be less or equal to Skills.Mining.DebrisReduction_Rank7!");
}
if (getDebrisReductionRank7() > getDebrisReductionRank8()) {
reason.add("Skills.Mining.DebrisReduction_Rank7 should be less or equal to Skills.Mining.DebrisReduction_Rank8!");
}
if (getDropMultiplierRank1() > getDropMultiplierRank2()) {
reason.add("Skills.Mining.DropMultiplier_Rank1 should be less or equal to Skills.Mining.DropMultiplier_Rank2!");
}
if (getDropMultiplierRank2() > getDropMultiplierRank3()) {
reason.add("Skills.Mining.DropMultiplier_Rank2 should be less or equal to Skills.Mining.DropMultiplier_Rank3!");
}
if (getDropMultiplierRank3() > getDropMultiplierRank4()) {
reason.add("Skills.Mining.DropMultiplier_Rank3 should be less or equal to Skills.Mining.DropMultiplier_Rank4!");
}
if (getDropMultiplierRank4() > getDropMultiplierRank5()) {
reason.add("Skills.Mining.DropMultiplier_Rank4 should be less or equal to Skills.Mining.DropMultiplier_Rank5!");
}
if (getDropMultiplierRank5() > getDropMultiplierRank6()) {
reason.add("Skills.Mining.DropMultiplier_Rank5 should be less or equal to Skills.Mining.DropMultiplier_Rank6!");
}
if (getDropMultiplierRank6() > getDropMultiplierRank7()) {
reason.add("Skills.Mining.DropMultiplier_Rank6 should be less or equal to Skills.Mining.DropMultiplier_Rank7!");
}
if (getDropMultiplierRank7() > getDropMultiplierRank8()) {
reason.add("Skills.Mining.DropMultiplier_Rank7 should be less or equal to Skills.Mining.DropMultiplier_Rank8!");
}
if (getBlastRadiusModifierRank1() > getBlastRadiusModifierRank2()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank1 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank2!");
}
if (getBlastRadiusModifierRank2() > getBlastRadiusModifierRank3()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank2 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank3!");
}
if (getBlastRadiusModifierRank3() > getBlastRadiusModifierRank4()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank3 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank4!");
}
if (getBlastRadiusModifierRank4() > getBlastRadiusModifierRank5()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank4 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank5!");
}
if (getBlastRadiusModifierRank5() > getBlastRadiusModifierRank6()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank5 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank6!");
}
if (getBlastRadiusModifierRank6() > getBlastRadiusModifierRank7()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank6 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank7!");
}
if (getBlastRadiusModifierRank7() > getBlastRadiusModifierRank8()) {
reason.add("Skills.Mining.BlastRadiusModifier_Rank7 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank8!");
}
/* REPAIR */
if (getRepairMasteryMaxBonus() < 1) {
reason.add("Skills.Repair.RepairMastery_MaxBonusPercentage should be at least 1!");
}
if (getRepairMasteryMaxLevel() < 1) {
reason.add("Skills.Repair.RepairMastery_MaxBonusLevel should be at least 1!");
}
if (getSuperRepairChanceMax() < 1) {
reason.add("Skills.Repair.SuperRepair_ChanceMax should be at least 1!");
}
if (getSuperRepairMaxLevel() < 1) {
reason.add("Skills.Repair.SuperRepair_MaxBonusLevel should be at least 1!");
}
if (getSalvageUnlockLevel() < 1) {
reason.add("Skills.Repair.Salvage_UnlockLevel should be at least 1!");
}
if (getArcaneForgingDowngradeChanceRank1() < 0 || getArcaneForgingDowngradeChanceRank1() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1 only accepts values from 0 to 100!");
}
if (getArcaneForgingDowngradeChanceRank2() < 0 || getArcaneForgingDowngradeChanceRank2() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2 only accepts values from 0 to 100!");
}
if (getArcaneForgingDowngradeChanceRank3() < 0 || getArcaneForgingDowngradeChanceRank3() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3 only accepts values from 0 to 100!");
}
if (getArcaneForgingDowngradeChanceRank4() < 0 || getArcaneForgingDowngradeChanceRank4() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4 only accepts values from 0 to 100!");
}
if (getArcaneForgingKeepEnchantsChanceRank1() < 0 || getArcaneForgingKeepEnchantsChanceRank1() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1 only accepts values from 0 to 100!");
}
if (getArcaneForgingKeepEnchantsChanceRank2() < 0 || getArcaneForgingKeepEnchantsChanceRank2() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2 only accepts values from 0 to 100!");
}
if (getArcaneForgingKeepEnchantsChanceRank3() < 0 || getArcaneForgingKeepEnchantsChanceRank3() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3 only accepts values from 0 to 100!");
}
if (getArcaneForgingKeepEnchantsChanceRank4() < 0 || getArcaneForgingKeepEnchantsChanceRank4() > 100) {
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4 only accepts values from 0 to 100!");
}
if (getArcaneForgingRankLevels1() < 0) {
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1 should be at least 0!");
}
if (getArcaneForgingRankLevels2() < 0) {
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2 should be at least 0!");
}
if (getArcaneForgingRankLevels3() < 0) {
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3 should be at least 0!");
}
if (getArcaneForgingRankLevels4() < 0) {
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4 should be at least 0!");
}
/* SMELTING */
if (getBurnModifierMaxLevel() < 1) {
reason.add("Skills.Smelting.FuelEfficiency_MaxBonusLevel should be at least 1!");
}
if (getBurnTimeMultiplier() < 1) {
reason.add("Skills.Smelting.FuelEfficiency_Multiplier should be at least 1!");
}
if (getSecondSmeltMaxLevel() < 1) {
reason.add("Skills.Smelting.SecondSmelt_MaxBonusLevel should be at least 1!");
}
if (getSecondSmeltMaxChance() < 1) {
reason.add("Skills.Smelting.SecondSmelt_MaxBonusChance should be at least 1!");
}
if (getFluxMiningUnlockLevel() < 1) {
reason.add("Skills.Smelting.FluxMining_UnlockLevel should be at least 1!");
}
if (getFluxMiningChance() < 1) {
reason.add("Skills.Smelting.FluxMining_Chance should be at least 1!");
}
if (getSmeltingVanillaXPBoostRank1Level() > getSmeltingVanillaXPBoostRank2Level()) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank1Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank2Level!");
}
if (getSmeltingVanillaXPBoostRank2Level() > getSmeltingVanillaXPBoostRank3Level()) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank2Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank3Level!");
}
if (getSmeltingVanillaXPBoostRank3Level() > getSmeltingVanillaXPBoostRank4Level()) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank3Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank4Level!");
}
if (getSmeltingVanillaXPBoostRank4Level() > getSmeltingVanillaXPBoostRank5Level()) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank4Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank5Level!");
}
if (getSmeltingVanillaXPBoostRank1Multiplier() < 1) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank1Multiplier should be at least 1!");
}
if (getSmeltingVanillaXPBoostRank2Multiplier() < 1) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank2Multiplier should be at least 1!");
}
if (getSmeltingVanillaXPBoostRank3Multiplier() < 1) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank3Multiplier should be at least 1!");
}
if (getSmeltingVanillaXPBoostRank4Multiplier() < 1) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank4Multiplier should be at least 1!");
}
if (getSmeltingVanillaXPBoostRank5Multiplier() < 1) {
reason.add("Skills.Smelting.VanillaXPBoost_Rank5Multiplier should be at least 1!");
}
/* SWORDS */
if (getBleedChanceMax() < 1) {
reason.add("Skills.Swords.Bleed_ChanceMax should be at least 1!");
}
if (getBleedMaxBonusLevel() < 1) {
reason.add("Skills.Swords.Bleed_MaxBonusLevel should be at least 1!");
}
if (getBleedMaxTicks() < 1) {
reason.add("Skills.Swords.Bleed_MaxTicks should be at least 1!");
}
if (getBleedMaxTicks() < getBleedBaseTicks()) {
reason.add("Skills.Swords.Bleed_MaxTicks should be at least Skills.Swords.Bleed_BaseTicks!");
}
if (getBleedBaseTicks() < 1) {
reason.add("Skills.Swords.Bleed_BaseTicks should be at least 1!");
}
if (getCounterChanceMax() < 1) {
reason.add("Skills.Swords.Counter_ChanceMax should be at least 1!");
}
if (getCounterMaxBonusLevel() < 1) {
reason.add("Skills.Swords.Counter_MaxBonusLevel should be at least 1!");
}
if (getCounterModifier() < 1) {
reason.add("Skills.Swords.Counter_DamageModifier should be at least 1!");
}
if (getSerratedStrikesModifier() < 1) {
reason.add("Skills.Swords.SerratedStrikes_DamageModifier should be at least 1!");
}
if (getSerratedStrikesTicks() < 1) {
reason.add("Skills.Swords.SerratedStrikes_BleedTicks should be at least 1!");
}
/* TAMING */
if (getGoreChanceMax() < 1) {
reason.add("Skills.Taming.Gore_ChanceMax should be at least 1!");
}
if (getGoreMaxBonusLevel() < 1) {
reason.add("Skills.Taming.Gore_MaxBonusLevel should be at least 1!");
}
if (getGoreBleedTicks() < 1) {
reason.add("Skills.Taming.Gore_BleedTicks should be at least 1!");
}
if (getGoreModifier() < 1) {
reason.add("Skills.Taming.Gore_Modifier should be at least 1!");
}
if (getFastFoodUnlock() < 1) {
reason.add("Skills.Taming.FastFood_UnlockLevel should be at least 1!");
}
if (getFastFoodChance() < 1) {
reason.add("Skills.Taming.FastFood_Chance should be at least 1!");
}
if (getEnviromentallyAwareUnlock() < 1) {
reason.add("Skills.Taming.EnvironmentallyAware_UnlockLevel should be at least 1!");
}
if (getThickFurUnlock() < 1) {
reason.add("Skills.Taming.ThickFur_UnlockLevel should be at least 1!");
}
if (getThickFurModifier() < 1) {
reason.add("Skills.Taming.ThickFur_Modifier should be at least 1!");
}
if (getHolyHoundUnlock() < 1) {
reason.add("Skills.Taming.HolyHound_UnlockLevel should be at least 1!");
}
if (getShockProofUnlock() < 1) {
reason.add("Skills.Taming.ShockProof_UnlockLevel should be at least 1!");
}
if (getShockProofModifier() < 1) {
reason.add("Skills.Taming.ShockProof_Modifier should be at least 1!");
}
if (getSharpenedClawsUnlock() < 1) {
reason.add("Skills.Taming.SharpenedClaws_UnlockLevel should be at least 1!");
}
if (getSharpenedClawsBonus() < 1) {
reason.add("Skills.Taming.SharpenedClaws_Bonus should be at least 1!");
}
/* UNARMED */
if (getDisarmChanceMax() < 1) {
reason.add("Skills.Unarmed.Disarm_ChanceMax should be at least 1!");
}
if (getDisarmMaxBonusLevel() < 1) {
reason.add("Skills.Unarmed.Disarm_MaxBonusLevel should be at least 1!");
}
if (getDeflectChanceMax() < 1) {
reason.add("Skills.Unarmed.Deflect_ChanceMax should be at least 1!");
}
if (getDeflectMaxBonusLevel() < 1) {
reason.add("Skills.Unarmed.Deflect_MaxBonusLevel should be at least 1!");
}
if (getIronGripChanceMax() < 1) {
reason.add("Skills.Unarmed.IronGrip_ChanceMax should be at least 1!");
}
if (getIronGripMaxBonusLevel() < 1) {
reason.add("Skills.Unarmed.IronGrip_MaxBonusLevel should be at least 1!");
}
if (getIronArmMinBonus() < 0) {
reason.add("Skills.Unarmed.IronArm_BonusMin should be at least 0!");
}
if (getIronArmMaxBonus() < 0) {
reason.add("Skills.Unarmed.IronArm_BonusMax should be at least 0!");
}
if (getIronArmMaxBonus() < getIronArmMinBonus()) {
reason.add("Skills.Unarmed.IronArm_BonusMax should be greater than or equal to Skills.Unarmed.IronArm_BonusMin!");
}
if (getIronArmIncreaseLevel() < 1) {
reason.add("Skills.Unarmed.IronArm_IncreaseLevel should be at least 1!");
}
/* WOODCUTTING */
if (getLeafBlowUnlockLevel() < 1) {
reason.add("Skills.Woodcutting.LeafBlower_UnlockLevel should be at least 1!");
}
if (getWoodcuttingDoubleDropChance() < 1) {
reason.add("Skills.Woodcutting.DoubleDrops_ChanceMax should be at least 1!");
}
if (getWoodcuttingDoubleDropMaxLevel() < 1) {
reason.add("Skills.Woodcutting.DoubleDrops_MaxBonusLevel should be at least 1!");
}
/* KRAKEN */
if (getKrakenTriesBeforeRelease() < 1) {
reason.add("Kraken.Tries_Before_Release should be at least 1!");
}
if (getKrakenHealth() < 1) {
reason.add("Kraken.Health should be at least 1!");
}
if (getKrakenAttackInterval() < 1) {
reason.add("Kraken.Attack_Interval_Seconds should be at least 1!");
}
if (getKrakenAttackDamage() < 1) {
reason.add("Kraken.Attack_Damage should be at least 1!");
}
return noErrorsInConfig(reason);
}
@Override
protected void loadKeys() {}
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
public int getEnchantBuff() {
int buff = config.getInt("Skills.General.Ability_EnchantBuff", 5);
return (buff <= 0) ? 1 : buff;
}
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
/* ACROBATICS */
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); }
public double getDodgeDamageModifier() { return config.getDouble("Skills.Acrobatics.Dodge_DamageModifier", 2.0D); }
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); }
public double getRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.Roll_DamageThreshold", 7.0D); }
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14.0D); }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
@@ -46,10 +807,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot_MaxBonus", 2.0D); }
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot_MaxDamage", 9.0D); }
public double getDazeBonusMax() { return config.getDouble("Skills.Archery.Daze_MaxChance", 50.0D); }
public int getDazeMaxBonusLevel() { return config.getInt("Skills.Archery.Daze_MaxBonusLevel", 1000); }
public int getDazeModifier() { return config.getInt("Skills.Archery.Daze_BonusDamage", 4); }
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze_BonusDamage", 4.0D); }
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
@@ -57,7 +819,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getForceMultiplier() { return config.getDouble("Skills.Archery.Force_Multiplier", 2.0D); }
/* AXES */
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
public double getBonusDamageAxesBonusMax() { return config.getDouble("Skills.Axes.DamageIncrease_MaxBonus", 4.0D); }
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
public double getAxesCriticalChance() { return config.getDouble("Skills.Axes.AxesCritical_MaxChance", 37.50D); }
@@ -66,14 +828,14 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getAxesCriticalPVEModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVE_Modifier", 2.0D); }
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact_Chance", 25.0D); }
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5D); }
public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact_BonusDamage", 2.0D); }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); }
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter_DamagerModifier", 2.0D); }
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml
@@ -85,7 +847,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getFishingTierLevelsTier4() { return config.getInt("Skills.Fishing.Tier_Levels.Tier4", 600); }
public int getFishingTierLevelsTier5() { return config.getInt("Skills.Fishing.Tier_Levels.Tier5", 800); }
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); }
public double getFishingMagicMultiplier() { return config.getDouble("Skills.Fishing.MagicHunter_Multiplier", 5.0D); }
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
@@ -93,11 +855,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* Shake */
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
public int getShakeChanceRank2() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_2", 40); }
public int getShakeChanceRank3() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_3", 55); }
public int getShakeChanceRank4() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_4", 60); }
public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); }
public double getShakeChanceRank1() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_1", 25.0D); }
public double getShakeChanceRank2() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_2", 40.0D); }
public double getShakeChanceRank3() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_3", 55.0D); }
public double getShakeChanceRank4() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_4", 60.0D); }
public double getShakeChanceRank5() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_5", 75.0D); }
/* Vanilla XP Boost */
public int getFishingVanillaXPModifierRank1() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_1", 1); }
@@ -189,15 +951,17 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* Arcane Forging */
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
public double getArcaneForgingDowngradeChanceRank1() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75.0D); }
public double getArcaneForgingDowngradeChanceRank2() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50.0D); }
public double getArcaneForgingDowngradeChanceRank3() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25.0D); }
public double getArcaneForgingDowngradeChanceRank4() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15.0D); }
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.May_Lose_Enchants", true); }
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
public double getArcaneForgingKeepEnchantsChanceRank1() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10.0D); }
public double getArcaneForgingKeepEnchantsChanceRank2() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20.0D); }
public double getArcaneForgingKeepEnchantsChanceRank3() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30.0D); }
public double getArcaneForgingKeepEnchantsChanceRank4() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40.0D); }
public int getArcaneForgingRankLevels1() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1", 100); }
public int getArcaneForgingRankLevels2() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2", 250); }
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
@@ -231,34 +995,35 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
public boolean getCounterRequiresBlock() { return config.getBoolean("Skills.Swords.Counter_RequiresBlock"); }
public double getCounterChanceMax() { return config.getDouble("Skills.Swords.Counter_ChanceMax", 30.0D); }
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); }
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
public double getCounterModifier() { return config.getDouble("Skills.Swords.Counter_DamageModifier", 2.0D); }
public int getSerratedStrikesModifier() { return config.getInt("Skills.Swords.SerratedStrikes_DamageModifier", 4); }
public double getSerratedStrikesModifier() { return config.getDouble("Skills.Swords.SerratedStrikes_DamageModifier", 4.0D); }
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
/* TAMING */
public double getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
public double getGoreChanceMax() { return config.getDouble("Skills.Taming.Gore_ChanceMax", 100.0D); }
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); }
public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore_BleedTicks", 2); }
public int getGoreModifier() { return config.getInt("Skills.Taming.Gore_Modifier", 2); }
public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore_Modifier", 2.0D); }
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFood_Chance", 50.0D); }
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur_Modifier", 2.0D); }
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); }
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof_Modifier", 6.0D); }
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws_UnlockLevel", 750); }
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws_Bonus", 2.0D); }
/* UNARMED */
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
@@ -270,7 +1035,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
public double getIronArmMinBonus() { return config.getDouble("Skills.Unarmed.IronArm_BonusMin", 3.0D); }
public double getIronArmMaxBonus() { return config.getDouble("Skills.Unarmed.IronArm_BonusMax", 8.0D); }
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
/* WOODCUTTING */
@@ -284,12 +1050,12 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
public int getKrakenHealth() { return config.getInt("Kraken.Health", 50); }
public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
public int getKrakenAttackDamage() { return config.getInt("Kraken.Attack_Damage", 1); }
public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
@@ -16,6 +18,7 @@ public class Config extends AutoUpdateConfigLoader {
private Config() {
super("config.yml");
validate();
}
public static Config getInstance() {
@@ -26,6 +29,148 @@ public class Config extends AutoUpdateConfigLoader {
return instance;
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
/* General Settings */
if (getSaveInterval() <= 0) {
reason.add("General.Save_Interval should be greater than 0!");
}
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Scoreboards */
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
reason.add("Scoreboards.Mcrank.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 (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
reason.add("Scoreboards.Mctop.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!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
}
/* Database Purging */
if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
}
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
}
/* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
}
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
}
if (getChimaeraItemId() < 1) {
reason.add("Items.Chimaera_Wing.Item_ID should be at least 1!");
}
/* Particles */
if (getLevelUpEffectsTier() < 1) {
reason.add("Particles.LevelUp_Tier should be at least 1!");
}
/* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) {
reason.add("Party.AutoKick_Interval should be at least -1!");
}
if (getAutoPartyKickTime() < 0) {
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
}
if (getPartyShareBonusBase() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
}
if (getPartyShareBonusIncrease() < 0) {
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
}
if (getPartyShareBonusCap() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
}
if (getPartyShareRange() <= 0) {
reason.add("Party.Sharing.Range should be greater than 0!");
}
/* Inspect command distance */
if (getInspectDistance() <= 0) {
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getTreeFellerThreshold() <= 0) {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getDetonatorItemID() < 1) {
reason.add("Skills.Mining.Detonator_ID should be at least 1!");
}
if (getRepairAnvilId() < 1) {
reason.add("Skills.Repair.Anvil_ID should be at least 1!");
}
if (getSalvageAnvilId() < 1) {
reason.add("Skills.Repair.Salvage_Anvil_ID should be at least 1!");
}
if (getRepairAnvilId() == getSalvageAnvilId()) {
reason.add("Cannot use the same item ID for Repair and Salvage anvils!");
}
if (getTamingCOTWWolfCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_Required should be at least 1!");
}
if (getTamingCOTWOcelotCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
}
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
}
return noErrorsInConfig(reason);
}
@Override
protected void loadKeys() {}
@@ -46,7 +191,11 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public String getPartyChatPrefix() { return config.getString("Commands.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.p.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
/* Mob Healthbar */
@@ -106,24 +255,24 @@ public class Config extends AutoUpdateConfigLoader {
str = String.valueOf(cfg.getInt(key));
}
if (str == "0") {
if (str.equals("0")) {
str = "No value set for '" + key + "'";
}
return str;
}
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
@@ -185,7 +334,6 @@ public class Config extends AutoUpdateConfigLoader {
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
/* Thresholds */
@@ -194,8 +342,6 @@ public class Config extends AutoUpdateConfigLoader {
/*
* SKILL SETTINGS
*/
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsDisabled(SkillType skill) {
@@ -216,9 +362,9 @@ public class Config extends AutoUpdateConfigLoader {
/* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Mining */
@@ -236,19 +382,13 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
/* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
@@ -272,27 +412,4 @@ public class Config extends AutoUpdateConfigLoader {
/* PVP & PVE Settings */
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience.Gains.Mobspawners.Multiplier", 0.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
}

View File

@@ -6,6 +6,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -90,4 +91,27 @@ public abstract class ConfigLoader {
}
}
}
protected boolean validateKeys() {
return true;
}
protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
protected void validate() {
if (validateKeys()) {
plugin.debug("No errors found in " + fileName + "!");
}
else {
plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
plugin.getServer().getPluginManager().disablePlugin(plugin);
plugin.noErrorsInConfigFiles = false;
}
}
}

View File

@@ -0,0 +1,198 @@
package com.gmail.nossr50.config.experience;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
}
if (getWitherSkeletonXP() < 0) {
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
}
/* Fishing */
if (getFishingBaseXP() <= 0) {
reason.add("Experience.Fishing.Base should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXPWolf() <= 0) {
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXPOcelot() <= 0) {
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
/* Woodcutting */
if (getWoodcuttingXPOak() <= 0) {
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
}
if (getWoodcuttingXPBirch() <= 0) {
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
}
if (getWoodcuttingXPSpruce() <= 0) {
reason.add("Experience.Woodcutting.Spruce should be greater than 0!");
}
if (getWoodcuttingXPJungle() <= 0) {
reason.add("Experience.Woodcutting.Jungle should be greater than 0!");
}
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Brown should be greater than 0!");
}
if (getWoodcuttingXPHugeRedMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Red should be greater than 0!");
}
return noErrorsInConfig(reason);
}
/*
* FORMULA SETTINGS
*/
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) +"_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
/* Materials */
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
/* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
}

View File

@@ -15,13 +15,15 @@ import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomToolConfig extends ConfigLoader {
private static CustomToolConfig instance;
private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();

View File

@@ -1,11 +1,11 @@
package com.gmail.nossr50.config.spout;
import org.getspout.spoutapi.keyboard.Keyboard;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import org.getspout.spoutapi.keyboard.Keyboard;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;

View File

@@ -5,7 +5,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -25,13 +24,14 @@ import com.gmail.nossr50.datatypes.treasure.Treasure;
public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
@@ -82,9 +82,7 @@ public class TreasureConfig extends ConfigLoader {
return;
}
Set<String> treasureConfigSet = treasureSection.getKeys(false);
for (String treasureName : treasureConfigSet) {
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
@@ -187,7 +185,7 @@ public class TreasureConfig extends ConfigLoader {
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
if (noErrorsInTreasure(reason)) {
if (noErrorsInConfig(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
treasures.put(treasureName, fTreasure);
}
@@ -211,7 +209,7 @@ public class TreasureConfig extends ConfigLoader {
reason.add("Invalid Mob: " + mobType);
}
if (noErrorsInTreasure(reason)) {
if (noErrorsInConfig(reason)) {
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
treasures.put(treasureName, sTreasure);
}
@@ -248,6 +246,10 @@ public class TreasureConfig extends ConfigLoader {
eTreasure.setDropsFromSoulSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
eTreasure.setDropsFromSnow();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
hTreasure.setDropsFromBushes();
}
@@ -268,10 +270,10 @@ public class TreasureConfig extends ConfigLoader {
reason.add("This cannot also be a shake drop.");
}
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
if (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, eTreasure);
}
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, hTreasure);
}
}
@@ -437,15 +439,11 @@ public class TreasureConfig extends ConfigLoader {
if (eTreasure.getDropsFromSoulSand()) {
excavationFromSoulSand.add(eTreasure);
}
if (eTreasure.getDropsFromSnow()) {
excavationFromSnow.add(eTreasure);
}
}
}
}
private boolean noErrorsInTreasure(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
}

View File

@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
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;
@@ -83,7 +84,14 @@ public interface DatabaseManager {
* Convert all users from this database to the provided database using
* {@link #saveUser(PlayerProfile)}.
*
* @param the DatabaseManager to save to
* @param destination The DatabaseManager to save to
*/
public void convertUsers(DatabaseManager destination);
/**
* Retrieve the type of database in use. Custom databases should return CUSTOM.
*
* @return The type of database
*/
public DatabaseType getDatabaseType();
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
public class DatabaseManagerFactory {
private static Class<? extends DatabaseManager> customManager = null;
@@ -10,20 +11,23 @@ public class DatabaseManagerFactory {
if (customManager != null) {
try {
return createCustomDatabaseManager(customManager);
} catch (Exception e) {
}
catch (Exception e) {
mcMMO.p.debug("Could not create custom database manager");
e.printStackTrace();
} catch (Throwable e) {
}
catch (Throwable e) {
mcMMO.p.debug("Failed to create custom database manager");
e.printStackTrace();
}
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
}
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager();
}
/**
* Sets the custom DatabaseManager class for McMMO to use. This should be
* Sets the custom DatabaseManager class for mcMMO to use. This should be
* called prior to mcMMO enabling.
* <p>
* The provided class must have an empty constructor, which is the one
@@ -33,7 +37,7 @@ public class DatabaseManagerFactory {
* stable. This method is subject to change and/or removal in future
* versions.
*
* @param man the DatabaseManager class to use
* @param clazz the DatabaseManager class to use
* @throws IllegalArgumentException if the provided class does not have
* an empty constructor
*/
@@ -41,7 +45,8 @@ public class DatabaseManagerFactory {
try {
clazz.getConstructor((Class<?>) null);
customManager = clazz;
} catch (Throwable e) {
}
catch (Throwable e) {
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
}
}
@@ -50,17 +55,21 @@ public class DatabaseManagerFactory {
return customManager;
}
// For data conversion purposes
public static DatabaseManager createDatabaseManager(DatabaseType type) {
switch (type) {
case FLATFILE:
return new FlatfileDatabaseManager();
public static FlatfileDatabaseManager createFlatfileDatabaseManager() {
return new FlatfileDatabaseManager();
}
public static SQLDatabaseManager createSQLDatabaseManager() {
return new SQLDatabaseManager();
case SQL:
return new SQLDatabaseManager();
default:
return null;
}
}
//TODO: Why is clazz never used here?
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
}
}

View File

@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -20,6 +21,7 @@ import org.bukkit.OfflinePlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
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.AbilityType;
@@ -102,7 +104,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().info("Purging old users...");
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
@@ -117,19 +118,33 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
String name = character[0];
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
boolean old = true;
if (player != null) {
old = (currentTime - player.getLastPlayed()) > PURGE_TIME;
long lastPlayed = 0;
boolean rewrite = false;
try {
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
}
catch (NumberFormatException e) {}
if (lastPlayed == 0) {
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
lastPlayed = player.getLastPlayed();
rewrite = true;
}
if (!old) {
writer.append(line).append("\r\n");
}
else {
if (currentTime - lastPlayed > PURGE_TIME) {
removedPlayers++;
Misc.profileCleanup(name);
}
else {
if (rewrite) {
// Rewrite their data with a valid time
character[37] = Long.toString(lastPlayed);
String newLine = org.apache.commons.lang.StringUtils.join(character, ":");
writer.append(newLine).append("\r\n");
}
else {
writer.append(line).append("\r\n");
}
}
}
// Write the new file
@@ -485,20 +500,12 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
try {
in = new BufferedReader(new FileReader(usersFilePath));
String line = "";
ArrayList<String> players = new ArrayList<String>();
while ((line = in.readLine()) != null) {
String[] data = line.split(":");
String playerName = data[0];
int powerLevel = 0;
// Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
if (players.contains(playerName)) {
continue;
}
players.add(playerName);
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
@@ -569,15 +576,83 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
in = new BufferedReader(new FileReader(usersFilePath));
StringBuilder writer = new StringBuilder();
String line = "";
HashSet<String> players = new HashSet<String>();
while ((line = in.readLine()) != null) {
// Length checks depend on last character being ':'
if (line.charAt(line.length() - 1) != ':') {
line = line + ":";
}
String[] character = line.split(":");
// Prevent the same player from being present multiple times
if (!players.add(character[0])) {
continue;
}
// If they're valid, rewrite them to the file.
if (character.length >= 37) {
if (character.length > 38) {
writer.append(line).append("\r\n");
} else {
// Placeholder, repair row if needed (I.E. when new skills are added and such)
}
else if (character.length < 33) {
// Before Version 1.0 - Drop
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
}
else {
String oldVersion = null;
StringBuilder newLine = new StringBuilder(line);
boolean announce = false;
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append("STANDARD").append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":");
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.2.00";
}
}
if (character.length <= 36) {
// Introduction of Blast Mining cooldowns
// Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.3.00";
}
}
if (character.length <= 37) {
// Making old-purge work with flatfile
// Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":");
announce = true; // TODO move this down
if (oldVersion == null) {
oldVersion = "1.4.00";
}
}
if (character.length <= 38) {
// Addition of mob healthbars
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
if (oldVersion == null) {
oldVersion = "1.4.06";
}
}
if (announce) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
writer.append(newLine).append("\r\n");
}
}
@@ -608,10 +683,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
private void tryClose(Closeable c) {
if (c == null) return;
if (c == null) {
return;
}
try {
c.close();
} catch (IOException e) {
}
catch (IOException e) {
e.printStackTrace();
}
}
@@ -716,4 +794,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
return skills;
}
public DatabaseType getDatabaseType() {
return DatabaseType.FLATFILE;
}
}

View File

@@ -17,6 +17,7 @@ import java.util.logging.Level;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.DatabaseUpdateType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
@@ -50,11 +51,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
private int reconnectAttempt = 0;
protected SQLDatabaseManager() {
checkConnected();
checkStructure();
}
public void purgePowerlessUsers() {
if (!checkConnected()) {
return;
}
mcMMO.p.getLogger().info("Purging powerless users...");
Collection<ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0").values();
@@ -71,6 +75,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public void purgeOldUsers() {
if (!checkConnected()) {
return;
}
long currentTime = System.currentTimeMillis();
mcMMO.p.getLogger().info("Purging old users...");
@@ -89,6 +97,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public boolean removeUser(String playerName) {
if (!checkConnected()) {
return false;
}
boolean success = update("DELETE FROM u, e, h, s, c " +
"USING " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
@@ -103,7 +115,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public void saveUser(PlayerProfile profile) {
checkConnected();
if (!checkConnected()) {
return;
}
int userId = readId(profile.getPlayerName());
if (userId == -1) {
newUser(profile.getPlayerName());
@@ -299,6 +314,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public void newUser(String playerName) {
if (!checkConnected()) {
return;
}
PreparedStatement statement = null;
try {
@@ -326,6 +345,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
if (!checkConnected()) {
return new PlayerProfile(playerName, false); // return fake profile if not connected
}
PreparedStatement statement = null;
try {
@@ -379,11 +402,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
// There is no such user
if (create) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
else {
return new PlayerProfile(playerName, false);
}
return new PlayerProfile(playerName, create);
}
// There is such a user
writeMissingRows(id);
@@ -392,6 +413,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public void convertUsers(DatabaseManager destination) {
if (!checkConnected()) {
return;
}
PreparedStatement statement = null;
try {
@@ -528,27 +553,31 @@ public final class SQLDatabaseManager implements DatabaseManager {
public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>();
Statement stmt = null;
try {
stmt = connection.createStatement();
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
while (result.next()) {
users.add(result.getString("user"));
if (checkConnected()) {
Statement stmt = null;
try {
stmt = connection.createStatement();
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
while (result.next()) {
users.add(result.getString("user"));
}
result.close();
}
result.close();
}
catch (SQLException e) {
printErrors(e);
}
finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
// Ignore
catch (SQLException e) {
printErrors(e);
}
finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
// Ignore
}
}
}
}
return users;
}
@@ -576,14 +605,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
connection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().info("Connection to MySQL failed!");
mcMMO.p.getLogger().severe("Connection to MySQL failed!");
printErrors(ex);
}
}
catch (ClassNotFoundException ex) {
connection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().info("MySQL database driver not found!");
mcMMO.p.getLogger().severe("MySQL database driver not found!");
}
}
}
@@ -592,6 +622,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Checks that the database structure is present and correct
*/
private void checkStructure() {
if (!checkConnected()) {
return;
}
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL,"
@@ -906,7 +940,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
/**
* Get the Integer. Only return first row / first field.
*
* @param sql SQL query to execute
* @param statement SQL query to execute
* @return the value in the first row / first field
*/
private int readInt(PreparedStatement statement) {
@@ -1185,4 +1219,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
}
public DatabaseType getDatabaseType() {
return DatabaseType.SQL;
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.chat;
package com.gmail.nossr50.datatypes.chat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.datatypes.database;
public enum DatabaseType {
FLATFILE,
SQL,
CUSTOM;
public static DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return FLATFILE;
}
else if (typeName.equalsIgnoreCase("mysql")) {
return SQL;
}
return CUSTOM;
}
}

View File

@@ -0,0 +1,16 @@
package com.gmail.nossr50.datatypes.experience;
public enum FormulaType {
LINEAR,
EXPONENTIAL,
UNKNOWN;
public static FormulaType getFormulaType(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
return UNKNOWN;
}
}
};

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.datatypes.party;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.StringUtils;
public enum ItemShareType {
LOOT,
@@ -30,4 +32,8 @@ public enum ItemShareType {
return null;
}
public String getLocaleString() {
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
}
}

View File

@@ -7,8 +7,6 @@ import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
public class Party {
private final LinkedHashSet<String> members = new LinkedHashSet<String>();
@@ -88,24 +86,10 @@ public class Party {
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<String>();
if (shareLootDrops) {
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Loot"));
}
if (shareMiningDrops) {
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Mining"));
}
if (shareHerbalismDrops) {
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Herbalism"));
}
if (shareWoodcuttingDrops) {
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Woodcutting"));
}
if (shareMiscDrops) {
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Misc"));
for (ItemShareType shareType : ItemShareType.values()) {
if (sharingDrops(shareType)) {
shareCategories.add(shareType.getLocaleString());
}
}
return shareCategories;

View File

@@ -0,0 +1,25 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.util.commands.CommandUtils;
public enum ShareMode {
NONE,
EQUAL,
RANDOM;
public static ShareMode getShareMode(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
if (string.equalsIgnoreCase("even")) {
return EQUAL;
}
else if (CommandUtils.shouldDisableToggle(string)) {
return NONE;
}
return null;
}
}
};

View File

@@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@@ -17,6 +18,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
@@ -63,6 +65,7 @@ public class McMMOPlayer {
private boolean ptpEnabled = true;
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
private long ptpTimeout;
private int ptpLastUse;
private boolean partyChatMode;
private boolean adminChatMode;
@@ -83,20 +86,17 @@ public class McMMOPlayer {
private int recentlyHurt;
private int respawnATS;
private int teleportLastUse;
private int teleportATS;
private int chimeraWingLastUse;
private Location teleportCommence;
private boolean isUsingUnarmed;
public McMMOPlayer(Player player) {
this(player, mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), true));
}
public McMMOPlayer(Player player, PlayerProfile profile) {
String playerName = player.getName();
this.player = player;
this.profile = profile;
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
party = PartyManager.getPlayerParty(playerName);
/*
@@ -314,16 +314,12 @@ public class McMMOPlayer {
* Teleportation cooldown & warmup
*/
public int getLastTeleport() {
return teleportLastUse;
public int getChimeraWingLastUse() {
return chimeraWingLastUse;
}
public void setLastTeleport(int value) {
teleportLastUse = value;
}
public void actualizeLastTeleport() {
teleportLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
public void actualizeChimeraWingLastUse() {
chimeraWingLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public Location getTeleportCommenceLocation() {
@@ -350,6 +346,14 @@ public class McMMOPlayer {
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public int getTeleportATS() {
return teleportATS;
}
public void actualizeTeleportATS() {
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
/*
* Repair Anvil Placement
*/
@@ -620,6 +624,14 @@ public class McMMOPlayer {
ptpConfirmRequired = !ptpConfirmRequired;
}
public int getPtpLastUse() {
return ptpLastUse;
}
public void actualizePtpLastUse() {
ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public long getPtpTimeout() {
return ptpTimeout;
}
@@ -684,7 +696,7 @@ public class McMMOPlayer {
return 0;
}
xp = (float) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier());
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
if (Config.getInstance().getToolModsEnabled()) {
CustomTool tool = ModUtils.getToolFromItemStack(player.getItemInHand());
@@ -694,6 +706,20 @@ public class McMMOPlayer {
}
}
return PerksUtils.handleXpPerks(player, xp);
return PerksUtils.handleXpPerks(player, xp, skillType);
}
public void checkGodMode() {
if (godMode && !Permissions.mcgod(player)) {
toggleGodMode();
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
}
}
public void checkParty() {
if (inParty() && !Permissions.party(player)) {
removeParty();
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
}
}

View File

@@ -8,17 +8,21 @@ import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
public class PlayerProfile {
private final String playerName;
private boolean loaded;
private boolean changed;
/* HUDs */
private HudType hudType;
@@ -69,7 +73,12 @@ public class PlayerProfile {
}
public void save() {
if (!changed) {
return;
}
mcMMO.getDatabaseManager().saveUser(this);
changed = false;
}
public String getPlayerName() {
@@ -147,6 +156,8 @@ public class PlayerProfile {
public void setSkillDATS(AbilityType abilityType, long DATS) {
int wearsOff = (int) (DATS * .001D);
changed = true;
skillsDATS.put(abilityType, wearsOff);
}
@@ -154,6 +165,8 @@ public class PlayerProfile {
* Reset all skill cooldowns.
*/
public void resetCooldowns() {
changed = true;
for (AbilityType ability : skillsDATS.keySet()) {
skillsDATS.put(ability, 0);
}
@@ -184,6 +197,8 @@ public class PlayerProfile {
return;
}
changed = true;
skillsXp.put(skillType, newValue);
}
@@ -202,6 +217,8 @@ public class PlayerProfile {
return;
}
changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
}
@@ -216,6 +233,8 @@ public class PlayerProfile {
return;
}
changed = true;
skills.put(skillType, newValue);
skillsXp.put(skillType, 0F);
}
@@ -231,6 +250,8 @@ public class PlayerProfile {
return;
}
changed = true;
skills.put(skillType, skills.get(skillType) + levels);
skillsXp.put(skillType, 0F);
}
@@ -246,17 +267,22 @@ public class PlayerProfile {
return;
}
changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) + experience);
}
/**
* Get the amount of Xp remaining before the next level.
* Get the total amount of Xp before the next level.
*
* @param skillType Type of skill to check
* @return the Xp remaining until next level
* @return the total amount of Xp until next level
*/
public int getXpToLevel(SkillType skillType) {
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(skillType);
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType);
}
private int getChildSkillLevel(SkillType skillType) {

View File

@@ -8,6 +8,7 @@ import org.bukkit.Color;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
@@ -25,6 +26,7 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public enum SkillType {
@@ -103,12 +105,20 @@ public enum SkillType {
return Config.getInstance().getDoubleDropsDisabled(this);
}
public boolean getHardcoreStatLossEnabled() {
return Config.getInstance().getHardcoreStatLossEnabled(this);
}
public boolean getHardcoreVampirismEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled(this);
}
public ToolType getTool() {
return tool;
}
public double getXpModifier() {
return Config.getInstance().getFormulaSkillModifier(this);
return ExperienceConfig.getInstance().getFormulaSkillModifier(this);
}
public static SkillType getSkill(String skillName) {

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.spout.huds;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
@@ -11,6 +10,8 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
import com.gmail.nossr50.datatypes.spout.popups.McMMOXpBar;
import org.getspout.spoutapi.SpoutManager;
public class McMMOHud {
private Player player;
private PlayerProfile profile;

View File

@@ -1,10 +1,5 @@
package com.gmail.nossr50.datatypes.spout.popups;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
@@ -13,6 +8,11 @@ import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.locale.LocaleLoader;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.player.SpoutPlayer;
public class McMMOMenu extends GenericPopup {
private McMMOButton hudButton;
private McMMOButton escapeButton;

View File

@@ -1,5 +1,12 @@
package com.gmail.nossr50.datatypes.spout.popups;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.StringUtils;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
@@ -8,13 +15,6 @@ import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.StringUtils;
public class McMMOXpBar {
private SpoutPlayer spoutPlayer;
private Widget xpBar;

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure {
// dirt | grass | sand | gravel | clay | mycel | soulsand
// dirt | grass | sand | gravel | clay | mycel | soulsand | snow
// 00000001 - dirt 1
// 00000010 - grass 2
// 00000100 - sand 4
@@ -11,6 +11,7 @@ public class ExcavationTreasure extends Treasure {
// 00010000 - clay 16
// 00100000 - mycel 32
// 01000000 - soulsand 64
// 10000000 - snow 128
private byte dropsFrom = 0x0;
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
@@ -55,6 +56,10 @@ public class ExcavationTreasure extends Treasure {
return getDropFromMask(64);
}
public boolean getDropsFromSnow() {
return getDropFromMask(128);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
@@ -88,6 +93,10 @@ public class ExcavationTreasure extends Treasure {
setDropFromMask(64);
}
public void setDropsFromSnow() {
setDropFromMask(128);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
@@ -121,6 +130,10 @@ public class ExcavationTreasure extends Treasure {
unsetDropFromMask(64);
}
public void unsetDropsFromSnow() {
unsetDropFromMask(128);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}

View File

@@ -0,0 +1,14 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
/**
* Called when a user levels change
*/
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill) {
super(player, skill);
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
/**
* Called when a user loses levels in a skill
*/
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
private int levelsLost;
public McMMOPlayerLevelDownEvent(Player player, SkillType skill) {
super(player, skill);
this.levelsLost = 1;
}
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost) {
super(player, skill);
this.levelsLost = levelsLost;
}
/**
* @param levelsLost Set the number of levels lost in this event
*/
public void setLevelsLost(int levelsLost) {
this.levelsLost = levelsLost;
}
/**
* @return The number of levels lost in this event
*/
public int getLevelsLost() {
return levelsLost;
}
}

View File

@@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
/**
* Called when a user levels up in a skill
*/
public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
private int levelsGained;
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
@@ -21,8 +21,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
}
/**
* @param levelsGained
* @return Set the number of levels gained in this event
* @param levelsGained Set the number of levels gained in this event
*/
public void setLevelsGained(int levelsGained) {
this.levelsGained = levelsGained;

View File

@@ -23,7 +23,7 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
}
/**
* @param xpGained int amount of experience gained in this event
* @return int amount of experience gained in this event
*/
@Deprecated
public int getXpGained() {

View File

@@ -7,7 +7,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
* Called when mcMMO applies damage from an entity due to special abilities.
*/
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
super(damager, damagee, cause, damage);
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
* Called when mcMMO applies damage due to special abilities.
*/
public class FakeEntityDamageEvent extends EntityDamageEvent {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
super(damagee, cause, damage);
}
}

View File

@@ -0,0 +1,38 @@
package com.gmail.nossr50.events.hardcore;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancellable {
private boolean cancelled;
public McMMOPlayerDeathPenaltyEvent(Player player) {
super(player);
this.cancelled = false;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** 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

@@ -34,6 +34,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
@@ -50,6 +51,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class EntityListener implements Listener {
private final mcMMO plugin;
@@ -124,7 +126,7 @@ public class EntityListener implements Listener {
return;
}
int damage = event.getDamage();
double damage = event.getDamage();
if (damage <= 0) {
return;
@@ -132,6 +134,11 @@ public class EntityListener implements Listener {
Entity defender = event.getEntity();
if (defender.hasMetadata(mcMMO.customDamageKey)) {
defender.removeMetadata(mcMMO.customDamageKey, plugin);
return;
}
if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return;
}
@@ -184,7 +191,7 @@ public class EntityListener implements Listener {
return;
}
int damage = event.getDamage();
double damage = event.getDamage();
if (damage <= 0) {
return;
@@ -192,7 +199,12 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity();
if (!(entity instanceof LivingEntity)) {
if (entity.hasMetadata(mcMMO.customDamageKey)) {
entity.removeMetadata(mcMMO.customDamageKey, plugin);
return;
}
if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
return;
}
@@ -206,11 +218,6 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (Misc.isNPCEntity(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
/* Check for invincibility */
@@ -221,6 +228,10 @@ public class EntityListener implements Listener {
switch (cause) {
case FALL:
if (!Config.getInstance().getPreventXPAfterTeleport() || SkillUtils.calculateTimeLeft((long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) {
return;
}
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canRoll()) {
@@ -338,12 +349,12 @@ public class EntityListener implements Listener {
if (entity.hasMetadata(mcMMO.customNameKey)) {
entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString());
entity.removeMetadata(mcMMO.customNameKey, mcMMO.p);
entity.removeMetadata(mcMMO.customNameKey, plugin);
}
if (entity.hasMetadata(mcMMO.customVisibleKey)) {
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
entity.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
entity.removeMetadata(mcMMO.customVisibleKey, plugin);
}
}
@@ -403,7 +414,7 @@ public class EntityListener implements Listener {
}
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (Misc.isNPCEntity(player)) {
return;
@@ -430,7 +441,7 @@ public class EntityListener implements Listener {
}
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (Misc.isNPCEntity(player)) {
return;

View File

@@ -6,7 +6,6 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -15,30 +14,29 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.chat.PartyChatManager;
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.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
@@ -68,6 +66,35 @@ public class PlayerListener implements Listener {
this.plugin = plugin;
}
/**
* Monitor PlayerTeleportEvents.
* <p>
* These events are monitored for the purpose of setting the
* player's last teleportation timestamp, in order to prevent
* possible Acrobatics exploitation.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
return;
}
UserManager.getPlayer(player).actualizeTeleportATS();
}
/**
* Handle PlayerDeathEvents at the lowest priority.
* <p>
* These events are used to modify the death message of a player when
* needed to correct issues potentially caused by the custom naming used
* for mob healthbars.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDeathLowest(PlayerDeathEvent event) {
String deathMessage = event.getDeathMessage();
@@ -76,39 +103,59 @@ public class PlayerListener implements Listener {
return;
}
event.setDeathMessage(MobHealthbarUtils.fixDeathMessage(deathMessage, event.getEntity()));
Player player = event.getEntity();
if (Misc.isNPCEntity(player)) {
return;
}
event.setDeathMessage(MobHealthbarUtils.fixDeathMessage(deathMessage, player));
}
/**
* Monitor PlayerDeath events.
* Monitor PlayerDeathEvents.
* <p>
* These events are monitored for the purpose of dealing the penalties
* associated with hardcore and vampirism modes. If neither of these
* modes are enabled, or if the player who died has hardcore bypass
* permissions, this handler does nothing.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeathMonitor(PlayerDeathEvent event) {
if (!Config.getInstance().getHardcoreEnabled()) {
boolean statLossEnabled = HardcoreManager.isStatLossEnabled();
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
if (!statLossEnabled && !vampirismEnabled) {
return;
}
Player player = event.getEntity();
Player killedPlayer = event.getEntity();
if (Misc.isNPCEntity(player) || Permissions.hardcoreBypass(player)) {
if (Misc.isNPCEntity(killedPlayer) || Permissions.hardcoreBypass(killedPlayer)) {
return;
}
Player killer = player.getKiller();
Player killer = killedPlayer.getKiller();
if (killer != null && Config.getInstance().getHardcoreVampirismEnabled()) {
HardcoreManager.invokeVampirism(killer, player);
if (killer != null && vampirismEnabled) {
HardcoreManager.invokeVampirism(killer, killedPlayer);
}
HardcoreManager.invokeStatPenalty(player);
if (statLossEnabled) {
HardcoreManager.invokeStatPenalty(killedPlayer);
}
}
/**
* Monitor PlayerChangedWorld events.
* Monitor PlayerChangedWorldEvents.
* <p>
* These events are monitored for the purpose of removing god mode or
* player parties if they are not allowed on the world the player has
* changed to.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
@@ -120,37 +167,41 @@ public class PlayerListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getGodMode() && !Permissions.mcgod(player)) {
mcMMOPlayer.toggleGodMode();
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
}
if (mcMMOPlayer.inParty() && !Permissions.party(player)) {
mcMMOPlayer.removeParty();
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
mcMMOPlayer.checkGodMode();
mcMMOPlayer.checkParty();
}
/**
* Handle PlayerDropItem events that involve modifying the event.
* Monitor PlayerDropItemEvents.
* <p>
* These events are monitored for the purpose of flagging sharable
* dropped items, as well as removing ability buffs from pickaxes
* and shovels.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack();
if (ItemUtils.isSharable(dropStack)) {
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
}
SkillUtils.removeAbilityBuff(dropStack);
}
/**
* Handle PlayerFishEvents at the highest priority.
* <p>
* These events are used for the purpose of handling our anti-exploit
* code, as well as dealing with ice fishing.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
Item drop = event.getItemDrop();
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
SkillUtils.removeAbilityBuff(drop.getItemStack());
}
/**
* Monitor PlayerFish events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
public void onPlayerFishHighest(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
@@ -163,59 +214,77 @@ public class PlayerListener implements Listener {
case FISHING:
if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention());
if (event.isCancelled()) {
return;
}
}
if (fishingManager.canMasterAngler()) {
fishingManager.masterAngler(event.getHook());
}
break;
return;
case CAUGHT_FISH:
fishingManager.handleFishing((Item) event.getCaught());
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
}
break;
case CAUGHT_ENTITY:
Entity entity = event.getCaught();
if (fishingManager.canShake(entity)) {
fishingManager.shakeCheck((LivingEntity) entity);
}
break;
return;
case IN_GROUND:
Fish hook = event.getHook();
Block block = event.getPlayer().getTargetBlock(null, 100);
Block block = player.getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player);
mcMMO.p.getServer().getPluginManager().callEvent(blockBreakEvent);
if (blockBreakEvent.isCancelled()) {
return;
}
event.setCancelled(true);
fishingManager.iceFishing(hook, block);
fishingManager.iceFishing(event.getHook(), block);
}
break;
return;
default:
break;
return;
}
}
/**
* Monitor PlayerPickupItem events.
* Monitor PlayerFishEvents.
* <p>
* These events are monitored for the purpose of handling the various
* Fishing skills and abilities.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
Entity caught = event.getCaught();
switch (event.getState()) {
case FISHING:
if (fishingManager.canMasterAngler()) {
fishingManager.masterAngler(event.getHook());
}
return;
case CAUGHT_FISH:
fishingManager.handleFishing((Item) caught);
return;
case CAUGHT_ENTITY:
if (fishingManager.canShake(caught)) {
fishingManager.shakeCheck((LivingEntity) caught);
}
return;
default:
return;
}
}
/**
* Handle PlayerPickupItemEvents at the highest priority.
* <p>
* These events are used to handle item sharing between party members and
* are also used to handle item pickup for the Unarmed skill.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
@@ -226,10 +295,11 @@ public class PlayerListener implements Listener {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack();
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isShareable(dropStack)) {
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (event.isCancelled()) {
@@ -238,7 +308,7 @@ public class PlayerListener implements Listener {
}
}
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isShareable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(Unarmed.handleItemPickup(player.getInventory(), drop));
if (event.isCancelled()) {
@@ -250,9 +320,13 @@ public class PlayerListener implements Listener {
}
/**
* Monitor PlayerQuit events.
* Monitor PlayerQuitEvents.
* <p>
* These events are monitored for the purpose of resetting player
* variables and other garbage collection tasks that must take place when
* a player exits the server.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
@@ -262,32 +336,22 @@ public class PlayerListener implements Listener {
return;
}
/* GARBAGE COLLECTION */
BleedTimerTask.bleedOut(player); // Bleed it out
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer.resetAbilityMode();
BleedTimerTask.bleedOut(player);
mcMMOPlayer.getProfile().save();
UserManager.remove(player.getName());
}
/**
* Start user data prefetch.
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLoginStart(PlayerLoginEvent event) {
UserManager.prefetchUserData(event.getPlayer().getName());
}
/**
* Cancel user data prefetch if a plugin kicks them.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
public void onLoginComplete(PlayerLoginEvent event) {
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
UserManager.discardPrefetch(event.getPlayer().getName());
}
}
/**
* Monitor PlayerJoin events.
* Monitor PlayerJoinEvents.
* <p>
* These events are monitored for the purpose of initializing player
* variables, as well as handling the MOTD display and other important
* join messages.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
@@ -305,7 +369,7 @@ public class PlayerListener implements Listener {
}
if (plugin.isXPEventEnabled()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", Config.getInstance().getExperienceGainsGlobalMultiplier()));
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
@@ -315,9 +379,13 @@ public class PlayerListener implements Listener {
}
/**
* Monitor PlayerRespawn events.
* Monitor PlayerRespawnEvents.
* <p>
* These events are monitored for the purpose of setting the
* player's last respawn timestamp, in order to prevent
* possible exploitation.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
@@ -331,34 +399,28 @@ public class PlayerListener implements Listener {
}
/**
* Handle PlayerInteract events that involve modifying the event.
* Handle PlayerInteractEvents at the lowest priority.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractLowest(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
ItemStack heldItem = player.getItemInHand();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
// This shouldn't be possible - this is probably a band-aid for a larger issue somewhere else.
if (mcMMOPlayer == null) {
return;
}
MiningManager miningManager = mcMMOPlayer.getMiningManager();
Block block = event.getClickedBlock();
ItemStack heldItem = player.getItemInHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
int blockID = block.getTypeId();
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
@@ -384,7 +446,7 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
else if (miningManager.canDetonate()) {
if (blockID == Material.TNT.getId()) {
if (block.getType() == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
}
else {
@@ -422,39 +484,26 @@ public class PlayerListener implements Listener {
break;
case RIGHT_CLICK_AIR:
/* BLAST MINING CHECK */
if (miningManager.canDetonate()) {
miningManager.remoteDetonation();
}
break;
default:
break;
}
}
/**
* Monitor PlayerInteract events.
* Monitor PlayerInteractEvents.
*
* @param event The event to watch
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
ItemStack heldItem = player.getItemInHand();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
// This shouldn't be possible - this is probably a band-aid for a larger issue somewhere else.
if (mcMMOPlayer == null) {
return;
}
ItemStack heldItem = player.getItemInHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
@@ -514,22 +563,40 @@ public class PlayerListener implements Listener {
/* ITEM CHECKS */
ChimaeraWing.activationCheck(player);
/* BLAST MINING CHECK */
MiningManager miningManager = mcMMOPlayer.getMiningManager();
if (miningManager.canDetonate()) {
miningManager.remoteDetonation();
}
break;
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && Permissions.callOfTheWild(player)) {
Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (!player.isSneaking()) {
break;
}
if (type == Material.RAW_FISH) {
tamingManager.summonOcelot();
}
else if (type == Material.BONE) {
/* CALL OF THE WILD CHECKS */
Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
switch (type) {
case APPLE:
tamingManager.summonHorse();
break;
case BONE:
tamingManager.summonWolf();
}
break;
case RAW_FISH:
tamingManager.summonOcelot();
break;
default:
break;
}
break;
@@ -540,7 +607,7 @@ public class PlayerListener implements Listener {
}
/**
* Monitor PlayerChat events.
* Handle PlayerChatEvents at high priority.
*
* @param event The event to watch
*/
@@ -553,12 +620,6 @@ public class PlayerListener implements Listener {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
mcMMO.p.debug(player.getName() + " is currently chatting, but has never logged on to the server.");
return;
}
ChatManager chatManager = null;
if (mcMMOPlayer.getPartyChatMode()) {

View File

@@ -3,13 +3,6 @@ package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.Button;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -19,6 +12,14 @@ import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.Button;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
public class SpoutListener implements Listener {
/**

View File

@@ -46,17 +46,19 @@ public final class LocaleLoader {
}
private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException {
String output = bundle.getString(key);
return formatString(bundle.getString(key), messageArguments);
}
public static String formatString(String string, Object... messageArguments) {
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
formatter.applyPattern(string);
string = formatter.format(messageArguments);
}
output = addColors(output);
string = addColors(string);
return output;
return string;
}
public static Locale getCurrentLocale() {

View File

@@ -5,8 +5,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.metadata.FixedMetadataValue;
@@ -51,14 +49,18 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.spout.SpoutUtils;
import net.shatteredlands.shatt.backup.ZipLibrary;
public class mcMMO extends JavaPlugin {
/* Managers */
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
/* File Paths */
private static String mainDirectory;
@@ -78,6 +80,9 @@ public class mcMMO extends JavaPlugin {
private static boolean spoutEnabled;
private static boolean combatTagEnabled;
// Config Validation Check
public boolean noErrorsInConfigFiles = true;
// XP Event Check
private boolean xpEventEnabled;
@@ -92,6 +97,7 @@ public class mcMMO extends JavaPlugin {
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
public final static String bowForceKey = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
public final static String customDamageKey = "mcMMO: Custom Damage";
public static FixedMetadataValue metadataValue;
@@ -109,6 +115,10 @@ public class mcMMO extends JavaPlugin {
setupSpout();
loadConfigFiles();
if (!noErrorsInConfigFiles) {
return;
}
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
databaseManager = DatabaseManagerFactory.getDatabaseManager();
@@ -118,6 +128,8 @@ public class mcMMO extends JavaPlugin {
PartyManager.loadParties();
formulaManager = new FormulaManager();
for (Player player : getServer().getOnlinePlayers()) {
UserManager.addUser(player); // In case of reload add all users back into UserManager
}
@@ -159,6 +171,7 @@ public class mcMMO extends JavaPlugin {
try {
UserManager.saveAll(); // Make sure to save player information if the server shuts down
PartyManager.saveParties(); // Save our parties
formulaManager.saveFormula();
placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores
}
@@ -225,6 +238,10 @@ public class mcMMO extends JavaPlugin {
getLogger().info("[Debug] " + message);
}
public static FormulaManager getFormulaManager() {
return formulaManager;
}
public static ChunkManager getPlaceStore() {
return placeStore;
}
@@ -307,11 +324,6 @@ public class mcMMO extends JavaPlugin {
repairables.addAll(rManager.getLoadedRepairables());
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
repairableManager.registerRepairables(repairables);
// Check if Repair Anvil and Salvage Anvil have different itemID's
if (Config.getInstance().getSalvageAnvilId() == Config.getInstance().getRepairAnvilId()) {
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
}
}
private void setupSpout() {

View File

@@ -8,7 +8,10 @@ import java.util.Locale;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.turt2live.metrics.EMetrics;
import com.turt2live.metrics.Metrics;
import com.turt2live.metrics.Metrics.Graph;
@@ -176,10 +179,20 @@ public class MetricsManager {
}
});
// ExperienceFormulaShape Graph
Graph experienceFormulaShapeGraph = metrics.createGraph("Experience Formula Shape Graph");
experienceFormulaShapeGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getFormulaType().toString()) {
@Override
public int getValue() {
return 1;
}
});
// GlobalMultiplier Graph
Graph globalMultiplierGraph = metrics.createGraph("Global Multiplier Graph");
globalMultiplierGraph.addPlotter(new Metrics.Plotter(Config.getInstance().getExperienceGainsGlobalMultiplier() + "") {
globalMultiplierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() + "") {
@Override
public int getValue() {
return 1;
@@ -189,7 +202,7 @@ public class MetricsManager {
// GlobalCurveModifier Graph
Graph globalCurveModifierGraph = metrics.createGraph("Global Curve Modifier Graph");
globalCurveModifierGraph.addPlotter(new Metrics.Plotter(Config.getInstance().getFormulaMultiplierCurve() + "") {
globalCurveModifierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) + "") {
@Override
public int getValue() {
return 1;
@@ -199,7 +212,7 @@ public class MetricsManager {
// GlobalMultiplierGraph Fuzzy Logic Numbers
Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz");
if (Config.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) {
if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) {
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
@Override
public int getValue() {
@@ -207,7 +220,7 @@ public class MetricsManager {
}
});
}
else if (Config.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) {
else if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) {
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
@Override
public int getValue() {
@@ -227,7 +240,7 @@ public class MetricsManager {
// GlobalCurveModifier Fuzzy Logic Numbers
Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz");
if (Config.getInstance().getFormulaMultiplierCurve() > 20.0) {
if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) > 20.0) {
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
@Override
public int getValue() {
@@ -235,7 +248,7 @@ public class MetricsManager {
}
});
}
else if (Config.getInstance().getFormulaMultiplierCurve() < 20.0) {
else if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) < 20.0) {
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
@Override
public int getValue() {

View File

@@ -10,7 +10,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
@@ -25,8 +28,15 @@ public final class PartyManager {
private PartyManager() {}
public static boolean checkPartyExistence(Player player, Party party, String partyName) {
if (party == null) {
/**
* Check if a party with a given name already exists.
*
* @param player The player to notify
* @param partyName The name of the party to check
* @return true if a party with that name exists, false otherwise
*/
public static boolean checkPartyExistence(Player player, String partyName) {
if (getParty(partyName) == null) {
return false;
}
@@ -34,13 +44,24 @@ public final class PartyManager {
return true;
}
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, Player player, Party oldParty, String newPartyName) {
/**
* Attempt to change parties or join a new party.
*
* @param mcMMOPlayer The player changing or joining parties
* @param newPartyName The name of the party being joined
* @return true if the party was joined successfully, false otherwise
*/
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
Player player = mcMMOPlayer.getPlayer();
if (mcMMOPlayer.inParty()) {
Party oldParty = mcMMOPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false;
}
removeFromParty(player, oldParty);
removeFromParty(mcMMOPlayer);
}
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
return false;
@@ -57,31 +78,30 @@ public final class PartyManager {
* @return true if they are in the same party, false otherwise
*/
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer);
McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
if (firstMcMMOPlayer == null || secondMcMMOPlayer == null) {
if (firstParty == null || secondParty == null) {
return false;
}
if (firstMcMMOPlayer.getParty() == null || secondMcMMOPlayer.getParty() == null) {
return false;
}
return firstMcMMOPlayer.getParty().equals(secondMcMMOPlayer.getParty());
return firstParty.equals(secondParty);
}
/**
* Get the near party members.
*
* @param player The player to check
* @param range The distance
* @param mcMMOPlayer The player to check
* @return the near party members
*/
public static List<Player> getNearMembers(Player player, Party party, double range) {
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = new ArrayList<Player>();
Party party = mcMMOPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member);
@@ -99,9 +119,9 @@ public final class PartyManager {
* @return all the players in the player's party
*/
public static LinkedHashSet<String> getAllMembers(Player player) {
Party party = getPlayerParty(player.getName());
Party party = getParty(player);
return party == null ? null : party.getMembers();
return party == null ? new LinkedHashSet<String>() : party.getMembers();
}
/**
@@ -121,11 +141,11 @@ public final class PartyManager {
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(Player player) {
return getOnlineMembers(getPlayerParty(player.getName()));
return getOnlineMembers(getParty(player));
}
private static List<Player> getOnlineMembers(Party party) {
return party == null ? null : party.getOnlineMembers();
return party == null ? new ArrayList<Player>() : party.getOnlineMembers();
}
/**
@@ -145,23 +165,37 @@ public final class PartyManager {
}
/**
* Retrieve a party by a member name
* Retrieve a party by a members name
*
* @param playerName The member name
* @param playerName The members name
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName) {
for (Party party : parties) {
for (String memberName : party.getMembers()) {
if (memberName.equalsIgnoreCase(playerName)) {
return party;
}
if (party.getMembers().contains(playerName)) {
return party;
}
}
return null;
}
/**
* Retrieve a party by member
*
* @param player The member
* @return the existing party, null otherwise
*/
public static Party getParty(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer != null) {
return mcMMOPlayer.getParty();
}
return getPlayerParty(player.getName());
}
/**
* Get a list of all current parties.
*
@@ -189,14 +223,21 @@ public final class PartyManager {
else {
// If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equalsIgnoreCase(playerName)) {
String newLeader = members.iterator().next();
party.setLeader(newLeader);
setPartyLeader(members.iterator().next(), party);
}
informPartyMembersQuit(party, playerName);
}
}
processPartyLeaving(UserManager.getPlayer(player));
/**
* Remove a player from a party.
*
* @param mcMMOPlayer The player to remove
*/
public static void removeFromParty(McMMOPlayer mcMMOPlayer) {
removeFromParty(mcMMOPlayer.getPlayer(), mcMMOPlayer.getParty());
processPartyLeaving(mcMMOPlayer);
}
/**
@@ -215,23 +256,15 @@ public final class PartyManager {
/**
* Create a new party
*
* @param player The player to add to the party
* @param mcMMOPlayer The player to add to the party
* @param partyName The party to add the player to
* @param password The password for this party, null if there was no password
*/
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
partyName = partyName.replace(".", "");
Party party = getParty(partyName);
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
Player player = mcMMOPlayer.getPlayer();
String playerName = player.getName();
if (party != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists"));
return;
}
party = new Party(playerName, partyName, password);
Party party = new Party(playerName, partyName.replace(".", ""), password);
if (password != null) {
player.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
@@ -240,24 +273,7 @@ public final class PartyManager {
parties.add(party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
addToParty(playerName, mcMMOPlayer, party);
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param mcMMOPlayer The player to add to the party
* @param party The party to add the player to
* @param password the password for this party, null if there was no password
*/
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, Party party, String password) {
if (!checkPartyPassword(player, party, password) || mcMMOPlayer.getParty() == party) {
return;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
addToParty(player.getName(), mcMMOPlayer, party);
addToParty(mcMMOPlayer, party);
}
/**
@@ -269,67 +285,57 @@ public final class PartyManager {
* @return true if the player can join the party
*/
public static boolean checkPartyPassword(Player player, Party party, String password) {
if (!party.isLocked()) {
return true;
if (party.isLocked()) {
String partyPassword = party.getPassword();
if (partyPassword == null) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return false;
}
if (password == null) {
player.sendMessage(LocaleLoader.getString("Party.Password.None"));
return false;
}
if (!password.equals(partyPassword)) {
player.sendMessage(LocaleLoader.getString("Party.Password.Incorrect"));
return false;
}
}
String partyPassword = party.getPassword();
if (partyPassword == null) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return false;
}
if (password == null) {
player.sendMessage(LocaleLoader.getString("Party.Password.None"));
return false;
}
else if (!password.equals(partyPassword)) {
player.sendMessage(LocaleLoader.getString("Party.Password.Incorrect"));
return false;
}
else {
return true;
}
return true;
}
/**
* Accept a party invitation
*
* @param Player The plaer to add to the party
* @param mcMMOPlayer The player to add to the party
*/
public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) {
public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) {
Party invite = mcMMOPlayer.getPartyInvite();
if (mcMMOPlayer.getParty() == invite) {
return;
}
// // Pretty sure this isn't possible
// if (!parties.contains(invite)) {
// parties.add(invite);
// }
if (!parties.contains(invite)) {
parties.add(invite);
}
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
mcMMOPlayer.removePartyInvite();
addToParty(player.getName(), mcMMOPlayer, invite);
addToParty(mcMMOPlayer, invite);
}
/**
* Add a player to a party
*
* @param player The player to add to a party
* @param mcMMOPlayer The player to add to the party
* @param party The party
*/
public static void addToParty(String playerName, McMMOPlayer mcMMOPlayer, Party party) {
if (mcMMOPlayer.getParty() == party) {
return;
}
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
String playerName = mcMMOPlayer.getPlayer().getName();
informPartyMembersJoin(party, playerName);
mcMMOPlayer.setParty(party);
party.getMembers().add(playerName);
}
@@ -342,11 +348,7 @@ public final class PartyManager {
public static String getPartyLeader(String partyName) {
Party party = getParty(partyName);
if (party == null) {
return null;
}
return party.getLeader();
return party == null ? null : party.getLeader();
}
/**
@@ -359,10 +361,12 @@ public final class PartyManager {
String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) {
if (member.getName().equalsIgnoreCase(playerName)) {
String memberName = member.getName();
if (memberName.equalsIgnoreCase(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
}
else if (member.getName().equalsIgnoreCase(leaderName)) {
else if (memberName.equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
}
else {
@@ -376,12 +380,12 @@ public final class PartyManager {
/**
* Check if a player can invite others to his party.
*
* @param player The player to check
* @param mcMMOPlayer The player to check
* @return true if the player can invite
*/
public static boolean canInvite(Player player, Party party) {
return !(party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName()));
public static boolean canInvite(McMMOPlayer mcMMOPlayer) {
Party party = mcMMOPlayer.getParty();
return !party.isLocked() || party.getLeader().equalsIgnoreCase(mcMMOPlayer.getPlayer().getName());
}
/**
@@ -410,8 +414,12 @@ public final class PartyManager {
party.setLeader(partiesFile.getString(partyName + ".Leader"));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.setXpShareMode(ShareHandler.ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
party.setItemShareMode(ShareHandler.ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
for (ItemShareType itemShareType : ItemShareType.values()) {
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
}
List<String> memberNames = partiesFile.getStringList(partyName + ".Members");
LinkedHashSet<String> members = party.getMembers();
@@ -443,6 +451,10 @@ public final class PartyManager {
partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString());
for (ItemShareType itemShareType : ItemShareType.values()) {
partiesFile.set(partyName + ".ItemShareType." + itemShareType.toString(), party.sharingDrops(itemShareType));
}
List<String> memberNames = new ArrayList<String>();
for (String member : party.getMembers()) {
@@ -478,6 +490,17 @@ public final class PartyManager {
return !event.isCancelled();
}
/**
* Remove party data from the mcMMOPlayer.
*
* @param mcMMOPlayer The player to remove party data from.
*/
public static void processPartyLeaving(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
/**
* Notify party members when a player joins.
*
@@ -501,14 +524,4 @@ public final class PartyManager {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
}
}
private static void processPartyLeaving(McMMOPlayer mcMMOPlayer) {
if (mcMMOPlayer == null) {
return;
}
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
}

View File

@@ -10,40 +10,15 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public final class ShareHandler {
public enum ShareMode {
NONE,
EQUAL,
RANDOM;
public static ShareMode getShareMode(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
if (string.equalsIgnoreCase("even")) {
return EQUAL;
}
else if (CommandUtils.shouldDisableToggle(string)) {
return NONE;
}
return null;
}
}
};
private ShareHandler() {}
private static List<Player> nearMembers;
private static int partySize;
/**
* Distribute Xp amongst party members.
*
@@ -55,36 +30,33 @@ public final class ShareHandler {
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
Party party = mcMMOPlayer.getParty();
switch (party.getXpShareMode()) {
case EQUAL:
Player player = mcMMOPlayer.getPlayer();
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
}
double partySize = nearMembers.size() + 1;
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + partySize * Config.getInstance().getPartyShareBonusIncrease(), Config.getInstance().getPartyShareBonusCap());
float splitXp = (float) (xp / partySize * shareBonus);
for (Player member : nearMembers) {
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
}
mcMMOPlayer.beginUnsharedXpGain(skillType, splitXp);
return true;
case NONE:
default:
return false;
if (party.getXpShareMode() != ShareMode.EQUAL) {
return false;
}
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
if (nearMembers.isEmpty()) {
return false;
}
nearMembers.add(mcMMOPlayer.getPlayer());
int partySize = nearMembers.size();
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap());
float splitXp = (float) (xp / partySize * shareBonus);
for (Player member : nearMembers) {
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
}
return true;
}
/**
* Distribute Items amongst party members.
*
* @param item Item that will get shared
* @param drop Item that will get shared
* @param mcMMOPlayer Player who picked up the item
* @return True if the item has been shared
*/
@@ -108,9 +80,7 @@ public final class ShareHandler {
return false;
}
Player player = mcMMOPlayer.getPlayer();
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
if (nearMembers.isEmpty()) {
return false;
@@ -119,8 +89,8 @@ public final class ShareHandler {
Player winningPlayer = null;
ItemStack newStack = itemStack.clone();
nearMembers.add(player);
partySize = nearMembers.size();
nearMembers.add(mcMMOPlayer.getPlayer());
int partySize = nearMembers.size();
drop.remove();
newStack.setAmount(1);

View File

@@ -20,7 +20,7 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
@Override
public void run() {
if (target.isValid()) {
if (target != null && target.isValid()) {
target.setCustomNameVisible(oldNameVisible);
target.setCustomName(oldName);
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);

View File

@@ -14,8 +14,8 @@ public class SaveTimerTask extends BukkitRunnable {
// All player data will be saved periodically through this
int count = 1;
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
new PlayerProfileSaveTask(mcMMOPlayer).runTaskLater(mcMMO.p, count);
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
new PlayerProfileSaveTask(mcMMOPlayer.getProfile()).runTaskLater(mcMMO.p, count);
count++;
}

View File

@@ -25,7 +25,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
@Override
public void run() {
Player player = mcMMO.p.getServer().getPlayer(playerName);
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
Integer rank;
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));

View File

@@ -1,41 +0,0 @@
package com.gmail.nossr50.runnables.database;
import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.locale.LocaleLoader;
public class ConversionTask extends BukkitRunnable {
private final DatabaseManager sourceDb;
private final CommandSender sender;
private final String message;
public ConversionTask(DatabaseManager from, CommandSender sendback, String oldType, String newType) {
sourceDb = from;
sender = sendback;
message = LocaleLoader.getString("Commands.mmoupdate.Finish", oldType, newType);
}
@Override
public void run() {
sourceDb.convertUsers(mcMMO.getDatabaseManager());
// Announce completeness
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new CompleteAnnouncement());
}
public class CompleteAnnouncement implements Runnable {
@Override
public void run() {
try {
sender.sendMessage(message);
} catch (Exception e) {
mcMMO.p.getLogger().log(Level.WARNING, "Exception sending database conversion completion message to " + sender.getName(), e);
}
}
}
}

View File

@@ -0,0 +1,32 @@
package com.gmail.nossr50.runnables.database;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.locale.LocaleLoader;
public class DatabaseConversionTask extends BukkitRunnable {
private final DatabaseManager sourceDatabase;
private final CommandSender sender;
private final String message;
public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) {
this.sourceDatabase = sourceDatabase;
this.sender = sender;
message = LocaleLoader.getString("Commands.mcconvert.Database.Finish", oldType, newType);
}
@Override
public void run() {
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() {
@Override
public void run() {
sender.sendMessage(message);
}
});
}
}

View File

@@ -0,0 +1,84 @@
package com.gmail.nossr50.runnables.database;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
public class FormulaConversionTask extends BukkitRunnable {
private CommandSender sender;
private FormulaType formulaType;
public FormulaConversionTask(CommandSender sender, FormulaType formulaType) {
this.sender = sender;
this.formulaType = formulaType;
}
@Override
public void run() {
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
PlayerProfile profile;
// 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);
if (!profile.isLoaded()) {
mcMMO.p.debug("Profile not loaded.");
continue;
}
editValues(profile);
profile.save(); // Since this is a temporary profile, we save it here.
}
else {
profile = mcMMOPlayer.getProfile();
editValues(profile);
}
}
mcMMO.getFormulaManager().setPreviousFormulaType(formulaType);
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", formulaType.toString()));
}
private void editValues(PlayerProfile profile) {
mcMMO.p.debug("========================================================================");
mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":");
for (SkillType skillType : SkillType.nonChildSkills()) {
int oldLevel = profile.getSkillLevel(skillType);
int oldXPLevel = profile.getSkillXpLevel(skillType);
int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel);
if (totalOldXP == 0) {
continue;
}
int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(skillType, (int) Math.floor(totalOldXP / ExperienceConfig.getInstance().getExpModifier()), formulaType);
int newLevel = newExperienceValues[0];
int newXPlevel = newExperienceValues[1];
mcMMO.p.debug(" Skill: " + skillType.toString());
mcMMO.p.debug(" OLD:");
mcMMO.p.debug(" Level: " + oldLevel);
mcMMO.p.debug(" XP " + oldXPLevel);
mcMMO.p.debug(" Total XP " + totalOldXP);
mcMMO.p.debug(" NEW:");
mcMMO.p.debug(" Level " + newLevel);
mcMMO.p.debug(" XP " + newXPlevel);
mcMMO.p.debug("------------------------------------------------------------------------");
profile.modifySkill(skillType, newLevel);
profile.setSkillXpLevel(skillType, newXPlevel);
}
}
}

View File

@@ -29,8 +29,6 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
Player player = mcMMOPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
mcMMOPlayer.setTeleportCommenceLocation(null);
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
return;

View File

@@ -1,19 +0,0 @@
package com.gmail.nossr50.runnables.player;
import java.util.concurrent.Callable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
public class PlayerProfileLoader implements Callable<PlayerProfile> {
private final String playerName;
public PlayerProfileLoader(String player) {
this.playerName = player;
}
@Override
public PlayerProfile call() {
return mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
}
}

View File

@@ -1,29 +1,18 @@
package com.gmail.nossr50.runnables.player;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.util.player.UserManager;
public class PlayerProfileSaveTask extends BukkitRunnable {
private McMMOPlayer mcMMOPlayer;
private PlayerProfile playerProfile;
public PlayerProfileSaveTask(McMMOPlayer mcMMOPlayer) {
this.mcMMOPlayer = mcMMOPlayer;
this.playerProfile = mcMMOPlayer.getProfile();
public PlayerProfileSaveTask(PlayerProfile playerProfile) {
this.playerProfile = playerProfile;
}
@Override
public void run() {
playerProfile.save();
Player player = mcMMOPlayer.getPlayer();
if (!player.isOnline()) {
UserManager.remove(player.getName());
}
}
}

View File

@@ -11,7 +11,7 @@ public class AwardCombatXpTask extends BukkitRunnable {
private double baseXp;
private SkillType skillType;
private LivingEntity target;
private int baseHealth;
private double baseHealth;
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) {
this.mcMMOPlayer = mcMMOPlayer;
@@ -23,8 +23,8 @@ public class AwardCombatXpTask extends BukkitRunnable {
@Override
public void run() {
int health = target.getHealth();
int damage = baseHealth - health;
double health = target.getHealth();
double damage = baseHealth - health;
// May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0) {

View File

@@ -5,16 +5,16 @@ import com.gmail.nossr50.config.Config;
public final class Acrobatics {
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
public static double dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax();
public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel();
public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
public static double rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax();
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static double gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
@@ -25,11 +25,11 @@ public final class Acrobatics {
private Acrobatics() {};
protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) {
return Math.max(damage / damageModifier, 1);
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
return Math.max(damage / damageModifier, 1.0);
}
protected static int calculateModifiedRollDamage(int damage, int damageThreshold) {
return Math.max(damage - damageThreshold, 0);
protected static double calculateModifiedRollDamage(double damage, double damageThreshold) {
return Math.max(damage - damageThreshold, 0.0);
}
}

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