mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
356 Commits
1.4.06
...
dev-comman
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13f0f396d7 | ||
|
|
31e04a2d91 | ||
|
|
2fcd3904dc | ||
|
|
92fa2782d0 | ||
|
|
eb10db5b06 | ||
|
|
f64f62492f | ||
|
|
3fe936306b | ||
|
|
c79f8043ad | ||
|
|
8369ae4616 | ||
|
|
4715688fe8 | ||
|
|
62e03a4ef5 | ||
|
|
9ef3c721df | ||
|
|
f55039ac6b | ||
|
|
be792a1052 | ||
|
|
c612036db3 | ||
|
|
ad4ee6f402 | ||
|
|
49a5bd2ba6 | ||
|
|
8aac6a992b | ||
|
|
5da66f05d4 | ||
|
|
134e0db2e9 | ||
|
|
b3415ee2f4 | ||
|
|
14175a6dfd | ||
|
|
7b3fb46a9a | ||
|
|
0aea165a8f | ||
|
|
17b7a9bf10 | ||
|
|
bd611ee11c | ||
|
|
c6ca65f5c9 | ||
|
|
95f15e68fe | ||
|
|
89dabaeb43 | ||
|
|
c2e100b1e3 | ||
|
|
9f33c6cef1 | ||
|
|
7e241e3993 | ||
|
|
bc51505150 | ||
|
|
e0599a0dea | ||
|
|
d410251595 | ||
|
|
810c74dc2a | ||
|
|
100f2c7e56 | ||
|
|
e13e5295e8 | ||
|
|
b100b7bcc7 | ||
|
|
f4ff8518c2 | ||
|
|
dbd27b641e | ||
|
|
4a428a47af | ||
|
|
3252137ed7 | ||
|
|
68c4b99d1b | ||
|
|
f282891d0a | ||
|
|
7f4e3fedb3 | ||
|
|
2042e0cdbd | ||
|
|
2662fee9fb | ||
|
|
e8e2dcff46 | ||
|
|
3b09012b35 | ||
|
|
a774733af4 | ||
|
|
4a7e1e2b94 | ||
|
|
b8c1f868f5 | ||
|
|
3f56a8fbcf | ||
|
|
d8e86d0fc7 | ||
|
|
e125700b43 | ||
|
|
819a1c62ed | ||
|
|
4bc446e306 | ||
|
|
7f2f15d88e | ||
|
|
be4736fffd | ||
|
|
b4f4de4628 | ||
|
|
b9c652ef2b | ||
|
|
bf4e8d43ea | ||
|
|
468fbdab56 | ||
|
|
309dfd50cd | ||
|
|
44e3e4d1e1 | ||
|
|
476f426590 | ||
|
|
766f1f4127 | ||
|
|
b3cf9bf839 | ||
|
|
056f7cc93b | ||
|
|
741f629ab8 | ||
|
|
dd64c4008b | ||
|
|
3a5de8e2ce | ||
|
|
2d78c0738d | ||
|
|
77617ebee2 | ||
|
|
67e9d9c535 | ||
|
|
800786111c | ||
|
|
ed8197bd50 | ||
|
|
82f8c4ce36 | ||
|
|
b1cf7d0348 | ||
|
|
ae77313007 | ||
|
|
49cbaad47f | ||
|
|
1d96ed72dc | ||
|
|
ec378d046f | ||
|
|
a25dc24c6c | ||
|
|
68eb51a3d0 | ||
|
|
2eda3a9c83 | ||
|
|
ad8e200a84 | ||
|
|
0c83bf2a80 | ||
|
|
6eaec5ffab | ||
|
|
8a2c5fb051 | ||
|
|
9485869014 | ||
|
|
e1bf55b077 | ||
|
|
81140824e4 | ||
|
|
d5545de81f | ||
|
|
8632baed27 | ||
|
|
9aaea7e44f | ||
|
|
c2f8f4d016 | ||
|
|
5131e74349 | ||
|
|
3927427b5b | ||
|
|
4aef4c63fc | ||
|
|
fb4777e7f0 | ||
|
|
d8f3a54f9b | ||
|
|
de964a3a60 | ||
|
|
ce3bc07aa8 | ||
|
|
5a6bb363cf | ||
|
|
3f9c98d72e | ||
|
|
96b54387fe | ||
|
|
70eb67dd6a | ||
|
|
77f9f40065 | ||
|
|
14ae1a69c4 | ||
|
|
c9858dfd49 | ||
|
|
f75fe3cc89 | ||
|
|
c19ccbccac | ||
|
|
2f90e533a5 | ||
|
|
0cd0919447 | ||
|
|
e8b886fcc6 | ||
|
|
b8e937a234 | ||
|
|
eb2e0d3abf | ||
|
|
3365da7f8d | ||
|
|
a0e37a4a09 | ||
|
|
5541c15753 | ||
|
|
f87110749e | ||
|
|
a0ef0d5708 | ||
|
|
2e2abcd645 | ||
|
|
6baf820afa | ||
|
|
288287badf | ||
|
|
ca4feca073 | ||
|
|
7c9356955e | ||
|
|
57541ec233 | ||
|
|
9c6d1ce020 | ||
|
|
c72ead9d0a | ||
|
|
4262a1b2a5 | ||
|
|
eb589b6e78 | ||
|
|
98e5e53fda | ||
|
|
00918fbdc1 | ||
|
|
5ad0f2c624 | ||
|
|
babb9baa2b | ||
|
|
45143836e5 | ||
|
|
ceacd7dc52 | ||
|
|
6eb255632f | ||
|
|
3a37d0e092 | ||
|
|
4c7fb1854d | ||
|
|
763cff6898 | ||
|
|
fa34d06341 | ||
|
|
1ca53da0e2 | ||
|
|
57dfa00541 | ||
|
|
36ae84eada | ||
|
|
7f290504ad | ||
|
|
92b4be9a01 | ||
|
|
8cb8dea642 | ||
|
|
a63f745c73 | ||
|
|
4a0fee5796 | ||
|
|
cf90236e57 | ||
|
|
fc6c7bb1de | ||
|
|
1b92131ce9 | ||
|
|
792ecd6aad | ||
|
|
933b6f278b | ||
|
|
45dfc13ebd | ||
|
|
1254ab232a | ||
|
|
b49e56c857 | ||
|
|
d5bd9a1693 | ||
|
|
9b60cd96f9 | ||
|
|
0a05ed98d0 | ||
|
|
6a3a564bd4 | ||
|
|
3828f78480 | ||
|
|
239d7e33cb | ||
|
|
b8c479549c | ||
|
|
0a9fd4a92e | ||
|
|
4c96161acb | ||
|
|
ce7a7a31a7 | ||
|
|
834e26b44e | ||
|
|
f71b302f6f | ||
|
|
566a381e95 | ||
|
|
5d7d779a49 | ||
|
|
59a35b170c | ||
|
|
14eb473355 | ||
|
|
a8e23e08ee | ||
|
|
15f5dcf860 | ||
|
|
9be9908a22 | ||
|
|
446b6c107b | ||
|
|
5a3f8ad15f | ||
|
|
3a2c6a0827 | ||
|
|
e865acd871 | ||
|
|
4a0e1ba444 | ||
|
|
1a88b0b944 | ||
|
|
e0592b3f62 | ||
|
|
1ec55c2d7e | ||
|
|
6427a7dcdf | ||
|
|
7bac0e2ca5 | ||
|
|
e8bc2475c3 | ||
|
|
816b08b14a | ||
|
|
64e1448782 | ||
|
|
ae0a27991b | ||
|
|
f1b82dcbe6 | ||
|
|
bfbd50d8f4 | ||
|
|
de07316261 | ||
|
|
eae196c6a1 | ||
|
|
8af41975ff | ||
|
|
957bbbc9b2 | ||
|
|
17faf1561f | ||
|
|
ec6419f0ff | ||
|
|
f6e60bebcc | ||
|
|
797ac20567 | ||
|
|
3bc029a0de | ||
|
|
4eba33a1c6 | ||
|
|
800a452d62 | ||
|
|
177604e94a | ||
|
|
088015dd4d | ||
|
|
0f2d0aee5f | ||
|
|
1004e2a32b | ||
|
|
5c2b523f7a | ||
|
|
de42063171 | ||
|
|
a49d373af0 | ||
|
|
0095f7f9c7 | ||
|
|
f53820e4de | ||
|
|
25e4700ef9 | ||
|
|
58c7dcb705 | ||
|
|
44626c36a9 | ||
|
|
cfd5bfe2c4 | ||
|
|
f7928787dc | ||
|
|
d6630a0eb5 | ||
|
|
af39e84aef | ||
|
|
93fe2ff504 | ||
|
|
b42f2d4073 | ||
|
|
c5c231920d | ||
|
|
89ddf8c4fa | ||
|
|
71ab678945 | ||
|
|
14daee3b1b | ||
|
|
d2bbbb0fe7 | ||
|
|
fd8d9b02a9 | ||
|
|
a639a37637 | ||
|
|
7eec53d621 | ||
|
|
7523afffb5 | ||
|
|
2c8b9334b6 | ||
|
|
d41ccf9072 | ||
|
|
c98d298cf1 | ||
|
|
73d0b377ae | ||
|
|
df29306a1f | ||
|
|
435522415d | ||
|
|
a17d1d3a2f | ||
|
|
94a5bef62c | ||
|
|
2cd9a5658e | ||
|
|
3c5bd3cedd | ||
|
|
8e02b57369 | ||
|
|
935b8b7bc4 | ||
|
|
9c54f8fd11 | ||
|
|
6bfc1b84de | ||
|
|
59f545d5ce | ||
|
|
23983422e0 | ||
|
|
956bf2d763 | ||
|
|
964b2636fb | ||
|
|
490bc195d8 | ||
|
|
0ce41150c6 | ||
|
|
0455416dec | ||
|
|
a6e7febf77 | ||
|
|
ede0757d83 | ||
|
|
8282d84b16 | ||
|
|
223649ec28 | ||
|
|
68e433b3b7 | ||
|
|
1a51b93ec9 | ||
|
|
c31ffa5ab4 | ||
|
|
ca6bee07ea | ||
|
|
9acaa7b126 | ||
|
|
2bae937b28 | ||
|
|
51bf989418 | ||
|
|
07dd460d78 | ||
|
|
045d74fb9d | ||
|
|
c8c76f4174 | ||
|
|
83c4d09093 | ||
|
|
50ef8d9610 | ||
|
|
98c6abad36 | ||
|
|
62146480db | ||
|
|
6518d192ec | ||
|
|
3fe9cfee74 | ||
|
|
d495054eb5 | ||
|
|
ce80636141 | ||
|
|
fe93be66ad | ||
|
|
1f712063bf | ||
|
|
560c3860b4 | ||
|
|
36f1a2d78a | ||
|
|
3ddd8d2056 | ||
|
|
5441fcc374 | ||
|
|
1d83784820 | ||
|
|
fb5bab6e92 | ||
|
|
90fcf35c34 | ||
|
|
4ff6b5fbc7 | ||
|
|
ead1398132 | ||
|
|
6330c4a69e | ||
|
|
dcc18049a1 | ||
|
|
fcb8909a54 | ||
|
|
37e3bfe7d9 | ||
|
|
d61b837dcf | ||
|
|
f079e22789 | ||
|
|
1f53c62ced | ||
|
|
9fb4e0988b | ||
|
|
d8bbe459b9 | ||
|
|
8bd7526b43 | ||
|
|
24b1485555 | ||
|
|
7683dfc436 | ||
|
|
ccbffca278 | ||
|
|
aeaab43f44 | ||
|
|
a2450d2d07 | ||
|
|
c85bd8ab70 | ||
|
|
3f6bce0fc6 | ||
|
|
e566b20e2b | ||
|
|
f37a7d759a | ||
|
|
d1341b0be0 | ||
|
|
4ea3d690db | ||
|
|
d5dc9895e4 | ||
|
|
b1fc72e8a9 | ||
|
|
7479a02220 | ||
|
|
d1bf48ad79 | ||
|
|
a345737b8b | ||
|
|
c501ebb357 | ||
|
|
15e0570a8c | ||
|
|
09e77c8c94 | ||
|
|
f5c58f3679 | ||
|
|
ddcbe64db6 | ||
|
|
c5137eb884 | ||
|
|
e073eca458 | ||
|
|
78f2e0a064 | ||
|
|
df2defe969 | ||
|
|
6d4a2feaae | ||
|
|
8939fc09b3 | ||
|
|
e0e574c19e | ||
|
|
02126c93b9 | ||
|
|
37671bad9a | ||
|
|
0e8ce005d7 | ||
|
|
584a225d6e | ||
|
|
736359056f | ||
|
|
bf2e527e72 | ||
|
|
be7992d541 | ||
|
|
435eb7f8b9 | ||
|
|
001f1dbd3c | ||
|
|
7b5372a985 | ||
|
|
1647ef4fae | ||
|
|
ee86f8244f | ||
|
|
e518b58b23 | ||
|
|
5af1164b5c | ||
|
|
c9aba059e2 | ||
|
|
dc9469c0cc | ||
|
|
696e82e622 | ||
|
|
18a5ec73d7 | ||
|
|
83ee8dd3f8 | ||
|
|
04224b309a | ||
|
|
01a1cf5765 | ||
|
|
8fdf4042bb | ||
|
|
621969459a | ||
|
|
6fe1c85592 | ||
|
|
79346d92d7 | ||
|
|
24ceeb626b | ||
|
|
68727496ad | ||
|
|
d07b67b5bf | ||
|
|
4dc9c97978 | ||
|
|
99916f99fd |
@@ -7,6 +7,87 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
|
Version 1.4.08-dev
|
||||||
|
+ Added the possibility to gain experience when using Fishing "Shake"
|
||||||
|
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
||||||
|
|
||||||
|
Version 1.4.07
|
||||||
|
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
||||||
|
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
|
||||||
|
+ Added more tiers to Fishing, Repair and Smelting!
|
||||||
|
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
|
||||||
|
+ Added horses to the "Shake" ability
|
||||||
|
+ Added ability to summon horses via "Call of the Wild" using apples
|
||||||
|
+ 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
|
||||||
|
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
|
||||||
|
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
|
||||||
|
+ Added Quartz and Name Tags to the default Excavation treasures
|
||||||
|
+ Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus
|
||||||
|
+ Added cooldown to commands with heavy database access to prevent denial of service
|
||||||
|
+ Added /mcscoreboard keep, to keep the scoreboard up forever
|
||||||
|
+ Added Rainbow Mode to scoreboards
|
||||||
|
+ Added new /mccooldowns command to show all ability cooldowns
|
||||||
|
+ Commands may now both print text and display a scoreboard
|
||||||
|
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
||||||
|
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||||
|
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||||
|
= 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.
|
||||||
|
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
|
||||||
|
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
|
||||||
|
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
|
||||||
|
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
|
||||||
|
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
|
||||||
|
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||||
|
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||||
|
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||||
|
! Changed default XP multiplier for repairing shears
|
||||||
|
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
|
||||||
|
! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
|
||||||
|
! Changed Hardcore modes, they will also subtract experience
|
||||||
|
! Changed various values to double in advanced.yml for the sake of consistency.
|
||||||
|
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
|
||||||
|
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||||
|
! 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 modes 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 "Tree Feller" algorithm (Thanks Riking!)
|
||||||
|
! Improved AFK Acrobatics prevention mechanism
|
||||||
|
! Improved profile saving
|
||||||
|
! Improved partial name matcher
|
||||||
|
! Improved update checker
|
||||||
|
! 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)
|
||||||
|
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
|
||||||
|
! Massively improved scoreboard handling
|
||||||
|
! Reworked scoreboard configuration (config.yml) - **you will need to update**
|
||||||
|
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
||||||
|
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
|
||||||
|
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
|
||||||
|
- Removed SpoutPlugin support
|
||||||
|
|
||||||
Version 1.4.06
|
Version 1.4.06
|
||||||
+ Added "Ice Fishing" ability to Fishing
|
+ Added "Ice Fishing" ability to Fishing
|
||||||
+ Added global scoreboards to track skill rankings (display using /mctop)
|
+ Added global scoreboards to track skill rankings (display using /mctop)
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -2,12 +2,10 @@
|
|||||||
## The RPG lovers mod
|
## The RPG lovers mod
|
||||||
|
|
||||||
### Dev builds
|
### Dev builds
|
||||||
Our latest development builds are available [here](http://ci.mcmmo.info).
|
Our latest development builds are available ~~[here](http://ci.mcmmo.info)~~. Unfortunately, the mcMMO site is down; a temporary dev build location is hosted [here](http://ci.ecocitycraft.com/job/mcMMO/).
|
||||||
|
|
||||||
### Brief Description
|
### 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.
|
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||||
|
|
||||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
|
||||||
|
|
||||||
## About the Team
|
## About the Team
|
||||||
|
|
||||||
@@ -31,17 +29,18 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
|||||||
(https://github.com/TfT-02)
|
(https://github.com/TfT-02)
|
||||||
[]
|
[]
|
||||||
(https://github.com/t00thpick1)
|
(https://github.com/t00thpick1)
|
||||||
|
[]
|
||||||
|
(https://github.com/riking)
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
||||||
|
|
||||||
The typical command used to build mcMMO is: mvn clean package install
|
The typical command used to build mcMMO is: `mvn clean package install`
|
||||||
|
|
||||||
Required Libraries:
|
Required Libraries:
|
||||||
* Spout API
|
|
||||||
* JUnit
|
* JUnit
|
||||||
* Metrics
|
* EMetrics
|
||||||
* Bukkit
|
* Bukkit
|
||||||
|
|
||||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#
|
#
|
||||||
|
# Repair configuration
|
||||||
|
# Last updated on ${project.version}-b${BUILD_NUMBER}
|
||||||
|
#
|
||||||
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
|
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
|
||||||
# All repair configs have a main section titled "Repairables"
|
# All repair configs have a main section titled "Repairables"
|
||||||
# Afterwards, all sub-items are considered a Repairable to be loaded
|
# Afterwards, all sub-items are considered a Repairable to be loaded. The names of each subitem should be the exact material name.
|
||||||
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
|
# The bare minimum of a Repairable is that it have a RepairMaterial and a MaximumDurability
|
||||||
#
|
|
||||||
# ItemId: This is the id of the item to be repairable.
|
|
||||||
## This is required to be set.
|
|
||||||
#
|
#
|
||||||
# ItemType: This is the type of item to be repaired, this is only important to permissions.
|
# ItemType: This is the type of item to be repaired, this is only important to permissions.
|
||||||
## Valid values are ARMOR, TOOL, and OTHER.
|
## Valid values are ARMOR, TOOL, and OTHER.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
|
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
|
||||||
## This defaults to OTHER.
|
## This defaults to OTHER.
|
||||||
#
|
#
|
||||||
# RepairMaterialId: This is the id of the item used to repair this repairable.
|
# RepairMaterial: This is the material name of the item used to repair this repairable.
|
||||||
## This is required to be set.
|
## This is required to be set.
|
||||||
#
|
#
|
||||||
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
|
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
## This is required to be set.
|
## This is required to be set.
|
||||||
#
|
#
|
||||||
# MinimumLevel: This is the minimum repair level needed to repair this item.
|
# MinimumLevel: This is the minimum repair level needed to repair this item.
|
||||||
## Valid values are > 0
|
## Valid values are => 0
|
||||||
## This defaults to 0
|
## This defaults to 0
|
||||||
#
|
#
|
||||||
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
|
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
|
||||||
@@ -42,32 +42,19 @@
|
|||||||
#
|
#
|
||||||
###
|
###
|
||||||
Repairables:
|
Repairables:
|
||||||
ChainHelmet:
|
#
|
||||||
ItemId: 302
|
# Chainmail repairables
|
||||||
ItemType: ARMOR
|
###
|
||||||
RepairMaterialId: 51
|
# Armor
|
||||||
MaximumDurability: 165
|
CHAINMAIL_HELMET:
|
||||||
MinimumQuantity: 5
|
RepairMaterial: FIRE
|
||||||
XpMultiplier: 2
|
XpMultiplier: 2
|
||||||
ChainChest:
|
CHAINMAIL_CHESTPLATE:
|
||||||
ItemId: 303
|
RepairMaterial: FIRE
|
||||||
ItemType: ARMOR
|
|
||||||
RepairMaterialId: 51
|
|
||||||
MaximumDurability: 240
|
|
||||||
MinimumQuantity: 8
|
|
||||||
XpMultiplier: 2
|
XpMultiplier: 2
|
||||||
ChainLegs:
|
CHAINMAIL_LEGGINGS:
|
||||||
ItemId: 304
|
RepairMaterial: FIRE
|
||||||
ItemType: ARMOR
|
|
||||||
RepairMaterialId: 51
|
|
||||||
MaximumDurability: 225
|
|
||||||
MinimumQuantity: 7
|
|
||||||
XpMultiplier: 2
|
XpMultiplier: 2
|
||||||
ChainBoots:
|
CHAINMAIL_BOOTS:
|
||||||
ItemId: 305
|
RepairMaterial: FIRE
|
||||||
ItemType: ARMOR
|
|
||||||
RepairMaterialId: 51
|
|
||||||
RepairMaterialMetadata: -1
|
|
||||||
MaximumDurability: 195
|
|
||||||
MinimumQuantity: 4
|
|
||||||
XpMultiplier: 2
|
XpMultiplier: 2
|
||||||
|
|||||||
57
pom.xml
57
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.06</version>
|
<version>1.4.08-dev1</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@@ -22,38 +22,6 @@
|
|||||||
<include>.jenkins</include>
|
<include>.jenkins</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
|
||||||
<targetPath>resources</targetPath>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
<directory>${basedir}/src/main/resources/xpbar/</directory>
|
|
||||||
<includes>
|
|
||||||
<include>xpbar*.png</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<targetPath>resources</targetPath>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
<directory>${basedir}/src/main/resources/healthbar/</directory>
|
|
||||||
<includes>
|
|
||||||
<include>health*.png</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<targetPath>resources</targetPath>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
<directory>${basedir}/src/main/resources/skillicon/</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.png</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<targetPath>resources</targetPath>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
<directory>${basedir}/src/main/resources/sound/</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.wav</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
<resource>
|
||||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
@@ -62,6 +30,14 @@
|
|||||||
<include>locale*.properties</include>
|
<include>locale*.properties</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<targetPath>mods</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>${basedir}/src/main/resources/mods</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -132,10 +108,6 @@
|
|||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>spout-repo</id>
|
|
||||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>Plugin MetricsExtension</id>
|
<id>Plugin MetricsExtension</id>
|
||||||
<url>http://repo.turt2live.com</url>
|
<url>http://repo.turt2live.com</url>
|
||||||
@@ -145,13 +117,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.5.2-R1.0</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.getspout</groupId>
|
|
||||||
<artifactId>spoutplugin</artifactId>
|
|
||||||
<version>LATEST</version>
|
<version>LATEST</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
@@ -178,7 +143,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>Jenkins</system>
|
<system>Jenkins</system>
|
||||||
<url>ci.mcmmo.org</url>
|
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||||
import com.gmail.nossr50.chat.ChatMode;
|
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import com.gmail.nossr50.chat.PartyChatManager;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
||||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||||
import com.gmail.nossr50.config.Config;
|
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
@@ -47,6 +48,11 @@ public final class ExperienceAPI {
|
|||||||
return !skill.isChildSkill();
|
return !skill.isChildSkill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void addRawXP(Player player, String skillType, int XP) {
|
||||||
|
addRawXP(player, skillType, (float) XP);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds raw XP to the player.
|
* Adds raw XP to the player.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -58,10 +64,15 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
public static void addRawXP(Player player, String skillType, int XP) {
|
public static void addRawXP(Player player, String skillType, float XP) {
|
||||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||||
|
addRawXPOffline(playerName, skillType, (float) XP);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds raw XP to an offline player.
|
* Adds raw XP to an offline player.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -74,8 +85,8 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||||
addOfflineXP(playerName, getSkillType(skillType), XP);
|
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +101,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
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 +117,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||||
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,7 +134,7 @@ public final class ExperienceAPI {
|
|||||||
public static void addModifiedXP(Player player, String skillType, int XP) {
|
public static void addModifiedXP(Player player, String skillType, int XP) {
|
||||||
SkillType skill = getSkillType(skillType);
|
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 +152,7 @@ public final class ExperienceAPI {
|
|||||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||||
SkillType skill = getSkillType(skillType);
|
SkillType skill = getSkillType(skillType);
|
||||||
|
|
||||||
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,7 +414,7 @@ public final class ExperienceAPI {
|
|||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
for (SkillType type : SkillType.nonChildSkills()) {
|
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||||
powerLevel += profile.getSkillLevel(type);
|
powerLevel += profile.getSkillLevel(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,6 +446,40 @@ public final class ExperienceAPI {
|
|||||||
return Config.getInstance().getPowerLevelCap();
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the level of a player in a specific skill type.
|
* Sets the level of a player in a specific skill type.
|
||||||
* </br>
|
* </br>
|
||||||
|
|||||||
@@ -77,13 +77,12 @@ public final class PartyAPI {
|
|||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
Party party = PartyManager.getParty(partyName);
|
Party party = PartyManager.getParty(partyName);
|
||||||
String playerName = player.getName();
|
|
||||||
|
|
||||||
if (party == null) {
|
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
|
* @param player The player to remove
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(Player player) {
|
public static void removeFromParty(Player player) {
|
||||||
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
|
PartyManager.removeFromParty(UserManager.getPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.gmail.nossr50.api;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
|
|
||||||
public class SpoutHudAPI {
|
|
||||||
private SpoutHudAPI() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable the mcMMO XP bar for a player.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*/
|
|
||||||
public static void disableXpBar(Player player) {
|
|
||||||
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable the mcMMO XP bar for the server.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*/
|
|
||||||
public static void disableXpBar() {
|
|
||||||
SpoutConfig.getInstance().setXPBarEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.gmail.nossr50.api;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
||||||
|
|
||||||
public final class SpoutToolsAPI {
|
|
||||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
|
||||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
|
||||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
|
||||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
|
||||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
private SpoutToolsAPI() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param spoutTool The tool to add
|
|
||||||
* @param type The type of tool to add
|
|
||||||
*/
|
|
||||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
|
||||||
switch (type) {
|
|
||||||
case AXE:
|
|
||||||
spoutAxes.add(spoutTool);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HOE:
|
|
||||||
spoutHoes.add(spoutTool);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PICKAXE:
|
|
||||||
spoutPickaxes.add(spoutTool);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHOVEL:
|
|
||||||
spoutShovels.add(spoutTool);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SWORD:
|
|
||||||
spoutSwords.add(spoutTool);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
|||||||
|
|
||||||
public class AdminChatManager extends ChatManager {
|
public class AdminChatManager extends ChatManager {
|
||||||
protected AdminChatManager(Plugin plugin) {
|
protected AdminChatManager(Plugin plugin) {
|
||||||
super(plugin, Config.getInstance().getAdminDisplayNames(), "Commands.AdminChat.Prefix");
|
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public abstract class ChatManager {
|
|||||||
protected boolean useDisplayNames;
|
protected boolean useDisplayNames;
|
||||||
protected String chatPrefix;
|
protected String chatPrefix;
|
||||||
|
|
||||||
|
protected String senderName;
|
||||||
protected String displayName;
|
protected String displayName;
|
||||||
protected String message;
|
protected String message;
|
||||||
|
|
||||||
@@ -27,8 +28,9 @@ public abstract class ChatManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayName = useDisplayNames ? event.getDisplayName() : event.getSender();
|
senderName = event.getSender();
|
||||||
message = LocaleLoader.getString(chatPrefix, displayName) + event.getMessage();
|
displayName = useDisplayNames ? event.getDisplayName() : senderName;
|
||||||
|
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
|
||||||
|
|
||||||
sendMessage();
|
sendMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
|
|
||||||
public class ChatManagerFactory {
|
public class ChatManagerFactory {
|
||||||
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
|
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
|
||||||
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();
|
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.chat;
|
package com.gmail.nossr50.chat;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ public class PartyChatManager extends ChatManager {
|
|||||||
private Party party;
|
private Party party;
|
||||||
|
|
||||||
protected PartyChatManager(Plugin plugin) {
|
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) {
|
public void setParty(Party party) {
|
||||||
@@ -25,6 +26,10 @@ public class PartyChatManager extends ChatManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendMessage() {
|
protected void sendMessage() {
|
||||||
|
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
||||||
|
message = message.replaceFirst(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
member.sendMessage(message);
|
member.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -39,9 +40,10 @@ public class KrakenCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0], true);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
if (mcMMOPlayer == null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ public class KrakenCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ public class McabilityCommand extends ToggleCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendSuccessMessage(CommandSender sender) {
|
protected void sendSuccessMessage(CommandSender sender) {
|
||||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ public class McgodCommand extends ToggleCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendSuccessMessage(CommandSender sender) {
|
protected void sendSuccessMessage(CommandSender sender) {
|
||||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.HolidayManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
|
||||||
|
|
||||||
public class McmmoCommand implements CommandExecutor {
|
public class McmmoCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@@ -28,16 +27,12 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(mcSplit);
|
sender.sendMessage(mcSplit);
|
||||||
|
|
||||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||||
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
|
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||||
SpoutUtils.sendDonationNotification((Player) sender);
|
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
|
||||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||||
|
HolidayManager.anniversaryCheck(sender);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -2,24 +2,19 @@ package com.gmail.nossr50.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McscoreboardCommand implements TabExecutor {
|
public class McscoreboardCommand implements TabExecutor {
|
||||||
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@@ -27,94 +22,49 @@ public class McscoreboardCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
|
||||||
clearScoreboard(player);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (args[0].equalsIgnoreCase("clear")) {
|
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||||
clearScoreboard(player);
|
ScoreboardManager.clearBoard(sender.getName());
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("rank")) {
|
|
||||||
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
if (args[0].equalsIgnoreCase("keep")) {
|
||||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
if (!Config.getInstance().getAllowKeepBoard()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
if (!ScoreboardManager.isBoardShown(sender.getName())) {
|
||||||
ScoreboardManager.enablePlayerRankScoreboard(player);
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("stats")) {
|
|
||||||
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
|
||||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
ScoreboardManager.keepBoard(sender.getName());
|
||||||
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
||||||
}
|
return true;
|
||||||
else if (args[0].equalsIgnoreCase("top")) {
|
|
||||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
|
||||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return help(sender);
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!args[0].equalsIgnoreCase("top")) {
|
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
|
||||||
return false;
|
if (CommandUtils.isInvalidInteger(sender, args[1])) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
int time = Math.abs(Integer.parseInt(args[1]));
|
||||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
|
||||||
|
ScoreboardManager.setRevertTimer(sender.getName(), time);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isInt(args[1])) {
|
return help(sender);
|
||||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if (!args[0].equalsIgnoreCase("top")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
|
||||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.isInvalidInteger(sender, args[2])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return help(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,20 +72,17 @@ public class McscoreboardCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size()));
|
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
|
||||||
case 2:
|
|
||||||
if (args[0].equalsIgnoreCase("top")) {
|
|
||||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
|
||||||
}
|
|
||||||
// Fallthrough
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearScoreboard(Player player) {
|
private boolean help(CommandSender sender) {
|
||||||
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
|
||||||
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MobhealthCommand implements TabExecutor {
|
public class MobhealthCommand implements TabExecutor {
|
||||||
@@ -44,11 +44,11 @@ public class MobhealthCommand implements TabExecutor {
|
|||||||
try {
|
try {
|
||||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||||
playerProfile.setMobHealthbarType(type);
|
playerProfile.setMobHealthbarType(type);
|
||||||
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
sender.sendMessage("Invalid type!"); //TODO: Localize
|
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public abstract class ToggleCommand implements TabExecutor {
|
public abstract class ToggleCommand implements TabExecutor {
|
||||||
@@ -45,18 +45,15 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
mcMMOPlayer = UserManager.getPlayer(args[0], true);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
if (mcMMOPlayer == null) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = mcMMOPlayer.getPlayer();
|
player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
if (CommandUtils.isOffline(sender, player)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyCommandAction();
|
applyCommandAction();
|
||||||
sendSuccessMessage(sender);
|
sendSuccessMessage(sender);
|
||||||
return true;
|
return true;
|
||||||
@@ -70,7 +67,7 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
@@ -21,7 +21,7 @@ public class XprateCommand implements TabExecutor {
|
|||||||
private double originalRate;
|
private double originalRate;
|
||||||
|
|
||||||
public XprateCommand() {
|
public XprateCommand() {
|
||||||
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
originalRate = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,7 +42,7 @@ public class XprateCommand implements TabExecutor {
|
|||||||
mcMMO.p.toggleXpEventEnabled();
|
mcMMO.p.toggleXpEventEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -66,7 +66,7 @@ public class XprateCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int newXpRate = Integer.parseInt(args[0]);
|
int newXpRate = Integer.parseInt(args[0]);
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.chat;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatMode;
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
|
|
||||||
public class AdminChatCommand extends ChatCommand {
|
public class AdminChatCommand extends ChatCommand {
|
||||||
public AdminChatCommand() {
|
public AdminChatCommand() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.bukkit.util.StringUtil;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
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.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.gmail.nossr50.commands.chat;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatMode;
|
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import com.gmail.nossr50.chat.PartyChatManager;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
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 (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.toString());
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@@ -21,15 +22,17 @@ public class McremoveCommand implements TabExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.getDatabaseManager().removeUser(args[0])) {
|
if (mcMMO.getDatabaseManager().removeUser(playerName)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
|
||||||
}
|
}
|
||||||
else {
|
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;
|
return true;
|
||||||
@@ -43,7 +46,7 @@ public class McremoveCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MmoshowdbCommand implements TabExecutor {
|
public class MmoshowdbCommand implements TabExecutor {
|
||||||
@@ -17,22 +18,16 @@ public class MmoshowdbCommand implements TabExecutor {
|
|||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
||||||
if (clazz != null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
|
if (clazz != null) {
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class AddlevelsCommand extends ExperienceCommand {
|
public class AddlevelsCommand extends ExperienceCommand {
|
||||||
@Override
|
@Override
|
||||||
@@ -22,11 +20,14 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleCommand(SkillType skill) {
|
protected void handleCommand(SkillType skill) {
|
||||||
|
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||||
profile.addLevels(skill, value);
|
profile.addLevels(skill, value);
|
||||||
|
|
||||||
if (player != null) {
|
if (player == null) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class AddxpCommand extends ExperienceCommand {
|
public class AddxpCommand extends ExperienceCommand {
|
||||||
@Override
|
@Override
|
||||||
@@ -35,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
|
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,9 +15,9 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
editValues();
|
editValues();
|
||||||
allSkills = false;
|
cleanUp();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@@ -65,11 +65,12 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
return true;
|
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 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) {
|
if (mcMMOPlayer == null) {
|
||||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false);
|
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||||
|
|
||||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -84,8 +85,8 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
editValues();
|
editValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSenderMessage(sender, args[0]);
|
handleSenderMessage(sender, playerName);
|
||||||
allSkills = false;
|
cleanUp();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -97,7 +98,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
case 2:
|
case 2:
|
||||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||||
@@ -147,7 +148,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,4 +170,9 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cleanUp() {
|
||||||
|
allSkills = false;
|
||||||
|
player = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class MmoeditCommand extends ExperienceCommand {
|
public class MmoeditCommand extends ExperienceCommand {
|
||||||
@Override
|
@Override
|
||||||
@@ -22,11 +20,16 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleCommand(SkillType skill) {
|
protected void handleCommand(SkillType skill) {
|
||||||
|
int skillLevel = profile.getSkillLevel(skill);
|
||||||
|
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||||
|
|
||||||
profile.modifySkill(skill, value);
|
profile.modifySkill(skill, value);
|
||||||
|
|
||||||
if (player != null) {
|
if (player == null || value == skillLevel) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value));
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class SkillresetCommand extends ExperienceCommand {
|
public class SkillresetCommand extends ExperienceCommand {
|
||||||
private CommandSender sender;
|
private CommandSender sender;
|
||||||
@@ -56,11 +56,12 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
return true;
|
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 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) {
|
if (mcMMOPlayer == null) {
|
||||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false);
|
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||||
|
|
||||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -76,7 +77,7 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
editValues();
|
editValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSenderMessage(sender, args[0]);
|
handleSenderMessage(sender, playerName);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -101,11 +102,16 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int levelsRemoved = profile.getSkillLevel(skill);
|
||||||
|
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||||
|
|
||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(skill, 0);
|
||||||
|
|
||||||
if (player != null) {
|
if (player == null) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill() {
|
protected void handlePlayerMessageSkill() {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
|
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,11 @@ package com.gmail.nossr50.commands.hardcore;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class HardcoreCommand extends HardcoreModeCommand {
|
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
|
@Override
|
||||||
protected boolean checkTogglePermissions() {
|
protected boolean checkTogglePermissions() {
|
||||||
return Permissions.hardcoreToggle(sender);
|
return Permissions.hardcoreToggle(sender);
|
||||||
@@ -29,13 +18,46 @@ public class HardcoreCommand extends HardcoreModeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkEnabled() {
|
protected boolean checkEnabled(String skill) {
|
||||||
return Config.getInstance().getHardcoreEnabled();
|
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
|
@Override
|
||||||
protected void modify() {
|
protected void modify() {
|
||||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
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.NON_CHILD_SKILLS) {
|
||||||
|
skillType.setHardcoreStatLossEnabled(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
@@ -19,6 +20,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
protected CommandSender sender;
|
protected CommandSender sender;
|
||||||
protected double newPercent;
|
protected double newPercent;
|
||||||
protected DecimalFormat percent;
|
protected DecimalFormat percent;
|
||||||
|
protected String skill;
|
||||||
|
|
||||||
public HardcoreModeCommand() {
|
public HardcoreModeCommand() {
|
||||||
percent = new DecimalFormat("##0.00%");
|
percent = new DecimalFormat("##0.00%");
|
||||||
@@ -35,11 +37,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkEnabled()) {
|
if (checkEnabled("ALL")) {
|
||||||
disable();
|
disable("ALL");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enable();
|
enable("ALL");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -51,7 +53,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable();
|
enable("ALL");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
disable();
|
disable("ALL");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +79,36 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
modify();
|
modify();
|
||||||
return true;
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -98,9 +130,9 @@ public abstract class HardcoreModeCommand implements TabExecutor {
|
|||||||
|
|
||||||
protected abstract boolean checkTogglePermissions();
|
protected abstract boolean checkTogglePermissions();
|
||||||
protected abstract boolean checkModifyPermissions();
|
protected abstract boolean checkModifyPermissions();
|
||||||
protected abstract boolean checkEnabled();
|
protected abstract boolean checkEnabled(String skill);
|
||||||
protected abstract void enable();
|
protected abstract void enable(String skill);
|
||||||
protected abstract void disable();
|
protected abstract void disable(String skill);
|
||||||
protected abstract void modify();
|
protected abstract void modify();
|
||||||
|
|
||||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.hardcore;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@@ -17,25 +18,46 @@ public class VampirismCommand extends HardcoreModeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkEnabled() {
|
protected boolean checkEnabled(String skill) {
|
||||||
return Config.getInstance().getHardcoreVampirismEnabled();
|
if (skill.equalsIgnoreCase("ALL")) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (!skillType.getHardcoreVampirismEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SkillType.getSkill(skill).getHardcoreVampirismEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable(String skill) {
|
||||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
toggle(true);
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void disable() {
|
protected void disable(String skill) {
|
||||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
toggle(false);
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void modify() {
|
protected void modify() {
|
||||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
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 enable) {
|
||||||
|
if (skill.equalsIgnoreCase("ALL")) {
|
||||||
|
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||||
|
skillType.setHardcoreVampirismEnabled(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,11 +24,11 @@ public class PartyAcceptCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
PartyManager.joinInvitedParty(mcMMOPlayer);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||||
@@ -16,13 +17,14 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
String targetName = Misc.getMatchedPlayerName(args[1]);
|
||||||
|
|
||||||
if (!playerParty.getMembers().contains(args[1])) {
|
if (!playerParty.getMembers().contains(targetName)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.setPartyLeader(args[1], playerParty);
|
PartyManager.setPartyLeader(targetName, playerParty);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class PartyCommand implements TabExecutor {
|
public class PartyCommand implements TabExecutor {
|
||||||
@@ -176,7 +177,7 @@ public class PartyCommand implements TabExecutor {
|
|||||||
case INVITE:
|
case INVITE:
|
||||||
case KICK:
|
case KICK:
|
||||||
case OWNER:
|
case OWNER:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
case EXPSHARE:
|
case EXPSHARE:
|
||||||
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
|
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()));
|
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
if (matches.size() == 0) {
|
||||||
playerNames = UserManager.getPlayers().keySet();
|
playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@@ -17,22 +16,20 @@ public class PartyCreateCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
Party newParty = PartyManager.getParty(args[1]);
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel creating a new party
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
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.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.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);
|
playerParty.setXpShareMode(mode);
|
||||||
|
|
||||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
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.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInfoCommand implements CommandExecutor {
|
public class PartyInfoCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOPlayer;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Party playerParty;
|
private Party playerParty;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
playerParty = mcMMOPlayer.getParty();
|
playerParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
displayPartyHeader();
|
displayPartyHeader();
|
||||||
@@ -63,7 +64,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
private void displayShareModeInfo() {
|
private void displayShareModeInfo() {
|
||||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||||
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
|
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE);
|
||||||
|
|
||||||
if (!xpShareEnabled && !itemShareEnabled) {
|
if (!xpShareEnabled && !itemShareEnabled) {
|
||||||
return;
|
return;
|
||||||
@@ -103,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void displayMemberInfo() {
|
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;
|
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||||
|
|||||||
@@ -15,22 +15,33 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
public class PartyInviteCommand implements CommandExecutor {
|
public class PartyInviteCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]);
|
Player player = (Player) sender;
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
String playerName = player.getName();
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) {
|
if (playerName.equalsIgnoreCase(args[1])) {
|
||||||
return false;
|
player.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PartyManager.canInvite(mcMMOPlayer)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1], true);
|
||||||
|
|
||||||
|
if (mcMMOTarget == null) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = mcMMOTarget.getPlayer();
|
Player target = mcMMOTarget.getPlayer();
|
||||||
Player player = (Player) sender;
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (player.equals(target)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PartyManager.inSameParty(player, target)) {
|
if (PartyManager.inSameParty(player, target)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
||||||
@@ -38,16 +49,10 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Party playerParty = mcMMOPlayer.getParty();
|
Party playerParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (!PartyManager.canInvite(player, playerParty)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOTarget.setPartyInvite(playerParty);
|
mcMMOTarget.setPartyInvite(playerParty);
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
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"));
|
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|||||||
@@ -9,31 +9,26 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyJoinCommand implements CommandExecutor {
|
public class PartyJoinCommand implements CommandExecutor {
|
||||||
private McMMOPlayer mcMMOTarget;
|
|
||||||
private Player target;
|
|
||||||
private Party targetParty;
|
|
||||||
|
|
||||||
private McMMOPlayer mcMMOPlayer;
|
private McMMOPlayer mcMMOPlayer;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Party playerParty;
|
private Party targetParty;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
|
player = (Player) sender;
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
// Verify target exists and is in a different party than the player
|
// Verify target exists and is in a different party than the player
|
||||||
if (!canJoinParty(sender, args[1])) {
|
if (!canJoinParty(sender, args[1])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
|
||||||
player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
String password = getPassword(args);
|
String password = getPassword(args);
|
||||||
|
|
||||||
// Make sure party passwords match
|
// Make sure party passwords match
|
||||||
@@ -41,12 +36,15 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String partyName = targetParty.getName();
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||||
|
PartyManager.addToParty(mcMMOPlayer, targetParty);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -64,26 +62,21 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canJoinParty(CommandSender sender, String targetName) {
|
private boolean canJoinParty(CommandSender sender, String targetName) {
|
||||||
mcMMOTarget = UserManager.getPlayer(targetName);
|
// Short-circuit for joining your own party
|
||||||
|
if (sender.getName().equalsIgnoreCase(targetName)) {
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
target = mcMMOTarget.getPlayer();
|
targetParty = PartyManager.getPlayerParty(targetName);
|
||||||
|
|
||||||
if (!mcMMOTarget.inParty()) {
|
if (targetParty == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = (Player) sender;
|
// Can't join your own party
|
||||||
mcMMOPlayer = UserManager.getPlayer(player);
|
if (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty)) {
|
||||||
|
|
||||||
playerParty = mcMMOPlayer.getParty();
|
|
||||||
targetParty = mcMMOTarget.getParty();
|
|
||||||
|
|
||||||
if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
if (!playerParty.getMembers().contains(target.getName())) {
|
if (!playerParty.getMembers().contains(target.getName())) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ public class PartyLockCommand implements CommandExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle unlocking a party.
|
* Handle unlocking a party.
|
||||||
*
|
|
||||||
* @return true if party is successfully unlocked, false otherwise.
|
|
||||||
*/
|
*/
|
||||||
private void unlockParty(CommandSender sender, String permissionMessage) {
|
private void unlockParty(CommandSender sender, String permissionMessage) {
|
||||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
|
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
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.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@@ -17,13 +18,14 @@ public class PartyQuitCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Player player = (Player) sender;
|
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)) {
|
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.removeFromParty(player, playerParty);
|
PartyManager.removeFromParty(mcMMOPlayer);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ public class PartyRenameCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
Party newParty = PartyManager.getParty(newPartyName);
|
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel renaming the party
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
|||||||
Player target = mcMMOPlayer.getPtpRequest();
|
Player target = mcMMOPlayer.getPtpRequest();
|
||||||
mcMMOPlayer.removePtpRequest();
|
mcMMOPlayer.removePtpRequest();
|
||||||
|
|
||||||
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
|
if (!PtpCommand.canTeleport(player, target.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ import org.bukkit.util.StringUtil;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class PtpCommand implements TabExecutor {
|
public class PtpCommand implements TabExecutor {
|
||||||
@@ -76,10 +77,10 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||||
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
long ptpLastUse = mcMMOPlayer.getPtpLastUse();
|
||||||
|
|
||||||
if (ptpCooldown > 0) {
|
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) {
|
if (timeRemaining > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
|
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
|
||||||
@@ -87,7 +88,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTeleportRequest(sender, player, args[0]);
|
sendTeleportRequest(player, Misc.getMatchedPlayerName(args[0]));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
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()));
|
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
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()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +113,8 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
private void sendTeleportRequest(Player player, String targetName) {
|
||||||
if (!canTeleport(sender, player, targetName)) {
|
if (!canTeleport(player, targetName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,21 +132,21 @@ public class PtpCommand implements TabExecutor {
|
|||||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
|
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
|
protected static boolean canTeleport(Player player, String targetName) {
|
||||||
mcMMOTarget = UserManager.getPlayer(targetName);
|
target = mcMMO.p.getServer().getPlayerExact(targetName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
if (target == null) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
target = mcMMOTarget.getPlayer();
|
|
||||||
targetName = target.getName();
|
|
||||||
|
|
||||||
if (player.equals(target)) {
|
if (player.equals(target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOTarget = UserManager.getPlayer(target);
|
||||||
|
|
||||||
if (!PartyManager.inSameParty(player, target)) {
|
if (!PartyManager.inSameParty(player, target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
return false;
|
return false;
|
||||||
@@ -177,25 +178,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
|
||||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
|
||||||
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
teleportingPlayer.teleport(targetPlayer);
|
|
||||||
|
|
||||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
|
||||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
|
||||||
|
|
||||||
mcMMOPlayer.actualizeRecentlyHurt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -28,44 +29,42 @@ public class InspectCommand implements TabExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
|
||||||
|
|
||||||
// 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 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) {
|
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))) {
|
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||||
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
||||||
return true;
|
|
||||||
|
if (!Config.getInstance().getInspectUseChat()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
for (SkillType skill : SkillType.GATHERING_SKILLS) {
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
|
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
|
}
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
|
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
|
for (SkillType skill : SkillType.COMBAT_SKILLS) {
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
|
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
|
}
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
|
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
|
for (SkillType skill : SkillType.MISC_SKILLS) {
|
||||||
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
|
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Player target = mcMMOPlayer.getPlayer();
|
Player target = mcMMOPlayer.getPlayer();
|
||||||
@@ -80,9 +79,12 @@ public class InspectCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||||
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
|
||||||
return true;
|
|
||||||
|
if (!Config.getInstance().getInspectUseChat()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||||
@@ -103,7 +105,7 @@ public class InspectCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class MccooldownCommand implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (Config.getInstance().getCooldownUseBoard()) {
|
||||||
|
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
||||||
|
|
||||||
|
if (!Config.getInstance().getCooldownUseChat()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
||||||
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||||
|
|
||||||
|
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||||
|
if (!ability.getPermissions(player)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
|
||||||
|
|
||||||
|
if (seconds <= 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,11 +13,12 @@ import org.bukkit.util.StringUtil;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McrankCommand implements TabExecutor {
|
public class McrankCommand implements TabExecutor {
|
||||||
@@ -34,13 +35,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getMcrankScoreboardEnabled()) {
|
display(sender, sender.getName());
|
||||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
|
||||||
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
display(sender, sender.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -50,13 +45,14 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = args[0];
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
playerName = mcMMOPlayer.getPlayer().getName();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
playerName = player.getName();
|
||||||
|
|
||||||
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) {
|
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,13 +60,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
|
display(sender, playerName);
|
||||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
|
||||||
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
display(sender, playerName);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -82,7 +72,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
Set<String> playerNames = UserManager.getPlayerNames();
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
@@ -90,6 +80,20 @@ public class McrankCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void display(CommandSender sender, String playerName) {
|
private void display(CommandSender sender, String playerName) {
|
||||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
if (sender instanceof Player) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
|
||||||
|
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
|
||||||
|
|
||||||
|
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McstatsCommand implements TabExecutor {
|
public class McstatsCommand implements TabExecutor {
|
||||||
@@ -25,28 +25,29 @@ public class McstatsCommand implements TabExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
if (Config.getInstance().getStatsUseBoard()) {
|
||||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||||
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
|
|
||||||
|
if (!Config.getInstance().getStatsUseChat()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||||
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||||
|
|
||||||
|
CommandUtils.printGatheringSkills(player);
|
||||||
|
CommandUtils.printCombatSkills(player);
|
||||||
|
CommandUtils.printMiscSkills(player);
|
||||||
|
|
||||||
|
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||||
|
|
||||||
|
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
|
||||||
|
|
||||||
CommandUtils.printGatheringSkills(player);
|
|
||||||
CommandUtils.printCombatSkills(player);
|
|
||||||
CommandUtils.printMiscSkills(player);
|
|
||||||
|
|
||||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
|
||||||
|
|
||||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,36 +11,40 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MctopCommand implements TabExecutor {
|
public class MctopCommand implements TabExecutor {
|
||||||
private SkillType skill;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
SkillType skill = null;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
display(1, "ALL", sender, command);
|
display(1, skill, sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (StringUtils.isInt(args[0])) {
|
if (StringUtils.isInt(args[0])) {
|
||||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
|
display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extractSkill(sender, args[0])) {
|
skill = extractSkill(sender, args[0]);
|
||||||
|
|
||||||
|
if (skill == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(1, skill.toString(), sender, command);
|
display(1, skill, sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -48,11 +52,13 @@ public class MctopCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extractSkill(sender, args[0])) {
|
skill = extractSkill(sender, args[0]);
|
||||||
|
|
||||||
|
if (skill == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command);
|
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -70,35 +76,44 @@ public class MctopCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(int page, String skill, CommandSender sender, Command command) {
|
private void display(int page, SkillType skill, CommandSender sender, Command command) {
|
||||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
if (skill != null && !Permissions.mctop(sender, skill)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
|
if (sender instanceof Player) {
|
||||||
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
}
|
|
||||||
else {
|
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||||
display(page, skill, sender);
|
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display(page, skill, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(int page, String query, CommandSender sender) {
|
private void display(int page, SkillType skill, CommandSender sender) {
|
||||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
|
||||||
|
boolean useChat = useBoard ? Config.getInstance().getTopUseChat() : true;
|
||||||
|
|
||||||
|
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean extractSkill(CommandSender sender, String skillName) {
|
private SkillType extractSkill(CommandSender sender, String skillName) {
|
||||||
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = SkillType.getSkill(skillName);
|
SkillType skill = SkillType.getSkill(skillName);
|
||||||
|
|
||||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return skill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,15 +82,15 @@ public class AcrobaticsCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canRoll) {
|
if (canRoll) {
|
||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canGracefulRoll) {
|
if (canGracefulRoll) {
|
||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canDodge) {
|
if (canDodge) {
|
||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDaze) {
|
if (canDaze) {
|
||||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRetrieve) {
|
if (canRetrieve) {
|
||||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
public class AxesCommand extends SkillCommand {
|
public class AxesCommand extends SkillCommand {
|
||||||
private String critChance;
|
private String critChance;
|
||||||
private String critChanceLucky;
|
private String critChanceLucky;
|
||||||
private float bonusDamage;
|
private double bonusDamage;
|
||||||
private float impactDamage;
|
private double impactDamage;
|
||||||
private String skullSplitterLength;
|
private String skullSplitterLength;
|
||||||
private String skullSplitterLengthEndurance;
|
private String skullSplitterLengthEndurance;
|
||||||
|
|
||||||
@@ -109,11 +109,11 @@ public class AxesCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canCritical) {
|
if (canCritical) {
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSkullSplitter) {
|
if (canSkullSplitter) {
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canGigaDrill) {
|
if (canGigaDrill) {
|
||||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,36 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class FishingCommand extends SkillCommand {
|
public class FishingCommand extends SkillCommand {
|
||||||
private int lootTier;
|
private int lootTier;
|
||||||
private String magicChance;
|
|
||||||
private String magicChanceLucky;
|
|
||||||
private String chanceRaining = "";
|
|
||||||
private String shakeChance;
|
private String shakeChance;
|
||||||
private String shakeChanceLucky;
|
private String shakeChanceLucky;
|
||||||
private int fishermansDietRank;
|
private int fishermansDietRank;
|
||||||
private String biteChance;
|
private String biteChance;
|
||||||
|
|
||||||
|
private String trapTreasure;
|
||||||
|
private String commonTreasure;
|
||||||
|
private String uncommonTreasure;
|
||||||
|
private String rareTreasure;
|
||||||
|
private String epicTreasure;
|
||||||
|
private String legendaryTreasure;
|
||||||
|
private String recordTreasure;
|
||||||
|
|
||||||
|
private String magicChance;
|
||||||
|
|
||||||
private boolean canTreasureHunt;
|
private boolean canTreasureHunt;
|
||||||
private boolean canMagicHunt;
|
private boolean canMagicHunt;
|
||||||
private boolean canShake;
|
private boolean canShake;
|
||||||
@@ -38,16 +49,24 @@ public class FishingCommand extends SkillCommand {
|
|||||||
// TREASURE HUNTER
|
// TREASURE HUNTER
|
||||||
if (canTreasureHunt) {
|
if (canTreasureHunt) {
|
||||||
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
||||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
|
||||||
|
|
||||||
if (isStorming) {
|
// Item drop rates
|
||||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
|
||||||
enchantChance *= 1.1D;
|
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
|
||||||
}
|
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
|
||||||
|
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
|
||||||
|
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
|
||||||
|
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
|
||||||
|
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
|
||||||
|
|
||||||
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
|
// Magic hunter drop rates
|
||||||
magicChance = treasureHunterStrings[0];
|
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
|
||||||
magicChanceLucky = treasureHunterStrings[1];
|
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
|
||||||
|
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
|
||||||
|
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
|
||||||
|
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
|
||||||
|
|
||||||
|
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHAKE
|
// SHAKE
|
||||||
@@ -64,15 +83,17 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||||
Biome biome = player.getLocation().getBlock().getBiome();
|
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation();
|
||||||
|
|
||||||
|
Biome biome = location.getBlock().getBiome();
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||||
rawBiteChance = rawBiteChance * 2.0;
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||||
rawBiteChance = rawBiteChance * 2.0;
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
||||||
@@ -106,20 +127,20 @@ public class FishingCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canShake) {
|
if (canIceFish) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||||
}
|
|
||||||
|
|
||||||
if (canFishermansDiet) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canIceFish) {
|
if (canShake) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canFishermansDiet) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,31 +151,13 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canMasterAngler) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canTreasureHunt) {
|
if (canTreasureHunt) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canMagicHunt) {
|
if (canMagicHunt) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
|
||||||
}
|
|
||||||
|
|
||||||
if (canShake) {
|
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
|
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canFishermansDiet) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canIceFish) {
|
if (canIceFish) {
|
||||||
@@ -167,5 +170,31 @@ public class FishingCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canMasterAngler) {
|
||||||
|
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
|
||||||
|
|
||||||
|
if (skillValue < unlockLevel) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canShake) {
|
||||||
|
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
|
||||||
|
|
||||||
|
if (skillValue < unlockLevel) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canFishermansDiet) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,11 +135,11 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canGreenTerra) {
|
if (canGreenTerra) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canGreenThumbPlants) {
|
if (canGreenThumbPlants) {
|
||||||
@@ -151,15 +151,15 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasHylianLuck) {
|
if (hasHylianLuck) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canShroomThumb) {
|
if (canShroomThumb) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canDoubleDrop) {
|
if (canDoubleDrop) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.skills;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||||
import com.gmail.nossr50.skills.mining.Mining;
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -106,26 +107,26 @@ public class MiningCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canDoubleDrop) {
|
if (canDoubleDrop) {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSuperBreaker) {
|
if (canSuperBreaker) {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBlast) {
|
if (canBlast) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
|
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBiggerBombs) {
|
if (canBiggerBombs) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
|
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
||||||
@@ -136,7 +137,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDemoExpert) {
|
if (canDemoExpert) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
|
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||||
|
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class RepairCommand extends SkillCommand {
|
public class RepairCommand extends SkillCommand {
|
||||||
@@ -41,10 +42,10 @@ public class RepairCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
// We're using pickaxes here, not the best but it works
|
// We're using pickaxes here, not the best but it works
|
||||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
|
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
||||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
|
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
|
||||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
|
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
|
||||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
|
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
|
||||||
|
|
||||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||||
@@ -139,13 +140,13 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canSuperRepair) {
|
if (canSuperRepair) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canArcaneForge) {
|
if (canArcaneForge) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
|
||||||
|
|
||||||
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
|
|
||||||
public SkillCommand(SkillType skill) {
|
public SkillCommand(SkillType skill) {
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
skillName = SkillUtils.getSkillName(skill);
|
skillName = skill.getName();
|
||||||
skillGuideCommand = new SkillGuideCommand(skill);
|
skillGuideCommand = new SkillGuideCommand(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,17 +69,14 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
permissionsCheck();
|
permissionsCheck();
|
||||||
dataCalculations();
|
dataCalculations();
|
||||||
|
|
||||||
|
if (Config.getInstance().getSkillUseBoard()) {
|
||||||
|
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||||
|
}
|
||||||
|
|
||||||
if (!skill.isChildSkill()) {
|
if (!skill.isChildSkill()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||||
if (Config.getInstance().getSkillScoreboardEnabled()) {
|
|
||||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
|
||||||
ScoreboardManager.enablePlayerSkillScoreboard(mcMMOPlayer, skill);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||||
@@ -91,7 +87,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||||
|
|
||||||
for (SkillType parent : parents) {
|
for (SkillType parent : parents) {
|
||||||
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +139,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String[] calculateLengthDisplayValues() {
|
protected String[] calculateLengthDisplayValues() {
|
||||||
int maxLength = skill.getAbility().getMaxTicks();
|
int maxLength = skill.getAbility().getMaxLength();
|
||||||
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||||
|
|
||||||
@@ -157,7 +153,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
protected void luckyEffectsDisplay() {
|
protected void luckyEffectsDisplay() {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName)));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -9,17 +10,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class SkillGuideCommand implements CommandExecutor {
|
public class SkillGuideCommand implements CommandExecutor {
|
||||||
private String header;
|
private String header;
|
||||||
private String[] guide;
|
private ArrayList<String> guide;
|
||||||
|
|
||||||
private String invalidPage;
|
private String invalidPage;
|
||||||
|
|
||||||
public SkillGuideCommand(SkillType skillType) {
|
public SkillGuideCommand(SkillType skillType) {
|
||||||
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
|
header = LocaleLoader.getString("Guides.Header", skillType.getName());
|
||||||
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
|
guide = getGuide(skillType);
|
||||||
|
|
||||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getTotalPageNumber() {
|
private int getTotalPageNumber() {
|
||||||
return (int) Math.ceil(guide.length / 8.0);
|
return (int) Math.ceil(guide.size() / 8.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendGuide(CommandSender sender, int pageNumber) {
|
private void sendGuide(CommandSender sender, int pageNumber) {
|
||||||
@@ -76,15 +76,38 @@ public class SkillGuideCommand implements CommandExecutor {
|
|||||||
|
|
||||||
// Add targeted strings
|
// Add targeted strings
|
||||||
while (allStrings.size() < 9) {
|
while (allStrings.size() < 9) {
|
||||||
if (pageIndexStart + allStrings.size() > guide.length) {
|
if (pageIndexStart + allStrings.size() > guide.size()) {
|
||||||
allStrings.add("");
|
allStrings.add("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
|
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
|
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
|
||||||
return allStrings;
|
return allStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<String> getGuide(SkillType skillType) {
|
||||||
|
ArrayList<String> guide = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n");
|
||||||
|
|
||||||
|
if (section[0].startsWith("!")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
guide.addAll(Arrays.asList(section));
|
||||||
|
|
||||||
|
if (section.length < 8) {
|
||||||
|
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
|
||||||
|
guide.add("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return guide;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||||
|
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class SmeltingCommand extends SkillCommand {
|
public class SmeltingCommand extends SkillCommand {
|
||||||
@@ -90,11 +91,11 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canSecondSmelt) {
|
if (canSecondSmelt) {
|
||||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canVanillaXPBoost) {
|
if (canVanillaXPBoost) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
|
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
|
||||||
@@ -109,7 +110,7 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,17 +86,17 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
if (canCounter) {
|
if (canCounter) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBleed) {
|
if (canBleed) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
|
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSerratedStrike) {
|
if (canSerratedStrike) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -36,7 +38,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck() {
|
protected void permissionsCheck() {
|
||||||
canBeastLore = Permissions.beastLore(player);
|
canBeastLore = Permissions.beastLore(player);
|
||||||
canCallWild = Permissions.callOfTheWild(player);
|
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||||
canFastFood = Permissions.fastFoodService(player);
|
canFastFood = Permissions.fastFoodService(player);
|
||||||
canGore = Permissions.gore(player);
|
canGore = Permissions.gore(player);
|
||||||
@@ -91,6 +93,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +159,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canGore) {
|
if (canGore) {
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
private String disarmChanceLucky;
|
private String disarmChanceLucky;
|
||||||
private String ironGripChance;
|
private String ironGripChance;
|
||||||
private String ironGripChanceLucky;
|
private String ironGripChanceLucky;
|
||||||
private int ironArmBonus;
|
private double ironArmBonus;
|
||||||
|
|
||||||
private boolean canBerserk;
|
private boolean canBerserk;
|
||||||
private boolean canDisarm;
|
private boolean canDisarm;
|
||||||
@@ -113,19 +113,19 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDeflect) {
|
if (canDeflect) {
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canDisarm) {
|
if (canDisarm) {
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canIronGrip) {
|
if (canIronGrip) {
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBerserk) {
|
if (canBerserk) {
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDoubleDrop) {
|
if (canDoubleDrop) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canTreeFell) {
|
if (canTreeFell) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.spout;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
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 {
|
|
||||||
private static final List<String> HUD_TYPES;
|
|
||||||
|
|
||||||
static {
|
|
||||||
ArrayList<String> types = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (HudType type : HudType.values()) {
|
|
||||||
types.add(type.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(types);
|
|
||||||
HUD_TYPES = ImmutableList.copyOf(types);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
|
|
||||||
default:
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
|
||||||
try {
|
|
||||||
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
|
|
||||||
spoutHud.initializeXpBar();
|
|
||||||
spoutHud.updateXpBar();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.spout;
|
|
||||||
|
|
||||||
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.spout.SpoutConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
|
|
||||||
public abstract class SpoutCommand implements TabExecutor {
|
|
||||||
protected PlayerProfile playerProfile;
|
|
||||||
protected McMMOHud spoutHud;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
|
||||||
spoutHud = playerProfile.getSpoutHud();
|
|
||||||
|
|
||||||
if (spoutHud == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
return noArguments(command, sender, args);
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
return oneArgument(command, sender, args);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
|
||||||
|
|
||||||
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.spout;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
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 {
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
|
||||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches;
|
|
||||||
default:
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
|
||||||
if (spoutHud.getXpBarLocked()) {
|
|
||||||
unlockXpBar(sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
lockXpBar(sender, spoutHud.getLastGained());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
|
||||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
|
||||||
lockXpBar(sender, spoutHud.getLastGained());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
|
||||||
unlockXpBar(sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.isInvalidSkill(sender, args[0])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkillType skill = SkillType.getSkill(args[0]);
|
|
||||||
|
|
||||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.xplock(sender, skill)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
lockXpBar(sender, skill);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lockXpBar(CommandSender sender, SkillType skill) {
|
|
||||||
if (skill != null) {
|
|
||||||
spoutHud.setXpBarLocked(true);
|
|
||||||
spoutHud.setSkillLock(skill);
|
|
||||||
spoutHud.updateXpBar();
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unlockXpBar(CommandSender sender) {
|
|
||||||
spoutHud.setXpBarLocked(false);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
output = output.replace(" ", " ");
|
output = output.replace(" ", " ");
|
||||||
|
|
||||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||||
while (output.indexOf('#') != -1) {
|
while (output.replaceAll("[//s]", "").startsWith("#")) {
|
||||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
|
|
||||||
// Dump to the new one
|
// Dump to the new one
|
||||||
for (String key : comments.keySet()) {
|
for (String key : comments.keySet()) {
|
||||||
if (output.indexOf(key) != -1) {
|
if (output.contains(key)) {
|
||||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -16,6 +18,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
private Config() {
|
private Config() {
|
||||||
super("config.yml");
|
super("config.yml");
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config getInstance() {
|
public static Config getInstance() {
|
||||||
@@ -26,6 +29,167 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
return instance;
|
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 (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||||
|
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(getRankUseChat() || getRankUseBoard())) {
|
||||||
|
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(getTopUseChat() || getTopUseBoard())) {
|
||||||
|
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(getStatsUseChat() || getStatsUseBoard())) {
|
||||||
|
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(getInspectUseChat() || getInspectUseBoard())) {
|
||||||
|
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Database Purging */
|
||||||
|
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() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
|
||||||
|
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
|
||||||
|
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 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 (getChimaeraItem() == null) {
|
||||||
|
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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 (getDetonatorItem() == null) {
|
||||||
|
reason.add("Skills.Mining.Detonator_Item is invalid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getRepairAnvilMaterial() == null) {
|
||||||
|
reason.add("Skills.Repair.Anvil_Type is invalid!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSalvageAnvilMaterial() == null) {
|
||||||
|
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
|
||||||
|
reason.add("Cannot use the same item 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
|
@Override
|
||||||
protected void loadKeys() {}
|
protected void loadKeys() {}
|
||||||
|
|
||||||
@@ -46,8 +210,14 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||||
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
||||||
|
|
||||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
||||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
|
||||||
|
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
|
||||||
|
|
||||||
|
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
|
||||||
|
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
|
||||||
|
|
||||||
|
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
||||||
|
|
||||||
/* Mob Healthbar */
|
/* Mob Healthbar */
|
||||||
public MobHealthbarType getMobHealthbarDefault() {
|
public MobHealthbarType getMobHealthbarDefault() {
|
||||||
@@ -62,22 +232,35 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||||
|
|
||||||
/* Scoreboards */
|
/* Scoreboards */
|
||||||
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
|
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
||||||
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
||||||
|
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
||||||
|
|
||||||
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
|
||||||
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
|
||||||
|
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
|
||||||
|
|
||||||
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
|
||||||
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
|
||||||
|
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
|
||||||
|
|
||||||
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
|
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
|
||||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
|
public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
|
||||||
|
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
|
||||||
|
|
||||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
|
||||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
|
||||||
|
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
|
||||||
|
|
||||||
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
|
||||||
|
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
|
||||||
|
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
|
||||||
|
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
|
||||||
|
|
||||||
|
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
||||||
|
|
||||||
|
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
||||||
|
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
||||||
|
|
||||||
/* Database Purging */
|
/* Database Purging */
|
||||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||||
@@ -86,55 +269,48 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* mySQL */
|
/* mySQL */
|
||||||
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
|
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
|
||||||
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
|
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
|
||||||
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
|
public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
|
||||||
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
|
public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
|
||||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||||
|
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
|
||||||
|
|
||||||
public String getMySQLUserPassword() {
|
private String getStringIncludingInts(String key) {
|
||||||
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
|
String str = config.getString(key);
|
||||||
return getStringIncludingInts(config, "MySQL.Database.User_Password");
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
|
||||||
String str = cfg.getString(key);
|
|
||||||
|
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
str = String.valueOf(cfg.getInt(key));
|
str = String.valueOf(config.getInt(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str == "0") {
|
if (str.equals("0")) {
|
||||||
str = "No value set for '" + key + "'";
|
str = "No value set for '" + key + "'";
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hardcore Mode */
|
/* Hardcore Mode */
|
||||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||||
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
|
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 double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
||||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
|
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 boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
|
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 double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
||||||
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
|
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
||||||
|
|
||||||
/* SMP Mods */
|
/* SMP Mods */
|
||||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
|
||||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||||
|
|
||||||
/* Items */
|
/* Items */
|
||||||
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
||||||
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
||||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
public Material getChimaeraItem() { return Material.matchMaterial(config.getString("Items.Chimaera_Wing.Item_Name", "Feather")); }
|
||||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||||
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
||||||
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
||||||
@@ -155,11 +331,11 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||||
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
||||||
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
||||||
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
|
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
|
||||||
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
|
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05D); }
|
||||||
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
|
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5D); }
|
||||||
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
||||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0D); }
|
||||||
|
|
||||||
/* Party Teleport Settings */
|
/* Party Teleport Settings */
|
||||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
|
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
|
||||||
@@ -170,7 +346,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||||
|
|
||||||
/* Inspect command distance */
|
/* Inspect command distance */
|
||||||
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
|
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABILITY SETTINGS
|
* ABILITY SETTINGS
|
||||||
@@ -182,11 +358,10 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
||||||
|
|
||||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
||||||
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||||
|
|
||||||
/* Durability Settings */
|
/* Durability Settings */
|
||||||
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
|
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
|
||||||
|
|
||||||
/* Thresholds */
|
/* Thresholds */
|
||||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||||
@@ -194,8 +369,6 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/*
|
/*
|
||||||
* SKILL SETTINGS
|
* 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 getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||||
|
|
||||||
public boolean getDoubleDropsDisabled(SkillType skill) {
|
public boolean getDoubleDropsDisabled(SkillType skill) {
|
||||||
@@ -216,18 +389,18 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Acrobatics */
|
/* Acrobatics */
|
||||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
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 */
|
/* Fishing */
|
||||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
|
||||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||||
|
|
||||||
/* Mining */
|
/* Mining */
|
||||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
||||||
|
|
||||||
/* Repair */
|
/* Repair */
|
||||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
|
||||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_ID", "GOLD_BLOCK")); }
|
||||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||||
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
||||||
@@ -236,27 +409,22 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
|
||||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
|
||||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_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 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.0D); }
|
||||||
|
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* 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 getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
|
||||||
|
public boolean getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||||
|
|
||||||
/* Level Caps */
|
/* Level Caps */
|
||||||
public int getPowerLevelCap() {
|
public int getPowerLevelCap() {
|
||||||
@@ -272,27 +440,4 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* PVP & PVE Settings */
|
/* PVP & PVE Settings */
|
||||||
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
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); }
|
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())); }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.util.List;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -15,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
public abstract class ConfigLoader {
|
public abstract class ConfigLoader {
|
||||||
protected static final mcMMO plugin = mcMMO.p;
|
protected static final mcMMO plugin = mcMMO.p;
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
protected File configFile;
|
private File configFile;
|
||||||
protected FileConfiguration config;
|
protected FileConfiguration config;
|
||||||
|
|
||||||
public ConfigLoader(String relativePath, String fileName) {
|
public ConfigLoader(String relativePath, String fileName) {
|
||||||
@@ -33,7 +29,13 @@ public abstract class ConfigLoader {
|
|||||||
protected void loadFile() {
|
protected void loadFile() {
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||||
createFile();
|
|
||||||
|
try {
|
||||||
|
plugin.saveResource(fileName, false); // Normal files
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||||
@@ -44,50 +46,45 @@ public abstract class ConfigLoader {
|
|||||||
|
|
||||||
protected abstract void loadKeys();
|
protected abstract void loadKeys();
|
||||||
|
|
||||||
protected void createFile() {
|
protected boolean validateKeys() {
|
||||||
configFile.getParentFile().mkdirs();
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
InputStream inputStream = plugin.getResource(fileName);
|
protected boolean noErrorsInConfig(List<String> issues) {
|
||||||
|
for (String issue : issues) {
|
||||||
if (inputStream == null) {
|
plugin.getLogger().warning(issue);
|
||||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream outputStream = null;
|
return issues.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
protected void validate() {
|
||||||
outputStream = new FileOutputStream(configFile);
|
if (validateKeys()) {
|
||||||
|
plugin.debug("No errors found in " + fileName + "!");
|
||||||
int read;
|
|
||||||
byte[] bytes = new byte[1024];
|
|
||||||
|
|
||||||
while ((read = inputStream.read(bytes)) != -1) {
|
|
||||||
outputStream.write(bytes, 0, read);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e) {
|
else {
|
||||||
e.printStackTrace();
|
plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
|
||||||
}
|
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||||
catch (IOException e) {
|
plugin.noErrorsInConfigFiles = false;
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (outputStream != null) {
|
|
||||||
try {
|
|
||||||
outputStream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return configFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void backup() {
|
||||||
|
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
||||||
|
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
||||||
|
|
||||||
|
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||||
|
|
||||||
|
if (plugin.getResource(fileName) != null) {
|
||||||
|
plugin.saveResource(fileName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||||
|
loadFile();
|
||||||
|
loadKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
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.repairables.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!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getDodgeXPModifier() < 0) {
|
||||||
|
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getRollXPModifier() < 0) {
|
||||||
|
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getFallXPModifier() < 0) {
|
||||||
|
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fishing */
|
||||||
|
if (getFishingBaseXP() <= 0) {
|
||||||
|
reason.add("Experience.Fishing.Base should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getFishingShakeXP() <= 0) {
|
||||||
|
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Repair */
|
||||||
|
if (getRepairXPBase() <= 0) {
|
||||||
|
reason.add("Experience.Repair.Base should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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(" ", "_")); }
|
||||||
|
|
||||||
|
/* Acrobatics */
|
||||||
|
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
|
||||||
|
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
|
||||||
|
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
|
||||||
|
|
||||||
|
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||||
|
|
||||||
|
/* Fishing */
|
||||||
|
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||||
|
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
||||||
|
|
||||||
|
/* 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); }
|
||||||
|
}
|
||||||
@@ -1,33 +1,34 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||||
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
|
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||||
|
|
||||||
public class CustomArmorConfig extends ConfigLoader {
|
public class CustomArmorConfig extends ConfigLoader {
|
||||||
private static CustomArmorConfig instance;
|
private static CustomArmorConfig instance;
|
||||||
|
|
||||||
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
|
|
||||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
private List<Material> customBoots = new ArrayList<Material>();
|
||||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
private List<Material> customChestplates = new ArrayList<Material>();
|
||||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
private List<Material> customHelmets = new ArrayList<Material>();
|
||||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
private List<Material> customLeggings = new ArrayList<Material>();
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
|
||||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
|
||||||
|
|
||||||
public CustomArmorConfig() {
|
public CustomArmorConfig() {
|
||||||
super("ModConfigs", "armor.yml");
|
super("mods", "armor.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,13 +52,22 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadArmor("Boots", customBootIDs);
|
loadArmor("Boots", customBoots);
|
||||||
loadArmor("Chestplates", customChestplateIDs);
|
loadArmor("Chestplates", customChestplates);
|
||||||
loadArmor("Helmets", customHelmetIDs);
|
loadArmor("Helmets", customHelmets);
|
||||||
loadArmor("Leggings", customLeggingIDs);
|
loadArmor("Leggings", customLeggings);
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
|
needsUpdate = false;
|
||||||
|
backup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadArmor(String armorType, List<Integer> idList) {
|
private void loadArmor(String armorType, List<Material> materialList) {
|
||||||
|
if (needsUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||||
|
|
||||||
if (armorSection == null) {
|
if (armorSection == null) {
|
||||||
@@ -67,35 +77,60 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||||
|
|
||||||
for (String armorName : armorConfigSet) {
|
for (String armorName : armorConfigSet) {
|
||||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
if (config.contains(armorType + "." + armorName + "." + ".ID")) {
|
||||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
needsUpdate = true;
|
||||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
return;
|
||||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
}
|
||||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
|
||||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
|
||||||
|
|
||||||
if (id == 0) {
|
Material armorMaterial = Material.matchMaterial(armorName);
|
||||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
|
||||||
|
if (armorMaterial == null) {
|
||||||
|
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
||||||
|
|
||||||
|
if (repairMaterial == null) {
|
||||||
|
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
|
||||||
repairable = false;
|
repairable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomItem armor;
|
|
||||||
|
|
||||||
if (repairable) {
|
if (repairable) {
|
||||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
||||||
|
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||||
|
|
||||||
|
if (repairQuantity == 0) {
|
||||||
|
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
short durability = armorMaterial.getMaxDurability();
|
||||||
|
|
||||||
|
if (durability == 0) {
|
||||||
|
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||||
|
}
|
||||||
|
|
||||||
|
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
armor = new CustomItem(id, durability);
|
materialList.add(armorMaterial);
|
||||||
|
|
||||||
idList.add(id);
|
|
||||||
customIDs.add(id);
|
|
||||||
customArmorList.add(armor);
|
|
||||||
customArmor.put(id, armor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomBoots(Material material) {
|
||||||
|
return customBoots.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomChestplate(Material material) {
|
||||||
|
return customChestplates.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomHelmet(Material material) {
|
||||||
|
return customHelmets.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomLeggings(Material material) {
|
||||||
|
return customLeggings.contains(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
@@ -14,20 +15,21 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|||||||
public class CustomBlockConfig extends ConfigLoader {
|
public class CustomBlockConfig extends ConfigLoader {
|
||||||
private static CustomBlockConfig instance;
|
private static CustomBlockConfig instance;
|
||||||
|
|
||||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
private boolean needsUpdate = false;
|
||||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||||
|
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||||
|
|
||||||
|
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||||
|
|
||||||
public CustomBlockConfig() {
|
public CustomBlockConfig() {
|
||||||
super("ModConfigs", "blocks.yml");
|
super("mods", "blocks.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,9 +48,18 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
loadBlocks("Mining", customMiningBlocks);
|
loadBlocks("Mining", customMiningBlocks);
|
||||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
|
needsUpdate = false;
|
||||||
|
backup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||||
|
if (needsUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||||
|
|
||||||
if (skillSection == null) {
|
if (skillSection == null) {
|
||||||
@@ -58,63 +69,80 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||||
|
|
||||||
for (String blockName : skillConfigSet) {
|
for (String blockName : skillConfigSet) {
|
||||||
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
|
||||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
needsUpdate = true;
|
||||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
return;
|
||||||
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
|
}
|
||||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
|
||||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
|
||||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
|
||||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
|
||||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
|
||||||
|
|
||||||
CustomBlock block;
|
String[] blockInfo = blockName.split("[|]");
|
||||||
ItemStack itemDrop;
|
|
||||||
ItemStack blockItem;
|
|
||||||
|
|
||||||
if (id == 0) {
|
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
|
||||||
|
if (blockMaterial == null) {
|
||||||
|
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte blockData = Byte.valueOf(blockInfo[1]);
|
||||||
|
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||||
|
blockList.add(blockMaterialData);
|
||||||
|
|
||||||
if (skillType.equals("Ability_Blocks")) {
|
if (skillType.equals("Ability_Blocks")) {
|
||||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
|
||||||
|
|
||||||
blockList.add(blockItem);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropItem && dropID == 0) {
|
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
|
|
||||||
dropItem = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropItem) {
|
|
||||||
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
itemDrop = (new MaterialData(id, data)).toItemStack(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
|
||||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
|
||||||
|
|
||||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||||
customOres.add(blockItem);
|
customOres.add(blockMaterialData);
|
||||||
}
|
}
|
||||||
else if (skillType.equals("Woodcutting")) {
|
else if (skillType.equals("Woodcutting")) {
|
||||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||||
customLogs.add(blockItem);
|
customLogs.add(blockMaterialData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
customLeaves.add(blockItem);
|
customLeaves.add(blockMaterialData);
|
||||||
block.setXpGain(0); // Leaves don't grant XP
|
xp = 0; // Leaves don't grant XP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockList.add(blockItem);
|
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
|
||||||
customItems.add(blockItem);
|
|
||||||
customBlocks.add(block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomBlock getCustomBlock(MaterialData data) {
|
||||||
|
return customBlockMap.get(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomOre(MaterialData data) {
|
||||||
|
return customOres.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomLog(MaterialData data) {
|
||||||
|
return customLogs.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomLeaf(MaterialData data) {
|
||||||
|
return customLeaves.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomAbilityBlock(MaterialData data) {
|
||||||
|
return customAbilityBlocks.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomExcavationBlock(MaterialData data) {
|
||||||
|
return customExcavationBlocks.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomHerbalismBlock(MaterialData data) {
|
||||||
|
return customHerbalismBlocks.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomMiningBlock(MaterialData data) {
|
||||||
|
return customMiningBlocks.contains(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomWoodcuttingBlock(MaterialData data) {
|
||||||
|
return customWoodcuttingBlocks.contains(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,24 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ClassUtils;
|
||||||
|
|
||||||
public class CustomEntityConfig extends ConfigLoader {
|
public class CustomEntityConfig extends ConfigLoader {
|
||||||
private static CustomEntityConfig instance;
|
private static CustomEntityConfig instance;
|
||||||
|
|
||||||
public List<Integer> customEntityIds = new ArrayList<Integer>();
|
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||||
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
|
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||||
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
|
|
||||||
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
|
|
||||||
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
|
|
||||||
|
|
||||||
public CustomEntityConfig() {
|
public CustomEntityConfig() {
|
||||||
super("ModConfigs", "entities.yml");
|
super("mods", "entities.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,48 +32,86 @@ public class CustomEntityConfig extends ConfigLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
loadMobs("Hostile", customHostileEntityIds);
|
if (config.getConfigurationSection("Hostile") != null) {
|
||||||
loadMobs("Neutral", customNeutralEntityIds);
|
backup();
|
||||||
loadMobs("Passive", customPassiveEntityIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadMobs(String entityType, List<Integer> entityIdList) {
|
|
||||||
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
|
|
||||||
|
|
||||||
if (entitySection == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> entityConfigSet = entitySection.getKeys(false);
|
for (String entityName : config.getKeys(false)) {
|
||||||
|
Class<?> clazz = null;
|
||||||
|
String className = config.getString(entityName + ".Class", "");
|
||||||
|
|
||||||
for (String entityName : entityConfigSet) {
|
try {
|
||||||
int id = config.getInt(entityType + "." + entityName + ".ID", 0);
|
clazz = ClassUtils.getClass(className);
|
||||||
EntityType type = EntityType.fromId(id);
|
}
|
||||||
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
|
catch (ClassNotFoundException e) {
|
||||||
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
|
plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
|
||||||
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0);
|
plugin.getLogger().warning("This custom entity may not function properly.");
|
||||||
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false);
|
|
||||||
int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0);
|
|
||||||
int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0);
|
|
||||||
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0);
|
|
||||||
|
|
||||||
CustomEntity entity;
|
|
||||||
|
|
||||||
if (id == 0) {
|
|
||||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) {
|
String entityTypeName = entityName.replace("_", ".");
|
||||||
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild.");
|
double xpMultiplier = config.getDouble(entityName + ".XP_Multiplier", 1.0D);
|
||||||
|
|
||||||
|
boolean canBeTamed = config.getBoolean(entityName + ".Tameable");
|
||||||
|
int tamingXp = config.getInt(entityName + ".Taming_XP");
|
||||||
|
|
||||||
|
boolean canBeSummoned = config.getBoolean(entityName + ".CanBeSummoned");
|
||||||
|
Material callOfTheWildMaterial = Material.matchMaterial(config.getString(entityName + ".COTW_Material", ""));
|
||||||
|
byte callOfTheWildData = (byte) config.getInt(entityName + ".COTW_Material_Data");
|
||||||
|
int callOfTheWildAmount = config.getInt(entityName + ".COTW_Material_Amount");
|
||||||
|
|
||||||
|
if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
|
||||||
|
plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
|
||||||
canBeSummoned = false;
|
canBeSummoned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount);
|
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
|
||||||
|
|
||||||
entityIdList.add(id);
|
customEntityTypeMap.put(entityTypeName, entity);
|
||||||
customEntityTypes.add(type);
|
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
||||||
customEntities.add(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomEntity(Entity entity) {
|
||||||
|
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||||
|
return customEntityClassMap.containsKey(entity.getClass().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomEntity getCustomEntity(Entity entity) {
|
||||||
|
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
|
||||||
|
|
||||||
|
if (customEntity == null) {
|
||||||
|
try {
|
||||||
|
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||||
|
customEntity = customEntityClassMap.get(entity.getClass().getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return customEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntity(CustomEntity customEntity, String className, String entityName) {
|
||||||
|
customEntityTypeMap.put(entityName, customEntity);
|
||||||
|
customEntityClassMap.put(className, customEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,28 +5,36 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||||
|
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||||
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
|
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||||
|
|
||||||
public class CustomToolConfig extends ConfigLoader {
|
public class CustomToolConfig extends ConfigLoader {
|
||||||
private static CustomToolConfig instance;
|
private static CustomToolConfig instance;
|
||||||
|
|
||||||
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
|
||||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
private List<Material> customAxes = new ArrayList<Material>();
|
||||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
private List<Material> customBows = new ArrayList<Material>();
|
||||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
private List<Material> customHoes = new ArrayList<Material>();
|
||||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
private List<Material> customPickaxes = new ArrayList<Material>();
|
||||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
private List<Material> customShovels = new ArrayList<Material>();
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
private List<Material> customSwords = new ArrayList<Material>();
|
||||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
|
||||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||||
|
|
||||||
private CustomToolConfig() {
|
private CustomToolConfig() {
|
||||||
super("ModConfigs", "tools.yml");
|
super("mods", "tools.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,15 +58,24 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadTool("Axes", customAxeIDs);
|
loadTool("Axes", customAxes);
|
||||||
loadTool("Bows", customBowIDs);
|
loadTool("Bows", customBows);
|
||||||
loadTool("Hoes", customHoeIDs);
|
loadTool("Hoes", customHoes);
|
||||||
loadTool("Pickaxes", customPickaxeIDs);
|
loadTool("Pickaxes", customPickaxes);
|
||||||
loadTool("Shovels", customShovelIDs);
|
loadTool("Shovels", customShovels);
|
||||||
loadTool("Swords", customSwordIDs);
|
loadTool("Swords", customSwords);
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
|
needsUpdate = false;
|
||||||
|
backup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTool(String toolType, List<Integer> idList) {
|
private void loadTool(String toolType, List<Material> materialList) {
|
||||||
|
if (needsUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||||
|
|
||||||
if (toolSection == null) {
|
if (toolSection == null) {
|
||||||
@@ -68,38 +85,83 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||||
|
|
||||||
for (String toolName : toolConfigSet) {
|
for (String toolName : toolConfigSet) {
|
||||||
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
|
||||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
needsUpdate = true;
|
||||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
return;
|
||||||
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
}
|
||||||
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
|
||||||
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
|
|
||||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
|
|
||||||
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
|
|
||||||
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
|
|
||||||
|
|
||||||
if (id == 0) {
|
Material toolMaterial = Material.matchMaterial(toolName);
|
||||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
|
||||||
|
if (toolMaterial == null) {
|
||||||
|
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
||||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
Material repairMaterial = Material.matchMaterial(config.getString(toolType + "." + toolName + ".Repair_Material", ""));
|
||||||
|
|
||||||
|
if (repairMaterial == null) {
|
||||||
|
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
|
||||||
repairable = false;
|
repairable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomTool tool;
|
|
||||||
|
|
||||||
if (repairable) {
|
if (repairable) {
|
||||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
|
||||||
|
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
||||||
|
|
||||||
|
if (repairQuantity == 0) {
|
||||||
|
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
short durability = toolMaterial.getMaxDurability();
|
||||||
|
|
||||||
|
if (durability == 0) {
|
||||||
|
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
|
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||||
|
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||||
|
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
||||||
|
|
||||||
idList.add(id);
|
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
|
||||||
customIDs.add(id);
|
|
||||||
customToolList.add(tool);
|
materialList.add(toolMaterial);
|
||||||
customTools.put(id, tool);
|
customToolMap.put(toolMaterial, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomAxe(Material material) {
|
||||||
|
return customAxes.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomBow(Material material) {
|
||||||
|
return customBows.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomHoe(Material material) {
|
||||||
|
return customHoes.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomPickaxe(Material material) {
|
||||||
|
return customPickaxes.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomShovel(Material material) {
|
||||||
|
return customShovels.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomSword(Material material) {
|
||||||
|
return customSwords.contains(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomTool(Material material) {
|
||||||
|
return customToolMap.containsKey(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomTool getCustomTool(Material material) {
|
||||||
|
return customToolMap.get(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
public class SpoutConfig extends ConfigLoader {
|
|
||||||
private static SpoutConfig instance;
|
|
||||||
|
|
||||||
private SpoutConfig() {
|
|
||||||
super("spout.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SpoutConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new SpoutConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadKeys() {
|
|
||||||
// Setup default HUD
|
|
||||||
}
|
|
||||||
|
|
||||||
public HudType getDefaultHudType() {
|
|
||||||
try {
|
|
||||||
return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
return HudType.STANDARD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
|
||||||
public Keyboard getMenuKey() {
|
|
||||||
try {
|
|
||||||
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
return Keyboard.KEY_M;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XP Bar */
|
|
||||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
|
||||||
public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); }
|
|
||||||
|
|
||||||
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
|
|
||||||
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
|
|
||||||
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
|
|
||||||
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
|
|
||||||
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
|
|
||||||
|
|
||||||
/* HUD Colors */
|
|
||||||
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
|
|
||||||
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
|
|
||||||
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
|
|
||||||
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
|
|
||||||
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
|
|
||||||
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
|
|
||||||
|
|
||||||
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
|
||||||
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
|
||||||
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
|
||||||
|
|
||||||
/* Notification Tiers */
|
|
||||||
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
|
|
||||||
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
|
|
||||||
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
|
|
||||||
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
|
|
||||||
}
|
|
||||||
@@ -3,35 +3,38 @@ package com.gmail.nossr50.config.treasure;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.Dye;
|
||||||
import org.bukkit.potion.Potion;
|
import org.bukkit.potion.Potion;
|
||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||||
|
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||||
|
|
||||||
public class TreasureConfig extends ConfigLoader {
|
public class TreasureConfig extends ConfigLoader {
|
||||||
private static TreasureConfig instance;
|
private static TreasureConfig instance;
|
||||||
|
|
||||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = 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> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||||
@@ -45,6 +48,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
|
||||||
|
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
||||||
@@ -58,7 +62,8 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
||||||
|
|
||||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||||
|
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||||
|
|
||||||
private TreasureConfig() {
|
private TreasureConfig() {
|
||||||
super("treasures.yml");
|
super("treasures.yml");
|
||||||
@@ -75,377 +80,310 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
if (config.getConfigurationSection("Treasures") != null) {
|
||||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
backup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTreaures("Fishing");
|
||||||
|
loadTreaures("Excavation");
|
||||||
|
loadTreaures("Hylian_Luck");
|
||||||
|
loadEnchantments();
|
||||||
|
|
||||||
|
for (EntityType entity : EntityType.values()) {
|
||||||
|
if (entity.isAlive()) {
|
||||||
|
loadTreaures("Shake." + entity.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadTreaures(String type) {
|
||||||
|
boolean isFishing = type.equals("Fishing");
|
||||||
|
boolean isShake = type.contains("Shake");
|
||||||
|
boolean isExcavation = type.equals("Excavation");
|
||||||
|
boolean isHylian = type.equals("Hylian_Luck");
|
||||||
|
|
||||||
|
ConfigurationSection treasureSection = config.getConfigurationSection(type);
|
||||||
|
|
||||||
if (treasureSection == null) {
|
if (treasureSection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
// Initialize fishing HashMap
|
||||||
|
for (Rarity rarity : Rarity.values()) {
|
||||||
for (String treasureName : treasureConfigSet) {
|
if (!fishingRewards.containsKey(rarity)) {
|
||||||
|
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String treasureName : treasureSection.getKeys(false)) {
|
||||||
// Validate all the things!
|
// Validate all the things!
|
||||||
List<String> reason = new ArrayList<String>();
|
List<String> reason = new ArrayList<String>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ID, Amount, and Data
|
* Material, Amount, and Data
|
||||||
*/
|
*/
|
||||||
|
Material material;
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".ID")) {
|
if (treasureName.contains("POTION")) {
|
||||||
reason.add("Missing ID");
|
material = Material.POTION;
|
||||||
|
}
|
||||||
|
else if (treasureName.contains("INK_SACK")) {
|
||||||
|
material = Material.INK_SACK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
material = Material.matchMaterial(treasureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Amount")) {
|
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||||
reason.add("Missing Amount");
|
int data = config.getInt(type + "." + treasureName + ".Data");
|
||||||
|
|
||||||
|
if (material == null) {
|
||||||
|
reason.add("Invalid material: " + treasureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Data")) {
|
if (amount <= 0) {
|
||||||
reason.add("Missing Data");
|
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = config.getInt("Treasures." + treasureName + ".ID");
|
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
|
||||||
int amount = config.getInt("Treasures." + treasureName + ".Amount");
|
reason.add("Data of " + treasureName + " is invalid! " + data);
|
||||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
|
||||||
|
|
||||||
if (Material.getMaterial(id) == null) {
|
|
||||||
reason.add("Invalid id: " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount < 1) {
|
|
||||||
reason.add("Invalid amount: " + amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id < 256 && (data > 127 || data < -128)) {
|
|
||||||
reason.add("Invalid data: " + data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XP, Drop Chance, and Drop Level
|
* XP, Drop Chance, and Drop Level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".XP")) {
|
int xp = config.getInt(type + "." + treasureName + ".XP");
|
||||||
reason.add("Missing XP");
|
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
|
||||||
}
|
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
|
|
||||||
reason.add("Missing Drop_Chance");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
|
|
||||||
reason.add("Missing Drop_Level");
|
|
||||||
}
|
|
||||||
|
|
||||||
int xp = config.getInt("Treasures." + treasureName + ".XP");
|
|
||||||
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
|
|
||||||
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
|
|
||||||
|
|
||||||
if (xp < 0) {
|
if (xp < 0) {
|
||||||
reason.add("Invalid xp: " + xp);
|
reason.add(treasureName + " has an invalid XP value: " + xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropChance < 0) {
|
if (dropChance < 0.0D) {
|
||||||
reason.add("Invalid Drop_Chance: " + dropChance);
|
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropLevel < 0) {
|
if (dropLevel < 0) {
|
||||||
reason.add("Invalid Drop_Level: " + dropLevel);
|
reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Potions
|
* Specific Types
|
||||||
*/
|
*/
|
||||||
|
Rarity rarity = null;
|
||||||
|
|
||||||
|
if (isFishing) {
|
||||||
|
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
|
||||||
|
|
||||||
|
if (rarity == null) {
|
||||||
|
reason.add("Invalid Rarity for item: " + treasureName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Itemstack
|
||||||
|
*/
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
|
|
||||||
if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
|
if (treasureName.contains("POTION")) {
|
||||||
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
|
String potionType = treasureName.substring(7);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
|
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add("Invalid Potion_Type: " + potionType);
|
reason.add("Invalid Potion_Type: " + potionType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (treasureName.contains("INK_SACK")) {
|
||||||
item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
String color = treasureName.substring(9);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Drops From & Max Level
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
||||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
|
||||||
reason.add("This can only be a fishing drop.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
|
||||||
reason.add("Missing Max_Level");
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
|
||||||
|
|
||||||
if (noErrorsInTreasure(reason)) {
|
|
||||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
|
||||||
treasures.put(treasureName, fTreasure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
|
||||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
|
||||||
reason.add("This can only be a shake drop.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.contains("Treasures." + treasureName + ".Mob")) {
|
|
||||||
reason.add("Missing Mob");
|
|
||||||
}
|
|
||||||
|
|
||||||
String mobType = config.getString("Treasures." + treasureName + ".Mob");
|
|
||||||
EntityType mob = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mob = EntityType.valueOf(mobType.toUpperCase().trim());
|
Dye dye = new Dye();
|
||||||
}
|
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||||
catch (IllegalArgumentException ex){
|
|
||||||
reason.add("Invalid Mob: " + mobType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noErrorsInTreasure(reason)) {
|
item = dye.toItemStack(amount);
|
||||||
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
|
}
|
||||||
treasures.put(treasureName, sTreasure);
|
catch (IllegalArgumentException ex) {
|
||||||
|
reason.add("Invalid Dye_Color: " + color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (material != null) {
|
||||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
item = new ItemStack(material, amount, (short) data);
|
||||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
eTreasure.setDropsFromDirt();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
eTreasure.setDropsFromGrass();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
}
|
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
|
|
||||||
eTreasure.setDropsFromSand();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
|
|
||||||
eTreasure.setDropsFromGravel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
|
|
||||||
eTreasure.setDropsFromClay();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
|
|
||||||
eTreasure.setDropsFromMycel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
|
|
||||||
eTreasure.setDropsFromSoulSand();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
|
||||||
hTreasure.setDropsFromBushes();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
|
|
||||||
hTreasure.setDropsFromFlowers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
|
|
||||||
hTreasure.setDropsFromPots();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
||||||
reason.add("This cannot also be a fishing drop.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
|
||||||
reason.add("This cannot also be a shake drop.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
|
||||||
treasures.put(treasureName, eTreasure);
|
|
||||||
}
|
|
||||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
|
|
||||||
treasures.put(treasureName, hTreasure);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
if (noErrorsInConfig(reason)) {
|
||||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
if (isFishing) {
|
||||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||||
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
|
|
||||||
|
|
||||||
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
|
||||||
String treasureKey = nextEntry.getKey();
|
|
||||||
Treasure treasure = nextEntry.getValue();
|
|
||||||
|
|
||||||
if (treasure instanceof FishingTreasure) {
|
|
||||||
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (isShake) {
|
||||||
|
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|
||||||
fishingRewards.add((FishingTreasure) treasure);
|
if (type.equals("Shake.BLAZE")) {
|
||||||
}
|
shakeFromBlaze.add(shakeTreasure);
|
||||||
else if (treasure instanceof ShakeTreasure) {
|
}
|
||||||
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
|
else if (type.equals("Shake.CAVE_SPIDER")) {
|
||||||
continue;
|
shakeFromCaveSpider.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.CHICKEN")) {
|
||||||
|
shakeFromChicken.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.COW")) {
|
||||||
|
shakeFromCow.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.CREEPER")) {
|
||||||
|
shakeFromCreeper.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.ENDERMAN")) {
|
||||||
|
shakeFromEnderman.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.GHAST")) {
|
||||||
|
shakeFromGhast.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.HORSE")) {
|
||||||
|
shakeFromHorse.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.IRON_GOLEM")) {
|
||||||
|
shakeFromIronGolem.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.MAGMA_CUBE")) {
|
||||||
|
shakeFromMagmaCube.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.MUSHROOM_COW")) {
|
||||||
|
shakeFromMushroomCow.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.PIG")) {
|
||||||
|
shakeFromPig.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||||
|
shakeFromPigZombie.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SHEEP")) {
|
||||||
|
shakeFromSheep.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SKELETON")) {
|
||||||
|
shakeFromSkeleton.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SLIME")) {
|
||||||
|
shakeFromSlime.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SPIDER")) {
|
||||||
|
shakeFromSpider.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SNOWMAN")) {
|
||||||
|
shakeFromSnowman.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.SQUID")) {
|
||||||
|
shakeFromSquid.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.WITCH")) {
|
||||||
|
shakeFromWitch.add(shakeTreasure);
|
||||||
|
}
|
||||||
|
else if (type.equals("Shake.ZOMBIE")) {
|
||||||
|
shakeFromZombie.add(shakeTreasure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (isExcavation) {
|
||||||
|
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
ShakeTreasure e = (ShakeTreasure) treasure;
|
if (dropList.contains("Dirt")) {
|
||||||
switch (e.getMob()) {
|
excavationFromDirt.add(excavationTreasure);
|
||||||
case BLAZE:
|
}
|
||||||
shakeFromBlaze.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CAVE_SPIDER:
|
if (dropList.contains("Grass")) {
|
||||||
shakeFromCaveSpider.add(e);
|
excavationFromGrass.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case CHICKEN:
|
if (dropList.contains("Sand")) {
|
||||||
shakeFromChicken.add(e);
|
excavationFromSand.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case COW:
|
if (dropList.contains("Gravel")) {
|
||||||
shakeFromCow.add(e);
|
excavationFromGravel.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case CREEPER:
|
if (dropList.contains("Clay")) {
|
||||||
shakeFromCreeper.add(e);
|
excavationFromClay.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case ENDERMAN:
|
if (dropList.contains("Mycelium")) {
|
||||||
shakeFromEnderman.add(e);
|
excavationFromMycel.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case GHAST:
|
if (dropList.contains("Soul_Sand")) {
|
||||||
shakeFromGhast.add(e);
|
excavationFromSoulSand.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case IRON_GOLEM:
|
if (dropList.contains("Snow")) {
|
||||||
shakeFromIronGolem.add(e);
|
excavationFromSnow.add(excavationTreasure);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case MAGMA_CUBE:
|
|
||||||
shakeFromMagmaCube.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MUSHROOM_COW:
|
|
||||||
shakeFromMushroomCow.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PIG:
|
|
||||||
shakeFromPig.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PIG_ZOMBIE:
|
|
||||||
shakeFromPigZombie.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHEEP:
|
|
||||||
shakeFromSheep.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKELETON:
|
|
||||||
shakeFromSkeleton.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SLIME:
|
|
||||||
shakeFromSlime.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPIDER:
|
|
||||||
shakeFromSpider.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SNOWMAN:
|
|
||||||
shakeFromSnowman.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQUID:
|
|
||||||
shakeFromSquid.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WITCH:
|
|
||||||
shakeFromWitch.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ZOMBIE:
|
|
||||||
shakeFromZombie.add(e);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (treasure instanceof HylianTreasure) {
|
|
||||||
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (isHylian) {
|
||||||
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
if (dropList.contains("Bushes")) {
|
||||||
|
hylianFromBushes.add(hylianTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
if (hTreasure.getDropsFromBushes()) {
|
if (dropList.contains("Flowers")) {
|
||||||
hylianFromBushes.add(hTreasure);
|
hylianFromFlowers.add(hylianTreasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hTreasure.getDropsFromFlowers()) {
|
if (dropList.contains("Pots")) {
|
||||||
hylianFromFlowers.add(hTreasure);
|
hylianFromPots.add(hylianTreasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hTreasure.getDropsFromPots()) {
|
|
||||||
hylianFromPots.add(hTreasure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (treasure instanceof ExcavationTreasure) {
|
|
||||||
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromDirt()) {
|
|
||||||
excavationFromDirt.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromGrass()) {
|
|
||||||
excavationFromGrass.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromSand()) {
|
|
||||||
excavationFromSand.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromGravel()) {
|
|
||||||
excavationFromGravel.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromClay()) {
|
|
||||||
excavationFromClay.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromMycel()) {
|
|
||||||
excavationFromMycel.add(eTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eTreasure.getDropsFromSoulSand()) {
|
|
||||||
excavationFromSoulSand.add(eTreasure);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noErrorsInTreasure(List<String> issues) {
|
private void loadEnchantments() {
|
||||||
for (String issue : issues) {
|
for (Rarity rarity : Rarity.values()) {
|
||||||
plugin.getLogger().warning(issue);
|
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return issues.isEmpty();
|
if (!fishingEnchantments.containsKey(rarity)) {
|
||||||
|
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
|
||||||
|
|
||||||
|
if (enchantmentSection == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
||||||
|
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
||||||
|
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||||
|
|
||||||
|
if (enchantment == null) {
|
||||||
|
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||||
|
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,16 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
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.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
|
||||||
public interface DatabaseManager {
|
public interface DatabaseManager {
|
||||||
// One month in milliseconds
|
// One month in milliseconds
|
||||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||||
|
// During convertUsers, how often to output a status
|
||||||
|
public final int progressInterval = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge users with 0 power level from the database.
|
* Purge users with 0 power level from the database.
|
||||||
@@ -33,8 +37,9 @@ public interface DatabaseManager {
|
|||||||
* Save a user to the database.
|
* Save a user to the database.
|
||||||
*
|
*
|
||||||
* @param profile The profile of the player to save
|
* @param profile The profile of the player to save
|
||||||
|
* @return true if successful, false on failure
|
||||||
*/
|
*/
|
||||||
public void saveUser(PlayerProfile profile);
|
public boolean saveUser(PlayerProfile profile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve leaderboard info.
|
* Retrieve leaderboard info.
|
||||||
@@ -44,15 +49,18 @@ public interface DatabaseManager {
|
|||||||
* @param statsPerPage The number of stats per page
|
* @param statsPerPage The number of stats per page
|
||||||
* @return the requested leaderboard information
|
* @return the requested leaderboard information
|
||||||
*/
|
*/
|
||||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve rank info.
|
* Retrieve rank info into a HashMap from SkillType to the rank.
|
||||||
|
* <p>
|
||||||
|
* The special value <code>null</code> is used to represent the Power
|
||||||
|
* Level rank (the combination of all skill levels).
|
||||||
*
|
*
|
||||||
* @param playerName The name of the user to retrieve the rankings for
|
* @param playerName The name of the user to retrieve the rankings for
|
||||||
* @return the requested rank information
|
* @return the requested rank information
|
||||||
*/
|
*/
|
||||||
public Map<String, Integer> readRank(String playerName);
|
public Map<SkillType, Integer> readRank(String playerName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new user to the database.
|
* Add a new user to the database.
|
||||||
@@ -83,7 +91,14 @@ public interface DatabaseManager {
|
|||||||
* Convert all users from this database to the provided database using
|
* Convert all users from this database to the provided database using
|
||||||
* {@link #saveUser(PlayerProfile)}.
|
* {@link #saveUser(PlayerProfile)}.
|
||||||
*
|
*
|
||||||
* @param the DatabaseManager to save to
|
* @param destination The DatabaseManager to save to
|
||||||
*/
|
*/
|
||||||
public void convertUsers(DatabaseManager destination);
|
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||||
|
|
||||||
public class DatabaseManagerFactory {
|
public class DatabaseManagerFactory {
|
||||||
private static Class<? extends DatabaseManager> customManager = null;
|
private static Class<? extends DatabaseManager> customManager = null;
|
||||||
@@ -9,39 +10,44 @@ public class DatabaseManagerFactory {
|
|||||||
public static DatabaseManager getDatabaseManager() {
|
public static DatabaseManager getDatabaseManager() {
|
||||||
if (customManager != null) {
|
if (customManager != null) {
|
||||||
try {
|
try {
|
||||||
return createCustomDatabaseManager(customManager);
|
return createDefaultCustomDatabaseManager();
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
mcMMO.p.debug("Could not create custom database manager");
|
mcMMO.p.debug("Could not create custom database manager");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Throwable e) {
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
mcMMO.p.debug("Failed to create custom database manager");
|
mcMMO.p.debug("Failed to create custom database manager");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager();
|
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.
|
* called prior to mcMMO enabling.
|
||||||
* <p>
|
* <p/>
|
||||||
* The provided class must have an empty constructor, which is the one
|
* The provided class must have an empty constructor, which is the one
|
||||||
* that will be used.
|
* that will be used.
|
||||||
* <p>
|
* <p/>
|
||||||
* This method is intended for API use, but it should not be considered
|
* This method is intended for API use, but it should not be considered
|
||||||
* stable. This method is subject to change and/or removal in future
|
* stable. This method is subject to change and/or removal in future
|
||||||
* versions.
|
* versions.
|
||||||
*
|
*
|
||||||
* @param man the DatabaseManager class to use
|
* @param clazz the DatabaseManager class to use
|
||||||
|
*
|
||||||
* @throws IllegalArgumentException if the provided class does not have
|
* @throws IllegalArgumentException if the provided class does not have
|
||||||
* an empty constructor
|
* an empty constructor
|
||||||
*/
|
*/
|
||||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||||
try {
|
try {
|
||||||
clazz.getConstructor((Class<?>) null);
|
clazz.getConstructor((Class<?>) null);
|
||||||
customManager = clazz;
|
customManager = clazz;
|
||||||
} catch (Throwable e) {
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
|
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,17 +56,32 @@ public class DatabaseManagerFactory {
|
|||||||
return customManager;
|
return customManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For data conversion purposes
|
public static DatabaseManager createDatabaseManager(DatabaseType type) {
|
||||||
|
switch (type) {
|
||||||
|
case FLATFILE:
|
||||||
|
return new FlatfileDatabaseManager();
|
||||||
|
|
||||||
public static FlatfileDatabaseManager createFlatfileDatabaseManager() {
|
case SQL:
|
||||||
return new FlatfileDatabaseManager();
|
return new SQLDatabaseManager();
|
||||||
|
|
||||||
|
case CUSTOM:
|
||||||
|
try {
|
||||||
|
return createDefaultCustomDatabaseManager();
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SQLDatabaseManager createSQLDatabaseManager() {
|
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
||||||
return new SQLDatabaseManager();
|
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||||
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
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.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public final class FlatfileDatabaseManager implements DatabaseManager {
|
public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||||
@@ -102,7 +102,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
mcMMO.p.getLogger().info("Purging old users...");
|
mcMMO.p.getLogger().info("Purging old users...");
|
||||||
|
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
@@ -117,19 +116,34 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
String name = character[0];
|
String name = character[0];
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
long lastPlayed = 0;
|
||||||
boolean old = true;
|
boolean rewrite = false;
|
||||||
if (player != null) {
|
try {
|
||||||
old = (currentTime - player.getLastPlayed()) > PURGE_TIME;
|
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
if (lastPlayed == 0) {
|
||||||
|
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
|
||||||
|
lastPlayed = player.getLastPlayed();
|
||||||
|
rewrite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!old) {
|
if (currentTime - lastPlayed > PURGE_TIME) {
|
||||||
writer.append(line).append("\r\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
removedPlayers++;
|
removedPlayers++;
|
||||||
Misc.profileCleanup(name);
|
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
|
// Write the new file
|
||||||
@@ -189,7 +203,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveUser(PlayerProfile profile) {
|
public boolean saveUser(PlayerProfile profile) {
|
||||||
String playerName = profile.getPlayerName();
|
String playerName = profile.getPlayerName();
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
@@ -244,8 +258,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
|
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
|
||||||
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
|
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
|
||||||
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
|
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
|
||||||
HudType hudType = profile.getHudType();
|
writer.append(":");
|
||||||
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
|
|
||||||
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
|
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
|
||||||
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
|
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
|
||||||
@@ -259,9 +272,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Write the new file
|
// Write the new file
|
||||||
out = new FileWriter(usersFilePath);
|
out = new FileWriter(usersFilePath);
|
||||||
out.write(writer.toString());
|
out.write(writer.toString());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
tryClose(in);
|
||||||
@@ -270,24 +285,24 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName));
|
List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
|
||||||
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
||||||
|
|
||||||
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> readRank(String playerName) {
|
public Map<SkillType, Integer> readRank(String playerName) {
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
|
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||||
|
|
||||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
skills.put("ALL", getPlayerRank(playerName, powerLevels));
|
skills.put(null, getPlayerRank(playerName, powerLevels));
|
||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
@@ -333,7 +348,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
out.append("0:"); // DATS
|
out.append("0:"); // DATS
|
||||||
out.append("0:"); // DATS
|
out.append("0:"); // DATS
|
||||||
out.append("0:"); // DATS
|
out.append("0:"); // DATS
|
||||||
out.append("STANDARD").append(":"); // HUD
|
out.append(":");
|
||||||
out.append("0:"); // Fishing
|
out.append("0:"); // Fishing
|
||||||
out.append("0:"); // FishingXp
|
out.append("0:"); // FishingXp
|
||||||
out.append("0:"); // Blast Mining
|
out.append("0:"); // Blast Mining
|
||||||
@@ -372,28 +387,41 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile p = loadFromLine(character);
|
PlayerProfile p = loadFromLine(character);
|
||||||
in.close();
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Didn't find the player, create a new one
|
||||||
|
if (create) {
|
||||||
|
newUser(playerName);
|
||||||
|
return new PlayerProfile(playerName, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
// I have no idea why it's necessary to inline tryClose() here, but it removes
|
||||||
|
// a resource leak warning, and I'm trusting the compiler on this one.
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create) {
|
// Return unloaded profile
|
||||||
newUser(playerName);
|
|
||||||
return new PlayerProfile(playerName, true);
|
|
||||||
}
|
|
||||||
return new PlayerProfile(playerName);
|
return new PlayerProfile(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convertUsers(DatabaseManager destination) {
|
public void convertUsers(DatabaseManager destination) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
int convertedUsers = 0;
|
||||||
|
long startMillis = System.currentTimeMillis();
|
||||||
|
|
||||||
synchronized (fileWritingLock) {
|
synchronized (fileWritingLock) {
|
||||||
try {
|
try {
|
||||||
@@ -410,6 +438,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
convertedUsers++;
|
||||||
|
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -421,11 +451,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkConnected() {
|
|
||||||
// Not implemented
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getStoredUsers() {
|
public List<String> getStoredUsers() {
|
||||||
ArrayList<String> users = new ArrayList<String>();
|
ArrayList<String> users = new ArrayList<String>();
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
@@ -480,25 +505,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
|
String playerName = null;
|
||||||
// Read from the FlatFile database and fill our arrays with information
|
// Read from the FlatFile database and fill our arrays with information
|
||||||
synchronized (fileWritingLock) {
|
synchronized (fileWritingLock) {
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(usersFilePath));
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
String line = "";
|
String line = "";
|
||||||
ArrayList<String> players = new ArrayList<String>();
|
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] data = line.split(":");
|
String[] data = line.split(":");
|
||||||
String playerName = data[0];
|
playerName = data[0];
|
||||||
int powerLevel = 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);
|
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||||
|
|
||||||
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
||||||
@@ -518,7 +536,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
tryClose(in);
|
||||||
@@ -569,16 +587,100 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
in = new BufferedReader(new FileReader(usersFilePath));
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line = "";
|
String line = "";
|
||||||
|
HashSet<String> players = new HashSet<String>();
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
|
// Remove empty lines from the file
|
||||||
|
if (line.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length checks depend on last character being ':'
|
||||||
|
if (line.charAt(line.length() - 1) != ':') {
|
||||||
|
line = line + ":";
|
||||||
|
}
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
// If they're valid, rewrite them to the file.
|
// Prevent the same player from being present multiple times
|
||||||
if (character.length >= 37) {
|
if (!players.add(character[0])) {
|
||||||
writer.append(line).append("\r\n");
|
continue;
|
||||||
} else {
|
|
||||||
// Placeholder, repair row if needed (I.E. when new skills are added and such)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (character.length < 33) {
|
||||||
|
// Before Version 1.0 - Drop
|
||||||
|
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String oldVersion = null;
|
||||||
|
|
||||||
|
if (!character[33].isEmpty()) {
|
||||||
|
// Removal of Spout Support
|
||||||
|
// Version 1.4.07-dev2
|
||||||
|
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||||
|
line = line.replace(character[33], "");
|
||||||
|
oldVersion = "1.4.07";
|
||||||
|
}
|
||||||
|
|
||||||
|
// If they're valid, rewrite them to the file.
|
||||||
|
if (character.length > 38) {
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder newLine = new StringBuilder(line);
|
||||||
|
|
||||||
|
if (character.length <= 33) {
|
||||||
|
// Introduction of HUDType
|
||||||
|
// Version 1.1.06
|
||||||
|
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||||
|
newLine.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(":");
|
||||||
|
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 (oldVersion != null) {
|
||||||
|
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.append(newLine).append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the new file
|
// Write the new file
|
||||||
@@ -608,10 +710,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tryClose(Closeable c) {
|
private void tryClose(Closeable c) {
|
||||||
if (c == null) return;
|
if (c == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
c.close();
|
c.close();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -650,7 +755,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||||
HudType hudType;
|
|
||||||
MobHealthbarType mobHealthbarType;
|
MobHealthbarType mobHealthbarType;
|
||||||
|
|
||||||
// TODO on updates, put new values in a try{} ?
|
// TODO on updates, put new values in a try{} ?
|
||||||
@@ -681,13 +785,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Acrobatics - Unused
|
// Acrobatics - Unused
|
||||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||||
|
|
||||||
try {
|
|
||||||
hudType = HudType.valueOf(character[33]);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
||||||
}
|
}
|
||||||
@@ -695,7 +792,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
|
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||||
@@ -716,4 +813,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatabaseType getDatabaseType() {
|
||||||
|
return DatabaseType.FLATFILE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
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.DatabaseUpdateType;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
|
||||||
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
@@ -50,11 +50,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
private int reconnectAttempt = 0;
|
private int reconnectAttempt = 0;
|
||||||
|
|
||||||
protected SQLDatabaseManager() {
|
protected SQLDatabaseManager() {
|
||||||
checkConnected();
|
|
||||||
checkStructure();
|
checkStructure();
|
||||||
|
|
||||||
|
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgePowerlessUsers() {
|
public void purgePowerlessUsers() {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
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();
|
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 +76,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void purgeOldUsers() {
|
public void purgeOldUsers() {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Purging old users...");
|
mcMMO.p.getLogger().info("Purging old users...");
|
||||||
@@ -85,10 +94,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
|
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
|
||||||
|
|
||||||
processPurge(usernames);
|
processPurge(usernames);
|
||||||
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");;
|
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeUser(String playerName) {
|
public boolean removeUser(String playerName) {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean success = update("DELETE FROM u, e, h, s, c " +
|
boolean success = update("DELETE FROM u, e, h, s, c " +
|
||||||
"USING " + tablePrefix + "users u " +
|
"USING " + tablePrefix + "users u " +
|
||||||
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
@@ -102,23 +115,25 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveUser(PlayerProfile profile) {
|
public boolean saveUser(PlayerProfile profile) {
|
||||||
checkConnected();
|
if (!checkConnected()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int userId = readId(profile.getPlayerName());
|
int userId = readId(profile.getPlayerName());
|
||||||
if (userId == -1) {
|
if (userId == -1) {
|
||||||
newUser(profile.getPlayerName());
|
newUser(profile.getPlayerName());
|
||||||
userId = readId(profile.getPlayerName());
|
userId = readId(profile.getPlayerName());
|
||||||
if (userId == -1) {
|
if (userId == -1) {
|
||||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean success = true;
|
||||||
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
||||||
HudType hudType = profile.getHudType();
|
|
||||||
|
|
||||||
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||||
saveHuds(userId, (hudType == null ? "STANDARD" : hudType.toString()), (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
||||||
saveLongs(
|
success &= saveLongs(
|
||||||
"UPDATE " + tablePrefix + "cooldowns SET "
|
"UPDATE " + tablePrefix + "cooldowns SET "
|
||||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||||
+ ", herbalism = ?, excavation = ?, swords = ?"
|
+ ", herbalism = ?, excavation = ?, swords = ?"
|
||||||
@@ -132,7 +147,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
|
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
|
||||||
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
|
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
|
||||||
profile.getSkillDATS(AbilityType.BLAST_MINING));
|
profile.getSkillDATS(AbilityType.BLAST_MINING));
|
||||||
saveIntegers(
|
success &= saveIntegers(
|
||||||
"UPDATE " + tablePrefix + "skills SET "
|
"UPDATE " + tablePrefix + "skills SET "
|
||||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||||
@@ -151,7 +166,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
profile.getSkillLevel(SkillType.ACROBATICS),
|
profile.getSkillLevel(SkillType.ACROBATICS),
|
||||||
profile.getSkillLevel(SkillType.FISHING),
|
profile.getSkillLevel(SkillType.FISHING),
|
||||||
userId);
|
userId);
|
||||||
saveIntegers(
|
success &= saveIntegers(
|
||||||
"UPDATE " + tablePrefix + "experience SET "
|
"UPDATE " + tablePrefix + "experience SET "
|
||||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||||
@@ -170,13 +185,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
profile.getSkillXpLevel(SkillType.ACROBATICS),
|
profile.getSkillXpLevel(SkillType.ACROBATICS),
|
||||||
profile.getSkillXpLevel(SkillType.FISHING),
|
profile.getSkillXpLevel(SkillType.FISHING),
|
||||||
userId);
|
userId);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
||||||
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
String query = skillName.equalsIgnoreCase("ALL") ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skillName;
|
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
@@ -214,14 +230,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> readRank(String playerName) {
|
public Map<SkillType, Integer> readRank(String playerName) {
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||||
String skillName = skillType.name().toLowerCase();
|
String skillName = skillType.name().toLowerCase();
|
||||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
@@ -246,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
skills.put(skillType, rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,7 +299,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put("ALL", rank + resultSet.getRow());
|
skills.put(null, rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,6 +315,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void newUser(String playerName) {
|
public void newUser(String playerName) {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -326,6 +346,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
||||||
|
return loadPlayerProfile(playerName, create, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return new PlayerProfile(playerName, false); // return fake profile if not connected
|
||||||
|
}
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -334,7 +362,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
||||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
||||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||||
+ "h.hudtype, h.mobhealthbar "
|
+ "h.mobhealthbar "
|
||||||
+ "FROM " + tablePrefix + "users u "
|
+ "FROM " + tablePrefix + "users u "
|
||||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||||
@@ -351,7 +379,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
result.close();
|
result.close();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (SQLException e) {}
|
catch (SQLException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.close();
|
result.close();
|
||||||
}
|
}
|
||||||
@@ -371,6 +400,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// Problem, nothing was returned
|
// Problem, nothing was returned
|
||||||
|
|
||||||
|
// Quit if this is second time around
|
||||||
|
if (!retry) {
|
||||||
|
return new PlayerProfile(playerName, false);
|
||||||
|
}
|
||||||
|
|
||||||
// First, read User Id - this is to check for orphans
|
// First, read User Id - this is to check for orphans
|
||||||
|
|
||||||
int id = readId(playerName);
|
int id = readId(playerName);
|
||||||
@@ -379,19 +413,23 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
// There is no such user
|
// There is no such user
|
||||||
if (create) {
|
if (create) {
|
||||||
newUser(playerName);
|
newUser(playerName);
|
||||||
return new PlayerProfile(playerName, true);
|
return loadPlayerProfile(playerName, false, false);
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new PlayerProfile(playerName, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return unloaded profile if can't create
|
||||||
|
return new PlayerProfile(playerName, false);
|
||||||
}
|
}
|
||||||
// There is such a user
|
// There is such a user
|
||||||
writeMissingRows(id);
|
writeMissingRows(id);
|
||||||
// Retry, and abort on re-failure
|
// Retry, and abort on re-failure
|
||||||
return loadPlayerProfile(playerName, false);
|
return loadPlayerProfile(playerName, create, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convertUsers(DatabaseManager destination) {
|
public void convertUsers(DatabaseManager destination) {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -400,7 +438,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
||||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
||||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||||
+ "h.hudtype, h.mobhealthbar "
|
+ "h.mobhealthbar "
|
||||||
+ "FROM " + tablePrefix + "users u "
|
+ "FROM " + tablePrefix + "users u "
|
||||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||||
@@ -409,6 +447,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
+ "WHERE u.user = ?");
|
+ "WHERE u.user = ?");
|
||||||
List<String> usernames = getStoredUsers();
|
List<String> usernames = getStoredUsers();
|
||||||
ResultSet result = null;
|
ResultSet result = null;
|
||||||
|
int convertedUsers = 0;
|
||||||
|
long startMillis = System.currentTimeMillis();
|
||||||
for (String playerName : usernames) {
|
for (String playerName : usernames) {
|
||||||
statement.setString(1, playerName);
|
statement.setString(1, playerName);
|
||||||
try {
|
try {
|
||||||
@@ -420,6 +460,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
convertedUsers++;
|
||||||
|
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
@@ -429,13 +471,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
try {
|
try {
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check connection status and re-establish if dead or stale.
|
* Check connection status and re-establish if dead or stale.
|
||||||
*
|
*
|
||||||
@@ -528,27 +572,32 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
public List<String> getStoredUsers() {
|
public List<String> getStoredUsers() {
|
||||||
ArrayList<String> users = new ArrayList<String>();
|
ArrayList<String> users = new ArrayList<String>();
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
if (checkConnected()) {
|
||||||
stmt = connection.createStatement();
|
Statement stmt = null;
|
||||||
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
|
try {
|
||||||
while (result.next()) {
|
stmt = connection.createStatement();
|
||||||
users.add(result.getString("user"));
|
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);
|
||||||
catch (SQLException e) {
|
}
|
||||||
printErrors(e);
|
finally {
|
||||||
}
|
if (stmt != null) {
|
||||||
finally {
|
try {
|
||||||
if (stmt != null) {
|
stmt.close();
|
||||||
try {
|
}
|
||||||
stmt.close();
|
catch (SQLException e) {
|
||||||
} catch (SQLException e) {
|
// Ignore
|
||||||
// Ignore
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,14 +625,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
connection = null;
|
connection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
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) {
|
catch (ClassNotFoundException ex) {
|
||||||
connection = null;
|
connection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
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 +642,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Checks that the database structure is present and correct
|
* Checks that the database structure is present and correct
|
||||||
*/
|
*/
|
||||||
private void checkStructure() {
|
private void checkStructure() {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||||
+ "`user` varchar(40) NOT NULL,"
|
+ "`user` varchar(40) NOT NULL,"
|
||||||
@@ -600,7 +654,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
|
||||||
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
||||||
+ "PRIMARY KEY (`user_id`)) "
|
+ "PRIMARY KEY (`user_id`)) "
|
||||||
+ "DEFAULT CHARSET=latin1;");
|
+ "DEFAULT CHARSET=latin1;");
|
||||||
@@ -701,6 +754,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
|
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case DROPPED_SPOUT:
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;");
|
||||||
|
return;
|
||||||
|
|
||||||
case KILL_ORPHANS:
|
case KILL_ORPHANS:
|
||||||
mcMMO.p.getLogger().info("Killing orphans");
|
mcMMO.p.getLogger().info("Killing orphans");
|
||||||
write(
|
write(
|
||||||
@@ -807,7 +864,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
|
if (!sql.contains("DROP COLUMN")) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -906,7 +963,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
/**
|
/**
|
||||||
* Get the Integer. Only return first row / first field.
|
* Get the Integer. Only return first row / first field.
|
||||||
*
|
*
|
||||||
* @param sql SQL query to execute
|
* @param statement SQL query to execute
|
||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
private int readInt(PreparedStatement statement) {
|
private int readInt(PreparedStatement statement) {
|
||||||
@@ -985,7 +1042,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveIntegers(String sql, int... args) {
|
private boolean saveIntegers(String sql, int... args) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -997,9 +1054,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
@@ -1013,7 +1072,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveLongs(String sql, int id, long... args) {
|
private boolean saveLongs(String sql, int id, long... args) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1026,9 +1085,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
statement.setInt(i++, id);
|
statement.setInt(i++, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
@@ -1063,7 +1124,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveLogin(int id, long login) {
|
private boolean saveLogin(int id, long login) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1071,9 +1132,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
statement.setLong(1, login);
|
statement.setLong(1, login);
|
||||||
statement.setInt(2, id);
|
statement.setInt(2, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
@@ -1087,18 +1150,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveHuds(int userId, String hudType, String mobHealthBar) {
|
private boolean saveHuds(int userId, String mobHealthBar) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?");
|
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
|
||||||
statement.setString(1, hudType);
|
statement.setString(1, mobHealthBar);
|
||||||
statement.setString(2, mobHealthBar);
|
statement.setInt(2, userId);
|
||||||
statement.setInt(3, userId);
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
@@ -1116,7 +1180,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||||
HudType hudType;
|
|
||||||
MobHealthbarType mobHealthbarType;
|
MobHealthbarType mobHealthbarType;
|
||||||
|
|
||||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
|
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
|
||||||
@@ -1163,13 +1226,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
|
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
|
||||||
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||||
|
|
||||||
try {
|
|
||||||
hudType = HudType.valueOf(result.getString(OFFSET_OTHER + 1));
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
|
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
|
||||||
}
|
}
|
||||||
@@ -1177,7 +1233,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
|
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printErrors(SQLException ex) {
|
private void printErrors(SQLException ex) {
|
||||||
@@ -1185,4 +1241,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatabaseType getDatabaseType() {
|
||||||
|
return DatabaseType.SQL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,5 +7,6 @@ public enum DatabaseUpdateType {
|
|||||||
MOB_HEALTHBARS,
|
MOB_HEALTHBARS,
|
||||||
PARTY_NAMES,
|
PARTY_NAMES,
|
||||||
KILL_ORPHANS,
|
KILL_ORPHANS,
|
||||||
|
DROPPED_SPOUT
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,79 +1,19 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
package com.gmail.nossr50.datatypes.mods;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class CustomBlock {
|
public class CustomBlock {
|
||||||
private int itemID;
|
|
||||||
private byte dataValue;
|
|
||||||
private int xpGain;
|
private int xpGain;
|
||||||
private int tier;
|
private boolean canDoubleDrop;
|
||||||
private ItemStack itemDrop;
|
|
||||||
private int minimumDropAmount;
|
|
||||||
private int maximumDropAmount;
|
|
||||||
|
|
||||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
public CustomBlock(int xpGain, boolean canDoubleDrop) {
|
||||||
this.itemID = itemID;
|
|
||||||
this.dataValue = dataValue;
|
|
||||||
this.xpGain = xpGain;
|
this.xpGain = xpGain;
|
||||||
this.tier = tier;
|
this.canDoubleDrop = canDoubleDrop;
|
||||||
this.itemDrop = itemDrop;
|
|
||||||
this.minimumDropAmount = minimumDropAmount;
|
|
||||||
this.maximumDropAmount = maximumDropAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemID() {
|
|
||||||
return itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemID(int itemID) {
|
|
||||||
this.itemID = itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getDataValue() {
|
|
||||||
return dataValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataValue(byte dataValue) {
|
|
||||||
this.dataValue = dataValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXpGain() {
|
public int getXpGain() {
|
||||||
return xpGain;
|
return xpGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXpGain(int xpGain) {
|
public boolean isDoubleDropEnabled() {
|
||||||
this.xpGain = xpGain;
|
return canDoubleDrop;
|
||||||
}
|
|
||||||
|
|
||||||
public int getTier() {
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTier(int tier) {
|
|
||||||
this.tier = tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemDrop() {
|
|
||||||
return itemDrop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemDrop(ItemStack itemDrop) {
|
|
||||||
this.itemDrop = itemDrop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinimumDropAmount() {
|
|
||||||
return minimumDropAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinimumDropAmount(int minimumDropAmount) {
|
|
||||||
this.minimumDropAmount = minimumDropAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximumDropAmount() {
|
|
||||||
return maximumDropAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaximumDropAmount(int maximumDropAmount) {
|
|
||||||
this.maximumDropAmount = maximumDropAmount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
package com.gmail.nossr50.datatypes.mods;
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CustomEntity {
|
public class CustomEntity {
|
||||||
private int entityID;
|
|
||||||
private EntityType entityType;
|
|
||||||
private double xpMultiplier;
|
private double xpMultiplier;
|
||||||
private boolean canBeTamed;
|
private boolean canBeTamed;
|
||||||
private int tamingXP;
|
private int tamingXP;
|
||||||
@@ -13,9 +10,7 @@ public class CustomEntity {
|
|||||||
private ItemStack callOfTheWildItem;
|
private ItemStack callOfTheWildItem;
|
||||||
private int callOfTheWildAmount;
|
private int callOfTheWildAmount;
|
||||||
|
|
||||||
public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
|
public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
|
||||||
this.entityID = entityID;
|
|
||||||
this.entityType = entityType;
|
|
||||||
this.xpMultiplier = xpMultiplier;
|
this.xpMultiplier = xpMultiplier;
|
||||||
this.canBeTamed = canBeTamed;
|
this.canBeTamed = canBeTamed;
|
||||||
this.tamingXP = tamingXP;
|
this.tamingXP = tamingXP;
|
||||||
@@ -24,67 +19,27 @@ public class CustomEntity {
|
|||||||
this.callOfTheWildAmount = callOfTheWildAmount;
|
this.callOfTheWildAmount = callOfTheWildAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntityID() {
|
|
||||||
return entityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntityID(int entityID) {
|
|
||||||
this.entityID = entityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityType getEntityType() {
|
|
||||||
return entityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntityType(EntityType entityType) {
|
|
||||||
this.entityType = entityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getXpMultiplier() {
|
public double getXpMultiplier() {
|
||||||
return xpMultiplier;
|
return xpMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXpMultiplier(double xpMultiplier) {
|
public boolean canBeTamed() {
|
||||||
this.xpMultiplier = xpMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanBeTamed() {
|
|
||||||
return canBeTamed;
|
return canBeTamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanBeTamed(boolean canBeTamed) {
|
|
||||||
this.canBeTamed = canBeTamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTamingXP() {
|
public int getTamingXP() {
|
||||||
return tamingXP;
|
return tamingXP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTamingXP(int tamingXP) {
|
public boolean canBeSummoned() {
|
||||||
this.tamingXP = tamingXP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanBeSummoned() {
|
|
||||||
return canBeSummoned;
|
return canBeSummoned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanBeSummoned(boolean canBeSummoned) {
|
|
||||||
this.canBeSummoned = canBeSummoned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getCallOfTheWildItem() {
|
public ItemStack getCallOfTheWildItem() {
|
||||||
return callOfTheWildItem;
|
return callOfTheWildItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCallOfTheWildItem(ItemStack callOfTheWildItem) {
|
|
||||||
this.callOfTheWildItem = callOfTheWildItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCallOfTheWildAmount() {
|
public int getCallOfTheWildAmount() {
|
||||||
return callOfTheWildAmount;
|
return callOfTheWildAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCallOfTheWildAmount(int callOfTheWildAmount) {
|
|
||||||
this.callOfTheWildAmount = callOfTheWildAmount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
|
||||||
|
|
||||||
public class CustomItem {
|
|
||||||
protected int itemID;
|
|
||||||
protected short durability;
|
|
||||||
|
|
||||||
public CustomItem(int itemID, short durability) {
|
|
||||||
this.itemID = itemID;
|
|
||||||
this.durability = durability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemID() {
|
|
||||||
return itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemID(int itemID) {
|
|
||||||
this.itemID = itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getDurability() {
|
|
||||||
return durability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDurability(short durability) {
|
|
||||||
this.durability = durability;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
package com.gmail.nossr50.datatypes.mods;
|
||||||
|
|
||||||
public class CustomTool extends CustomItem {
|
public class CustomTool {
|
||||||
private double xpMultiplier;
|
private double xpMultiplier;
|
||||||
private boolean abilityEnabled;
|
private boolean abilityEnabled;
|
||||||
private int tier;
|
private int tier;
|
||||||
|
|
||||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
|
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) {
|
||||||
super(itemID, durability);
|
|
||||||
this.xpMultiplier = xpMultiplier;
|
this.xpMultiplier = xpMultiplier;
|
||||||
this.abilityEnabled = abilityEnabled;
|
this.abilityEnabled = abilityEnabled;
|
||||||
this.tier = tier;
|
this.tier = tier;
|
||||||
@@ -16,23 +15,11 @@ public class CustomTool extends CustomItem {
|
|||||||
return xpMultiplier;
|
return xpMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXpMultiplier(Double xpMultiplier) {
|
|
||||||
this.xpMultiplier = xpMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAbilityEnabled() {
|
public boolean isAbilityEnabled() {
|
||||||
return abilityEnabled;
|
return abilityEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbilityEnabled(boolean abilityEnabled) {
|
|
||||||
this.abilityEnabled = abilityEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTier() {
|
public int getTier() {
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTier(int tier) {
|
|
||||||
this.tier = tier;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.datatypes.party;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public enum ItemShareType {
|
public enum ItemShareType {
|
||||||
LOOT,
|
LOOT,
|
||||||
@@ -30,4 +32,8 @@ public enum ItemShareType {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocaleString() {
|
||||||
|
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user